Skip to content

Update Vaults, Remove LRT page and All Stake Assets #14418

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 68 additions & 7 deletions projects/ether-fi/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const { nullAddress } = require("../helper/unwrapLPs");
const ADDRESSES = require('../helper/coreAssets.json')
const sdk = require('@defillama/sdk')

function staking(contract, token) {
Expand All @@ -7,19 +8,79 @@ function staking(contract, token) {
}
}

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: {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only chain should be Ethereum

Copy link
Contributor Author

@vvalecha519 vvalecha519 Apr 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is ethfi staking on arbitrum and base. This is why we have multiple chains and this was done before.

The main focus is to have:

  1. correct total etherfi total which should be
    tvl: async ({ timestamp }) => { //total tvl not stake tvl
    let etherfi_tvl = 0
    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'] })
    }

    return {
    [nullAddress]: etherfi_tvl
    }
    }
    Screenshot 2025-04-23 at 3 03 52 PM

    1. Correct stake tvl:
      sum of:
      a) EETH totalSupply on Ethereum,
      b) EBTC totalSupply on Ethereum, Scroll and Berachain
      EUSD on Ethereum and Scroll

Screenshot 2025-04-23 at 3 04 13 PM

  1. Correct liquid tvl which means including all our vaults
    Screenshot 2025-04-23 at 3 05 35 PM

  2. Get rid of etherfi Vault page as it is redundant

    Screenshot 2025-04-23 at 3 05 49 PM

staking: staking("0x86B5780b606940Eb59A062aA85a07959518c0161", "0xFe0c30065B384F05761f15d0CC899D4F9F9Cc0eB"),
tvl: async ({ timestamp }) => {
staking: staking("0x86B5780b606940Eb59A062aA85a07959518c0161", "0xFe0c30065B384F05761f15d0CC899D4F9F9Cc0eB"), //ethfi

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' })
await api.getBlock()
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]: await api.call({ target: '0x6329004E903B7F420245E7aF3f355186f2432466', abi: 'uint256:getTvl' })
[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")
}
arbitrum: {
staking: staking("0x86B5780b606940Eb59A062aA85a07959518c0161", "0x7189fb5b6504bbff6a852b13b7b82a3c118fdc27") //ethfi
},
base: {
staking: staking("0x86B5780b606940Eb59A062aA85a07959518c0161", "0x7189fb5b6504bbff6a852b13b7b82a3c118fdc27"), //ethfi
},
}
129 changes: 83 additions & 46 deletions projects/etherfi-liquid/index.js
Original file line number Diff line number Diff line change
@@ -1,59 +1,96 @@
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.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]
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'] })
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'] })
amount -= weth
api.add(ADDRESSES.ethereum.WETH, weth)
}
api.add(base, amount)
}


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,
},
};
}
41 changes: 0 additions & 41 deletions projects/etherfi-lrt/index.js

This file was deleted.

2 changes: 2 additions & 0 deletions projects/helper/coreAssets.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@
"cbETH": "0xBe9895146f7AF43049ca1c1AE358B0541Ea49704",
"FDUSD": "0xc5f0f7b66764f6ec8c8dff7ba683102295e16409",
"EETH": "0x35fa164735182de50811e8e2e824cfb9b6118ac2",
"EUSD": "0x939778D83b46B456224A33Fb59630B11DEC56663",
"EBTC": "0x657e8C867D8B37dCC18fA4Caead9C45EB088C642",
"AEVO": "0xB528edBef013aff855ac3c50b381f253aF13b997",
"STONE": "0x4d831e22f062b5327dfdb15f0b6a5df20e2e3dd0",
"USDM": "0x59D9356E565Ab3A36dD77763Fc0d87fEaf85508C",
Expand Down