-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
22 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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, | ||
}, | ||
} |