diff --git a/adapters/rhomarkets/src/sdk/config.ts b/adapters/rhomarkets/src/sdk/config.ts index 05bf245..e4e70c5 100644 --- a/adapters/rhomarkets/src/sdk/config.ts +++ b/adapters/rhomarkets/src/sdk/config.ts @@ -22,3 +22,9 @@ export const RPC_URLS = { export const WETH_ADDRESS = { [CHAINS.SCROLL]: "0x5300000000000000000000000000000000000004", }; + +export const rUSDC_ADDRESS = "0xAE1846110F72f2DaaBC75B7cEEe96558289EDfc5"; + +export const FIXED_BLOCK_NUMS = [9664314n, 10135815n]; + +export const FIXED_EXCHANGE_RATE = 1020933877280826510n; diff --git a/adapters/rhomarkets/src/sdk/marketDetails.ts b/adapters/rhomarkets/src/sdk/marketDetails.ts index 856bb4e..c90a234 100644 --- a/adapters/rhomarkets/src/sdk/marketDetails.ts +++ b/adapters/rhomarkets/src/sdk/marketDetails.ts @@ -1,5 +1,11 @@ import { createPublicClient, extractChain, http, getContract } from "viem"; -import { CHAINS, RPC_URLS } from "./config"; +import { + CHAINS, + FIXED_BLOCK_NUMS, + FIXED_EXCHANGE_RATE, + RPC_URLS, + rUSDC_ADDRESS, +} from "./config"; import { scroll } from "viem/chains"; import coreAbi from "./abi/core.abi"; import ltokenAbi from "./abi/ltoken.abi"; @@ -75,9 +81,8 @@ export const getMarketInfos = async ( functionName: "symbol", })) as any, }); - - const exchangeRateResults = await publicClient.multicall({ + let exchangeRateResults = await publicClient.multicall({ contracts: markets.map((m) => ({ address: m.address, abi: m.abi, @@ -92,16 +97,25 @@ export const getMarketInfos = async ( const marketAddress = markets[i].address.toLowerCase(); const underlyingAddress = underlyingAddresses[i]; + // Fix rUSDC exchange rate issue that occurred between blocks 9664314 and 9671174 + const fixedUSDCBlockData = + marketAddress.toLowerCase() === rUSDC_ADDRESS.toLowerCase() && + blockNumber && + blockNumber > FIXED_BLOCK_NUMS[0] && + blockNumber < FIXED_BLOCK_NUMS[1]; + marketInfos.push({ address: marketAddress, underlyingAddress, decimals: (decimalResults[i].result as number) || 0, underlyingSymbol: (underlyingSymbolResults[i].result as any) || "ETH", - exchangeRateStored: BigInt( - exchangeRateResults[i].status === "success" - ? (exchangeRateResults[i].result as any) - : 0 - ), + exchangeRateStored: fixedUSDCBlockData + ? FIXED_EXCHANGE_RATE + : BigInt( + exchangeRateResults[i].status === "success" + ? (exchangeRateResults[i].result as any) + : 0 + ), }); }