Skip to content

Commit e464026

Browse files
g1nt0kimadrezaz
andauthored
Add Pryzm Protocol TVL adapter (DefiLlama#12877)
Co-authored-by: MadReza <[email protected]>
1 parent d416c5a commit e464026

File tree

4 files changed

+80
-1
lines changed

4 files changed

+80
-1
lines changed

projects/helper/chain/cosmos.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ const endPoints = {
4646
kopi: "https://rest.kopi.money",
4747
noble: "https://noble-api.polkachu.com",
4848
elys: "https://api.elys.network", // https://api.elys.network/#/Query/ElysAmmPoolAll
49+
pryzm: "https://api.pryzm.zone"
4950
};
5051

5152
const chainSubpaths = {

projects/helper/chains.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,7 @@
269269
"pool2",
270270
"posi",
271271
"proton",
272+
"pryzm",
272273
"pulse",
273274
"q",
274275
"qom",

projects/helper/tokenMapping.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ coreAssets = JSON.parse(JSON.stringify(coreAssets))
1919

2020

2121
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',
22-
'kopi', 'elys',
22+
'kopi', 'elys', "pryzm"
2323

2424
]
2525
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',

projects/pryzm/index.js

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
const { get } = require('../helper/http')
2+
const { endPoints, } = require('../helper/chain/cosmos');
3+
4+
const host_chains = {
5+
cosmos: {
6+
hostChainId: "uatom",
7+
coinGeckoId: "cosmos",
8+
decimals: 1e6,
9+
},
10+
11+
injective: {
12+
hostChainId: "inj",
13+
coinGeckoId: "injective-protocol",
14+
decimals: 1e18,
15+
},
16+
17+
osmosis: {
18+
hostChainId: "uosmo",
19+
coinGeckoId: "osmosis",
20+
decimals: 1e6,
21+
},
22+
23+
terra2: {
24+
hostChainId: "uluna",
25+
coinGeckoId: "terra-luna-2",
26+
decimals: 1e6,
27+
},
28+
29+
celestia: {
30+
hostChainId: "utia",
31+
coinGeckoId: "celestia",
32+
decimals: 1e6,
33+
},
34+
};
35+
36+
const endpoint = endPoints["pryzm"]
37+
const amm_vault_address = "pryzm1y7d08j5uy7kgurnv4pwag8h34m2cgptcwe75wn";
38+
39+
function tvlOnChain(chain) {
40+
return async (api) => {
41+
const [{ amount: coin }, { host_chain_state: state }] =
42+
await Promise.all([
43+
await get(`${endpoint}/cosmos/bank/v1beta1/supply/by_denom?denom=c:${chain.hostChainId}`),
44+
await get(`${endpoint}/pryzm/icstaking/v1/host_chain_state/${chain.hostChainId}`),
45+
]);
46+
47+
const balance = coin.amount * state.exchange_rate / chain.decimals
48+
api.addCGToken(chain.coinGeckoId, balance)
49+
};
50+
}
51+
52+
async function tvl(api) {
53+
const { balances: data } =
54+
await get(`${endpoint}/cosmos/bank/v1beta1/balances/${amm_vault_address}?pagination.limit=1000`);
55+
56+
for (const { denom, amount } of data) {
57+
if (denom.startsWith("c:") ||
58+
denom.startsWith("p:") ||
59+
denom.startsWith("y:") ||
60+
denom.startsWith("lp:")
61+
) {
62+
continue
63+
}
64+
api.add(denom, amount);
65+
}
66+
}
67+
68+
module.exports = {
69+
methodology: "Counts the liquidity on liquid staking module and all AMM pools",
70+
pryzm: {
71+
tvl
72+
},
73+
};
74+
75+
for (const chainName of Object.keys(host_chains)) {
76+
module.exports[chainName] = { tvl: tvlOnChain(host_chains[chainName]) };
77+
}

0 commit comments

Comments
 (0)