From ee22c7b65102f1d1c013acf47079741d6972b8f6 Mon Sep 17 00:00:00 2001 From: immasandwich Date: Fri, 16 Dec 2022 15:46:45 -0500 Subject: [PATCH] feat(app-tokens): Support definitions as underlying tokens (#1935) --- ...aave-amm.lending.template.token-fetcher.ts | 4 +-- .../aave-safety-module.abpt.token-fetcher.ts | 7 ++-- ...ve-safety-module.stk-aave.token-fetcher.ts | 4 +-- ...ve-safety-module.stk-abpt.token-fetcher.ts | 4 +-- .../aave-v2.lending.template.token-fetcher.ts | 4 +-- .../common/across.v1-pool.token-fetcher.ts | 4 +-- .../common/across.v2-pool.token-fetcher.ts | 4 +-- .../aelin/common/aelin.pool.token-fetcher.ts | 4 +-- .../airswap.s-ast-v2.token-fetcher.ts | 4 +-- .../airswap.s-ast-v3.token-fetcher.ts | 4 +-- .../alpha-v1.lending.token-fetcher.ts | 5 +-- .../common/arrakis.pool.token-fetcher.ts | 7 ++-- .../ethereum/aura.aura-bal.token-fetcher.ts | 4 +-- .../ethereum/aura.deposit.token-fetcher.ts | 4 +-- .../common/badger.vault.token-fetcher.ts | 6 ++-- .../balancer-v1.pool.token-fetcher.ts | 5 +-- .../common/balancer-v2.pool.token-fetcher.ts | 4 +-- .../balancer-v2.wrapped-aave.token-fetcher.ts | 4 +-- .../bancor-v3.bnt-pool.token-fetcher.ts | 7 ++-- .../ethereum/bancor-v3.pool.token-fetcher.ts | 7 ++-- ...e-smart-alpha.junior-pool.token-fetcher.ts | 4 +-- ...e-smart-alpha.senior-pool.token-fetcher.ts | 4 +-- .../bastion-protocol.pool.token-fetcher.ts | 9 +++-- .../beefy/common/beefy.vault.token-fetcher.ts | 4 +-- .../ethereum/bend-dao.supply.token-fetcher.ts | 4 +-- .../bend-dao.variable-debt.token-fetcher.ts | 4 +-- .../cask-protocol.wallet.token-fetcher.ts | 4 +-- .../chicken-bond.blusd.token-fetcher.ts | 4 +-- .../common/clearpool.pool.token-fetcher.ts | 4 +-- .../ethereum/clever.lever.token-fetcher.ts | 4 +-- .../common/compound.supply.token-fetcher.ts | 5 +-- .../concentrator.acrv.token-fetcher.ts | 4 +-- .../concentrator.afxs.token-fetcher.ts | 4 +-- .../convex.deposit-sidechain.token-fetcher.ts | 4 +-- .../common/convex.deposit.token-fetcher.ts | 4 +-- .../curve.pool-dynamic.token-fetcher.ts | 9 +++-- .../common/curve.pool-static.token-fetcher.ts | 9 +++-- .../common/dhedge-v2.pool.token-fetcher.ts | 4 +-- .../polygon/dystopia.pool.token-fetcher.ts | 7 ++-- .../ease/common/ease.rca.token-fetcher.ts | 6 ++-- .../enzyme-finance.vault.token-fetcher.ts | 4 +-- .../common/euler.d-token.token-fetcher.ts | 4 +-- .../common/euler.e-token.token-fetcher.ts | 4 +-- .../common/euler.p-token.token-fetcher.ts | 4 +-- .../polygon/furucombo.fund.token-fetcher.ts | 4 +-- .../ethereum/gearbox.lending.token-fetcher.ts | 7 ++-- .../gmx/common/gmx.es-gmx.token-fetcher.ts | 4 +-- src/apps/gmx/common/gmx.glp.token-fetcher.ts | 5 +-- .../gro/avalanche/gro.labs.token-fetcher.ts | 4 +-- .../hedgefarm.alpha-one.token-fetcher.ts | 4 +-- .../idle/ethereum/idle.vault.token-fetcher.ts | 4 +-- .../impermax.collateral.token-fetcher.ts | 4 +-- .../common/impermax.lend.token-fetcher.ts | 4 +-- .../impermax.collateral.token-fetcher.ts | 4 +-- .../helpers/impermax.lend.token-fetcher.ts | 4 +-- .../index-coop.index.token-fetcher.ts | 6 ++-- .../common/insurace.mining.token-fetcher.ts | 4 +-- .../polygon/klima.s-klima.token-fetcher.ts | 4 +-- .../polygon/klima.ws-klima.token-fetcher.ts | 4 +-- .../llama-airforce.vault.token-fetcher.ts | 7 ++-- .../lyra-avalon.pool.token-fetcher.ts | 4 +-- .../lyra-avalon.stk-lyra.token-fetcher.ts | 4 +-- .../ethereum/maple.pool.token-fetcher.ts | 4 +-- .../polygon/meshswap.supply.token-fetcher.ts | 4 +-- .../ethereum/mstable.imusd.token-fetcher.ts | 4 +-- .../mstable.meta-vault.token-fetcher.ts | 4 +-- .../polygon/mstable.imusd.token-fetcher.ts | 4 +-- .../ethereum/olympus.g-ohm.token-fetcher.ts | 4 +-- .../olympus.s-ohm-v1.token-fetcher.ts | 4 +-- .../ethereum/olympus.s-ohm.token-fetcher.ts | 4 +-- .../olympus.ws-ohm-v1.token-fetcher.ts | 4 +-- .../ooki/arbitrum/ooki.lend.token-fetcher.ts | 4 +-- .../ooki.lend.token-fetcher.ts | 4 +-- .../ooki/ethereum/ooki.lend.token-fetcher.ts | 4 +-- .../ooki/optimism/ooki.lend.token-fetcher.ts | 4 +-- .../ooki/polygon/ooki.lend.token-fetcher.ts | 4 +-- .../common/openleverage.pool.token-fetcher.ts | 4 +-- .../origin-dollar.veogv.token-fetcher.ts | 4 +-- .../origin-dollar.wousd.token-fetcher.ts | 4 +-- .../p-stake.stake.token-fetcher.ts | 4 +-- .../ethereum/pendle-v2.pool.token-fetcher.ts | 19 ++++++++--- ...pendle-v2.principal-token.token-fetcher.ts | 5 +++ ....standardized-yield-token.token-fetcher.ts | 4 +++ .../pendle-v2.yield-token.token-fetcher.ts | 4 +++ .../pendle.ownership.token-fetcher.ts | 4 +-- .../ethereum/pendle.yield.token-fetcher.ts | 4 +-- .../common/pickle.jar-univ3.token-fetcher.ts | 15 ++++----- .../pickle/common/pickle.jar.token-fetcher.ts | 7 ++-- .../ethereum/pie-dao.e-dough.token-fetcher.ts | 4 +-- .../platypus-finance.pool.token-fetcher.ts | 4 +-- .../arbitrum/plutus.plv-glp.token-fetcher.ts | 4 +-- .../pods-yield.strategy.token-fetcher.ts | 4 +-- ...ether-v3.community-ticket.token-fetcher.ts | 17 +++++----- .../pool-together-v3.pod.token-fetcher.ts | 7 ++-- ...ol-together-v3.prize-pool.token-fetcher.ts | 6 ++-- .../pool-together-v4.ticket.token-fetcher.ts | 6 ++-- .../polygon/qi-dao.yield.token-fetcher.ts | 4 +-- .../common/rari-fuse.supply.token-fetcher.ts | 4 +-- .../rari/ethereum/rari.fund.token-fetcher.ts | 6 ++-- .../common/reaper.vault.token-fetcher.ts | 4 +-- .../common/robo-vault.vault.token-fetcher.ts | 4 +-- .../rook/common/rook.pool.token-fetcher.ts | 7 ++-- .../common/rubicon.bath.token-fetcher.ts | 4 +-- .../ethereum/sideshift.svxai.token-fetcher.ts | 4 +-- .../stake-dao.locker.token-fetcher.ts | 4 +-- .../common/stargate.eth.token-fetcher.ts | 4 +-- .../common/stargate.pool.token-fetcher.ts | 4 +-- .../stargate.auction-locked.token-fetcher.ts | 4 +-- .../polygon/superfluid.vault.token-fetcher.ts | 4 +-- .../sushiswap-kashi.lending.token-fetcher.ts | 7 ++-- .../common/synthetix.snx.token-fetcher.ts | 2 +- .../common/synthetix.synth.token-fetcher.ts | 2 +- .../fantom/tarot.supply.token-fetcher.ts | 4 +-- .../tarot/fantom/tarot.vault.token-fetcher.ts | 4 +-- .../tempus/common/tempus.amm.token-fetcher.ts | 8 +++-- .../common/tempus.pool.token-fetcher.ts | 4 +-- .../common/tenderize.swap.token-fetcher.ts | 9 +++-- .../common/tenderize.tender.token-fetcher.ts | 6 ++-- .../ethereum/tokemak.reactor.token-fetcher.ts | 4 +-- .../umami-finance.compound.token-fetcher.ts | 4 +-- ...mi-finance.marinate-umami.token-fetcher.ts | 4 +-- .../common/unagii.vault-token-fetcher.ts | 6 ++-- .../common/unipilot.vault.token-fetcher.ts | 9 +++-- ...v2.pool.on-chain.template.token-fetcher.ts | 7 ++-- .../vaporwave-finance.vault.token-fetcher.ts | 4 +-- .../optimism/velodrome.pool.token-fetcher.ts | 7 ++-- .../wombat-exchange.pool.token-fetcher.ts | 4 +-- .../yearn/common/yearn.vault.token-fetcher.ts | 5 ++- .../ethereum/yearn.y-crv.token-fetcher.ts | 4 +-- .../ethereum/yearn.yield.token-fetcher.ts | 4 +-- .../yield-protocol.lend.token-fetcher.ts | 4 +-- .../yield-protocol.pool.token-fetcher.ts | 4 +-- .../yield-yak.vault.token-fetcher.ts | 4 +-- .../app-token.template.position-fetcher.ts | 33 +++++++++---------- .../template/app-token.template.types.ts | 7 ++++ .../template/vault.template.token-fetcher.ts | 4 +-- .../wrapper.template.token-fetcher.ts | 6 ++-- 137 files changed, 394 insertions(+), 313 deletions(-) diff --git a/src/apps/aave-amm/helpers/aave-amm.lending.template.token-fetcher.ts b/src/apps/aave-amm/helpers/aave-amm.lending.template.token-fetcher.ts index 188621560..c467c37ef 100644 --- a/src/apps/aave-amm/helpers/aave-amm.lending.template.token-fetcher.ts +++ b/src/apps/aave-amm/helpers/aave-amm.lending.template.token-fetcher.ts @@ -60,8 +60,8 @@ export abstract class AaveAmmLendingTemplateTokenFetcher extends AppTokenTemplat ); } - async getUnderlyingTokenAddresses({ contract }: GetUnderlyingTokensParams) { - return contract.UNDERLYING_ASSET_ADDRESS(); + async getUnderlyingTokenDefinitions({ contract }: GetUnderlyingTokensParams) { + return [{ address: await contract.UNDERLYING_ASSET_ADDRESS(), network: this.network }]; } async getReserveConfigDataProps({ diff --git a/src/apps/aave-safety-module/ethereum/aave-safety-module.abpt.token-fetcher.ts b/src/apps/aave-safety-module/ethereum/aave-safety-module.abpt.token-fetcher.ts index b4814ebda..a3184719d 100644 --- a/src/apps/aave-safety-module/ethereum/aave-safety-module.abpt.token-fetcher.ts +++ b/src/apps/aave-safety-module/ethereum/aave-safety-module.abpt.token-fetcher.ts @@ -46,8 +46,11 @@ export class EthereumAaveSafetyModuleAbptTokenFetcher extends AppTokenTemplatePo return ['0x41a08648c3766f9f9d85598ff102a08f4ef84f84']; } - async getUnderlyingTokenAddresses(_params: GetUnderlyingTokensParams): Promise { - return [this.aaveAddress, this.wethAddress]; + async getUnderlyingTokenDefinitions(_params: GetUnderlyingTokensParams) { + return [ + { address: this.aaveAddress, network: this.network }, + { address: this.wethAddress, network: this.network }, + ]; } async getPricePerShare({ diff --git a/src/apps/aave-safety-module/ethereum/aave-safety-module.stk-aave.token-fetcher.ts b/src/apps/aave-safety-module/ethereum/aave-safety-module.stk-aave.token-fetcher.ts index 3a873eeda..afbb8ddb6 100644 --- a/src/apps/aave-safety-module/ethereum/aave-safety-module.stk-aave.token-fetcher.ts +++ b/src/apps/aave-safety-module/ethereum/aave-safety-module.stk-aave.token-fetcher.ts @@ -29,8 +29,8 @@ export class EthereumAaveSafetyModuleStkAaveTokenFetcher extends AppTokenTemplat return ['0x4da27a545c0c5b758a6ba100e3a049001de870f5']; } - async getUnderlyingTokenAddresses(_params: GetUnderlyingTokensParams) { - return ['0x7fc66500c84a76ad7e9c93437bfc5ac33e2ddae9']; + async getUnderlyingTokenDefinitions(_params: GetUnderlyingTokensParams) { + return [{ address: '0x7fc66500c84a76ad7e9c93437bfc5ac33e2ddae9', network: this.network }]; } async getLiquidity({ appToken }: GetDataPropsParams) { diff --git a/src/apps/aave-safety-module/ethereum/aave-safety-module.stk-abpt.token-fetcher.ts b/src/apps/aave-safety-module/ethereum/aave-safety-module.stk-abpt.token-fetcher.ts index 285f3b947..3700b92a6 100644 --- a/src/apps/aave-safety-module/ethereum/aave-safety-module.stk-abpt.token-fetcher.ts +++ b/src/apps/aave-safety-module/ethereum/aave-safety-module.stk-abpt.token-fetcher.ts @@ -29,8 +29,8 @@ export class EthereumAaveSafetyModuleStkAbptTokenFetcher extends AppTokenTemplat return ['0xa1116930326d21fb917d5a27f1e9943a9595fb47']; } - async getUnderlyingTokenAddresses() { - return ['0x41a08648c3766f9f9d85598ff102a08f4ef84f84']; + async getUnderlyingTokenDefinitions() { + return [{ address: '0x41a08648c3766f9f9d85598ff102a08f4ef84f84', network: this.network }]; } async getLiquidity({ appToken }: GetDataPropsParams) { diff --git a/src/apps/aave-v2/helpers/aave-v2.lending.template.token-fetcher.ts b/src/apps/aave-v2/helpers/aave-v2.lending.template.token-fetcher.ts index 9353d47fa..4bf06f2d7 100644 --- a/src/apps/aave-v2/helpers/aave-v2.lending.template.token-fetcher.ts +++ b/src/apps/aave-v2/helpers/aave-v2.lending.template.token-fetcher.ts @@ -84,8 +84,8 @@ export abstract class AaveV2LendingTemplateTokenFetcher extends AppTokenTemplate ); } - async getUnderlyingTokenAddresses({ contract }: GetUnderlyingTokensParams) { - return contract.UNDERLYING_ASSET_ADDRESS(); + async getUnderlyingTokenDefinitions({ contract }: GetUnderlyingTokensParams) { + return [{ address: await contract.UNDERLYING_ASSET_ADDRESS(), network: this.network }]; } async getReserveConfigDataProps({ diff --git a/src/apps/across/common/across.v1-pool.token-fetcher.ts b/src/apps/across/common/across.v1-pool.token-fetcher.ts index 7ebd7c4ee..363ac1c59 100644 --- a/src/apps/across/common/across.v1-pool.token-fetcher.ts +++ b/src/apps/across/common/across.v1-pool.token-fetcher.ts @@ -29,8 +29,8 @@ export abstract class AcrossV1PoolTokenFetcher extends AppTokenTemplatePositionF return this.poolAddresses; } - async getUnderlyingTokenAddresses({ contract }: GetUnderlyingTokensParams) { - return contract.l1Token(); + async getUnderlyingTokenDefinitions({ contract }: GetUnderlyingTokensParams) { + return [{ address: await contract.l1Token(), network: this.network }]; } async getPricePerShare({ contract, appToken, multicall }: GetPricePerShareParams) { diff --git a/src/apps/across/common/across.v2-pool.token-fetcher.ts b/src/apps/across/common/across.v2-pool.token-fetcher.ts index c6b448d0c..dc580e904 100644 --- a/src/apps/across/common/across.v2-pool.token-fetcher.ts +++ b/src/apps/across/common/across.v2-pool.token-fetcher.ts @@ -58,10 +58,10 @@ export abstract class AcrossV2PoolTokenFetcher extends AppTokenTemplatePositionF return definitions.map(v => v.address); } - async getUnderlyingTokenAddresses({ + async getUnderlyingTokenDefinitions({ definition, }: GetUnderlyingTokensParams) { - return [definition.underlyingTokenAddress]; + return [{ address: definition.underlyingTokenAddress, network: this.network }]; } async getPricePerShare({ appToken, multicall }: GetPricePerShareParams) { diff --git a/src/apps/aelin/common/aelin.pool.token-fetcher.ts b/src/apps/aelin/common/aelin.pool.token-fetcher.ts index 014d84a46..7cead3c56 100644 --- a/src/apps/aelin/common/aelin.pool.token-fetcher.ts +++ b/src/apps/aelin/common/aelin.pool.token-fetcher.ts @@ -49,8 +49,8 @@ export abstract class AelinPoolTokenFetcher extends AppTokenTemplatePositionFetc return data.poolCreateds.map(v => v.id); } - getUnderlyingTokenAddresses({ contract }: GetUnderlyingTokensParams) { - return contract.purchaseToken(); + async getUnderlyingTokenDefinitions({ contract }: GetUnderlyingTokensParams) { + return [{ address: await contract.purchaseToken(), network: this.network }]; } async getLiquidity({ appToken }: GetDataPropsParams) { diff --git a/src/apps/airswap/ethereum/airswap.s-ast-v2.token-fetcher.ts b/src/apps/airswap/ethereum/airswap.s-ast-v2.token-fetcher.ts index 65c2d0c3a..c4311e4c7 100644 --- a/src/apps/airswap/ethereum/airswap.s-ast-v2.token-fetcher.ts +++ b/src/apps/airswap/ethereum/airswap.s-ast-v2.token-fetcher.ts @@ -26,8 +26,8 @@ export class EthereumAirswapSAstV2TokenFetcher extends AppTokenTemplatePositionF return ['0x579120871266ccd8de6c85ef59e2ff6743e7cd15']; } - async getUnderlyingTokenAddresses({ contract }: GetUnderlyingTokensParams) { - return contract.token(); + async getUnderlyingTokenDefinitions({ contract }: GetUnderlyingTokensParams) { + return [{ address: await contract.token(), network: this.network }]; } async getLabel(): Promise { diff --git a/src/apps/airswap/ethereum/airswap.s-ast-v3.token-fetcher.ts b/src/apps/airswap/ethereum/airswap.s-ast-v3.token-fetcher.ts index bb00e9b4e..4c665dfa6 100644 --- a/src/apps/airswap/ethereum/airswap.s-ast-v3.token-fetcher.ts +++ b/src/apps/airswap/ethereum/airswap.s-ast-v3.token-fetcher.ts @@ -26,8 +26,8 @@ export class EthereumAirswapSAstV3TokenFetcher extends AppTokenTemplatePositionF return ['0x6d88b09805b90dad911e5c5a512eedd984d6860b']; } - async getUnderlyingTokenAddresses({ contract }: GetUnderlyingTokensParams) { - return contract.token(); + async getUnderlyingTokenDefinitions({ contract }: GetUnderlyingTokensParams) { + return [{ address: await contract.token(), network: this.network }]; } async getLabel(): Promise { diff --git a/src/apps/alpha-v1/ethereum/alpha-v1.lending.token-fetcher.ts b/src/apps/alpha-v1/ethereum/alpha-v1.lending.token-fetcher.ts index cd8c82c00..0d90bdd55 100644 --- a/src/apps/alpha-v1/ethereum/alpha-v1.lending.token-fetcher.ts +++ b/src/apps/alpha-v1/ethereum/alpha-v1.lending.token-fetcher.ts @@ -2,6 +2,7 @@ import { Inject } from '@nestjs/common'; import BigNumber from 'bignumber.js'; 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 { AppTokenTemplatePositionFetcher } from '~position/template/app-token.template.position-fetcher'; import { @@ -33,8 +34,8 @@ export class EthereumAlphaV1LendingTokenFetcher extends AppTokenTemplatePosition return ['0x67b66c99d3eb37fa76aa3ed1ff33e8e39f0b9c7a']; } - async getUnderlyingTokenAddresses() { - return ['0x0000000000000000000000000000000000000000']; + async getUnderlyingTokenDefinitions() { + return [{ address: ZERO_ADDRESS, network: this.network }]; } async getPrice({ diff --git a/src/apps/arrakis/common/arrakis.pool.token-fetcher.ts b/src/apps/arrakis/common/arrakis.pool.token-fetcher.ts index 3a70c8ff7..4ad78e5d8 100644 --- a/src/apps/arrakis/common/arrakis.pool.token-fetcher.ts +++ b/src/apps/arrakis/common/arrakis.pool.token-fetcher.ts @@ -58,10 +58,13 @@ export abstract class ArrakisPoolTokenFetcher extends AppTokenTemplatePositionFe return definitions.map(v => v.address); } - async getUnderlyingTokenAddresses({ + async getUnderlyingTokenDefinitions({ definition, }: GetUnderlyingTokensParams) { - return [definition.underlyingTokenAddress0, definition.underlyingTokenAddress1]; + return [ + { address: definition.underlyingTokenAddress0, network: this.network }, + { address: definition.underlyingTokenAddress1, network: this.network }, + ]; } async getPricePerShare({ diff --git a/src/apps/aura/ethereum/aura.aura-bal.token-fetcher.ts b/src/apps/aura/ethereum/aura.aura-bal.token-fetcher.ts index 07161735c..b54a09bc2 100644 --- a/src/apps/aura/ethereum/aura.aura-bal.token-fetcher.ts +++ b/src/apps/aura/ethereum/aura.aura-bal.token-fetcher.ts @@ -42,8 +42,8 @@ export class EthereumAuraAuraBalTokenFetcher extends AppTokenTemplatePositionFet return [this.AURA_BAL_ADDRESS]; } - async getUnderlyingTokenAddresses() { - return [this.BAL_WETH_ADDRESS]; + async getUnderlyingTokenDefinitions() { + return [{ address: this.BAL_WETH_ADDRESS, network: this.network }]; } async getPrice(): Promise { diff --git a/src/apps/aura/ethereum/aura.deposit.token-fetcher.ts b/src/apps/aura/ethereum/aura.deposit.token-fetcher.ts index 29425c6f8..cde041ee8 100644 --- a/src/apps/aura/ethereum/aura.deposit.token-fetcher.ts +++ b/src/apps/aura/ethereum/aura.deposit.token-fetcher.ts @@ -73,12 +73,12 @@ export class EthereumAuraDepositTokenFetcher extends AppTokenTemplatePositionFet return definitions.map(v => v.address); } - async getUnderlyingTokenAddresses({ + async getUnderlyingTokenDefinitions({ definition, }: GetUnderlyingTokensParams) { const boosterContract = this.contractFactory.auraBooster({ address: definition.booster, network: this.network }); const poolInfo = await boosterContract.poolInfo(definition.poolIndex); - return poolInfo.lptoken; + return [{ address: poolInfo.lptoken, network: this.network }]; } async getLiquidity({ appToken }: GetDataPropsParams) { diff --git a/src/apps/badger/common/badger.vault.token-fetcher.ts b/src/apps/badger/common/badger.vault.token-fetcher.ts index 12628bb90..d155bebf0 100644 --- a/src/apps/badger/common/badger.vault.token-fetcher.ts +++ b/src/apps/badger/common/badger.vault.token-fetcher.ts @@ -46,8 +46,10 @@ export abstract class BadgerVaultTokenFetcher extends AppTokenTemplatePositionFe return definitions.map(v => v.address); } - async getUnderlyingTokenAddresses({ definition }: GetUnderlyingTokensParams) { - return definition.underlyingTokenAddress; + async getUnderlyingTokenDefinitions({ + definition, + }: GetUnderlyingTokensParams) { + return [{ address: definition.underlyingTokenAddress, network: this.network }]; } async getPricePerShare({ contract, appToken, multicall }: GetPricePerShareParams) { diff --git a/src/apps/balancer-v1/ethereum/balancer-v1.pool.token-fetcher.ts b/src/apps/balancer-v1/ethereum/balancer-v1.pool.token-fetcher.ts index 1c9b7fbd3..95bb9329e 100644 --- a/src/apps/balancer-v1/ethereum/balancer-v1.pool.token-fetcher.ts +++ b/src/apps/balancer-v1/ethereum/balancer-v1.pool.token-fetcher.ts @@ -78,8 +78,9 @@ export class EthereumBalancerV1PoolTokenFetcher extends AppTokenTemplatePosition return poolsFromSubgraph.pools.map(v => v.id); } - async getUnderlyingTokenAddresses({ contract }: GetUnderlyingTokensParams) { - return contract.getCurrentTokens(); + async getUnderlyingTokenDefinitions({ contract }: GetUnderlyingTokensParams) { + const tokenAddresses = await contract.getCurrentTokens(); + return tokenAddresses.map(address => ({ address, network: this.network })); } async getPricePerShare({ contract, appToken }: GetPricePerShareParams) { diff --git a/src/apps/balancer-v2/common/balancer-v2.pool.token-fetcher.ts b/src/apps/balancer-v2/common/balancer-v2.pool.token-fetcher.ts index cf3d20f6e..69c34d566 100644 --- a/src/apps/balancer-v2/common/balancer-v2.pool.token-fetcher.ts +++ b/src/apps/balancer-v2/common/balancer-v2.pool.token-fetcher.ts @@ -110,7 +110,7 @@ export abstract class BalancerV2PoolTokenFetcher extends AppTokenTemplatePositio return contract.totalSupply(); } - async getUnderlyingTokenAddresses({ address, contract, multicall }: GetUnderlyingTokensParams) { + async getUnderlyingTokenDefinitions({ address, contract, multicall }: GetUnderlyingTokensParams) { const _vault = this.contractFactory.balancerVault({ address: this.vaultAddress, network: this.network }); const vault = multicall.wrap(_vault); @@ -121,7 +121,7 @@ export abstract class BalancerV2PoolTokenFetcher extends AppTokenTemplatePositio const underlyingTokenAddresses = poolTokens.tokens.map(v => v.toLowerCase()); const redundantIndex = underlyingTokenAddresses.findIndex(v => v === address); const tokenAddresses = underlyingTokenAddresses.filter((_, i) => i !== redundantIndex); - return tokenAddresses; + return tokenAddresses.map(address => ({ address, network: this.network })); } async getPricePerShare({ appToken, contract, multicall }: GetPricePerShareParams) { diff --git a/src/apps/balancer-v2/ethereum/balancer-v2.wrapped-aave.token-fetcher.ts b/src/apps/balancer-v2/ethereum/balancer-v2.wrapped-aave.token-fetcher.ts index 00946f016..7dfe72c7b 100644 --- a/src/apps/balancer-v2/ethereum/balancer-v2.wrapped-aave.token-fetcher.ts +++ b/src/apps/balancer-v2/ethereum/balancer-v2.wrapped-aave.token-fetcher.ts @@ -33,8 +33,8 @@ export class EthereumBalancerV2WrappedAaveTokenFetcher extends AppTokenTemplateP return this.contractFactory.balancerWrappedAaveToken({ address, network: this.network }); } - async getUnderlyingTokenAddresses({ contract }: GetUnderlyingTokensParams) { - return contract.callStatic.ATOKEN(); + async getUnderlyingTokenDefinitions({ contract }: GetUnderlyingTokensParams) { + return [{ address: await contract.callStatic.ATOKEN(), network: this.network }]; } async getPricePerShare() { diff --git a/src/apps/bancor-v3/ethereum/bancor-v3.bnt-pool.token-fetcher.ts b/src/apps/bancor-v3/ethereum/bancor-v3.bnt-pool.token-fetcher.ts index 5e1c4e348..ce3521053 100644 --- a/src/apps/bancor-v3/ethereum/bancor-v3.bnt-pool.token-fetcher.ts +++ b/src/apps/bancor-v3/ethereum/bancor-v3.bnt-pool.token-fetcher.ts @@ -36,9 +36,10 @@ export class EthereumBancorV3BntPoolTokenFetcher extends AppTokenTemplatePositio return [this.bntPoolTokenAddress]; } - async getUnderlyingTokenAddresses({ contract }: GetUnderlyingTokensParams) { - const underlyingTokenAddress = await contract.reserveToken(); - return underlyingTokenAddress.toLowerCase().replace(ETH_ADDR_ALIAS, ZERO_ADDRESS); + async getUnderlyingTokenDefinitions({ contract }: GetUnderlyingTokensParams) { + const underlyingTokenAddressRaw = await contract.reserveToken(); + const underlyingTokenAddress = underlyingTokenAddressRaw.toLowerCase().replace(ETH_ADDR_ALIAS, ZERO_ADDRESS); + return [{ address: underlyingTokenAddress, network: this.network }]; } async getPricePerShare({ diff --git a/src/apps/bancor-v3/ethereum/bancor-v3.pool.token-fetcher.ts b/src/apps/bancor-v3/ethereum/bancor-v3.pool.token-fetcher.ts index 91e6708b1..a9e95a5da 100644 --- a/src/apps/bancor-v3/ethereum/bancor-v3.pool.token-fetcher.ts +++ b/src/apps/bancor-v3/ethereum/bancor-v3.pool.token-fetcher.ts @@ -45,9 +45,10 @@ export class EthereumBancorV3PoolTokenFetcher extends AppTokenTemplatePositionFe return addresses; } - async getUnderlyingTokenAddresses({ contract }: GetUnderlyingTokensParams) { - const underlyingTokenAddress = await contract.reserveToken(); - return underlyingTokenAddress.toLowerCase().replace(ETH_ADDR_ALIAS, ZERO_ADDRESS); + async getUnderlyingTokenDefinitions({ contract }: GetUnderlyingTokensParams) { + const underlyingTokenAddressRaw = await contract.reserveToken(); + const underlyingTokenAddress = underlyingTokenAddressRaw.toLowerCase().replace(ETH_ADDR_ALIAS, ZERO_ADDRESS); + return [{ address: underlyingTokenAddress, network: this.network }]; } async getPricePerShare({ diff --git a/src/apps/barnbridge-smart-alpha/common/barnbridge-smart-alpha.junior-pool.token-fetcher.ts b/src/apps/barnbridge-smart-alpha/common/barnbridge-smart-alpha.junior-pool.token-fetcher.ts index 26c563375..7afed34cf 100644 --- a/src/apps/barnbridge-smart-alpha/common/barnbridge-smart-alpha.junior-pool.token-fetcher.ts +++ b/src/apps/barnbridge-smart-alpha/common/barnbridge-smart-alpha.junior-pool.token-fetcher.ts @@ -70,10 +70,10 @@ export abstract class BarnbridgeSmartAlphaJuniorPoolTokenFetcher extends AppToke return definitions.map(x => x.address); } - async getUnderlyingTokenAddresses({ + async getUnderlyingTokenDefinitions({ definition, }: GetUnderlyingTokensParams) { - return [definition.underlyingTokenAddress]; + return [{ address: definition.underlyingTokenAddress, network: this.network }]; } async getPricePerShare({ diff --git a/src/apps/barnbridge-smart-alpha/common/barnbridge-smart-alpha.senior-pool.token-fetcher.ts b/src/apps/barnbridge-smart-alpha/common/barnbridge-smart-alpha.senior-pool.token-fetcher.ts index 135f3d9fe..7b9e0f4e1 100644 --- a/src/apps/barnbridge-smart-alpha/common/barnbridge-smart-alpha.senior-pool.token-fetcher.ts +++ b/src/apps/barnbridge-smart-alpha/common/barnbridge-smart-alpha.senior-pool.token-fetcher.ts @@ -70,10 +70,10 @@ export abstract class BarnbridgeSmartAlphaSeniorPoolTokenFetcher extends AppToke return definitions.map(x => x.address); } - async getUnderlyingTokenAddresses({ + async getUnderlyingTokenDefinitions({ definition, }: GetUnderlyingTokensParams) { - return [definition.underlyingTokenAddress]; + return [{ address: definition.underlyingTokenAddress, network: this.network }]; } async getPricePerShare({ diff --git a/src/apps/bastion-protocol/aurora/bastion-protocol.pool.token-fetcher.ts b/src/apps/bastion-protocol/aurora/bastion-protocol.pool.token-fetcher.ts index 0c1841f4a..a4d41cbdd 100644 --- a/src/apps/bastion-protocol/aurora/bastion-protocol.pool.token-fetcher.ts +++ b/src/apps/bastion-protocol/aurora/bastion-protocol.pool.token-fetcher.ts @@ -58,16 +58,19 @@ export class AuroraBastionProtocolPoolTokenFetcher extends AppTokenTemplatePosit return definitions.map(v => v.address); } - async getUnderlyingTokenAddresses({ + async getUnderlyingTokenDefinitions({ definition, multicall, - }: GetUnderlyingTokensParams): Promise { + }: GetUnderlyingTokensParams) { const swapContract = this.contractFactory.bastionProtocolSwap({ address: definition.swapAddress, network: this.network, }); - return Promise.all([multicall.wrap(swapContract).getToken(0), multicall.wrap(swapContract).getToken(1)]); + return [ + { address: await multicall.wrap(swapContract).getToken(0), network: this.network }, + { address: await multicall.wrap(swapContract).getToken(1), network: this.network }, + ]; } async getPricePerShare({ diff --git a/src/apps/beefy/common/beefy.vault.token-fetcher.ts b/src/apps/beefy/common/beefy.vault.token-fetcher.ts index a52ff2740..5797196e5 100644 --- a/src/apps/beefy/common/beefy.vault.token-fetcher.ts +++ b/src/apps/beefy/common/beefy.vault.token-fetcher.ts @@ -48,10 +48,10 @@ export abstract class BeefyVaultTokenFetcher extends AppTokenTemplatePositionFet return definitions.map(v => v.address); } - async getUnderlyingTokenAddresses({ + async getUnderlyingTokenDefinitions({ definition, }: GetUnderlyingTokensParams) { - return definition.underlyingAddress; + return [{ address: definition.underlyingAddress, network: this.network }]; } async getPricePerShare({ diff --git a/src/apps/bend-dao/ethereum/bend-dao.supply.token-fetcher.ts b/src/apps/bend-dao/ethereum/bend-dao.supply.token-fetcher.ts index a2bb0c715..e5fca2146 100644 --- a/src/apps/bend-dao/ethereum/bend-dao.supply.token-fetcher.ts +++ b/src/apps/bend-dao/ethereum/bend-dao.supply.token-fetcher.ts @@ -35,8 +35,8 @@ export class EthereumBendDaoSupplyTokenFetcher extends AppTokenTemplatePositionF return [this.bTokenAddress]; } - async getUnderlyingTokenAddresses({ contract }: GetUnderlyingTokensParams) { - return contract.UNDERLYING_ASSET_ADDRESS(); + async getUnderlyingTokenDefinitions({ contract }: GetUnderlyingTokensParams) { + return [{ address: await contract.UNDERLYING_ASSET_ADDRESS(), network: this.network }]; } async getLiquidity({ appToken }: GetDataPropsParams): Promise { diff --git a/src/apps/bend-dao/ethereum/bend-dao.variable-debt.token-fetcher.ts b/src/apps/bend-dao/ethereum/bend-dao.variable-debt.token-fetcher.ts index 7e2d0ea88..21cffc8c0 100644 --- a/src/apps/bend-dao/ethereum/bend-dao.variable-debt.token-fetcher.ts +++ b/src/apps/bend-dao/ethereum/bend-dao.variable-debt.token-fetcher.ts @@ -36,8 +36,8 @@ export class EthereumBendDaoVariableDebtTokenFetcher extends AppTokenTemplatePos return [this.debtTokenAddress]; } - async getUnderlyingTokenAddresses({ contract }: GetUnderlyingTokensParams) { - return contract.UNDERLYING_ASSET_ADDRESS(); + async getUnderlyingTokenDefinitions({ contract }: GetUnderlyingTokensParams) { + return [{ address: await contract.UNDERLYING_ASSET_ADDRESS(), network: this.network }]; } async getLiquidity({ appToken }: GetDataPropsParams): Promise { diff --git a/src/apps/cask-protocol/common/cask-protocol.wallet.token-fetcher.ts b/src/apps/cask-protocol/common/cask-protocol.wallet.token-fetcher.ts index ecd3becbe..af30bd443 100644 --- a/src/apps/cask-protocol/common/cask-protocol.wallet.token-fetcher.ts +++ b/src/apps/cask-protocol/common/cask-protocol.wallet.token-fetcher.ts @@ -24,8 +24,8 @@ export abstract class CaskProtocolWalletTokenFetcher extends AppTokenTemplatePos return [this.caskVaultContractAddress]; } - async getUnderlyingTokenAddresses({ contract }: GetUnderlyingTokensParams) { - return contract.getBaseAsset(); + async getUnderlyingTokenDefinitions({ contract }: GetUnderlyingTokensParams) { + return [{ address: await contract.getBaseAsset(), network: this.network }]; } async getPricePerShare({ appToken, contract }: GetPricePerShareParams) { diff --git a/src/apps/chicken-bond/ethereum/chicken-bond.blusd.token-fetcher.ts b/src/apps/chicken-bond/ethereum/chicken-bond.blusd.token-fetcher.ts index 014067968..0442b79a9 100644 --- a/src/apps/chicken-bond/ethereum/chicken-bond.blusd.token-fetcher.ts +++ b/src/apps/chicken-bond/ethereum/chicken-bond.blusd.token-fetcher.ts @@ -27,8 +27,8 @@ export class EthereumChickenBondBlusdTokenFetcher extends AppTokenTemplatePositi return ['0xb9d7dddca9a4ac480991865efef82e01273f79c3']; } - async getUnderlyingTokenAddresses() { - return ['0x5f98805a4e8be255a32880fdec7f6728c6568ba0']; + async getUnderlyingTokenDefinitions() { + return [{ address: '0x5f98805a4e8be255a32880fdec7f6728c6568ba0', network: this.network }]; } async getPrice({ multicall }: GetPriceParams): Promise { diff --git a/src/apps/clearpool/common/clearpool.pool.token-fetcher.ts b/src/apps/clearpool/common/clearpool.pool.token-fetcher.ts index f4289e08a..345398268 100644 --- a/src/apps/clearpool/common/clearpool.pool.token-fetcher.ts +++ b/src/apps/clearpool/common/clearpool.pool.token-fetcher.ts @@ -31,8 +31,8 @@ export abstract class ClearpoolPoolTokenFetcher extends AppTokenTemplatePosition return this.clearpoolContractFactory.clearpoolPool({ address, network: this.network }); } - getUnderlyingTokenAddresses({ contract }: GetUnderlyingTokensParams) { - return contract.currency(); + async getUnderlyingTokenDefinitions({ contract }: GetUnderlyingTokensParams) { + return [{ address: await contract.currency(), network: this.network }]; } getPricePerShare({ contract }: GetPricePerShareParams): Promise { diff --git a/src/apps/clever/ethereum/clever.lever.token-fetcher.ts b/src/apps/clever/ethereum/clever.lever.token-fetcher.ts index dea1a39dd..9ef334571 100644 --- a/src/apps/clever/ethereum/clever.lever.token-fetcher.ts +++ b/src/apps/clever/ethereum/clever.lever.token-fetcher.ts @@ -29,8 +29,8 @@ export class EthereumCleverLeverTokenFetcher extends AppTokenTemplatePositionFet return [CLEVCVX]; } - async getUnderlyingTokenAddresses() { - return [CVX]; + async getUnderlyingTokenDefinitions() { + return [{ address: CVX, network: this.network }]; } async getPricePerShare() { diff --git a/src/apps/compound/common/compound.supply.token-fetcher.ts b/src/apps/compound/common/compound.supply.token-fetcher.ts index 1f87d0912..d6fba42a6 100644 --- a/src/apps/compound/common/compound.supply.token-fetcher.ts +++ b/src/apps/compound/common/compound.supply.token-fetcher.ts @@ -42,14 +42,15 @@ export abstract class CompoundSupplyTokenFetcher< return this.getMarkets({ ...params, contract: comptroller }); } - async getUnderlyingTokenAddresses(params: GetUnderlyingTokensParams) { + async getUnderlyingTokenDefinitions(params: GetUnderlyingTokensParams) { const underlyingAddressRaw = await this.getUnderlyingAddress(params).catch(err => { // if the underlying call failed, it's the compound-wrapped native token if (isMulticallUnderlyingError(err)) return ZERO_ADDRESS; throw err; }); - return underlyingAddressRaw.toLowerCase().replace(ETH_ADDR_ALIAS, ZERO_ADDRESS); + const underlyingAddress = underlyingAddressRaw.toLowerCase().replace(ETH_ADDR_ALIAS, ZERO_ADDRESS); + return [{ address: underlyingAddress, network: this.network }]; } async getExchangeRateMantissa(params: GetPricePerShareParams) { diff --git a/src/apps/concentrator/ethereum/concentrator.acrv.token-fetcher.ts b/src/apps/concentrator/ethereum/concentrator.acrv.token-fetcher.ts index 2201ed7f3..6c7895161 100644 --- a/src/apps/concentrator/ethereum/concentrator.acrv.token-fetcher.ts +++ b/src/apps/concentrator/ethereum/concentrator.acrv.token-fetcher.ts @@ -26,8 +26,8 @@ export class EthereumConcentratorAcrvTokenFetcher extends AppTokenTemplatePositi return ['0x2b95a1dcc3d405535f9ed33c219ab38e8d7e0884']; } - async getUnderlyingTokenAddresses() { - return ['0x62b9c7356a2dc64a1969e19c23e4f579f9810aa7']; + async getUnderlyingTokenDefinitions() { + return [{ address: '0x62b9c7356a2dc64a1969e19c23e4f579f9810aa7', network: this.network }]; } async getPricePerShare({ appToken, contract }: GetPricePerShareParams) { diff --git a/src/apps/concentrator/ethereum/concentrator.afxs.token-fetcher.ts b/src/apps/concentrator/ethereum/concentrator.afxs.token-fetcher.ts index 05c0f0808..beeebcd4b 100644 --- a/src/apps/concentrator/ethereum/concentrator.afxs.token-fetcher.ts +++ b/src/apps/concentrator/ethereum/concentrator.afxs.token-fetcher.ts @@ -26,8 +26,8 @@ export class EthereumConcentratorAfxsTokenFetcher extends AppTokenTemplatePositi return ['0xdaf03d70fe637b91ba6e521a32e1fb39256d3ec9']; } - async getUnderlyingTokenAddresses() { - return ['0x62b9c7356a2dc64a1969e19c23e4f579f9810aa7']; + async getUnderlyingTokenDefinitions() { + return [{ address: '0xfeef77d3f69374f66429c91d732a244f074bdf74', network: this.network }]; } async getPricePerShare({ appToken, contract }: GetPricePerShareParams) { diff --git a/src/apps/convex/common/convex.deposit-sidechain.token-fetcher.ts b/src/apps/convex/common/convex.deposit-sidechain.token-fetcher.ts index 7c594c41b..d3d2a30b9 100644 --- a/src/apps/convex/common/convex.deposit-sidechain.token-fetcher.ts +++ b/src/apps/convex/common/convex.deposit-sidechain.token-fetcher.ts @@ -58,7 +58,7 @@ export abstract class ConvexDepositSidechainTokenFetcher extends AppTokenTemplat return definitions.map(v => v.address); } - async getUnderlyingTokenAddresses({ + async getUnderlyingTokenDefinitions({ definition, }: GetUnderlyingTokensParams) { const depositContract = this.contractFactory.convexBoosterSidechain({ @@ -67,7 +67,7 @@ export abstract class ConvexDepositSidechainTokenFetcher extends AppTokenTemplat }); const poolInfo = await depositContract.poolInfo(definition.poolIndex); - return poolInfo.lptoken; + return [{ address: poolInfo.lptoken, network: this.network }]; } async getLabel({ appToken }: GetDisplayPropsParams) { diff --git a/src/apps/convex/common/convex.deposit.token-fetcher.ts b/src/apps/convex/common/convex.deposit.token-fetcher.ts index 11b8784fc..5a2eb5256 100644 --- a/src/apps/convex/common/convex.deposit.token-fetcher.ts +++ b/src/apps/convex/common/convex.deposit.token-fetcher.ts @@ -61,7 +61,7 @@ export abstract class ConvexDepositTokenFetcher extends AppTokenTemplatePosition return definitions.map(v => v.address); } - async getUnderlyingTokenAddresses({ + async getUnderlyingTokenDefinitions({ definition, }: GetUnderlyingTokensParams) { const depositContract = this.contractFactory.convexBooster({ @@ -70,7 +70,7 @@ export abstract class ConvexDepositTokenFetcher extends AppTokenTemplatePosition }); const poolInfo = await depositContract.poolInfo(definition.poolIndex); - return poolInfo.lptoken; + return [{ address: poolInfo.lptoken, network: this.network }]; } async getLabel({ appToken }: GetDisplayPropsParams) { diff --git a/src/apps/curve/common/curve.pool-dynamic.token-fetcher.ts b/src/apps/curve/common/curve.pool-dynamic.token-fetcher.ts index 44ff44348..a817e14cb 100644 --- a/src/apps/curve/common/curve.pool-dynamic.token-fetcher.ts +++ b/src/apps/curve/common/curve.pool-dynamic.token-fetcher.ts @@ -127,15 +127,20 @@ export abstract class CurvePoolDynamicTokenFetcher extends A return definitions.map(v => v.address); } - async getUnderlyingTokenAddresses({ multicall, definition }: GetUnderlyingTokensParams) { + async getUnderlyingTokenDefinitions({ + multicall, + definition, + }: GetUnderlyingTokensParams) { const contract = multicall.wrap(this.resolveRegistry(this.registryAddress)); const swapAddress = definition.swapAddress; const coinsRaw = await this.resolveCoinAddresses({ contract, swapAddress, multicall }); - return coinsRaw + const underlyingTokenAddresses = coinsRaw .map(v => v.toLowerCase()) .filter(v => v !== ZERO_ADDRESS) .map(v => (v === ETH_ADDR_ALIAS ? ZERO_ADDRESS : v)); + + return underlyingTokenAddresses.map(address => ({ address, network: this.network })); } async getPricePerShare({ diff --git a/src/apps/curve/common/curve.pool-static.token-fetcher.ts b/src/apps/curve/common/curve.pool-static.token-fetcher.ts index 7517f5cb9..f3a38f055 100644 --- a/src/apps/curve/common/curve.pool-static.token-fetcher.ts +++ b/src/apps/curve/common/curve.pool-static.token-fetcher.ts @@ -85,7 +85,10 @@ export abstract class CurvePoolStaticTokenFetcher extends Ap return definitions.map(v => v.address); } - async getUnderlyingTokenAddresses({ multicall, definition }: GetUnderlyingTokensParams) { + async getUnderlyingTokenDefinitions({ + multicall, + definition, + }: GetUnderlyingTokensParams) { const contract = multicall.wrap(this.resolvePoolContract(definition)); const coinAddressesRaw = await Promise.all( @@ -97,10 +100,12 @@ export abstract class CurvePoolStaticTokenFetcher extends Ap ), ); - return compact(coinAddressesRaw) + const underlyingTokenAddresses = compact(coinAddressesRaw) .filter(v => v !== ZERO_ADDRESS) .map(v => v.toLowerCase()) .map(v => v.replace(ETH_ADDR_ALIAS, ZERO_ADDRESS)); + + return underlyingTokenAddresses.map(address => ({ address, network: this.network })); } async getPricePerShare({ diff --git a/src/apps/dhedge-v2/common/dhedge-v2.pool.token-fetcher.ts b/src/apps/dhedge-v2/common/dhedge-v2.pool.token-fetcher.ts index 4ee38c066..0324567c3 100644 --- a/src/apps/dhedge-v2/common/dhedge-v2.pool.token-fetcher.ts +++ b/src/apps/dhedge-v2/common/dhedge-v2.pool.token-fetcher.ts @@ -38,8 +38,8 @@ export abstract class DhedgeV2PoolTokenFetcher extends AppTokenTemplatePositionF return deployedFunds; } - async getUnderlyingTokenAddresses() { - return this.underlyingTokenAddress; + async getUnderlyingTokenDefinitions() { + return [{ address: this.underlyingTokenAddress, network: this.network }]; } async getPricePerShare({ contract }: GetPricePerShareParams) { diff --git a/src/apps/dystopia/polygon/dystopia.pool.token-fetcher.ts b/src/apps/dystopia/polygon/dystopia.pool.token-fetcher.ts index b4bb8e217..2c91b7b55 100644 --- a/src/apps/dystopia/polygon/dystopia.pool.token-fetcher.ts +++ b/src/apps/dystopia/polygon/dystopia.pool.token-fetcher.ts @@ -59,8 +59,11 @@ export class PolygonDystopiaPairsTokenFetcher extends AppTokenTemplatePositionFe return data.pairs.map(v => v.id); } - async getUnderlyingTokenAddresses({ contract }: GetUnderlyingTokensParams) { - return Promise.all([contract.token0(), contract.token1()]); + async getUnderlyingTokenDefinitions({ contract }: GetUnderlyingTokensParams) { + return [ + { address: await contract.token0(), network: this.network }, + { address: await contract.token1(), network: this.network }, + ]; } async getPricePerShare({ appToken, contract }: GetPricePerShareParams) { diff --git a/src/apps/ease/common/ease.rca.token-fetcher.ts b/src/apps/ease/common/ease.rca.token-fetcher.ts index 88b6ceba5..4aa0763c4 100644 --- a/src/apps/ease/common/ease.rca.token-fetcher.ts +++ b/src/apps/ease/common/ease.rca.token-fetcher.ts @@ -46,8 +46,10 @@ export abstract class EaseRcaTokenFetcher extends AppTokenTemplatePositionFetche return definitions.map(v => v.address); } - async getUnderlyingTokenAddresses({ definition }: GetUnderlyingTokensParams) { - return definition.underlyingTokenAddress; + async getUnderlyingTokenDefinitions({ + definition, + }: GetUnderlyingTokensParams) { + return [{ address: definition.underlyingTokenAddress, network: this.network }]; } async getLiquidity({ appToken }: GetDataPropsParams) { diff --git a/src/apps/enzyme-finance/ethereum/enzyme-finance.vault.token-fetcher.ts b/src/apps/enzyme-finance/ethereum/enzyme-finance.vault.token-fetcher.ts index 1477e0d2d..b44b96477 100644 --- a/src/apps/enzyme-finance/ethereum/enzyme-finance.vault.token-fetcher.ts +++ b/src/apps/enzyme-finance/ethereum/enzyme-finance.vault.token-fetcher.ts @@ -53,8 +53,8 @@ export class EthereumEnzymeFinanceVaultTokenFetcher extends AppTokenTemplatePosi return contract.name(); } - async getUnderlyingTokenAddresses({ contract }: GetUnderlyingTokensParams) { - return (await contract.getTrackedAssets()).map(x => x.toLowerCase()); + async getUnderlyingTokenDefinitions({ contract }: GetUnderlyingTokensParams) { + return (await contract.getTrackedAssets()).map(x => ({ address: x.toLowerCase(), network: this.network })); } async getPricePerShare({ diff --git a/src/apps/euler/common/euler.d-token.token-fetcher.ts b/src/apps/euler/common/euler.d-token.token-fetcher.ts index e67ccaf38..d5c86818c 100644 --- a/src/apps/euler/common/euler.d-token.token-fetcher.ts +++ b/src/apps/euler/common/euler.d-token.token-fetcher.ts @@ -42,10 +42,10 @@ export abstract class EulerDTokenTokenFetcher extends AppTokenTemplatePositionFe return definitions.map(v => v.address); } - async getUnderlyingTokenAddresses({ + async getUnderlyingTokenDefinitions({ definition, }: GetUnderlyingTokensParams) { - return definition.underlyingTokenAddress; + return [{ address: definition.underlyingTokenAddress, network: this.network }]; } async getSymbol({ address }): Promise { diff --git a/src/apps/euler/common/euler.e-token.token-fetcher.ts b/src/apps/euler/common/euler.e-token.token-fetcher.ts index 40f2735c9..d685bf22a 100644 --- a/src/apps/euler/common/euler.e-token.token-fetcher.ts +++ b/src/apps/euler/common/euler.e-token.token-fetcher.ts @@ -46,10 +46,10 @@ export abstract class EulerETokenTokenFetcher extends AppTokenTemplatePositionFe return definitions.map(v => v.address); } - async getUnderlyingTokenAddresses({ + async getUnderlyingTokenDefinitions({ definition, }: GetUnderlyingTokensParams) { - return definition.underlyingTokenAddress; + return [{ address: definition.underlyingTokenAddress, network: this.network }]; } async getSymbol({ address }): Promise { diff --git a/src/apps/euler/common/euler.p-token.token-fetcher.ts b/src/apps/euler/common/euler.p-token.token-fetcher.ts index d64f6dcd9..7663dcd0c 100644 --- a/src/apps/euler/common/euler.p-token.token-fetcher.ts +++ b/src/apps/euler/common/euler.p-token.token-fetcher.ts @@ -41,10 +41,10 @@ export abstract class EulerPTokenTokenFetcher extends AppTokenTemplatePositionFe return definitions.map(v => v.address); } - async getUnderlyingTokenAddresses({ + async getUnderlyingTokenDefinitions({ definition, }: GetUnderlyingTokensParams) { - return definition.underlyingTokenAddress; + return [{ address: definition.underlyingTokenAddress, network: this.network }]; } async getSymbol({ address }): Promise { diff --git a/src/apps/furucombo/polygon/furucombo.fund.token-fetcher.ts b/src/apps/furucombo/polygon/furucombo.fund.token-fetcher.ts index fb927e153..64aff0458 100644 --- a/src/apps/furucombo/polygon/furucombo.fund.token-fetcher.ts +++ b/src/apps/furucombo/polygon/furucombo.fund.token-fetcher.ts @@ -107,10 +107,10 @@ export class PolygonFurucomboFundTokenFetcher extends AppTokenTemplatePositionFe return definitions.map(v => v.address); } - async getUnderlyingTokenAddresses({ + async getUnderlyingTokenDefinitions({ definition, }: GetUnderlyingTokensParams) { - return definition.stakingTokenAddress; + return [{ address: definition.stakingTokenAddress, network: this.network }]; } async getPricePerShare({ diff --git a/src/apps/gearbox/ethereum/gearbox.lending.token-fetcher.ts b/src/apps/gearbox/ethereum/gearbox.lending.token-fetcher.ts index eccbe5a13..c03663b37 100644 --- a/src/apps/gearbox/ethereum/gearbox.lending.token-fetcher.ts +++ b/src/apps/gearbox/ethereum/gearbox.lending.token-fetcher.ts @@ -99,8 +99,11 @@ export class EthereumGearboxLendingTokenFetcher extends AppTokenTemplatePosition return []; } - async getUnderlyingTokenAddresses({ definition }: GetUnderlyingTokensParams) { - return this._getPoolContract(definition).underlyingToken(); + async getUnderlyingTokenDefinitions({ + definition, + }: GetUnderlyingTokensParams) { + const underlyingTokenAddress = await this._getPoolContract(definition).underlyingToken(); + return [{ address: underlyingTokenAddress, network: this.network }]; } async getPricePerShare({ diff --git a/src/apps/gmx/common/gmx.es-gmx.token-fetcher.ts b/src/apps/gmx/common/gmx.es-gmx.token-fetcher.ts index fd3f563d7..3ace5bf05 100644 --- a/src/apps/gmx/common/gmx.es-gmx.token-fetcher.ts +++ b/src/apps/gmx/common/gmx.es-gmx.token-fetcher.ts @@ -25,8 +25,8 @@ export abstract class GmxEsGmxTokenFetcher extends AppTokenTemplatePositionFetch return [this.esGmxAddress]; } - async getUnderlyingTokenAddresses() { - return [this.gmxAddress]; + async getUnderlyingTokenDefinitions() { + return [{ address: this.gmxAddress, network: this.network }]; } async getPricePerShare() { diff --git a/src/apps/gmx/common/gmx.glp.token-fetcher.ts b/src/apps/gmx/common/gmx.glp.token-fetcher.ts index 5d361f987..9910dd66a 100644 --- a/src/apps/gmx/common/gmx.glp.token-fetcher.ts +++ b/src/apps/gmx/common/gmx.glp.token-fetcher.ts @@ -33,7 +33,7 @@ export abstract class GmxGlpTokenFetcher extends AppTokenTemplatePositionFetcher return [this.glpTokenAddress]; } - async getUnderlyingTokenAddresses({ multicall }: GetUnderlyingTokensParams) { + async getUnderlyingTokenDefinitions({ multicall }: GetUnderlyingTokensParams) { const glpManagerContract = this.contractFactory.gmxAumManager({ address: this.glmManagerAddress, network: this.network, @@ -46,7 +46,8 @@ export abstract class GmxGlpTokenFetcher extends AppTokenTemplatePositionFetcher const tokenRange = range(0, Number(tokenCount)); const tokenAddresses = await Promise.all(tokenRange.map(i => multicall.wrap(vault).allWhitelistedTokens(i))); - return tokenAddresses.filter(v => !this.blockedTokenAddresses.includes(v.toLowerCase())); + const validTokenAddresses = tokenAddresses.filter(v => !this.blockedTokenAddresses.includes(v.toLowerCase())); + return validTokenAddresses.map(address => ({ address, network: this.network })); } async getPricePerShare({ appToken, multicall }: GetPricePerShareParams) { diff --git a/src/apps/gro/avalanche/gro.labs.token-fetcher.ts b/src/apps/gro/avalanche/gro.labs.token-fetcher.ts index e2cc37f8e..b11b03ee7 100644 --- a/src/apps/gro/avalanche/gro.labs.token-fetcher.ts +++ b/src/apps/gro/avalanche/gro.labs.token-fetcher.ts @@ -35,8 +35,8 @@ export class AvalancheGroLabsTokenFetcher extends AppTokenTemplatePositionFetche ]; } - async getUnderlyingTokenAddresses({ contract }: GetUnderlyingTokensParams) { - return contract.token(); + async getUnderlyingTokenDefinitions({ contract }: GetUnderlyingTokensParams) { + return [{ address: await contract.token(), network: this.network }]; } async getPricePerShare({ contract }: GetPricePerShareParams) { diff --git a/src/apps/hedgefarm/avalanche/hedgefarm.alpha-one.token-fetcher.ts b/src/apps/hedgefarm/avalanche/hedgefarm.alpha-one.token-fetcher.ts index 4f86d8ba3..257792637 100644 --- a/src/apps/hedgefarm/avalanche/hedgefarm.alpha-one.token-fetcher.ts +++ b/src/apps/hedgefarm/avalanche/hedgefarm.alpha-one.token-fetcher.ts @@ -29,8 +29,8 @@ export class AvalancheHedgefarmAlphaOneTokenFetcher extends AppTokenTemplatePosi return ['0xde4133f0cfa1a61ba94ec64b6fede4acc1fe929e']; } - async getUnderlyingTokenAddresses() { - return ['0xb97ef9ef8734c71904d8002f8b6bc66dd9c48a6e']; + async getUnderlyingTokenDefinitions() { + return [{ address: '0xb97ef9ef8734c71904d8002f8b6bc66dd9c48a6e', network: this.network }]; } async getPricePerShare({ contract }: GetPricePerShareParams) { diff --git a/src/apps/idle/ethereum/idle.vault.token-fetcher.ts b/src/apps/idle/ethereum/idle.vault.token-fetcher.ts index 9c1bc42e1..411f8cbba 100644 --- a/src/apps/idle/ethereum/idle.vault.token-fetcher.ts +++ b/src/apps/idle/ethereum/idle.vault.token-fetcher.ts @@ -38,8 +38,8 @@ export class EthereumIdleVaultTokenFetcher extends AppTokenTemplatePositionFetch return controller.getAllMarkets(); } - async getUnderlyingTokenAddresses({ contract }: GetUnderlyingTokensParams) { - return contract.token(); + async getUnderlyingTokenDefinitions({ contract }: GetUnderlyingTokensParams) { + return [{ address: await contract.token(), network: this.network }]; } async getPricePerShare({ appToken, contract }: GetPricePerShareParams) { diff --git a/src/apps/impermax/common/impermax.collateral.token-fetcher.ts b/src/apps/impermax/common/impermax.collateral.token-fetcher.ts index 6508b36e5..34beb3252 100644 --- a/src/apps/impermax/common/impermax.collateral.token-fetcher.ts +++ b/src/apps/impermax/common/impermax.collateral.token-fetcher.ts @@ -42,8 +42,8 @@ export abstract class ImpermaxCollateralTokenFetcher extends AppTokenTemplatePos return _.compact(collateralAddresses); } - async getUnderlyingTokenAddresses({ contract }: GetUnderlyingTokensParams) { - return contract.underlying(); + async getUnderlyingTokenDefinitions({ contract }: GetUnderlyingTokensParams) { + return [{ address: await contract.underlying(), network: this.network }]; } async getLiquidity({ appToken }: GetDataPropsParams) { diff --git a/src/apps/impermax/common/impermax.lend.token-fetcher.ts b/src/apps/impermax/common/impermax.lend.token-fetcher.ts index 8220c8562..5c725c0d2 100644 --- a/src/apps/impermax/common/impermax.lend.token-fetcher.ts +++ b/src/apps/impermax/common/impermax.lend.token-fetcher.ts @@ -43,8 +43,8 @@ export abstract class ImpermaxLendTokenFetcher extends AppTokenTemplatePositionF return _.flatten(collateralAddresses); } - async getUnderlyingTokenAddresses({ contract }: GetUnderlyingTokensParams) { - return contract.underlying(); + async getUnderlyingTokenDefinitions({ contract }: GetUnderlyingTokensParams) { + return [{ address: await contract.underlying(), network: this.network }]; } async getPricePerShare({ contract, appToken }: GetPricePerShareParams) { diff --git a/src/apps/impermax/helpers/impermax.collateral.token-fetcher.ts b/src/apps/impermax/helpers/impermax.collateral.token-fetcher.ts index c9b4aa511..f4a944724 100644 --- a/src/apps/impermax/helpers/impermax.collateral.token-fetcher.ts +++ b/src/apps/impermax/helpers/impermax.collateral.token-fetcher.ts @@ -38,7 +38,7 @@ export abstract class ImpermaxCollateralTokenFetcher extends AppTokenTemplatePos return _.compact(collateralAddresses); } - async getUnderlyingTokenAddresses({ contract }: GetUnderlyingTokensParams) { - return contract.underlying(); + async getUnderlyingTokenDefinitions({ contract }: GetUnderlyingTokensParams) { + return [{ address: await contract.underlying(), network: this.network }]; } } diff --git a/src/apps/impermax/helpers/impermax.lend.token-fetcher.ts b/src/apps/impermax/helpers/impermax.lend.token-fetcher.ts index b65b30934..d6487c7e4 100644 --- a/src/apps/impermax/helpers/impermax.lend.token-fetcher.ts +++ b/src/apps/impermax/helpers/impermax.lend.token-fetcher.ts @@ -42,8 +42,8 @@ export abstract class ImpermaxLendTokenFetcher extends AppTokenTemplatePositionF return _.flatten(collateralAddresses); } - async getUnderlyingTokenAddresses({ contract }: GetUnderlyingTokensParams) { - return contract.underlying(); + async getUnderlyingTokenDefinitions({ contract }: GetUnderlyingTokensParams) { + return [{ address: await contract.underlying(), network: this.network }]; } async getPricePerShare({ contract, appToken }: GetPricePerShareParams) { diff --git a/src/apps/index-coop/ethereum/index-coop.index.token-fetcher.ts b/src/apps/index-coop/ethereum/index-coop.index.token-fetcher.ts index b0d56fc3e..3029e2f8c 100644 --- a/src/apps/index-coop/ethereum/index-coop.index.token-fetcher.ts +++ b/src/apps/index-coop/ethereum/index-coop.index.token-fetcher.ts @@ -42,10 +42,8 @@ export class EthereumIndexCoopIndexTokenFetcher extends AppTokenTemplatePosition ]; } - async getUnderlyingTokenAddresses({ - contract, - }: GetUnderlyingTokensParams): Promise { - return contract.getComponents(); + async getUnderlyingTokenDefinitions({ contract }: GetUnderlyingTokensParams) { + return (await contract.getComponents()).map(address => ({ address, network: this.network })); } async getPrice({ contract, appToken }: GetPriceParams) { diff --git a/src/apps/insurace/common/insurace.mining.token-fetcher.ts b/src/apps/insurace/common/insurace.mining.token-fetcher.ts index ae907f5e2..74817852e 100644 --- a/src/apps/insurace/common/insurace.mining.token-fetcher.ts +++ b/src/apps/insurace/common/insurace.mining.token-fetcher.ts @@ -44,10 +44,10 @@ export abstract class InsuraceMiningTokenFetcher extends AppTokenTemplatePositio return definitions.map(v => v.address); } - async getUnderlyingTokenAddresses({ + async getUnderlyingTokenDefinitions({ definition, }: GetUnderlyingTokensParams) { - return [definition.underlyingTokenAddress]; + return [{ address: definition.underlyingTokenAddress, network: this.network }]; } async getPricePerShare({ diff --git a/src/apps/klima/polygon/klima.s-klima.token-fetcher.ts b/src/apps/klima/polygon/klima.s-klima.token-fetcher.ts index 502524295..ffc45460b 100644 --- a/src/apps/klima/polygon/klima.s-klima.token-fetcher.ts +++ b/src/apps/klima/polygon/klima.s-klima.token-fetcher.ts @@ -26,8 +26,8 @@ export class PolygonKlimaSKlimaTokenFetcher extends AppTokenTemplatePositionFetc return ['0xb0c22d8d350c67420f06f48936654f567c73e8c8']; } - async getUnderlyingTokenAddresses() { - return ['0x4e78011ce80ee02d2c3e649fb657e45898257815']; + async getUnderlyingTokenDefinitions() { + return [{ address: '0x4e78011ce80ee02d2c3e649fb657e45898257815', network: this.network }]; } async getPricePerShare() { diff --git a/src/apps/klima/polygon/klima.ws-klima.token-fetcher.ts b/src/apps/klima/polygon/klima.ws-klima.token-fetcher.ts index 4d4a83d13..13fad3f84 100644 --- a/src/apps/klima/polygon/klima.ws-klima.token-fetcher.ts +++ b/src/apps/klima/polygon/klima.ws-klima.token-fetcher.ts @@ -26,8 +26,8 @@ export class PolygonKlimaWsKlimaTokenFetcher extends AppTokenTemplatePositionFet return ['0x6f370dba99e32a3cad959b341120db3c9e280ba6']; } - async getUnderlyingTokenAddresses({ contract }: GetUnderlyingTokensParams) { - return [await contract.sKLIMA()]; + async getUnderlyingTokenDefinitions({ contract }: GetUnderlyingTokensParams) { + return [{ address: await contract.sKLIMA(), network: this.network }]; } async getPricePerShare({ appToken, multicall }: GetPricePerShareParams) { diff --git a/src/apps/llama-airforce/ethereum/llama-airforce.vault.token-fetcher.ts b/src/apps/llama-airforce/ethereum/llama-airforce.vault.token-fetcher.ts index a1dbadff5..bd7bc5416 100644 --- a/src/apps/llama-airforce/ethereum/llama-airforce.vault.token-fetcher.ts +++ b/src/apps/llama-airforce/ethereum/llama-airforce.vault.token-fetcher.ts @@ -37,17 +37,18 @@ export class EthereumLlamaAirforceVaultTokenFetcher extends AppTokenTemplatePosi ]; } - async getUnderlyingTokenAddresses({ + async getUnderlyingTokenDefinitions({ address, contract, multicall, }: GetUnderlyingTokensParams) { if (address === '0x8659fc767cad6005de79af65dafe4249c57927af') { const pirexContract = this.contractFactory.llamaAirforceUnionVaultPirex({ address, network: this.network }); - return multicall.wrap(pirexContract).asset(); + + return [{ address: await multicall.wrap(pirexContract).asset(), network: this.network }]; } - return contract.underlying(); + return [{ address: await contract.underlying(), network: this.network }]; } async getPricePerShare({ contract, appToken, multicall }: GetPricePerShareParams) { diff --git a/src/apps/lyra-avalon/optimism/lyra-avalon.pool.token-fetcher.ts b/src/apps/lyra-avalon/optimism/lyra-avalon.pool.token-fetcher.ts index c77b4f8ca..21e8418a7 100644 --- a/src/apps/lyra-avalon/optimism/lyra-avalon.pool.token-fetcher.ts +++ b/src/apps/lyra-avalon/optimism/lyra-avalon.pool.token-fetcher.ts @@ -85,8 +85,8 @@ export class OptimismLyraAvalonPoolTokenFetcher extends AppTokenTemplatePosition return markets.map(market => market.liquidityTokens); } - async getUnderlyingTokenAddresses() { - return ['0x8c6f28f2f1a3c87f0f938b96d27520d9751ec8d9']; // sUSD + async getUnderlyingTokenDefinitions() { + return [{ address: '0x8c6f28f2f1a3c87f0f938b96d27520d9751ec8d9', network: this.network }]; } async getPricePerShare({ diff --git a/src/apps/lyra-avalon/optimism/lyra-avalon.stk-lyra.token-fetcher.ts b/src/apps/lyra-avalon/optimism/lyra-avalon.stk-lyra.token-fetcher.ts index 933568163..2fe14e124 100644 --- a/src/apps/lyra-avalon/optimism/lyra-avalon.stk-lyra.token-fetcher.ts +++ b/src/apps/lyra-avalon/optimism/lyra-avalon.stk-lyra.token-fetcher.ts @@ -26,8 +26,8 @@ export class OptimismLyraAvalonStkLyraTokenFetcher extends AppTokenTemplatePosit return ['0xde48b1b5853cc63b1d05e507414d3e02831722f8']; } - async getUnderlyingTokenAddresses() { - return ['0x50c5725949a6f0c72e6c4a641f24049a917db0cb']; + async getUnderlyingTokenDefinitions() { + return [{ address: '0x50c5725949a6f0c72e6c4a641f24049a917db0cb', network: this.network }]; } async getLiquidity({ appToken }: GetDataPropsParams) { diff --git a/src/apps/maple/ethereum/maple.pool.token-fetcher.ts b/src/apps/maple/ethereum/maple.pool.token-fetcher.ts index d27bcaa7f..414c9e17f 100644 --- a/src/apps/maple/ethereum/maple.pool.token-fetcher.ts +++ b/src/apps/maple/ethereum/maple.pool.token-fetcher.ts @@ -49,8 +49,8 @@ export class EthereumMaplePoolTokenFetcher extends AppTokenTemplatePositionFetch return definitions.map(v => v.address); } - async getUnderlyingTokenAddresses({ contract }: GetUnderlyingTokensParams) { - return contract.asset(); + async getUnderlyingTokenDefinitions({ contract }: GetUnderlyingTokensParams) { + return [{ address: await contract.asset(), network: this.network }]; } async getApy({ definition }: GetDataPropsParams) { diff --git a/src/apps/meshswap/polygon/meshswap.supply.token-fetcher.ts b/src/apps/meshswap/polygon/meshswap.supply.token-fetcher.ts index 73f14ba72..80df8e35c 100644 --- a/src/apps/meshswap/polygon/meshswap.supply.token-fetcher.ts +++ b/src/apps/meshswap/polygon/meshswap.supply.token-fetcher.ts @@ -53,8 +53,8 @@ export class PolygonMeshswapSupplyTokenFetcher extends AppTokenTemplatePositionF return poolAddresses; } - async getUnderlyingTokenAddresses({ contract }: GetUnderlyingTokensParams) { - return contract.token(); + async getUnderlyingTokenDefinitions({ contract }: GetUnderlyingTokensParams) { + return [{ address: await contract.token(), network: this.network }]; } async getPricePerShare() { diff --git a/src/apps/mstable/ethereum/mstable.imusd.token-fetcher.ts b/src/apps/mstable/ethereum/mstable.imusd.token-fetcher.ts index faa2ff9bb..a1e835e0d 100644 --- a/src/apps/mstable/ethereum/mstable.imusd.token-fetcher.ts +++ b/src/apps/mstable/ethereum/mstable.imusd.token-fetcher.ts @@ -27,8 +27,8 @@ export class EthereumMstableImusdTokenFetcher extends AppTokenTemplatePositionFe return ['0x30647a72dc82d7fbb1123ea74716ab8a317eac19']; } - async getUnderlyingTokenAddresses({ contract }: GetUnderlyingTokensParams) { - return contract.asset(); + async getUnderlyingTokenDefinitions({ contract }: GetUnderlyingTokensParams) { + return [{ address: await contract.asset(), network: this.network }]; } async getPricePerShare({ appToken, contract }: GetPricePerShareParams) { diff --git a/src/apps/mstable/ethereum/mstable.meta-vault.token-fetcher.ts b/src/apps/mstable/ethereum/mstable.meta-vault.token-fetcher.ts index dbf99e793..e58f36a7b 100644 --- a/src/apps/mstable/ethereum/mstable.meta-vault.token-fetcher.ts +++ b/src/apps/mstable/ethereum/mstable.meta-vault.token-fetcher.ts @@ -29,8 +29,8 @@ export class EthereumMstableMetaVaultTokenFetcher extends AppTokenTemplatePositi ]; } - async getUnderlyingTokenAddresses({ contract }: GetUnderlyingTokensParams) { - return contract.asset(); + async getUnderlyingTokenDefinitions({ contract }: GetUnderlyingTokensParams) { + return [{ address: await contract.asset(), network: this.network }]; } async getPricePerShare({ contract, appToken }: GetPricePerShareParams) { diff --git a/src/apps/mstable/polygon/mstable.imusd.token-fetcher.ts b/src/apps/mstable/polygon/mstable.imusd.token-fetcher.ts index 49fd6dbb8..41bcefc35 100644 --- a/src/apps/mstable/polygon/mstable.imusd.token-fetcher.ts +++ b/src/apps/mstable/polygon/mstable.imusd.token-fetcher.ts @@ -27,8 +27,8 @@ export class PolygonMstableImusdTokenFetcher extends AppTokenTemplatePositionFet return ['0x5290ad3d83476ca6a2b178cd9727ee1ef72432af']; } - async getUnderlyingTokenAddresses({ contract }: GetUnderlyingTokensParams) { - return contract.asset(); + async getUnderlyingTokenDefinitions({ contract }: GetUnderlyingTokensParams) { + return [{ address: await contract.asset(), network: this.network }]; } async getPricePerShare({ appToken, contract }: GetPricePerShareParams) { diff --git a/src/apps/olympus/ethereum/olympus.g-ohm.token-fetcher.ts b/src/apps/olympus/ethereum/olympus.g-ohm.token-fetcher.ts index 34d9156c6..bbd8065a3 100644 --- a/src/apps/olympus/ethereum/olympus.g-ohm.token-fetcher.ts +++ b/src/apps/olympus/ethereum/olympus.g-ohm.token-fetcher.ts @@ -31,8 +31,8 @@ export class EthereumOlympusGOhmTokenFetcher extends AppTokenTemplatePositionFet return ['0x0ab87046fbb341d058f17cbc4c1133f25a20a52f']; } - async getUnderlyingTokenAddresses({ contract }: GetUnderlyingTokensParams) { - return [await contract.sOHM()]; + async getUnderlyingTokenDefinitions({ contract }: GetUnderlyingTokensParams) { + return [{ address: await contract.sOHM(), network: this.network }]; } async getPricePerShare({ contract, appToken }: GetPricePerShareParams) { diff --git a/src/apps/olympus/ethereum/olympus.s-ohm-v1.token-fetcher.ts b/src/apps/olympus/ethereum/olympus.s-ohm-v1.token-fetcher.ts index a96637adf..a5b4db818 100644 --- a/src/apps/olympus/ethereum/olympus.s-ohm-v1.token-fetcher.ts +++ b/src/apps/olympus/ethereum/olympus.s-ohm-v1.token-fetcher.ts @@ -26,8 +26,8 @@ export class EthereumOlympusSOhmV1TokenFetcher extends AppTokenTemplatePositionF return ['0x04f2694c8fcee23e8fd0dfea1d4f5bb8c352111f']; } - async getUnderlyingTokenAddresses() { - return ['0x383518188c0c6d7730d91b2c03a03c837814a899']; + async getUnderlyingTokenDefinitions() { + return [{ address: '0x383518188c0c6d7730d91b2c03a03c837814a899', network: this.network }]; } async getPricePerShare() { diff --git a/src/apps/olympus/ethereum/olympus.s-ohm.token-fetcher.ts b/src/apps/olympus/ethereum/olympus.s-ohm.token-fetcher.ts index fad07b1de..469760c73 100644 --- a/src/apps/olympus/ethereum/olympus.s-ohm.token-fetcher.ts +++ b/src/apps/olympus/ethereum/olympus.s-ohm.token-fetcher.ts @@ -26,8 +26,8 @@ export class EthereumOlympusSOhmTokenFetcher extends AppTokenTemplatePositionFet return ['0x04906695d6d12cf5459975d7c3c03356e4ccd460']; } - async getUnderlyingTokenAddresses() { - return ['0x64aa3364f17a4d01c6f1751fd97c2bd3d7e7f1d5']; + async getUnderlyingTokenDefinitions() { + return [{ address: '0x64aa3364f17a4d01c6f1751fd97c2bd3d7e7f1d5', network: this.network }]; } async getPricePerShare() { diff --git a/src/apps/olympus/ethereum/olympus.ws-ohm-v1.token-fetcher.ts b/src/apps/olympus/ethereum/olympus.ws-ohm-v1.token-fetcher.ts index 5dd54da4e..cdb511843 100644 --- a/src/apps/olympus/ethereum/olympus.ws-ohm-v1.token-fetcher.ts +++ b/src/apps/olympus/ethereum/olympus.ws-ohm-v1.token-fetcher.ts @@ -26,8 +26,8 @@ export class EthereumOlympusWsOhmV1TokenFetcher extends AppTokenTemplatePosition return ['0xca76543cf381ebbb277be79574059e32108e3e65']; } - async getUnderlyingTokenAddresses({ contract }: GetUnderlyingTokensParams) { - return [await contract.sOHM()]; + async getUnderlyingTokenDefinitions({ contract }: GetUnderlyingTokensParams) { + return [{ address: await contract.sOHM(), network: this.network }]; } async getPricePerShare({ appToken, multicall }: GetPricePerShareParams) { diff --git a/src/apps/ooki/arbitrum/ooki.lend.token-fetcher.ts b/src/apps/ooki/arbitrum/ooki.lend.token-fetcher.ts index 0b1a677f0..967215bed 100644 --- a/src/apps/ooki/arbitrum/ooki.lend.token-fetcher.ts +++ b/src/apps/ooki/arbitrum/ooki.lend.token-fetcher.ts @@ -38,8 +38,8 @@ export class ArbitrumOokiLendTokenFetcher extends AppTokenTemplatePositionFetche return tokenAddresses.map(v => v.token); } - getUnderlyingTokenAddresses({ contract }: GetUnderlyingTokensParams) { - return contract.loanTokenAddress(); + async getUnderlyingTokenDefinitions({ contract }: GetUnderlyingTokensParams) { + return [{ address: await contract.loanTokenAddress(), network: this.network }]; } async getPricePerShare({ contract }: GetPricePerShareParams) { diff --git a/src/apps/ooki/binance-smart-chain/ooki.lend.token-fetcher.ts b/src/apps/ooki/binance-smart-chain/ooki.lend.token-fetcher.ts index 1545ff509..699d784b0 100644 --- a/src/apps/ooki/binance-smart-chain/ooki.lend.token-fetcher.ts +++ b/src/apps/ooki/binance-smart-chain/ooki.lend.token-fetcher.ts @@ -38,8 +38,8 @@ export class BinanceSmartChainOokiLendTokenFetcher extends AppTokenTemplatePosit return tokenAddresses.map(v => v.token); } - getUnderlyingTokenAddresses({ contract }: GetUnderlyingTokensParams) { - return contract.loanTokenAddress(); + async getUnderlyingTokenDefinitions({ contract }: GetUnderlyingTokensParams) { + return [{ address: await contract.loanTokenAddress(), network: this.network }]; } async getPricePerShare({ contract }: GetPricePerShareParams) { diff --git a/src/apps/ooki/ethereum/ooki.lend.token-fetcher.ts b/src/apps/ooki/ethereum/ooki.lend.token-fetcher.ts index 119fc8404..41d545f07 100644 --- a/src/apps/ooki/ethereum/ooki.lend.token-fetcher.ts +++ b/src/apps/ooki/ethereum/ooki.lend.token-fetcher.ts @@ -38,8 +38,8 @@ export class EthereumOokiLendTokenFetcher extends AppTokenTemplatePositionFetche return tokenAddresses.map(v => v.token); } - getUnderlyingTokenAddresses({ contract }: GetUnderlyingTokensParams) { - return contract.loanTokenAddress(); + async getUnderlyingTokenDefinitions({ contract }: GetUnderlyingTokensParams) { + return [{ address: await contract.loanTokenAddress(), network: this.network }]; } async getPricePerShare({ contract }: GetPricePerShareParams) { diff --git a/src/apps/ooki/optimism/ooki.lend.token-fetcher.ts b/src/apps/ooki/optimism/ooki.lend.token-fetcher.ts index 24003acd0..3444b67af 100644 --- a/src/apps/ooki/optimism/ooki.lend.token-fetcher.ts +++ b/src/apps/ooki/optimism/ooki.lend.token-fetcher.ts @@ -38,8 +38,8 @@ export class OptimismOokiLendTokenFetcher extends AppTokenTemplatePositionFetche return tokenAddresses.map(v => v.token); } - getUnderlyingTokenAddresses({ contract }: GetUnderlyingTokensParams) { - return contract.loanTokenAddress(); + async getUnderlyingTokenDefinitions({ contract }: GetUnderlyingTokensParams) { + return [{ address: await contract.loanTokenAddress(), network: this.network }]; } async getPricePerShare({ contract }: GetPricePerShareParams) { diff --git a/src/apps/ooki/polygon/ooki.lend.token-fetcher.ts b/src/apps/ooki/polygon/ooki.lend.token-fetcher.ts index 580b238d3..538635b2c 100644 --- a/src/apps/ooki/polygon/ooki.lend.token-fetcher.ts +++ b/src/apps/ooki/polygon/ooki.lend.token-fetcher.ts @@ -38,8 +38,8 @@ export class PolygonOokiLendTokenFetcher extends AppTokenTemplatePositionFetcher return tokenAddresses.map(v => v.token); } - getUnderlyingTokenAddresses({ contract }: GetUnderlyingTokensParams) { - return contract.loanTokenAddress(); + async getUnderlyingTokenDefinitions({ contract }: GetUnderlyingTokensParams) { + return [{ address: await contract.loanTokenAddress(), network: this.network }]; } async getPricePerShare({ contract }: GetPricePerShareParams) { diff --git a/src/apps/openleverage/common/openleverage.pool.token-fetcher.ts b/src/apps/openleverage/common/openleverage.pool.token-fetcher.ts index bf9dcefeb..79cafc945 100644 --- a/src/apps/openleverage/common/openleverage.pool.token-fetcher.ts +++ b/src/apps/openleverage/common/openleverage.pool.token-fetcher.ts @@ -53,8 +53,8 @@ export abstract class OpenleveragePoolTokenFetcher extends AppTokenTemplatePosit return this.contractFactory.openleverageLpool({ address, network: this.network }); } - getUnderlyingTokenAddresses({ contract }: GetUnderlyingTokensParams) { - return contract.underlying(); + async getUnderlyingTokenDefinitions({ contract }: GetUnderlyingTokensParams) { + return [{ address: await contract.underlying(), network: this.network }]; } async getPricePerShare({ contract }: GetPricePerShareParams) { diff --git a/src/apps/origin-dollar/ethereum/origin-dollar.veogv.token-fetcher.ts b/src/apps/origin-dollar/ethereum/origin-dollar.veogv.token-fetcher.ts index 22e1ad3b0..2492b41c4 100644 --- a/src/apps/origin-dollar/ethereum/origin-dollar.veogv.token-fetcher.ts +++ b/src/apps/origin-dollar/ethereum/origin-dollar.veogv.token-fetcher.ts @@ -53,8 +53,8 @@ export class EthereumOriginDollarVeogvTokenFetcher extends AppTokenTemplatePosit return ['0x0c4576ca1c365868e162554af8e385dc3e7c66d9']; } - async getUnderlyingTokenAddresses({ contract }: GetUnderlyingTokensParams) { - return contract.ogv(); + async getUnderlyingTokenDefinitions({ contract }: GetUnderlyingTokensParams) { + return [{ address: await contract.ogv(), network: this.network }]; } async getPrice({ appToken, contract, multicall }: GetPriceParams): Promise { diff --git a/src/apps/origin-dollar/ethereum/origin-dollar.wousd.token-fetcher.ts b/src/apps/origin-dollar/ethereum/origin-dollar.wousd.token-fetcher.ts index 2c9d380f9..f5550071d 100644 --- a/src/apps/origin-dollar/ethereum/origin-dollar.wousd.token-fetcher.ts +++ b/src/apps/origin-dollar/ethereum/origin-dollar.wousd.token-fetcher.ts @@ -37,8 +37,8 @@ export class EthereumOriginDollarWousdTokenFetcher extends AppTokenTemplatePosit return ['0xd2af830e8cbdfed6cc11bab697bb25496ed6fa62']; } - async getUnderlyingTokenAddresses({ contract }: GetUnderlyingTokensParams) { - return contract.asset(); + async getUnderlyingTokenDefinitions({ contract }: GetUnderlyingTokensParams) { + return [{ address: await contract.asset(), network: this.network }]; } async getPrice({ appToken, contract, multicall }: GetPriceParams): Promise { diff --git a/src/apps/p-stake/binance-smart-chain/p-stake.stake.token-fetcher.ts b/src/apps/p-stake/binance-smart-chain/p-stake.stake.token-fetcher.ts index f1dd87f41..dea779b0b 100644 --- a/src/apps/p-stake/binance-smart-chain/p-stake.stake.token-fetcher.ts +++ b/src/apps/p-stake/binance-smart-chain/p-stake.stake.token-fetcher.ts @@ -28,8 +28,8 @@ export class BinanceSmartChainPStakeStakeTokenFetcher extends AppTokenTemplatePo return ['0xc2e9d07f66a89c44062459a47a0d2dc038e4fb16']; } - async getUnderlyingTokenAddresses() { - return [ZERO_ADDRESS]; + async getUnderlyingTokenDefinitions() { + return [{ address: ZERO_ADDRESS, network: this.network }]; } async getPricePerShare({ multicall }: GetPricePerShareParams) { diff --git a/src/apps/pendle-v2/ethereum/pendle-v2.pool.token-fetcher.ts b/src/apps/pendle-v2/ethereum/pendle-v2.pool.token-fetcher.ts index 94748096a..6acff5bd2 100644 --- a/src/apps/pendle-v2/ethereum/pendle-v2.pool.token-fetcher.ts +++ b/src/apps/pendle-v2/ethereum/pendle-v2.pool.token-fetcher.ts @@ -14,6 +14,8 @@ import { GetDisplayPropsParams, GetPriceParams, GetPricePerShareParams, + GetUnderlyingTokensParams, + UnderlyingTokenDefinition, } from '~position/template/app-token.template.types'; import { NETWORK_IDS } from '~types/network.interface'; @@ -100,20 +102,29 @@ export class EthereumPendleV2PoolTokenFetcher extends AppTokenTemplatePositionFe return definitions; } - async getAddresses({ definitions }: GetAddressesParams) { - return definitions.map(definition => definition.address); - } - getContract(address: string) { return this.pendleV2ContractFactory.pendleMarket({ address, network: this.network }); } + async getAddresses({ definitions }: GetAddressesParams) { + return definitions.map(definition => definition.address); + } + async getPrice({ definition, }: GetPriceParams): Promise { return definition.price; } + async getUnderlyingTokenDefinitions({ + definition, + }: GetUnderlyingTokensParams): Promise { + return [ + { address: definition.pt.address, network: this.network }, + { address: definition.sy.address, network: this.network }, + ]; + } + async getPricePerShare({ definition, }: GetPricePerShareParams): Promise< diff --git a/src/apps/pendle-v2/ethereum/pendle-v2.principal-token.token-fetcher.ts b/src/apps/pendle-v2/ethereum/pendle-v2.principal-token.token-fetcher.ts index e2e79d88c..5e5052bef 100644 --- a/src/apps/pendle-v2/ethereum/pendle-v2.principal-token.token-fetcher.ts +++ b/src/apps/pendle-v2/ethereum/pendle-v2.principal-token.token-fetcher.ts @@ -38,6 +38,7 @@ export class EthereumPendleV2PrincipalTokenTokenFetcher extends AppTokenTemplate PendleV2PrincipalTokenDefinition > { groupLabel = 'Principal Tokens'; + constructor( @Inject(APP_TOOLKIT) protected readonly appToolkit: IAppToolkit, @Inject(PendleV2ContractFactory) protected readonly pendleV2ContractFactory: PendleV2ContractFactory, @@ -74,6 +75,10 @@ export class EthereumPendleV2PrincipalTokenTokenFetcher extends AppTokenTemplate return definitions.map(definition => definition.address); } + async getUnderlyingTokenDefinitions() { + return []; + } + async getPrice({ definition, }: GetPriceParams< diff --git a/src/apps/pendle-v2/ethereum/pendle-v2.standardized-yield-token.token-fetcher.ts b/src/apps/pendle-v2/ethereum/pendle-v2.standardized-yield-token.token-fetcher.ts index b0b3a8c53..4fa25de81 100644 --- a/src/apps/pendle-v2/ethereum/pendle-v2.standardized-yield-token.token-fetcher.ts +++ b/src/apps/pendle-v2/ethereum/pendle-v2.standardized-yield-token.token-fetcher.ts @@ -70,6 +70,10 @@ export class EthereumPendleV2StandardizedYieldTokenTokenFetcher extends AppToken return definitions.map(definition => definition.address); } + async getUnderlyingTokenDefinitions() { + return []; + } + async getPrice({ definition, }: GetPriceParams< diff --git a/src/apps/pendle-v2/ethereum/pendle-v2.yield-token.token-fetcher.ts b/src/apps/pendle-v2/ethereum/pendle-v2.yield-token.token-fetcher.ts index 242e0180c..138b7861f 100644 --- a/src/apps/pendle-v2/ethereum/pendle-v2.yield-token.token-fetcher.ts +++ b/src/apps/pendle-v2/ethereum/pendle-v2.yield-token.token-fetcher.ts @@ -72,6 +72,10 @@ export class EthereumPendleV2YieldTokenTokenFetcher extends AppTokenTemplatePosi return definitions.map(definition => definition.address); } + async getUnderlyingTokenDefinitions() { + return []; + } + async getPrice({ definition, }: GetPriceParams): Promise { diff --git a/src/apps/pendle/ethereum/pendle.ownership.token-fetcher.ts b/src/apps/pendle/ethereum/pendle.ownership.token-fetcher.ts index cdc6b3978..ba388e456 100644 --- a/src/apps/pendle/ethereum/pendle.ownership.token-fetcher.ts +++ b/src/apps/pendle/ethereum/pendle.ownership.token-fetcher.ts @@ -111,8 +111,8 @@ export class EthereumPendleOwnershipTokenFetcher extends AppTokenTemplatePositio return this.contractFactory.pendleOwnershipToken({ address, network: this.network }); } - getUnderlyingTokenAddresses({ contract }: GetUnderlyingTokensParams) { - return contract.underlyingYieldToken(); + async getUnderlyingTokenDefinitions({ contract }: GetUnderlyingTokensParams) { + return [{ address: await contract.underlyingYieldToken(), network: this.network }]; } async getPricePerShare({ diff --git a/src/apps/pendle/ethereum/pendle.yield.token-fetcher.ts b/src/apps/pendle/ethereum/pendle.yield.token-fetcher.ts index 2fd450a22..1e35dd1db 100644 --- a/src/apps/pendle/ethereum/pendle.yield.token-fetcher.ts +++ b/src/apps/pendle/ethereum/pendle.yield.token-fetcher.ts @@ -107,8 +107,8 @@ export class EthereumPendleYieldTokenFetcher extends AppTokenTemplatePositionFet return this.contractFactory.pendleYieldToken({ address, network: this.network }); } - getUnderlyingTokenAddresses({ contract }: GetUnderlyingTokensParams) { - return contract.underlyingAsset(); + async getUnderlyingTokenDefinitions({ contract }: GetUnderlyingTokensParams) { + return [{ address: await contract.underlyingAsset(), network: this.network }]; } async getPricePerShare({ diff --git a/src/apps/pickle/common/pickle.jar-univ3.token-fetcher.ts b/src/apps/pickle/common/pickle.jar-univ3.token-fetcher.ts index 878cab065..e8c164e43 100644 --- a/src/apps/pickle/common/pickle.jar-univ3.token-fetcher.ts +++ b/src/apps/pickle/common/pickle.jar-univ3.token-fetcher.ts @@ -51,20 +51,20 @@ export abstract class PickleJarUniv3TokenFetcher extends AppTokenTemplatePositio const contract = multicall.wrap(this.getContract(address)); const context = { address, definition, contract, multicall, tokenLoader }; - const underlyingTokenAddress = await this.getUnderlyingTokenAddresses(context) - .then(v => v.toLowerCase()) + const underlyingTokenDefinitions = await this.getUnderlyingTokenDefinitions(context) + .then(v => v.map(t => ({ address: t.address.toLowerCase(), network: t.network }))) .catch(err => { if (isMulticallUnderlyingError(err)) return null; throw err; }); - if (!underlyingTokenAddress) return null; + if (!underlyingTokenDefinitions) return null; const controllerAddr = await contract.controller(); const controller = multicall.wrap( this.contractFactory.pickleController({ address: controllerAddr, network: this.network }), ); - const strategyAddr = await controller.strategies(underlyingTokenAddress); + const strategyAddr = await controller.strategies(underlyingTokenDefinitions[0].address); const strategy = multicall.wrap( this.contractFactory.pickleStrategyUniv3({ address: strategyAddr, network: this.network }), ); @@ -78,7 +78,7 @@ export abstract class PickleJarUniv3TokenFetcher extends AppTokenTemplatePositio }); if (!tokenId) return null; - return { address, definition, underlyingTokenAddress, tokenId }; + return { address, definition, underlyingTokenDefinitions, tokenId }; }), ); @@ -157,9 +157,8 @@ export abstract class PickleJarUniv3TokenFetcher extends AppTokenTemplatePositio return vaults.map(v => v.vaultAddress); } - async getUnderlyingTokenAddresses({ contract }: GetUnderlyingTokensParams): Promise { - const pool = await contract.pool(); - return pool; + async getUnderlyingTokenDefinitions({ contract }: GetUnderlyingTokensParams) { + return [{ address: await contract.pool(), network: this.network }]; } async getPricePerShare({ contract }: GetPricePerShareParams): Promise { diff --git a/src/apps/pickle/common/pickle.jar.token-fetcher.ts b/src/apps/pickle/common/pickle.jar.token-fetcher.ts index d0c2138b5..0eda95878 100644 --- a/src/apps/pickle/common/pickle.jar.token-fetcher.ts +++ b/src/apps/pickle/common/pickle.jar.token-fetcher.ts @@ -33,13 +33,12 @@ export abstract class PickleJarTokenFetcher extends AppTokenTemplatePositionFetc return vaults.map(v => v.vaultAddress); } - async getUnderlyingTokenAddresses({ contract }: GetUnderlyingTokensParams) { + async getUnderlyingTokenDefinitions({ contract }: GetUnderlyingTokensParams) { // If jar doesn't have the pool property, it's a "legacy" deposit token (e.g. UniV2 LP) try { - const pool = await contract.pool(); - return pool; + return [{ address: await contract.pool(), network: this.network }]; } catch { - return contract.token(); + return [{ address: await contract.token(), network: this.network }]; } } diff --git a/src/apps/pie-dao/ethereum/pie-dao.e-dough.token-fetcher.ts b/src/apps/pie-dao/ethereum/pie-dao.e-dough.token-fetcher.ts index 0215e2cd9..a297a5892 100644 --- a/src/apps/pie-dao/ethereum/pie-dao.e-dough.token-fetcher.ts +++ b/src/apps/pie-dao/ethereum/pie-dao.e-dough.token-fetcher.ts @@ -26,8 +26,8 @@ export class EthereumPieDaoEDoughTokenFetcher extends AppTokenTemplatePositionFe return ['0x63cbd1858bd79de1a06c3c26462db360b834912d']; } - async getUnderlyingTokenAddresses() { - return ['0xad32a8e6220741182940c5abf610bde99e737b2d']; // DOUGH + async getUnderlyingTokenDefinitions() { + return [{ address: '0xad32a8e6220741182940c5abf610bde99e737b2d', network: this.network }]; // DOUGH } async getPricePerShare() { diff --git a/src/apps/platypus-finance/common/platypus-finance.pool.token-fetcher.ts b/src/apps/platypus-finance/common/platypus-finance.pool.token-fetcher.ts index c6c3a60af..ae51303b5 100644 --- a/src/apps/platypus-finance/common/platypus-finance.pool.token-fetcher.ts +++ b/src/apps/platypus-finance/common/platypus-finance.pool.token-fetcher.ts @@ -42,8 +42,8 @@ export abstract class PlatypusFinancePoolTokenFetcher extends AppTokenTemplatePo return tokenAddressesByPool.flat(); } - async getUnderlyingTokenAddresses({ contract }: GetUnderlyingTokensParams) { - return contract.underlyingToken(); + async getUnderlyingTokenDefinitions({ contract }: GetUnderlyingTokensParams) { + return [{ address: await contract.underlyingToken(), network: this.network }]; } async getPricePerShare({ contract, multicall, appToken }: GetPricePerShareParams) { diff --git a/src/apps/plutus/arbitrum/plutus.plv-glp.token-fetcher.ts b/src/apps/plutus/arbitrum/plutus.plv-glp.token-fetcher.ts index e8834a942..5d6bb28b3 100644 --- a/src/apps/plutus/arbitrum/plutus.plv-glp.token-fetcher.ts +++ b/src/apps/plutus/arbitrum/plutus.plv-glp.token-fetcher.ts @@ -32,8 +32,8 @@ export class ArbitrumPlutusPlvGlpTokenFetcher extends AppTokenTemplatePositionFe return ['0x5326e71ff593ecc2cf7acae5fe57582d6e74cff1']; } - async getUnderlyingTokenAddresses({ contract }: GetUnderlyingTokensParams) { - return contract.asset(); + async getUnderlyingTokenDefinitions({ contract }: GetUnderlyingTokensParams) { + return [{ address: await contract.asset(), network: this.network }]; } async getPricePerShare({ contract }: GetPricePerShareParams) { diff --git a/src/apps/pods-yield/ethereum/pods-yield.strategy.token-fetcher.ts b/src/apps/pods-yield/ethereum/pods-yield.strategy.token-fetcher.ts index a3cb0bd07..880e6a7de 100644 --- a/src/apps/pods-yield/ethereum/pods-yield.strategy.token-fetcher.ts +++ b/src/apps/pods-yield/ethereum/pods-yield.strategy.token-fetcher.ts @@ -33,8 +33,8 @@ export class EthereumPodsYieldStrategyTokenFetcher extends AppTokenTemplatePosit return strategyAddresses; } - async getUnderlyingTokenAddresses({ contract }: GetUnderlyingTokensParams) { - return contract.asset(); + async getUnderlyingTokenDefinitions({ contract }: GetUnderlyingTokensParams) { + return [{ address: await contract.asset(), network: this.network }]; } async getPricePerShare({ contract, appToken }: GetPricePerShareParams) { diff --git a/src/apps/pool-together-v3/common/pool-together-v3.community-ticket.token-fetcher.ts b/src/apps/pool-together-v3/common/pool-together-v3.community-ticket.token-fetcher.ts index 87e83268b..03e727a21 100644 --- a/src/apps/pool-together-v3/common/pool-together-v3.community-ticket.token-fetcher.ts +++ b/src/apps/pool-together-v3/common/pool-together-v3.community-ticket.token-fetcher.ts @@ -123,17 +123,16 @@ export abstract class PoolTogetherV3CommunityTicketTokenFetcher extends AppToken return appToken.symbol; } - async getUnderlyingTokenAddresses({ + async getUnderlyingTokenDefinitions({ definition, multicall, - }: GetUnderlyingTokensParams): Promise< - string | string[] - > { - const contract = multicall.wrap( - this.contractFactory.poolTogetherV3CommunityPrizePool({ network: this.network, address: definition.prizePool }), - ); - const underlyingTokenAddress = await contract.token().then(addr => addr.toLowerCase()); - return [underlyingTokenAddress]; + }: GetUnderlyingTokensParams) { + const prizePool = this.contractFactory.poolTogetherV3CommunityPrizePool({ + network: this.network, + address: definition.prizePool, + }); + + return [{ address: await multicall.wrap(prizePool).token(), network: this.network }]; } async getLiquidity({ appToken }: GetDataPropsParams) { diff --git a/src/apps/pool-together-v3/common/pool-together-v3.pod.token-fetcher.ts b/src/apps/pool-together-v3/common/pool-together-v3.pod.token-fetcher.ts index a09ed8356..3bb5497bd 100644 --- a/src/apps/pool-together-v3/common/pool-together-v3.pod.token-fetcher.ts +++ b/src/apps/pool-together-v3/common/pool-together-v3.pod.token-fetcher.ts @@ -51,11 +51,8 @@ export abstract class PoolTogetherV3PodTokenFetcher extends AppTokenTemplatePosi return Number(pricePerShareRaw) / 10 ** appToken.decimals; } - async getUnderlyingTokenAddresses({ - contract, - }: GetUnderlyingTokensParams): Promise { - const underlyingTokenAddress = await contract.token().then(addr => addr.toLowerCase()); - return [underlyingTokenAddress]; + async getUnderlyingTokenDefinitions({ contract }: GetUnderlyingTokensParams) { + return [{ address: await contract.token(), network: this.network }]; } async getLiquidity({ appToken }: GetDataPropsParams) { diff --git a/src/apps/pool-together-v3/common/pool-together-v3.prize-pool.token-fetcher.ts b/src/apps/pool-together-v3/common/pool-together-v3.prize-pool.token-fetcher.ts index c83da074e..8c5d1fb1a 100644 --- a/src/apps/pool-together-v3/common/pool-together-v3.prize-pool.token-fetcher.ts +++ b/src/apps/pool-together-v3/common/pool-together-v3.prize-pool.token-fetcher.ts @@ -46,10 +46,8 @@ export abstract class PoolTogetherV3PrizePoolTokenFetcher ex abstract getDefinitions(): Promise; - async getUnderlyingTokenAddresses({ - definition, - }: GetUnderlyingTokensParams): Promise { - return [definition.underlyingTokenAddress]; + async getUnderlyingTokenDefinitions({ definition }: GetUnderlyingTokensParams) { + return [{ address: definition.underlyingTokenAddress, network: this.network }]; } async getLiquidity({ appToken }: GetDataPropsParams) { diff --git a/src/apps/pool-together-v4/common/pool-together-v4.ticket.token-fetcher.ts b/src/apps/pool-together-v4/common/pool-together-v4.ticket.token-fetcher.ts index 7138303f7..43ec26899 100644 --- a/src/apps/pool-together-v4/common/pool-together-v4.ticket.token-fetcher.ts +++ b/src/apps/pool-together-v4/common/pool-together-v4.ticket.token-fetcher.ts @@ -80,10 +80,10 @@ export abstract class PoolTogetherV4TicketTokenFetcher extends AppTokenTemplateP return definitions; } - async getUnderlyingTokenAddresses({ + async getUnderlyingTokenDefinitions({ definition, - }: GetUnderlyingTokensParams): Promise { - return [definition.underlyingTokenAddress]; + }: GetUnderlyingTokensParams) { + return [{ address: definition.underlyingTokenAddress, network: this.network }]; } async getLiquidity({ appToken }: GetDataPropsParams) { diff --git a/src/apps/qi-dao/polygon/qi-dao.yield.token-fetcher.ts b/src/apps/qi-dao/polygon/qi-dao.yield.token-fetcher.ts index 5dc365ebe..2fa8d5db7 100644 --- a/src/apps/qi-dao/polygon/qi-dao.yield.token-fetcher.ts +++ b/src/apps/qi-dao/polygon/qi-dao.yield.token-fetcher.ts @@ -38,8 +38,8 @@ export class PolygonQiDaoYieldTokenFetcher extends AppTokenTemplatePositionFetch ]; } - async getUnderlyingTokenAddresses({ contract }: GetUnderlyingTokensParams) { - return contract.Token(); + async getUnderlyingTokenDefinitions({ contract }: GetUnderlyingTokensParams) { + return [{ address: await contract.Token(), network: this.network }]; } async getPricePerShare({ appToken }: GetPricePerShareParams) { diff --git a/src/apps/rari-fuse/common/rari-fuse.supply.token-fetcher.ts b/src/apps/rari-fuse/common/rari-fuse.supply.token-fetcher.ts index a55a71c90..ee1780ac8 100644 --- a/src/apps/rari-fuse/common/rari-fuse.supply.token-fetcher.ts +++ b/src/apps/rari-fuse/common/rari-fuse.supply.token-fetcher.ts @@ -85,8 +85,8 @@ export abstract class RariFuseSupplyTokenFetcher< return definitions.map(v => v.address); } - async getUnderlyingTokenAddresses({ contract }: GetUnderlyingTokensParams) { - return this.getUnderlyingTokenAddress(contract); + async getUnderlyingTokenDefinitions({ contract }: GetUnderlyingTokensParams) { + return [{ address: await this.getUnderlyingTokenAddress(contract), network: this.network }]; } async getPricePerShare({ diff --git a/src/apps/rari/ethereum/rari.fund.token-fetcher.ts b/src/apps/rari/ethereum/rari.fund.token-fetcher.ts index 24894ebe6..d50ab3368 100644 --- a/src/apps/rari/ethereum/rari.fund.token-fetcher.ts +++ b/src/apps/rari/ethereum/rari.fund.token-fetcher.ts @@ -65,9 +65,9 @@ export class EthereumRariFundTokenFetcher extends AppTokenTemplatePositionFetche return RARI_POOL_DEFINITIONS.map(v => v.poolTokenAddress); } - async getUnderlyingTokenAddresses({ multicall, address }: GetUnderlyingTokensParams) { + async getUnderlyingTokenDefinitions({ multicall, address }: GetUnderlyingTokensParams) { const { poolManagerAddress, isEther } = RARI_POOL_DEFINITIONS.find(v => v.poolTokenAddress === address)!; - if (isEther) return [ZERO_ADDRESS]; + if (isEther) return [{ address: ZERO_ADDRESS, network: this.network }]; const managerContract = this.contractFactory.rariFundManager({ address: poolManagerAddress, @@ -75,7 +75,7 @@ export class EthereumRariFundTokenFetcher extends AppTokenTemplatePositionFetche }); const symbols = await multicall.wrap(managerContract).callStatic.getAcceptedCurrencies(); - return symbols.map(v => SYMBOL_TO_ADDRESS[v]!); + return symbols.map(v => ({ address: SYMBOL_TO_ADDRESS[v]!, network: this.network })); } async getPricePerShare({ appToken }: GetPricePerShareParams) { diff --git a/src/apps/reaper/common/reaper.vault.token-fetcher.ts b/src/apps/reaper/common/reaper.vault.token-fetcher.ts index 22a249b67..a21bf92cf 100644 --- a/src/apps/reaper/common/reaper.vault.token-fetcher.ts +++ b/src/apps/reaper/common/reaper.vault.token-fetcher.ts @@ -48,8 +48,8 @@ export abstract class ReaperVaultTokenFetcher extends AppTokenTemplatePositionFe return definitions.map(v => v.address); } - async getUnderlyingTokenAddresses({ definition }: GetUnderlyingTokensParams) { - return [definition.underlyingAddress]; + async getUnderlyingTokenDefinitions({ definition }: GetUnderlyingTokensParams) { + return [{ address: definition.underlyingAddress, network: this.network }]; } async getPricePerShare({ diff --git a/src/apps/robo-vault/common/robo-vault.vault.token-fetcher.ts b/src/apps/robo-vault/common/robo-vault.vault.token-fetcher.ts index 407e7ccc8..a5d4d70ad 100644 --- a/src/apps/robo-vault/common/robo-vault.vault.token-fetcher.ts +++ b/src/apps/robo-vault/common/robo-vault.vault.token-fetcher.ts @@ -30,8 +30,8 @@ export abstract class RoboVaultVaultTokenFetcher extends AppTokenTemplatePositio return data.map(v => v.addr.toLowerCase()); } - async getUnderlyingTokenAddresses({ contract }: GetUnderlyingTokensParams) { - return contract.token(); + async getUnderlyingTokenDefinitions({ contract }: GetUnderlyingTokensParams) { + return [{ address: await contract.token(), network: this.network }]; } async getPricePerShare({ contract, appToken }: GetPricePerShareParams) { diff --git a/src/apps/rook/common/rook.pool.token-fetcher.ts b/src/apps/rook/common/rook.pool.token-fetcher.ts index 399e2ef87..40378483e 100644 --- a/src/apps/rook/common/rook.pool.token-fetcher.ts +++ b/src/apps/rook/common/rook.pool.token-fetcher.ts @@ -33,9 +33,10 @@ export abstract class RookPoolTokenFetcher extends AppTokenTemplatePositionFetch return this.kTokenAddresses; } - async getUnderlyingTokenAddresses({ contract }: GetUnderlyingTokensParams) { - const underlying = await contract.underlying(); - return underlying.toLowerCase().replace(ETH_ADDR_ALIAS, ZERO_ADDRESS); + async getUnderlyingTokenDefinitions({ contract }: GetUnderlyingTokensParams) { + const underlyingRaw = await contract.underlying(); + const underlying = underlyingRaw.toLowerCase().replace(ETH_ADDR_ALIAS, ZERO_ADDRESS); + return [{ address: underlying, network: this.network }]; } async getPricePerShare({ appToken, multicall }: GetPricePerShareParams) { diff --git a/src/apps/rubicon/common/rubicon.bath.token-fetcher.ts b/src/apps/rubicon/common/rubicon.bath.token-fetcher.ts index c58a6f1f2..eb31c2cc2 100644 --- a/src/apps/rubicon/common/rubicon.bath.token-fetcher.ts +++ b/src/apps/rubicon/common/rubicon.bath.token-fetcher.ts @@ -49,8 +49,8 @@ export abstract class RubiconBathTokenFetcher extends AppTokenTemplatePositionFe return definitions.map(v => v.address); } - async getUnderlyingTokenAddresses({ definition }: GetUnderlyingTokensParams) { - return definition.underlyingTokenAddress; + async getUnderlyingTokenDefinitions({ definition }: GetUnderlyingTokensParams) { + return [{ address: definition.underlyingTokenAddress, network: this.network }]; } async getSupply({ diff --git a/src/apps/sideshift/ethereum/sideshift.svxai.token-fetcher.ts b/src/apps/sideshift/ethereum/sideshift.svxai.token-fetcher.ts index 9dfd1f43d..45ff037b4 100644 --- a/src/apps/sideshift/ethereum/sideshift.svxai.token-fetcher.ts +++ b/src/apps/sideshift/ethereum/sideshift.svxai.token-fetcher.ts @@ -31,8 +31,8 @@ export class EthereumSideshiftSvxaiTokenFetcher extends AppTokenTemplatePosition return ['0x3808708e761b988d23ae011ed0e12674fb66bd62']; } - async getUnderlyingTokenAddresses({ contract }: GetUnderlyingTokensParams) { - return contract.asset(); + async getUnderlyingTokenDefinitions({ contract }: GetUnderlyingTokensParams) { + return [{ address: await contract.asset(), network: this.network }]; } async getPricePerShare({ contract, appToken }: GetPricePerShareParams) { diff --git a/src/apps/stake-dao/ethereum/stake-dao.locker.token-fetcher.ts b/src/apps/stake-dao/ethereum/stake-dao.locker.token-fetcher.ts index 3bccc3ca3..278d8de9a 100644 --- a/src/apps/stake-dao/ethereum/stake-dao.locker.token-fetcher.ts +++ b/src/apps/stake-dao/ethereum/stake-dao.locker.token-fetcher.ts @@ -58,8 +58,8 @@ export class EthereumStakeDaoLockerTokenFetcher extends AppTokenTemplatePosition return LOCKERS.map(v => v.tokenAddress); } - async getUnderlyingTokenAddresses({ address }: GetUnderlyingTokensParams): Promise { - return LOCKERS.find(v => v.tokenAddress == address)!.underlyingTokenAddress; + async getUnderlyingTokenDefinitions({ address }: GetUnderlyingTokensParams) { + return [{ address: LOCKERS.find(v => v.tokenAddress == address)!.underlyingTokenAddress, network: this.network }]; } async getPricePerShare({ appToken, multicall }: GetPricePerShareParams) { diff --git a/src/apps/stargate/common/stargate.eth.token-fetcher.ts b/src/apps/stargate/common/stargate.eth.token-fetcher.ts index d8e7fead6..d9ae29a62 100644 --- a/src/apps/stargate/common/stargate.eth.token-fetcher.ts +++ b/src/apps/stargate/common/stargate.eth.token-fetcher.ts @@ -25,8 +25,8 @@ export abstract class StargateEthTokenFetcher extends AppTokenTemplatePositionFe return [this.stargateEthAddress]; } - async getUnderlyingTokenAddresses() { - return [ZERO_ADDRESS]; + async getUnderlyingTokenDefinitions() { + return [{ address: ZERO_ADDRESS, network: this.network }]; } async getLiquidity({ appToken }: GetDataPropsParams) { diff --git a/src/apps/stargate/common/stargate.pool.token-fetcher.ts b/src/apps/stargate/common/stargate.pool.token-fetcher.ts index 706aa1770..aad929031 100644 --- a/src/apps/stargate/common/stargate.pool.token-fetcher.ts +++ b/src/apps/stargate/common/stargate.pool.token-fetcher.ts @@ -39,8 +39,8 @@ export abstract class StargatePoolTokenFetcher extends AppTokenTemplatePositionF return Promise.all(range(0, Number(numPools)).map(pid => multicall.wrap(factory).allPools(pid))); } - async getUnderlyingTokenAddresses({ contract }: GetUnderlyingTokensParams) { - return contract.token(); + async getUnderlyingTokenDefinitions({ contract }: GetUnderlyingTokensParams) { + return [{ address: await contract.token(), network: this.network }]; } async getPricePerShare({ appToken, contract }: GetPricePerShareParams) { diff --git a/src/apps/stargate/ethereum/stargate.auction-locked.token-fetcher.ts b/src/apps/stargate/ethereum/stargate.auction-locked.token-fetcher.ts index 485d1cf24..78d3cc5f6 100644 --- a/src/apps/stargate/ethereum/stargate.auction-locked.token-fetcher.ts +++ b/src/apps/stargate/ethereum/stargate.auction-locked.token-fetcher.ts @@ -26,8 +26,8 @@ export class EthereumStargateAuctionLockedTokenFetcher extends AppTokenTemplateP return ['0x4dfcad285ef39fed84e77edf1b7dbc442565e55e']; } - getUnderlyingTokenAddresses({ contract }: GetUnderlyingTokensParams) { - return contract.stargateToken(); + async getUnderlyingTokenDefinitions({ contract }: GetUnderlyingTokensParams) { + return [{ address: await contract.stargateToken(), network: this.network }]; } async getPricePerShare(): Promise { diff --git a/src/apps/superfluid/polygon/superfluid.vault.token-fetcher.ts b/src/apps/superfluid/polygon/superfluid.vault.token-fetcher.ts index 408e7ad32..7e920d784 100644 --- a/src/apps/superfluid/polygon/superfluid.vault.token-fetcher.ts +++ b/src/apps/superfluid/polygon/superfluid.vault.token-fetcher.ts @@ -58,8 +58,8 @@ export class PolygonSuperfluidVaultTokenFetcher extends AppTokenTemplatePosition return tokenData.tokens?.filter(x => !this.brokenAddresses.includes(x.id)).map(v => v.id) ?? []; } - async getUnderlyingTokenAddresses({ contract }: GetUnderlyingTokensParams) { - return await contract.getUnderlyingToken(); + async getUnderlyingTokenDefinitions({ contract }: GetUnderlyingTokensParams) { + return [{ address: await contract.getUnderlyingToken(), network: this.network }]; } async getLiquidity({ appToken }: GetDataPropsParams) { diff --git a/src/apps/sushiswap-kashi/common/sushiswap-kashi.lending.token-fetcher.ts b/src/apps/sushiswap-kashi/common/sushiswap-kashi.lending.token-fetcher.ts index 7524a4f38..120741ef6 100644 --- a/src/apps/sushiswap-kashi/common/sushiswap-kashi.lending.token-fetcher.ts +++ b/src/apps/sushiswap-kashi/common/sushiswap-kashi.lending.token-fetcher.ts @@ -100,10 +100,13 @@ export abstract class SushiswapKashiLendingTokenFetcher extends AppTokenTemplate return definitions.map(v => v.address); } - async getUnderlyingTokenAddresses({ + async getUnderlyingTokenDefinitions({ definition, }: GetUnderlyingTokensParams) { - return [definition.assetAddress, definition.collateralAddress]; + return [ + { address: definition.assetAddress, network: this.network }, + { address: definition.collateralAddress, network: this.network }, + ]; } async getPricePerShare() { diff --git a/src/apps/synthetix/common/synthetix.snx.token-fetcher.ts b/src/apps/synthetix/common/synthetix.snx.token-fetcher.ts index 655761e8d..ee1d59c96 100644 --- a/src/apps/synthetix/common/synthetix.snx.token-fetcher.ts +++ b/src/apps/synthetix/common/synthetix.snx.token-fetcher.ts @@ -30,7 +30,7 @@ export abstract class SynthetixSnxTokenFetcher extends AppTokenTemplatePositionF return [this.snxAddress]; } - async getUnderlyingTokenAddresses() { + async getUnderlyingTokenDefinitions() { return []; } diff --git a/src/apps/synthetix/common/synthetix.synth.token-fetcher.ts b/src/apps/synthetix/common/synthetix.synth.token-fetcher.ts index 11e1a9bdb..2064914f2 100644 --- a/src/apps/synthetix/common/synthetix.synth.token-fetcher.ts +++ b/src/apps/synthetix/common/synthetix.synth.token-fetcher.ts @@ -73,7 +73,7 @@ export abstract class SynthetixSynthTokenFetcher extends AppTokenTemplatePositio return addresses; } - async getUnderlyingTokenAddresses() { + async getUnderlyingTokenDefinitions() { return []; } diff --git a/src/apps/tarot/fantom/tarot.supply.token-fetcher.ts b/src/apps/tarot/fantom/tarot.supply.token-fetcher.ts index a1b5df466..022c80def 100644 --- a/src/apps/tarot/fantom/tarot.supply.token-fetcher.ts +++ b/src/apps/tarot/fantom/tarot.supply.token-fetcher.ts @@ -127,8 +127,8 @@ export class FantomTarotSupplyTokenFetcher extends AppTokenTemplatePositionFetch return definitions.map(({ address }) => address); } - async getUnderlyingTokenAddresses({ contract }: GetUnderlyingTokensParams) { - return contract.underlying(); + async getUnderlyingTokenDefinitions({ contract }: GetUnderlyingTokensParams) { + return [{ address: await contract.underlying(), network: this.network }]; } async getPricePerShare({ contract, appToken }: GetPricePerShareParams) { diff --git a/src/apps/tarot/fantom/tarot.vault.token-fetcher.ts b/src/apps/tarot/fantom/tarot.vault.token-fetcher.ts index e06205646..98050cbd8 100644 --- a/src/apps/tarot/fantom/tarot.vault.token-fetcher.ts +++ b/src/apps/tarot/fantom/tarot.vault.token-fetcher.ts @@ -35,8 +35,8 @@ export class FantomTarotVaultTokenFetcher extends AppTokenTemplatePositionFetche ]; } - async getUnderlyingTokenAddresses({ contract }: GetUnderlyingTokensParams) { - return contract.underlying(); + async getUnderlyingTokenDefinitions({ contract }: GetUnderlyingTokensParams) { + return [{ address: await contract.underlying(), network: this.network }]; } async getPricePerShare({ contract, appToken }: GetPricePerShareParams) { diff --git a/src/apps/tempus/common/tempus.amm.token-fetcher.ts b/src/apps/tempus/common/tempus.amm.token-fetcher.ts index d3cfc7bf9..e64b9693f 100644 --- a/src/apps/tempus/common/tempus.amm.token-fetcher.ts +++ b/src/apps/tempus/common/tempus.amm.token-fetcher.ts @@ -31,13 +31,17 @@ export abstract class TempusAmmTokenFetcher extends AppTokenTemplatePositionFetc return data.tempusPools.map(v => v.ammAddress.toLowerCase()); } - async getUnderlyingTokenAddresses({ + async getUnderlyingTokenDefinitions({ contract, multicall, }: GetUnderlyingTokensParams) { const poolAddress = await contract.tempusPool(); const pool = multicall.wrap(this.contractFactory.tempusPool({ address: poolAddress, network: this.network })); - return [await pool.principalShare(), await pool.yieldShare()]; + + return [ + { address: await pool.principalShare(), network: this.network }, + { address: await pool.yieldShare(), network: this.network }, + ]; } async getPricePerShare({ contract, appToken }: GetPricePerShareParams) { diff --git a/src/apps/tempus/common/tempus.pool.token-fetcher.ts b/src/apps/tempus/common/tempus.pool.token-fetcher.ts index b4e91913b..25fb0a049 100644 --- a/src/apps/tempus/common/tempus.pool.token-fetcher.ts +++ b/src/apps/tempus/common/tempus.pool.token-fetcher.ts @@ -32,10 +32,10 @@ export abstract class TempusPoolTokenFetcher extends AppTokenTemplatePositionFet return data.tempusPools.flatMap(v => [v.principalsAddress, v.yieldsAddress]); } - async getUnderlyingTokenAddresses({ contract, multicall }: GetUnderlyingTokensParams) { + async getUnderlyingTokenDefinitions({ contract, multicall }: GetUnderlyingTokensParams) { const poolAddress = await contract.pool(); const pool = multicall.wrap(this.contractFactory.tempusPool({ address: poolAddress, network: this.network })); - return [await pool.backingToken()]; + return [{ address: await pool.backingToken(), network: this.network }]; } async getPricePerShare({ contract, appToken }: GetPricePerShareParams) { diff --git a/src/apps/tenderize/common/tenderize.swap.token-fetcher.ts b/src/apps/tenderize/common/tenderize.swap.token-fetcher.ts index bafe87eac..2a0cfdf16 100644 --- a/src/apps/tenderize/common/tenderize.swap.token-fetcher.ts +++ b/src/apps/tenderize/common/tenderize.swap.token-fetcher.ts @@ -42,8 +42,13 @@ export abstract class SwapTokenFetcher extends AppTokenTemplatePositionFetcher< return definitions.map(v => v.lpToken); } - async getUnderlyingTokenAddresses({ definition }: GetUnderlyingTokensParams) { - return [definition.steak, definition.address]; + async getUnderlyingTokenDefinitions({ + definition, + }: GetUnderlyingTokensParams) { + return [ + { address: definition.steak, network: this.network }, + { address: definition.address, network: this.network }, + ]; } async getPricePerShare() { diff --git a/src/apps/tenderize/common/tenderize.tender.token-fetcher.ts b/src/apps/tenderize/common/tenderize.tender.token-fetcher.ts index 38d7a262b..e73d9e85b 100644 --- a/src/apps/tenderize/common/tenderize.tender.token-fetcher.ts +++ b/src/apps/tenderize/common/tenderize.tender.token-fetcher.ts @@ -42,8 +42,10 @@ export abstract class TenderTokenFetcher extends AppTokenTemplatePositionFetcher return definitions.map(v => v.address); } - async getUnderlyingTokenAddresses({ definition }: GetUnderlyingTokensParams) { - return definition.steak; + async getUnderlyingTokenDefinitions({ + definition, + }: GetUnderlyingTokensParams) { + return [{ address: definition.steak, network: this.network }]; } async getPricePerShare({ diff --git a/src/apps/tokemak/ethereum/tokemak.reactor.token-fetcher.ts b/src/apps/tokemak/ethereum/tokemak.reactor.token-fetcher.ts index f8aedd612..737aba15a 100644 --- a/src/apps/tokemak/ethereum/tokemak.reactor.token-fetcher.ts +++ b/src/apps/tokemak/ethereum/tokemak.reactor.token-fetcher.ts @@ -50,7 +50,7 @@ export class EthereumTokemakReactorTokenFetcher extends AppTokenTemplatePosition ]; } - async getUnderlyingTokenAddresses({ contract }: GetUnderlyingTokensParams) { - return contract.underlyer(); + async getUnderlyingTokenDefinitions({ contract }: GetUnderlyingTokensParams) { + return [{ address: await contract.underlyer(), network: this.network }]; } } diff --git a/src/apps/umami-finance/arbitrum/umami-finance.compound.token-fetcher.ts b/src/apps/umami-finance/arbitrum/umami-finance.compound.token-fetcher.ts index 96fca38d1..0fb728ba7 100644 --- a/src/apps/umami-finance/arbitrum/umami-finance.compound.token-fetcher.ts +++ b/src/apps/umami-finance/arbitrum/umami-finance.compound.token-fetcher.ts @@ -37,8 +37,8 @@ export class ArbitrumUmamiFinanceCompoundTokenFetcher extends AppTokenTemplatePo return ['0x1922c36f3bc762ca300b4a46bb2102f84b1684ab']; } - async getUnderlyingTokenAddresses(): Promise { - return '0x2adabd6e8ce3e82f52d9998a7f64a90d294a92a4'; + async getUnderlyingTokenDefinitions() { + return [{ address: '0x2adabd6e8ce3e82f52d9998a7f64a90d294a92a4', network: this.network }]; } async getPricePerShare({ diff --git a/src/apps/umami-finance/arbitrum/umami-finance.marinate-umami.token-fetcher.ts b/src/apps/umami-finance/arbitrum/umami-finance.marinate-umami.token-fetcher.ts index c8ea8ed41..da92bbf75 100644 --- a/src/apps/umami-finance/arbitrum/umami-finance.marinate-umami.token-fetcher.ts +++ b/src/apps/umami-finance/arbitrum/umami-finance.marinate-umami.token-fetcher.ts @@ -37,8 +37,8 @@ export class ArbitrumUmamiFinanceMarinateUmamiTokenFetcher extends AppTokenTempl return ['0x2adabd6e8ce3e82f52d9998a7f64a90d294a92a4']; } - async getUnderlyingTokenAddresses(): Promise { - return '0x1622bf67e6e5747b81866fe0b85178a93c7f86e3'; + async getUnderlyingTokenDefinitions() { + return [{ address: '0x1622bf67e6e5747b81866fe0b85178a93c7f86e3', network: this.network }]; } async getReserves({ appToken }: GetDataPropsParams) { diff --git a/src/apps/unagii/common/unagii.vault-token-fetcher.ts b/src/apps/unagii/common/unagii.vault-token-fetcher.ts index cbc7e670a..44ae44685 100644 --- a/src/apps/unagii/common/unagii.vault-token-fetcher.ts +++ b/src/apps/unagii/common/unagii.vault-token-fetcher.ts @@ -79,12 +79,10 @@ export abstract class UnagiiVaultTokenFetcher extends AppTokenTemplatePositionFe return underlyingAssets / appToken.supply; } - async getUnderlyingTokenAddresses({ - definition, - }: GetUnderlyingTokensParams): Promise { + async getUnderlyingTokenDefinitions({ definition }: GetUnderlyingTokensParams) { const underlyingTokenAddress = definition.underlyingTokenAddress === ETH_ADDR_ALIAS ? ZERO_ADDRESS : definition.underlyingTokenAddress; - return [underlyingTokenAddress]; + return [{ address: underlyingTokenAddress, network: this.network }]; } async getLiquidity({ appToken }: GetDataPropsParams) { diff --git a/src/apps/unipilot/common/unipilot.vault.token-fetcher.ts b/src/apps/unipilot/common/unipilot.vault.token-fetcher.ts index 51c72f238..706ca9325 100644 --- a/src/apps/unipilot/common/unipilot.vault.token-fetcher.ts +++ b/src/apps/unipilot/common/unipilot.vault.token-fetcher.ts @@ -51,8 +51,13 @@ export abstract class UnipilotVaultTokenFetcher extends AppTokenTemplatePosition return definitions.map(v => v.address); } - async getUnderlyingTokenAddresses({ definition }: GetUnderlyingTokensParams) { - return [definition.token0Address, definition.token1Address]; + async getUnderlyingTokenDefinitions({ + definition, + }: GetUnderlyingTokensParams) { + return [ + { address: definition.token0Address, network: this.network }, + { address: definition.token1Address, network: this.network }, + ]; } async getTokenDefinitions({ definition }: GetTokenDefinitionsParams) { diff --git a/src/apps/uniswap-v2/common/uniswap-v2.pool.on-chain.template.token-fetcher.ts b/src/apps/uniswap-v2/common/uniswap-v2.pool.on-chain.template.token-fetcher.ts index 1afe46360..781ee9458 100644 --- a/src/apps/uniswap-v2/common/uniswap-v2.pool.on-chain.template.token-fetcher.ts +++ b/src/apps/uniswap-v2/common/uniswap-v2.pool.on-chain.template.token-fetcher.ts @@ -65,8 +65,11 @@ export abstract class UniswapV2PoolOnChainTemplateTokenFetcher< return compact(poolAddresses); } - async getUnderlyingTokenAddresses({ contract }: GetUnderlyingTokensParams) { - return Promise.all([this.getPoolToken0(contract), this.getPoolToken1(contract)]); + async getUnderlyingTokenDefinitions({ contract }: GetUnderlyingTokensParams) { + return [ + { address: await this.getPoolToken0(contract), network: this.network }, + { address: await this.getPoolToken1(contract), network: this.network }, + ]; } async getPricePerShare({ appToken, contract }: GetPricePerShareParams) { diff --git a/src/apps/vaporwave-finance/aurora/vaporwave-finance.vault.token-fetcher.ts b/src/apps/vaporwave-finance/aurora/vaporwave-finance.vault.token-fetcher.ts index 68b1b5cbb..17cd6c93a 100644 --- a/src/apps/vaporwave-finance/aurora/vaporwave-finance.vault.token-fetcher.ts +++ b/src/apps/vaporwave-finance/aurora/vaporwave-finance.vault.token-fetcher.ts @@ -53,10 +53,10 @@ export class AuroraVaporwaveFinanceVaultTokenFetcher extends AppTokenTemplatePos return definitions.map(x => x.address); } - async getUnderlyingTokenAddresses({ + async getUnderlyingTokenDefinitions({ definition, }: GetUnderlyingTokensParams) { - return definition.underlyingTokenAddress; + return [{ address: definition.underlyingTokenAddress, network: this.network }]; } async getPricePerShare({ contract, appToken }: GetPricePerShareParams) { diff --git a/src/apps/velodrome/optimism/velodrome.pool.token-fetcher.ts b/src/apps/velodrome/optimism/velodrome.pool.token-fetcher.ts index 7cd66c6b9..f2e1c2edf 100644 --- a/src/apps/velodrome/optimism/velodrome.pool.token-fetcher.ts +++ b/src/apps/velodrome/optimism/velodrome.pool.token-fetcher.ts @@ -44,8 +44,11 @@ export class OptimismVelodromePoolsTokenFetcher extends AppTokenTemplatePosition return data.data.map(pool => pool.address); } - async getUnderlyingTokenAddresses({ contract }: GetUnderlyingTokensParams) { - return Promise.all([contract.token0(), contract.token1()]); + async getUnderlyingTokenDefinitions({ contract }: GetUnderlyingTokensParams) { + return [ + { address: await contract.token0(), network: this.network }, + { address: await contract.token1(), network: this.network }, + ]; } async getPricePerShare({ appToken, contract }: GetPricePerShareParams) { diff --git a/src/apps/wombat-exchange/common/wombat-exchange.pool.token-fetcher.ts b/src/apps/wombat-exchange/common/wombat-exchange.pool.token-fetcher.ts index 97f24a3e9..453268901 100644 --- a/src/apps/wombat-exchange/common/wombat-exchange.pool.token-fetcher.ts +++ b/src/apps/wombat-exchange/common/wombat-exchange.pool.token-fetcher.ts @@ -42,8 +42,8 @@ export abstract class WombatExchangePoolTokenFetcher extends AppTokenTemplatePos return tokenAddressesByPool.flat(); } - async getUnderlyingTokenAddresses({ contract }: GetUnderlyingTokensParams) { - return contract.underlyingToken(); + async getUnderlyingTokenDefinitions({ contract }: GetUnderlyingTokensParams) { + return [{ address: await contract.underlyingToken(), network: this.network }]; } async getPricePerShare({ contract, multicall, appToken }: GetPricePerShareParams) { diff --git a/src/apps/yearn/common/yearn.vault.token-fetcher.ts b/src/apps/yearn/common/yearn.vault.token-fetcher.ts index 8edda9efa..6590eba9c 100644 --- a/src/apps/yearn/common/yearn.vault.token-fetcher.ts +++ b/src/apps/yearn/common/yearn.vault.token-fetcher.ts @@ -37,11 +37,10 @@ export abstract class YearnVaultTokenFetcher extends AppToke return vaultDefinitions.map(({ address }) => address.toLowerCase()); } - async getUnderlyingTokenAddresses({ contract }: GetUnderlyingTokensParams): Promise { + async getUnderlyingTokenDefinitions({ contract }: GetUnderlyingTokensParams) { const vault = await this.selectVault(contract.address.toLowerCase()); if (!vault) throw new Error('Cannot find specified vault'); - - return [vault.token.address.toLowerCase()]; + return [{ address: vault!.token.address.toLowerCase(), network: this.network }]; } async getLiquidity({ appToken }: GetDataPropsParams) { diff --git a/src/apps/yearn/ethereum/yearn.y-crv.token-fetcher.ts b/src/apps/yearn/ethereum/yearn.y-crv.token-fetcher.ts index ed502024b..a52aff8ff 100644 --- a/src/apps/yearn/ethereum/yearn.y-crv.token-fetcher.ts +++ b/src/apps/yearn/ethereum/yearn.y-crv.token-fetcher.ts @@ -26,8 +26,8 @@ export class EthereumYearnYCrvTokenTokenFetcher extends AppTokenTemplatePosition return ['0xfcc5c47be19d06bf83eb04298b026f81069ff65b']; } - async getUnderlyingTokenAddresses() { - return '0xd533a949740bb3306d119cc777fa900ba034cd52'; + async getUnderlyingTokenDefinitions() { + return [{ address: '0xd533a949740bb3306d119cc777fa900ba034cd52', network: this.network }]; } async getLiquidity({ appToken }: GetDataPropsParams) { diff --git a/src/apps/yearn/ethereum/yearn.yield.token-fetcher.ts b/src/apps/yearn/ethereum/yearn.yield.token-fetcher.ts index 54483d433..4550ca9fa 100644 --- a/src/apps/yearn/ethereum/yearn.yield.token-fetcher.ts +++ b/src/apps/yearn/ethereum/yearn.yield.token-fetcher.ts @@ -34,10 +34,10 @@ export class EthereumYearnYieldTokenFetcher extends AppTokenTemplatePositionFetc return Y_TOKENS.map(yToken => yToken.address); } - async getUnderlyingTokenAddresses({ contract }: GetUnderlyingTokensParams): Promise { + async getUnderlyingTokenDefinitions({ contract }: GetUnderlyingTokensParams) { const match = Y_TOKENS.find(yToken => yToken.address === contract.address.toLowerCase()); if (!match) throw new Error('Cannot find specified Y token'); - return [match.underlyingAddress]; + return [{ address: match.underlyingAddress, network: this.network }]; } async getPricePerShare({ contract }: GetPricePerShareParams): Promise { diff --git a/src/apps/yield-protocol/common/yield-protocol.lend.token-fetcher.ts b/src/apps/yield-protocol/common/yield-protocol.lend.token-fetcher.ts index 340ed5e5c..76fd8bea3 100644 --- a/src/apps/yield-protocol/common/yield-protocol.lend.token-fetcher.ts +++ b/src/apps/yield-protocol/common/yield-protocol.lend.token-fetcher.ts @@ -118,8 +118,8 @@ export abstract class YieldProtocolLendTokenFetcher extends AppTokenTemplatePosi return definitions.map(v => v.address); } - async getUnderlyingTokenAddresses({ contract }: GetUnderlyingTokensParams) { - return contract.underlying(); + async getUnderlyingTokenDefinitions({ contract }: GetUnderlyingTokensParams) { + return [{ address: await contract.underlying(), network: this.network }]; } async getPricePerShare({ diff --git a/src/apps/yield-protocol/common/yield-protocol.pool.token-fetcher.ts b/src/apps/yield-protocol/common/yield-protocol.pool.token-fetcher.ts index 13dc51332..50d1b0f1b 100644 --- a/src/apps/yield-protocol/common/yield-protocol.pool.token-fetcher.ts +++ b/src/apps/yield-protocol/common/yield-protocol.pool.token-fetcher.ts @@ -147,8 +147,8 @@ export abstract class YieldProtocolPoolTokenFetcher extends AppTokenTemplatePosi return this.poolTokenAddresses; } - async getUnderlyingTokenAddresses({ contract }: GetUnderlyingTokensParams) { - return [await contract.base()]; + async getUnderlyingTokenDefinitions({ contract }: GetUnderlyingTokensParams) { + return [{ address: await contract.base(), network: this.network }]; } async getPricePerShare({ appToken, contract, multicall }: GetPricePerShareParams) { diff --git a/src/apps/yield-yak/avalanche/yield-yak.vault.token-fetcher.ts b/src/apps/yield-yak/avalanche/yield-yak.vault.token-fetcher.ts index 3c4d26172..15c1f28af 100644 --- a/src/apps/yield-yak/avalanche/yield-yak.vault.token-fetcher.ts +++ b/src/apps/yield-yak/avalanche/yield-yak.vault.token-fetcher.ts @@ -48,8 +48,8 @@ export class AvalancheYieldyakVaultTokenFetcher extends AppTokenTemplatePosition return farms.map(farm => farm.address.toLowerCase()); } - async getUnderlyingTokenAddresses({ contract }: GetUnderlyingTokensParams) { - return contract.depositToken().then(addr => addr.toLowerCase()); + async getUnderlyingTokenDefinitions({ contract }: GetUnderlyingTokensParams) { + return [{ address: await contract.depositToken(), network: this.network }]; } async getLabel({ appToken }: GetDisplayPropsParams): Promise { diff --git a/src/position/template/app-token.template.position-fetcher.ts b/src/position/template/app-token.template.position-fetcher.ts index 09a271494..6e59b97b9 100644 --- a/src/position/template/app-token.template.position-fetcher.ts +++ b/src/position/template/app-token.template.position-fetcher.ts @@ -1,6 +1,6 @@ import { Inject } from '@nestjs/common'; import { BigNumberish, Contract } from 'ethers/lib/ethers'; -import _ from 'lodash'; +import _, { isEqual, uniqWith } from 'lodash'; import { compact, intersection, isArray, partition, sortBy, sum } from 'lodash'; import { drillBalance } from '~app-toolkit'; @@ -31,6 +31,7 @@ import { GetPriceParams, GetTokenPropsParams, GetUnderlyingTokensParams, + UnderlyingTokenDefinition, } from './app-token.template.types'; import { PositionFetcherTemplateCommons } from './position-fetcher.template.types'; @@ -50,7 +51,6 @@ export abstract class AppTokenTemplatePositionFetcher< isExcludedFromExplore = false; isExcludedFromTvl = false; - fromNetwork?: Network; minLiquidity = 1000; constructor(@Inject(APP_TOOLKIT) protected readonly appToolkit: IAppToolkit) {} @@ -68,9 +68,9 @@ export abstract class AppTokenTemplatePositionFetcher< } // 4. Get underlying token addresses - async getUnderlyingTokenAddresses(_params: GetUnderlyingTokensParams): Promise { - return []; - } + abstract getUnderlyingTokenDefinitions( + _params: GetUnderlyingTokensParams, + ): Promise; // 5A. Get symbol (ERC20 standard) async getSymbol({ address, multicall }: GetTokenPropsParams): Promise { @@ -173,38 +173,37 @@ export abstract class AppTokenTemplatePositionFetcher< const contract = multicall.wrap(this.getContract(address)); const context = { address, definition, contract, multicall, tokenLoader }; - const underlyingTokenAddresses = await this.getUnderlyingTokenAddresses(context) - .then(v => (Array.isArray(v) ? v : [v])) - .then(v => v.map(t => t.toLowerCase())) + const underlyingTokenDefinitions = await this.getUnderlyingTokenDefinitions(context) + .then(v => v.map(t => ({ address: t.address.toLowerCase(), network: t.network, tokenId: t.tokenId }))) .catch(err => { if (isMulticallUnderlyingError(err)) return null; throw err; }); - if (!underlyingTokenAddresses) return null; - return { address, definition, underlyingTokenAddresses }; + if (!underlyingTokenDefinitions) return null; + return { address, definition, underlyingTokenDefinitions }; }), ); const skeletons = compact(maybeSkeletons); const [base, meta] = partition(skeletons, t => { const tokenAddresses = skeletons.map(v => v.address); - return intersection(t.underlyingTokenAddresses, tokenAddresses).length === 0; + const underlyingTokenAddresses = t.underlyingTokenDefinitions.map(v => v.address); + return intersection(underlyingTokenAddresses, tokenAddresses).length === 0; }); const currentTokens: AppTokenPosition[] = []; for (const skeletonsSubset of [base, meta]) { - const underlyingTokenRequests = skeletons - .flatMap(v => v.underlyingTokenAddresses) - .map(v => ({ network: this.fromNetwork ?? this.network, address: v })); + const underlyingTokenQueries = skeletons.flatMap(v => v.underlyingTokenDefinitions); + const underlyingTokenRequestsUnique = uniqWith(underlyingTokenQueries, isEqual); const tokenDependencies = await tokenLoader - .getMany(underlyingTokenRequests) + .getMany(underlyingTokenRequestsUnique) .then(tokenDeps => compact(tokenDeps)); const allTokens = [...currentTokens, ...tokenDependencies]; const skeletonsWithResolvedTokens = await Promise.all( - skeletonsSubset.map(async ({ address, definition, underlyingTokenAddresses }) => { - const maybeTokens = underlyingTokenAddresses.map(v => allTokens.find(t => t.address === v)); + skeletonsSubset.map(async ({ address, definition, underlyingTokenDefinitions }) => { + const maybeTokens = underlyingTokenDefinitions.map(v => allTokens.find(t => t.address === v.address)); const tokens = compact(maybeTokens); if (maybeTokens.length !== tokens.length) return null; diff --git a/src/position/template/app-token.template.types.ts b/src/position/template/app-token.template.types.ts index 22d616184..e9e931d40 100644 --- a/src/position/template/app-token.template.types.ts +++ b/src/position/template/app-token.template.types.ts @@ -1,6 +1,7 @@ import { IMulticallWrapper } from '~multicall/multicall.interface'; import { AppTokenPosition } from '~position/position.interface'; import { TokenDependencySelector } from '~position/selectors/token-dependency-selector.interface'; +import { Network } from '~types/network.interface'; export type DefaultAppTokenDefinition = { address: string; @@ -12,6 +13,12 @@ export type DefaultAppTokenDataProps = { apy: number; }; +export type UnderlyingTokenDefinition = { + address: string; + network: Network; + tokenId?: number; +}; + // PHASE 1: List addresses and definitions export type GetDefinitionsParams = { multicall: IMulticallWrapper; diff --git a/src/position/template/vault.template.token-fetcher.ts b/src/position/template/vault.template.token-fetcher.ts index adfb53e38..fe1b1ecfc 100644 --- a/src/position/template/vault.template.token-fetcher.ts +++ b/src/position/template/vault.template.token-fetcher.ts @@ -19,8 +19,8 @@ export abstract class VaultTemplateTokenFetcher extends AppTokenTemplatePosition return [this.vaultAddress]; } - async getUnderlyingTokenAddresses(_params: GetUnderlyingTokensParams) { - return this.underlyingTokenAddress; + async getUnderlyingTokenDefinitions(_params: GetUnderlyingTokensParams) { + return [{ address: this.underlyingTokenAddress, network: this.network }]; } async getPricePerShare({ multicall, appToken }: GetPricePerShareParams) { diff --git a/src/position/template/wrapper.template.token-fetcher.ts b/src/position/template/wrapper.template.token-fetcher.ts index f27b20e48..1fc58f5f6 100644 --- a/src/position/template/wrapper.template.token-fetcher.ts +++ b/src/position/template/wrapper.template.token-fetcher.ts @@ -1,10 +1,12 @@ import { Erc20 } from '~contract/contracts'; import { AppTokenTemplatePositionFetcher } from '~position/template/app-token.template.position-fetcher'; import { GetDataPropsParams, GetUnderlyingTokensParams } from '~position/template/app-token.template.types'; +import { Network } from '~types'; export abstract class WrapperTemplateTokenFetcher extends AppTokenTemplatePositionFetcher { abstract vaultAddress: string; abstract underlyingTokenAddress: string; + fromNetwork: Network; getContract(address: string): Erc20 { return this.appToolkit.globalContracts.erc20({ address, network: this.network }); @@ -14,8 +16,8 @@ export abstract class WrapperTemplateTokenFetcher extends AppTokenTemplatePositi return [this.vaultAddress]; } - async getUnderlyingTokenAddresses(_params: GetUnderlyingTokensParams) { - return this.underlyingTokenAddress; + async getUnderlyingTokenDefinitions(_params: GetUnderlyingTokensParams) { + return [{ address: this.underlyingTokenAddress, network: this.fromNetwork ?? this.network }]; } async getPricePerShare() {