Skip to content
Verified contractExactMIT

YoCctpxAdapter

Address0x9862b2d58b4aa332dfdfc5804666c802267fdae9
Balance

0 ETH

 

Transactions

0

 

Compiler

solc 0.8.34

 

Same code

Only this contract

 

Details

Compiler
solc 0.8.34+commit.80d5c536
Language
solidity
Optimization
Yes, 10,000 runs
EVM version
cancun
Via IR
yes
License
MIT
Match
Exactcreation code: yes, runtime code: yes
Verified on Sourcify
Created in block
26,307,157
Creation transaction
0x9e920a37ab…f26ff1b5d0

src/adapters/cctpx/YoCctpxAdapter.sol

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

import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";

import { ICrossChainTokenService } from "../../interfaces/external/ICrossChainTokenService.sol";
import { IYoBridgeRouteRegistry } from "../../interfaces/IYoBridgeRouteRegistry.sol";
import { IYoCctpxAdapter } from "../../interfaces/IYoCctpxAdapter.sol";
import { IYoRegistry } from "../../interfaces/IYoRegistry.sol";
import { YoAdapterBase } from "../base/YoAdapterBase.sol";

/// @title  YoCctpxAdapter
/// @notice Immutable adapter for Circle "CCTP for non-USDC" (CCTPx) burn-and-mint transfers of one
///         pinned token (e.g. EURC). See `IYoCctpxAdapter` for the approval / route / fee contract.
/// @dev    INVARIANTS:
///           - `msg.sender` is the vault when invoked via `YoVault.manage(...)`.
///           - The token and its CCTPx `tokenId` are pinned at construction; nothing else can be bridged.
///           - Funds may only leave to a route allowlisted in `routeRegistry`.
///           - Delivery goes to the raw 20-byte allowlisted `recipient` only, is relayable by anyone
///             (`destinationCaller == 0`), and runs no destination hook, so the adapter adds no strand
///             vector. Delivery still depends on Circle-side state (see `IYoCctpxAdapter`).
///           - Fee refunds are attributed to the vault, never to an operator-chosen address.
///           - The native fee is paid ONLY from `msg.value`, capped at `maxNativeFee`, and the
///             service must forward all of it as the fee: it neither keeps an excess nor tops up a
///             shortfall from its own balance.
///           - Each call leaks zero new balance / zero allowance to the `TokenManager`; pre-existing
///             dust is recoverable by registered YO vaults via `rescue` / `rescueETH` (see
///             {YoAdapterBase}).
contract YoCctpxAdapter is YoAdapterBase, IYoCctpxAdapter {
    using SafeERC20 for IERC20;

    /// @notice `minFinalityThreshold` of a fast transfer (needs a `PRE_FINALITY` quote item).
    uint32 public constant FINALITY_FAST = 1000;

    /// @notice `minFinalityThreshold` of a standard transfer (attested at finality).
    uint32 public constant FINALITY_STANDARD = 2000;

    /// @notice The CCTPx `CrossChainTokenService` this adapter transfers through.
    ICrossChainTokenService public immutable service;

    /// @notice The token transferred on this chain. Pinned at construction.
    IERC20 public immutable token;

    /// @notice The CCTPx cross-chain id of `token`. Pinned at construction.
    bytes32 public immutable tokenId;

    /// @notice Allowlist of permitted `(vault, adapter, token, destinationDomain, recipient)` routes.
    IYoBridgeRouteRegistry public immutable routeRegistry;

    /// @notice Max native fee (`msg.value`) tolerated per transfer, in wei.
    uint256 public immutable maxNativeFee;

    constructor(
        ICrossChainTokenService _service,
        IERC20 _token,
        bytes32 _tokenId,
        IYoBridgeRouteRegistry _routeRegistry,
        uint256 _maxNativeFee,
        IYoRegistry _yoRegistry
    )
        YoAdapterBase(_yoRegistry)
    {
        // Fail the deployment on a token / tokenId mismatch: the TokenManager would pull a different
        // token than the one the vault approved, so every transfer would revert.
        address registered = _service.resolveTokenAddress(_tokenId);
        if (registered != address(_token)) {
            revert TokenMismatch(address(_token), registered);
        }
        service = _service;
        token = _token;
        tokenId = _tokenId;
        routeRegistry = _routeRegistry;
        maxNativeFee = _maxNativeFee;
    }

    /// @inheritdoc IYoCctpxAdapter
    function crossChainTransfer(
        uint256 amount,
        uint32 destinationDomain,
        address recipient,
        uint32 minFinalityThreshold,
        bytes calldata signedQuote
    )
        external
        payable
        nonReentrant
        returns (uint256)
    {
        if (amount == 0) {
            revert InvalidAmount();
        }
        // CCTPx accepts a zero recipient on the source but reverts its delivery, which would strand
        // the burned tokens. Reject it even if a zero route were ever allowlisted.
        if (recipient == address(0)) {
            revert InvalidRecipient();
        }
        // Only the two documented tiers: any other value either pays the fast fee for a standard
        // attestation or depends on undocumented attester behaviour.
        if (minFinalityThreshold != FINALITY_FAST && minFinalityThreshold != FINALITY_STANDARD) {
            revert InvalidFinalityThreshold(minFinalityThreshold);
        }
        if (msg.value > maxNativeFee) {
            revert NativeFeeTooHigh(msg.value, maxNativeFee);
        }
        address vault = msg.sender;
        // CCTPx mints the same token on the destination, so no output token is pinned (`bytes32(0)`).
        if (!routeRegistry.isRouteAllowed(
                vault,
                address(this),
                address(token),
                destinationDomain,
                bytes32(uint256(uint160(recipient))),
                bytes32(0)
            )) {
            revert RouteNotAllowed(destinationDomain, recipient);
        }

        token.safeTransferFrom(vault, address(this), amount);
        // The per-token TokenManager pulls the tokens, so it (not the service) is the spender.
        address tokenManager = service.resolveTokenManager(tokenId);
        token.forceApprove(tokenManager, amount);

        _transfer(amount, destinationDomain, recipient, minFinalityThreshold, signedQuote);

        token.forceApprove(tokenManager, 0);

        _emitAction(address(service), address(token), AdapterDirection.Bridge, amount);
        return amount;
    }

    /// @dev Dispatch to the service with the delivery parameters fixed here rather than supplied by the
    ///      operator: the raw 20-byte recipient (CCTPx reverts delivery on a 32-byte encoding), any
    ///      relayer (`bytes32(0)`, no strand vector), no destination hook, and fee refunds attributed to
    ///      the vault.
    ///
    ///      The service pays the signed quote's total fee out of its OWN balance: it keeps any excess
    ///      `msg.value` and silently covers a shortfall from ETH earlier callers left behind. Requiring
    ///      its balance to be unchanged proves it spent exactly `msg.value` and none of its own ETH —
    ///      measured, not mirrored from Circle's quote decoding. That the spent ETH is the quoted fee
    ///      (and not, say, an excess the fee manager keeps) is Circle-trusted; `maxNativeFee` bounds it.
    function _transfer(
        uint256 amount,
        uint32 destinationDomain,
        address recipient,
        uint32 minFinalityThreshold,
        bytes calldata signedQuote
    )
        private
    {
        uint256 serviceBalance = address(service).balance;

        service.crossChainTransfer{ value: msg.value }(
            tokenId,
            amount,
            destinationDomain,
            abi.encodePacked(recipient),
            bytes32(0),
            minFinalityThreshold,
            ICrossChainTokenService.QuoteClaim({ signedQuote: signedQuote, refundAddress: payable(msg.sender) }),
            false,
            ""
        );

        uint256 serviceBalanceAfter = address(service).balance;
        if (serviceBalanceAfter != serviceBalance) {
            // The fee actually charged: `serviceBalance + msg.value - serviceBalanceAfter`. This only
            // underflows if the service gained ETH from elsewhere during the call, which still reverts.
            revert IncorrectNativeFee(msg.value, serviceBalance + msg.value - serviceBalanceAfter);
        }
    }
}

