Skip to content
Verified contractExactBUSL-1.1

UsdcReserveBridge

Address0x861f29c253e23cc482a289d6a577a51eb2e483e3
Balance

0 ETH

 

Transactions

0

 

Compiler

solc 0.8.29

 

Same code

Only this contract

 

Details

Compiler
solc 0.8.29+commit.ab55807c
Language
solidity
Optimization
Yes, 200 runs
EVM version
cancun
License
BUSL-1.1
Match
Exactcreation code: yes, runtime code: yes
Verified on Sourcify
Created in block
26,450,191
Creation transaction
0x566359aa9f…c0aa22d74d

src/UsdcReserveBridge.sol

// SPDX-License-Identifier: BUSL-1.1
// Copyright (c) 2026 Hermetica Labs, Inc.
pragma solidity 0.8.29;

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

interface IXReserve {
    function depositToRemote(
        uint256 value,
        uint32 remoteDomain,
        bytes32 remoteRecipient,
        address localToken,
        uint256 maxFee,
        bytes calldata hookData
    ) external;
}

/// @title UsdcReserveBridge
/// @notice Bridges the caller's USDC through Circle xReserve into the USDh redeeming reserve on Stacks
///         (SPN5AKG35QZSK2M8GAMR4AFX45659RJHDW353HSG.redeeming-reserve-v1-2) as USDCx.
/// @dev No owner, no storage, no upgrade path. Every routing value is a constant. `bridge` only pulls from
///      `msg.sender`, so an allowance given to this contract can only be spent by its owner calling `bridge`.
///      `sweep` returns any token balance left in this contract to the treasury Safe.
contract UsdcReserveBridge {
    IERC20 public constant USDC = IERC20(0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48);
    IXReserve public constant XRESERVE = IXReserve(0x8888888199b2Df864bf678259607d6D5EBb4e3Ce);

    /// @notice The treasury's 2-of-3 Safe: the only destination of `sweep`.
    address public constant TREASURY_SAFE = 0x1046a6AD45B60264c83A4b93F6D2c6078C73c1d5;

    /// @notice xReserve domain of Stacks.
    uint32 public constant STACKS_DOMAIN = 10003;

    /// @notice 11 zero bytes, Stacks address version 22 (0x16), hash160 of SPN5AKG35QZSK2M8GAMR4AFX45659RJHDW353HSG.
    bytes32 public constant RESERVE_RECIPIENT = 0x0000000000000000000000162a554e032dff998a8882a98229fd214c54e2516f;

    /// @notice Clarity serialization of { contract-name: "redeeming-reserve-v1-2" }. usdcx-v1 builds the
    ///         contract principal from it; without it, USDCx would mint to the deployer address instead.
    bytes public constant RESERVE_HOOK_DATA =
        hex"0c000000010d636f6e74726163742d6e616d650d0000001672656465656d696e672d726573657276652d76312d32";

    /// @notice Bridges `amount` USDC (6 decimals) from the caller to the redeeming reserve. No relayer fee.
    function bridge(uint256 amount) external {
        require(USDC.transferFrom(msg.sender, address(this), amount), "USDC transferFrom failed");
        require(USDC.approve(address(XRESERVE), amount), "USDC approve failed");
        XRESERVE.depositToRemote(amount, STACKS_DOMAIN, RESERVE_RECIPIENT, address(USDC), 0, RESERVE_HOOK_DATA);
    }

    /// @notice Sends this contract's whole balance of `token` to the treasury Safe, e.g. USDC transferred here by
    ///         mistake. Anyone may call it: the destination is fixed, and `bridge` never leaves a balance behind.
    /// @dev Accepts tokens that return nothing from `transfer` (e.g. USDT).
    function sweep(IERC20 token) external {
        require(address(token).code.length > 0, "not a token");
        uint256 balance = token.balanceOf(address(this));
        (bool ok, bytes memory data) = address(token).call(abi.encodeCall(IERC20.transfer, (TREASURY_SAFE, balance)));
        require(ok && (data.length == 0 || abi.decode(data, (bool))), "token transfer failed");
    }
}
Compiler settingsShow
{
  "viaIR": false,
  "metadata": {
    "appendCBOR": true,
    "bytecodeHash": "ipfs",
    "useLiteralContent": false
  },
  "libraries": {},
  "optimizer": {
    "runs": 200,
    "enabled": true
  },
  "evmVersion": "cancun",
  "remappings": [
    "forge-std/=lib/forge-std/src/"
  ]
}

Source code and metadata: Sourcify.

The source code belongs to the authors of the contract.