diff --git a/src/apps/midas/binance-smart-chain/midas.market.token-fetcher.ts b/src/apps/midas/binance-smart-chain/midas.market.token-fetcher.ts index f47ee999a..987f1b3f8 100644 --- a/src/apps/midas/binance-smart-chain/midas.market.token-fetcher.ts +++ b/src/apps/midas/binance-smart-chain/midas.market.token-fetcher.ts @@ -20,7 +20,7 @@ export class BinanceSmartChainMidasMarketTokenFetcher extends MidasMarketTokenFe groupLabel = 'Lending'; poolDirectoryAddress = '0x295d7347606f4bd810c8296bb8d75d657001fcf7'; - poolLensAddress = '0x6f4e0b5405f3751f7327cf8095004c34fc307f55'; + poolLensAddress = '0x2d3c31e38d3ad71571b1406639003a6648481628'; constructor( @Inject(APP_TOOLKIT) protected readonly appToolkit: IAppToolkit, @@ -59,7 +59,6 @@ export class BinanceSmartChainMidasMarketTokenFetcher extends MidasMarketTokenFe async getMarketTokenAddresses(contract: MidasPoolLensContract, poolAddress: string): Promise { const assets = await contract.simulate.getPoolAssetsWithData([poolAddress]).then(v => v.result); - return assets.map(asset => asset.cToken); } diff --git a/src/apps/midas/common/midas.market.token-fetcher.ts b/src/apps/midas/common/midas.market.token-fetcher.ts index 198e7ac04..521e4364a 100644 --- a/src/apps/midas/common/midas.market.token-fetcher.ts +++ b/src/apps/midas/common/midas.market.token-fetcher.ts @@ -1,6 +1,6 @@ import { Inject } from '@nestjs/common'; import { BigNumberish } from 'ethers'; -import { Abi, GetContractReturnType, PublicClient } from 'viem'; +import { Abi, BaseError, ContractFunctionRevertedError, GetContractReturnType, PublicClient } from 'viem'; import { APP_TOOLKIT, IAppToolkit } from '~app-toolkit/app-toolkit.interface'; import { BLOCKS_PER_DAY } from '~app-toolkit/constants/blocks'; @@ -79,7 +79,18 @@ export abstract class MidasMarketTokenFetcher< const definitions = await Promise.all( poolIndexes.map(async poolId => { const { comptroller, name } = await this.getPool(poolDirectory, poolId); - const marketAddresses = await this.getMarketTokenAddresses(poolLens, comptroller); + const marketAddresses = await this.getMarketTokenAddresses(poolLens, comptroller).catch(e => { + if (e instanceof BaseError) { + const err = e.walk((e: Error) => e instanceof ContractFunctionRevertedError); + + if (err) { + const reason = (err as ContractFunctionRevertedError).reason; + if (reason === 'Not implemented') return []; + } + } + + throw e; + }); return marketAddresses.map(marketAddress => ({ address: marketAddress.toLowerCase(), diff --git a/src/apps/midas/polygon/midas.market.token-fetcher.ts b/src/apps/midas/polygon/midas.market.token-fetcher.ts index 39ed7b20a..6f2cd462e 100644 --- a/src/apps/midas/polygon/midas.market.token-fetcher.ts +++ b/src/apps/midas/polygon/midas.market.token-fetcher.ts @@ -20,7 +20,7 @@ export class PolygonMidasMarketTokenFetcher extends MidasMarketTokenFetcher< groupLabel = 'Lending'; poolDirectoryAddress = '0x9a161e68ec0d5364f4d09a6080920daff6fff250'; - poolLensAddress = '0xd94ca960132557385e9ad993c69cc22a3344c2e7'; + poolLensAddress = '0x16d8c0ee982d5219285b1042d3675a6d9e247f9d'; constructor( @Inject(APP_TOOLKIT) protected readonly appToolkit: IAppToolkit, @@ -59,7 +59,6 @@ export class PolygonMidasMarketTokenFetcher extends MidasMarketTokenFetcher< async getMarketTokenAddresses(contract: MidasPoolLensContract, poolAddress: string): Promise { const assets = await contract.simulate.getPoolAssetsWithData([poolAddress]).then(v => v.result); - return assets.map(asset => asset.cToken); }