From dba170faf3b0b548e18f33828e578bad15ae0b56 Mon Sep 17 00:00:00 2001 From: djaciel Date: Wed, 27 Nov 2024 23:31:11 -0600 Subject: [PATCH] fix: improve underwater flow calculation by parsing midPrice --- packages/overlay-sdk/src/marketsList/markets.ts | 1 - packages/overlay-sdk/src/trade/trade.ts | 4 +++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/overlay-sdk/src/marketsList/markets.ts b/packages/overlay-sdk/src/marketsList/markets.ts index c722e91..815175f 100644 --- a/packages/overlay-sdk/src/marketsList/markets.ts +++ b/packages/overlay-sdk/src/marketsList/markets.ts @@ -266,7 +266,6 @@ export class OverlaySDKMarkets extends OverlaySDKModule { } private async _getMarketOnchainData(markets: Address[], chainId: CHAINS): Promise { - console.log("_getMarketOnchainData") const OverlayV1MarketABIFunctions = OverlayV1Market2ABI.filter((abi) => abi.type === "function") const OverlayV1StateABIFunctions = OverlayV1StateABI.filter((abi) => abi.type === "function") diff --git a/packages/overlay-sdk/src/trade/trade.ts b/packages/overlay-sdk/src/trade/trade.ts index 78ffa59..1cc1359 100644 --- a/packages/overlay-sdk/src/trade/trade.ts +++ b/packages/overlay-sdk/src/trade/trade.ts @@ -223,7 +223,9 @@ export class OverlaySDKTrade extends OverlaySDKModule { const rawOiShort = ois[1] const rawCapOi = capOi - const showUnderwaterFlow = isLong ? Number(liquidationPriceEstimate) > Number(midPrice) : Number(liquidationPriceEstimate) < Number(midPrice) + const midPriceParsed = formatBigNumber(midPrice, 18, 18, true) as number + console.log("======= showUnderwaterFlow", isLong, Number(liquidationPriceEstimate), midPriceParsed) + const showUnderwaterFlow = isLong ? Number(liquidationPriceEstimate) > midPriceParsed : Number(liquidationPriceEstimate) < midPriceParsed const exceedOiCap = isLong ? BigInt(rawExpectedOi) + rawOiLong > rawCapOi : BigInt(rawExpectedOi) + rawOiShort > rawCapOi