From 535b204e7099a751ff480a9f1fe03f5e4cc2252e Mon Sep 17 00:00:00 2001 From: Vaibhav Valecha Date: Tue, 22 Apr 2025 18:26:58 -0500 Subject: [PATCH 1/9] Update vaults, remove lrt and simply --- projects/ether-fi/index.js | 17 ++++- projects/etherfi-liquid/index.js | 118 +++++++++++++++++++------------ projects/etherfi-lrt/index.js | 41 ----------- projects/helper/coreAssets.json | 2 + 4 files changed, 88 insertions(+), 90 deletions(-) delete mode 100644 projects/etherfi-lrt/index.js diff --git a/projects/ether-fi/index.js b/projects/ether-fi/index.js index 9a2c088fa2..a7601bf709 100644 --- a/projects/ether-fi/index.js +++ b/projects/ether-fi/index.js @@ -12,14 +12,25 @@ module.exports = { ethereum: { staking: staking("0x86B5780b606940Eb59A062aA85a07959518c0161", "0xFe0c30065B384F05761f15d0CC899D4F9F9Cc0eB"), tvl: async ({ timestamp }) => { + let etherfi_tvl = 0 const api = new sdk.ChainApi({ timestamp, chain: 'optimism' }) - await api.getBlock() + const block = await api.getBlock() + //total tvl not stake tvl + if (block < 122693890) { + etherfi_tvl = await api.call({ target: '0x6329004E903B7F420245E7aF3f355186f2432466', abi: 'uint256:getTvl' }) + } else { + etherfi_tvl = await api.call({ target: '0xAB7590CeE3Ef1A863E9A5877fBB82D9bE11504da', abi: 'function categoryTVL(string _category) view returns (uint256)', params: ['tvl'] }) + } + return { - [nullAddress]: await api.call({ target: '0x6329004E903B7F420245E7aF3f355186f2432466', abi: 'uint256:getTvl' }) + [nullAddress]: etherfi_tvl } } }, - arbitrum:{ + arbitrum: { staking: staking("0x86B5780b606940Eb59A062aA85a07959518c0161", "0x7189fb5b6504bbff6a852b13b7b82a3c118fdc27") + }, + base: { + staking: staking("0x86B5780b606940Eb59A062aA85a07959518c0161", "0x6C240DDA6b5c336DF09A4D011139beAAa1eA2Aa2") } } diff --git a/projects/etherfi-liquid/index.js b/projects/etherfi-liquid/index.js index bc6001deb4..102e52cdca 100644 --- a/projects/etherfi-liquid/index.js +++ b/projects/etherfi-liquid/index.js @@ -1,59 +1,85 @@ const ADDRESSES = require('../helper/coreAssets.json') const sdk = require('@defillama/sdk') -const liquidVaults = [ - "0xf0bb20865277aBd641a307eCe5Ee04E79073416C", - "0x08c6F91e2B681FaF5e17227F2a44C307b3C1364C" -] -const liquidAccountants = [ - "0x0d05D94a5F1E76C18fbeB7A13d17C8a314088198", - "0xc315D6e14DDCDC7407784e2Caf815d131Bc1D3E7" -] + +const vault_config = { + 'eth': { + 'vaults': [ + '0xf0bb20865277aBd641a307eCe5Ee04E79073416C',//eth liq + '0x917ceE801a67f933F2e6b33fC0cD1ED2d5909D88',//weeths + '0x7223442cad8e9cA474fC40109ab981608F8c4273',//weethk + '0x83599937c2C9bEA0E0E8ac096c6f32e86486b410', //beraEth + '0xca8711dAF13D852ED2121E4bE3894Dae366039E4', //move + ], + 'accountant': [ + '0x0d05D94a5F1E76C18fbeB7A13d17C8a314088198', //eth liq + '0xbe16605B22a7faCEf247363312121670DFe5afBE', //weeths + '0x126af21dc55C300B7D0bBfC4F3898F558aE8156b', //weethk + '0x04B8136820598A4e50bEe21b8b6a23fE25Df9Bd8', //beraEth + '0x075e60550C6f77f430B284E76aF699bC31651f75', //move + ], + 'base': ADDRESSES.ethereum.EETH, + 'decimals': 18 + }, + 'btc': { + 'vaults': [ + '0x5f46d540b6eD704C3c8789105F30E075AA900726', //btc liq + '0xC673ef7791724f0dcca38adB47Fbb3AEF3DB6C80', //beraBtc + ], + 'accountant': [ + '0xEa23aC6D7D11f6b181d6B98174D334478ADAe6b0', //btc liq + '0xF44BD12956a0a87c2C20113DdFe1537A442526B5', //beraBtc + ], + 'base': ADDRESSES.ethereum.EBTC, + 'decimals': 8 + }, + 'usd': { + 'vaults': [ + '0x08c6F91e2B681FaF5e17227F2a44C307b3C1364C', //usd liq + '0x352180974C71f84a934953Cf49C4E538a6F9c997', //exilir + '0xeDa663610638E6557c27e2f4e973D3393e844E70', //mev + '0xbc0f3B23930fff9f4894914bD745ABAbA9588265', //ultra + ], + 'accountant': [ + '0xc315D6e14DDCDC7407784e2Caf815d131Bc1D3E7', //usd liq + '0xBae19b38Bf727Be64AF0B578c34985c3D612e2Ba', //exilir + '0x1D4F0F05e50312d3E7B65659Ef7d06aa74651e0C', //mev + '0x95fE19b324bE69250138FE8EE50356e9f6d17Cfe', //ultra + ], + 'base': ADDRESSES.ethereum.EUSD, + 'decimals': 18 + } +} + +async function updateVaultTvl(api, config) { + const { vaults, accountant, base } = config + const baseDecimals = config.decimals + + const vaultsSupply = await api.multiCall({ calls: vaults, abi: 'uint256:totalSupply' }) + const quotes = await api.multiCall({ calls: accountant, abi: 'uint256:getRate' }) + const decimals = await api.multiCall({ calls: accountant, abi: 'uint256:decimals' }) + + for (let i = 0; i < vaultsSupply.length; i++) { + const vaultSupply = vaultsSupply[i] + const quote = quotes[i] + const decimal = decimals[i] + + api.add(base, (vaultSupply / 10 ** decimal) * (quote / 10 ** decimal) * 10 ** baseDecimals) + } +} + async function tvl(api) { - const optimismApi = new sdk.ChainApi({ chain: 'optimism', timestamp: api.timestamp }) - await optimismApi.getBlock() - const wethBal = await optimismApi.call({ - target: '0xAB7590CeE3Ef1A863E9A5877fBB82D9bE11504da', - abi: 'function categoryTVL(string _category) view returns (uint256)', - params: ['liquid-weth'] - }); - const updatedTimestamp = await optimismApi.call({ - target: '0xAB7590CeE3Ef1A863E9A5877fBB82D9bE11504da', - abi: 'function categoryLastUpdated(string _category) view returns (uint256)', - params: ['liquid-weth'] - }); - - //eth vault - const balETH = await api.call({ - abi: "uint256:totalSupply", - target: liquidVaults[0], - }); - const ethQuote = await api.call({ - target: liquidAccountants[0], - abi: 'function getRate() view returns (uint256)' - }); - if (api.timestamp - updatedTimestamp > 12 * 60 * 60) { - throw new Error('Data is outdated') + for (const config of Object.values(vault_config)) { + await updateVaultTvl(api, config) } - api.add(ADDRESSES.ethereum.EETH, BigInt(balETH) * BigInt(ethQuote) / BigInt(1e18) - BigInt(wethBal)); - api.add(ADDRESSES.ethereum.WETH, wethBal) - //usdc vault - const balUSD = await api.call({ - abi: "uint256:totalSupply", - target: liquidVaults[1], - }); - const usdQuote = await api.call({ - target: liquidAccountants[1], - abi: 'function getRate() view returns (uint256)' - }); - api.add(ADDRESSES.ethereum.USDC, balUSD * usdQuote / 1e6); } module.exports = { doublecounted: true, + misrepresentedTokens: true, ethereum: { - tvl, + tvl: tvl, }, -}; +} diff --git a/projects/etherfi-lrt/index.js b/projects/etherfi-lrt/index.js deleted file mode 100644 index 78604fcdee..0000000000 --- a/projects/etherfi-lrt/index.js +++ /dev/null @@ -1,41 +0,0 @@ -const ADDRESSES = require('../helper/coreAssets.json') - -const vaults = [ - '0x917ceE801a67f933F2e6b33fC0cD1ED2d5909D88', - '0x7223442cad8e9cA474fC40109ab981608F8c4273', - '0x657e8C867D8B37dCC18fA4Caead9C45EB088C642', - '0x352180974C71f84a934953Cf49C4E538a6F9c997', - '0xeDa663610638E6557c27e2f4e973D3393e844E70', -] - -const vaultAccountant = [ - '0xbe16605B22a7faCEf247363312121670DFe5afBE', - '0x126af21dc55C300B7D0bBfC4F3898F558aE8156b', - '0x1b293DC39F94157fA0D1D36d7e0090C8B8B8c13F', - '0xBae19b38Bf727Be64AF0B578c34985c3D612e2Ba', - '0x1D4F0F05e50312d3E7B65659Ef7d06aa74651e0C', -] - -async function vaultsTvl(api) { - const supplies = await api.multiCall({ calls: vaults, abi: 'uint256:totalSupply' }) - const quotes = await api.multiCall({ calls: vaultAccountant, abi: 'uint256:getRate' }) - const bases = await api.multiCall({ calls: vaultAccountant, abi: 'address:base' }) - for (let i = 0; i < vaults.length; i++) { - const bvSupply = supplies[i] - let base = bases[i] - const quote = quotes[i] - if (base.toLowerCase() === ADDRESSES.ethereum.WETH.toLowerCase()) - base = ADDRESSES.ethereum.EETH - - const denominator = Math.pow(10, (String(quote).length - 1)) - api.add(base, bvSupply * quote / denominator) - } -} - -module.exports = { - doublecounted: true, - misrepresentedTokens: true, - ethereum: { - tvl: vaultsTvl, - }, -} \ No newline at end of file diff --git a/projects/helper/coreAssets.json b/projects/helper/coreAssets.json index e6454a49ce..92ad25e2fd 100644 --- a/projects/helper/coreAssets.json +++ b/projects/helper/coreAssets.json @@ -49,6 +49,8 @@ "cbETH": "0xBe9895146f7AF43049ca1c1AE358B0541Ea49704", "FDUSD": "0xc5f0f7b66764f6ec8c8dff7ba683102295e16409", "EETH": "0x35fa164735182de50811e8e2e824cfb9b6118ac2", + "EUSD": "0x939778D83b46B456224A33Fb59630B11DEC56663", + "EBTC": "0x657e8C867D8B37dCC18fA4Caead9C45EB088C642", "AEVO": "0xB528edBef013aff855ac3c50b381f253aF13b997", "STONE": "0x4d831e22f062b5327dfdb15f0b6a5df20e2e3dd0", "USDM": "0x59D9356E565Ab3A36dD77763Fc0d87fEaf85508C", From 4c84cf30a2fabe8dd7cb63a2b4a027a0d3bc9b74 Mon Sep 17 00:00:00 2001 From: Vaibhav Valecha Date: Tue, 22 Apr 2025 18:37:48 -0500 Subject: [PATCH 2/9] add eusd and ebtc --- projects/ether-fi/index.js | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/projects/ether-fi/index.js b/projects/ether-fi/index.js index a7601bf709..e0d88e6cde 100644 --- a/projects/ether-fi/index.js +++ b/projects/ether-fi/index.js @@ -1,6 +1,38 @@ const { nullAddress } = require("../helper/unwrapLPs"); const sdk = require('@defillama/sdk') +async function updateEbtcTvl(api) { + const chains = ['ethereum', 'base', 'berachain', 'corn', 'scroll'] + for (const chain of chains) { + let chainApi = new sdk.ChainApi({ chain: chain, timestamp: api.timestamp }) + if (chain === 'ethereum') { + chainApi = api; + } + const btcBal = await chainApi.call({ + target: '0x657e8C867D8B37dCC18fA4Caead9C45EB088C642', + abi: 'uint256:totalSupply' + }); + api.add(ADDRESSES.ethereum.EBTC, btcBal); + } + return +} + +async function updateEusdTvl(api) { + const chains = ['ethereum', 'scroll'] + for (const chain of chains) { + let chainApi = new sdk.ChainApi({ chain: chain, timestamp: api.timestamp }) + if (chain === 'ethereum') { + chainApi = api; + } + const eusdBal = await chainApi.call({ + target: '0x939778D83b46B456224A33Fb59630B11DEC56663', + abi: 'uint256:totalSupply' + }); + api.add(ADDRESSES.ethereum.EUSD, eusdBal); + } + return +} + function staking(contract, token) { return async (api) => { api.add(token, await api.call({ target: contract, abi: 'erc20:totalSupply'})) From d71e7bcd632464c9081b201a7917c50fb379134f Mon Sep 17 00:00:00 2001 From: Vaibhav Valecha Date: Wed, 23 Apr 2025 21:36:23 -0500 Subject: [PATCH 3/9] split for the chains --- projects/ether-fi/index.js | 63 ++++++++++++++++---------------------- 1 file changed, 27 insertions(+), 36 deletions(-) diff --git a/projects/ether-fi/index.js b/projects/ether-fi/index.js index e0d88e6cde..5aff43cb2f 100644 --- a/projects/ether-fi/index.js +++ b/projects/ether-fi/index.js @@ -1,49 +1,32 @@ const { nullAddress } = require("../helper/unwrapLPs"); +const ADDRESSES = require('../helper/coreAssets.json') const sdk = require('@defillama/sdk') -async function updateEbtcTvl(api) { - const chains = ['ethereum', 'base', 'berachain', 'corn', 'scroll'] - for (const chain of chains) { - let chainApi = new sdk.ChainApi({ chain: chain, timestamp: api.timestamp }) - if (chain === 'ethereum') { - chainApi = api; - } - const btcBal = await chainApi.call({ - target: '0x657e8C867D8B37dCC18fA4Caead9C45EB088C642', - abi: 'uint256:totalSupply' - }); - api.add(ADDRESSES.ethereum.EBTC, btcBal); - } - return -} - -async function updateEusdTvl(api) { - const chains = ['ethereum', 'scroll'] - for (const chain of chains) { - let chainApi = new sdk.ChainApi({ chain: chain, timestamp: api.timestamp }) - if (chain === 'ethereum') { - chainApi = api; - } - const eusdBal = await chainApi.call({ - target: '0x939778D83b46B456224A33Fb59630B11DEC56663', - abi: 'uint256:totalSupply' - }); - api.add(ADDRESSES.ethereum.EUSD, eusdBal); +function staking(contract, token) { + return async (api) => { + api.add(token, await api.call({ target: contract, abi: 'erc20:totalSupply'})) } - return } -function staking(contract, token) { +function multiAssetStaking(contracts, tokens) { return async (api) => { - api.add(token, await api.call({ target: contract, abi: 'erc20:totalSupply'})) + for (let i = 0; i < contracts.length; i++) { + api.add(tokens[i], await api.call({ target: contracts[i], abi: 'erc20:totalSupply'})) + } } } module.exports = { doublecounted: true, ethereum: { - staking: staking("0x86B5780b606940Eb59A062aA85a07959518c0161", "0xFe0c30065B384F05761f15d0CC899D4F9F9Cc0eB"), - tvl: async ({ timestamp }) => { + //etherfi stake page is supply of staked : eeth, ebtc, eusd, ethfi + staking: staking("0x86B5780b606940Eb59A062aA85a07959518c0161", "0xFe0c30065B384F05761f15d0CC899D4F9F9Cc0eB"), //ethfi + staking: staking("0x35fA164735182de50811E8e2E824cFb9B6118ac2", "0x35fA164735182de50811E8e2E824cFb9B6118ac2"), //eeth + staking: staking("0x657e8C867D8B37dCC18fA4Caead9C45EB088C642", "0x657e8C867D8B37dCC18fA4Caead9C45EB088C642"), //ebtc + staking: staking("0x939778D83b46B456224A33Fb59630B11DEC56663", "0x939778D83b46B456224A33Fb59630B11DEC56663"), //eusd + + //total tvl (not stake tvl) + tvl: async ({ timestamp }) => { let etherfi_tvl = 0 const api = new sdk.ChainApi({ timestamp, chain: 'optimism' }) const block = await api.getBlock() @@ -60,9 +43,17 @@ module.exports = { } }, arbitrum: { - staking: staking("0x86B5780b606940Eb59A062aA85a07959518c0161", "0x7189fb5b6504bbff6a852b13b7b82a3c118fdc27") + staking: staking("0x86B5780b606940Eb59A062aA85a07959518c0161", "0x7189fb5b6504bbff6a852b13b7b82a3c118fdc27") //ethfi + }, + base: { //etherfi stake should increase these as they are not on ethereum mainnet + staking: staking("0x86B5780b606940Eb59A062aA85a07959518c0161", "0x7189fb5b6504bbff6a852b13b7b82a3c118fdc27"), //ethfi + staking: staking("0x657e8C867D8B37dCC18fA4Caead9C45EB088C642", "0x657e8C867D8B37dCC18fA4Caead9C45EB088C642"), //ebtc, + }, + berachain: { //etherfi stake should increase these as they are not on ethereum mainnet + staking: staking("0x657e8C867D8B37dCC18fA4Caead9C45EB088C642", "0x657e8C867D8B37dCC18fA4Caead9C45EB088C642") //ebtc }, - base: { - staking: staking("0x86B5780b606940Eb59A062aA85a07959518c0161", "0x6C240DDA6b5c336DF09A4D011139beAAa1eA2Aa2") + scroll: { //etherfi stake should increase these as they are not on ethereum mainnet + staking: staking("0x657e8C867D8B37dCC18fA4Caead9C45EB088C642", "0x657e8C867D8B37dCC18fA4Caead9C45EB088C642"), //ebtc, + staking: staking("0x939778D83b46B456224A33Fb59630B11DEC56663", "0x939778D83b46B456224A33Fb59630B11DEC56663") //eusd } } From dc256bc0f51143f542de4c4f26f0a9a6c079f806 Mon Sep 17 00:00:00 2001 From: Vaibhav Valecha Date: Wed, 30 Apr 2025 18:32:26 -0400 Subject: [PATCH 4/9] fix issues in pr --- projects/ether-fi/index.js | 85 +++++++++++++++++++++----------- projects/etherfi-liquid/index.js | 21 ++++++-- 2 files changed, 72 insertions(+), 34 deletions(-) diff --git a/projects/ether-fi/index.js b/projects/ether-fi/index.js index 5aff43cb2f..9adf090bed 100644 --- a/projects/ether-fi/index.js +++ b/projects/ether-fi/index.js @@ -8,52 +8,79 @@ function staking(contract, token) { } } -function multiAssetStaking(contracts, tokens) { - return async (api) => { - for (let i = 0; i < contracts.length; i++) { - api.add(tokens[i], await api.call({ target: contracts[i], abi: 'erc20:totalSupply'})) - } +WBTC = {'ethereum': '0x2260fac5e5542a773aa44fbcfedf7c193bc2c599', 'arbitrum': '0x2f2a2543b76a4166549f7aab2e75bef0aefc5b0f', 'berachain': '0x0555e30da8f98308edb960aa94c0db47230d2b9c',} +LBTC = {'ethereum':'0x8236a87084f8b84306f72007f36f2618a5634494', 'base': '0xecac9c5f704e954931349da37f60e39f515c11c1', 'berachain': '0xecac9c5f704e954931349da37f60e39f515c11c1', } +CBBTC = {'ethereum': '0xcbb7c0000ab88b473b1f5afd9ef808440eed33bf', 'base': '0xcbb7c0000ab88b473b1f5afd9ef808440eed33bf', 'arbitrum': '0xcbb7c0000ab88b473b1f5afd9ef808440eed33bf'} + +async function ebtc_staking(timestamp) { + const api = new sdk.ChainApi({ timestamp, chain: 'ethereum' }) + const EBTC = '0x657e8C867D8B37dCC18fA4Caead9C45EB088C642' + //ethereum, arb , berachain, base + //'ethereum-karak':'0x468c34703F6c648CCf39DBaB11305D17C70ba011', 'ethereum-karak': '0x9C0823D3A1172F9DdF672d438dec79c39a64f448' + let wbtc_held = 0 + let lbtc_held = 0 + let cbbtc_held = 0 + for (const chain in WBTC) { + const api = new sdk.ChainApi({ timestamp, chain: chain }) + const token = WBTC[chain] + const supply = await api.call({ target: token, abi: 'erc20:balanceOf', params: [EBTC] }) + wbtc_held += parseInt(supply) + } + + for (const chain in LBTC) { + const api = new sdk.ChainApi({ timestamp, chain: chain }) + const token = LBTC[chain] + const supply = await api.call({ target: token, abi: 'erc20:balanceOf', params: [EBTC] }) + lbtc_held += parseInt(supply) + } + for (const chain in CBBTC) { + const api = new sdk.ChainApi({ timestamp, chain: chain }) + const token = CBBTC[chain] + const supply = await api.call({ target: token, abi: 'erc20:balanceOf', params: [EBTC] }) + cbbtc_held += parseInt(supply) } + //karak and symbiotic + const lbtc_karak = await api.call({ target: '0x468c34703F6c648CCf39DBaB11305D17C70ba011', abi: 'erc20:balanceOf', params: [EBTC] }) + const wbtc_karak = await api.call({ target: '0x126d4dBf752AaF61f3eAaDa24Ab0dB84FEcf6891', abi: 'erc20:balanceOf', params: [EBTC] }) + const lbtc_symbiotic = await api.call({ target: '0x9C0823D3A1172F9DdF672d438dec79c39a64f448', abi: 'erc20:balanceOf', params: [EBTC] }) + const wbtc_symbiotic = await api.call({ target: '0x971e5b5D4baa5607863f3748FeBf287C7bf82618', abi: 'erc20:balanceOf', params: [EBTC] }) + const holder_address = '0xd4E20ECA1f996Dab35883dC0AD5E3428AF888D45'; + const lbtc_held_holder = await api.call({ target: LBTC['ethereum'], abi: 'erc20:balanceOf', params: [holder_address] }) + lbtc_held += parseInt(lbtc_karak) + parseInt(lbtc_symbiotic) + parseInt(lbtc_held_holder) + wbtc_held += parseInt(wbtc_karak) + parseInt(wbtc_symbiotic) + + return [lbtc_held, wbtc_held, cbbtc_held] } module.exports = { doublecounted: true, ethereum: { - //etherfi stake page is supply of staked : eeth, ebtc, eusd, ethfi staking: staking("0x86B5780b606940Eb59A062aA85a07959518c0161", "0xFe0c30065B384F05761f15d0CC899D4F9F9Cc0eB"), //ethfi - staking: staking("0x35fA164735182de50811E8e2E824cFb9B6118ac2", "0x35fA164735182de50811E8e2E824cFb9B6118ac2"), //eeth - staking: staking("0x657e8C867D8B37dCC18fA4Caead9C45EB088C642", "0x657e8C867D8B37dCC18fA4Caead9C45EB088C642"), //ebtc - staking: staking("0x939778D83b46B456224A33Fb59630B11DEC56663", "0x939778D83b46B456224A33Fb59630B11DEC56663"), //eusd - //total tvl (not stake tvl) tvl: async ({ timestamp }) => { - let etherfi_tvl = 0 + const [lbtc_held, wbtc_held, cbbtc_held] = await ebtc_staking(timestamp) + console.log(lbtc_held, wbtc_held, cbbtc_held) const api = new sdk.ChainApi({ timestamp, chain: 'optimism' }) - const block = await api.getBlock() - //total tvl not stake tvl - if (block < 122693890) { - etherfi_tvl = await api.call({ target: '0x6329004E903B7F420245E7aF3f355186f2432466', abi: 'uint256:getTvl' }) - } else { - etherfi_tvl = await api.call({ target: '0xAB7590CeE3Ef1A863E9A5877fBB82D9bE11504da', abi: 'function categoryTVL(string _category) view returns (uint256)', params: ['tvl'] }) - } - + const ethereum_api = new sdk.ChainApi({ timestamp, chain: 'ethereum' }) + const eth_supply = await api.call({ target: '0x6329004E903B7F420245E7aF3f355186f2432466', abi: 'uint256:getTvl' }) + const looped_tvl = await api.call({ target: '0xAB7590CeE3Ef1A863E9A5877fBB82D9bE11504da', abi: 'function categoryTVL(string _category) view returns (uint256)', params: ['liquideth'] }) + console.log("looped_tvl", looped_tvl) + console.log("eth_supply", eth_supply) + const etherfi_eth_tvl = eth_supply - looped_tvl + const eusd = await ethereum_api.call({ target: '0x939778D83b46B456224A33Fb59630B11DEC56663', abi: 'uint256:totalSupply' }) / 10 ** 12 return { - [nullAddress]: etherfi_tvl + [nullAddress]: etherfi_eth_tvl, + [ADDRESSES.ethereum.USDC]: eusd, + [LBTC['ethereum']]: lbtc_held, + [WBTC['ethereum']]: wbtc_held, + [CBBTC['ethereum']]: cbbtc_held, } } }, arbitrum: { staking: staking("0x86B5780b606940Eb59A062aA85a07959518c0161", "0x7189fb5b6504bbff6a852b13b7b82a3c118fdc27") //ethfi }, - base: { //etherfi stake should increase these as they are not on ethereum mainnet + base: { staking: staking("0x86B5780b606940Eb59A062aA85a07959518c0161", "0x7189fb5b6504bbff6a852b13b7b82a3c118fdc27"), //ethfi - staking: staking("0x657e8C867D8B37dCC18fA4Caead9C45EB088C642", "0x657e8C867D8B37dCC18fA4Caead9C45EB088C642"), //ebtc, }, - berachain: { //etherfi stake should increase these as they are not on ethereum mainnet - staking: staking("0x657e8C867D8B37dCC18fA4Caead9C45EB088C642", "0x657e8C867D8B37dCC18fA4Caead9C45EB088C642") //ebtc - }, - scroll: { //etherfi stake should increase these as they are not on ethereum mainnet - staking: staking("0x657e8C867D8B37dCC18fA4Caead9C45EB088C642", "0x657e8C867D8B37dCC18fA4Caead9C45EB088C642"), //ebtc, - staking: staking("0x939778D83b46B456224A33Fb59630B11DEC56663", "0x939778D83b46B456224A33Fb59630B11DEC56663") //eusd - } } diff --git a/projects/etherfi-liquid/index.js b/projects/etherfi-liquid/index.js index 102e52cdca..81e3a1325d 100644 --- a/projects/etherfi-liquid/index.js +++ b/projects/etherfi-liquid/index.js @@ -47,26 +47,37 @@ const vault_config = { '0x1D4F0F05e50312d3E7B65659Ef7d06aa74651e0C', //mev '0x95fE19b324bE69250138FE8EE50356e9f6d17Cfe', //ultra ], - 'base': ADDRESSES.ethereum.EUSD, - 'decimals': 18 + 'base': ADDRESSES.ethereum.USDC, + 'decimals': 6 } } async function updateVaultTvl(api, config) { + const timestamp = api.timestamp const { vaults, accountant, base } = config const baseDecimals = config.decimals + const optimism_api = new sdk.ChainApi({ timestamp, chain: 'optimism' }) const vaultsSupply = await api.multiCall({ calls: vaults, abi: 'uint256:totalSupply' }) const quotes = await api.multiCall({ calls: accountant, abi: 'uint256:getRate' }) const decimals = await api.multiCall({ calls: accountant, abi: 'uint256:decimals' }) - + let amount = 0 for (let i = 0; i < vaultsSupply.length; i++) { const vaultSupply = vaultsSupply[i] const quote = quotes[i] const decimal = decimals[i] - - api.add(base, (vaultSupply / 10 ** decimal) * (quote / 10 ** decimal) * 10 ** baseDecimals) + amount += (vaultSupply / 10 ** decimal) * (quote / 10 ** decimal) * 10 ** baseDecimals + } + if(base === ADDRESSES.ethereum.EBTC) { + const wbtc = 100 * 10 ** 8 //await optimism_api.call({ target: '0xAB7590CeE3Ef1A863E9A5877fBB82D9bE11504da', abi: 'function categoryTVL(string _category) view returns (uint256)', params: ['liquid-v2-wbtc'] }) + amount -= wbtc + api.add(ADDRESSES.ethereum.WBTC, wbtc) + } else if(base === ADDRESSES.ethereum.EETH) { + const weth = await optimism_api.call({ target: '0xAB7590CeE3Ef1A863E9A5877fBB82D9bE11504da', abi: 'function categoryTVL(string _category) view returns (uint256)', params: ['liquid-v2-weth'] }) + amount -= weth + api.add(ADDRESSES.ethereum.WETH, weth) } + api.add(base, amount) } From 60e515952ca44fe19d00bdc4b53786a581f22dd4 Mon Sep 17 00:00:00 2001 From: Vaibhav Valecha Date: Thu, 1 May 2025 01:47:29 -0400 Subject: [PATCH 5/9] add non etherfi tvl of vaults --- projects/etherfi-liquid/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/projects/etherfi-liquid/index.js b/projects/etherfi-liquid/index.js index 81e3a1325d..019b2fa0ef 100644 --- a/projects/etherfi-liquid/index.js +++ b/projects/etherfi-liquid/index.js @@ -69,11 +69,11 @@ async function updateVaultTvl(api, config) { amount += (vaultSupply / 10 ** decimal) * (quote / 10 ** decimal) * 10 ** baseDecimals } if(base === ADDRESSES.ethereum.EBTC) { - const wbtc = 100 * 10 ** 8 //await optimism_api.call({ target: '0xAB7590CeE3Ef1A863E9A5877fBB82D9bE11504da', abi: 'function categoryTVL(string _category) view returns (uint256)', params: ['liquid-v2-wbtc'] }) + const wbtc = await optimism_api.call({ target: '0xAB7590CeE3Ef1A863E9A5877fBB82D9bE11504da', abi: 'function categoryTVL(string _category) view returns (uint256)', params: ['liquid-vault-wbtc'] }) amount -= wbtc api.add(ADDRESSES.ethereum.WBTC, wbtc) } else if(base === ADDRESSES.ethereum.EETH) { - const weth = await optimism_api.call({ target: '0xAB7590CeE3Ef1A863E9A5877fBB82D9bE11504da', abi: 'function categoryTVL(string _category) view returns (uint256)', params: ['liquid-v2-weth'] }) + const weth = await optimism_api.call({ target: '0xAB7590CeE3Ef1A863E9A5877fBB82D9bE11504da', abi: 'function categoryTVL(string _category) view returns (uint256)', params: ['liquid-vault-weth'] }) amount -= weth api.add(ADDRESSES.ethereum.WETH, weth) } From 4cf88e83e6581eb4bf98aed8bac896bb95b895c1 Mon Sep 17 00:00:00 2001 From: Vaibhav Valecha Date: Tue, 6 May 2025 01:21:02 -0400 Subject: [PATCH 6/9] make backwards compatible --- projects/ether-fi/index.js | 11 +++++++---- projects/etherfi-liquid/index.js | 16 ++++++++++++++-- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/projects/ether-fi/index.js b/projects/ether-fi/index.js index 9adf090bed..30859da25a 100644 --- a/projects/ether-fi/index.js +++ b/projects/ether-fi/index.js @@ -13,6 +13,9 @@ LBTC = {'ethereum':'0x8236a87084f8b84306f72007f36f2618a5634494', 'base': '0xecac CBBTC = {'ethereum': '0xcbb7c0000ab88b473b1f5afd9ef808440eed33bf', 'base': '0xcbb7c0000ab88b473b1f5afd9ef808440eed33bf', 'arbitrum': '0xcbb7c0000ab88b473b1f5afd9ef808440eed33bf'} async function ebtc_staking(timestamp) { + if(timestamp < 1746507563) { + return [0, 0, 0] + } const api = new sdk.ChainApi({ timestamp, chain: 'ethereum' }) const EBTC = '0x657e8C867D8B37dCC18fA4Caead9C45EB088C642' //ethereum, arb , berachain, base @@ -59,13 +62,13 @@ module.exports = { tvl: async ({ timestamp }) => { const [lbtc_held, wbtc_held, cbbtc_held] = await ebtc_staking(timestamp) - console.log(lbtc_held, wbtc_held, cbbtc_held) const api = new sdk.ChainApi({ timestamp, chain: 'optimism' }) const ethereum_api = new sdk.ChainApi({ timestamp, chain: 'ethereum' }) const eth_supply = await api.call({ target: '0x6329004E903B7F420245E7aF3f355186f2432466', abi: 'uint256:getTvl' }) - const looped_tvl = await api.call({ target: '0xAB7590CeE3Ef1A863E9A5877fBB82D9bE11504da', abi: 'function categoryTVL(string _category) view returns (uint256)', params: ['liquideth'] }) - console.log("looped_tvl", looped_tvl) - console.log("eth_supply", eth_supply) + let looped_tvl = 0 + if(timestamp > 1746507563) { + looped_tvl = await api.call({ target: '0xAB7590CeE3Ef1A863E9A5877fBB82D9bE11504da', abi: 'function categoryTVL(string _category) view returns (uint256)', params: ['liquideth'] }) + } const etherfi_eth_tvl = eth_supply - looped_tvl const eusd = await ethereum_api.call({ target: '0x939778D83b46B456224A33Fb59630B11DEC56663', abi: 'uint256:totalSupply' }) / 10 ** 12 return { diff --git a/projects/etherfi-liquid/index.js b/projects/etherfi-liquid/index.js index 019b2fa0ef..e084ccf932 100644 --- a/projects/etherfi-liquid/index.js +++ b/projects/etherfi-liquid/index.js @@ -53,6 +53,7 @@ const vault_config = { } async function updateVaultTvl(api, config) { + api.block = 21722402 const timestamp = api.timestamp const { vaults, accountant, base } = config const baseDecimals = config.decimals @@ -69,14 +70,25 @@ async function updateVaultTvl(api, config) { amount += (vaultSupply / 10 ** decimal) * (quote / 10 ** decimal) * 10 ** baseDecimals } if(base === ADDRESSES.ethereum.EBTC) { - const wbtc = await optimism_api.call({ target: '0xAB7590CeE3Ef1A863E9A5877fBB82D9bE11504da', abi: 'function categoryTVL(string _category) view returns (uint256)', params: ['liquid-vault-wbtc'] }) + let wbtc = 0 + if(api.block < 22422439) { + wbtc = await api.call({ target: '0x657e8C867D8B37dCC18fA4Caead9C45EB088C642', abi: 'uint256:totalSupply'}) + } else { + wbtc = await optimism_api.call({ target: '0xAB7590CeE3Ef1A863E9A5877fBB82D9bE11504da', abi: 'function categoryTVL(string _category) view returns (uint256)', params: ['liquid-vault-wbtc'] }) + } amount -= wbtc api.add(ADDRESSES.ethereum.WBTC, wbtc) } else if(base === ADDRESSES.ethereum.EETH) { - const weth = await optimism_api.call({ target: '0xAB7590CeE3Ef1A863E9A5877fBB82D9bE11504da', abi: 'function categoryTVL(string _category) view returns (uint256)', params: ['liquid-vault-weth'] }) + let weth = 0 + if (api.block < 22422439) { + weth = await optimism_api.call({ target: '0xAB7590CeE3Ef1A863E9A5877fBB82D9bE11504da', abi: 'function categoryTVL(string _category) view returns (uint256)', params: ['liquid-weth'] }) + } else { + weth = await optimism_api.call({ target: '0xAB7590CeE3Ef1A863E9A5877fBB82D9bE11504da', abi: 'function categoryTVL(string _category) view returns (uint256)', params: ['liquid-vault-weth'] }) + } amount -= weth api.add(ADDRESSES.ethereum.WETH, weth) } + if(amount < 0) amount = 0 api.add(base, amount) } From 9fd831e421f579d75d8c26ee7ce8995bf9bfad4c Mon Sep 17 00:00:00 2001 From: Vaibhav Valecha Date: Thu, 8 May 2025 00:46:52 -0400 Subject: [PATCH 7/9] resync liquid --- projects/etherfi-liquid/index.js | 36 ++++++++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 4 deletions(-) diff --git a/projects/etherfi-liquid/index.js b/projects/etherfi-liquid/index.js index e084ccf932..6792920dae 100644 --- a/projects/etherfi-liquid/index.js +++ b/projects/etherfi-liquid/index.js @@ -19,6 +19,13 @@ const vault_config = { '0x04B8136820598A4e50bEe21b8b6a23fE25Df9Bd8', //beraEth '0x075e60550C6f77f430B284E76aF699bC31651f75', //move ], + 'timestampDeployed': [ + 1717457039, + 1718161451, + 1719943535, + 1735549559, + 1737018599, + ], 'base': ADDRESSES.ethereum.EETH, 'decimals': 18 }, @@ -31,6 +38,10 @@ const vault_config = { '0xEa23aC6D7D11f6b181d6B98174D334478ADAe6b0', //btc liq '0xF44BD12956a0a87c2C20113DdFe1537A442526B5', //beraBtc ], + 'timestampDeployed': [ + 1731626531, + 1735548563, + ], 'base': ADDRESSES.ethereum.EBTC, 'decimals': 8 }, @@ -47,15 +58,32 @@ const vault_config = { '0x1D4F0F05e50312d3E7B65659Ef7d06aa74651e0C', //mev '0x95fE19b324bE69250138FE8EE50356e9f6d17Cfe', //ultra ], + 'timestampDeployed': [ + 1738059803, + 1724977967, + 1724694191, + 1733455907 + ], 'base': ADDRESSES.ethereum.USDC, 'decimals': 6 } } async function updateVaultTvl(api, config) { - api.block = 21722402 const timestamp = api.timestamp - const { vaults, accountant, base } = config + let { vaults, accountant, base } = config + const filtered_vaults = [] + const filtered_accountant = [] + //remove vaults that were deployed before the block + for (let i = 0; i < vaults.length; i++) { + if (config.timestampDeployed[i] < timestamp) { + filtered_vaults.push(vaults[i]) + filtered_accountant.push(accountant[i]) + } + } + vaults = filtered_vaults + accountant = filtered_accountant + const baseDecimals = config.decimals const optimism_api = new sdk.ChainApi({ timestamp, chain: 'optimism' }) @@ -71,7 +99,7 @@ async function updateVaultTvl(api, config) { } if(base === ADDRESSES.ethereum.EBTC) { let wbtc = 0 - if(api.block < 22422439) { + if(api.timestamp < 1746507563) { wbtc = await api.call({ target: '0x657e8C867D8B37dCC18fA4Caead9C45EB088C642', abi: 'uint256:totalSupply'}) } else { wbtc = await optimism_api.call({ target: '0xAB7590CeE3Ef1A863E9A5877fBB82D9bE11504da', abi: 'function categoryTVL(string _category) view returns (uint256)', params: ['liquid-vault-wbtc'] }) @@ -80,7 +108,7 @@ async function updateVaultTvl(api, config) { api.add(ADDRESSES.ethereum.WBTC, wbtc) } else if(base === ADDRESSES.ethereum.EETH) { let weth = 0 - if (api.block < 22422439) { + if (api.timestamp < 1746507563) { weth = await optimism_api.call({ target: '0xAB7590CeE3Ef1A863E9A5877fBB82D9bE11504da', abi: 'function categoryTVL(string _category) view returns (uint256)', params: ['liquid-weth'] }) } else { weth = await optimism_api.call({ target: '0xAB7590CeE3Ef1A863E9A5877fBB82D9bE11504da', abi: 'function categoryTVL(string _category) view returns (uint256)', params: ['liquid-vault-weth'] }) From 877ae7f17731d20f812ccda502cd467bde1be893 Mon Sep 17 00:00:00 2001 From: Vaibhav Valecha Date: Thu, 8 May 2025 00:49:35 -0400 Subject: [PATCH 8/9] increade timestamp --- projects/etherfi-liquid/index.js | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/projects/etherfi-liquid/index.js b/projects/etherfi-liquid/index.js index 6792920dae..adb09683b9 100644 --- a/projects/etherfi-liquid/index.js +++ b/projects/etherfi-liquid/index.js @@ -20,11 +20,11 @@ const vault_config = { '0x075e60550C6f77f430B284E76aF699bC31651f75', //move ], 'timestampDeployed': [ - 1717457039, - 1718161451, - 1719943535, - 1735549559, - 1737018599, + 1717457139, + 1718161551, + 1719943635, + 1735549659, + 1737018699, ], 'base': ADDRESSES.ethereum.EETH, 'decimals': 18 @@ -39,8 +39,8 @@ const vault_config = { '0xF44BD12956a0a87c2C20113DdFe1537A442526B5', //beraBtc ], 'timestampDeployed': [ - 1731626531, - 1735548563, + 1731626631, + 1735548663, ], 'base': ADDRESSES.ethereum.EBTC, 'decimals': 8 @@ -59,10 +59,10 @@ const vault_config = { '0x95fE19b324bE69250138FE8EE50356e9f6d17Cfe', //ultra ], 'timestampDeployed': [ - 1738059803, - 1724977967, - 1724694191, - 1733455907 + 1738059903, + 1724978067, + 1724694291, + 1733456007 ], 'base': ADDRESSES.ethereum.USDC, 'decimals': 6 From 048ac4cd228d686b7369dd8c419c818193b5f4af Mon Sep 17 00:00:00 2001 From: Vaibhav Valecha Date: Wed, 21 May 2025 21:21:30 +0900 Subject: [PATCH 9/9] update per comments --- projects/etherfi-liquid/index.js | 125 +++++++++++++++++++------------ 1 file changed, 77 insertions(+), 48 deletions(-) diff --git a/projects/etherfi-liquid/index.js b/projects/etherfi-liquid/index.js index adb09683b9..8955003bdc 100644 --- a/projects/etherfi-liquid/index.js +++ b/projects/etherfi-liquid/index.js @@ -1,68 +1,69 @@ const ADDRESSES = require('../helper/coreAssets.json') const sdk = require('@defillama/sdk') - - const vault_config = { 'eth': { 'vaults': [ - '0xf0bb20865277aBd641a307eCe5Ee04E79073416C',//eth liq - '0x917ceE801a67f933F2e6b33fC0cD1ED2d5909D88',//weeths - '0x7223442cad8e9cA474fC40109ab981608F8c4273',//weethk - '0x83599937c2C9bEA0E0E8ac096c6f32e86486b410', //beraEth - '0xca8711dAF13D852ED2121E4bE3894Dae366039E4', //move + '0xf0bb20865277aBd641a307eCe5Ee04E79073416C', // eth liq + '0x917ceE801a67f933F2e6b33fC0cD1ED2d5909D88', // weeths + '0x7223442cad8e9cA474fC40109ab981608F8c4273', // weethk + '0x83599937c2C9bEA0E0E8ac096c6f32e86486b410', // beraEth + '0xca8711dAF13D852ED2121E4bE3894Dae366039E4', // move ], 'accountant': [ - '0x0d05D94a5F1E76C18fbeB7A13d17C8a314088198', //eth liq - '0xbe16605B22a7faCEf247363312121670DFe5afBE', //weeths - '0x126af21dc55C300B7D0bBfC4F3898F558aE8156b', //weethk - '0x04B8136820598A4e50bEe21b8b6a23fE25Df9Bd8', //beraEth - '0x075e60550C6f77f430B284E76aF699bC31651f75', //move + '0x0d05D94a5F1E76C18fbeB7A13d17C8a314088198', // eth liq + '0xbe16605B22a7faCEf247363312121670DFe5afBE', // weeths + '0x126af21dc55C300B7D0bBfC4F3898F558aE8156b', // weethk + '0x04B8136820598A4e50bEe21b8b6a23fE25Df9Bd8', // beraEth + '0x075e60550C6f77f430B284E76aF699bC31651f75', // move ], 'timestampDeployed': [ - 1717457139, - 1718161551, - 1719943635, - 1735549659, - 1737018699, + 1717457039, + 1718161451, + 1719943535, + 1735549559, + 1737018599, ], 'base': ADDRESSES.ethereum.EETH, 'decimals': 18 }, 'btc': { 'vaults': [ - '0x5f46d540b6eD704C3c8789105F30E075AA900726', //btc liq - '0xC673ef7791724f0dcca38adB47Fbb3AEF3DB6C80', //beraBtc + '0x5f46d540b6eD704C3c8789105F30E075AA900726', // btc liq + '0xC673ef7791724f0dcca38adB47Fbb3AEF3DB6C80', // beraBtc ], 'accountant': [ - '0xEa23aC6D7D11f6b181d6B98174D334478ADAe6b0', //btc liq - '0xF44BD12956a0a87c2C20113DdFe1537A442526B5', //beraBtc - ], + '0xEa23aC6D7D11f6b181d6B98174D334478ADAe6b0', // btc liq + '0xF44BD12956a0a87c2C20113DdFe1537A442526B5', // beraBtc + ], 'timestampDeployed': [ - 1731626631, - 1735548663, + 1731626531, + 1735548563, + ], + 'base': [ + "0x657e8c867d8b37dcc18fa4caead9c45eb088c642", // EBTC + "0x2260fac5e5542a773aa44fbcfedf7c193bc2c599" // WBTC ], - 'base': ADDRESSES.ethereum.EBTC, 'decimals': 8 }, 'usd': { 'vaults': [ - '0x08c6F91e2B681FaF5e17227F2a44C307b3C1364C', //usd liq - '0x352180974C71f84a934953Cf49C4E538a6F9c997', //exilir - '0xeDa663610638E6557c27e2f4e973D3393e844E70', //mev - '0xbc0f3B23930fff9f4894914bD745ABAbA9588265', //ultra + '0x08c6F91e2B681FaF5e17227F2a44C307b3C1364C', // usd liq + '0x352180974C71f84a934953Cf49C4E538a6F9c997', // exilir + '0xeDa663610638E6557c27e2f4e973D3393e844E70', // mev + '0xbc0f3B23930fff9f4894914bD745ABAbA9588265', // ultra ], 'accountant': [ - '0xc315D6e14DDCDC7407784e2Caf815d131Bc1D3E7', //usd liq - '0xBae19b38Bf727Be64AF0B578c34985c3D612e2Ba', //exilir - '0x1D4F0F05e50312d3E7B65659Ef7d06aa74651e0C', //mev - '0x95fE19b324bE69250138FE8EE50356e9f6d17Cfe', //ultra + '0xc315D6e14DDCDC7407784e2Caf815d131Bc1D3E7', // usd liq + '0xBae19b38Bf727Be64AF0B578c34985c3D612e2Ba', // exilir + '0x1D4F0F05e50312d3E7B65659Ef7d06aa74651e0C', // mev + '0x95fE19b324bE69250138FE8EE50356e9f6d17Cfe', // ultra ], 'timestampDeployed': [ - 1738059903, - 1724978067, - 1724694291, - 1733456007 + 1738059803, + 1724977967, + 1724694191, + 1733455907 ], 'base': ADDRESSES.ethereum.USDC, 'decimals': 6 @@ -74,13 +75,15 @@ async function updateVaultTvl(api, config) { let { vaults, accountant, base } = config const filtered_vaults = [] const filtered_accountant = [] - //remove vaults that were deployed before the block + + // Filter out vaults not deployed yet for (let i = 0; i < vaults.length; i++) { if (config.timestampDeployed[i] < timestamp) { filtered_vaults.push(vaults[i]) filtered_accountant.push(accountant[i]) } } + vaults = filtered_vaults accountant = filtered_accountant @@ -90,6 +93,7 @@ async function updateVaultTvl(api, config) { const vaultsSupply = await api.multiCall({ calls: vaults, abi: 'uint256:totalSupply' }) const quotes = await api.multiCall({ calls: accountant, abi: 'uint256:getRate' }) const decimals = await api.multiCall({ calls: accountant, abi: 'uint256:decimals' }) + let amount = 0 for (let i = 0; i < vaultsSupply.length; i++) { const vaultSupply = vaultsSupply[i] @@ -97,34 +101,59 @@ async function updateVaultTvl(api, config) { const decimal = decimals[i] amount += (vaultSupply / 10 ** decimal) * (quote / 10 ** decimal) * 10 ** baseDecimals } - if(base === ADDRESSES.ethereum.EBTC) { + if (JSON.stringify(base).includes(ADDRESSES.ethereum.EBTC)) { let wbtc = 0 - if(api.timestamp < 1746507563) { - wbtc = await api.call({ target: '0x657e8C867D8B37dCC18fA4Caead9C45EB088C642', abi: 'uint256:totalSupply'}) + if (api.timestamp < 1746507563) { + wbtc = await api.call({ + target: '0x657e8C867D8B37dCC18fA4Caead9C45EB088C642', + abi: 'uint256:totalSupply' + }) } else { - wbtc = await optimism_api.call({ target: '0xAB7590CeE3Ef1A863E9A5877fBB82D9bE11504da', abi: 'function categoryTVL(string _category) view returns (uint256)', params: ['liquid-vault-wbtc'] }) + wbtc = await optimism_api.call({ + target: '0xAB7590CeE3Ef1A863E9A5877fBB82D9bE11504da', + abi: 'function categoryTVL(string _category) view returns (uint256)', + params: ['liquid-vault-wbtc'] + }) } amount -= wbtc api.add(ADDRESSES.ethereum.WBTC, wbtc) - } else if(base === ADDRESSES.ethereum.EETH) { + } else if (JSON.stringify(base).includes(ADDRESSES.ethereum.EETH)) { let weth = 0 if (api.timestamp < 1746507563) { - weth = await optimism_api.call({ target: '0xAB7590CeE3Ef1A863E9A5877fBB82D9bE11504da', abi: 'function categoryTVL(string _category) view returns (uint256)', params: ['liquid-weth'] }) + weth = await optimism_api.call({ + target: '0xAB7590CeE3Ef1A863E9A5877fBB82D9bE11504da', + abi: 'function categoryTVL(string _category) view returns (uint256)', + params: ['liquid-weth'] + }) } else { - weth = await optimism_api.call({ target: '0xAB7590CeE3Ef1A863E9A5877fBB82D9bE11504da', abi: 'function categoryTVL(string _category) view returns (uint256)', params: ['liquid-vault-weth'] }) + weth = await optimism_api.call({ + target: '0xAB7590CeE3Ef1A863E9A5877fBB82D9bE11504da', + abi: 'function categoryTVL(string _category) view returns (uint256)', + params: ['liquid-vault-weth'] + }) } amount -= weth api.add(ADDRESSES.ethereum.WETH, weth) } - if(amount < 0) amount = 0 - api.add(base, amount) -} + if (amount < 0) amount = 0 + + // upport multiple base tokens + if (Array.isArray(base)) { + const share = amount / base.length + for (const token of base) { + api.add(token, share) + } + } else { + api.add(base, amount) + } +} async function tvl(api) { for (const config of Object.values(vault_config)) { await updateVaultTvl(api, config) } + console.log(await api.getBalancesV2().getUSDJSONs()) } module.exports = {