Skip to content

Commit

Permalink
fallback to oracle/mark price if 0 comes thru (#135)
Browse files Browse the repository at this point in the history
  • Loading branch information
lowkeynicc authored Nov 14, 2024
1 parent 1dd743b commit 81da7c6
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions common-ts/src/common-ui-utils/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,15 @@ const getOpenPositionData = (
}
}

// if for any reason oracle or mark price blips to 0, fallback to the other one so we don't show a crazy pnl
if (markPrice.lte(ZERO) && oraclePrice.gt(ZERO)) {
markPrice = oraclePrice;
}

if (oraclePrice.lte(ZERO) && markPrice.gt(ZERO)) {
oraclePrice = markPrice;
}

const pnlVsMark = TRADING_COMMON_UTILS.calculatePotentialProfit({
currentPositionSize: BigNum.from(
perpPositionWithRemainderBaseAdded.baseAssetAmount.abs(),
Expand Down

0 comments on commit 81da7c6

Please sign in to comment.