diff --git a/ts/client/src/accounts/healthCache.ts b/ts/client/src/accounts/healthCache.ts index dd763ee58..1c15650e5 100644 --- a/ts/client/src/accounts/healthCache.ts +++ b/ts/client/src/accounts/healthCache.ts @@ -5,6 +5,7 @@ import { I80F48, I80F48Dto, MAX_I80F48, + ONE_I80F48, ZERO_I80F48, } from './I80F48'; import { HealthType } from './mangoAccount'; @@ -312,7 +313,13 @@ export class HealthCache { ); } - return amount.div(source.oraclePrice); + return amount + .div(source.oraclePrice) + .mul( + ONE_I80F48.sub( + group.banksMap.get(sourceTokenName).loanOriginationFeeRate, + ), + ); } } diff --git a/ts/client/src/accounts/mangoAccount.ts b/ts/client/src/accounts/mangoAccount.ts index ade05e7e9..e4552d16e 100644 --- a/ts/client/src/accounts/mangoAccount.ts +++ b/ts/client/src/accounts/mangoAccount.ts @@ -218,9 +218,10 @@ export class MangoAccount { } /** - * The amount of given source native token you can swap to a target token considering all existing assets as collateral. - * note: slippageAndFeesFactor is a normalized number, <1, e.g. a slippage of 5% and some fees which are 1%, then slippageAndFeesFactor = 0.94 - * the factor is used to compute how much target can be obtained by swapping source TODO: loan origination fees + * The max amount of given source native token you can swap to a target token. + * note: slippageAndFeesFactor is a normalized number, <1, + * e.g. a slippage of 5% and some fees which are 1%, then slippageAndFeesFactor = 0.94 + * the factor is used to compute how much target can be obtained by swapping source */ getMaxSourceForTokenSwap( group: Group,