Add Liquidity

Get Liquidity

import { ChainId, liquidity } from '@neptunemutual/sdk'
import { info } from './info.js'
import { getProvider } from './provider.js'
import { weiAsDollars } from './bn.js'
const get = async () => {
const { key, coverName } = info
const provider = getProvider()
const response = await liquidity.getBalance(ChainId.Mumbai, key, provider)
console.info('[%s Liquidity] %s', coverName, weiAsDollars(response.result))
}
get()
/*****************************************************************************
[info] [Compound Finance Cover Liquidity] $200,000.00
*****************************************************************************/

Add Liquidity

import { ChainId, liquidity } from '@neptunemutual/sdk'
import { info } from './info.js'
import { getProvider } from './provider.js'
import { ether, weiAsDollars } from './bn.js'
const add = async () => {
const { key, coverName } = info
const provider = getProvider()
const amount = ether(150_000)
let response = await liquidity.getBalance(ChainId.Mumbai, key, provider)
console.info('[%s Liquidity] Before: %s', coverName, weiAsDollars(response.result))
await liquidity.approve(ChainId.Mumbai, key, { amount }, provider)
response = await liquidity.add(ChainId.Mumbai, key, amount, provider)
console.info(response)
await response.result.wait()
response = await liquidity.getBalance(ChainId.Mumbai, key, provider)
console.info('[%s Liquidity] After: %s', coverName, weiAsDollars(response.result))
}
add()
/*****************************************************************************
[info] [Compound Finance Cover Liquidity] Before: $50,000.00
[info] {
status: 'Success',
result: {
nonce: 1,
gasPrice: BigNumber { _hex: '0x06fc23ac00', _isBigNumber: true },
gasLimit: BigNumber { _hex: '0x02acb4', _isBigNumber: true },
to: '0x931c1ac02164790eA8AfBC0C4122650BF9F6dd1c',
value: BigNumber { _hex: '0x00', _isBigNumber: true },
data: '0x3b57e2bc70726f746f3a636f6e7472616374733a636f7665723a6366633a303100000002000000000000000000000000000000000000000000001fc3842bd1f071c00000',
chainId: 80001,
v: 160037,
r: '0xbf8e2cb36b2b35cf103ec398bfff715b9ba7d6d59f399a1d23d84e10cd4899b3',
s: '0x677f04fd0e6bfe936377790cc16e96a1ae68152f8fcf7173d59afc3883af803e',
from: '0x076F91C0A411197e6Fce476F37c6385CCeacd26D',
hash: '0x4812f3d78c0c668bd17938e23402deb0036374f077f60ef63c2bdf03596409e3',
type: null,
wait: [Function (anonymous)]
}
}
[info] [Compound Finance Cover Liquidity] After: $200,000.00
*****************************************************************************/