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

Swap calculates the amount of token in instead of token out #20

Open
mehtaphysical opened this issue Apr 15, 2021 · 0 comments
Open

Swap calculates the amount of token in instead of token out #20

mehtaphysical opened this issue Apr 15, 2021 · 0 comments

Comments

@mehtaphysical
Copy link
Contributor

Right now swap is expecting an amount for the token in and will calculate the amount of the token out.

What if we added a feature to set how much token out we want from the swap and then calculate the amount of token in is required. We could do this sort of calculation on the front-end and set the min amount out appropriately, but there is a chance that we over pay and get more out than we wanted.

This would allow people to use the swap for "Buy Now" buttons that allow people to pay in any token:

  • Buyer pays in nDAI
  • nDAI is swapped for sale price
  • Seller receives exactly sale price in wNEAR

With out this, the buyer could receive more wNEAR than the sale price.

If this sounds good I'm happy to make a PR.

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

No branches or pull requests

1 participant