Skip to content

Comments

fix/PRO-3493/swap-wrapped-native-issue#365

Merged
RanaBug merged 1 commit intostagingfrom
fix/PRO-3493/swap-wrapped-native-issue
Jul 8, 2025
Merged

fix/PRO-3493/swap-wrapped-native-issue#365
RanaBug merged 1 commit intostagingfrom
fix/PRO-3493/swap-wrapped-native-issue

Conversation

@RanaBug
Copy link
Collaborator

@RanaBug RanaBug commented Jul 8, 2025

Description

  • Swap wrapped / native token issue resolved
  • Slippage increase from 1% to 3% on Lifi SDK
  • Removing warning on cost higher than amount

How Has This Been Tested?

  • Existing Unit Tests and Manual Testing

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Summary by CodeRabbit

  • Improvements

    • Reduced the default slippage tolerance for swap offers, potentially leading to more favorable exchange rates.
    • Enhanced transaction step logic to avoid unnecessary token wrapping during swaps.
    • Added data attributes to transaction info buttons for easier access to block explorer URLs.
  • Temporary Changes

    • Disabled the safety warning for high transaction costs in the send modal (to be reintroduced in a future update).

@RanaBug RanaBug requested a review from IAmKio July 8, 2025 12:03
@RanaBug RanaBug self-assigned this Jul 8, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jul 8, 2025

Walkthrough

This update refines token swap and transaction logic by adjusting slippage tolerance, enhancing token wrapping checks, and updating function signatures for offer and transaction retrieval. Additional metadata attributes are added to transaction info buttons, and a safety warning in the send modal is temporarily disabled pending a future update.

Changes

Files/Paths Change Summary
src/apps/the-exchange/components/EnterAmount/EnterAmount.tsx Slippage parameter in getOffer changed from 0.05 to 0.03.
src/apps/the-exchange/components/ExchangeAction/ExchangeAction.tsx swapToken argument added to getStepTransactions call in exchange handler.
src/apps/the-exchange/hooks/useOffer.tsx Updated imports; getBestOffer and getStepTransactions signatures changed; improved token wrapping logic.
src/components/BottomMenuModal/HistoryModal/TransactionInfo.tsx Added data-url attributes to transaction info buttons for block explorer links.
src/components/BottomMenuModal/SendModal/SendModalTokensTabView.tsx Safety warning for high transaction cost commented out; ESLint unused variable suppression added.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant EnterAmount
    participant ExchangeAction
    participant useOffer
    participant TokenService

    User->>EnterAmount: Input swap details
    EnterAmount->>useOffer: getBestOffer(..., slippage=0.03)
    useOffer->>TokenService: Fetch token data
    useOffer-->>EnterAmount: Return best offer

    User->>ExchangeAction: Click exchange
    ExchangeAction->>useOffer: getStepTransactions(swapToken, offer, walletAddress)
    useOffer->>TokenService: Check if wrapping required
    useOffer-->>ExchangeAction: Return step transactions
Loading

Possibly related PRs

  • pillarwallet/x#315: Extends token wrapping logic and slippage control in the same functions updated here, directly building on useOffer enhancements.
  • pillarwallet/x#306: Adds debug logging around getStepTransactions calls, related at the function usage level to the signature changes in this PR.

Suggested reviewers

  • IAmKio

Poem

A hop and a swap, the tokens dance anew,
With slippage trimmed and wrapping logic true.
Buttons now whisper URLs with glee,
While warnings take a nap—just temporarily!
Through every flow, the code hops on—
Another exchange, another dawn.
🐇✨

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

npm error Exit handler never called!
npm error This is an error with npm itself. Please report this error at:
npm error https://github.com/npm/cli/issues
npm error A complete log of this run can be found in: /.npm/_logs/2025-07-08T12_05_01_451Z-debug-0.log

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@cloudflare-workers-and-pages
Copy link

Deploying x with  Cloudflare Pages  Cloudflare Pages

Latest commit: 2f6d449
Status: ✅  Deploy successful!
Preview URL: https://f66eda79.x-e62.pages.dev
Branch Preview URL: https://fix-pro-3493-swap-wrapped-na.x-e62.pages.dev

View logs

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
src/components/BottomMenuModal/SendModal/SendModalTokensTabView.tsx (1)

598-611: Safety warning temporarily disabled - verify user impact.

The safety warning that prevents users from proceeding when transaction costs exceed the send amount has been disabled pending Transaction Kit 2.0. While this addresses the PR objective, consider the user experience implications of removing this protective measure.

Ensure that:

  1. Users are still informed about high transaction costs through other means
  2. The temporary removal timeline is acceptable from a UX perspective
  3. Transaction Kit 2.0 timeline is confirmed for reintroducing this feature
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7f0badf and 2f6d449.

📒 Files selected for processing (5)
  • src/apps/the-exchange/components/EnterAmount/EnterAmount.tsx (1 hunks)
  • src/apps/the-exchange/components/ExchangeAction/ExchangeAction.tsx (1 hunks)
  • src/apps/the-exchange/hooks/useOffer.tsx (4 hunks)
  • src/components/BottomMenuModal/HistoryModal/TransactionInfo.tsx (2 hunks)
  • src/components/BottomMenuModal/SendModal/SendModalTokensTabView.tsx (2 hunks)
