Skip to content

Commit

Permalink
sdk: fix getUnrealizedPNL for market index 0
Browse files Browse the repository at this point in the history
  • Loading branch information
crispheaney committed Jan 17, 2024
1 parent bc18f93 commit 959bb4d
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion sdk/src/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -766,7 +766,9 @@ export class User {
strict = false
): BN {
return this.getActivePerpPositions()
.filter((pos) => (marketIndex ? pos.marketIndex === marketIndex : true))
.filter((pos) =>
marketIndex !== undefined ? pos.marketIndex === marketIndex : true
)
.reduce((unrealizedPnl, perpPosition) => {
const market = this.driftClient.getPerpMarketAccount(
perpPosition.marketIndex
Expand Down

0 comments on commit 959bb4d

Please sign in to comment.