UniversalRouter
0xc6da9c87cae2fcecad79e22c398de16bfab0cfda
Verification
Verified
v0.8.29+commit.ab55807c
Type
Contract
24,282 bytes
ABI entries
62
17 read · 4 write
License
none
Contract information
- Address
- 0xc6da9c87cae2fcecad79e22c398de16bfab0cfda
- Chain
- Robinhood Chain (4663)
- Compiler
- v0.8.29+commit.ab55807c
- Optimization
- Enabled
- Creator
- 0xe8e1a5AF24…E2b2153C3e
- Creation tx
- 0x5e01ec2e38…ee5d99f0d0
Token
Not a token
This contract does not expose ERC-20 metadata.
Read contract (17)
OPTIMISM_CHAIN_ID() → uint256
PERMIT2() → address
UNISWAP_V2_FACTORY() → address
UNISWAP_V2_PAIR_INIT_CODE_HASH() → bytes32
UNISWAP_V3_FACTORY() → address
UNISWAP_V3_POOL_INIT_CODE_HASH() → bytes32
VELODROME_CL_FACTORY() → address
VELODROME_CL_FACTORY_2() → address
VELODROME_CL_FACTORY_3() → address
VELODROME_CL_POOL_INIT_CODE_HASH() → bytes32
VELODROME_CL_POOL_INIT_CODE_HASH_2() → bytes32
VELODROME_CL_POOL_INIT_CODE_HASH_3() → bytes32
VELODROME_V2_FACTORY() → address
VELODROME_V2_INIT_CODE_HASH() → bytes32
WETH9() → address
msgSender() → address
poolManager() → address
Events (3)
CrossChainSwapUniversalRouterBridgeUniversalRouterSwap
ABI
[
{
"inputs": [
{
"components": [
{
"internalType": "address",
"name": "permit2",
"type": "address"
},
{
"internalType": "address",
"name": "weth9",
"type": "address"
},
{
"internalType": "address",
"name": "v2Factory",
"type": "address"
},
{
"internalType": "address",
"name": "v3Factory",
"type": "address"
},
{
"internalType": "bytes32",
"name": "pairInitCodeHash",
"type": "bytes32"
},
{
"internalType": "bytes32",
"name": "poolInitCodeHash",
"type": "bytes32"
},
{
"internalType": "address",
"name": "v4PoolManager",
"type": "address"
},
{
"internalType": "address",
"name": "veloV2Factory",
"type": "address"
},
{
"internalType": "address",
"name": "veloCLFactory",
"type": "address"
},
{
"internalType": "bytes32",
"name": "veloV2InitCodeHash",
"type": "bytes32"
},
{
"internalType": "bytes32",
"name": "veloCLInitCodeHash",
"type": "bytes32"
},
{
"internalType": "address",
"name": "veloCLFactory2",
"type": "address"
},
{
"internalType": "bytes32",
"name": "veloCLInitCodeHash2",
"type": "bytes32"
},
{
"internalType": "address",
"name": "veloCLFactory3",
"type": "address"
},
{
"internalType": "bytes32",
"name": "veloCLInitCodeHash3",
"type": "bytes32"
}
],
"internalType": "struct RouterDeployParameters",
"name": "params",
"type": "tuple"
}
],
"stateMutability": "nonpayable",
"type": "constructor"
},
{
"inputs": [],
"name": "BalanceTooLow",
"type": "error"
},
{
"inputs": [],
"name": "ContractLocked",
"type": "error"
},
{
"inputs": [
{
"internalType": "Currency",
"name": "currency",
"type": "address"
}
],
"name": "DeltaNotNegative",
"type": "error"
},
{
"inputs": [
{
"internalType": "Currency",
"name": "currency",
"type": "address"
}
],
"name": "DeltaNotPositive",
"type": "error"
},
{
"inputs": [],
"name": "ETHNotAccepted",
"type": "error"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "commandIndex",
"type": "uint256"
},
{
"internalType": "bytes",
"name": "message",
"type": "bytes"
}
],
"name": "ExecutionFailed",
"type": "error"
},
{
"inputs": [],
"name": "FromAddressIsNotOwner",
"type": "error"
},
{
"inputs": [],
"name": "InputLengthMismatch",
"type": "error"
},
{
"inputs": [],
"name": "InsufficientBalance",
"type": "error"
},
{
"inputs": [],
"name": "InsufficientETH",
"type": "error"
},
{
"inputs": [],
"name": "InsufficientToken",
"type": "error"
},
{
"inputs": [],
"name": "InvalidBips",
"type": "error"
},
{
"inputs": [
{
"internalType": "uint8",
"name": "bridgeType",
"type": "uint8"
}
],
"name": "InvalidBridgeType",
"type": "error"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "commandType",
"type": "uint256"
}
],
"name": "InvalidCommandType",
"type": "error"
},
{
"inputs": [],
"name": "InvalidEthSender",
"type": "error"
},
{
"inputs": [],
"name": "InvalidPath",
"type": "error"
},
{
"inputs": [],
"name": "InvalidRecipient",
"type": "error"
},
{
"inputs": [],
"name": "InvalidReserves",
"type": "error"
},
{
"inputs": [],
"name": "InvalidTokenAddress",
"type": "error"
},
{
"inputs": [],
"name": "LengthMismatch",
"type": "error"
},
{
"inputs": [],
"name": "NotPoolManager",
"type": "error"
},
{
"inputs": [],
"name": "SliceOutOfBounds",
"type": "error"
},
{
"inputs": [],
"name": "StableExactOutputUnsupported",
"type": "error"
},
{
"inputs": [],
"name": "TransactionDeadlinePassed",
"type": "error"
},
{
"inputs": [],
"name": "UnsafeCast",
"type": "error"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "action",
"type": "uint256"
}
],
"name": "UnsupportedAction",
"type": "error"
},
{
"inputs": [],
"name": "V2InvalidPath",
"type": "error"
},
{
"inputs": [],
"name": "V2TooLittleReceived",
"type": "error"
},
{
"inputs": [],
"name": "V2TooMuchRequested",
"type": "error"
},
{
"inputs": [],
"name": "V3InvalidAmountOut",
"type": "error"
},
{
"inputs": [],
"name": "V3InvalidCaller",
"type": "error"
},
{
"inputs": [],
"name": "V3InvalidSwap",
"type": "error"
},
{
"inputs": [],
"name": "V3TooLittleReceived",
"type": "error"
},
{
"inputs": [],
"name": "V3TooMuchRequested",
"type": "error"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "minAmountOutReceived",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "amountReceived",
"type": "uint256"
}
],
"name": "V4TooLittleReceived",
"type": "error"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "maxAmountInRequested",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "amountRequested",
"type": "uint256"
}
],
"name": "V4TooMuchRequested",
"type": "error"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "caller",
"type": "address"
},
{
"indexed": true,
"internalType": "address",
"name": "localRouter",
"type": "address"
},
{
"indexed": true,
"internalType": "uint32",
"name": "destinationDomain",
"type": "uint32"
},
{
"indexed": false,
"internalType": "bytes32",
"name": "commitment",
"type": "bytes32"
}
],
"name": "CrossChainSwap",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "sender",
"type": "address"
},
{
"indexed": true,
"internalType": "address",
"name": "recipient",
"type": "address"
},
{
"indexed": true,
"internalType": "address",
"name": "token",
"type": "address"
},
{
"indexed": false,
"internalType": "uint256",
"name": "amount",
"type": "uint256"
},
{
"indexed": false,
"internalType": "uint32",
"name": "domain",
"type": "uint32"
}
],
"name": "UniversalRouterBridge",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "sender",
"type": "address"
},
{
"indexed": true,
"internalType": "address",
"name": "recipient",
"type": "address"
}
],
"name": "UniversalRouterSwap",
"type": "event"
},
{
"inputs": [],
"name": "OPTIMISM_CHAIN_ID",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "PERMIT2",
"outputs": [
{
"internalType": "contract IPermit2",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "UNISWAP_V2_FACTORY",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "UNISWAP_V2_PAIR_INIT_CODE_HASH",
"outputs": [
{
"internalType": "bytes32",
"name": "",
"type": "bytes32"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "UNISWAP_V3_FACTORY",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "UNISWAP_V3_POOL_INIT_CODE_HASH",
"outputs": [
{
"internalType": "bytes32",
"name": "",
"type": "bytes32"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "VELODROME_CL_FACTORY",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "VELODROME_CL_FACTORY_2",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "VELODROME_CL_FACTORY_3",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "VELODROME_CL_POOL_INIT_CODE_HASH",
"outputs": [
{
"internalType": "bytes32",
"name": "",
"type": "bytes32"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "VELODROME_CL_POOL_INIT_CODE_HASH_2",
"outputs": [
{
"internalType": "bytes32",
"name": "",
"type": "bytes32"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "VELODROME_CL_POOL_INIT_CODE_HASH_3",
"outputs": [
{
"internalType": "bytes32",
"name": "",
"type": "bytes32"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "VELODROME_V2_FACTORY",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "VELODROME_V2_INIT_CODE_HASH",
"outputs": [
{
"internalType": "bytes32",
"name": "",
"type": "bytes32"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "WETH9",
"outputs": [
{
"internalType": "contract IWETH9",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "bytes",
"name": "commands",
"type": "bytes"
},
{
"internalType": "bytes[]",
"name": "inputs",
"type": "bytes[]"
}
],
"name": "execute",
"outputs": [],
"stateMutability": "payable",
"type": "function"
},
{
"inputs": [
{
"internalType": "bytes",
"name": "commands",
"type": "bytes"
},
{
"internalType": "bytes[]",
"name": "inputs",
"type": "bytes[]"
},
{
"internalType": "uint256",
"name": "deadline",
"type": "uint256"
}
],
"name": "execute",
"outputs": [],
"stateMutability": "payable",
"type": "function"
},
{
"inputs": [],
"name": "msgSender",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "poolManager",
"outputs": [
{
"internalType": "contract IPoolManager",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "int256",
"name": "amount0Delta",
"type": "int256"
},
{
"internalType": "int256",
"name": "amount1Delta",
"type": "int256"
},
{
"internalType": "bytes",
"name": "data",
"type": "bytes"
}
],
"name": "uniswapV3SwapCallback",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "bytes",
"name": "data",
"type": "bytes"
}
],
"name": "unlockCallback",
"outputs": [
{
"internalType": "bytes",
"name": "",
"type": "bytes"
}
],
"stateMutability": "nonpayable",
"type": "function"
},
{
"stateMutability": "payable",
"type": "receive"
}
]Source code
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8.24;
// Command implementations
import {Dispatcher} from './base/Dispatcher.sol';
import {RouterDeployParameters} from './types/RouterDeployParameters.sol';
import {PaymentsImmutables, PaymentsParameters} from './modules/PaymentsImmutables.sol';
import {RouterImmutables, RouterParameters} from './modules/uniswap/RouterImmutables.sol';
import {V4SwapRouter} from './modules/uniswap/v4/V4SwapRouter.sol';
import {Commands} from './libraries/Commands.sol';
import {IUniversalRouter} from './interfaces/IUniversalRouter.sol';
contract UniversalRouter is IUniversalRouter, Dispatcher {
constructor(RouterDeployParameters memory params)
RouterImmutables(RouterParameters(
params.v2Factory,
params.v3Factory,
params.pairInitCodeHash,
params.poolInitCodeHash,
params.veloV2Factory,
params.veloCLFactory,
params.veloV2InitCodeHash,
params.veloCLInitCodeHash,
params.veloCLFactory2,
params.veloCLInitCodeHash2,
params.veloCLFactory3,
params.veloCLInitCodeHash3
))
V4SwapRouter(params.v4PoolManager)
PaymentsImmutables(PaymentsParameters(params.permit2, params.weth9))
{}
modifier checkDeadline(uint256 deadline) {
if (block.timestamp > deadline) revert TransactionDeadlinePassed();
_;
}
/// @notice To receive ETH from WETH
receive() external payable {
if (msg.sender != address(WETH9) && msg.sender != address(poolManager)) revert InvalidEthSender();
}
/// @inheritdoc IUniversalRouter
function execute(bytes calldata commands, bytes[] calldata inputs, uint256 deadline)
external
payable
checkDeadline(deadline)
{
execute(commands, inputs);
}
/// @inheritdoc Dispatcher
function execute(bytes calldata commands, bytes[] calldata inputs) public payable override isNotLocked {
bool success;
bytes memory output;
uint256 numCommands = commands.length;
if (inputs.length != numCommands) revert LengthMismatch();
// loop through all given commands, execute them and pass along outputs as defined
for (uint256 commandIndex = 0; commandIndex < numCommands; commandIndex++) {
bytes1 command = commands[commandIndex];
bytes calldata input = inputs[commandIndex];
(success, output) = dispatch(command, input);
if (!success && successRequired(command)) {
revert ExecutionFailed({commandIndex: commandIndex, message: output});
}
}
}
function successRequired(bytes1 command) internal pure returns (bool) {
return command & Commands.FLAG_ALLOW_REVERT == 0;
}
}
Chain explorer3131msChain node84ms