From 0e59dc73f2ec748e036f84451e63426c84dde1a1 Mon Sep 17 00:00:00 2001 From: g1nt0ki <99907941+g1nt0ki@users.noreply.github.com> Date: Wed, 5 Nov 2025 14:17:58 +0100 Subject: [PATCH] refactor yield-basis --- package.json | 3 +-- projects/yield-basis/index.js | 13 +++++++++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 2fb9c218d..1d30cb9ef 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/projects/yield-basis/index.js b/projects/yield-basis/index.js index 9f2a44178..ebeeaefe2 100644 --- a/projects/yield-basis/index.js +++ b/projects/yield-basis/index.js @@ -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) }) @@ -32,4 +36,5 @@ Object.keys(config).forEach(chain => { } }) -module.exports.doublecounted = true // all the tokens end up on curve \ No newline at end of file +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` \ No newline at end of file