node_modules/@openzeppelin/contracts/interfaces/IERC1363.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (interfaces/IERC1363.sol)

pragma solidity >=0.6.2;

import {IERC20} from "./IERC20.sol";
import {IERC165} from "./IERC165.sol";

/**
 * @title IERC1363
 * @dev Interface of the ERC-1363 standard as defined in the https://eips.ethereum.org/EIPS/eip-1363[ERC-1363].
 *
 * Defines an extension interface for ERC-20 tokens that supports executing code on a recipient contract
 * after `transfer` or `transferFrom`, or code on a spender contract after `approve`, in a single transaction.
 */
interface IERC1363 is IERC20, IERC165 {
    /*
     * Note: the ERC-165 identifier for this interface is 0xb0202a11.
     * 0xb0202a11 ===
     *   bytes4(keccak256('transferAndCall(address,uint256)')) ^
     *   bytes4(keccak256('transferAndCall(address,uint256,bytes)')) ^
     *   bytes4(keccak256('transferFromAndCall(address,address,uint256)')) ^
     *   bytes4(keccak256('transferFromAndCall(address,address,uint256,bytes)')) ^
     *   bytes4(keccak256('approveAndCall(address,uint256)')) ^
     *   bytes4(keccak256('approveAndCall(address,uint256,bytes)'))
     */

    /**
     * @dev Moves a `value` amount of tokens from the caller's account to `to`
     * and then calls {IERC1363Receiver-onTransferReceived} on `to`.
     * @param to The address which you want to transfer to.
     * @param value The amount of tokens to be transferred.
     * @return A boolean value indicating whether the operation succeeded unless throwing.
     */
    function transferAndCall(address to, uint256 value) external returns (bool);

    /**
     * @dev Moves a `value` amount of tokens from the caller's account to `to`
     * and then calls {IERC1363Receiver-onTransferReceived} on `to`.
     * @param to The address which you want to transfer to.
     * @param value The amount of tokens to be transferred.
     * @param data Additional data with no specified format, sent in call to `to`.
     * @return A boolean value indicating whether the operation succeeded unless throwing.
     */
    function transferAndCall(address to, uint256 value, bytes calldata data) external returns (bool);

    /**
     * @dev Moves a `value` amount of tokens from `from` to `to` using the allowance mechanism
     * and then calls {IERC1363Receiver-onTransferReceived} on `to`.
     * @param from The address which you want to send tokens from.
     * @param to The address which you want to transfer to.
     * @param value The amount of tokens to be transferred.
     * @return A boolean value indicating whether the operation succeeded unless throwing.
     */
    function transferFromAndCall(address from, address to, uint256 value) external returns (bool);

    /**
     * @dev Moves a `value` amount of tokens from `from` to `to` using the allowance mechanism
     * and then calls {IERC1363Receiver-onTransferReceived} on `to`.
     * @param from The address which you want to send tokens from.
     * @param to The address which you want to transfer to.
     * @param value The amount of tokens to be transferred.
     * @param data Additional data with no specified format, sent in call to `to`.
     * @return A boolean value indicating whether the operation succeeded unless throwing.
     */
    function transferFromAndCall(address from, address to, uint256 value, bytes calldata data) external returns (bool);

    /**
     * @dev Sets a `value` amount of tokens as the allowance of `spender` over the
     * caller's tokens and then calls {IERC1363Spender-onApprovalReceived} on `spender`.
     * @param spender The address which will spend the funds.
     * @param value The amount of tokens to be spent.
     * @return A boolean value indicating whether the operation succeeded unless throwing.
     */
    function approveAndCall(address spender, uint256 value) external returns (bool);

    /**
     * @dev Sets a `value` amount of tokens as the allowance of `spender` over the
     * caller's tokens and then calls {IERC1363Spender-onApprovalReceived} on `spender`.
     * @param spender The address which will spend the funds.
     * @param value The amount of tokens to be spent.
     * @param data Additional data with no specified format, sent in call to `spender`.
     * @return A boolean value indicating whether the operation succeeded unless throwing.
     */
    function approveAndCall(address spender, uint256 value, bytes calldata data) external returns (bool);
}

node_modules/@openzeppelin/contracts/interfaces/IERC165.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (interfaces/IERC165.sol)

pragma solidity >=0.4.16;

import {IERC165} from "../utils/introspection/IERC165.sol";

node_modules/@openzeppelin/contracts/interfaces/IERC20.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (interfaces/IERC20.sol)

pragma solidity >=0.4.16;

import {IERC20} from "../token/ERC20/IERC20.sol";

node_modules/@openzeppelin/contracts/token/ERC20/IERC20.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (token/ERC20/IERC20.sol)

pragma solidity >=0.4.16;

/**
 * @dev Interface of the ERC-20 standard as defined in the ERC.
 */
