diff --git a/ts/client/src/accounts/mangoAccount.ts b/ts/client/src/accounts/mangoAccount.ts index 2d669c890..3222be1ec 100644 --- a/ts/client/src/accounts/mangoAccount.ts +++ b/ts/client/src/accounts/mangoAccount.ts @@ -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)); }