Skip to content

Commit

Permalink
fix pnl when no perps positions (#126)
Browse files Browse the repository at this point in the history
  • Loading branch information
markonmars authored Dec 12, 2024
1 parent b66609d commit cc66b7b
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/rover/ActionGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@ export class ActionGenerator {
denom: neutralDenom,
}
: this.findHighestValueCollateral(account, oraclePrices)
const totalPerpPnl = calculateTotalPerpPnl(account.perps)

// Perp pnl
let hasPerps = account.perps && account.perps.length > 0
const totalPerpPnl = hasPerps ? calculateTotalPerpPnl(account.perps) : new BigNumber(0)

// In some cases, a position may be unhealthy but have no debt, as all the negative pnl is
// covered by the collateral. In this case, we can use the total amount of perp debt
Expand Down

0 comments on commit cc66b7b

Please sign in to comment.