Skip to content
Verified contractPartialMIT

MigrationIntake

Address0xfb6626917a2ea7cc68ee6ed567cb5232ecb71a78
Balance

0 ETH

 

Transactions

79

 

Compiler

solc 0.8.28

 

Same code

Only this contract

 

Details

Compiler
solc 0.8.28+commit.7893614a
Language
solidity
Optimization
Yes, 200 runs
EVM version
paris
License
MIT
Match
Partialcreation code: yes, runtime code: yes
Verified on Sourcify
Created in block
26,282,546
Creation transaction
0xe62dc1f17a…655eea82ea

MigrationIntake.sol

// SPDX-License-Identifier: MIT
pragma solidity 0.8.28;

/// @title MigrationIntake — burn exactly your snapshot balance of WMTX on Ethereum to claim on Base
/// @notice One transaction per wallet, gated three ways:
///         1. a permit signature (EIP-2612) authorises this contract for exactly the snapshot amount;
///         2. a Merkle proof binds (wallet, amount) to the frozen snapshot root;
///         3. an oracle authorisation (EIP-712, short-lived) proves the portal checked the live
///            eligibility rules for this wallet moments ago.
///         burnFrom then destroys the tokens and Claimed is emitted. The owner can pause (reversible)
///         or close (permanent) and rotate the oracle key; nothing else is adjustable.
/// @dev Leaf and pair hashing follow OpenZeppelin StandardMerkleTree over (address, uint256):
///      leaf = keccak256(bytes.concat(keccak256(abi.encode(account, amount)))), pairs hashed sorted.
///      WMTX gates burnFrom behind BURNER_ROLE: the token admin must grant it to this contract after
///      deployment (and may revoke it when claims close). The role lets this contract burn only what a
///      claimant has itself approved for exactly its snapshot amount.
interface IWMTX {
    function permit(address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) external;
    function burnFrom(address account, uint256 amount) external;
}

