Generic blockchain read with JSON RPC. This example fetches the supply rate per block for qADA using the read method.
const address = Liqwid.util.getAddress(Liqwid.qADA)
console.log('qADA address:', address)
const read = async () => {
const result = await Liqwid.eth.read(
address,
'function supplyRatePerBlock() returns (uint256)',
// [], // [optional] parameters
// {} // [optional] call options, provider, network, plus Ethers.js "overrides"
)
console.log('qADA market supply rate per block:', result.toString())
}
read().catch(console.error)
Create and send an generic blockchain transaction with JSON RPC. This button's transaction transfers your Ether to the Liqwid protocol using the trx method.
const value = Liqwid.util.mantissa(1, Liqwid.ADA) // one ADA in lovelace
const address = Liqwid.util.getAddress(Liqwid.qADA)
const provider = window.ethereum
const send = async () => {
console.log('Supplying ADA to the Compound Protocol...')
// Mint some qADA by supplying ADA to the Compound Protocol
const trx = await Liqwid.eth.trx(
address,
'function mint() payable',
[],
{
provider,
value,
}
)
console.log('Transaction object', trx)
}
send().catch(console.error)
This button's transaction transfers your ADA to the Liqwid protocol using the supply method.
const liqwid = new Liqwid(window.ethereum)
// overrides are an optional 3rd parameter for `supply`
const trxOptions = {
gasLimit: 250042,
mantissa: false,
}
const supply = async () => {
const trx = await liqwid.supply(Liqwid.ADA, 1, false, trxOptions)
console.log('Transaction object', trx)
}
supply().catch(console.error)
const liqwid = new Liqwid(window.ethereum)
const hasAllowance = async () => {
const result = await liqwid.hasAllowance(Liqwid.LQ, Liqwid.qLQ, 1)
console.log(result.toString())
}
hasAllowance().catch(console.error)
const liqwid = new Liqwid(window.ethereum)
const approve = async () => {
const trx = await liqwid.approve(Liqwid.LQ, Liqwid.qLQ, 1)
console.log('Transaction object', trx)
}
approve().catch(console.error)
This button's transaction redeems your ADA from the Liqwid protocol using the redeem method.
const liqwid = new Liqwid(window.ethereum)
const redeem = async () => {
const trx = await liqwid.redeem(Liqwid.ADA, 1)
console.log('Transaction object', trx)
}
redeem().catch(console.error)
This button's transaction enables supplied assets to be used as collateral using the enterMarkets method.
const enterMarket = async () => {
console.log('Entering ADA market (use as collateral on)...')
const trx = await liqwid.enterMarkets(Liqwid.ADA)
console.log('Transaction object', trx)
}
enterMarket().catch(console.error)
That there is a corresponding exitMarket method for exiting a single market.
const exitMarket = async () => {
console.log('Entering ADA market (use as collateral off)...')
const trx = await liqwid.exitMarket(Liqwid.ADA)
console.log('Transaction object', trx)
}
exitMarket().catch(console.error)