Skip to content

Commit

Permalink
Merge pull request #40 from overlay-market/fix/trade-state-underwater
Browse files Browse the repository at this point in the history
fix: improve underwater flow calculation by parsing midPrice
  • Loading branch information
Aliona-D authored Nov 28, 2024
2 parents f80914a + dba170f commit c0d77c7
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 c0d77c7

Please sign in to comment.