Skip to content

Commit

Permalink
Add Arcadia V2 TVL calculation (#9747)
Browse files Browse the repository at this point in the history
* ✨ add Arcadia V2 TVL

* πŸ“ update methodology

* 🎨 prettify & cleanup

* πŸ“ update methodology typo

* code refactor

---------

Co-authored-by: j-vp <[email protected]>
Co-authored-by: Jasper <[email protected]>
  • Loading branch information
3 people authored Apr 8, 2024
1 parent f1a5081 commit b1b4602
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions projects/arcadia-finance-v2/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
const { sumTokens2 } = require('../helper/unwrapLPs')

const config = {
base: {
factory: "0xDa14Fdd72345c4d2511357214c5B89A919768e59",
pools: {
wethPool: "0x803ea69c7e87D1d6C86adeB40CB636cC0E6B98E2",
usdcPool: "0x3ec4a293Fb906DD2Cd440c20dECB250DeF141dF1",
},
uniNFT: '0x03a520b32c04bf3beef7beb72e919cf822ed34f1',
},
}

async function tvl(api) {
let { factory, pools, uniNFT, } = config[api.chain];
pools = Object.values(pools);
const uTokens = await api.multiCall({ abi: "address:asset", calls: pools })
await api.sumTokens({ tokensAndOwners2: [uTokens, pools] })
const accounts = await api.fetchList({ lengthAbi: 'allAccountsLength', itemAbi: 'allAccounts', target: factory, });

const assetData = await api.multiCall({ abi: abi.assetData, calls: accounts, });
const ownerTokens = accounts.map((account, i) => [assetData[i].assets, account])
await api.sumTokens({ ownerTokens, blacklistedTokens: [uniNFT] })
return sumTokens2({ api, owners: accounts, resolveUniV3: true })
}

module.exports = {
methodology:
"TVL is calculated as the sum of all Account values and the available balance in the liquidity pools. Assets are not double counted.",
base: { tvl },
start: 1711389600, // Mon Mar 25 2024 18:00:00 GMT+0000
hallmarks: [
[Math.floor(new Date("2024-04-03") / 1e3), "Points program announced."],
],
};

const abi = {
"assetData": "function generateAssetData() view returns (address[] assets, uint256[], uint256[])",
}

0 comments on commit b1b4602

Please sign in to comment.