Skip to content

Commit 0e59dc7

Browse files
committed
refactor yield-basis
1 parent beb2355 commit 0e59dc7

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@
1919
"biggest-files": "node utils/scripts/sortTopFilesByLines.js",
2020
"check-bitcoin-duplicates": "node utils/scripts/checkBTCDupsv2.js",
2121
"string-timestamp": "node utils/scripts/stringTimestamp.js",
22-
"sort-chains": "node projects/helper/getChainList.js",
23-
"postinstall": "echo 'run \"npm update @defillama/sdk\" if you want lastest sdk changes' "
22+
"sort-chains": "node projects/helper/getChainList.js"
2423
},
2524
"author": "",
2625
"license": "ISC",

projects/yield-basis/index.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,28 @@ const abi = {
66
}
77

88
const config = {
9-
ethereum: { factory: '0x370a449FeBb9411c95bf897021377fe0B7D100c0' }
9+
ethereum: { factory: '0x370a449FeBb9411c95bf897021377fe0B7D100c0', crvUSD: '0xf939E0A03FB07F59A73314E73794Be0E57ac1b4E' }
1010
}
1111

1212
Object.keys(config).forEach(chain => {
13-
const { factory, } = config[chain]
13+
const { factory, crvUSD, } = config[chain]
1414
module.exports[chain] = {
1515
tvl: async (api) => {
1616
const markets = await api.fetchList({ lengthAbi: abi.market_count, itemAbi: abi.markets, target: factory })
1717

1818
const lpBalances = await api.multiCall({ abi: 'erc20:balanceOf', calls: markets.map(i => ({ target: i.cryptopool, params: i.amm })) })
19+
const crvUSDDebt = await api.multiCall({ abi: 'uint256:get_debt', calls: markets.map(i => i.amm) })
1920
const lpSupply = await api.multiCall({ abi: 'erc20:totalSupply', calls: markets.map(i => i.cryptopool) })
2021
const balanceInLpPools = await api.multiCall({ abi: 'erc20:balanceOf', calls: markets.map(lp => ({ target: lp.asset_token, params: lp.cryptopool })) })
21-
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
22+
const crvUSDbalanceInLpPools = await api.multiCall({ abi: 'erc20:balanceOf', calls: markets.map(lp => ({ target: crvUSD, params: lp.cryptopool })) })
23+
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
2224

2325

2426
balanceInLpPools.forEach((v, i) => {
2527
const ratio = lpBalances[i] / lpSupply[i]
2628
api.add(markets[i].asset_token, v * ratio)
29+
api.add(crvUSD, crvUSDbalanceInLpPools[i] * ratio)
30+
api.add(crvUSD, crvUSDDebt[i] * -1)
2731
})
2832

2933

@@ -32,4 +36,5 @@ Object.keys(config).forEach(chain => {
3236
}
3337
})
3438

35-
module.exports.doublecounted = true // all the tokens end up on curve
39+
module.exports.doublecounted = true // all the tokens end up on curve
40+
module.exports.methodology = `Tvl is the value of LP tokens in curve pools minus the value of borrowed crvUSD tokens`

0 commit comments

Comments
 (0)