Skip to content

Commit

Permalink
feat(tholgar): added v2 vault (#10008)
Browse files Browse the repository at this point in the history
  • Loading branch information
0xmemorygrinder authored Apr 29, 2024
1 parent 264f5c8 commit 056aa7a
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions projects/tholgar/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const abi = require("./abi.json");

const WAR_CONTROLLER = "0xFDeac9F9e4a5A7340Ac57B47C67d383fb4f13DBb";
const WAR_REDEEMER = "0x4787Ef084c1d57ED87D58a716d991F8A9CD3828C";
const VAULT_V2 = '0x2fc1E74BC8A6D15fE768c10C2EDe7D6d95ec27e9';
const VAULT = '0x188cA46Aa2c7ae10C14A931512B62991D5901453';
const WAR = '0xa8258deE2a677874a48F5320670A869D74f0cbC1';

Expand All @@ -25,7 +26,7 @@ async function getLockers(api) {
return lockers;
}

async function ethTvl(api,) {
async function warlordTvl(api, vaultAddress) {
const balances = {};

const lockers = await getLockers(api);
Expand All @@ -35,17 +36,25 @@ async function ethTvl(api,) {
const tokensQueued = await api.multiCall({ abi: abi["queuedForWithdrawal"], calls: tokens.map(i => ({ target: WAR_REDEEMER, params: [i] })) })

const totalSupply = await api.call({target: WAR, abi: abi['totalSupply']});
const vaultBalance = await api.call({ target: VAULT, abi: abi['totalAssets']});
const vaultBalance = await api.call({ target: vaultAddress, abi: abi['totalAssets']});
const ratio = vaultBalance / totalSupply;

bals.forEach((v, i) => {
// console.log(balances, tokens[i], (v - tokensQueued[i]) * ratio, Math.floor((v - tokensQueued[i]) * ratio).toString(), BigInt(1.731174581703269e+21.))
sdk.util.sumSingleBalance(balances, tokens[i], (v - tokensQueued[i]) * ratio)
})

return balances;
}

async function ethTvl(api,) {
const v1 = await warlordTvl(api, VAULT)
const v2 = await warlordTvl(api, VAULT_V2)

sdk.util.mergeBalances(v1, v2);

return v1;
}

module.exports = {
methodology: "Counts the total number of cvx and aura Locked inside Warlord and compare it to the balance of Tholgar Vault",
ethereum: {
Expand Down

0 comments on commit 056aa7a

Please sign in to comment.