Skip to content

Commit

Permalink
feat: update carmine options (DefiLlama#9175)
Browse files Browse the repository at this point in the history
  • Loading branch information
DaveVodrazka authored and YeeeeeHan committed Apr 24, 2024
1 parent 48e557a commit 3f34606
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions projects/carmine-options/api.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
const { call, multiCall, number, sumTokens, } = require("../helper/chain/starknet");
const abi = require("./abi");

const amm = "0x076dbabc4293db346b0a56b29b6ea9fe18e93742c73f12348c8747ecfc1050aa";
const legacyAmm = "0x076dbabc4293db346b0a56b29b6ea9fe18e93742c73f12348c8747ecfc1050aa";
const amm = "0x047472e6755afc57ada9550b6a3ac93129cc4b5f98f51c73e0644d129fd208d9";

async function tvl(_, _1, _2, { api }) {
let lpTokens = await call({ abi: abi.get_all_lptoken_addresses, target: amm, })
lpTokens = number.bigNumberishArrayToHexadecimalStringArray(lpTokens.array.toString().split(','))
let underlyings = await multiCall({ abi: abi.get_underlying_token_address, target: amm, calls: lpTokens, });
return sumTokens({ owner: amm, tokens: underlyings, api, });
let legacyLpTokens = await call({ abi: abi.get_all_lptoken_addresses, target: legacyAmm, })
let newLpTokens = await call({ abi: abi.get_all_lptoken_addresses, target: amm, })
legacyLpTokens = number.bigNumberishArrayToHexadecimalStringArray(legacyLpTokens.array.toString().split(','))
newLpTokens = number.bigNumberishArrayToHexadecimalStringArray(newLpTokens.array.toString().split(','))
const legacyUnderlyings = await multiCall({ abi: abi.get_underlying_token_address, target: legacyAmm, calls: legacyLpTokens, })
const underlyings = await multiCall({ abi: abi.get_underlying_token_address, target: amm, calls: newLpTokens, })
const owners = [amm, legacyAmm];
const tokens = [...legacyUnderlyings, ...underlyings]
return sumTokens({ owners, tokens, api, })
}

module.exports = {
Expand Down

0 comments on commit 3f34606

Please sign in to comment.