interface IERC20 {
    /**
     * @dev Emitted when `value` tokens are moved from one account (`from`) to
     * another (`to`).
     *
     * Note that `value` may be zero.
     */
    event Transfer(address indexed from, address indexed to, uint256 value);

    /**
     * @dev Emitted when the allowance of a `spender` for an `owner` is set by
     * a call to {approve}. `value` is the new allowance.
     */
    event Approval(address indexed owner, address indexed spender, uint256 value);

    /**
     * @dev Returns the value of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

    /**
     * @dev Returns the value of tokens owned by `account`.
     */
    function balanceOf(address account) external view returns (uint256);

    /**
     * @dev Moves a `value` amount of tokens from the caller's account to `to`.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transfer(address to, uint256 value) external returns (bool);

    /**
     * @dev Returns the remaining number of tokens that `spender` will be
     * allowed to spend on behalf of `owner` through {transferFrom}. This is
     * zero by default.
     *
     * This value changes when {approve} or {transferFrom} are called.
     */
    function allowance(address owner, address spender) external view returns (uint256);

    /**
     * @dev Sets a `value` amount of tokens as the allowance of `spender` over the
     * caller's tokens.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * IMPORTANT: Beware that changing an allowance with this method brings the risk
     * that someone may use both the old and the new allowance by unfortunate
     * transaction ordering. One possible solution to mitigate this race
     * condition is to first reduce the spender's allowance to 0 and set the
     * desired value afterwards:
     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
     *
     * Emits an {Approval} event.
     */
    function approve(address spender, uint256 value) external returns (bool);

    /**
     * @dev Moves a `value` amount of tokens from `from` to `to` using the
     * allowance mechanism. `value` is then deducted from the caller's
     * allowance.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(address from, address to, uint256 value) external returns (bool);
}

node_modules/@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.5.0) (token/ERC20/utils/SafeERC20.sol)

pragma solidity ^0.8.20;

import {IERC20} from "../IERC20.sol";
import {IERC1363} from "../../../interfaces/IERC1363.sol";

/**
 * @title SafeERC20
 * @dev Wrappers around ERC-20 operations that throw on failure (when the token
 * contract returns false). Tokens that return no value (and instead revert or
 * throw on failure) are also supported, non-reverting calls are assumed to be
 * successful.
 * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
 * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
 */
library SafeERC20 {
    /**
     * @dev An operation with an ERC-20 token failed.
     */
    error SafeERC20FailedOperation(address token);

    /**
     * @dev Indicates a failed `decreaseAllowance` request.
     */
    error SafeERC20FailedDecreaseAllowance(address spender, uint256 currentAllowance, uint256 requestedDecrease);

    /**
     * @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,
     * non-reverting calls are assumed to be successful.
     */
    function safeTransfer(IERC20 token, address to, uint256 value) internal {
        if (!_safeTransfer(token, to, value, true)) {
            revert SafeERC20FailedOperation(address(token));
        }
    }

    /**
     * @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the
     * calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.
     */
    function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
        if (!_safeTransferFrom(token, from, to, value, true)) {
            revert SafeERC20FailedOperation(address(token));
        }
    }

    /**
     * @dev Variant of {safeTransfer} that returns a bool instead of reverting if the operation is not successful.
     */
    function trySafeTransfer(IERC20 token, address to, uint256 value) internal returns (bool) {
        return _safeTransfer(token, to, value, false);
    }

    /**
     * @dev Variant of {safeTransferFrom} that returns a bool instead of reverting if the operation is not successful.
     */
    function trySafeTransferFrom(IERC20 token, address from, address to, uint256 value) internal returns (bool) {
        return _safeTransferFrom(token, from, to, value, false);
    }

