-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #296 from dappradar/Refactoring
sushiswap refactoring
- Loading branch information
Showing
18 changed files
with
57 additions
and
437 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,59 +1,28 @@ | ||
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<Partial<ITvlReturn>> { | ||
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, | ||
provider, | ||
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 }; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<Partial<ITvlReturn>> { | ||
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 }; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,72 +1,28 @@ | ||
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<Partial<ITvlReturn>> { | ||
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, | ||
provider, | ||
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 }; |
Oops, something went wrong.