8000 Swaps fixes by christianbaroni · Pull Request #6573 · rainbow-me/rainbow · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Swaps fixes #6573

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

Merged
merged 19 commits into from
Apr 22, 2025
Merged

Swaps fixes #6573

merged 19 commits into from
Apr 22, 2025

Conversation

christianbaroni
Copy link
Member
@christianbaroni christianbaroni commented Apr 15, 2025

Fixes APP-2566
Fixes APP-2508
Fixes APP-2368
Fixes APP-2568

What changed (plus any additional context for devs)

  • Fixes pricing issues throughout swaps that stemmed from using the prices baked into the input/output assets, instead of the asset pricing baked into the quote. Now preferring quote pricing if it exists for the input/output assets in quote.value.
  • Fixes two issues with wallet switching within swaps: the fact that balances weren’t properly updated, and the input style clipping that occurred after switching accounts. The latter was caused by a swap-provider re-render triggered by useAccountSettings when switching accounts. Now using currency from userAssetsStoreManager to avoid these re-renders.
  • Adds a more complete, type-safe navigateToSwaps helper, which removes all the redundant boilerplate from each swaps entry point
    • Makes it straightforward to e.g. populate specific input/output assets or input fields, or focus a specific input — all settings are optional
    • Initial input and slider values produced by navigateToSwaps are now applied directly — additional changes stemming from the inputValues animated reaction no longer occur on mount
    • Also handles quick buy tracking via a trackQuickBuyMetadata boolean
  • Removes the need for a bunch of type assertions in swap-provider and fixes raps gas types
  • Moves submit/failure swap event tracking to an external trackSwapEvent helper, and removes all JS thread shared value reads
  • Improves the logic around gas fee/maxSwappableAmount
  • Reworks setAsset to avoid shared value JS thread reads and JS/UI thread logic redundancy
    • Now handling input value updates directly in setAsset instead of waiting for an animated reaction to trigger
  • Reworks the updateInputValuesAfterFlip logic to be clearer and more predictable
  • Now refocusing swaps search inputs after the network selector is closed, if an input was previously focused
  • Cleans up the useSwapInputsController animated reactions to limit redundant logic and remove unnecessary work
  • Fixes swaps warning layout issues, and updates swap warnings more explicitly in response to specific shared value changes (via useAnimatedReaction instead of useDerivedValue) to prevent erratic updates
  • Fixes a couple edge cases in SwapNumberPad where fetches were being triggered for certain edits to the input value that didn't result in the number actually changing (e.g. adding/removing a decimal point, adding/removing zeros to the end of a number containing a decimal point)
  • Adds a No Balance state to the slider which snaps the slider back to zero if there's no input balance

Screen recordings / screenshots

What to test

Copy link
Contributor
@ibrahimtaveras00 ibrahimtaveras00 left a comment

Choose a reason for hiding this comment

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

Screenshot 2025-04-16 at 8 53 41 PM

Original issue I reported on slack has been fixed ✅

Also spot checked other swaps and looks good 👍🏽

@christianbaroni christianbaroni marked this pull request as ready for review April 17, 2025 17:08
@walmat walmat removed their request for review April 17, 2025 18:06
@brunobar79
Copy link
Contributor

Launch in simulator or device for b1ef53e

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.

A lot going on here, did a lot of testing and didn't find anything blocking. Code looks good 👍

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.

Tried a bunch of wacky scenarios and didn't encounter any issues. No nits after a cursory look through all the changes.

Copy link
linear bot commented Apr 18, 2025

@brunobar79
Copy link
Contributor

Launch in simulator or device for 6a89e43

@brunobar79
Copy link
Contributor

Launch in simulator or device for 2b9f106

@christianbaroni christianbaroni merged commit 052a80b into develop Apr 22, 2025
7 of 8 checks passed
@christianbaroni christianbaroni deleted the @christian/swaps-bug-fixes branch April 22, 2025 04:01
derHowie pushed a commit that referenced this pull request Apr 23, 2025
* Rework `navigateToSwaps`

* Swaps bug fixes, performance improvements

* Clean up remote config, fix slippage types

* Clean up `AnimatedSpinner` image on unmount

* Push missing files, lint fixes

* Lint

* Separate chain badge improvements

* Separate user assets store type fixes, clean up error supression

* Ensure `getSwapsNavigationParams` always returns valid params

Haven't ever seen this happen, just in case due to the current lack of proper navigation typing

* Fix swaps network selection input handling

* Prevent swaps inputs from clearing unless `Cancel` is pressed, rework network selector handling

* Prevent swap input re-render

* Limit erratic gas state updates, propagate balance updates in swaps after account switches

* Allow user assets to refresh while swaps is open

* Remove unnecessary `useCleanupOnUnmount` component wrapper

* Fix remaining `hasEnoughFundsForGas` / `maxSwappableAmount` edge cases

* Reduce size of `FlipButton` hit box

* Handle negative `decimalPlaces` in `scaleUpWorklet`
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.

5 participants
0