|
1 |
| -const { staking } = require('../helper/staking'); |
| 1 | +const { staking } = require('../helper/staking') |
| 2 | +const { graphQuery } = require('../helper/http'); |
| 3 | +const { sumTokens2 } = require('../helper/unwrapLPs'); |
2 | 4 |
|
3 | 5 | const STATE_CHAIN_GATEWAY_CONTRACT = '0x826180541412D574cf1336d22c0C0a287822678A';
|
4 | 6 | const FLIP_TOKEN = '0x6995ab7c4d7f4b03f467cf4c8e920427d9621dbd'
|
5 | 7 |
|
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 | + } |
12 | 25 | }
|
| 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 | + } |
13 | 55 | };
|
0 commit comments