add back getEquityUi for perp
This commit is contained in:
parent
4fc2b42f99
commit
fb8eb59355
|
@ -388,9 +388,13 @@ export class Group {
|
|||
}
|
||||
|
||||
public getMintDecimals(mintPk: PublicKey): number {
|
||||
const banks = this.banksMapByMint.get(mintPk.toString());
|
||||
if (!banks) throw new Error(`No bank found for mint ${mintPk}!`);
|
||||
return banks[0].mintDecimals;
|
||||
const bank = this.getFirstBankByMint(mintPk);
|
||||
return bank.mintDecimals;
|
||||
}
|
||||
|
||||
public getMintDecimalsByTokenIndex(tokenIndex: TokenIndex): number {
|
||||
const bank = this.getFirstBankByTokenIndex(tokenIndex);
|
||||
return bank.mintDecimals;
|
||||
}
|
||||
|
||||
public getInsuranceMintDecimals(): number {
|
||||
|
|
|
@ -1219,6 +1219,13 @@ export class PerpPosition {
|
|||
return ZERO_I80F48();
|
||||
}
|
||||
|
||||
public getEquityUi(group: Group, perpMarket: PerpMarket): number {
|
||||
return toUiDecimals(
|
||||
this.getEquity(perpMarket),
|
||||
group.getMintDecimalsByTokenIndex(perpMarket.settleTokenIndex),
|
||||
);
|
||||
}
|
||||
|
||||
public getEquity(perpMarket: PerpMarket): I80F48 {
|
||||
const lotsToQuote = I80F48.fromI64(perpMarket.baseLotSize).mul(
|
||||
perpMarket.price,
|
||||
|
|
Loading…
Reference in New Issue