diff --git a/packages/blue-sdk-ethers/test/e2e/Market.test.ts b/packages/blue-sdk-ethers/test/e2e/Market.test.ts index 66f2e57b..68ed1ec2 100644 --- a/packages/blue-sdk-ethers/test/e2e/Market.test.ts +++ b/packages/blue-sdk-ethers/test/e2e/Market.test.ts @@ -8,7 +8,8 @@ import { blueAbi } from "./abis.js"; import { test } from "./setup.js"; const { morpho, adaptiveCurveIrm } = addresses[ChainId.EthMainnet]; -const { usdc_wstEth, usdc_idle, eth_wstEth } = markets[ChainId.EthMainnet]; +const { usdc_wstEth, usdc_idle, eth_wstEth, crvUsd_stkcvx2BTC } = + markets[ChainId.EthMainnet]; describe("augment/Market", () => { test("should fetch market data", async ({ wallet }) => { @@ -103,4 +104,39 @@ describe("augment/Market", () => { expect(value).toStrictEqual(expectedData); }); + + test("should fetch market with incorrect oracle", async ({ + client, + wallet, + }) => { + const params = new MarketParams({ + ...crvUsd_stkcvx2BTC, + oracle: randomAddress(), + }); + + const timestamp = (await client.timestamp()) + 3n; + + await client.setNextBlockTimestamp({ timestamp }); + await client.writeContract({ + address: morpho, + abi: blueAbi, + functionName: "createMarket", + args: [{ ...params }], + }); + + const expectedData = new Market({ + params, + totalSupplyAssets: 0n, + totalSupplyShares: 0n, + totalBorrowAssets: 0n, + totalBorrowShares: 0n, + lastUpdate: 1711597274n, + fee: 0n, + rateAtTarget: 1268391679n, + }); + + const value = await Market.fetch(params.id, wallet); + + expect(value).toStrictEqual(expectedData); + }); });