return 0 for swap from same source to same target

Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
This commit is contained in:
microwavedcola1 2022-08-15 20:16:46 +02:00
parent 03dbac82f9
commit 20c915f0ee
2 changed files with 5 additions and 0 deletions

View File

@ -234,6 +234,10 @@ export class MangoAccount {
targetTokenName: string,
slippageAndFeesFactor: number,
): I80F48 {
if (sourceTokenName === targetTokenName) {
return ZERO_I80F48;
}
return this.accountData.healthCache
.getMaxSourceForTokenSwap(
group,

View File

@ -91,6 +91,7 @@ async function debugUser(client, group, mangoAccount) {
);
}
getMaxSourceForTokenSwapWrapper('SOL', 'BTC');
getMaxSourceForTokenSwapWrapper('USDC', 'USDC');
}
async function main() {