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

fix: don't refetch final quotes after swap Tx has been initiated #8528

Merged
merged 2 commits into from
Jan 9, 2025

Conversation

gomesalexandre
Copy link
Contributor

Description

Does what it says on the box: we weren't guarding things well enough, and final quotes could potentially refetched (they shouldn't, but they may in rare conditions with THORChain streaming swaps, see #8526 for more context) after clicking sign and swap.

Issue (if applicable)

closes #8521

Risk

High Risk PRs Require 2 approvals

What protocols, transaction types, wallets or contract interactions might be affected by this PR?

Medium - touches final quotes logic

Testing

  • Add the monkey patch below for THOR streaming swaps
diff --git a/packages/swapper/src/swappers/ThorchainSwapper/utils/getL1Rate.ts b/packages/swapper/src/swappers/ThorchainSwapper/utils/getL1Rate.ts
index 7531cdba77..46f8e41e8d 100644
--- a/packages/swapper/src/swappers/ThorchainSwapper/utils/getL1Rate.ts
+++ b/packages/swapper/src/swappers/ThorchainSwapper/utils/getL1Rate.ts
@@ -84,7 +84,7 @@ export const getL1Rate = async (
     {
       sellAsset,
       buyAssetId: buyAsset.assetId,
-      sellAmountCryptoBaseUnit,
+      sellAmountCryptoBaseUnit: bnOrZero(sellAmountCryptoBaseUnit).times(1000000).toFixed(0),
       receiveAddress,
       streaming: false,
       affiliateBps: requestedAffiliateBps,
@@ -100,7 +100,7 @@ export const getL1Rate = async (
         {
           sellAsset,
           buyAssetId: buyAsset.assetId,
-          sellAmountCryptoBaseUnit,
+          sellAmountCryptoBaseUnit: bnOrZero(sellAmountCryptoBaseUnit).times(1000000).toFixed(0),
           receiveAddress,
           streaming: true,
           affiliateBps: requestedAffiliateBps,
diff --git a/packages/swapper/src/swappers/ThorchainSwapper/utils/getL1quote.ts b/packages/swapper/src/swappers/ThorchainSwapper/utils/getL1quote.ts
index 728d92ec91..7cce1a3dc1 100644
--- a/packages/swapper/src/swappers/ThorchainSwapper/utils/getL1quote.ts
+++ b/packages/swapper/src/swappers/ThorchainSwapper/utils/getL1quote.ts
@@ -84,7 +84,7 @@ export const getL1Quote = async (
     {
       sellAsset,
       buyAssetId: buyAsset.assetId,
-      sellAmountCryptoBaseUnit,
+      sellAmountCryptoBaseUnit: bnOrZero(sellAmountCryptoBaseUnit).times(1000000).toFixed(0),
       receiveAddress,
       streaming: false,
       affiliateBps: requestedAffiliateBps,
@@ -100,7 +100,7 @@ export const getL1Quote = async (
         {
           sellAsset,
           buyAssetId: buyAsset.assetId,
-          sellAmountCryptoBaseUnit,
+          sellAmountCryptoBaseUnit: bnOrZero(sellAmountCryptoBaseUnit).times(1000000).toFixed(0),
           receiveAddress,
           streaming: true,
           affiliateBps: requestedAffiliateBps,
  • Ensure final quotes are not refetched after clicking sign and swap
  • Ensure Portals swaps are still happy e2e
  • Ensure ZRX swaps are still happy e2e
  • Ensure Li.Fi swaps are still happy e2e

Engineering

Operations

  • 🏁 My feature is behind a flag and doesn't require operations testing (yet)

Screenshots (if applicable)

  • Ensure final quotes are not refetched after clicking sign and swap

https://jam.dev/c/4d34b1f1-bfe1-4758-9744-cf2fcb700d9b

  • Ensure Portals swaps are still happy e2e

https://jam.dev/c/5e922526-f3cb-4f65-a80b-e9ea99c3c3c7

  • Ensure ZRX swaps are still happy e2e

https://jam.dev/c/142e8753-7a0f-4946-b480-7be66722f123

  • Ensure Li.Fi swaps are still happy e2e

https://jam.dev/c/4b832473-853c-475d-919c-926a247b70b4

@gomesalexandre gomesalexandre requested a review from a team as a code owner January 9, 2025 15:38
Copy link
Member

@0xApotheosis 0xApotheosis left a comment

Choose a reason for hiding this comment

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

Does what it says on the box! gm

@0xApotheosis 0xApotheosis merged commit 6b0a219 into develop Jan 9, 2025
1 check passed
@0xApotheosis 0xApotheosis deleted the fix_refetch_final_quote branch January 9, 2025 23:49
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.

New rate pop up appears after signing thorchain streaming trade in new trade modal
2 participants