-
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 #149 from dappradar/zksync-integrations
Zksync integrations
- Loading branch information
Showing
3 changed files
with
77 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import util from '../../../../util/blockchainUtil'; | ||
import { ITvlParams, ITvlReturn } from '../../../../interfaces/ITvl'; | ||
import BigNumber from 'bignumber.js'; | ||
|
||
const ABI = [ | ||
{ | ||
inputs: [], | ||
name: 'totalNetAssets', | ||
outputs: [ | ||
{ | ||
internalType: 'uint256', | ||
name: '', | ||
type: 'uint256', | ||
}, | ||
], | ||
stateMutability: 'view', | ||
type: 'function', | ||
}, | ||
]; | ||
const START_BLOCK = 724058; | ||
const MARK_TO_MARKET_ADDRESS = '0x240aad990FFc5F04F11593fF4dCF1fF714d6fc80'; | ||
const USDC_ADDRESS = '0x3355df6d4c9c3035724fd0e3914de96a5a83aaf4'; | ||
|
||
async function tvl(params: ITvlParams): Promise<Partial<ITvlReturn>> { | ||
const { block, chain, provider, web3 } = params; | ||
const balances = {}; | ||
if (block < START_BLOCK) { | ||
return { balances }; | ||
} | ||
|
||
const usdcBalance = await util.executeCall( | ||
MARK_TO_MARKET_ADDRESS, | ||
ABI, | ||
'totalNetAssets', | ||
[], | ||
block, | ||
chain, | ||
web3, | ||
); | ||
|
||
balances[USDC_ADDRESS] = new BigNumber(usdcBalance).toFixed(); | ||
|
||
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
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,31 @@ | ||
import formatter from '../../../../util/formatter'; | ||
import util from '../../../../util/blockchainUtil'; | ||
import { ITvlParams, ITvlReturn } from '../../../../interfaces/ITvl'; | ||
|
||
const START_BLOCK = 1466617; | ||
const WOOPPV2_ADDRESS = '0x42ED123EB5266A5B8E2B54B2C76180CCF5e72FEe'; | ||
const USDC_ADDRESS = '0x3355df6d4c9c3035724fd0e3914de96a5a83aaf4'; | ||
const WETH_ADDRESS = '0x5aea5775959fbc2557cc8789bc1bf90a239d9a91'; | ||
|
||
async function tvl(params: ITvlParams): Promise<Partial<ITvlReturn>> { | ||
const { block, chain, provider, web3 } = params; | ||
const balances = {}; | ||
if (block < START_BLOCK) { | ||
return { balances }; | ||
} | ||
|
||
const tokenBalances = await util.getTokenBalances( | ||
WOOPPV2_ADDRESS, | ||
[USDC_ADDRESS, WETH_ADDRESS], | ||
block, | ||
chain, | ||
web3, | ||
); | ||
|
||
formatter.sumMultiBalanceOf(balances, tokenBalances, chain, provider); | ||
formatter.convertBalancesToFixed(balances); | ||
|
||
return { balances }; | ||
} | ||
|
||
export { tvl }; |