Skip to content
Verified contractExactMIT

UsdcTreasurySpender

Address0xd803cfdb47494afd2e67d042c5fe0872372d1345
Balance

0 ETH

 

Transactions

2

 

Compiler

solc 0.8.30

 

Same code

1 more contract

 

Details

Compiler
solc 0.8.30+commit.73712a01
Language
solidity
Optimization
Yes, 200 runs
EVM version
shanghai
License
MIT
Match
Exactcreation code: yes, runtime code: yes
Verified on Sourcify
Created in block
26,415,675
Creation transaction
0x5471d47762…9e27d2a42a

UsdcTreasurySpender.sol

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;

/// @notice A USDC allowance target with one operator and one fixed treasury.
/// @dev The contract never holds USDC and cannot send an approved owner's funds elsewhere.
contract UsdcTreasurySpender {
    address public constant USDC = 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48;
    address public immutable operator;
    address public immutable treasury;

    error Unauthorized();
    error InvalidAddress();
    error InvalidAmount();
    error TransferFailed();

    event Pulled(address indexed owner, uint256 amount);

    constructor(address operator_, address treasury_) {
        if (block.chainid != 1) revert Unauthorized();
        if (operator_ == address(0) || treasury_ == address(0) || treasury_ == USDC || USDC.code.length == 0) revert InvalidAddress();
        operator = operator_;
        treasury = treasury_;
    }

    function pull(address owner, uint256 amount) external {
        if (msg.sender != operator) revert Unauthorized();
        if (owner == address(0) || owner == treasury) revert InvalidAddress();
        if (amount == 0) revert InvalidAmount();
        (bool ok, bytes memory response) = USDC.call(
            abi.encodeWithSelector(0x23b872dd, owner, treasury, amount)
        );
        if (!ok || response.length != 32 || !abi.decode(response, (bool))) revert TransferFailed();
        emit Pulled(owner, amount);
    }
}
Compiler settingsShow
{
  "metadata": {
    "bytecodeHash": "ipfs"
  },
  "libraries": {},
  "optimizer": {
    "runs": 200,
    "enabled": true
  },
  "evmVersion": "shanghai",
  "remappings": []
}

Source code and metadata: Sourcify.

The source code belongs to the authors of the contract.