contract MigrationIntake {
    bytes32 public immutable ROOT;
    IWMTX public immutable TOKEN;
    bytes32 public immutable DOMAIN_SEPARATOR;
    bytes32 public constant AUTHORIZATION_TYPEHASH = keccak256("ClaimAuthorization(address account,uint256 amount,uint256 expiry)");

    address public owner;
    address public pendingOwner;
    address public oracle;
    bool public paused;
    bool public closed;

    mapping(address => bool) public claimed;

    event Claimed(address indexed account, uint256 amount, uint256 blockNumber);
    event Paused(address indexed by);
    event Unpaused(address indexed by);
    event Closed(address indexed by);
    event OracleUpdated(address indexed previousOracle, address indexed newOracle);
    event OwnershipTransferStarted(address indexed previousOwner, address indexed newOwner);
    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);

    error NotOwner(address caller);
    error NotPendingOwner(address caller);
    error ZeroAddress();
    error IsPaused();
    error IsClosed();
    error AlreadyClaimed(address account);
    error BadProof(address account, uint256 amount);
    error AuthorizationExpired(uint256 expiry, uint256 nowTs);
    error BadAuthorization(address recovered, address oracle);

    modifier onlyOwner() {
        if (msg.sender != owner) revert NotOwner(msg.sender);
        _;
    }

    constructor(address token, bytes32 root, address owner_, address oracle_) {
        if (token == address(0) || owner_ == address(0) || oracle_ == address(0)) revert ZeroAddress();
        TOKEN = IWMTX(token);
        ROOT = root;
        owner = owner_;
        oracle = oracle_;
        DOMAIN_SEPARATOR = keccak256(abi.encode(
            keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"),
            keccak256("WMTX Migration Intake"),
            keccak256("1"),
            block.chainid,
            address(this)
        ));
        emit OwnershipTransferred(address(0), owner_);
        emit OracleUpdated(address(0), oracle_);
    }

    // ---------------------------------------------------------------- claims

    /// @notice Permit + proof + oracle authorisation + burn in one call. The permit is applied
    ///         best-effort: if someone front-runs it (a known griefing pattern) the allowance already
    ///         exists and the burn proceeds anyway.
    /// @param expiry      unix time until which the oracle authorisation is valid
    /// @param authorization  oracle's 65-byte EIP-712 signature over (msg.sender, amount, expiry)
    function claim(
        uint256 amount,
        bytes32[] calldata proof,
        uint256 expiry,
        bytes calldata authorization,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) external {
        try TOKEN.permit(msg.sender, address(this), amount, deadline, v, r, s) {} catch {}
        _claim(amount, proof, expiry, authorization);
    }

    /// @notice Fallback for wallets that cannot sign EIP-2612: approve(this, amount) first, then call.
    function claimApproved(uint256 amount, bytes32[] calldata proof, uint256 expiry, bytes calldata authorization) external {
        _claim(amount, proof, expiry, authorization);
    }

    function _claim(uint256 amount, bytes32[] calldata proof, uint256 expiry, bytes calldata authorization) internal {
        if (closed) revert IsClosed();
        if (paused) revert IsPaused();
        if (claimed[msg.sender]) revert AlreadyClaimed(msg.sender);
        bytes32 leaf = keccak256(bytes.concat(keccak256(abi.encode(msg.sender, amount))));
        if (!_verify(proof, leaf)) revert BadProof(msg.sender, amount);
        if (block.timestamp > expiry) revert AuthorizationExpired(expiry, block.timestamp);
        address signer = _recover(authorizationDigest(msg.sender, amount, expiry), authorization);
        if (signer != oracle) revert BadAuthorization(signer, oracle);
        claimed[msg.sender] = true;
        TOKEN.burnFrom(msg.sender, amount); // reverts unless balance and allowance cover the exact amount
        emit Claimed(msg.sender, amount, block.number);
    }

    /// @notice The EIP-712 digest the oracle signs for (account, amount, expiry).
    function authorizationDigest(address account, uint256 amount, uint256 expiry) public view returns (bytes32) {
        return keccak256(abi.encodePacked("\x19\x01", DOMAIN_SEPARATOR, keccak256(abi.encode(AUTHORIZATION_TYPEHASH, account, amount, expiry))));
    }

    // ---------------------------------------------------------------- owner controls

    function pause() external onlyOwner {
        paused = true;
        emit Paused(msg.sender);
    }

    function unpause() external onlyOwner {
        paused = false;
        emit Unpaused(msg.sender);
    }

    /// @notice Permanent. After this no claim can ever succeed; there is no reopen.
    function close() external onlyOwner {
        closed = true;
        emit Closed(msg.sender);
    }

    function setOracle(address newOracle) external onlyOwner {
        if (newOracle == address(0)) revert ZeroAddress();
        emit OracleUpdated(oracle, newOracle);
        oracle = newOracle;
    }

    function transferOwnership(address newOwner) external onlyOwner {
        if (newOwner == address(0)) revert ZeroAddress();
        pendingOwner = newOwner;
        emit OwnershipTransferStarted(owner, newOwner);
    }

    function acceptOwnership() external {
        if (msg.sender != pendingOwner) revert NotPendingOwner(msg.sender);
        emit OwnershipTransferred(owner, msg.sender);
        owner = msg.sender;
        pendingOwner = address(0);
    }

    // ---------------------------------------------------------------- internals

    function _verify(bytes32[] calldata proof, bytes32 leaf) internal view returns (bool) {
        bytes32 h = leaf;
        for (uint256 i = 0; i < proof.length; i++) {
            bytes32 p = proof[i];
            h = h < p ? keccak256(abi.encodePacked(h, p)) : keccak256(abi.encodePacked(p, h));
        }
        return h == ROOT;
    }

    /// @dev ecrecover with the usual malleability guards; returns address(0) on any malformed input,
    ///      which can never equal a non-zero oracle.
    function _recover(bytes32 digest, bytes calldata sig) internal pure returns (address) {
        if (sig.length != 65) return address(0);
        bytes32 r;
        bytes32 s;
        uint8 v;
        assembly {
            r := calldataload(sig.offset)
            s := calldataload(add(sig.offset, 32))
            v := byte(0, calldataload(add(sig.offset, 64)))
        }
        if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) return address(0);
        if (v != 27 && v != 28) return address(0);
        return ecrecover(digest, v, r, s);
    }
}
Compiler settingsShow
{
  "metadata": {
    "bytecodeHash": "none"
  },
  "optimizer": {
    "runs": 200,
    "enabled": true
  },
  "evmVersion": "paris"
}

Source code and metadata: Sourcify.

The source code belongs to the authors of the contract.