    /**
     * @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
     * non-reverting calls are assumed to be successful.
     *
     * IMPORTANT: If the token implements ERC-7674 (ERC-20 with temporary allowance), and if the "client"
     * smart contract uses ERC-7674 to set temporary allowances, then the "client" smart contract should avoid using
     * this function. Performing a {safeIncreaseAllowance} or {safeDecreaseAllowance} operation on a token contract
     * that has a non-zero temporary allowance (for that particular owner-spender) will result in unexpected behavior.
     */
    function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
        uint256 oldAllowance = token.allowance(address(this), spender);
        forceApprove(token, spender, oldAllowance + value);
    }

    /**
     * @dev Decrease the calling contract's allowance toward `spender` by `requestedDecrease`. If `token` returns no
     * value, non-reverting calls are assumed to be successful.
     *
     * IMPORTANT: If the token implements ERC-7674 (ERC-20 with temporary allowance), and if the "client"
     * smart contract uses ERC-7674 to set temporary allowances, then the "client" smart contract should avoid using
     * this function. Performing a {safeIncreaseAllowance} or {safeDecreaseAllowance} operation on a token contract
     * that has a non-zero temporary allowance (for that particular owner-spender) will result in unexpected behavior.
     */
    function safeDecreaseAllowance(IERC20 token, address spender, uint256 requestedDecrease) internal {
        unchecked {
            uint256 currentAllowance = token.allowance(address(this), spender);
            if (currentAllowance < requestedDecrease) {
                revert SafeERC20FailedDecreaseAllowance(spender, currentAllowance, requestedDecrease);
            }
            forceApprove(token, spender, currentAllowance - requestedDecrease);
        }
    }

    /**
     * @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,
     * non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval
     * to be set to zero before setting it to a non-zero value, such as USDT.
     *
     * NOTE: If the token implements ERC-7674, this function will not modify any temporary allowance. This function
     * only sets the "standard" allowance. Any temporary allowance will remain active, in addition to the value being
     * set here.
     */
    function forceApprove(IERC20 token, address spender, uint256 value) internal {
        if (!_safeApprove(token, spender, value, false)) {
            if (!_safeApprove(token, spender, 0, true)) revert SafeERC20FailedOperation(address(token));
            if (!_safeApprove(token, spender, value, true)) revert SafeERC20FailedOperation(address(token));
        }
    }

    /**
     * @dev Performs an {ERC1363} transferAndCall, with a fallback to the simple {ERC20} transfer if the target has no
     * code. This can be used to implement an {ERC721}-like safe transfer that relies on {ERC1363} checks when
     * targeting contracts.
     *
     * Reverts if the returned value is other than `true`.
     */
    function transferAndCallRelaxed(IERC1363 token, address to, uint256 value, bytes memory data) internal {
        if (to.code.length == 0) {
            safeTransfer(token, to, value);
        } else if (!token.transferAndCall(to, value, data)) {
            revert SafeERC20FailedOperation(address(token));
        }
    }

    /**
     * @dev Performs an {ERC1363} transferFromAndCall, with a fallback to the simple {ERC20} transferFrom if the target
     * has no code. This can be used to implement an {ERC721}-like safe transfer that relies on {ERC1363} checks when
     * targeting contracts.
     *
     * Reverts if the returned value is other than `true`.
     */
    function transferFromAndCallRelaxed(
        IERC1363 token,
        address from,
        address to,
        uint256 value,
        bytes memory data
    ) internal {
        if (to.code.length == 0) {
            safeTransferFrom(token, from, to, value);
        } else if (!token.transferFromAndCall(from, to, value, data)) {
            revert SafeERC20FailedOperation(address(token));
        }
    }

    /**
     * @dev Performs an {ERC1363} approveAndCall, with a fallback to the simple {ERC20} approve if the target has no
     * code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when
     * targeting contracts.
     *
     * NOTE: When the recipient address (`to`) has no code (i.e. is an EOA), this function behaves as {forceApprove}.
     * Oppositely, when the recipient address (`to`) has code, this function only attempts to call {ERC1363-approveAndCall}
     * once without retrying, and relies on the returned value to be true.
     *
     * Reverts if the returned value is other than `true`.
     */
    function approveAndCallRelaxed(IERC1363 token, address to, uint256 value, bytes memory data) internal {
        if (to.code.length == 0) {
            forceApprove(token, to, value);
        } else if (!token.approveAndCall(to, value, data)) {
            revert SafeERC20FailedOperation(address(token));
        }
    }

    /**
     * @dev Imitates a Solidity `token.transfer(to, value)` call, relaxing the requirement on the return value: the
     * return value is optional (but if data is returned, it must not be false).
     *
     * @param token The token targeted by the call.
     * @param to The recipient of the tokens
     * @param value The amount of token to transfer
     * @param bubble Behavior switch if the transfer call reverts: bubble the revert reason or return a false boolean.
     */
    function _safeTransfer(IERC20 token, address to, uint256 value, bool bubble) private returns (bool success) {
        bytes4 selector = IERC20.transfer.selector;

        assembly ("memory-safe") {
            let fmp := mload(0x40)
            mstore(0x00, selector)
            mstore(0x04, and(to, shr(96, not(0))))
            mstore(0x24, value)
            success := call(gas(), token, 0, 0x00, 0x44, 0x00, 0x20)
            // if call success and return is true, all is good.
            // otherwise (not success or return is not true), we need to perform further checks
            if iszero(and(success, eq(mload(0x00), 1))) {
                // if the call was a failure and bubble is enabled, bubble the error
                if and(iszero(success), bubble) {
                    returndatacopy(fmp, 0x00, returndatasize())
                    revert(fmp, returndatasize())
                }
                // if the return value is not true, then the call is only successful if:
                // - the token address has code
                // - the returndata is empty
                success := and(success, and(iszero(returndatasize()), gt(extcodesize(token), 0)))
            }
            mstore(0x40, fmp)
        }
    }

    /**
     * @dev Imitates a Solidity `token.transferFrom(from, to, value)` call, relaxing the requirement on the return
     * value: the return value is optional (but if data is returned, it must not be false).
     *
     * @param token The token targeted by the call.
     * @param from The sender of the tokens
     * @param to The recipient of the tokens
     * @param value The amount of token to transfer
     * @param bubble Behavior switch if the transfer call reverts: bubble the revert reason or return a false boolean.
     */
    function _safeTransferFrom(
        IERC20 token,
        address from,
        address to,
        uint256 value,
        bool bubble
    ) private returns (bool success) {
        bytes4 selector = IERC20.transferFrom.selector;

        assembly ("memory-safe") {
            let fmp := mload(0x40)
            mstore(0x00, selector)
            mstore(0x04, and(from, shr(96, not(0))))
            mstore(0x24, and(to, shr(96, not(0))))
            mstore(0x44, value)
            success := call(gas(), token, 0, 0x00, 0x64, 0x00, 0x20)
            // if call success and return is true, all is good.
            // otherwise (not success or return is not true), we need to perform further checks
            if iszero(and(success, eq(mload(0x00), 1))) {
                // if the call was a failure and bubble is enabled, bubble the error
                if and(iszero(success), bubble) {
                    returndatacopy(fmp, 0x00, returndatasize())
                    revert(fmp, returndatasize())
                }
                // if the return value is not true, then the call is only successful if:
                // - the token address has code
                // - the returndata is empty
                success := and(success, and(iszero(returndatasize()), gt(extcodesize(token), 0)))
            }
            mstore(0x40, fmp)
            mstore(0x60, 0)
        }
    }

    /**
     * @dev Imitates a Solidity `token.approve(spender, value)` call, relaxing the requirement on the return value:
     * the return value is optional (but if data is returned, it must not be false).
     *
     * @param token The token targeted by the call.
     * @param spender The spender of the tokens
     * @param value The amount of token to transfer
     * @param bubble Behavior switch if the transfer call reverts: bubble the revert reason or return a false boolean.
     */
    function _safeApprove(IERC20 token, address spender, uint256 value, bool bubble) private returns (bool success) {
        bytes4 selector = IERC20.approve.selector;

        assembly ("memory-safe") {
            let fmp := mload(0x40)
            mstore(0x00, selector)
            mstore(0x04, and(spender, shr(96, not(0))))
            mstore(0x24, value)
            success := call(gas(), token, 0, 0x00, 0x44, 0x00, 0x20)
            // if call success and return is true, all is good.
            // otherwise (not success or return is not true), we need to perform further checks
            if iszero(and(success, eq(mload(0x00), 1))) {
                // if the call was a failure and bubble is enabled, bubble the error
                if and(iszero(success), bubble) {
                    returndatacopy(fmp, 0x00, returndatasize())
                    revert(fmp, returndatasize())
                }
                // if the return value is not true, then the call is only successful if:
                // - the token address has code
                // - the returndata is empty
                success := and(success, and(iszero(returndatasize()), gt(extcodesize(token), 0)))
            }
            mstore(0x40, fmp)
        }
    }
}

node_modules/@openzeppelin/contracts/utils/ReentrancyGuardTransient.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.5.0) (utils/ReentrancyGuardTransient.sol)

pragma solidity ^0.8.24;

import {TransientSlot} from "./TransientSlot.sol";

