From 5d8909336e5cb61551072c47f94274e2ff56bc10 Mon Sep 17 00:00:00 2001 From: Mantas S Date: Thu, 25 Jul 2024 15:56:54 +0300 Subject: [PATCH 1/6] sushiswap ethereum and bsc --- src/factory/providers/bsc/sushiswap/data.json | 7 --- src/factory/providers/bsc/sushiswap/index.ts | 30 +--------- .../providers/ethereum/sushiswap/data.json | 7 --- .../providers/ethereum/sushiswap/index.ts | 56 ++----------------- .../ethereum/sushiswap/kashi-lending.ts | 48 ---------------- 5 files changed, 8 insertions(+), 140 deletions(-) delete mode 100644 src/factory/providers/bsc/sushiswap/data.json delete mode 100644 src/factory/providers/ethereum/sushiswap/data.json delete mode 100644 src/factory/providers/ethereum/sushiswap/kashi-lending.ts diff --git a/src/factory/providers/bsc/sushiswap/data.json b/src/factory/providers/bsc/sushiswap/data.json deleted file mode 100644 index d9e2c535..00000000 --- a/src/factory/providers/bsc/sushiswap/data.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "address": "0x947950bcc74888a40ffa2593c5798f11fc9124c4", - "name": "SushiToken", - "symbol": "SUSHI", - "decimals": 18, - "logo": "https://user-dashboard.s3.us-east-2.amazonaws.com/token_images/prod/35/0x947950bcc74888a40ffa2593c5798f11fc9124c4_large.png" -} \ No newline at end of file diff --git a/src/factory/providers/bsc/sushiswap/index.ts b/src/factory/providers/bsc/sushiswap/index.ts index 3c85ad40..9576d6e2 100644 --- a/src/factory/providers/bsc/sushiswap/index.ts +++ b/src/factory/providers/bsc/sushiswap/index.ts @@ -4,12 +4,10 @@ import { ITvlParams, ITvlReturn } from '../../../../interfaces/ITvl'; const START_BLOCK = 5205069; const FACTORY_ADDRESS = '0xc35DADB65012eC5796536bD9864eD8773aBc74C4'; -const GRAPHQL_API = - 'https://api.thegraph.com/subgraphs/name/sushiswap/bsc-exchange'; -const QUERY_SIZE = 400; async function tvl(params: ITvlParams): Promise> { const { block, chain, provider, web3 } = params; + if (block < START_BLOCK) { return {}; } @@ -27,28 +25,4 @@ async function tvl(params: ITvlParams): Promise> { return { balances, poolBalances }; } -async function getPoolVolumes(pools, priorBlockNumber) { - const poolVolumes = await uniswapV2.getPoolVolumes( - GRAPHQL_API, - QUERY_SIZE, - pools, - priorBlockNumber, - null, - ); - - return poolVolumes; -} - -async function getTokenVolumes(tokens, priorBlockNumber) { - const tokenVolumes = await uniswapV2.getTokenVolumes( - GRAPHQL_API, - QUERY_SIZE, - tokens, - priorBlockNumber, - null, - ); - - return tokenVolumes; -} - -export { tvl, getPoolVolumes, getTokenVolumes }; +export { tvl }; diff --git a/src/factory/providers/ethereum/sushiswap/data.json b/src/factory/providers/ethereum/sushiswap/data.json deleted file mode 100644 index 4015c3d3..00000000 --- a/src/factory/providers/ethereum/sushiswap/data.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "address": "0x6b3595068778dd592e39a122f4f5a5cf09c90fe2", - "name": "SushiToken", - "symbol": "SUSHI", - "decimals": 18, - "logo": "https://user-dashboard.s3.us-east-2.amazonaws.com/token_images/prod/35/0x947950bcc74888a40ffa2593c5798f11fc9124c4_large.png" -} \ No newline at end of file diff --git a/src/factory/providers/ethereum/sushiswap/index.ts b/src/factory/providers/ethereum/sushiswap/index.ts index 0517c0e2..b8dc9914 100644 --- a/src/factory/providers/ethereum/sushiswap/index.ts +++ b/src/factory/providers/ethereum/sushiswap/index.ts @@ -1,22 +1,18 @@ -import { kashiLending } from './kashi-lending'; -import BigNumber from 'bignumber.js'; +import formatter from '../../../../util/formatter'; import uniswapV2 from '../../../../util/calculators/uniswapV2'; import { ITvlParams, ITvlReturn } from '../../../../interfaces/ITvl'; -import formatter from '../../../../util/formatter'; const START_BLOCK = 10794229; -const FACTORY_ADDRESS = '0xc0aee478e3658e2610c5f7a4a2e1777ce9e4f2ac'; -const GRAPHQL_API = - 'https://api.thegraph.com/subgraphs/name/sushiswap/exchange'; -const QUERY_SIZE = 400; +const FACTORY_ADDRESS = '0xC0AEe478e3658e2610c5F7A4A2E1777cE9e4f2Ac'; async function tvl(params: ITvlParams): Promise> { const { block, chain, provider, web3 } = params; + if (block < START_BLOCK) { return {}; } - const { balances: dexBalances, poolBalances } = await uniswapV2.getTvl( + const { balances, poolBalances } = await uniswapV2.getTvl( FACTORY_ADDRESS, block, chain, @@ -24,49 +20,9 @@ async function tvl(params: ITvlParams): Promise> { web3, ); - /*const kashiBalances = await kashiLending({ - block, - chain, - provider, - web3, - } as ITvlParams);*/ - const balances = formatter.sum([dexBalances /*, kashiBalances.balances*/]); - - for (const token in balances) { - if (BigNumber(balances[token] || 0).isLessThan(100000)) { - delete balances[token]; - } - } + formatter.convertBalancesToFixed(balances); return { balances, poolBalances }; } -async function getPoolVolumes(pools, priorBlockNumber) { - const poolVolumes = await uniswapV2.getPoolVolumes( - GRAPHQL_API, - QUERY_SIZE, - pools, - priorBlockNumber, - null, - ); - - return poolVolumes; -} - -async function getTokenVolumes(tokens, priorBlockNumber) { - const tokenVolumes = await uniswapV2.getTokenVolumes( - GRAPHQL_API, - QUERY_SIZE, - tokens, - priorBlockNumber, - null, - ); - - return tokenVolumes; -} - -module.exports = { - tvl, - getPoolVolumes, - getTokenVolumes, -}; +export { tvl }; diff --git a/src/factory/providers/ethereum/sushiswap/kashi-lending.ts b/src/factory/providers/ethereum/sushiswap/kashi-lending.ts deleted file mode 100644 index e060b6de..00000000 --- a/src/factory/providers/ethereum/sushiswap/kashi-lending.ts +++ /dev/null @@ -1,48 +0,0 @@ -import { request, gql } from 'graphql-request'; -import util from '../../../../util/blockchainUtil'; -import BigNumber from 'bignumber.js'; -import { ITvlParams, ITvlReturn } from '../../../../interfaces/ITvl'; - -const graphUrl = 'https://api.thegraph.com/subgraphs/name/sushiswap/bentobox'; -const bentoboxQuery = gql` - query get_bentoboxes($block: Int, $tokensSkip: Int) { - bentoBoxes(first: 100, block: { number: $block }) { - id - tokens(first: 1000, orderBy: totalSupplyBase, orderDirection: desc) { - id - } - totalTokens - } - } -`; - -async function kashiLending(params: ITvlParams): Promise> { - const { block, chain, provider, web3 } = params; - console.time('Getting KashiBalance'); - - const boxTokens = []; - const kashiBalances = {}; - - const { bentoBoxes } = await request(graphUrl, bentoboxQuery, { block }); - - for (const bentoBox of bentoBoxes) { - boxTokens.push(...bentoBox.tokens.map((token) => token.id)); - - const boxesBalances = await util.getTokenBalances( - bentoBox.id, - boxTokens, - block, - chain, - web3, - ); - for (const boxBalance of boxesBalances) { - kashiBalances[boxBalance.token] = BigNumber( - kashiBalances[boxBalance.token] || 0, - ).plus(boxBalance.balance); - } - } - console.timeEnd('Getting KashiBalance'); - return { balances: kashiBalances }; -} - -export { kashiLending }; From ac47ab53c019fdb4f2505217d98baa5b63b49f81 Mon Sep 17 00:00:00 2001 From: Mantas S Date: Thu, 25 Jul 2024 15:57:53 +0300 Subject: [PATCH 2/6] celo --- .../providers/celo/sushiswap/data.json | 7 ---- src/factory/providers/celo/sushiswap/index.ts | 32 ++----------------- 2 files changed, 3 insertions(+), 36 deletions(-) delete mode 100644 src/factory/providers/celo/sushiswap/data.json diff --git a/src/factory/providers/celo/sushiswap/data.json b/src/factory/providers/celo/sushiswap/data.json deleted file mode 100644 index 5441876a..00000000 --- a/src/factory/providers/celo/sushiswap/data.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "address": "0xd15ec721c2a896512ad29c671997dd68f9593226", - "name": "Sushi", - "symbol": "SUSHI", - "decimals": 18, - "logo": "https://assets.coingecko.com/coins/images/12271/small/512x512_Logo_no_chop.png" -} \ No newline at end of file diff --git a/src/factory/providers/celo/sushiswap/index.ts b/src/factory/providers/celo/sushiswap/index.ts index 943f5497..6ccc3cf3 100644 --- a/src/factory/providers/celo/sushiswap/index.ts +++ b/src/factory/providers/celo/sushiswap/index.ts @@ -1,15 +1,13 @@ -import uniswapV2 from '../../../../util/calculators/uniswapV2'; import formatter from '../../../../util/formatter'; +import uniswapV2 from '../../../../util/calculators/uniswapV2'; import { ITvlParams, ITvlReturn } from '../../../../interfaces/ITvl'; const START_BLOCK = 7253488; const FACTORY_ADDRESS = '0xc35DADB65012eC5796536bD9864eD8773aBc74C4'; -const GRAPHQL_API = - 'https://api.thegraph.com/subgraphs/name/sushiswap/celo-exchange'; -const QUERY_SIZE = 400; async function tvl(params: ITvlParams): Promise> { const { block, chain, provider, web3 } = params; + if (block < START_BLOCK) { return {}; } @@ -27,28 +25,4 @@ async function tvl(params: ITvlParams): Promise> { return { balances, poolBalances }; } -async function getPoolVolumes(pools, priorBlockNumber) { - const poolVolumes = await uniswapV2.getPoolVolumes( - GRAPHQL_API, - QUERY_SIZE, - pools, - priorBlockNumber, - null, - ); - - return poolVolumes; -} - -async function getTokenVolumes(tokens, priorBlockNumber) { - const tokenVolumes = await uniswapV2.getTokenVolumes( - GRAPHQL_API, - QUERY_SIZE, - tokens, - priorBlockNumber, - null, - ); - - return tokenVolumes; -} - -export { tvl, getPoolVolumes, getTokenVolumes }; +export { tvl }; From e0e5468ee5fb533850e375e32a00a14c46c3e3d3 Mon Sep 17 00:00:00 2001 From: Mantas S Date: Thu, 25 Jul 2024 15:59:05 +0300 Subject: [PATCH 3/6] fantom --- .../providers/fantom/sushiswap/data.json | 7 --- .../providers/fantom/sushiswap/index.ts | 43 ++-------------- .../fantom/sushiswap/kashi-lending.ts | 49 ------------------- 3 files changed, 3 insertions(+), 96 deletions(-) delete mode 100644 src/factory/providers/fantom/sushiswap/data.json delete mode 100644 src/factory/providers/fantom/sushiswap/kashi-lending.ts diff --git a/src/factory/providers/fantom/sushiswap/data.json b/src/factory/providers/fantom/sushiswap/data.json deleted file mode 100644 index 58845315..00000000 --- a/src/factory/providers/fantom/sushiswap/data.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "address": "0xae75a438b2e0cb8bb01ec1e1e376de11d44477cc", - "name": "Sushi", - "symbol": "SUSHI", - "decimals": 18, - "logo": "https://user-dashboard.s3.us-east-2.amazonaws.com/token_images/prod/35/0x947950bcc74888a40ffa2593c5798f11fc9124c4_large.png" -} \ No newline at end of file diff --git a/src/factory/providers/fantom/sushiswap/index.ts b/src/factory/providers/fantom/sushiswap/index.ts index dcb94509..065f4baf 100644 --- a/src/factory/providers/fantom/sushiswap/index.ts +++ b/src/factory/providers/fantom/sushiswap/index.ts @@ -1,14 +1,9 @@ -import BigNumber from 'bignumber.js'; -import { kashiLending } from './kashi-lending'; import formatter from '../../../../util/formatter'; import uniswapV2 from '../../../../util/calculators/uniswapV2'; import { ITvlParams, ITvlReturn } from '../../../../interfaces/ITvl'; const START_BLOCK = 2457879; const FACTORY_ADDRESS = '0xc35DADB65012eC5796536bD9864eD8773aBc74C4'; -const GRAPHQL_API = - 'https://api.thegraph.com/subgraphs/name/sushiswap/fantom-exchange'; -const QUERY_SIZE = 400; async function tvl(params: ITvlParams): Promise> { const { block, chain, provider, web3 } = params; @@ -17,7 +12,7 @@ async function tvl(params: ITvlParams): Promise> { return {}; } - const { balances: dexBalances, poolBalances } = await uniswapV2.getTvl( + const { balances, poolBalances } = await uniswapV2.getTvl( FACTORY_ADDRESS, block, chain, @@ -25,41 +20,9 @@ async function tvl(params: ITvlParams): Promise> { web3, ); - //const kashiBalances = await kashiLending(block, chain, web3); - - const balances = formatter.sum([dexBalances /*, kashiBalances*/]); - - for (const token in balances) { - if (BigNumber(balances[token] || 0).isLessThan(100000)) { - delete balances[token]; - } - } + formatter.convertBalancesToFixed(balances); return { balances, poolBalances }; } -async function getPoolVolumes(pools, priorBlockNumber) { - const poolVolumes = await uniswapV2.getPoolVolumes( - GRAPHQL_API, - QUERY_SIZE, - pools, - priorBlockNumber, - null, - ); - - return poolVolumes; -} - -async function getTokenVolumes(tokens, priorBlockNumber) { - const tokenVolumes = await uniswapV2.getTokenVolumes( - GRAPHQL_API, - QUERY_SIZE, - tokens, - priorBlockNumber, - null, - ); - - return tokenVolumes; -} - -export { tvl, getPoolVolumes, getTokenVolumes }; +export { tvl }; diff --git a/src/factory/providers/fantom/sushiswap/kashi-lending.ts b/src/factory/providers/fantom/sushiswap/kashi-lending.ts deleted file mode 100644 index 7edc841f..00000000 --- a/src/factory/providers/fantom/sushiswap/kashi-lending.ts +++ /dev/null @@ -1,49 +0,0 @@ -import { request, gql } from 'graphql-request'; -import util from '../../../../util/blockchainUtil'; -import BigNumber from 'bignumber.js'; - -const graphUrl = - 'https://api.thegraph.com/subgraphs/name/sushiswap/fantom-bentobox'; -const bentoboxQuery = gql` - query get_bentoboxes($block: Int, $tokensSkip: Int) { - bentoBoxes(first: 100, block: { number: $block }) { - id - tokens(first: 1000, orderBy: totalSupplyBase, orderDirection: desc) { - id - } - totalTokens - } - } -`; - -async function kashiLending(block, chain, web3) { - console.time('Getting KashiBalance'); - - const boxTokens = []; - const kashiBalances = {}; - - const { bentoBoxes } = await request(graphUrl, bentoboxQuery, { block }); - - for (const bentoBox of bentoBoxes) { - boxTokens.push(...bentoBox.tokens.map((token) => token.id)); - - const boxesBalances = await util.getTokenBalances( - bentoBox.id, - boxTokens, - block, - chain, - web3, - ); - for (const boxBalance of boxesBalances) { - kashiBalances[boxBalance.token] = BigNumber( - kashiBalances[boxBalance.token] || 0, - ).plus(boxBalance.balance); - } - } - - console.timeEnd('Getting KashiBalance'); - - return kashiBalances; -} - -export { kashiLending }; From 9c754eb7fbb2ea24b28b38f03d5d1eadf4202931 Mon Sep 17 00:00:00 2001 From: Mantas S Date: Thu, 25 Jul 2024 16:00:02 +0300 Subject: [PATCH 4/6] moonriver --- .../providers/moonriver/sushiswap/data.json | 7 ----- .../providers/moonriver/sushiswap/index.ts | 30 ++----------------- 2 files changed, 2 insertions(+), 35 deletions(-) delete mode 100644 src/factory/providers/moonriver/sushiswap/data.json diff --git a/src/factory/providers/moonriver/sushiswap/data.json b/src/factory/providers/moonriver/sushiswap/data.json deleted file mode 100644 index b4d63311..00000000 --- a/src/factory/providers/moonriver/sushiswap/data.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "address": "", - "name": "", - "symbol": "", - "decimals": 0, - "logo": "" -} \ No newline at end of file diff --git a/src/factory/providers/moonriver/sushiswap/index.ts b/src/factory/providers/moonriver/sushiswap/index.ts index 5f98e495..b60f35b7 100644 --- a/src/factory/providers/moonriver/sushiswap/index.ts +++ b/src/factory/providers/moonriver/sushiswap/index.ts @@ -4,12 +4,10 @@ import { ITvlParams, ITvlReturn } from '../../../../interfaces/ITvl'; const START_BLOCK = 428426; const FACTORY_ADDRESS = '0xc35DADB65012eC5796536bD9864eD8773aBc74C4'; -const GRAPHQL_API = - 'https://api.thegraph.com/subgraphs/name/sushiswap/moonriver-exchange'; -const QUERY_SIZE = 400; async function tvl(params: ITvlParams): Promise> { const { block, chain, provider, web3 } = params; + if (block < START_BLOCK) { return {}; } @@ -27,28 +25,4 @@ async function tvl(params: ITvlParams): Promise> { return { balances, poolBalances }; } -async function getPoolVolumes(pools, priorBlockNumber) { - const poolVolumes = await uniswapV2.getPoolVolumes( - GRAPHQL_API, - QUERY_SIZE, - pools, - priorBlockNumber, - null, - ); - - return poolVolumes; -} - -async function getTokenVolumes(tokens, priorBlockNumber) { - const tokenVolumes = await uniswapV2.getTokenVolumes( - GRAPHQL_API, - QUERY_SIZE, - tokens, - priorBlockNumber, - null, - ); - - return tokenVolumes; -} - -export { tvl, getPoolVolumes, getTokenVolumes }; +export { tvl }; From cce79a667a6bafc918874b5bb0772e463657909d Mon Sep 17 00:00:00 2001 From: Mantas S Date: Thu, 25 Jul 2024 16:01:12 +0300 Subject: [PATCH 5/6] polygon --- .../providers/polygon/sushiswap/data.json | 7 ----- .../providers/polygon/sushiswap/index.ts | 31 ++----------------- 2 files changed, 3 insertions(+), 35 deletions(-) delete mode 100644 src/factory/providers/polygon/sushiswap/data.json diff --git a/src/factory/providers/polygon/sushiswap/data.json b/src/factory/providers/polygon/sushiswap/data.json deleted file mode 100644 index dbb3b279..00000000 --- a/src/factory/providers/polygon/sushiswap/data.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "address": "0x0b3f868e0be5597d5db7feb59e1cadbb0fdda50a", - "name": "SushiToken (PoS)", - "symbol": "SUSHI", - "decimals": 18, - "logo": "https://user-dashboard.s3.us-east-2.amazonaws.com/token_images/prod/35/0x947950bcc74888a40ffa2593c5798f11fc9124c4_large.png" -} \ No newline at end of file diff --git a/src/factory/providers/polygon/sushiswap/index.ts b/src/factory/providers/polygon/sushiswap/index.ts index 9c4905b5..e5e212cf 100644 --- a/src/factory/providers/polygon/sushiswap/index.ts +++ b/src/factory/providers/polygon/sushiswap/index.ts @@ -4,12 +4,10 @@ import { ITvlParams, ITvlReturn } from '../../../../interfaces/ITvl'; const START_BLOCK = 11333218; const FACTORY_ADDRESS = '0xc35DADB65012eC5796536bD9864eD8773aBc74C4'; -const GRAPHQL_API = - 'https://api.thegraph.com/subgraphs/name/sushiswap/matic-exchange'; -const QUERY_SIZE = 400; async function tvl(params: ITvlParams): Promise> { const { block, chain, provider, web3 } = params; + if (block < START_BLOCK) { return {}; } @@ -23,31 +21,8 @@ async function tvl(params: ITvlParams): Promise> { ); formatter.convertBalancesToFixed(balances); - return { balances, poolBalances }; -} - -async function getPoolVolumes(pools, priorBlockNumber) { - const poolVolumes = await uniswapV2.getPoolVolumes( - GRAPHQL_API, - QUERY_SIZE, - pools, - priorBlockNumber, - null, - ); - return poolVolumes; -} - -async function getTokenVolumes(tokens, priorBlockNumber) { - const tokenVolumes = await uniswapV2.getTokenVolumes( - GRAPHQL_API, - QUERY_SIZE, - tokens, - priorBlockNumber, - null, - ); - - return tokenVolumes; + return { balances, poolBalances }; } -export { tvl, getPoolVolumes, getTokenVolumes }; +export { tvl }; From 0ecbaacb038c8e10bff557e52458dbfef59f860c Mon Sep 17 00:00:00 2001 From: Mantas S Date: Thu, 25 Jul 2024 16:03:30 +0300 Subject: [PATCH 6/6] arb, avax --- .../providers/arbitrum/sushiswap/data.json | 7 --- .../providers/arbitrum/sushiswap/index.ts | 51 ++++--------------- .../providers/arbitrum/sushiswap/trident.ts | 47 ----------------- .../providers/avalanche/sushiswap/index.ts | 28 ++++++++++ 4 files changed, 38 insertions(+), 95 deletions(-) delete mode 100644 src/factory/providers/arbitrum/sushiswap/data.json delete mode 100644 src/factory/providers/arbitrum/sushiswap/trident.ts create mode 100644 src/factory/providers/avalanche/sushiswap/index.ts diff --git a/src/factory/providers/arbitrum/sushiswap/data.json b/src/factory/providers/arbitrum/sushiswap/data.json deleted file mode 100644 index 97f25640..00000000 --- a/src/factory/providers/arbitrum/sushiswap/data.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "address": "0xd4d42f0b6def4ce0383636770ef773390d85c61a", - "name": "Sushi", - "symbol": "SUSHI", - "decimals": 18, - "logo": "https://user-dashboard.s3.us-east-2.amazonaws.com/token_images/prod/35/0x947950bcc74888a40ffa2593c5798f11fc9124c4_large.png" -} \ No newline at end of file diff --git a/src/factory/providers/arbitrum/sushiswap/index.ts b/src/factory/providers/arbitrum/sushiswap/index.ts index f260a6b0..8d64c9ea 100644 --- a/src/factory/providers/arbitrum/sushiswap/index.ts +++ b/src/factory/providers/arbitrum/sushiswap/index.ts @@ -1,18 +1,18 @@ -import { ITvlParams, ITvlReturn } from '../../../../interfaces/ITvl'; -import uniswapV2 from '../../../../util/calculators/uniswapV2'; -import { trident } from './trident'; -import BigNumber from 'bignumber.js'; import formatter from '../../../../util/formatter'; +import uniswapV2 from '../../../../util/calculators/uniswapV2'; +import { ITvlParams, ITvlReturn } from '../../../../interfaces/ITvl'; +const START_BLOCK = 70; const FACTORY_ADDRESS = '0xc35DADB65012eC5796536bD9864eD8773aBc74C4'; -const GRAPHQL_API = - 'https://api.thegraph.com/subgraphs/name/sushi-labs/kashi-arbitrum'; -const QUERY_SIZE = 500; async function tvl(params: ITvlParams): Promise> { const { block, chain, provider, web3 } = params; - const { balances: dexBalances, poolBalances } = await uniswapV2.getTvl( + if (block < START_BLOCK) { + return {}; + } + + const { balances, poolBalances } = await uniswapV2.getTvl( FACTORY_ADDRESS, block, chain, @@ -20,40 +20,9 @@ async function tvl(params: ITvlParams): Promise> { web3, ); - //const { balances: tridentBalance } = await trident(params); + formatter.convertBalancesToFixed(balances); - const balances = formatter.sum([dexBalances /*, tridentBalance*/]); - - for (const token in balances) { - if (BigNumber(balances[token] || 0).isLessThan(100000)) { - delete balances[token]; - } - } return { balances, poolBalances }; } -async function getPoolVolumes(pools, priorBlockNumber) { - const poolVolumes = await uniswapV2.getPoolVolumes( - GRAPHQL_API, - QUERY_SIZE, - pools, - priorBlockNumber, - null, - ); - - return poolVolumes; -} - -async function getTokenVolumes(tokens, priorBlockNumber) { - const tokenVolumes = await uniswapV2.getTokenVolumes( - GRAPHQL_API, - QUERY_SIZE, - tokens, - priorBlockNumber, - null, - ); - - return tokenVolumes; -} - -export { tvl, getPoolVolumes, getTokenVolumes }; +export { tvl }; diff --git a/src/factory/providers/arbitrum/sushiswap/trident.ts b/src/factory/providers/arbitrum/sushiswap/trident.ts deleted file mode 100644 index 3b905441..00000000 --- a/src/factory/providers/arbitrum/sushiswap/trident.ts +++ /dev/null @@ -1,47 +0,0 @@ -import { ITvlParams, ITvlReturn } from '../../../../interfaces/ITvl'; -import BigNumber from 'bignumber.js'; -import { gql, request } from 'graphql-request'; - -const GRAPHQL_API_TRIDENT = - 'https://api.thegraph.com/subgraphs/name/sushi-v2/trident-arbitrum'; -const TOKENS = gql` - query get_tokens($block: Int) { - tokens( - block: { number: $block } - first: 1000 - orderBy: liquidityUSD - orderDirection: desc - where: { liquidityUSD_gt: 0 } - ) { - id - liquidity - } - } -`; -async function trident(params: ITvlParams): Promise> { - const { block, chain, provider, web3 } = params; - - const requestResult = await request(GRAPHQL_API_TRIDENT, TOKENS, { - block: block, - }); - const balances = {}; - requestResult.tokens.forEach((token) => { - if (balances[token.id]) { - balances[token.id] = BigNumber(token.liquidity) - .plus(balances[token.id]) - .toFixed(); - } else { - balances[token.id] = BigNumber(token.liquidity).toFixed(); - } - }); - - for (const token in balances) { - if (BigNumber(balances[token] || 0).isLessThan(100000)) { - delete balances[token]; - } - } - - return { balances }; -} - -export { trident }; diff --git a/src/factory/providers/avalanche/sushiswap/index.ts b/src/factory/providers/avalanche/sushiswap/index.ts new file mode 100644 index 00000000..8a221692 --- /dev/null +++ b/src/factory/providers/avalanche/sushiswap/index.ts @@ -0,0 +1,28 @@ +import formatter from '../../../../util/formatter'; +import uniswapV2 from '../../../../util/calculators/uniswapV2'; +import { ITvlParams, ITvlReturn } from '../../../../interfaces/ITvl'; + +const START_BLOCK = 506190; +const FACTORY_ADDRESS = '0xc35DADB65012eC5796536bD9864eD8773aBc74C4'; + +async function tvl(params: ITvlParams): Promise> { + const { block, chain, provider, web3 } = params; + + if (block < START_BLOCK) { + return {}; + } + + const { balances, poolBalances } = await uniswapV2.getTvl( + FACTORY_ADDRESS, + block, + chain, + provider, + web3, + ); + + formatter.convertBalancesToFixed(balances); + + return { balances, poolBalances }; +} + +export { tvl };