SwapProxy

0x02e5be68d46dac0b524905bff209cf47ee6db2a9

Verification
Verified
v0.8.26+commit.8a97fa7a
Type
Contract
1,005 bytes
ABI entries
1
0 read · 1 write
License
gnu_gpl_v3

Contract information

Address
0x02e5be68d46dac0b524905bff209cf47ee6db2a9
Chain
Robinhood Chain (4663)
Compiler
v0.8.26+commit.8a97fa7a
Optimization
Enabled
Creation tx
0x33a2419d00…dd0faa3f62

Token

Not a token

This contract does not expose ERC-20 metadata.

Read contract (0)

No read functions

The ABI is unavailable or exposes no view functions.

ABI

[
  {
    "inputs": [
      {
        "internalType": "contract IUniversalRouter",
        "name": "router",
        "type": "address"
      },
      {
        "internalType": "address",
        "name": "token",
        "type": "address"
      },
      {
        "internalType": "uint256",
        "name": "amount",
        "type": "uint256"
      },
      {
        "internalType": "bytes",
        "name": "commands",
        "type": "bytes"
      },
      {
        "internalType": "bytes[]",
        "name": "inputs",
        "type": "bytes[]"
      },
      {
        "internalType": "uint256",
        "name": "deadline",
        "type": "uint256"
      }
    ],
    "name": "execute",
    "outputs": [],
    "stateMutability": "nonpayable",
    "type": "function"
  }
]

Source code

// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8.24;

import {ERC20} from 'solmate/src/tokens/ERC20.sol';
import {SafeTransferLib} from 'solmate/src/utils/SafeTransferLib.sol';
import {IUniversalRouter} from './interfaces/IUniversalRouter.sol';
import {ISwapProxy} from './interfaces/ISwapProxy.sol';

/// @title SwapProxy
/// @notice Enables 2-tx swap flow (approve + swap) without Permit2 signed messages
/// @dev Transfers tokens from the user directly into the Universal Router (UR), then
///      executes UR commands with payerIsUser=false so the router uses its own balance.
///      This contract is to help with token-inputs, ETH-input actions should be sent directly to the UR.
///      IMPORTANT: All swap commands MUST use payerIsUser=false.
///      All recipient addresses MUST be the user's explicit address, NOT MSG_SENDER,
///      because MSG_SENDER resolves to this proxy contract within the UR execution context.
contract SwapProxy is ISwapProxy {
    using SafeTransferLib for ERC20;

    /// @inheritdoc ISwapProxy
    function execute(
        IUniversalRouter router,
        address token,
        uint256 amount,
        bytes calldata commands,
        bytes[] calldata inputs,
        uint256 deadline
    ) external {
        // Note: Solmate's SafeTransferLib does not check that the token address contains code.
        // Transfer calls to empty addresses silently succeed.
        ERC20(token).safeTransferFrom(msg.sender, address(router), amount);
        router.execute(commands, inputs, deadline);
    }
}
Chain explorer1117msChain node75ms