/**
 * @dev Variant of {ReentrancyGuard} that uses transient storage.
 *
 * NOTE: This variant only works on networks where EIP-1153 is available.
 *
 * _Available since v5.1._
 *
 * @custom:stateless
 */
abstract contract ReentrancyGuardTransient {
    using TransientSlot for *;

    // keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.ReentrancyGuard")) - 1)) & ~bytes32(uint256(0xff))
    bytes32 private constant REENTRANCY_GUARD_STORAGE =
        0x9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f00;

    /**
     * @dev Unauthorized reentrant call.
     */
    error ReentrancyGuardReentrantCall();

    /**
     * @dev Prevents a contract from calling itself, directly or indirectly.
     * Calling a `nonReentrant` function from another `nonReentrant`
     * function is not supported. It is possible to prevent this from happening
     * by making the `nonReentrant` function external, and making it call a
     * `private` function that does the actual work.
     */
    modifier nonReentrant() {
        _nonReentrantBefore();
        _;
        _nonReentrantAfter();
    }

    /**
     * @dev A `view` only version of {nonReentrant}. Use to block view functions
     * from being called, preventing reading from inconsistent contract state.
     *
     * CAUTION: This is a "view" modifier and does not change the reentrancy
     * status. Use it only on view functions. For payable or non-payable functions,
     * use the standard {nonReentrant} modifier instead.
     */
    modifier nonReentrantView() {
        _nonReentrantBeforeView();
        _;
    }

    function _nonReentrantBeforeView() private view {
        if (_reentrancyGuardEntered()) {
            revert ReentrancyGuardReentrantCall();
        }
    }

    function _nonReentrantBefore() private {
        // On the first call to nonReentrant, REENTRANCY_GUARD_STORAGE.asBoolean().tload() will be false
        _nonReentrantBeforeView();

        // Any calls to nonReentrant after this point will fail
        _reentrancyGuardStorageSlot().asBoolean().tstore(true);
    }

    function _nonReentrantAfter() private {
        _reentrancyGuardStorageSlot().asBoolean().tstore(false);
    }

    /**
     * @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a
     * `nonReentrant` function in the call stack.
     */
    function _reentrancyGuardEntered() internal view returns (bool) {
        return _reentrancyGuardStorageSlot().asBoolean().tload();
    }

    function _reentrancyGuardStorageSlot() internal pure virtual returns (bytes32) {
        return REENTRANCY_GUARD_STORAGE;
    }
}

node_modules/@openzeppelin/contracts/utils/TransientSlot.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.3.0) (utils/TransientSlot.sol)
// This file was procedurally generated from scripts/generate/templates/TransientSlot.js.

pragma solidity ^0.8.24;

/**
 * @dev Library for reading and writing value-types to specific transient storage slots.
 *
 * Transient slots are often used to store temporary values that are removed after the current transaction.
 * This library helps with reading and writing to such slots without the need for inline assembly.
 *
 *  * Example reading and writing values using transient storage:
 * ```solidity
 * contract Lock {
 *     using TransientSlot for *;
 *
 *     // Define the slot. Alternatively, use the SlotDerivation library to derive the slot.
 *     bytes32 internal constant _LOCK_SLOT = 0xf4678858b2b588224636b8522b729e7722d32fc491da849ed75b3fdf3c84f542;
 *
 *     modifier locked() {
 *         require(!_LOCK_SLOT.asBoolean().tload());
 *
 *         _LOCK_SLOT.asBoolean().tstore(true);
 *         _;
 *         _LOCK_SLOT.asBoolean().tstore(false);
 *     }
 * }
 * ```
 *
 * TIP: Consider using this library along with {SlotDerivation}.
 */
library TransientSlot {
    /**
     * @dev UDVT that represents a slot holding an address.
     */
    type AddressSlot is bytes32;

    /**
     * @dev Cast an arbitrary slot to a AddressSlot.
     */
    function asAddress(bytes32 slot) internal pure returns (AddressSlot) {
        return AddressSlot.wrap(slot);
    }

    /**
     * @dev UDVT that represents a slot holding a bool.
     */
    type BooleanSlot is bytes32;

    /**
     * @dev Cast an arbitrary slot to a BooleanSlot.
     */
    function asBoolean(bytes32 slot) internal pure returns (BooleanSlot) {
        return BooleanSlot.wrap(slot);
    }

    /**
     * @dev UDVT that represents a slot holding a bytes32.
     */
    type Bytes32Slot is bytes32;

    /**
     * @dev Cast an arbitrary slot to a Bytes32Slot.
     */
    function asBytes32(bytes32 slot) internal pure returns (Bytes32Slot) {
        return Bytes32Slot.wrap(slot);
    }

    /**
     * @dev UDVT that represents a slot holding a uint256.
     */
    type Uint256Slot is bytes32;

    /**
     * @dev Cast an arbitrary slot to a Uint256Slot.
     */
    function asUint256(bytes32 slot) internal pure returns (Uint256Slot) {
        return Uint256Slot.wrap(slot);
    }

    /**
     * @dev UDVT that represents a slot holding a int256.
     */
    type Int256Slot is bytes32;

    /**
     * @dev Cast an arbitrary slot to a Int256Slot.
     */
    function asInt256(bytes32 slot) internal pure returns (Int256Slot) {
        return Int256Slot.wrap(slot);
    }

    /**
     * @dev Load the value held at location `slot` in transient storage.
     */
    function tload(AddressSlot slot) internal view returns (address value) {
        assembly ("memory-safe") {
            value := tload(slot)
        }
    }

    /**
     * @dev Store `value` at location `slot` in transient storage.
     */
    function tstore(AddressSlot slot, address value) internal {
        assembly ("memory-safe") {
            tstore(slot, value)
        }
    }

    /**
     * @dev Load the value held at location `slot` in transient storage.
     */
    function tload(BooleanSlot slot) internal view returns (bool value) {
        assembly ("memory-safe") {
            value := tload(slot)
        }
    }

    /**
     * @dev Store `value` at location `slot` in transient storage.
     */
    function tstore(BooleanSlot slot, bool value) internal {
        assembly ("memory-safe") {
            tstore(slot, value)
        }
    }

    /**
     * @dev Load the value held at location `slot` in transient storage.
     */
    function tload(Bytes32Slot slot) internal view returns (bytes32 value) {
        assembly ("memory-safe") {
            value := tload(slot)
        }
    }

    /**
     * @dev Store `value` at location `slot` in transient storage.
     */
    function tstore(Bytes32Slot slot, bytes32 value) internal {
        assembly ("memory-safe") {
            tstore(slot, value)
        }
    }

    /**
     * @dev Load the value held at location `slot` in transient storage.
     */
    function tload(Uint256Slot slot) internal view returns (uint256 value) {
        assembly ("memory-safe") {
            value := tload(slot)
        }
    }

    /**
     * @dev Store `value` at location `slot` in transient storage.
     */
    function tstore(Uint256Slot slot, uint256 value) internal {
        assembly ("memory-safe") {
            tstore(slot, value)
        }
    }

    /**
     * @dev Load the value held at location `slot` in transient storage.
     */
    function tload(Int256Slot slot) internal view returns (int256 value) {
        assembly ("memory-safe") {
            value := tload(slot)
        }
    }

    /**
     * @dev Store `value` at location `slot` in transient storage.
     */
    function tstore(Int256Slot slot, int256 value) internal {
        assembly ("memory-safe") {
            tstore(slot, value)
        }
    }
}

