Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Resolve the exchange rate discrepancy between blocks 9664314 and… #19

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions adapters/rhomarkets/src/sdk/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
30 changes: 22 additions & 8 deletions adapters/rhomarkets/src/sdk/marketDetails.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -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,
Expand All @@ -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
),
});
}

Expand Down
Loading