Skip to content

Commit

Permalink
Fix: Quicksilver (filter out undefined)
Browse files Browse the repository at this point in the history
  • Loading branch information
0xpeluche committed Sep 30, 2024
1 parent 143b391 commit 523d378
Showing 1 changed file with 9 additions and 28 deletions.
37 changes: 9 additions & 28 deletions projects/quicksilver/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,32 +16,15 @@ const coinGeckoIds = {

async function tvl() {
const balances = {};
const { zones } = await get(endPoints.quicksilver + "/quicksilver/interchainstaking/v1/zones");
const { supply } = await get(endPoints.quicksilver + "/cosmos/bank/v1beta1/supply");

const { zones } = await get(
endPoints.quicksilver + "/quicksilver/interchainstaking/v1/zones"
);
const { supply } = await get(
endPoints.quicksilver + "/cosmos/bank/v1beta1/supply"
);

zones.map((zone) => {
const balance = supply.find((coin) => {
return coin.denom === zone.local_denom;
});
let amount = balance.amount / 1e6;
if (zone.base_denom === "adydx")
amount = balance.amount / 1e18

zones.forEach((zone) => {
const balance = supply.find((coin) => coin.denom === zone.local_denom);
if (!balance) return
const amount = zone.base_denom === "adydx" ? balance.amount / 1e18 : balance.amount / Math.pow(10, 6)
const id = coinGeckoIds[zone.base_denom]
if (!id) {
throw new Error("Missing CoinGecko ID for denom " + zone.base_denom);
}

sdk.util.sumSingleBalance(
balances,
id,
amount * zone.redemption_rate
);
sdk.util.sumSingleBalance(balances, id, amount * zone.redemption_rate);
});

return balances;
Expand All @@ -50,7 +33,5 @@ async function tvl() {
module.exports = {
timetravel: false,
methodology: "Sum of all the tokens that are liquid staked on Quicksilver",
quicksilver: {
tvl,
},
}; // node test.js projects/quicksilver/index.js
quicksilver: { tvl },
};

0 comments on commit 523d378

Please sign in to comment.