node_modules/@openzeppelin/contracts/utils/introspection/IERC165.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (utils/introspection/IERC165.sol)

pragma solidity >=0.4.16;

/**
 * @dev Interface of the ERC-165 standard, as defined in the
 * https://eips.ethereum.org/EIPS/eip-165[ERC].
 *
 * Implementers can declare support of contract interfaces, which can then be
 * queried by others ({ERC165Checker}).
 *
 * For an implementation, see {ERC165}.
 */
interface IERC165 {
    /**
     * @dev Returns true if this contract implements the interface defined by
     * `interfaceId`. See the corresponding
     * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[ERC section]
     * to learn more about how these ids are created.
     *
     * This function call must use less than 30 000 gas.
     */
    function supportsInterface(bytes4 interfaceId) external view returns (bool);
}

src/adapters/base/YoAdapterBase.sol

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

import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import { ReentrancyGuardTransient } from "@openzeppelin/contracts/utils/ReentrancyGuardTransient.sol";

import { IYoRegistry } from "../../interfaces/IYoRegistry.sol";

/// @title  YoAdapterBase
/// @notice Shared base for every YO adapter: the `rescue` / `rescueETH` recovery surface and the
///         canonical `nonReentrant` guard.
/// @dev    INVARIANTS:
///           - No admin keys, no upgrade path.
///           - `rescue` / `rescueETH` are callable only by a *currently*-registered YO vault (per the
///             immutable `YoRegistry.isYoVault`) and always send to `msg.sender` — no caller-controlled
///             destination, so a removed vault loses rescue rights and the path cannot be redirected.
///           - Rescue shares the adapters' reentrancy guard, so no cross-method reentry is possible.
abstract contract YoAdapterBase is ReentrancyGuardTransient {
    using SafeERC20 for IERC20;

    /// @notice Registry consulted to validate rescue callers. Immutable for the lifetime of the
    ///         adapter; if a new registry is ever needed, redeploy.
    IYoRegistry public immutable yoRegistry;

    /// @notice Basis-points denominator (100% == 10_000). Shared by adapters that cap fees or floor
    ///         slippage against a bps bound.
    uint256 internal constant BPS_DENOMINATOR = 10_000;

    error CallerNotYoVault(address caller);
    error ZeroRegistry();
    error EthTransferFailed();

    /// @notice Emitted on every successful `rescue(IERC20)`. `amount == 0` is permitted and emits.
    event Rescued(address indexed token, address indexed to, uint256 amount);
    /// @notice Emitted on every successful `rescueETH()`. `amount == 0` is permitted and emits.
    event RescuedETH(address indexed to, uint256 amount);

    /// @notice Direction of value flow relative to the calling vault.
    /// @dev    `Deposit` = vault → external protocol; `Withdraw` = external protocol → vault;
    ///         `Bridge` = vault → another chain (funds leave this chain and do not return to the
    ///         vault here). New variants are appended so existing ordinals stay stable for off-chain
    ///         decoders. `YoSwapAdapter` does not emit `AdapterAction`; it has its own `SwapAction`
    ///         event that captures both legs of an exchange in a single log.
    enum AdapterDirection {
        Deposit,
        Withdraw,
        Bridge
    }

    /// @notice Vault-level audit signal emitted by every adapter operation. Lets off-chain
    ///         monitoring reconstruct strategy actions without parsing each external protocol's logs.
    /// @param  vault     The calling YO vault (always `msg.sender` for adapter entrypoints).
    /// @param  target    The external protocol contract the adapter interacted with.
    /// @param  asset     The ERC-20 token whose movement defines this leg of the action.
    /// @param  direction Inflow or outflow relative to the vault.
    /// @param  amount    Quantity of `asset` in its native decimals.
    event AdapterAction(
        address indexed vault,
        address indexed target,
        address indexed asset,
        AdapterDirection direction,
        uint256 amount
    );

    constructor(IYoRegistry _yoRegistry) {
        if (address(_yoRegistry) == address(0)) {
            revert ZeroRegistry();
        }
        yoRegistry = _yoRegistry;
    }

    /// @dev Restricts the caller to a currently-registered YO vault. Applied to `rescue` /
    ///      `rescueETH`; child adapters' per-protocol methods are gated by their own allowlists
    ///      and do not use this modifier.
    modifier onlyYoVault() {
        if (!yoRegistry.isYoVault(msg.sender)) {
            revert CallerNotYoVault(msg.sender);
        }
        _;
    }

    /// @notice Sweep this adapter's full balance of `token` to the calling vault. Callable only by
    ///         a currently-registered YO vault.
    /// @return amount The token balance transferred.
    function rescue(IERC20 token) external nonReentrant onlyYoVault returns (uint256 amount) {
        amount = token.balanceOf(address(this));
        if (amount != 0) {
            token.safeTransfer(msg.sender, amount);
        }
        emit Rescued(address(token), msg.sender, amount);
    }

    /// @dev Emit an `AdapterAction` log keyed on `msg.sender` (the calling vault). Used by every
    ///      adapter at the point a deposit / withdraw / swap leg completes.
    function _emitAction(address target, address asset, AdapterDirection direction, uint256 amount) internal {
        emit AdapterAction(msg.sender, target, asset, direction, amount);
    }

    /// @dev `amount * bps / BPS_DENOMINATOR`. Shared by adapter fee caps and slippage floors (pass
    ///      `BPS_DENOMINATOR - slippageBps` for a floor).
    function _applyBps(uint256 amount, uint256 bps) internal pure returns (uint256) {
        return (amount * bps) / BPS_DENOMINATOR;
    }

    /// @notice Sweep this adapter's full ETH balance to the calling vault. Callable only by a
    ///         currently-registered YO vault.
    /// @return amount The ETH amount transferred.
    function rescueETH() external nonReentrant onlyYoVault returns (uint256 amount) {
        amount = address(this).balance;
        if (amount != 0) {
            (bool ok,) = payable(msg.sender).call{ value: amount }("");
            if (!ok) {
                revert EthTransferFailed();
            }
        }
        emit RescuedETH(msg.sender, amount);
    }
}

