Skip to content

Commit

Permalink
Jones - add smart lp tvl
Browse files Browse the repository at this point in the history
  • Loading branch information
0xIvan committed Aug 15, 2024
1 parent 871c0ed commit b6a7b73
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 6 deletions.
12 changes: 6 additions & 6 deletions projects/jones-dao/addresses.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,20 +45,20 @@ module.exports = {
"0xF46Ce0C13577232D5F29D9Bd78a9Cab278755346",
"0x42448fDDCec02124cf6dB19a9f91Dea7bB0e88e5",
],
smartLpArbFactories: [
"0xFEFd54D82337d3Dacb5DE53083C22BA41ca76CC5",
"0xb385809cCdB2BD87A5Cd32ad09287399F0318a92",
"0xf965734b1750E64D9a01c991C5E630D279C34fd2",
"0xb754D87BdAb6Cc8c903abC2Bda9cE6B3c9481e60",
],
tokens: {
arb: ADDRESSES.arbitrum.ARB,
aura: "0xC0c293ce456fF0ED870ADd98a0828Dd4d2903DBF",
dpx: "0x6C2C06790b3E3E3c38e12Ee22F8183b37a13EE55",
dpx_eth: "0x0C1Cf6883efA1B496B01f654E247B9b419873054",
glp: ADDRESSES.arbitrum.fsGLP,
gohm: "0x8D9bA570D6cb60C7e3e0F31343Efe75AB8E65FB1",
jones: "0x10393c20975cf177a3513071bc110f7962cd67da",
jglp: "0x7241bC8035b65865156DDb5EdEf3eB32874a3AF6",
rdpx: "0x32Eb7902D4134bf98A28b963D26de779AF92A212",
rdpx_eth: "0x7418F5A2621E13c05d1EFBd71ec922070794b90a",
usdc: ADDRESSES.arbitrum.USDC_CIRCLE,
uvrt: "0xa485a0bc44988B95245D5F20497CCaFF58a73E99",
weth: ADDRESSES.arbitrum.WETH,
wjaura: "0xcB9295ac65De60373A25C18d2044D517ed5da8A9",
},
};
42 changes: 42 additions & 0 deletions projects/jones-dao/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,48 @@ async function tvl(api) {
api.addTokens(optionVaultTokens, optionVaultBalances);
api.addTokens(addresses.tokens.usdc, jusdcTvl.output);

for (const factoryAddress of addresses.smartLpArbFactories) {
const nonce = await api.call({
target: factoryAddress,
abi: "uint256:nonce",
});

const contracts = await api.multiCall({
abi: "function getLPManagerContracts(uint256 _nonce) view returns (address lp,address viewer,address swapper,address receiver,address priceHelper,address lpManager,address doubleTracker,address singleTrackerZero,address singleTrackerOne,address compounder,address router)",
calls: Array.from({ length: nonce }, (_n, i) => i + 1).map((i) => ({
target: factoryAddress,
params: [i],
})),
});
const lpManagers = contracts.map((c) => c.lpManager);

const [token0s, token1s, aums] = await Promise.all([
api.multiCall({
abi: "address:token0",
calls: lpManagers,
}),
api.multiCall({
abi: "address:token1",
calls: lpManagers,
}),
api.multiCall({
abi: "function aum() returns (uint256 amount0, uint256 amount1)",
calls: lpManagers,
}),
]);

const balancesMap = aums.reduce((acc, { amount0, amount1 }, i) => {
acc[token0s[i]] = (acc[token0s[i]] ?? BigInt(0)) + BigInt(amount0);
acc[token1s[i]] = (acc[token1s[i]] ?? BigInt(0)) + BigInt(amount1);
return acc;
}, {});

const tokens = Object.keys(balancesMap);
const balances = Object.values(balancesMap);

api.addTokens(tokens, balances);
}

const tokensAndOwners = [
[addresses.tokens.uvrt, addresses.glp.stableRewardTracker],
[addresses.tokens.uvrt, addresses.glp.router],
Expand Down

0 comments on commit b6a7b73

Please sign in to comment.