-
Notifications
You must be signed in to change notification settings - Fork 24
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 #284 from dappradar/Xai-chain-integration
xai setup and camelot dapp
- Loading branch information
Showing
4 changed files
with
45 additions
and
1 deletion.
There are no files selected for viewing
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 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 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 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,41 @@ | ||
import formatter from '../../../../util/formatter'; | ||
import uniswapV2 from '../../../../util/calculators/uniswapV2'; | ||
import uniswapV3 from '../../../../util/calculators/uniswapV3chain'; | ||
import { ITvlParams, ITvlReturn } from '../../../../interfaces/ITvl'; | ||
|
||
const START_BLOCK = 2398999; | ||
const V2_FACTORY_ADDRESS = '0x18E621B64d7808c3C47bccbbD7485d23F257D26f'; | ||
const V3_FACTORY_ADDRESS = '0xD8676fBdfa5b56BB2298D452c9768f51e80e34AE'; | ||
|
||
async function tvl(params: ITvlParams): Promise<Partial<ITvlReturn>> { | ||
const { block, chain, provider, web3 } = params; | ||
if (block < START_BLOCK) { | ||
return { balances: {} }; | ||
} | ||
|
||
let balances = {}; | ||
|
||
const v2 = await uniswapV2.getTvl( | ||
V2_FACTORY_ADDRESS, | ||
block, | ||
chain, | ||
provider, | ||
web3, | ||
); | ||
|
||
balances = await uniswapV3.getTvl( | ||
V3_FACTORY_ADDRESS, | ||
START_BLOCK, | ||
block, | ||
chain, | ||
provider, | ||
web3, | ||
true, | ||
); | ||
|
||
balances = formatter.sum([v2.balances, balances]); | ||
|
||
return { balances }; | ||
} | ||
|
||
export { tvl }; |