Skip to content
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

Merged
merged 2 commits into from
Dec 31, 2024
Merged

[GSW-1987] optimize swap route #596

merged 2 commits into from
Dec 31, 2024

Conversation

tfrg
Copy link
Collaborator

@tfrg tfrg commented Dec 23, 2024

Description

  • Optimised the processing of swap data in FE

Details

  • Unnecessarily many retries
  • Removes forced latency of 0.3ms for data processing

Copy link

vercel bot commented Dec 23, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
gnoswap-interface ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 31, 2024 9:03am

Copy link
Member

@jinoosss jinoosss left a 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.

@tfrg tfrg force-pushed the GSW-1987-optimize-swap-route branch from 28fbf92 to cec71f4 Compare December 31, 2024 09:02
@tfrg tfrg merged commit c2ca3fd into develop Dec 31, 2024
6 checks passed
@tfrg tfrg deleted the GSW-1987-optimize-swap-route branch December 31, 2024 09:31
Copy link
Member

@notJoon notJoon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

left some comment

Comment on lines +133 to +143
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,
})})`;
}
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants