Skip to content

A more universal router than Uniswap's Universal Router

License

Notifications You must be signed in to change notification settings

Aureliano90/Muniversal-Router

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Muniversal Router

A more universal router than Uniswap's Universal Router which additionally supports flash swap, chained V2 swaps on any DEX, enabling risk-free arbitrage.

About the universal router

Smart contracts allows EOAs to interact with the blockchain programmatically, to some extent. Unlike Cosmos, each Ethereum transaction can only contain a call to a contract. While the contract called can subsequently call as many other contracts as EVM allows, the sequence of actions is predefined when the contract is deployed. To change the logic or to program the transaction differently, usually a new contract has to be written and deployed, which is a lot of effort and overhead.

While the Multicall contract allows multiple contract calls to be executed sequentially, it has its limitations. On the one hand, using it requires the knowledge and familiarity with ABI encoding/decoding. On the other hand, it lacks certain callback functions required by popular contracts, e.g. onERC721Received, onERC1155Received, uniswapV2Call.

With the advance of Universal Router from Uniswap, one can program transactions offchain and interact with popular contracts/protocols using a more friendly interface without the need to deploy his own contract.

Contract Overview

Command encoding

Refer to the original repo.

   ┌──────┬───────────────────────────────┐
   │ 0x00 │  V3_SWAP_EXACT_IN             │
   ├──────┼───────────────────────────────┤
   │ 0x01 │  V3_SWAP_EXACT_OUT            │
   ├──────┼───────────────────────────────┤
   │ 0x02 │  PERMIT2_TRANSFER_FROM        │
   ├──────┼───────────────────────────────┤
   │ 0x03 │  PERMIT2_PERMIT_BATCH         │
   ├──────┼───────────────────────────────┤
   │ 0x1e-│  -------                      │
   │ 0x3f │                               │
   └──────┴───────────────────────────────┘

Usage

To Install Dependencies

yarn install
forge install

To Format

yarn run prettier

To Compile and Run Tests

forge build
forge test

To Update Gas Snapshots

forge snapshot

About

A more universal router than Uniswap's Universal Router

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Solidity 100.0%