diff --git a/projects/zklend/abi.js b/projects/zklend/abi.js index ea2dd5f75656..be9c79fd6b33 100644 --- a/projects/zklend/abi.js +++ b/projects/zklend/abi.js @@ -50,29 +50,7 @@ const staking = [ const stakingAbi = {} staking.forEach(i => stakingAbi[i.name] = i) -const erc20 = [{ - "name": "balanceOf", - "type": "function", - "inputs": [ - { - "name": "account", - "type": "felt" - } - ], - "outputs": [ - { - "name": "balance", - "type": "Uint256" - } - ], - "stateMutability": "view", - "customInput": 'address', -}] -const erc20Abi = {} -erc20.forEach(i => erc20Abi[i.name] = i) - module.exports = { marketAbi, stakingAbi, - erc20Abi } \ No newline at end of file diff --git a/projects/zklend/index.js b/projects/zklend/index.js index d88d7c69a520..721c7b96a298 100644 --- a/projects/zklend/index.js +++ b/projects/zklend/index.js @@ -1,61 +1,42 @@ const ADDRESSES = require('../helper/coreAssets.json') const { multiCall, sumTokens, call } = require('../helper/chain/starknet') -const { marketAbi, stakingAbi, erc20Abi } = require('./abi'); +const { marketAbi, stakingAbi, } = require('./abi'); const market = '0x4c0a5193d58f74fbace4b74dcf65481e734ed1714121bdc571da345540efa05' const stakingContract = '0x0212c219a68c8fe38f37951123d1ec877570dfa891de270aa4f8634c5e60bc23' const assets = [ - ADDRESSES.starknet.WBTC, - ADDRESSES.starknet.ETH, - ADDRESSES.starknet.USDC, - ADDRESSES.starknet.DAI, - ADDRESSES.starknet.DAI_1, - ADDRESSES.starknet.USDT, - ADDRESSES.starknet.WSTETH, - ADDRESSES.starknet.STRK + ADDRESSES.starknet.WBTC, + ADDRESSES.starknet.ETH, + ADDRESSES.starknet.USDC, + ADDRESSES.starknet.DAI, + ADDRESSES.starknet.DAI_1, + ADDRESSES.starknet.USDT, + ADDRESSES.starknet.WSTETH, + ADDRESSES.starknet.STRK ] async function tvl(api) { - return sumTokens({ api, owner: market, tokens: assets }) + return sumTokens({ api, owner: market, tokens: assets }) } async function staking(api) { - const [amountStakedAtStakingContract, amountStakedAtMarketContract] = await Promise.all([ - call({ - target: stakingContract, - abi: stakingAbi.get_total_staked_amount - }), - call({ - target: ADDRESSES.starknet.ZEND, - abi: erc20Abi.balanceOf, - params: [ - market - ] - }) - ]) - const totalStaked = BigInt(amountStakedAtStakingContract) + BigInt(amountStakedAtMarketContract) - api.addTokens( - [ - ADDRESSES.starknet.ZEND - ], - [ - totalStaked - ] - ) + const amountStakedAtStakingContract = await call({ target: stakingContract, abi: stakingAbi.get_total_staked_amount }) + api.add(ADDRESSES.starknet.ZEND, amountStakedAtStakingContract) + return sumTokens({ api, owner: market, tokens: [ADDRESSES.starknet.ZEND] }) } async function borrowed(api) { - let data = await multiCall({ calls: assets, target: market, abi: marketAbi.get_total_debt_for_token }); - data = data.map(i => +i) - api.addTokens(assets, data) + let data = await multiCall({ calls: assets, target: market, abi: marketAbi.get_total_debt_for_token }); + data = data.map(i => +i) + api.addTokens(assets, data) } module.exports = { - methodology: 'Value of user supplied asset on zkLend is considered as TVL', - starknet: { - tvl, - borrowed, - staking, - }, + methodology: 'Value of user supplied asset on zkLend is considered as TVL', + starknet: { + tvl, + borrowed, + staking, + }, }