add deposits and borrows fn to mangoAccount
This commit is contained in:
parent
1c02ccd21d
commit
273b8dd597
|
@ -89,6 +89,16 @@ export class MangoAccount {
|
|||
return ta ? ta.ui(bank) : 0;
|
||||
}
|
||||
|
||||
deposits(bank: Bank): number {
|
||||
const ta = this.findToken(bank.tokenIndex);
|
||||
return ta ? ta.uiDeposits(bank) : 0;
|
||||
}
|
||||
|
||||
borrows(bank: Bank): number {
|
||||
const ta = this.findToken(bank.tokenIndex);
|
||||
return ta ? ta.uiBorrows(bank) : 0;
|
||||
}
|
||||
|
||||
tokens_active(): TokenPosition[] {
|
||||
return this.tokens.filter((token) => token.isActive());
|
||||
}
|
||||
|
@ -155,6 +165,20 @@ export class TokenPosition {
|
|||
return nativeI80F48ToUi(this.native(bank), bank.mintDecimals).toNumber();
|
||||
}
|
||||
|
||||
public uiDeposits(bank: Bank): number {
|
||||
return nativeI80F48ToUi(
|
||||
bank.depositIndex.mul(this.indexedPosition),
|
||||
bank.mintDecimals,
|
||||
).toNumber();
|
||||
}
|
||||
|
||||
public uiBorrows(bank: Bank): number {
|
||||
return nativeI80F48ToUi(
|
||||
bank.borrowIndex.mul(this.indexedPosition),
|
||||
bank.mintDecimals,
|
||||
).toNumber();
|
||||
}
|
||||
|
||||
public toString(group?: Group): String {
|
||||
let extra: string = '';
|
||||
if (group) {
|
||||
|
|
|
@ -553,7 +553,7 @@ export class MangoClient {
|
|||
({ pubkey: pk, isWritable: false, isSigner: false } as AccountMeta),
|
||||
),
|
||||
)
|
||||
.rpc();
|
||||
.rpc({ skipPreflight: true });
|
||||
}
|
||||
|
||||
// Serum
|
||||
|
|
Loading…
Reference in New Issue