fix get unsettled funding function

This commit is contained in:
tjs 2022-11-21 10:47:30 -05:00
parent 256b948207
commit 708ef68b85
1 changed files with 5 additions and 6 deletions

View File

@ -1092,16 +1092,15 @@ export class PerpPosition {
}
public getUnsettledFunding(perpMarket: PerpMarket): I80F48 {
if (this.basePositionLots.gt(new BN(0))) {
return perpMarket.longFunding
.sub(this.longSettledFunding)
.mul(I80F48.fromI64(this.basePositionLots));
} else if (this.basePositionLots.lt(new BN(0))) {
if (this.basePositionLots.isNeg()) {
return perpMarket.shortFunding
.sub(this.shortSettledFunding)
.mul(I80F48.fromI64(this.basePositionLots));
} else {
return perpMarket.longFunding
.sub(this.longSettledFunding)
.mul(I80F48.fromI64(this.basePositionLots));
}
return ZERO_I80F48();
}
public getEquity(perpMarket: PerpMarket): I80F48 {