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

Gasless Transactions #54

Open
calebsheridan opened this issue May 25, 2021 · 1 comment
Open

Gasless Transactions #54

calebsheridan opened this issue May 25, 2021 · 1 comment

Comments

@calebsheridan
Copy link

Description

ArcherSwapRouter contract enable users to pay for tips using tokens. We would like to surface this feature on the application.

New Option

Pay with tokens (on/off) - default off

Behavior

When pay with tokens is enabled, the tip should be paid with the "destination" tokens. The UI should reflect this payment in tokens.

When pay with tokens is disabled, the existing functionality should be used (pay in eth).

@chpiatt
Copy link
Contributor

chpiatt commented May 26, 2021

Practically, what is needed to implement this is some toggle in the user interface (checkbox, toggle switch, etc) that lets a user choose whether 'Gasless Transactions' are enabled. It should probably be disabled by default. We probably also want to add a tooltip to this toggle that explains that you are paying for the transaction as a % of the tokens you are trading (they aren't free).

If this toggle is set to true, then instead of calculating the miner tip in advance and calling:

  • swapExactTokensforETHAndTipAmount
  • swapExactTokensforTokensAndTipAmount
  • swapTokensForExactETHAndTipAmount
  • swapTokensForExactTokensAndTipAmount

We estimate the amount of the resulting ETH we expect from the trade and calculate the tip as % of that ETH that equates to the roughly same effective gas price. We then use that % as an input in the following methods:

  • swapExactTokensforETHAndTipPct
  • swapExactTokensforTokensAndTipPct
  • swapTokensForExactETHAndTipPct
  • swapTokensForExactTokensAndTipPct

The implementation for swapping tokens to ETH will be easier because you are already estimating the ETH output as part of the original trade. Swapping tokens for tokens will be a little trickier because in addition to estimating the original trade from Token A -> Token B, you will also need to estimate an additional trade from Token B -> ETH and include both trade 'paths' as params to the function call.

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

2 participants