|
1 | 1 | const ADDRESSES = require('../helper/coreAssets.json')
|
2 |
| -const config = require("./config"); |
3 |
| -const sdk = require('@defillama/sdk') |
4 | 2 |
|
5 |
| -async function getZircuitSupplies(api) { |
6 |
| - const { msteth, egeth } = config[api.chain]; |
7 |
| - const mlrttokens = [msteth, egeth]; |
8 |
| - const tokenSupplies = await api.multiCall({ abi: 'uint256:totalSupply', calls: mlrttokens, }); |
9 |
| - return { |
10 |
| - zircuitMstethSupply: tokenSupplies[0], |
11 |
| - zircuitEgethSupply: tokenSupplies[1], |
12 |
| - }; |
| 3 | +const CONFIG = { |
| 4 | + ethereum: { |
| 5 | + eigenConfig: "0x20b70E4A1883b81429533FeD944d7957121c7CAB", |
| 6 | + eigenStaking: "0x24db6717dB1C75B9Db6eA47164D8730B63875dB7", |
| 7 | + eigenBuffer: "0x98083e22d12497c1516d3c49e7cc6cd2cd9dcba4", |
| 8 | + egETH: "0x18f313fc6afc9b5fd6f0908c1b3d476e3fea1dd9", |
| 9 | + ethereum: ADDRESSES.null |
| 10 | + }, |
13 | 11 | }
|
14 | 12 |
|
15 |
| -async function tvl(api) { |
16 |
| - const { eigenConfig } = config[api.chain]; |
17 |
| - |
18 |
| - const zircuitApi = new sdk.ChainApi({ chain: 'zircuit', timestamp: api.timestamp }); |
19 |
| - await zircuitApi.getBlock() |
20 |
| - const zircuitSupplies = await getZircuitSupplies(zircuitApi); |
21 |
| - api.add(ADDRESSES.ethereum.STETH, zircuitSupplies.zircuitMstethSupply * -1); // Adjust for msteth |
22 |
| - api.add('0xeFEfeFEfeFeFEFEFEfefeFeFefEfEfEfeFEFEFEf', zircuitSupplies.zircuitEgethSupply * -1); // Adjust for egeth |
23 |
| - |
24 |
| - // Fetch token list and their supplies |
25 |
| - let tokens = await api.call({ abi: 'address[]:getSupportedAssetList', target: eigenConfig }); |
26 |
| - const mlrttokens = await api.multiCall({ abi: 'function mLRTReceiptByAsset(address) view returns (address)', calls: tokens, target: eigenConfig }); |
27 |
| - const tokenSupplies = await api.multiCall({ abi: 'uint256:totalSupply', calls: mlrttokens }); |
28 |
| - api.add(tokens, tokenSupplies); |
| 13 | +const abis = { |
| 14 | + getSupportedAssetList: 'address[]:getSupportedAssetList', |
| 15 | + mLRTReceiptByAsset: "function mLRTReceiptByAsset(address token) view returns (address)", |
| 16 | + getAssetDistributionData: "function getAssetDistributionData(address asset) view returns (uint256 assetLyingInDepositPool, uint256 assetLyingInNDCs, uint256 assetStakedInEigenLayer, uint256 assetLyingInEWD)", |
29 | 17 | }
|
30 | 18 |
|
31 |
| -async function tvl_zircuit(api) { |
32 |
| - const { msteth, egeth, wsteth, weth } = config[api.chain]; |
33 |
| - const mlrttokens = [msteth, egeth]; |
34 |
| - const tokens = [wsteth, weth]; |
35 |
| - |
36 |
| - // Now add zircuit-specific supplies |
37 |
| - const tokenSupplies = await api.multiCall({ abi: 'uint256:totalSupply', calls: mlrttokens }); |
38 |
| - api.add(tokens, tokenSupplies); |
| 19 | +const tvl = async (api) => { |
| 20 | + const { eigenConfig, eigenStaking, eigenBuffer, ethereum } = CONFIG[api.chain] |
| 21 | + const getSupportedAssetLists = await api.call({ abi: abis.getSupportedAssetList, target: eigenConfig }) |
| 22 | + const assetsDistributions = await api.multiCall({ target: eigenStaking, calls: getSupportedAssetLists, abi: abis.getAssetDistributionData }) |
| 23 | + await api.sumTokens({ owner: eigenBuffer, tokens: getSupportedAssetLists.map(t => t.toLowerCase() === '0xefefefefefefefefefefefefefefefefefefefef' ? ethereum : t) }) |
| 24 | + assetsDistributions.forEach(({ assetLyingInDepositPool, assetStakedInEigenLayer, assetLyingInNDCs, assetLyingInEWD }, i) => { |
| 25 | + const token = getSupportedAssetLists[i] |
| 26 | + api.add(token, assetLyingInDepositPool) |
| 27 | + api.add(token, assetStakedInEigenLayer) |
| 28 | + api.add(token, assetLyingInNDCs) |
| 29 | + api.add(token, assetLyingInEWD) |
| 30 | + }) |
39 | 31 | }
|
40 | 32 |
|
41 | 33 | module.exports = {
|
42 |
| - ethereum: { |
43 |
| - tvl: tvl, |
44 |
| - }, |
45 |
| - zircuit: { |
46 |
| - tvl: tvl_zircuit, |
47 |
| - }, |
48 |
| -}; |
49 |
| - |
50 |
| -module.exports.doublecounted = true; |
| 34 | + doublecounted: true, |
| 35 | + ethereum: { tvl }, |
| 36 | + zircuit: { tvl: () => ({ }) } |
| 37 | +} |
0 commit comments