apply loan origination fee buffer

Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
This commit is contained in:
microwavedcola1 2022-08-11 17:59:49 +02:00
parent 185b077285
commit 5402012064
2 changed files with 12 additions and 4 deletions

View File

@ -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,
),
);
}
}

View File

@ -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,