Skip to content

Commit 03e119a

Browse files
CumpsDg1nt0ki
andauthored
Chainflip tvl (DefiLlama#11464)
Co-authored-by: g1ntoki <[email protected]>
1 parent 686982a commit 03e119a

File tree

3 files changed

+60
-7
lines changed

3 files changed

+60
-7
lines changed

projects/chainflip/index.js

Lines changed: 49 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,55 @@
1-
const { staking } = require('../helper/staking');
1+
const { staking } = require('../helper/staking')
2+
const { graphQuery } = require('../helper/http');
3+
const { sumTokens2 } = require('../helper/unwrapLPs');
24

35
const STATE_CHAIN_GATEWAY_CONTRACT = '0x826180541412D574cf1336d22c0C0a287822678A';
46
const FLIP_TOKEN = '0x6995ab7c4d7f4b03f467cf4c8e920427d9621dbd'
57

6-
module.exports = {
7-
methodology: 'counts the number of FLIP tokens in the Chainflip State Chain Gateway Contract.',
8-
start: 1700740800, // FLIP went live on 2023-11-23 12:00 UTC
9-
ethereum: {
10-
tvl: () => 0,
11-
staking: staking(FLIP_TOKEN, STATE_CHAIN_GATEWAY_CONTRACT),
8+
const poolsDataQuery = `{
9+
allPools {
10+
nodes {
11+
baseAsset
12+
baseLiquidityAmount
13+
quoteAsset
14+
quoteLiquidityAmount
15+
}
16+
}
17+
allBoostPools {
18+
nodes {
19+
asset
20+
chain
21+
feeTierPips
22+
availableAmount
23+
unavailableAmount
24+
}
1225
}
26+
}`
27+
28+
const endpoint = 'https://cache-service.chainflip.io/graphql'
29+
30+
async function tvl(api) {
31+
// Call GraphQL and get tokens, add each to balance
32+
const { allPools: { nodes }, allBoostPools: { nodes: bNodes } } = await graphQuery(endpoint, poolsDataQuery);
33+
34+
nodes.forEach(i => {
35+
api.add(i.baseAsset, i.baseLiquidityAmount)
36+
api.add(i.quoteAsset, i.quoteLiquidityAmount)
37+
})
38+
bNodes.forEach(i => {
39+
api.add(i.asset, i.availableAmount)
40+
api.add(i.asset, i.unavailableAmount)
41+
})
42+
return sumTokens2({ api })
43+
}
44+
45+
module.exports = {
46+
methodology: 'The number of FLIP tokens in the Chainflip State Chain Gateway Contract, as well as the total deployed liquidity.',
47+
start: 1700740800, // FLIP went live on 2023-11-23 12:00 UTC
48+
ethereum: {
49+
tvl: () => ({}),
50+
staking: staking(FLIP_TOKEN, STATE_CHAIN_GATEWAY_CONTRACT),
51+
},
52+
chainflip: {
53+
tvl,
54+
}
1355
};

projects/helper/chains.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
"cardano",
5757
"celestia",
5858
"celo",
59+
"chainflip",
5960
"chainx",
6061
"chihuahua",
6162
"chz",

projects/helper/tokenMapping.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,16 @@ const fixBalancesTokens = {
4040
ozone: {
4141
// '0x83048f0bf34feed8ced419455a4320a735a92e9d': { coingeckoId: "ozonechain", decimals: 18 }, // was mapped to wrong chain
4242
},
43+
chainflip: {
44+
Dot: { coingeckoId:'polkadot', decimals: 10 },
45+
Usdc: { coingeckoId:'usd-coin', decimals: 6 },
46+
Flip: { coingeckoId:'chainflip', decimals: 18 },
47+
Btc: { coingeckoId:'bitcoin', decimals: 8 },
48+
Eth: { coingeckoId:'ethereum', decimals: 18 },
49+
Usdt: { coingeckoId:'tether', decimals: 6 },
50+
ArbEth: { coingeckoId:'ethereum', decimals: 18 },
51+
ArbUsdc: { coingeckoId:'usd-coin', decimals: 6 },
52+
},
4353
islm: {
4454
'0x0ce35b0d42608ca54eb7bcc8044f7087c18e7717': { coingeckoId: 'usd-coin', decimals: 6 },
4555
},

0 commit comments

Comments
 (0)