mirror of
https://github.com/alexgo-io/DefiLlama-Adapters.git
synced 2026-01-12 08:34:23 +08:00
refactor yield-basis
This commit is contained in:
@@ -19,8 +19,7 @@
|
||||
"biggest-files": "node utils/scripts/sortTopFilesByLines.js",
|
||||
"check-bitcoin-duplicates": "node utils/scripts/checkBTCDupsv2.js",
|
||||
"string-timestamp": "node utils/scripts/stringTimestamp.js",
|
||||
"sort-chains": "node projects/helper/getChainList.js",
|
||||
"postinstall": "echo 'run \"npm update @defillama/sdk\" if you want lastest sdk changes' "
|
||||
"sort-chains": "node projects/helper/getChainList.js"
|
||||
},
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
|
||||
@@ -6,24 +6,28 @@ const abi = {
|
||||
}
|
||||
|
||||
const config = {
|
||||
ethereum: { factory: '0x370a449FeBb9411c95bf897021377fe0B7D100c0' }
|
||||
ethereum: { factory: '0x370a449FeBb9411c95bf897021377fe0B7D100c0', crvUSD: '0xf939E0A03FB07F59A73314E73794Be0E57ac1b4E' }
|
||||
}
|
||||
|
||||
Object.keys(config).forEach(chain => {
|
||||
const { factory, } = config[chain]
|
||||
const { factory, crvUSD, } = config[chain]
|
||||
module.exports[chain] = {
|
||||
tvl: async (api) => {
|
||||
const markets = await api.fetchList({ lengthAbi: abi.market_count, itemAbi: abi.markets, target: factory })
|
||||
|
||||
const lpBalances = await api.multiCall({ abi: 'erc20:balanceOf', calls: markets.map(i => ({ target: i.cryptopool, params: i.amm })) })
|
||||
const crvUSDDebt = await api.multiCall({ abi: 'uint256:get_debt', calls: markets.map(i => i.amm) })
|
||||
const lpSupply = await api.multiCall({ abi: 'erc20:totalSupply', calls: markets.map(i => i.cryptopool) })
|
||||
const balanceInLpPools = await api.multiCall({ abi: 'erc20:balanceOf', calls: markets.map(lp => ({ target: lp.asset_token, params: lp.cryptopool })) })
|
||||
const tokensAndOwners = markets.map((m, i) => [m.asset_token, m.amm]) // check if any token is retain in amm contract and put in curve lp contract
|
||||
const crvUSDbalanceInLpPools = await api.multiCall({ abi: 'erc20:balanceOf', calls: markets.map(lp => ({ target: crvUSD, params: lp.cryptopool })) })
|
||||
const tokensAndOwners = markets.map((m,) => [m.asset_token, m.amm]) // check if any token is retain in amm contract and put in curve lp contract
|
||||
|
||||
|
||||
balanceInLpPools.forEach((v, i) => {
|
||||
const ratio = lpBalances[i] / lpSupply[i]
|
||||
api.add(markets[i].asset_token, v * ratio)
|
||||
api.add(crvUSD, crvUSDbalanceInLpPools[i] * ratio)
|
||||
api.add(crvUSD, crvUSDDebt[i] * -1)
|
||||
})
|
||||
|
||||
|
||||
@@ -33,3 +37,4 @@ Object.keys(config).forEach(chain => {
|
||||
})
|
||||
|
||||
module.exports.doublecounted = true // all the tokens end up on curve
|
||||
module.exports.methodology = `Tvl is the value of LP tokens in curve pools minus the value of borrowed crvUSD tokens`
|
||||
Reference in New Issue
Block a user