diff --git a/projects/alchemix/contracts.json b/projects/alchemix/contracts.json index 320372f36e..325afbd811 100644 --- a/projects/alchemix/contracts.json +++ b/projects/alchemix/contracts.json @@ -1,4 +1,18 @@ { + "arbitrum": { + "tokenHolders": { + "alUSDAlchemist": "0xb46eE2E4165F629b4aBCE04B7Eb4237f951AC66F", + "alUSDTransmuterBuffer": "0x00E33722ba54545667E76a18CE9D544130eEAbcC", + "alUSDTransmuter": "0xe7ec71B894583E9C1b07873fA86A7e81f3940eA8", + "alETHAlchemist": "0x654e16a0b161b150F5d1C8a5ba6E7A7B7760703A", + "alETHTransmuterBuffer": "0xECAd08EE07f1AA87f3E080997eBa6d02d28bb9D2", + "alETHTransmuter": "0x1EB7D78d7f6D73e5de67Fa62Fd8b55c54Aa9c0D4" + }, + "underlyingTokens": { + "USDC": "0xaf88d065e77c8cC2239327C5EDb3A432268e5831", + "WETH": "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1" + } + }, "fantom": { "tokenHolders": { "alUSDAlchemist": "0x76b2E3c5a183970AAAD2A48cF6Ae79E3e16D3A0E", diff --git a/projects/alchemix/index.js b/projects/alchemix/index.js index 53b41fc787..b574a7ea72 100644 --- a/projects/alchemix/index.js +++ b/projects/alchemix/index.js @@ -2,45 +2,41 @@ const { sumTokens2 } = require("../helper/unwrapLPs"); const { staking } = require("../helper/staking.js"); const contracts = require("./contracts"); -function tvl(chain) { - return async (api) => { - const tokens = Object.values(contracts[chain].underlyingTokens).concat(Object.values(contracts[chain].yvTokens)) - await sumTokens2({ tokens, api, owners: Object.values(contracts[chain].tokenHolders) }) - if (api.chain !== 'ethereum') return api.getBalances() +async function tvl(api) { + const chain = api.chain + const tokens = Object.values(contracts[chain].underlyingTokens).concat(Object.values(contracts[chain].yvTokens ?? [])) + await sumTokens2({ tokens, api, owners: Object.values(contracts[chain].tokenHolders) }) + if (api.chain !== 'ethereum') return api.getBalances() - await Promise.all( - Object.values(contracts.cvxLPpools).map(async ({ poolAddress, holder, tokenAddress, alToken }) => { - const lpTokenBalance = await api.call({ target: poolAddress, abi: "erc20:balanceOf", params: holder, }) - const supply = await api.call({ target: tokenAddress, abi: "erc20:totalSupply", }) - // console.log({poolAddress, holder, tokenAddress, alToken, lpTokenBalance, supply, ratio: lpTokenBalance / supply}) - if (+supply === 0) return; - const ratio = lpTokenBalance / supply - const tokenBalances = await api.multiCall({ target: tokenAddress, abi: 'function balances(uint256) view returns (uint256)', calls: [0, 1] }) - const tokens = await api.multiCall({ target: tokenAddress, abi: 'function coins(uint256) view returns (address)', calls: [0, 1] }) - alToken = alToken.toLowerCase() - tokens.forEach((token, i) => { - if (token.toLowerCase() !== alToken) { - if (!isNaN(tokenBalances[i] * ratio))api.add(token, tokenBalances[i] * ratio) - } - }) + await Promise.all( + Object.values(contracts.cvxLPpools).map(async ({ poolAddress, holder, tokenAddress, alToken }) => { + const lpTokenBalance = await api.call({ target: poolAddress, abi: "erc20:balanceOf", params: holder, }) + const supply = await api.call({ target: tokenAddress, abi: "erc20:totalSupply", }) + // console.log({poolAddress, holder, tokenAddress, alToken, lpTokenBalance, supply, ratio: lpTokenBalance / supply}) + if (+supply === 0) return; + const ratio = lpTokenBalance / supply + const tokenBalances = await api.multiCall({ target: tokenAddress, abi: 'function balances(uint256) view returns (uint256)', calls: [0, 1] }) + const tokens = await api.multiCall({ target: tokenAddress, abi: 'function coins(uint256) view returns (address)', calls: [0, 1] }) + alToken = alToken.toLowerCase() + tokens.forEach((token, i) => { + if (token.toLowerCase() !== alToken) { + if (!isNaN(tokenBalances[i] * ratio)) api.add(token, tokenBalances[i] * ratio) + } }) - ); - }; -} + }) + ); +}; module.exports = { doublecounted: true, ethereum: { - tvl: tvl("ethereum"), + tvl, staking: staking( contracts.ethereum.staking.holder, contracts.ethereum.staking.token ), }, - fantom: { - tvl: tvl("fantom"), - }, - optimism: { - tvl: tvl("optimism"), - }, + fantom: { tvl, }, + optimism: { tvl, }, + arbitrum: { tvl }, };