fix max swap

Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
This commit is contained in:
microwavedcola1 2023-07-12 09:38:48 +02:00
parent c40bffb047
commit a6fe8dfd48
1 changed files with 4 additions and 0 deletions

View File

@ -600,6 +600,10 @@ export class MangoAccount {
sourceBorrow.div(ONE_I80F48().add(sourceBank.loanOriginationFeeRate)),
);
}
// Cannot swap more than total deposits in mango for the token
maxSource = maxSource.min(sourceBank.nativeDeposits());
return toUiDecimals(maxSource, group.getMintDecimals(sourceMintPk));
}