-
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 #294 from dappradar/Skale-Europa-integration
Skale Europa integrations
- Loading branch information
Showing
8 changed files
with
158 additions
and
0 deletions.
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
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 = 3823515; | ||
const FACTORY_ADDRESS = '0xc318a82CB7c2B0faf7e355BB8F285016956aBF55'; | ||
|
||
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 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,29 @@ | ||
import { ITvlParams, ITvlReturn } from '../../../../interfaces/ITvl'; | ||
import axios from 'axios'; | ||
import formatter from '../../../../util/formatter'; | ||
import util from '../../../../util/blockchainUtil'; | ||
|
||
const URI = 'https://relayer.meson.fi/api/v1/list'; | ||
|
||
async function tvl(params: ITvlParams): Promise<Partial<ITvlReturn>> { | ||
const { block, chain, provider, web3 } = params; | ||
|
||
const balances = {}; | ||
const skaleEuropaData = (await axios.get(URI)).data.result.find( | ||
(item: any) => item.id === 'skale-europa', | ||
); | ||
|
||
const tokenBalances = await util.getTokenBalances( | ||
skaleEuropaData.address, | ||
skaleEuropaData.tokens.map((token: any) => token.addr), | ||
block, | ||
chain, | ||
web3, | ||
); | ||
|
||
formatter.sumMultiBalanceOf(balances, tokenBalances, chain, provider); | ||
formatter.convertBalancesToFixed(balances); | ||
return { balances }; | ||
} | ||
|
||
export { tvl }; |
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,42 @@ | ||
import formatter from '../../../../util/formatter'; | ||
import uniswapV2 from '../../../../util/calculators/uniswapV2'; | ||
import { ITvlParams, ITvlReturn } from '../../../../interfaces/ITvl'; | ||
import util from '../../../../util/blockchainUtil'; | ||
|
||
const START_BLOCK = 50404; | ||
const FACTORY_ADDRESS = '0x71f7bbbb33550fa5d70ca3f7eead87529f2dc3c8'; | ||
|
||
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, | ||
); | ||
|
||
const tokenBalances = await util.getTokenBalances( | ||
'0x45c550dc634bcc271c092a20d36761d3bb834e5d', | ||
[ | ||
'0x73d22d8a2D1f59Bf5Bcf62cA382481a2073FAF58', | ||
'0x1c0491E3396AD6a35f061c62387a95d7218FC515', | ||
'0x5F795bb52dAC3085f578f4877D450e2929D2F13d', | ||
'0xD05C4be5f3be302d376518c9492EC0147Fa5A718', | ||
], | ||
block, | ||
chain, | ||
web3, | ||
); | ||
|
||
formatter.sumMultiBalanceOf(balances, tokenBalances, chain, provider); | ||
formatter.convertBalancesToFixed(balances); | ||
return { balances, poolBalances }; | ||
} | ||
|
||
export { tvl }; |
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 = 5124080; | ||
const FACTORY_ADDRESS = '0x1aaF6eB4F85F8775400C1B10E6BbbD98b2FF8483'; | ||
|
||
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 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,25 @@ | ||
import { ITvlParams, ITvlReturn } from '../../../../interfaces/ITvl'; | ||
import uniswapV3 from '../../../../util/calculators/uniswapV3chain'; | ||
|
||
const V3_START_BLOCK = 5124251; | ||
const V3_FACTORY_ADDRESS = '0x51d15889b66A2c919dBbD624d53B47a9E8feC4bB'; | ||
|
||
async function tvl(params: ITvlParams): Promise<Partial<ITvlReturn>> { | ||
const { block, chain, provider, web3 } = params; | ||
if (block < V3_START_BLOCK) { | ||
return { balances: {} }; | ||
} | ||
|
||
const balances = await uniswapV3.getTvl( | ||
V3_FACTORY_ADDRESS, | ||
V3_START_BLOCK, | ||
block, | ||
chain, | ||
provider, | ||
web3, | ||
); | ||
|
||
return { balances, poolBalances: {} }; | ||
} | ||
|
||
export { tvl }; |
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