src/interfaces/IYoBridgeRouteRegistry.sol

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

/// @notice Per-vault allowlist of cross-chain destinations reachable through the YO bridge adapters
///         (`YoAcrossAdapter`, `YoCcipAdapter`, `YoCctpAdapter`, `YoCctpxAdapter`, `YoMayanAdapter`).
/// @dev    Bridges are the only adapters that move value OFF the current chain to a recipient
///         elsewhere, so the usual "funds return to the vault" invariant does not apply. This
///         registry is the on-chain destination floor: an adapter may only let `vault` send `token`
///         to `(destinationId, recipient)` if the multisig has explicitly allowlisted that route.
///
///         A route is keyed on six fields:
///           - `vault`         — the calling YO vault.
///           - `adapter`       — the bridge adapter (`address(this)` inside the adapter). Namespaces
///                               routes per bridge so an Across route for chainId 8453 can never be
///                               reused as a CCTP route for domain 8453.
///           - `token`         — the asset leaving the chain (e.g. USDC).
///           - `destinationId` — the bridge's native destination identifier, widened to `uint256`
///                               (Across chainId, CCIP chain selector, CCTP / CCTPx domain).
///           - `recipient`     — the destination recipient, widened to `bytes32` (an EVM address is
///                               left-padded to 32 bytes).
///           - `outputToken`   — the destination-chain token the adapter presents, widened to
///                               `bytes32`. Adapters where the operator names the delivered token
///                               (Across `outputToken`, Mayan order `tokenOut`) pass it here so the
///                               multisig pins the destination asset's identity; adapters where the
///                               protocol fixes the output (CCIP, CCTP, CCTPx) pass `bytes32(0)`.
interface IYoBridgeRouteRegistry {
    event RouteSet(
        address indexed vault,
        address indexed adapter,
        address indexed token,
        uint256 destinationId,
        bytes32 recipient,
        bytes32 outputToken,
        bool allowed
    );

    error ZeroAddress();
    error RenounceDisabled();

    /// @notice Allow or disallow a single bridge route. Owner-only.
    /// @param vault         The YO vault the route applies to.
    /// @param adapter       The bridge adapter that will consult this route.
    /// @param token         The asset being bridged.
    /// @param destinationId The bridge's destination identifier, widened to `uint256`.
    /// @param recipient     The destination recipient, widened to `bytes32`.
    /// @param outputToken   The pinned destination token, widened to `bytes32` (`0` when unpinned).
    /// @param allowed       `true` to allow the route, `false` to revoke it.
    function setRoute(
        address vault,
        address adapter,
        address token,
        uint256 destinationId,
        bytes32 recipient,
        bytes32 outputToken,
        bool allowed
    )
        external;

    /// @notice Whether `vault` may bridge `token` to `(destinationId, recipient)` delivering
    ///         `outputToken` via `adapter`.
    /// @dev    Defaults to `false` for every unset route.
    function isRouteAllowed(
        address vault,
        address adapter,
        address token,
        uint256 destinationId,
        bytes32 recipient,
        bytes32 outputToken
    )
        external
        view
        returns (bool);
}

src/interfaces/IYoCctpxAdapter.sol

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

/// @notice Immutable adapter that brokers Circle "CCTP for non-USDC" (CCTPx) burn-and-mint transfers
///         of one pinned token (e.g. EURC) on behalf of a vault.
/// @dev    Functions are intended to be invoked exclusively via `YoVault.manage(...)` so that
///         `msg.sender == vault` inside the adapter. The token and its CCTPx `tokenId` are pinned at
///         construction; only that token can be bridged.
///
///         SAFETY: a transfer moves funds off-chain, so the destination is constrained by
///         `YoBridgeRouteRegistry` — `(vault, adapter, token, destinationDomain, recipient)` must be
///         allowlisted by the multisig, with `recipient` keyed as `bytes32(uint256(uint160(recipient)))`
///         and `outputToken == bytes32(0)`. `destinationDomain` is a Circle domain id, NOT an EVM chain
///         id. The adapter fixes every other delivery parameter so it adds no strand vector:
///           - the destination address is the raw 20-byte `recipient` (CCTPx delivery reverts on any
///             other encoding, which would strand the burned tokens);
///           - `destinationCaller` is `bytes32(0)`, so anyone can relay the mint;
///           - no destination hook is executed;
///           - fee refunds are attributed to the vault.
///         Delivery still depends on Circle-side state: the destination TokenManager's pause, inbound
///         rate limit and minter allowance, the CCTPx denylist (recipient), the token's own pause and
///         blacklist, the service and `MessageTransmitterV2` pauses, domain trust, Iris enablement of
///         the token on the destination domain, and — for fast transfers only — the message expiry.
///         None of these consumes the message: it stays relayable once the condition clears. The multisig must
/// allowlist only EVM domains on which Iris lists the token's deployment as enabled.
///
///         RELAY: unless the signed quote includes Circle's `FORWARD` fee, Circle does not deliver the
///         message; someone must call `MessageTransmitterV2.receiveMessage` on the destination (anyone
///         can). A fast message must be relayed before its attested `expirationBlock`; after it, delivery
///         needs a finalized attestation.
///
///         `minFinalityThreshold` is restricted to the fast (`1000`) and standard
///         (`2000`) tiers; the choice between them is operator/cosigner-trusted (it is not a fund
///         destination).
///
///         FEES: paid ONLY in the native gas asset, forwarded as `msg.value` from `YoVault.manage`.
///         `msg.value` is capped at `maxNativeFee` and must equal the signed quote's total fee: the
///         adapter reverts unless the service forwards all of it (no excess kept, no shortfall covered).
///
///         APPROVAL FLOW: the vault approves the adapter on the token
///         (`vault.approveToken(token, adapter, cap)`); the adapter pulls via `transferFrom` and
///         approves the per-token CCTPx `TokenManager` for exactly the transferred amount.
interface IYoCctpxAdapter {
    error InvalidAmount();
    error InvalidRecipient();
    error InvalidFinalityThreshold(uint32 minFinalityThreshold);
    error RouteNotAllowed(uint32 destinationDomain, address recipient);
    error NativeFeeTooHigh(uint256 fee, uint256 cap);
    /// @dev `sent` is `msg.value`; `required` is the fee the service actually charged for the quote.
    error IncorrectNativeFee(uint256 sent, uint256 required);
    /// @dev Constructor: `token` is not the token CCTPx registers for `tokenId` on this chain.
    error TokenMismatch(address token, address registered);

