WT-1753 Factor in balance requirement for swap route and when getting amount to bridge for bridge to swap route #938
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR ensures we are properly factoring in the balance requirements (the amounts needed of imx and erc20s to perform the action) when trying to swap and when trying to do a bridge->swap
The swap has been updated to check the balance requirements before doing a swap to ensure the user has enough balance to cover both the amount to be swapped and the balance requirement.
The bridge->swap has been updated when constructing the amount to bridge. This now ensures if we have a balance requirement for the token we are also trying to bridge->swap that the amount bridged over covers enough to handle both swapping the amount and the balance requirement.