🧰 Additional context used
🧠 Learnings (5)
📓 Common learnings
Learnt from: RanaBug
PR: pillarwallet/x#275
File: src/apps/the-exchange/components/DropdownTokensList/DropdownTokenList.tsx:180-195
Timestamp: 2025-03-28T09:22:22.712Z
Learning: In the Exchange app, `swapTokenList` and `receiveTokenList` are derived from `searchTokenResult` when search is active, so including `searchToken` in the useEffect dependency array that uses these lists would be redundant as the lists will update when search results change.
src/apps/the-exchange/components/ExchangeAction/ExchangeAction.tsx (2)
Learnt from: RanaBug
PR: pillarwallet/x#275
File: src/apps/the-exchange/components/DropdownTokensList/DropdownTokenList.tsx:180-195
Timestamp: 2025-03-28T09:22:22.712Z
Learning: In the Exchange app, `swapTokenList` and `receiveTokenList` are derived from `searchTokenResult` when search is active, so including `searchToken` in the useEffect dependency array that uses these lists would be redundant as the lists will update when search results change.
Learnt from: RanaBug
PR: pillarwallet/x#334
File: src/apps/leaderboard/utils/index.tsx:91-94
Timestamp: 2025-06-17T09:20:44.533Z
Learning: In src/apps/leaderboard/utils/index.tsx, the getLastWeekMigrationData function intentionally uses currentWeek (not lastWeek) for the completedSwapWeek lookup. This is correct business logic - when retrieving last week's migration data, the function should check swap completion against the current week while using lastWeek for points and USD calculations.
src/components/BottomMenuModal/HistoryModal/TransactionInfo.tsx (1)
Learnt from: RanaBug
PR: pillarwallet/x#320
File: src/components/BottomMenuModal/HistoryModal/TransactionInfo.tsx:177-182
Timestamp: 2025-05-28T14:30:02.702Z
Learning: In the transaction history tracking feature, chain ID validation is performed earlier in the flow before the values reach the TransactionInfo component, so additional validation at the display level is not needed.
src/components/BottomMenuModal/SendModal/SendModalTokensTabView.tsx (1)
Learnt from: RanaBug
PR: pillarwallet/x#275
File: src/apps/the-exchange/components/DropdownTokensList/DropdownTokenList.tsx:180-195
Timestamp: 2025-03-28T09:22:22.712Z
Learning: In the Exchange app, `swapTokenList` and `receiveTokenList` are derived from `searchTokenResult` when search is active, so including `searchToken` in the useEffect dependency array that uses these lists would be redundant as the lists will update when search results change.
src/apps/the-exchange/hooks/useOffer.tsx (1)
Learnt from: RanaBug
PR: pillarwallet/x#275
File: src/apps/the-exchange/components/DropdownTokensList/DropdownTokenList.tsx:180-195
Timestamp: 2025-03-28T09:22:22.712Z
Learning: In the Exchange app, `swapTokenList` and `receiveTokenList` are derived from `searchTokenResult` when search is active, so including `searchToken` in the useEffect dependency array that uses these lists would be redundant as the lists will update when search results change.
🧬 Code Graph Analysis (1)
src/components/BottomMenuModal/HistoryModal/TransactionInfo.tsx (1)
src/utils/blockchain.ts (1)
  • getBlockScan (218-237)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: lint
  • GitHub Check: unit-tests
  • GitHub Check: build
🔇 Additional comments (10)
src/apps/the-exchange/components/EnterAmount/EnterAmount.tsx (1)

129-129: Clarify slippage tolerance change direction.

The PR objectives mention "increasing the slippage tolerance from 1% to 3%", but this change reduces slippage from 5% (0.05) to 3% (0.03). Please verify this is the intended change and update the PR description accordingly if needed.

src/apps/the-exchange/components/ExchangeAction/ExchangeAction.tsx (1)

99-102: LGTM! Function call updated correctly.

The addition of swapToken parameter aligns properly with the updated getStepTransactions function signature in the useOffer hook. The parameter is correctly sourced from the Redux state.

src/components/BottomMenuModal/HistoryModal/TransactionInfo.tsx (2)

213-213: LGTM! Metadata attribute added correctly.

The data-url attribute correctly matches the URL constructed in the onClick handler for transaction viewing.


237-237: LGTM! Metadata attribute added correctly.

The data-url attribute correctly matches the URL constructed in the onClick handler for blockchain explorer viewing, including the proper isAddress flag usage.

src/components/BottomMenuModal/SendModal/SendModalTokensTabView.tsx (1)

576-577: ESLint suppression added correctly.

The unused variable suppression is appropriate since costAsFiat is calculated but no longer used due to the commented safety warning below.

src/apps/the-exchange/hooks/useOffer.tsx (5)

22-25: LGTM! Necessary imports added.

The import additions for Token and chainNameToChainIdTokensData are required for the enhanced wrapping logic in getStepTransactions.


44-44: LGTM! Slippage parameter added to function signature.

The addition of the slippage parameter enables dynamic slippage control, which aligns with the PR objective of adjusting slippage tolerance.


62-62: LGTM! Slippage parameter correctly utilized.

The slippage parameter is properly passed to the routes request options, enabling the dynamic slippage control.


133-133: LGTM! Token parameter added for enhanced wrapping logic.

The addition of tokenToSwap parameter enables more precise wrapping detection by comparing the actual token to swap against the route token.


139-144: LGTM! Improved wrapping logic prevents unnecessary operations.

The enhanced wrapping logic correctly compares the route token (which may already be wrapped) with the actual token to swap, avoiding unnecessary wrapping steps when the token to swap is already wrapped.

Copy link
Collaborator

@IAmKio IAmKio left a comment

Choose a reason for hiding this comment

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

LGTM

@RanaBug RanaBug merged commit eb56588 into staging Jul 8, 2025
6 checks passed
@coderabbitai coderabbitai bot mentioned this pull request Aug 8, 2025
3 tasks
@coderabbitai coderabbitai bot mentioned this pull request Nov 18, 2025
3 tasks
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.

2 participants