    /// @notice Burn `amount` of the pinned token for delivery to `recipient` on `destinationDomain`,
    ///         paying the CCTPx fee in the native gas asset from `msg.value`.
    /// @dev    Reverts unless the `(token, destinationDomain, recipient)` route is allowlisted for the
    ///         calling vault, unless `minFinalityThreshold` is `1000` or `2000`, unless
    ///         `msg.value <= maxNativeFee`, and unless `msg.value` equals the signed quote's total fee.
    /// @param amount               Amount of the pinned token to transfer.
    /// @param destinationDomain    Circle domain id of the destination chain.
    /// @param recipient            Destination recipient (allowlisted route).
    /// @param minFinalityThreshold `2000` for a standard transfer, `1000` for a fast transfer.
    /// @param signedQuote          Signed fee quote from the Iris CCTPx quote API.
    /// @return The amount of the token transferred (`amount`).
    function crossChainTransfer(
        uint256 amount,
        uint32 destinationDomain,
        address recipient,
        uint32 minFinalityThreshold,
        bytes calldata signedQuote
    )
        external
        payable
        returns (uint256);
}

src/interfaces/IYoRegistry.sol

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

interface IYoRegistry {
    event YoVaultAdded(address indexed asset, address indexed vault);
    event YoVaultRemoved(address indexed asset, address indexed vault);

    /// @notice Checks if an address is a valid YO vault
    /// @param vaultAddress Vault address to be added
    function isYoVault(address vaultAddress) external view returns (bool);

    /// @notice Registers a YO vault
    /// @param vaultAddress YO vault address to be added
    function addYoVault(address vaultAddress) external;

    /// @notice Removes YO vault registration
    /// @param vaultAddress YO vault address to be removed
    function removeYoVault(address vaultAddress) external;

    /// @notice Returns a list of all registered YO vaults
    function listYoVaults() external view returns (address[] memory);
}

src/interfaces/external/ICrossChainTokenService.sol

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

/// @notice Minimal interface for Circle's "CCTP for non-USDC" (CCTPx) `CrossChainTokenService`, the
///         origin-chain entrypoint for burn-and-mint transfers of non-USDC tokens such as EURC.
/// @dev    CCTPx rides on CCTP V2's `MessageTransmitterV2` and Iris attestations, but it is a separate
///         contract layer from `TokenMessengerV2`:
///           - Tokens are addressed by a cross-chain `tokenId`, not by address.
///           - The per-token `TokenManager` (`resolveTokenManager(tokenId)`) pulls the tokens, so it —
///             not the service — is the approval spender.
///           - Fees are paid upfront in the native gas asset against a signed Iris quote; the recipient
///             receives the full `amount`.
///         Domains are Circle-internal ids, NOT EVM chain ids (domain 0 = Ethereum, domain 6 = Base).
interface ICrossChainTokenService {
    /// @notice Signed fee quote plus the refund attribution address, forwarded verbatim to the fee
    ///         manager. ABI-identical to Circle's `IFeeManager.QuoteClaim`.
    /// @param signedQuote   Version-prefixed, ABI-encoded quote returned by the Iris quote API.
    /// @param refundAddress Address any fee refund is attributed to. Not part of the signed quote.
    struct QuoteClaim {
        bytes signedQuote;
        address payable refundAddress;
    }

    /// @notice Burn `amount` of the `tokenId` token for delivery to `destinationAddress` on
    ///         `destinationDomain`, paying the quoted fee from `msg.value`.
    /// @param tokenId              Cross-chain id of the token to transfer.
    /// @param amount               Amount to transfer, in the local token's decimals.
    /// @param destinationDomain    Circle domain id of the destination chain.
    /// @param destinationAddress   Recipient on the destination domain. On EVM it must be the raw
    ///                             20-byte address; any other length makes delivery revert.
    /// @param destinationCaller    Address allowed to relay the message on the destination, as
    ///                             `bytes32`; `bytes32(0)` permits any caller.
    /// @param minFinalityThreshold `2000` selects a standard transfer, `1000` a fast transfer.
    /// @param claim                Signed fee quote and refund address.
    /// @param autoExecuteHookData  Whether `hookData` is executed on the recipient at delivery.
    /// @param hookData             Optional destination hook payload.
    function crossChainTransfer(
        bytes32 tokenId,
        uint256 amount,
        uint32 destinationDomain,
        bytes calldata destinationAddress,
        bytes32 destinationCaller,
        uint32 minFinalityThreshold,
        QuoteClaim calldata claim,
        bool autoExecuteHookData,
        bytes calldata hookData
    )
        external
        payable;

    /// @notice The deployed `TokenManager` for `tokenId`. Reverts `TokenNotRegistered` if none.
    function resolveTokenManager(bytes32 tokenId) external view returns (address);

    /// @notice The local token managed for `tokenId`. Reverts `TokenNotRegistered` if none.
    function resolveTokenAddress(bytes32 tokenId) external view returns (address);

    /// @notice The fee manager that collects quoted fees.
    function feeService() external view returns (address);
}
Compiler settingsShow
{
  "viaIR": true,
  "metadata": {
    "appendCBOR": true,
    "bytecodeHash": "ipfs",
    "useLiteralContent": false
  },
  "optimizer": {
    "runs": 10000,
    "enabled": true
  },
  "evmVersion": "cancun",
  "remappings": [
    "@openzeppelin/contracts/=node_modules/@openzeppelin/contracts/",
    "@openzeppelin/contracts-upgradeable/=node_modules/@openzeppelin/contracts-upgradeable/",
    "forge-std/=node_modules/forge-std/",
    "@morpho-org/=node_modules/@morpho-org/"
  ]
}

Source code and metadata: Sourcify.

The source code belongs to the authors of the contract.