Skip to content

Commit

Permalink
minor fix
Browse files Browse the repository at this point in the history
  • Loading branch information
g1nt0ki committed Dec 26, 2024
1 parent 69aac02 commit 808b49e
Showing 1 changed file with 51 additions and 61 deletions.
112 changes: 51 additions & 61 deletions projects/pryzm/index.js
Original file line number Diff line number Diff line change
@@ -1,87 +1,77 @@
const { get } = require('../helper/http')
const sdk = require("@defillama/sdk");
const { endPoints, sumTokens, getBalance2 } = require('../helper/chain/cosmos');
const { endPoints, } = require('../helper/chain/cosmos');

const host_chains = {
cosmos: {
hostChainId: "uatom",
coinGeckoId: "cosmos",
decimals: 1e6,
},
cosmos: {
hostChainId: "uatom",
coinGeckoId: "cosmos",
decimals: 1e6,
},

injective: {
hostChainId: "inj",
coinGeckoId: "injective-protocol",
decimals: 1e18,
},
injective: {
hostChainId: "inj",
coinGeckoId: "injective-protocol",
decimals: 1e18,
},

osmosis: {
hostChainId: "uosmo",
coinGeckoId: "osmosis",
decimals: 1e6,
},
osmosis: {
hostChainId: "uosmo",
coinGeckoId: "osmosis",
decimals: 1e6,
},

terra2: {
hostChainId: "uluna",
coinGeckoId: "terra-luna-2",
decimals: 1e6,
},
terra2: {
hostChainId: "uluna",
coinGeckoId: "terra-luna-2",
decimals: 1e6,
},

celestia: {
hostChainId: "utia",
coinGeckoId: "celestia",
decimals: 1e6,
},
celestia: {
hostChainId: "utia",
coinGeckoId: "celestia",
decimals: 1e6,
},
};

const endpoint = endPoints["pryzm"]
const amm_vault_address = "pryzm1y7d08j5uy7kgurnv4pwag8h34m2cgptcwe75wn";

function tvlOnChain(chain) {
return async () => {
const [{ amount: coin }, { host_chain_state: state }] =
await Promise.all([
await get(`${endpoint}/cosmos/bank/v1beta1/supply/by_denom?denom=c:${chain.hostChainId}`),
await get(`${endpoint}/pryzm/icstaking/v1/host_chain_state/${chain.hostChainId}`),
]);
return async (api) => {
const [{ amount: coin }, { host_chain_state: state }] =
await Promise.all([
await get(`${endpoint}/cosmos/bank/v1beta1/supply/by_denom?denom=c:${chain.hostChainId}`),
await get(`${endpoint}/pryzm/icstaking/v1/host_chain_state/${chain.hostChainId}`),
]);

const balance = coin.amount * state.exchange_rate / chain.decimals;

const balances = {};

sdk.util.sumSingleBalance(
balances,
chain.coinGeckoId,
balance
);

return balances;
};
const balance = coin.amount * state.exchange_rate / chain.decimals
api.addCGToken(chain.coinGeckoId, balance)
};
}

async function tvl(api) {
const { balances: data } =
await get(`${endpoint}/cosmos/bank/v1beta1/balances/${amm_vault_address}?pagination.limit=1000`);
const { balances: data } =
await get(`${endpoint}/cosmos/bank/v1beta1/balances/${amm_vault_address}?pagination.limit=1000`);

for (const { denom, amount } of data) {
if (denom.startsWith("c:") ||
denom.startsWith("p:") ||
denom.startsWith("y:") ||
denom.startsWith("lp:")
) {
continue
}
api.add(denom, amount);
for (const { denom, amount } of data) {
if (denom.startsWith("c:") ||
denom.startsWith("p:") ||
denom.startsWith("y:") ||
denom.startsWith("lp:")
) {
continue
}
api.add(denom, amount);
}
}

module.exports = {
methodology: "Counts the liquidity on liquid staking module and all AMM pools",
pryzm: {
tvl
},
methodology: "Counts the liquidity on liquid staking module and all AMM pools",
pryzm: {
tvl
},
};

for (const chainName of Object.keys(host_chains)) {
module.exports[chainName] = { tvl: tvlOnChain(host_chains[chainName]) };
module.exports[chainName] = { tvl: tvlOnChain(host_chains[chainName]) };
}

0 comments on commit 808b49e

Please sign in to comment.