-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[GSW-1987] optimize swap route #596
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
f407c78
to
23c82f2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check your sonarcube for duplicates and issues.
There doesn't seem to be any issues in the code.
28fbf92
to
cec71f4
Compare
Quality Gate passedIssues Measures |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
left some comment
if (swapRateAction === "ATOB") { | ||
if (!tokenBUSD || tokenBUSD === 0) return "-"; | ||
return `($${convertToKMB(floorNumber((tokenBUSD / Number(tokenBAmount)) * swapRate).toFixed(3), { | ||
isIgnoreKFormat: true, | ||
})})`; | ||
} else { | ||
if (!tokenAUSD || tokenAUSD === 0) return "-"; | ||
return `($${convertToKMB(floorNumber((tokenAUSD / Number(tokenAAmount)) * swapRate).toFixed(3), { | ||
isIgnoreKFormat: true, | ||
})})`; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems duplicate. how about make this as an function?
const formatPrice = (usd: number, amount: number): string => {
if (!usd || !amount) return '-'; // xxx: not sure about the condition.
const calculated = (usd / amount) * swapRate;
const flooredValue = floorNumber(calculated.toFixed(3), {
isIgnoreKFormat: true,
});
return `($${convertToKMB(flooredValue, { isIgnoreKFormat: true })})`;
};
if (swapRateAction === 'ATOB') {
return formatPrice(tokenBUSD, tokenBAmount);
} else {
return formatPrice(tokenAUSD, tokenAAmount);
}
Description
Details