Skip to content

Commit

Permalink
Add vaults and staking from fMoney (#9746)
Browse files Browse the repository at this point in the history
* added vaults and staking from fMoney

* minor fix

---------

Co-authored-by: 0xSuku <[email protected]>
  • Loading branch information
g1nt0ki and 0xSuku authored Apr 8, 2024
1 parent 721b281 commit bea7273
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 4 deletions.
24 changes: 24 additions & 0 deletions projects/fMoney/index.js
Original file line number Diff line number Diff line change
@@ -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
10 changes: 8 additions & 2 deletions projects/helper/unwrapLPs.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 => ({
Expand Down Expand Up @@ -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,
Expand Down
6 changes: 4 additions & 2 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down

0 comments on commit bea7273

Please sign in to comment.