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

feat: lifi swapper simplify status detection #8569

Merged
merged 3 commits into from
Jan 15, 2025

Conversation

gomesalexandre
Copy link
Contributor

Description

Or well, not exactly. More like being consistent with CoW and Chainflip by early returning on seen Txs - in effect, should be a no-op for the specific case of Li.Fi.

Issue (if applicable)

closes #8534

Risk

High Risk PRs Require 2 approvals

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

Low - seemingly a change of heuristics (early return on seen Tx vs. waiting for "DONE" status), though, in effect, both are true at the exact same time.

Testing

  • Li.Fi status detection is still happy

Engineering

  • ^

Operations

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

Screenshots (if applicable)

https://jam.dev/c/67cdc603-08f1-4321-a648-e20439cc514d

@gomesalexandre gomesalexandre requested a review from a team as a code owner January 14, 2025 13:58
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!

Screenshot 2025-01-15 at 17 30 46

One suggestion to make this more concise, if you're so inclined...

diff --git a/packages/swapper/src/swappers/LifiSwapper/endpoints.ts b/packages/swapper/src/swappers/LifiSwapper/endpoints.ts
index b5fd94a03d..b9d1a14304 100644
--- a/packages/swapper/src/swappers/LifiSwapper/endpoints.ts
+++ b/packages/swapper/src/swappers/LifiSwapper/endpoints.ts
@@ -286,15 +286,7 @@ export const lifiApi: SwapperApi = {
     if (!response.ok) return createDefaultStatusResponse()

     const statusResponse = await response.json()
-
-    // We have an out Tx hash (either same or cross-chain) for this step, so we consider the Tx (effectively, the step) confirmed
-    if ((statusResponse.receiving as ExtendedTransactionInfo)?.txHash) {
-      return {
-        status: TxStatus.Confirmed,
-        buyTxHash: (statusResponse.receiving as ExtendedTransactionInfo).txHash,
-        message: statusResponse.substatusMessage,
-      }
-    }
+    const receiving: ExtendedTransactionInfo | undefined = statusResponse.receiving

     const status = (() => {
       switch (statusResponse.status) {
@@ -308,8 +300,8 @@ export const lifiApi: SwapperApi = {
     })()

     return {
-      status,
-      buyTxHash: (statusResponse.receiving as ExtendedTransactionInfo)?.txHash,
+      status: receiving?.txHash ? TxStatus.Confirmed : status,
+      buyTxHash: receiving?.txHash,
       message: statusResponse.substatusMessage,
     }
   },

@gomesalexandre
Copy link
Contributor Author

One suggestion to make this more concise, if you're so inclined...

Absolutely @0xApotheosis ! Tackled in d63aa56 and retested: https://jam.dev/c/9c07f48b-9e24-4637-ad60-c4e858d38f7f

@gomesalexandre gomesalexandre enabled auto-merge (squash) January 15, 2025 08:09
@gomesalexandre gomesalexandre merged commit 6a3a601 into develop Jan 15, 2025
6 checks passed
@gomesalexandre gomesalexandre deleted the feat_lifi_improve_cleanup_status_detection branch January 15, 2025 08:17
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.

Swaps completing on-chain before swapper detects completion
2 participants