Fulcrum is a Defi platform for tokenized margin lending and trading.
Using Fulcrum, you can lend your tokens and earn interests in crypto. Although in principle your tokens can be redeemed any time you want, in practice you need to wait until there is available (non-borrowed) liquidity to claim your loan back. One of the ways you can use HAL is to monitor the liquidity and check when you can claim back your tokens
Lending on Fulcrum is powered by iTokens, which are global lending pools. Each asset has a single iToken equivalent (ETH as iETH, DAI has iDAI, etc.), and has an independent interest rate paid to lenders who have deposited funds into the contract. The interest earned is proportional to the amount of iToken held by each lender. iTokens are minted by transferring the underlying asset to the contract, calling mint, and receiving back an equivalent amount of the iToken (ERC20) at the current iToken price. iTokens have an on-chain API to query current "redemption value".
Using Fulcrum you can lend the following tokens, receiving the equivalent iToken:
Token | iToken | Decimals |
wETH | iETH | 18 |
SAI | iSAI | 18 |
DAI | iDAI | 18 |
USDC | iUSDC | 6 |
USDT | iUSDT | 6 |
SUSD | iSUSD | 18 |
WBTC | iWBTC | 8 |
LINK | iLINK | 18 |
ZRX | iZRX | 18 |
REP | iREP | 18 |
KNC | iKNC | 18 |
You can retrieve your original tokens when the balanceOf()
shows there is enough liquidity for that token.
Take a look at this example:
const Web3 = require('web3');βconst infuraEndPoint = 'https://mainnet.infura.io/v3/FOOBAR'; // Your InfuraEndPointconst web3 = new Web3(new Web3.providers.HttpProvider(infuraEndPoint));βconst WETH = '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'; // WETH addressconst iETH = '0x77f973FCaF871459aa58cd81881Ce453759281bC'; // iETH addressβconst tokenAbi = [{constant: true,inputs: [{name: '_owner',type: 'address',}],name: 'balanceOf',outputs: [{name: 'balance',type: 'uint256',}],payable: false,type: 'function',}];βconst getData = async (token, iToken) => {const tokenInst = await new web3.eth.Contract(tokenAbi, token);const balance = await tokenInst.methods.balanceOf(iToken).call();return console.log('π Balance: ', balance);};βgetData(WETH, iETH);
Using HAL you can create a trigger to check if there is available liquidity to claim your loan back, no coding needed π€.
What do you need?
A HAL account π
The token address
the iToken address
ERC20 tokens usually have 18 decimal digits. So, if you want to check if the total available liquidity is bigger than 1 KNC
, you have to insert 1 000 000 000 000 000 000
.
You can create a trigger programmatically using HAL's GraphQL layer. Simply use this mutation:
mutation {createContractsTrigger(input: {name: "Check liquidity",type: ContractsTrigger,statement: {contract: {address: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2", // ETH addressabi: [...]},inputs: [{type: "address",name: "_owner",value: "0x77f973FCaF871459aa58cd81881Ce453759281bC" // iETH address}],outputFilters: [{parameter: {name: "balance",type: "uint256"},returnIndex: 0,condition: {attribute: "1000000000000000000", // 1 ETHpredicate: "BiggerThan"}}],"method": {"name": "balanceOf"}},actions: [{type: Email,attributes: {body: "Hey!",subject: "You can reedem your loan!",to: []}}]}) {UUID}}
β