From bea7273d6b8161d5b47234bccf2e20a9f84f532a Mon Sep 17 00:00:00 2001 From: g1nt0ki <99907941+g1nt0ki@users.noreply.github.com> Date: Mon, 8 Apr 2024 15:37:48 +0200 Subject: [PATCH] Add vaults and staking from fMoney (#9746) * added vaults and staking from fMoney * minor fix --------- Co-authored-by: 0xSuku <84302571+0xSuku@users.noreply.github.com> --- projects/fMoney/index.js | 24 ++++++++++++++++++++++++ projects/helper/unwrapLPs.js | 10 ++++++++-- test.js | 6 ++++-- 3 files changed, 36 insertions(+), 4 deletions(-) create mode 100644 projects/fMoney/index.js diff --git a/projects/fMoney/index.js b/projects/fMoney/index.js new file mode 100644 index 000000000000..62d674259f64 --- /dev/null +++ b/projects/fMoney/index.js @@ -0,0 +1,24 @@ + +const { compoundExports2 } = require('../helper/compound') +const { sumBalancerLps } = require('../helper/unwrapLPs') + +const addresses = { + beetsVault: "0x8166994d9ebBe5829EC86Bd81258149B87faCfd3", + fuBUX: "0xcf211d1022f0B1aEC7CbAdCa1472fc20E6dFe3c6", + fBUX80lzUSDC20: "0x2ddcd6916ee7ccc6300cb0fe2919a341be0ee8bb" +} + +async function staking(api) { + return sumBalancerLps({}, [[addresses.fBUX80lzUSDC20, addresses.beetsVault]], 0, 0, undefined, api) +} + +const config = { + fantom: '0xB911d8064c0AA338241f349eD802Ad4bae6ec034', +} + + +Object.keys(config).forEach(chain => { + module.exports[chain] = compoundExports2({ comptroller: config[chain] }) +}); + +module.exports.fantom.staking = staking \ No newline at end of file diff --git a/projects/helper/unwrapLPs.js b/projects/helper/unwrapLPs.js index 336deaeb27b6..ecfd468a7c3c 100644 --- a/projects/helper/unwrapLPs.js +++ b/projects/helper/unwrapLPs.js @@ -341,7 +341,13 @@ async function sumTokensAndLPs(balances, tokens, block, chain = "ethereum", tran } const balancerVault = "0xBA12222222228d8Ba445958a75a0704d566BF2C8" -async function sumBalancerLps(balances, tokensAndOwners, block, chain, transformAddress) { +async function sumBalancerLps(balances, tokensAndOwners, block, chain, transformAddress, api) { + if (api) { + balances = api.getBalances() + chain = api.chain + block = api.block + } + let vault = chain === 'fantom' ? '0x20dd72Ed959b6147912C2e529F0a0C651c33c9ce' : balancerVault if (!transformAddress) transformAddress = await getChainTransform(chain) const poolIds = sdk.api.abi.multiCall({ calls: tokensAndOwners.map(t => ({ @@ -370,7 +376,7 @@ async function sumBalancerLps(balances, tokensAndOwners, block, chain, transform }); const balancerPoolsPromise = sdk.api.abi.multiCall({ calls: (await poolIds).output.map(o => ({ - target: balancerVault, + target: vault, params: o.output })), abi: getPoolTokens, diff --git a/test.js b/test.js index 994074ac0a09..071450af080a 100644 --- a/test.js +++ b/test.js @@ -208,9 +208,11 @@ sdk.api.abi.call = async (...args) => { console.log("Total:", humanizeNumber(usdTvls[chain]), "\n"); }); console.log(`------ TVL ------`); - Object.entries(usdTvls).forEach(([chain, usdTvl]) => { + const usdVals = Object.entries(usdTvls) + usdVals.sort((a, b) => b[1] - a[1]) + usdVals.forEach(([chain, usdTvl]) => { if (chain !== "tvl") { - console.log(chain.padEnd(25, " "), humanizeNumber(usdTvl)); + console.log(chain.padEnd(25, " "), humanizeNumber(Math.round(usdTvl))); } }); console.log("\ntotal".padEnd(25, " "), humanizeNumber(usdTvls.tvl), "\n");