From 2f01163d8b45e64840489feac1c22fc84f9dc4c0 Mon Sep 17 00:00:00 2001 From: William Poulin Date: Thu, 28 Sep 2023 16:55:43 -0400 Subject: [PATCH] fix(multicall): Remove unnecessary multicall declarations --- src/app-toolkit/app-toolkit.interface.ts | 2 +- src/app-toolkit/app-toolkit.service.ts | 2 +- .../common/across.staking.contract-position-fetcher.ts | 4 ++-- .../clever.farming.contract-position-fetcher.ts | 4 ++-- .../convex.lp-farm.contract-position-fetcher.ts | 4 ++-- ...mite.contract-position.template.position-fetcher.ts | 3 +-- .../gearbox/ethereum/gearbox.lending.token-fetcher.ts | 7 +++---- .../idle.best-yield.contract-position-fetcher.ts | 4 ++-- .../inverse-firm.loan.contract-position-fetcher.ts | 5 ++--- .../polygon/metavault-trade.mvlp.token-fetcher.ts | 4 ++-- .../mycelium/arbitrum/mycelium.mlp.token-fetcher.ts | 4 ++-- ...keswap.boosted-farm-v2.contract-position-fetcher.ts | 5 +++-- src/apps/phuture/common/phuture.index.token-fetcher.ts | 6 ++++-- ...pika-protocol-v3.vault.contract-position-fetcher.ts | 3 +-- .../pika-protocol.vault.contract-position-fetcher.ts | 3 +-- .../arbitrum/ramses.bribe.contract-position-fetcher.ts | 9 ++++++--- ...erve-protocol.cooldown.contract-position-fetcher.ts | 7 +++++-- .../arbitrum/sentiment.supply.token-fetcher.ts | 4 ++-- .../optimism/velodrome-v2.pool.token-fetcher.ts | 5 +++-- ...vendor-finance.pool-v2.contract-position-fetcher.ts | 2 +- .../template/app-token.template.position-fetcher.ts | 10 ++++++---- ...stom-contract-position.template.position-fetcher.ts | 4 +++- 22 files changed, 55 insertions(+), 46 deletions(-) diff --git a/src/app-toolkit/app-toolkit.interface.ts b/src/app-toolkit/app-toolkit.interface.ts index 55bf1428f..48f0b1c46 100644 --- a/src/app-toolkit/app-toolkit.interface.ts +++ b/src/app-toolkit/app-toolkit.interface.ts @@ -22,7 +22,7 @@ export interface IAppToolkit { getNetworkProvider(network: Network): StaticJsonRpcProvider; - getMulticall(network: Network, batchSize: number): IMulticallWrapper; + getMulticall(network: Network, batchSize?: number): IMulticallWrapper; // Base Tokens diff --git a/src/app-toolkit/app-toolkit.service.ts b/src/app-toolkit/app-toolkit.service.ts index 64473ef0b..7633d7fc0 100644 --- a/src/app-toolkit/app-toolkit.service.ts +++ b/src/app-toolkit/app-toolkit.service.ts @@ -48,7 +48,7 @@ export class AppToolkit implements IAppToolkit { return this.networkProviderService.getProvider(network); } - getMulticall(network: Network, batchSize: number) { + getMulticall(network: Network, batchSize = 250) { return this.multicallService.getMulticall(network, batchSize); } diff --git a/src/apps/across/common/across.staking.contract-position-fetcher.ts b/src/apps/across/common/across.staking.contract-position-fetcher.ts index 4bb25706a..8e042cda0 100644 --- a/src/apps/across/common/across.staking.contract-position-fetcher.ts +++ b/src/apps/across/common/across.staking.contract-position-fetcher.ts @@ -7,6 +7,7 @@ import { MetaType } from '~position/position.interface'; import { isSupplied } from '~position/position.utils'; import { ContractPositionTemplatePositionFetcher } from '~position/template/contract-position.template.position-fetcher'; import { + GetDefinitionsParams, GetDisplayPropsParams, GetTokenBalancesParams, GetTokenDefinitionsParams, @@ -38,8 +39,7 @@ export abstract class AcrossStakingContractPositionFetcher extends ContractPosit return this.contractFactory.acrossStaking({ address, network: this.network }); } - async getDefinitions(): Promise { - const multicall = this.appToolkit.getMulticall(this.network); + async getDefinitions({ multicall }: GetDefinitionsParams): Promise { const appTokens = await this.appToolkit.getAppTokenPositions({ appId: this.appId, network: this.network, diff --git a/src/apps/clever/ethereum/clever.farming.contract-position-fetcher.ts b/src/apps/clever/ethereum/clever.farming.contract-position-fetcher.ts index 06d433fb8..e48c03aa1 100644 --- a/src/apps/clever/ethereum/clever.farming.contract-position-fetcher.ts +++ b/src/apps/clever/ethereum/clever.farming.contract-position-fetcher.ts @@ -7,6 +7,7 @@ import { DefaultDataProps } from '~position/display.interface'; import { MetaType } from '~position/position.interface'; import { ContractPositionTemplatePositionFetcher } from '~position/template/contract-position.template.position-fetcher'; import { + GetDefinitionsParams, GetDisplayPropsParams, GetTokenBalancesParams, GetTokenDefinitionsParams, @@ -40,8 +41,7 @@ export class EthereumCleverFarmingContractPositionFetcher extends ContractPositi return this.contractFactory.cleverGauge({ address, network: this.network }); } - async getDefinitions(): Promise { - const multicall = this.appToolkit.getMulticall(this.network); + async getDefinitions({ multicall }: GetDefinitionsParams): Promise { const gaugeAddresses = [ '0xc5022291ca8281745d173bb855dcd34dda67f2f0', // abcCVX '0x86e917ad6cb44f9e6c8d9fa012acf0d0cfcf114f', // CLEV/ETH diff --git a/src/apps/convex/polygon/convex.lp-farm.contract-position-fetcher.ts b/src/apps/convex/polygon/convex.lp-farm.contract-position-fetcher.ts index a0067b2ee..74ddef9cf 100644 --- a/src/apps/convex/polygon/convex.lp-farm.contract-position-fetcher.ts +++ b/src/apps/convex/polygon/convex.lp-farm.contract-position-fetcher.ts @@ -9,6 +9,7 @@ import { MetaType } from '~position/position.interface'; import { isSupplied } from '~position/position.utils'; import { ContractPositionTemplatePositionFetcher } from '~position/template/contract-position.template.position-fetcher'; import { + GetDefinitionsParams, GetDisplayPropsParams, GetTokenBalancesParams, GetTokenDefinitionsParams, @@ -44,8 +45,7 @@ export class PolygonConvexLpFarmContractPositionFetcher extends ContractPosition return this.contractFactory.convexRewardPool({ address, network: this.network }); } - async getDefinitions(): Promise { - const multicall = this.appToolkit.getMulticall(this.network); + async getDefinitions({ multicall }: GetDefinitionsParams): Promise { const depositContract = this.contractFactory.convexBoosterSidechain({ address: this.boosterContractAddress, network: this.network, diff --git a/src/apps/dolomite/common/dolomite.contract-position.template.position-fetcher.ts b/src/apps/dolomite/common/dolomite.contract-position.template.position-fetcher.ts index c6cd21ffd..3bd35417b 100644 --- a/src/apps/dolomite/common/dolomite.contract-position.template.position-fetcher.ts +++ b/src/apps/dolomite/common/dolomite.contract-position.template.position-fetcher.ts @@ -150,8 +150,7 @@ export abstract class DolomiteContractPositionTemplatePositionFetcher extends Cu async getDataProps( params: GetDataPropsParams, ): Promise { - const multicall = this.appToolkit.getMulticall(this.network); - return mapTokensToDolomiteDataProps(params, this.isFetchingDolomiteBalances(), multicall); + return mapTokensToDolomiteDataProps(params, this.isFetchingDolomiteBalances(), params.multicall); } async getLabel(_params: GetDisplayPropsParams): Promise { diff --git a/src/apps/gearbox/ethereum/gearbox.lending.token-fetcher.ts b/src/apps/gearbox/ethereum/gearbox.lending.token-fetcher.ts index 9ccc40f37..2c85971e2 100644 --- a/src/apps/gearbox/ethereum/gearbox.lending.token-fetcher.ts +++ b/src/apps/gearbox/ethereum/gearbox.lending.token-fetcher.ts @@ -77,11 +77,10 @@ export class EthereumGearboxLendingTokenFetcher extends AppTokenTemplatePosition async getLiquidity( params: GetDataPropsParams, ): Promise { - const multicall = this.appToolkit.getMulticall(network); const poolContract = this._getPoolContract(params.definition); const [liquidity, underlyingToken] = await Promise.all([ - multicall.wrap(poolContract).expectedLiquidity(), - multicall.wrap(poolContract).underlyingToken(), + params.multicall.wrap(poolContract).expectedLiquidity(), + params.multicall.wrap(poolContract).underlyingToken(), ]); const underlyingTokenDecimals = await this.gearboxContractFactory .erc20({ address: underlyingToken, network }) @@ -105,8 +104,8 @@ export class EthereumGearboxLendingTokenFetcher extends AppTokenTemplatePosition async getPricePerShare({ contract: dieselTokenContract, definition, + multicall, }: GetPricePerShareParams) { - const multicall = this.appToolkit.getMulticall(network); const poolContract = this._getPoolContract(definition); const [underlying, underlyingToken, dieselTokenTotalSupply, dieselTokenDecimals] = await Promise.all([ diff --git a/src/apps/idle/ethereum/idle.best-yield.contract-position-fetcher.ts b/src/apps/idle/ethereum/idle.best-yield.contract-position-fetcher.ts index 897bca658..43ca0f589 100644 --- a/src/apps/idle/ethereum/idle.best-yield.contract-position-fetcher.ts +++ b/src/apps/idle/ethereum/idle.best-yield.contract-position-fetcher.ts @@ -8,6 +8,7 @@ import { DefaultDataProps } from '~position/display.interface'; import { MetaType } from '~position/position.interface'; import { ContractPositionTemplatePositionFetcher } from '~position/template/contract-position.template.position-fetcher'; import { + GetDefinitionsParams, GetDisplayPropsParams, GetTokenBalancesParams, GetTokenDefinitionsParams, @@ -39,8 +40,7 @@ export class EthereumIdleBestYieldContractPositionFetcher extends ContractPositi return this.contractFactory.idleToken({ address, network: this.network }); } - async getDefinitions(): Promise { - const multicall = this.appToolkit.getMulticall(this.network); + async getDefinitions({ multicall }: GetDefinitionsParams): Promise { const appTokens = await this.appToolkit.getAppTokenPositions({ appId: this.appId, groupIds: ['vault'], diff --git a/src/apps/inverse-firm/ethereum/inverse-firm.loan.contract-position-fetcher.ts b/src/apps/inverse-firm/ethereum/inverse-firm.loan.contract-position-fetcher.ts index 2b91391c9..241e873f4 100644 --- a/src/apps/inverse-firm/ethereum/inverse-firm.loan.contract-position-fetcher.ts +++ b/src/apps/inverse-firm/ethereum/inverse-firm.loan.contract-position-fetcher.ts @@ -12,6 +12,7 @@ import { isClaimable } from '~position/position.utils'; import { ContractPositionTemplatePositionFetcher } from '~position/template/contract-position.template.position-fetcher'; import { GetDataPropsParams, + GetDefinitionsParams, GetDisplayPropsParams, GetTokenBalancesParams, GetTokenDefinitionsParams, @@ -69,9 +70,7 @@ export class EthereumInverseFirmLoanContractPositionFetcher extends ContractPosi return this.contractFactory.simpleMarket({ network: this.network, address }); } - async getDefinitions(): Promise { - const multicall = this.appToolkit.getMulticall(this.network); - + async getDefinitions({ multicall }: GetDefinitionsParams): Promise { const dolaBorrowRightContract = this.contractFactory.dbr({ address: this.dbrAddress, network: this.network, diff --git a/src/apps/metavault-trade/polygon/metavault-trade.mvlp.token-fetcher.ts b/src/apps/metavault-trade/polygon/metavault-trade.mvlp.token-fetcher.ts index 959dfcef2..01cdb9b8f 100644 --- a/src/apps/metavault-trade/polygon/metavault-trade.mvlp.token-fetcher.ts +++ b/src/apps/metavault-trade/polygon/metavault-trade.mvlp.token-fetcher.ts @@ -9,6 +9,7 @@ import { DefaultAppTokenDataProps, DefaultAppTokenDefinition, GetAddressesParams, + GetDefinitionsParams, GetPricePerShareParams, GetUnderlyingTokensParams, UnderlyingTokenDefinition, @@ -42,8 +43,7 @@ export class PolygonMetavaultTradeMvlpTokenFetcher extends AppTokenTemplatePosit return this.contractFactory.erc20({ network: this.network, address }); } - async getDefinitions(): Promise { - const multicall = this.appToolkit.getMulticall(this.network); + async getDefinitions({ multicall }: GetDefinitionsParams): Promise { const mvlpManagerContract = this.contractFactory.metavaultTradeMvlpManager({ address: this.mvlpManagerAddress, network: this.network, diff --git a/src/apps/mycelium/arbitrum/mycelium.mlp.token-fetcher.ts b/src/apps/mycelium/arbitrum/mycelium.mlp.token-fetcher.ts index d1ea0fa53..a2974d019 100644 --- a/src/apps/mycelium/arbitrum/mycelium.mlp.token-fetcher.ts +++ b/src/apps/mycelium/arbitrum/mycelium.mlp.token-fetcher.ts @@ -9,6 +9,7 @@ import { DefaultAppTokenDataProps, DefaultAppTokenDefinition, GetAddressesParams, + GetDefinitionsParams, GetPricePerShareParams, GetUnderlyingTokensParams, UnderlyingTokenDefinition, @@ -42,8 +43,7 @@ export class ArbitrumMyceliumMlpTokenFetcher extends AppTokenTemplatePositionFet return this.contractFactory.erc20({ network: this.network, address }); } - async getDefinitions(): Promise { - const multicall = this.appToolkit.getMulticall(this.network); + async getDefinitions({ multicall }: GetDefinitionsParams): Promise { const mlpManagerContract = this.contractFactory.myceliumMlpManager({ address: this.mlpManagerAddress, network: this.network, diff --git a/src/apps/pancakeswap/binance-smart-chain/pancakeswap.boosted-farm-v2.contract-position-fetcher.ts b/src/apps/pancakeswap/binance-smart-chain/pancakeswap.boosted-farm-v2.contract-position-fetcher.ts index d696e0523..8e9ec22d6 100644 --- a/src/apps/pancakeswap/binance-smart-chain/pancakeswap.boosted-farm-v2.contract-position-fetcher.ts +++ b/src/apps/pancakeswap/binance-smart-chain/pancakeswap.boosted-farm-v2.contract-position-fetcher.ts @@ -4,9 +4,11 @@ import { compact, range } from 'lodash'; import { APP_TOOLKIT, IAppToolkit } from '~app-toolkit/app-toolkit.interface'; import { ZERO_ADDRESS } from '~app-toolkit/constants/address'; import { PositionTemplate } from '~app-toolkit/decorators/position-template.decorator'; +import { GetDefinitionsParams } from '~position/template/app-token.template.types'; import { GetMasterChefDataPropsParams, GetMasterChefTokenBalancesParams, + MasterChefContractPositionDefinition, MasterChefTemplateContractPositionFetcher, } from '~position/template/master-chef.template.contract-position-fetcher'; @@ -31,8 +33,7 @@ export class BinanceSmartChainPancakeSwapBoostedFarmV2ContractPositionFetcher ex return this.contractFactory.pancakeswapChefV2({ address, network: this.network }); } - async getDefinitions() { - const multicall = this.appToolkit.getMulticall(this.network); + async getDefinitions({ multicall }: GetDefinitionsParams): Promise { const chefV2 = this.contractFactory.pancakeswapChefV2({ address: this.chefAddress, network: this.network }); const poolLength = await chefV2.poolLength(); diff --git a/src/apps/phuture/common/phuture.index.token-fetcher.ts b/src/apps/phuture/common/phuture.index.token-fetcher.ts index 444f01491..70d7d80c2 100644 --- a/src/apps/phuture/common/phuture.index.token-fetcher.ts +++ b/src/apps/phuture/common/phuture.index.token-fetcher.ts @@ -6,6 +6,7 @@ import { DefaultAppTokenDataProps, GetDataPropsParams, GetDisplayPropsParams, + GetUnderlyingTokensParams, } from '~position/template/app-token.template.types'; import { PhutureContractFactory, PhutureManagedIndex } from '../contracts'; @@ -38,8 +39,9 @@ export abstract class PhutureIndexTokenFetcher extends AppTokenTemplatePositionF return [this.managerAddress]; } - async getUnderlyingTokenDefinitions() { - const multicall = this.appToolkit.getMulticall(this.network); + async getUnderlyingTokenDefinitions({ + multicall, + }: GetUnderlyingTokensParams) { const managerContract = this.contractFactory.phutureManagedIndex({ address: this.managerAddress, network: this.network, diff --git a/src/apps/pika-protocol-v3/optimism/pika-protocol-v3.vault.contract-position-fetcher.ts b/src/apps/pika-protocol-v3/optimism/pika-protocol-v3.vault.contract-position-fetcher.ts index e54a0bd5b..7ba807bbf 100644 --- a/src/apps/pika-protocol-v3/optimism/pika-protocol-v3.vault.contract-position-fetcher.ts +++ b/src/apps/pika-protocol-v3/optimism/pika-protocol-v3.vault.contract-position-fetcher.ts @@ -52,8 +52,7 @@ export class OptimismPikaProtocolV3VaultContractPositionFetcher extends Contract return `Staked ${getLabelFromToken(contractPosition.tokens[0])}`; } - async getTokenBalancesPerPosition({ address, contract }: GetTokenBalancesParams) { - const multicall = this.appToolkit.getMulticall(this.network); + async getTokenBalancesPerPosition({ address, contract, multicall }: GetTokenBalancesParams) { const rewardContract = this.contractFactory.pikaProtocolV3Rewards({ address: '0x939c11c596b851447e5220584d37f12854ba02ae', network: this.network, diff --git a/src/apps/pika-protocol/optimism/pika-protocol.vault.contract-position-fetcher.ts b/src/apps/pika-protocol/optimism/pika-protocol.vault.contract-position-fetcher.ts index 7c5d5c379..5fa88bde2 100644 --- a/src/apps/pika-protocol/optimism/pika-protocol.vault.contract-position-fetcher.ts +++ b/src/apps/pika-protocol/optimism/pika-protocol.vault.contract-position-fetcher.ts @@ -52,8 +52,7 @@ export class OptimismPikaProtocolVaultContractPositionFetcher extends ContractPo return `Staked ${getLabelFromToken(contractPosition.tokens[0])}`; } - async getTokenBalancesPerPosition({ address, contract }: GetTokenBalancesParams) { - const multicall = this.appToolkit.getMulticall(this.network); + async getTokenBalancesPerPosition({ address, contract, multicall }: GetTokenBalancesParams) { const rewardContract = this.contractFactory.pikaProtocolVaultReward({ address: '0x58488bb666d2da33f8e8938dbdd582d2481d4183', network: this.network, diff --git a/src/apps/ramses/arbitrum/ramses.bribe.contract-position-fetcher.ts b/src/apps/ramses/arbitrum/ramses.bribe.contract-position-fetcher.ts index 7ebde9ad7..9db4091a5 100644 --- a/src/apps/ramses/arbitrum/ramses.bribe.contract-position-fetcher.ts +++ b/src/apps/ramses/arbitrum/ramses.bribe.contract-position-fetcher.ts @@ -4,7 +4,11 @@ import { ZERO_ADDRESS } from '~app-toolkit/constants/address'; import { PositionTemplate } from '~app-toolkit/decorators/position-template.decorator'; import { DefaultDataProps } from '~position/display.interface'; import { MetaType } from '~position/position.interface'; -import { GetDisplayPropsParams, GetTokenDefinitionsParams } from '~position/template/contract-position.template.types'; +import { + GetDefinitionsParams, + GetDisplayPropsParams, + GetTokenDefinitionsParams, +} from '~position/template/contract-position.template.types'; import { VotingRewardsContractPositionFetcher } from '../common/ramses.voting-rewards.contract-position-fetcher'; import { RamsesBribe } from '../contracts'; @@ -23,14 +27,13 @@ export class ArbitrumRamsesBribeContractPositionFetcher extends VotingRewardsCon return this.contractFactory.ramsesBribe({ address, network: this.network }); } - async getDefinitions(): Promise { + async getDefinitions({ multicall }: GetDefinitionsParams): Promise { const pools = await this.appToolkit.getAppTokenPositions({ appId: this.appId, network: this.network, groupIds: ['pool'], }); - const multicall = this.appToolkit.getMulticall(this.network); const ramsesVoter = this.contractFactory.ramsesVoter({ network: this.network, address: this.voterAddress }); const gauges = await Promise.all(pools.map(p => multicall.wrap(ramsesVoter).gauges(p.address))); diff --git a/src/apps/reserve-protocol/ethereum/reserve-protocol.cooldown.contract-position-fetcher.ts b/src/apps/reserve-protocol/ethereum/reserve-protocol.cooldown.contract-position-fetcher.ts index bebe7d4e3..55e66db8a 100644 --- a/src/apps/reserve-protocol/ethereum/reserve-protocol.cooldown.contract-position-fetcher.ts +++ b/src/apps/reserve-protocol/ethereum/reserve-protocol.cooldown.contract-position-fetcher.ts @@ -92,9 +92,12 @@ export class EthereumReserveProtocolCooldownContractPositionFetcher extends Cont return getLabelFromToken(contractPosition.tokens[0]); } - async getTokenBalancesPerPosition({ address, contract }: GetTokenBalancesParams): Promise { + async getTokenBalancesPerPosition({ + address, + contract, + multicall, + }: GetTokenBalancesParams): Promise { // Get FacadeRead - const multicall = this.appToolkit.getMulticall(this.network); const facadeRead = multicall.wrap( this.contractFactory.facadeRead({ network: this.network, diff --git a/src/apps/sentiment/arbitrum/sentiment.supply.token-fetcher.ts b/src/apps/sentiment/arbitrum/sentiment.supply.token-fetcher.ts index 76b4af2dd..1aa983cf1 100644 --- a/src/apps/sentiment/arbitrum/sentiment.supply.token-fetcher.ts +++ b/src/apps/sentiment/arbitrum/sentiment.supply.token-fetcher.ts @@ -8,6 +8,7 @@ import { AppTokenTemplatePositionFetcher } from '~position/template/app-token.te import { DefaultAppTokenDataProps, GetAddressesParams, + GetDefinitionsParams, GetDisplayPropsParams, GetPricePerShareParams, GetUnderlyingTokensParams, @@ -39,8 +40,7 @@ export class ArbitrumSentimentSupplyTokenFetcher extends AppTokenTemplatePositio return this.contractFactory.sentimentLToken({ network: this.network, address }); } - async getDefinitions(): Promise { - const multicall = this.appToolkit.getMulticall(this.network); + async getDefinitions({ multicall }: GetDefinitionsParams): Promise { const registryContract = this.contractFactory.sentimentRegistry({ address: '0x17b07cfbab33c0024040e7c299f8048f4a49679b', network: this.network, diff --git a/src/apps/velodrome-v2/optimism/velodrome-v2.pool.token-fetcher.ts b/src/apps/velodrome-v2/optimism/velodrome-v2.pool.token-fetcher.ts index 1462b8351..40cc1b760 100644 --- a/src/apps/velodrome-v2/optimism/velodrome-v2.pool.token-fetcher.ts +++ b/src/apps/velodrome-v2/optimism/velodrome-v2.pool.token-fetcher.ts @@ -6,7 +6,9 @@ import { PositionTemplate } from '~app-toolkit/decorators/position-template.deco import { getLabelFromToken } from '~app-toolkit/helpers/presentation/image.present'; import { AppTokenTemplatePositionFetcher } from '~position/template/app-token.template.position-fetcher'; import { + DefaultAppTokenDefinition, GetAddressesParams, + GetDefinitionsParams, GetDisplayPropsParams, GetPricePerShareParams, GetUnderlyingTokensParams, @@ -30,8 +32,7 @@ export class OptimismVelodromeV2PoolTokenFetcher extends AppTokenTemplatePositio return this.contractFactory.velodromeV2Pool({ address, network: this.network }); } - async getDefinitions() { - const multicall = this.appToolkit.getMulticall(this.network); + async getDefinitions({ multicall }: GetDefinitionsParams): Promise { const factoryContract = this.contractFactory.velodromeV2PoolFactory({ address: '0xf1046053aa5682b4f9a81b5481394da16be5ff5a', network: this.network, diff --git a/src/apps/vendor-finance/common/vendor-finance.pool-v2.contract-position-fetcher.ts b/src/apps/vendor-finance/common/vendor-finance.pool-v2.contract-position-fetcher.ts index 3a6ac7818..54b3afca5 100644 --- a/src/apps/vendor-finance/common/vendor-finance.pool-v2.contract-position-fetcher.ts +++ b/src/apps/vendor-finance/common/vendor-finance.pool-v2.contract-position-fetcher.ts @@ -136,6 +136,7 @@ export abstract class VendorFinancePoolV2ContractPositionFetcher extends Contrac async getTokenBalancesPerPosition({ address, contractPosition, + multicall, }: GetTokenBalancesParams) { const collateralToken = contractPosition.tokens[0]!; const lentToken = contractPosition.tokens[1]!; @@ -148,7 +149,6 @@ export abstract class VendorFinancePoolV2ContractPositionFetcher extends Contrac // --- Borrower logic ---- const startKey = '0x'.padEnd(66, '0'); - const multicall = this.appToolkit.getMulticall(this.network); const positionTracker = multicall.wrap( this.contractFactory.vendorFinancePositionTracker({ address: this.positionTrackerAddr, diff --git a/src/position/template/app-token.template.position-fetcher.ts b/src/position/template/app-token.template.position-fetcher.ts index 3868b3042..fcd4a6189 100644 --- a/src/position/template/app-token.template.position-fetcher.ts +++ b/src/position/template/app-token.template.position-fetcher.ts @@ -53,6 +53,8 @@ export abstract class AppTokenTemplatePositionFetcher< minLiquidity = 1000; + batchSize = 250; + constructor(@Inject(APP_TOOLKIT) protected readonly appToolkit: IAppToolkit) {} // 1. Get token contract instance @@ -160,7 +162,7 @@ export abstract class AppTokenTemplatePositionFetcher< } async getPositionsForBatch(definitions: R[]) { - const multicall = this.appToolkit.getMulticall(this.network); + const multicall = this.appToolkit.getMulticall(this.network, this.batchSize); const tokenLoader = this.appToolkit.getTokenDependencySelector({ tags: { network: this.network, context: `${this.appId}__template` }, }); @@ -312,7 +314,7 @@ export abstract class AppTokenTemplatePositionFetcher< // Default (adapted) Template Runner // Note: This will be removed in favour of an orchestrator at a higher level once all groups are migrated async getPositions(): Promise[]> { - const multicall = this.appToolkit.getMulticall(this.network); + const multicall = this.appToolkit.getMulticall(this.network, this.batchSize); const tokenLoader = this.appToolkit.getTokenDependencySelector({ tags: { network: this.network, context: `${this.appId}__template` }, }); @@ -346,7 +348,7 @@ export abstract class AppTokenTemplatePositionFetcher< } async getBalances(_address: string): Promise[]> { - const multicall = this.appToolkit.getMulticall(this.network); + const multicall = this.appToolkit.getMulticall(this.network, this.batchSize); const address = await this.getAccountAddress(_address); const appTokens = await this.getPositionsForBalances(); if (address === ZERO_ADDRESS) return []; @@ -363,7 +365,7 @@ export abstract class AppTokenTemplatePositionFetcher< } async getRawBalances(_address: string): Promise { - const multicall = this.appToolkit.getMulticall(this.network); + const multicall = this.appToolkit.getMulticall(this.network, this.batchSize); const address = await this.getAccountAddress(_address); if (address === ZERO_ADDRESS) return []; diff --git a/src/position/template/custom-contract-position.template.position-fetcher.ts b/src/position/template/custom-contract-position.template.position-fetcher.ts index 17b98e782..1b3d7091d 100644 --- a/src/position/template/custom-contract-position.template.position-fetcher.ts +++ b/src/position/template/custom-contract-position.template.position-fetcher.ts @@ -42,6 +42,8 @@ export abstract class CustomContractPositionTemplatePositionFetcher< isExcludedFromExplore = false; isExcludedFromTvl = false; + batchSize = 250; + constructor(@Inject(APP_TOOLKIT) protected readonly appToolkit: IAppToolkit) {} // 1. Get contract position definitions (i.e.: contract addresses and additional context) @@ -93,7 +95,7 @@ export abstract class CustomContractPositionTemplatePositionFetcher< // Default (adapted) Template Runner // Note: This will be removed in favour of an orchestrator at a higher level once all groups are migrated async getPositions() { - const multicall = this.appToolkit.getMulticall(this.network); + const multicall = this.appToolkit.getMulticall(this.network, this.batchSize); const tokenLoader = this.appToolkit.getTokenDependencySelector({ tags: { network: this.network, context: `${this.appId}__template` }, });