Skip to content

Commit

Permalink
Add Pryzm Protocol TVL adapter (#12877)
Browse files Browse the repository at this point in the history
Co-authored-by: MadReza <mohammadreza@refractedlabs.com>
  • Loading branch information
g1nt0ki and madrezaz authored Dec 26, 2024
1 parent d416c5a commit e464026
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 1 deletion.
1 change: 1 addition & 0 deletions projects/helper/chain/cosmos.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ const endPoints = {
kopi: "https://rest.kopi.money",
noble: "https://noble-api.polkachu.com",
elys: "https://api.elys.network", // https://api.elys.network/#/Query/ElysAmmPoolAll
pryzm: "https://api.pryzm.zone"
};

const chainSubpaths = {
Expand Down
1 change: 1 addition & 0 deletions projects/helper/chains.json
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@
"pool2",
"posi",
"proton",
"pryzm",
"pulse",
"q",
"qom",
Expand Down
2 changes: 1 addition & 1 deletion projects/helper/tokenMapping.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ coreAssets = JSON.parse(JSON.stringify(coreAssets))


const ibcChains = ['ibc', 'terra', 'terra2', 'crescent', 'osmosis', 'kujira', 'stargaze', 'juno', 'injective', 'cosmos', 'comdex', 'umee', 'orai', 'persistence', 'fxcore', 'neutron', 'quasar', 'chihuahua', 'sei', 'archway', 'migaloo', 'secret', 'aura', 'xpla', 'bostrom', 'joltify', 'nibiru',
'kopi', 'elys',
'kopi', 'elys', "pryzm"

]
const caseSensitiveChains = [...ibcChains, 'solana', 'tezos', 'ton', 'algorand', 'aptos', 'near', 'bitcoin', 'waves', 'tron', 'litecoin', 'polkadot', 'ripple', 'elrond', 'cardano', 'stacks', 'sui', 'ergo', 'mvc', 'renec', 'doge', 'stellar', 'massa',
Expand Down
77 changes: 77 additions & 0 deletions projects/pryzm/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
const { get } = require('../helper/http')
const { endPoints, } = require('../helper/chain/cosmos');

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

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

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

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

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

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

function tvlOnChain(chain) {
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
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`);

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
},
};

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

0 comments on commit e464026

Please sign in to comment.