Skip to content

Commit 22c9cc9

Browse files
adding DegenHive adapter (DefiLlama#12429)
Co-authored-by: g1nt0ki <[email protected]>
1 parent e290b80 commit 22c9cc9

File tree

3 files changed

+93
-0
lines changed

3 files changed

+93
-0
lines changed

projects/DegenHive-amm/index.js

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
const sui = require("../helper/chain/sui");
2+
const { cachedGraphQuery } = require('../helper/cache');
3+
4+
const graphQL_endpoint = "https://5lox8etck8.execute-api.eu-central-1.amazonaws.com/api/v1";
5+
const GET_SUI_POOLS = `query GetSuiPools {
6+
getSuiPools {
7+
pools {
8+
poolId
9+
}
10+
}
11+
}`
12+
13+
async function tvl(api) {
14+
const sui_pools = await cachedGraphQuery('degen-hive-sui-pools', graphQL_endpoint, GET_SUI_POOLS);
15+
const poolIds = sui_pools.getSuiPools.pools.map(pool => pool.poolId);
16+
const suiPoolsData = await sui.getObjects(poolIds);
17+
18+
for (const { type, fields } of suiPoolsData) {
19+
if (fields.coin_x_reserve == 0 && fields.coin_y_reserve == 0) continue;
20+
let coin_x_type = type.split('<')[1].split(',')[0].trim();
21+
let coin_y_type = type.split('<')[1].split(',')[1].trim();
22+
23+
api.add(coin_x_type, fields.coin_x_reserve);
24+
api.add(coin_y_type, fields.coin_y_reserve);
25+
26+
if (fields.coin_z_reserve && fields.coin_z_reserve > 0) {
27+
let coin_z_type = type.split('<')[1].split(',')[2].trim();
28+
api.add(coin_z_type, fields.coin_z_reserve);
29+
}
30+
}
31+
}
32+
33+
// Export first
34+
module.exports = {
35+
timetravel: false,
36+
sui: {
37+
tvl,
38+
},
39+
methodology: "TVL consists of the liquidity in the DegenHive's AMM pools."
40+
};

projects/DegenHive-dsui/index.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
const sui = require("../helper/chain/sui");
2+
3+
async function tvl(api) {
4+
5+
// Add TVL from SUI liquid staking
6+
const dsui_vault = await sui.getObject("0x85aaf87a770b4a09822e7ca3de7f9424a4f58688cfa120f55b294a98d599d402");
7+
let sui_staked = Number(Number(dsui_vault.fields.dsui_supply * dsui_vault.fields.sui_claimable_per_dsui / 1e9 + dsui_vault.fields.sui_to_stake).toFixed(0));
8+
api.add( "0x2::sui::SUI", sui_staked)
9+
10+
}
11+
12+
module.exports = {
13+
timetravel: false,
14+
sui: {
15+
tvl,
16+
},
17+
methodology: "TVL consists of SUI staked with DegenHive's liquid staking protocol."
18+
};

projects/DegenHive-memepad/index.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
const sui = require("../helper/chain/sui");
2+
const { cachedGraphQuery } = require('../helper/cache');
3+
4+
const graphQL_endpoint = "https://5lox8etck8.execute-api.eu-central-1.amazonaws.com/api/v1";
5+
const GET_SUI_MEME_POOLS = `query GetSuiMemePools {
6+
getSuiMemePools {
7+
pools {
8+
meme_pool_addr
9+
}
10+
}
11+
}`
12+
13+
14+
15+
async function tvl(api) {
16+
const sui_meme_pools = await cachedGraphQuery('degen-hive-sui-meme-pools', graphQL_endpoint, GET_SUI_MEME_POOLS);
17+
18+
// Extract arrays of pool IDs
19+
const poolIds = sui_meme_pools.getSuiMemePools.pools.map(pool => pool.meme_pool_addr);
20+
const suiMemePoolsData = await sui.getObjects(poolIds)
21+
22+
// Add TVL for MEME Pools
23+
for (const { fields } of suiMemePoolsData) {
24+
if ( fields.sui_available == 0) continue;
25+
api.add( "0x2::sui::SUI", fields.sui_available)
26+
}
27+
}
28+
29+
module.exports = {
30+
timetravel: false,
31+
sui: {
32+
tvl,
33+
},
34+
methodology: "TVL consists of the liquidity in meme-coin launchpad pools."
35+
};

0 commit comments

Comments
 (0)