-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Arcadia V2 TVL calculation (#9747)
* β¨ 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
1 parent
f1a5081
commit b1b4602
Showing
1 changed file
with
39 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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[])", | ||
} |