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 inconsistencies between swaps store slippage and shared value #6399

Merged
merged 2 commits into from
Jan 22, 2025

Conversation

walmat
Copy link
Contributor

@walmat walmat commented Jan 14, 2025

Fixes APP-2255

What changed (plus any additional context for devs)

1. Swap Navigation Parameters Enhancement

State Management

  • Added slippage parameter handling in getSwapsNavigationParams
  • Improved default value handling for input/output assets
  • Added chainId fallback to mainnet

Parameter Processing

  • Added validation for slippage parameter
  • Implemented conversion from basis points to string format
  • Added integration with remote config for default slippage values

Code Organization

  • Moved state retrieval to top of function
  • Consolidated asset parameter handling
  • Added proper type safety for parameters

2. Swap Provider Updates

State Management

  • Removed direct worklet call for default slippage
  • Now uses navigation parameters for initial slippage value
  • Maintained existing haptics and analytics integration

Code Cleanup

  • Removed unused imports
  • Simplified parameter initialization
  • Improved type definitions

This PR improves the swap navigation parameter handling by adding proper slippage management and better state organization while maintaining existing functionality.

Screen recordings / screenshots

Simulator.Screen.Recording.-.iPhone.16.Pro.-.2025-01-14.at.12.24.57.mp4

What to test

test swaps on different chains and see the minimum value received changes with the slippage change

Copy link

linear bot commented Jan 14, 2025

@brunobar79
Copy link
Member

Launch in simulator or device for 0413473

@walmat walmat requested review from derHowie and maxbbb January 15, 2025 18:15
Copy link
Member

@derHowie derHowie left a comment

Choose a reason for hiding this comment

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

lgtm

Copy link
Contributor

@maxbbb maxbbb left a comment

Choose a reason for hiding this comment

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

Adding the ability to set the slippage in the route params is good but none of the current routes to swaps were trying to do that, and the fallback logic is the same as before so I'm not understanding how this fixes the linked issue.

@walmat
Copy link
Contributor Author

walmat commented Jan 17, 2025

Adding the ability to set the slippage in the route params is good but none of the current routes to swaps were trying to do that, and the fallback logic is the same as before so I'm not understanding how this fixes the linked issue.

That wasn't the issue. The issue was with the shared value and swaps store value being out of sync with one another, which is fixed in this PR. That deeplink / route param fix is just another one I noticed during investigating.

@brunobar79
Copy link
Member

Launch in simulator or device for d11ea69

@maxbbb maxbbb self-requested a review January 22, 2025 14:07
@walmat walmat merged commit 7c716cb into develop Jan 22, 2025
8 checks passed
@walmat walmat deleted the @matthew/APP-2255 branch January 22, 2025 14:10
derHowie pushed a commit that referenced this pull request Jan 23, 2025
)

* fix inconsistent slippage between swaps store and shared values

* fix initial swaps store value being stale from incoming initial params
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