Skip to content

Commit

Permalink
fix: improve underwater flow calculation by parsing midPrice
Browse files Browse the repository at this point in the history
  • Loading branch information
djaciel committed Nov 28, 2024
1 parent f80914a commit dba170f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 0 additions & 1 deletion packages/overlay-sdk/src/marketsList/markets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,6 @@ export class OverlaySDKMarkets extends OverlaySDKModule {
}

private async _getMarketOnchainData(markets: Address[], chainId: CHAINS): Promise<MarketOnchainData> {
console.log("_getMarketOnchainData")
const OverlayV1MarketABIFunctions = OverlayV1Market2ABI.filter((abi) => abi.type === "function")
const OverlayV1StateABIFunctions = OverlayV1StateABI.filter((abi) => abi.type === "function")

Expand Down
4 changes: 3 additions & 1 deletion packages/overlay-sdk/src/trade/trade.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit dba170f

Please sign in to comment.