GithubHelp home page GithubHelp logo

archerswap's Introduction

Archerswap

Archerswap is a proof-of concept DEX extension that allows users to execute Uniswap and Sushiswap trades without having to worry about:

  • Slippage
  • Frontrunning/Sandwich Attacks
  • Failed Transaction Cost
  • Transaction Cancellation Cost

How It Works

Instead of paying gas, users pay miners directly via a "Miner Tip". Trades are then routed through the Archer Relay network. Archer Relayers will attempt to execute the trade each block until the trade expires (as determined by the trade deadline specified when submitting the trade) or the user manually cancels the transaction.

Users pay nothing if the trade expires or is cancelled. The user can simply resubmit the trade if they choose to try again (possibly with higher slippage,lower target price, and/or a larger miner tip to increase their chances).

Link

Archer is currently in Alpha. Executing trades through Archer is generally safe, but the biggest risk is a phishing attack.

Users should be careful and only submit trades directly on: https://swap.archerdao.io

We recommend bookmarking this URL to ensure safety.

archerswap's People

Contributors

chpiatt avatar dependabot-preview[bot] avatar dependabot[bot] avatar johnkcr avatar jquesnelle avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

archerswap's Issues

Invalid Nonces

Description

If a nonce is used, any trades for that nonce are invalid. They should change to invalid state.

Implementation Details

tbd

Gasless Transactions

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).

Modify default tip implementation

As of now, we use a naive DEFAULT_ETH_TIP value to calculate the miner tip before a successful trade/gas estimation occurs. This is not ideal for a few reasons:

  • It is a single value, and now with the slider it makes more sense to have multiple default values so that even before gas estimation the slider still responds with different values for each tick on the slider
  • It doesn't respond to current market conditions w/r/t effective gas prices - if we know the current effective gas prices but we don't yet have a successful gas estimate for the trade we should still adjust the tip to respond to the gas prices anyway to better reflect current market conditions

Suggested implementation:

  • Instead of DEFAULT_ETH_TIP we should have a DEFAULT_GAS_ESTIMATE that is roughly equal to the average gas usage of a Archerswap trade (250,000 seems likes a reasonable default for now - probably better to be on the high side for UX reasons)
  • Create a new default ARRAY called DEFAULT_EFFECTIVE_GAS_PRICES (one for each tick of the slider) - suggested defaults: [60000000000, 70000000000, 100000000000, 140000000000, 300000000000, 800000000000, 2000000000000]
  • The default miner tip value for each tick of the slider will then be DEFAULT_GAS_ESTIMATE * DEFAULT_EFFECTIVE_GAS_PRICES[index]
  • Whenever we successfully fetch current effective gas prices from the server, replace the default values with these values
  • Whenever a new trade is generated via the UI and the estimateGas call is successful, replace DEFAULT_GAS_ESTIMATE with the actual gas estimate

Add Manage Transactions Section

Background

Currently, pending transactions sent through Archer are included in the same area as "Recent Transactions". This is confusing in part because rows with options to manage active tx are included with rows that are known to be read only.

As part of the original change, we changed the logic of how "Clear" works, which should be rolled back for the existing section and included in the new section.

Order Section Description
1 Manage Transactions New section, for managing Archer Trades
2 Recent Transactions Existing section, lists all activity

Scope

  • Add new section
  • Rollback logic on existing section

Out of scope

  • Changes related to the "status" of pending Archer tx.
  • Tx management functionality.

Pending Transaction Deadline

Background

Pending trades are valid until their deadline, at which they become invalid.

Description

We should show an indication of each trade's deadline in the Pending Transaction modal, with information about how many minutes remain for the trade to be valid.

Once a trade expires, the UI should show that the trade has expired and is no longer considered Pending.

Allow use of 'permit' for approvals

The Uni v3 frontend has added basic support for tokens that use permit for approvals, see:
https://github.com/Uniswap/uniswap-interface/blob/main/src/hooks/useERC20Permit.ts

Archerswap router also includes support for 'permit' for each of the swap functions, see:

function swapExactTokensForETHWithPermitAndTipAmount(

We should add support for the same permit flow used in the Uniswap V3 interface.

To begin with, we can just support the same PERMITTABLE_TOKENS that Uni V3 is supporting + ARCH (ARCH uses PermitType.AMOUNT).

Miner tip flickers

Description

The miner tip flickers at various points in the UI.

Simple steps to recreate: set up a trade and watch the miner tip update over a few blocks.

Areas observed

When connected and estimating a swap, the miner tip flickers between the default value and estimated value.

  • Connect
  • Select tokens
  • See Miner tip field

When connected and confirming a swap, the miner tip flickers between the estimated value and newly estimated value.

  • Connect
  • Select tokens
  • Press "Swap" to open Confirm Swap modal
  • See Miner tip field

When connected and signing a swap, the miner tip flickers between the value being signed and newly estimated value.

  • Connect
  • Select tokens
  • Press "Swap" to open Confirm Swap modal
  • Press "Confirm" to open Pending Transaction modal
  • See Miner tip text

Related issue

The miner tip will replace a recent estimate with default value, then a new estimate. For example:

  • 0.067483
  • 0.05
  • 0.064209

It may be more accurate to avoid the default and use the previous estimate. Even if gas usage changes (due to a user interaction), the tip should be closer to market conditions than the default more often.

Cancel Transaction Resets Tokens

Background

Users can cancel transactions for free, to try them again.

Expected behavior

After press "Cancel" on a transaction, it is possible to make the same trade (accepting any price updates) again easily.

Actual behavior

After pressing "Cancel" on a transaction, the selected tokens are reset to defaults (ETH -> select token). It is difficult to continue trading flow.

Adjusting the miner tip should adjust the amount of ETH input automatically

When a user selects ETH as the input asset, we should automatically adjust the input amount to account for the miner tip.

Selecting "MAX" in this case should result in the max ETH in the user's wallet minus the current miner tip.

Any time that the miner tip is updated (by adjusting the slider, setting the tip manually, or any new estimateGas call - i.e. those triggered on each new block or when the user adjusts any input to the trade), we should check that the input amount of ETH + the miner tip is not more than the user currently has in their wallet and if it is, automatically adjust the input ETH amount to the new max amount.

Add Intro Message

Description

Current swap application uses a different transaction pattern (tip vs gas). We would like users to get more information about the application and its benefits.

On-boarding Message

The on-boarding message should display about the swap component, using an existing UI component (as seen on Governance section). Its content should link users to this blog post describing the application.

Mockup

Note: colors should match application -- not as seen here.

Screenshot 2021-05-25 at 11 12 35

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.