copy perp position functions from dev branch

This commit is contained in:
tjs 2022-11-20 22:07:15 -05:00
parent 26d65e9db9
commit 57b05259f9
1 changed files with 18 additions and 0 deletions

View File

@ -1133,6 +1133,24 @@ export class PerpPosition {
!this.takerQuoteLots.eq(zero)
);
}
public getEntryPrice(perpMarket: PerpMarket): BN {
if (this.basePositionLots.eq(new BN(0))) {
return new BN(0);
}
return this.quoteEntryNative
.div(this.basePositionLots.mul(perpMarket.baseLotSize))
.abs();
}
public getBreakEvenPrice(perpMarket: PerpMarket): BN {
if (this.basePositionLots.eq(new BN(0))) {
return new BN(0);
}
return this.quoteRunningNative
.div(this.basePositionLots.mul(perpMarket.baseLotSize))
.abs();
}
}
export class PerpPositionDto {