Add Liquidity

Get Liquidity

1
import { ChainId, liquidity } from '@neptunemutual/sdk'
2
import { info } from './info.js'
3
import { getProvider } from './provider.js'
4
import { weiAsDollars } from './bn.js'
5
6
const get = async () => {
7
const { key, coverName } = info
8
const provider = getProvider()
9
10
const response = await liquidity.getBalance(ChainId.Mumbai, key, provider)
11
console.info('[%s Liquidity] %s', coverName, weiAsDollars(response.result))
12
}
13
14
get()
15
16
/*****************************************************************************
17
[info] [Compound Finance Cover Liquidity] $200,000.00
18
*****************************************************************************/
Copied!

Add Liquidity

1
import { ChainId, liquidity } from '@neptunemutual/sdk'
2
import { info } from './info.js'
3
import { getProvider } from './provider.js'
4
import { ether, weiAsDollars } from './bn.js'
5
6
const add = async () => {
7
const { key, coverName } = info
8
9
const provider = getProvider()
10
const amount = ether(150_000)
11
12
let response = await liquidity.getBalance(ChainId.Mumbai, key, provider)
13
console.info('[%s Liquidity] Before: %s', coverName, weiAsDollars(response.result))
14
15
await liquidity.approve(ChainId.Mumbai, key, { amount }, provider)
16
response = await liquidity.add(ChainId.Mumbai, key, amount, provider)
17
console.info(response)
18
19
await response.result.wait()
20
21
response = await liquidity.getBalance(ChainId.Mumbai, key, provider)
22
console.info('[%s Liquidity] After: %s', coverName, weiAsDollars(response.result))
23
}
24
25
add()
26
27
/*****************************************************************************
28
[info] [Compound Finance Cover Liquidity] Before: $50,000.00
29
[info] {
30
status: 'Success',
31
result: {
32
nonce: 1,
33
gasPrice: BigNumber { _hex: '0x06fc23ac00', _isBigNumber: true },
34
gasLimit: BigNumber { _hex: '0x02acb4', _isBigNumber: true },
35
to: '0x931c1ac02164790eA8AfBC0C4122650BF9F6dd1c',
36
value: BigNumber { _hex: '0x00', _isBigNumber: true },
37
data: '0x3b57e2bc70726f746f3a636f6e7472616374733a636f7665723a6366633a303100000002000000000000000000000000000000000000000000001fc3842bd1f071c00000',
38
chainId: 80001,
39
v: 160037,
40
r: '0xbf8e2cb36b2b35cf103ec398bfff715b9ba7d6d59f399a1d23d84e10cd4899b3',
41
s: '0x677f04fd0e6bfe936377790cc16e96a1ae68152f8fcf7173d59afc3883af803e',
42
from: '0x076F91C0A411197e6Fce476F37c6385CCeacd26D',
43
hash: '0x4812f3d78c0c668bd17938e23402deb0036374f077f60ef63c2bdf03596409e3',
44
type: null,
45
wait: [Function (anonymous)]
46
}
47
}
48
[info] [Compound Finance Cover Liquidity] After: $200,000.00
49
*****************************************************************************/
Copied!
Last modified 5mo ago