Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
This commit is contained in:
microwavedcola1 2022-08-22 20:09:31 +02:00
parent 2f5436d239
commit 50e9f39b76
1 changed files with 8 additions and 2 deletions

View File

@ -248,19 +248,25 @@ export class MangoAccount {
getMaxWithdrawWithBorrowForToken(group: Group, mintPk: PublicKey): I80F48 {
const bank: Bank = group.getFirstBankByMint(mintPk);
const initHealth = (this.accountData as MangoAccountData).initHealth;
if (initHealth.lte(ZERO_I80F48)) {
return ZERO_I80F48;
}
const maxBorrowNative = MangoAccount.getEquivalentTokenPosition(
bank,
initHealth.div(bank.initLiabWeight),
);
const maxBorrowNativeWithoutFees = maxBorrowNative.div(
const maxBorrowNativeMinusFees = maxBorrowNative.div(
ONE_I80F48.add(bank.loanOriginationFeeRate),
);
// console.log(`initHealth ${initHealth.toNumber()}`);
// console.log(`maxBorrowNative ${maxBorrowNative.toNumber()}`);
// console.log(
// `maxBorrowNativeWithoutFees ${maxBorrowNativeWithoutFees.toNumber()}`,
// );
return maxBorrowNativeWithoutFees;
return maxBorrowNativeMinusFees;
}
getMaxWithdrawWithBorrowForTokenUi(group: Group, mintPk: PublicKey): number {