Increase iterations for max swap to fix some edge case, fix debug script since fees are already accounted for

Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
This commit is contained in:
microwavedcola1 2023-05-10 11:18:46 +02:00
parent 450f446032
commit 13ac422875
2 changed files with 5 additions and 8 deletions

View File

@ -111,22 +111,19 @@ async function debugUser(
console.log(`Error for ${src}->${tgt}, ` + error.toString());
}
const maxSourceWoFees =
-maxSourceUi *
(1 + group.banksMapByName.get(src)![0].loanOriginationFeeRate.toNumber());
const maxTargetWoFees =
-maxSourceWoFees *
const maxTargetUi =
maxSourceUi *
(group.banksMapByName.get(src)![0].uiPrice /
group.banksMapByName.get(tgt)![0].uiPrice);
const sim = mangoAccount.simHealthRatioWithTokenPositionUiChanges(group, [
{
mintPk: group.banksMapByName.get(src)![0].mint,
uiTokenAmount: maxSourceWoFees,
uiTokenAmount: -maxSourceUi,
},
{
mintPk: group.banksMapByName.get(tgt)![0].mint,
uiTokenAmount: maxTargetWoFees,
uiTokenAmount: maxTargetUi,
},
]);
console.log(

View File

@ -559,7 +559,7 @@ export class HealthCache {
target: I80F48,
fun: (amount: I80F48) => I80F48,
): I80F48 {
const maxIterations = 20;
const maxIterations = 50;
let current = start;
// console.log(`scanRightUntilLessThan, start ${start.toLocaleString()}`);
for (const key of Array(maxIterations).fill(0).keys()) {