|
1 | | -// TODO: Once factory is upgraded, adapt this adapter to dynamically discover minters from factory events |
| 1 | +// TODO: Once factory is upgraded, adapt this adapter to dynamically discover minters and genesis contracts from factory events |
2 | 2 | // The factory (0xd696e56b3a054734d4c6dcbd32e11a278b0ec458) will emit: |
3 | | -// factory.deployed(address minter, string identifier) |
4 | | -// where identifier ends with "::minter" (e.g., "harbor_v1::BTC::fxUSD::minter") |
| 3 | +// factory.deployed(address contract, string identifier) |
| 4 | +// where identifier ends with "::minter" (e.g., "harbor_v1::BTC::fxUSD::minter") or "::genesis" (e.g., "harbor_v1::BTC::fxUSD::genesis") |
5 | 5 | // The factory address is fixed for all time. |
6 | | -// We can then index all minter addresses from factory events instead of hardcoding them. |
| 6 | +// We can then index all minter and genesis addresses from factory events instead of hardcoding them. |
7 | 7 |
|
8 | | -// Known minter addresses (will be replaced by factory discovery once factory is upgraded) |
| 8 | +// All minter contract addresses (proxy addresses from factory deployments) |
| 9 | +// Format: proxy address from "proxy" field where proxy name ends with "::minter" |
9 | 10 | const KNOWN_MINTERS = [ |
10 | | - '0xd6E2F8e57b4aFB51C6fA4cbC012e1cE6aEad989F', // Minter fxusd/eth |
11 | | - '0x33e32ff4d0677862fa31582CC654a25b9b1e4888', // Minter fxusd/btc |
12 | | - '0xF42516EB885E737780EB864dd07cEc8628000919', // Minter steth/btc |
| 11 | + // BTC::fxUSD::minter |
| 12 | + '0x33e32ff4d0677862fa31582CC654a25b9b1e4888', |
| 13 | + // BTC::stETH::minter |
| 14 | + '0xF42516EB885E737780EB864dd07cEc8628000919', |
| 15 | + // ETH::fxUSD::minter |
| 16 | + '0xd6E2F8e57b4aFB51C6fA4cbC012e1cE6aEad989F', |
| 17 | + // EUR::fxUSD::minter |
| 18 | + '0xDEFB2C04062350678965CBF38A216Cc50723B246', |
| 19 | + // EUR::stETH::minter |
| 20 | + '0x68911ea33E11bc77e07f6dA4db6cd23d723641cE', |
| 21 | + // GOLD::fxUSD::minter |
| 22 | + '0x880600E0c803d836E305B7c242FC095Eed234A8f', |
| 23 | + // GOLD::stETH::minter |
| 24 | + '0xB315DC4698DF45A477d8bb4B0Bc694C4D1Be91b5', |
| 25 | + // MCAP::fxUSD::minter |
| 26 | + '0x3d3EAe3a4Ee52ef703216c62EFEC3157694606dE', |
| 27 | + // MCAP::stETH::minter |
| 28 | + '0xe37e34Ab0AaaabAc0e20c911349c1dEfAD0691B6', |
| 29 | + // SILVER::fxUSD::minter |
| 30 | + '0x177bb50574CDA129BDd0B0F50d4E061d38AA75Ef', |
| 31 | + // SILVER::stETH::minter |
| 32 | + '0x1c0067BEe039A293804b8BE951B368D2Ec65b3e9', |
| 33 | +]; |
| 34 | + |
| 35 | +// Genesis contract addresses (proxy addresses from factory deployments) |
| 36 | +// Format: proxy address from "proxy" field where proxy name ends with "::genesis" |
| 37 | +const GENESIS_CONTRACTS = [ |
| 38 | + // BTC::fxUSD::genesis |
| 39 | + '0x42cc9a19b358a2A918f891D8a6199d8b05F0BC1C', |
| 40 | + // BTC::stETH::genesis |
| 41 | + '0xc64Fc46eED431e92C1b5e24DC296b5985CE6Cc00', |
| 42 | + // ETH::fxUSD::genesis |
| 43 | + '0xC9df4f62474Cf6cdE6c064DB29416a9F4f27EBdC', |
| 44 | + // EUR::fxUSD::genesis |
| 45 | + '0xa9EB43Ed6Ba3B953a82741F3e226C1d6B029699b', |
| 46 | + // EUR::stETH::genesis |
| 47 | + '0xf4F97218a00213a57A32E4606aAecC99e1805A89', |
| 48 | + // GOLD::fxUSD::genesis |
| 49 | + '0x2cbF457112Ef5A16cfcA10Fb173d56a5cc9DAa66', |
| 50 | + // GOLD::stETH::genesis |
| 51 | + '0x8Ad6b177137A6c33070c27d98355717849Ce526c', |
| 52 | + // MCAP::fxUSD::genesis |
| 53 | + '0x7Bfb831E6360D4600C7b9b200F8AcA6f89CecdA4', |
| 54 | + // MCAP::stETH::genesis |
| 55 | + '0xa6c02dE8E3150C6ffA9C80F98185d42653CB438d', |
| 56 | + // SILVER::fxUSD::genesis |
| 57 | + '0x66d18B9Dd5d1cd51957DFea0e0373b54E06118C8', |
| 58 | + // SILVER::stETH::genesis |
| 59 | + '0x8f655Ca32A1Fa8032955989c19e91886F26439dc', |
13 | 60 | ]; |
14 | 61 |
|
15 | 62 | async function tvl(api) { |
16 | | - // Get collateral token address from each minter using WRAPPED_COLLATERAL_TOKEN() function |
17 | | - // This makes it dynamic and supports any collateral token without hardcoding |
18 | | - const collateralTokens = await api.multiCall({ |
19 | | - abi: 'function WRAPPED_COLLATERAL_TOKEN() view returns (address)', |
20 | | - calls: KNOWN_MINTERS, |
21 | | - }); |
22 | | - |
23 | | - // Build tokensAndOwners array: [collateralToken, minterAddress] |
24 | | - const tokensAndOwners = KNOWN_MINTERS.map((minter, i) => [ |
25 | | - collateralTokens[i], |
26 | | - minter, |
27 | | - ]); |
| 63 | + // Combine minters and genesis contracts |
| 64 | + const allContracts = [...KNOWN_MINTERS, ...GENESIS_CONTRACTS]; |
28 | 65 |
|
29 | | - return api.sumTokens({ tokensAndOwners }); |
| 66 | + const collateralTokens = await api.multiCall({ abi: 'address:WRAPPED_COLLATERAL_TOKEN', calls: allContracts, }); |
| 67 | + return api.sumTokens({ tokensAndOwners2: [collateralTokens, allContracts] }); |
30 | 68 | } |
31 | 69 |
|
32 | 70 | module.exports = { |
33 | | - methodology: 'TVL is calculated by summing the balances of tokens (FXSAVE and wstETH) held by 0xHarborFi minter contracts.', |
34 | | - start: 23991071, |
| 71 | + methodology: 'TVL is calculated by summing the balances of collateral tokens held by all 0xHarborFi minter and genesis contracts. Each contract\'s collateral token is queried dynamically using WRAPPED_COLLATERAL_TOKEN().', |
35 | 72 | ethereum: { |
36 | 73 | tvl, |
37 | 74 | }, |
|
0 commit comments