Skip to content

Commit

Permalink
Merge pull request #149 from dappradar/zksync-integrations
Browse files Browse the repository at this point in the history
Zksync integrations
  • Loading branch information
mantasfam authored Jun 28, 2023
2 parents 9abdb84 + 0d819ac commit a9d837a
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 1 deletion.
46 changes: 46 additions & 0 deletions src/factory/providers/zksync-era/overnight/index.ts
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 };
1 change: 0 additions & 1 deletion src/factory/providers/zksync-era/vesync/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import uniswapV2 from '../../../../util/calculators/uniswapV2';
import formatter from '../../../../util/formatter';
import util from '../../../../util/blockchainUtil';
import { ITvlParams, ITvlReturn } from '../../../../interfaces/ITvl';
import BigNumber from 'bignumber.js';

const START_BLOCK = 95972;
const FACTORY_ADDRESS = '0x529Bd7Fc43285B96f1e8d5158626d1F15bb8A834';
Expand Down
31 changes: 31 additions & 0 deletions src/factory/providers/zksync-era/woofi/index.ts
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 };

0 comments on commit a9d837a

Please sign in to comment.