From 3aeffd4f0ad2359d3b8f9fbab7beee875096e070 Mon Sep 17 00:00:00 2001 From: Mantas S Date: Wed, 28 Jun 2023 11:32:38 +0300 Subject: [PATCH 1/2] overnight integration --- .../providers/zksync-era/overnight/index.ts | 46 +++++++++++++++++++ .../providers/zksync-era/vesync/index.ts | 1 - 2 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 src/factory/providers/zksync-era/overnight/index.ts diff --git a/src/factory/providers/zksync-era/overnight/index.ts b/src/factory/providers/zksync-era/overnight/index.ts new file mode 100644 index 00000000..d4623e83 --- /dev/null +++ b/src/factory/providers/zksync-era/overnight/index.ts @@ -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> { + 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 }; diff --git a/src/factory/providers/zksync-era/vesync/index.ts b/src/factory/providers/zksync-era/vesync/index.ts index aee0a863..2185e477 100644 --- a/src/factory/providers/zksync-era/vesync/index.ts +++ b/src/factory/providers/zksync-era/vesync/index.ts @@ -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'; From 0d819ac6e5c7188ca4361b793ff85ba851ca75ff Mon Sep 17 00:00:00 2001 From: Mantas S Date: Wed, 28 Jun 2023 13:00:16 +0300 Subject: [PATCH 2/2] woofy integration --- .../providers/zksync-era/woofi/index.ts | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 src/factory/providers/zksync-era/woofi/index.ts diff --git a/src/factory/providers/zksync-era/woofi/index.ts b/src/factory/providers/zksync-era/woofi/index.ts new file mode 100644 index 00000000..0cc69992 --- /dev/null +++ b/src/factory/providers/zksync-era/woofi/index.ts @@ -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> { + 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 };