Skip to content

Uniswap/UniswapX

main
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
January 9, 2023 12:13
July 7, 2023 15:49
July 17, 2023 06:18
lib
June 23, 2023 08:19
src
July 17, 2023 06:44
July 17, 2023 06:44
July 17, 2023 13:23

UniswapX

Integration Tests Unit Tests

UniswapX is an ERC20 swap settlement protocol that provides swappers with a gasless experience, MEV protection, and access to arbitrary liquidity sources. Swappers generate signed orders which specify the specification of their swap, and fillers compete using arbitrary fill strategies to satisfy these orders.

UniswapX Protocol Architecture

Architecture

Reactors

Order Reactors settle UniswapX orders. They are responsible for validating orders of a specific type, resolving them into inputs and outputs, and executing them against the filler's strategy, and verifying that the order was successfully fulfilled.

Reactors process orders using the following steps:

  • Validate the order
  • Resolve the order into inputs and outputs
  • Pull input tokens from the swapper to the fillContract using permit2 permitWitnessTransferFrom with the order as witness
  • Call reactorCallback on the fillContract
  • Verify that the output tokens were received by the output recipients

Reactors implement the IReactor interface which abstracts the specifics of the order specification. This allows for different reactor implementations with different order formats to be used with the same interface, allowing for shared infrastructure and easy extension by fillers.

Current reactor implementations:

Fill Contracts

Order fillContracts fill UniswapX orders. They specify the filler's strategy for fulfilling orders and are called by the reactor with reactorCallback.

Some sample fillContract implementations are provided in this repository:

  • SwapRouter02Executor: A fillContract that uses UniswapV2 and UniswapV3 via the SwapRouter02 router

Direct Fill

If a filler wants to fill orders using funds on-hand rather than a fillContract, they can do so gas efficiently using the directFill macro by specifying address(1) as the fillContract. This will pull tokens from the filler using msg.sender to satisfy the order outputs.

Integrating with UniswapX

Jump to the docs for Creating a Filler Integration.

Deployment Addresses

Contract Address Source
Exclusive Dutch Order Reactor 0xe80bF394d190851E215D5F67B67f8F5A52783F1E ExclusiveDutchOrderReactor
OrderQuoter 0x7714520f383C998e8822E8743FD6f90A2979689b OrderQuoter
Permit2 0x000000000022D473030F116dDEE9F6B43aC78BA3 Permit2

Usage

# install dependencies
forge install

# compile contracts
forge build

# run unit tests
forge test

# run integration tests
FOUNDRY_PROFILE=integration forge test

Audit

This codebase was audited by ABDK.

Bug Bounty

This repository is subject to the Uniswap Labs Bug Bounty program, per the terms defined here.

About

πŸ¦„ Gasless ERC20 swap settlement protocol πŸ¦„

Resources

License

Stars

Watchers

Forks

Packages

No packages published