osmosis-frontend icon indicating copy to clipboard operation
osmosis-frontend copied to clipboard

Support swap exact amount out

Open jonator opened this issue 3 years ago • 2 comments

We have implemented all of the pool math/estimates to allow for swapping for a desired out amount. We should allow for this in the frontend.

The simplest approach is to copy what uniswap does by simply allowing the user to type into the "To" amount input. The "From" field will be populated based on pool weight calculations.

Adding to icebox since it hasn't been requested by users.

jonator avatar Jun 28 '22 22:06 jonator

@sunnya97 and I agree this is a super valuable thing to add.

jonator avatar Sep 20 '22 15:09 jonator

Not a good first issue since it would require updates to the pool swap router

jonator avatar Sep 22 '22 18:09 jonator

https://app.clickup.com/t/8677f67a0

Reopen when planning dev

jonator avatar Feb 20 '23 16:02 jonator

Implementation notes:

  • Most work will be done in the trade clipboard component
  • We have an ObservableTradeTokenInConfig, but you may want to make another MobX store for trading the out token.
  • There may or may not need to be changes to the router
  • The math/quote generation logic should all be there, it's currently unused. So you'll mostly be dealing with UI logic and wiring.
  • We may need to add the multihop swap exact amount out message (for swapping through multiple pools). It should be nearly identical to the swap exact amount in message in the account store. We already have the swap exact amount out message (for swapping through a single pool).

jonator avatar Mar 23 '23 16:03 jonator

@jonator I've pushed a PR with some progress on this. Details are in the PR.

spryor avatar Apr 01 '23 02:04 spryor

Closing in favor of tracking on ClickUp

jonator avatar Apr 28 '23 20:04 jonator