|
1 |
| -const sdk = require("@defillama/sdk"); |
| 1 | +const ADDRESSES = require('../helper/coreAssets.json') |
2 | 2 | const abi = require("../origindollar/abi.json");
|
3 | 3 |
|
4 |
| -const vault = "0x39254033945aa2e4809cc2977e7087bee48bd7ab"; |
5 |
| - |
6 |
| -const ethTvl = async (timestamp, ethBlock) => { |
7 |
| - const balances = {}; |
8 |
| - |
9 |
| - // Account WETH, rETH, frxETH and stETH backing up the minted OUSD |
10 |
| - const backingAssets = ( |
11 |
| - await sdk.api.abi.call({ |
12 |
| - abi: abi.getAllAssets, |
13 |
| - target: vault, |
14 |
| - block: ethBlock, |
15 |
| - }) |
16 |
| - ).output; |
17 |
| - |
18 |
| - for (let i = 0; i < backingAssets.length; i++) { |
19 |
| - const backingAssetBalance = ( |
20 |
| - await sdk.api.abi.call({ |
21 |
| - abi: abi.checkBalance, |
22 |
| - target: vault, |
23 |
| - params: backingAssets[i], |
24 |
| - block: ethBlock, |
25 |
| - }) |
26 |
| - ).output; |
27 |
| - |
28 |
| - sdk.util.sumSingleBalance(balances, backingAssets[i], backingAssetBalance); |
29 |
| - } |
30 |
| - |
31 |
| - return balances; |
32 |
| -}; |
| 4 | + |
| 5 | +const ethTvl = async (api) => { |
| 6 | + const vault = "0x39254033945aa2e4809cc2977e7087bee48bd7ab"; |
| 7 | + const nativeStaking = '0x34eDb2ee25751eE67F68A45813B22811687C0238' |
| 8 | + const nativeStaking2 = '0x4685dB8bF2Df743c861d71E6cFb5347222992076' |
| 9 | + const stakingBalance1 = await api.call({ abi: abi.checkBalance, target: nativeStaking, params: ADDRESSES.ethereum.WETH }) |
| 10 | + api.add(ADDRESSES.ethereum.WETH, stakingBalance1) |
| 11 | + const stakingBalance2 = await api.call({ abi: abi.checkBalance, target: nativeStaking2, params: ADDRESSES.ethereum.WETH }) |
| 12 | + api.add(ADDRESSES.ethereum.WETH, stakingBalance2) |
| 13 | + |
| 14 | + // add ETH part of curve LP |
| 15 | + const convexStrategy = '0x1827F9eA98E0bf96550b2FC20F7233277FcD7E63' |
| 16 | + const lp = await api.call({ abi: 'address:curvePool', target: convexStrategy}) |
| 17 | + const ethIndex = await api.call({ abi: 'uint128:ethCoinIndex', target: convexStrategy}) |
| 18 | + const lpBalance = await api.call({ abi: abi.checkBalance, target: convexStrategy, params: ADDRESSES.ethereum.WETH}) |
| 19 | + const lpSupply = await api.call({ abi: 'erc20:totalSupply', target: lp}) |
| 20 | + const ethInPool = await api.call({ abi: 'function balances(uint256) view returns (uint256)', target: lp, params: ethIndex}) |
| 21 | + const ethLPBalance = (lpBalance / lpSupply) * ethInPool |
| 22 | + api.add(ADDRESSES.ethereum.WETH, ethLPBalance) |
| 23 | + |
| 24 | + |
| 25 | + return api.sumTokens({ owner: vault, tokens: [ADDRESSES.ethereum.WETH] }) |
| 26 | +} |
| 27 | + |
| 28 | +async function baseTvl(api) { |
| 29 | + const vault = '0x98a0CbeF61bD2D21435f433bE4CD42B56B38CC93' |
| 30 | + const aeroAMO = '0xF611cC500eEE7E4e4763A05FE623E2363c86d2Af' |
| 31 | + const dripper = await api.call({ target: vault, abi: 'function dripper() view returns (address)' }) |
| 32 | + const [amountWeth, _amountOETH] = await api.call({ abi: 'function getPositionPrincipal() view returns (uint256, uint256)', target: aeroAMO }) |
| 33 | + api.add(ADDRESSES.base.WETH, amountWeth) |
| 34 | + return api.sumTokens({ owners: [vault], tokens: [ADDRESSES.base.WETH] }) |
| 35 | + |
| 36 | +} |
| 37 | + |
33 | 38 |
|
34 | 39 | module.exports = {
|
35 | 40 | ethereum: {
|
36 | 41 | tvl: ethTvl,
|
37 | 42 | },
|
| 43 | + base: { |
| 44 | + tvl: baseTvl, |
| 45 | + }, |
38 | 46 | };
|
0 commit comments