ETH Price: $3,927.42 (-1.21%)

Contract

0x92Dc1cCE6767F82494BCBC54235A08B4FD457c26

Overview

ETH Balance

0 ETH

ETH Value

$0.00

More Info

Private Name Tags

Multichain Info

N/A
Transaction Hash
Method
Block
From
To

There are no matching entries

Please try again later

View more zero value Internal Transactions in Advanced View mode

Advanced mode:

Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
TrailsIntentEntrypoint

Compiler Version
v0.8.20+commit.a1b79de6

Optimization Enabled:
Yes with 200 runs

Other Settings:
shanghai EvmVersion
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {IERC20Permit} from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Permit.sol";
import {ECDSA} from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
import {ReentrancyGuard} from "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
import {ITrailsIntentEntrypoint} from "./interfaces/ITrailsIntentEntrypoint.sol";

/// @title TrailsIntentEntrypoint
/// @author Miguel Mota
/// @notice A contract to facilitate deposits to intent addresses with off-chain signed intents.
contract TrailsIntentEntrypoint is ReentrancyGuard, ITrailsIntentEntrypoint {
    // -------------------------------------------------------------------------
    // Libraries
    // -------------------------------------------------------------------------
    using ECDSA for bytes32;

    // -------------------------------------------------------------------------
    // Constants
    // -------------------------------------------------------------------------

    bytes32 public constant INTENT_TYPEHASH =
        keccak256("Intent(address user,address token,uint256 amount,address intentAddress,uint256 deadline)");
    string public constant VERSION = "1";

    // -------------------------------------------------------------------------
    // Errors
    // -------------------------------------------------------------------------

    error InvalidAmount();
    error InvalidToken();
    error InvalidIntentAddress();
    error IntentExpired();
    error InvalidIntentSignature();
    error IntentAlreadyUsed();

    // -------------------------------------------------------------------------
    // Immutable Variables
    // -------------------------------------------------------------------------

    /// @notice EIP-712 domain separator used for intent signatures.
    bytes32 public immutable DOMAIN_SEPARATOR;

    // -------------------------------------------------------------------------
    // State Variables
    // -------------------------------------------------------------------------

    /// @notice Tracks whether an intent digest has been consumed to prevent replays.
    mapping(bytes32 => bool) public usedIntents;

    // -------------------------------------------------------------------------
    // Constructor
    // -------------------------------------------------------------------------

    constructor() {
        DOMAIN_SEPARATOR = keccak256(
            abi.encode(
                keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"),
                keccak256(bytes("TrailsIntentEntrypoint")),
                keccak256(bytes(VERSION)),
                block.chainid,
                address(this)
            )
        );
    }

    // -------------------------------------------------------------------------
    // Functions
    // -------------------------------------------------------------------------

    /// @inheritdoc ITrailsIntentEntrypoint
    function depositToIntentWithPermit(
        address user,
        address token,
        uint256 amount,
        uint256 permitAmount,
        address intentAddress,
        uint256 deadline,
        uint8 permitV,
        bytes32 permitR,
        bytes32 permitS,
        uint8 sigV,
        bytes32 sigR,
        bytes32 sigS
    ) external nonReentrant {
        _verifyAndMarkIntent(user, token, amount, intentAddress, deadline, sigV, sigR, sigS);

        IERC20Permit(token).permit(user, address(this), permitAmount, deadline, permitV, permitR, permitS);
        require(IERC20(token).transferFrom(user, intentAddress, amount), "ERC20 transferFrom failed");

        emit IntentDeposit(user, intentAddress, amount);
    }

    /// @inheritdoc ITrailsIntentEntrypoint
    function depositToIntent(
        address user,
        address token,
        uint256 amount,
        address intentAddress,
        uint256 deadline,
        uint8 sigV,
        bytes32 sigR,
        bytes32 sigS
    ) external nonReentrant {
        _verifyAndMarkIntent(user, token, amount, intentAddress, deadline, sigV, sigR, sigS);

        require(IERC20(token).transferFrom(user, intentAddress, amount), "ERC20 transferFrom failed");

        emit IntentDeposit(user, intentAddress, amount);
    }

    // -------------------------------------------------------------------------
    // Internal Functions
    // -------------------------------------------------------------------------

    /// forge-lint: disable-next-line(mixed-case-function)
    function _verifyAndMarkIntent(
        address user,
        address token,
        uint256 amount,
        address intentAddress,
        uint256 deadline,
        uint8 sigV,
        bytes32 sigR,
        bytes32 sigS
    ) internal {
        if (amount == 0) revert InvalidAmount();
        if (token == address(0)) revert InvalidToken();
        if (intentAddress == address(0)) revert InvalidIntentAddress();
        if (block.timestamp > deadline) revert IntentExpired();

        bytes32 _typehash = INTENT_TYPEHASH;
        bytes32 intentHash;
        // keccak256(abi.encode(INTENT_TYPEHASH, user, token, amount, intentAddress, deadline));
        assembly {
            let ptr := mload(0x40)
            mstore(ptr, _typehash)
            mstore(add(ptr, 0x20), user)
            mstore(add(ptr, 0x40), token)
            mstore(add(ptr, 0x60), amount)
            mstore(add(ptr, 0x80), intentAddress)
            mstore(add(ptr, 0xa0), deadline)
            intentHash := keccak256(ptr, 0xc0)
        }

        bytes32 _domainSeparator = DOMAIN_SEPARATOR;
        bytes32 digest;
        // keccak256(abi.encodePacked("\x19\x01", DOMAIN_SEPARATOR, intentHash));
        assembly {
            let ptr := mload(0x40)
            mstore(ptr, 0x1901)
            mstore(add(ptr, 0x20), _domainSeparator)
            mstore(add(ptr, 0x40), intentHash)
            digest := keccak256(add(ptr, 0x1e), 0x42)
        }
        address recovered = ECDSA.recover(digest, sigV, sigR, sigS);
        if (recovered != user) revert InvalidIntentSignature();

        if (usedIntents[digest]) revert IntentAlreadyUsed();
        usedIntents[digest] = true;
    }

    /// @inheritdoc ITrailsIntentEntrypoint
    function payFee(
        address user,
        address feeToken,
        uint256 feeAmount,
        address feeCollector
    ) external nonReentrant {
        require(feeAmount > 0, "Fee amount must be greater than 0");
        require(feeToken != address(0), "Fee token must not be zero address");
        require(feeCollector != address(0), "Fee collector must not be zero address");

        // Transfer fee using existing allowance (from deposit permit)
        require(IERC20(feeToken).transferFrom(user, feeCollector, feeAmount), "ERC20 transferFrom failed");

        emit FeePaid(user, feeToken, feeAmount, feeCollector);
    }

    /// @inheritdoc ITrailsIntentEntrypoint
    function payFeeWithPermit(
        address user,
        address feeToken,
        uint256 feeAmount,
        address feeCollector,
        uint256 deadline,
        uint8 permitV,
        bytes32 permitR,
        bytes32 permitS
    ) external nonReentrant {
        require(feeAmount > 0, "Fee amount must be greater than 0");
        require(feeToken != address(0), "Fee token must not be zero address");
        require(feeCollector != address(0), "Fee collector must not be zero address");
        require(block.timestamp <= deadline, "Permit expired");

        // Execute permit to approve this contract
        IERC20Permit(feeToken).permit(user, address(this), feeAmount, deadline, permitV, permitR, permitS);

        // Transfer fee to collector
        require(IERC20(feeToken).transferFrom(user, feeCollector, feeAmount), "ERC20 transferFrom failed");

        emit FeePaid(user, feeToken, feeAmount, feeCollector);
    }
}

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

pragma solidity ^0.8.20;

/**
 * @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);
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (token/ERC20/extensions/IERC20Permit.sol)

pragma solidity ^0.8.20;

/**
 * @dev Interface of the ERC-20 Permit extension allowing approvals to be made via signatures, as defined in
 * https://eips.ethereum.org/EIPS/eip-2612[ERC-2612].
 *
 * Adds the {permit} method, which can be used to change an account's ERC-20 allowance (see {IERC20-allowance}) by
 * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't
 * need to send a transaction, and thus is not required to hold Ether at all.
 *
 * ==== Security Considerations
 *
 * There are two important considerations concerning the use of `permit`. The first is that a valid permit signature
 * expresses an allowance, and it should not be assumed to convey additional meaning. In particular, it should not be
 * considered as an intention to spend the allowance in any specific way. The second is that because permits have
 * built-in replay protection and can be submitted by anyone, they can be frontrun. A protocol that uses permits should
 * take this into consideration and allow a `permit` call to fail. Combining these two aspects, a pattern that may be
 * generally recommended is:
 *
 * ```solidity
 * function doThingWithPermit(..., uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public {
 *     try token.permit(msg.sender, address(this), value, deadline, v, r, s) {} catch {}
 *     doThing(..., value);
 * }
 *
 * function doThing(..., uint256 value) public {
 *     token.safeTransferFrom(msg.sender, address(this), value);
 *     ...
 * }
 * ```
 *
 * Observe that: 1) `msg.sender` is used as the owner, leaving no ambiguity as to the signer intent, and 2) the use of
 * `try/catch` allows the permit to fail and makes the code tolerant to frontrunning. (See also
 * {SafeERC20-safeTransferFrom}).
 *
 * Additionally, note that smart contract wallets (such as Argent or Safe) are not able to produce permit signatures, so
 * contracts should have entry points that don't rely on permit.
 */
interface IERC20Permit {
    /**
     * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,
     * given ``owner``'s signed approval.
     *
     * IMPORTANT: The same issues {IERC20-approve} has related to transaction
     * ordering also apply here.
     *
     * Emits an {Approval} event.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     * - `deadline` must be a timestamp in the future.
     * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`
     * over the EIP712-formatted function arguments.
     * - the signature must use ``owner``'s current nonce (see {nonces}).
     *
     * For more information on the signature format, see the
     * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP
     * section].
     *
     * CAUTION: See Security Considerations above.
     */
    function permit(
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) external;

    /**
     * @dev Returns the current nonce for `owner`. This value must be
     * included whenever a signature is generated for {permit}.
     *
     * Every successful call to {permit} increases ``owner``'s nonce by one. This
     * prevents a signature from being used multiple times.
     */
    function nonces(address owner) external view returns (uint256);

    /**
     * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.
     */
    // solhint-disable-next-line func-name-mixedcase
    function DOMAIN_SEPARATOR() external view returns (bytes32);
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/cryptography/ECDSA.sol)

pragma solidity ^0.8.20;

/**
 * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.
 *
 * These functions can be used to verify that a message was signed by the holder
 * of the private keys of a given address.
 */
library ECDSA {
    enum RecoverError {
        NoError,
        InvalidSignature,
        InvalidSignatureLength,
        InvalidSignatureS
    }

    /**
     * @dev The signature derives the `address(0)`.
     */
    error ECDSAInvalidSignature();

    /**
     * @dev The signature has an invalid length.
     */
    error ECDSAInvalidSignatureLength(uint256 length);

    /**
     * @dev The signature has an S value that is in the upper half order.
     */
    error ECDSAInvalidSignatureS(bytes32 s);

    /**
     * @dev Returns the address that signed a hashed message (`hash`) with `signature` or an error. This will not
     * return address(0) without also returning an error description. Errors are documented using an enum (error type)
     * and a bytes32 providing additional information about the error.
     *
     * If no error is returned, then the address can be used for verification purposes.
     *
     * The `ecrecover` EVM precompile allows for malleable (non-unique) signatures:
     * this function rejects them by requiring the `s` value to be in the lower
     * half order, and the `v` value to be either 27 or 28.
     *
     * IMPORTANT: `hash` _must_ be the result of a hash operation for the
     * verification to be secure: it is possible to craft signatures that
     * recover to arbitrary addresses for non-hashed data. A safe way to ensure
     * this is by receiving a hash of the original message (which may otherwise
     * be too long), and then calling {MessageHashUtils-toEthSignedMessageHash} on it.
     *
     * Documentation for signature generation:
     * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]
     * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]
     */
    function tryRecover(
        bytes32 hash,
        bytes memory signature
    ) internal pure returns (address recovered, RecoverError err, bytes32 errArg) {
        if (signature.length == 65) {
            bytes32 r;
            bytes32 s;
            uint8 v;
            // ecrecover takes the signature parameters, and the only way to get them
            // currently is to use assembly.
            assembly ("memory-safe") {
                r := mload(add(signature, 0x20))
                s := mload(add(signature, 0x40))
                v := byte(0, mload(add(signature, 0x60)))
            }
            return tryRecover(hash, v, r, s);
        } else {
            return (address(0), RecoverError.InvalidSignatureLength, bytes32(signature.length));
        }
    }

    /**
     * @dev Returns the address that signed a hashed message (`hash`) with
     * `signature`. This address can then be used for verification purposes.
     *
     * The `ecrecover` EVM precompile allows for malleable (non-unique) signatures:
     * this function rejects them by requiring the `s` value to be in the lower
     * half order, and the `v` value to be either 27 or 28.
     *
     * IMPORTANT: `hash` _must_ be the result of a hash operation for the
     * verification to be secure: it is possible to craft signatures that
     * recover to arbitrary addresses for non-hashed data. A safe way to ensure
     * this is by receiving a hash of the original message (which may otherwise
     * be too long), and then calling {MessageHashUtils-toEthSignedMessageHash} on it.
     */
    function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {
        (address recovered, RecoverError error, bytes32 errorArg) = tryRecover(hash, signature);
        _throwError(error, errorArg);
        return recovered;
    }

    /**
     * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.
     *
     * See https://eips.ethereum.org/EIPS/eip-2098[ERC-2098 short signatures]
     */
    function tryRecover(
        bytes32 hash,
        bytes32 r,
        bytes32 vs
    ) internal pure returns (address recovered, RecoverError err, bytes32 errArg) {
        unchecked {
            bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);
            // We do not check for an overflow here since the shift operation results in 0 or 1.
            uint8 v = uint8((uint256(vs) >> 255) + 27);
            return tryRecover(hash, v, r, s);
        }
    }

    /**
     * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.
     */
    function recover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address) {
        (address recovered, RecoverError error, bytes32 errorArg) = tryRecover(hash, r, vs);
        _throwError(error, errorArg);
        return recovered;
    }

    /**
     * @dev Overload of {ECDSA-tryRecover} that receives the `v`,
     * `r` and `s` signature fields separately.
     */
    function tryRecover(
        bytes32 hash,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) internal pure returns (address recovered, RecoverError err, bytes32 errArg) {
        // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature
        // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines
        // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most
        // signatures from current libraries generate a unique signature with an s-value in the lower half order.
        //
        // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value
        // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or
        // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept
        // these malleable signatures as well.
        if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {
            return (address(0), RecoverError.InvalidSignatureS, s);
        }

        // If the signature is valid (and not malleable), return the signer address
        address signer = ecrecover(hash, v, r, s);
        if (signer == address(0)) {
            return (address(0), RecoverError.InvalidSignature, bytes32(0));
        }

        return (signer, RecoverError.NoError, bytes32(0));
    }

    /**
     * @dev Overload of {ECDSA-recover} that receives the `v`,
     * `r` and `s` signature fields separately.
     */
    function recover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal pure returns (address) {
        (address recovered, RecoverError error, bytes32 errorArg) = tryRecover(hash, v, r, s);
        _throwError(error, errorArg);
        return recovered;
    }

    /**
     * @dev Optionally reverts with the corresponding custom error according to the `error` argument provided.
     */
    function _throwError(RecoverError error, bytes32 errorArg) private pure {
        if (error == RecoverError.NoError) {
            return; // no error: do nothing
        } else if (error == RecoverError.InvalidSignature) {
            revert ECDSAInvalidSignature();
        } else if (error == RecoverError.InvalidSignatureLength) {
            revert ECDSAInvalidSignatureLength(uint256(errorArg));
        } else if (error == RecoverError.InvalidSignatureS) {
            revert ECDSAInvalidSignatureS(errorArg);
        }
    }
}

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

pragma solidity ^0.8.20;

/**
 * @dev Contract module that helps prevent reentrant calls to a function.
 *
 * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
 * available, which can be applied to functions to make sure there are no nested
 * (reentrant) calls to them.
 *
 * Note that because there is a single `nonReentrant` guard, functions marked as
 * `nonReentrant` may not call one another. This can be worked around by making
 * those functions `private`, and then adding `external` `nonReentrant` entry
 * points to them.
 *
 * TIP: If EIP-1153 (transient storage) is available on the chain you're deploying at,
 * consider using {ReentrancyGuardTransient} instead.
 *
 * TIP: If you would like to learn more about reentrancy and alternative ways
 * to protect against it, check out our blog post
 * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
 */
abstract contract ReentrancyGuard {
    // Booleans are more expensive than uint256 or any type that takes up a full
    // word because each write operation emits an extra SLOAD to first read the
    // slot's contents, replace the bits taken up by the boolean, and then write
    // back. This is the compiler's defense against contract upgrades and
    // pointer aliasing, and it cannot be disabled.

    // The values being non-zero value makes deployment a bit more expensive,
    // but in exchange the refund on every call to nonReentrant will be lower in
    // amount. Since refunds are capped to a percentage of the total
    // transaction's gas, it is best to keep them low in cases like this one, to
    // increase the likelihood of the full refund coming into effect.
    uint256 private constant NOT_ENTERED = 1;
    uint256 private constant ENTERED = 2;

    uint256 private _status;

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

    constructor() {
        _status = NOT_ENTERED;
    }

    /**
     * @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();
    }

    function _nonReentrantBefore() private {
        // On the first call to nonReentrant, _status will be NOT_ENTERED
        if (_status == ENTERED) {
            revert ReentrancyGuardReentrantCall();
        }

        // Any calls to nonReentrant after this point will fail
        _status = ENTERED;
    }

    function _nonReentrantAfter() private {
        // By storing the original value once again, a refund is triggered (see
        // https://eips.ethereum.org/EIPS/eip-2200)
        _status = NOT_ENTERED;
    }

    /**
     * @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 _status == ENTERED;
    }
}

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

/// @title ITrailsIntentEntrypoint
/// @notice Interface for the TrailsIntentEntrypoint contract
interface ITrailsIntentEntrypoint {
    // -------------------------------------------------------------------------
    // Events
    // -------------------------------------------------------------------------

    /// @notice Emitted when a user deposits tokens to an intent address
    /// @param user The user making the deposit
    /// @param intentAddress The intent address receiving the deposit
    /// @param amount The amount of tokens deposited
    event IntentDeposit(address indexed user, address indexed intentAddress, uint256 amount);

    /// @notice Emitted when a fee is paid
    /// @param user The user paying the fee
    /// @param feeToken The token used to pay the fee
    /// @param feeAmount The amount of fee paid
    /// @param feeCollector The address that received the fee
    event FeePaid(address indexed user, address indexed feeToken, uint256 feeAmount, address indexed feeCollector);

    // -------------------------------------------------------------------------
    // Functions
    // -------------------------------------------------------------------------

    /// @notice Deposit tokens to an intent address using ERC20 permit
    /// @param user The user making the deposit
    /// @param token The token to deposit
    /// @param amount The amount to deposit
    /// @param permitAmount The amount to permit for spending
    /// @param intentAddress The intent address to deposit to
    /// @param deadline The permit deadline
    /// @param permitV The permit signature v component
    /// @param permitR The permit signature r component
    /// @param permitS The permit signature s component
    /// @param sigV The intent signature v component
    /// @param sigR The intent signature r component
    /// @param sigS The intent signature s component
    function depositToIntentWithPermit(
        address user,
        address token,
        uint256 amount,
        uint256 permitAmount,
        address intentAddress,
        uint256 deadline,
        uint8 permitV,
        bytes32 permitR,
        bytes32 permitS,
        uint8 sigV,
        bytes32 sigR,
        bytes32 sigS
    ) external;

    /// @notice Deposit tokens to an intent address (requires prior approval)
    /// @param user The user making the deposit
    /// @param token The token to deposit
    /// @param amount The amount to deposit
    /// @param intentAddress The intent address to deposit to
    /// @param deadline The intent deadline
    /// @param sigV The intent signature v component
    /// @param sigR The intent signature r component
    /// @param sigS The intent signature s component
    function depositToIntent(
        address user,
        address token,
        uint256 amount,
        address intentAddress,
        uint256 deadline,
        uint8 sigV,
        bytes32 sigR,
        bytes32 sigS
    ) external;

    /// @notice Pay fee using existing allowance (same token as deposit)
    /// @param user The user paying the fee
    /// @param feeToken The token to pay the fee in
    /// @param feeAmount The amount of fee to pay
    /// @param feeCollector The address to receive the fee
    function payFee(
        address user,
        address feeToken,
        uint256 feeAmount,
        address feeCollector
    ) external;

    /// @notice Pay fee using ERC20 permit (different token from deposit)
    /// @param user The user paying the fee
    /// @param feeToken The token to pay the fee in
    /// @param feeAmount The amount of fee to pay
    /// @param feeCollector The address to receive the fee
    /// @param deadline The permit deadline
    /// @param permitV The permit signature v component
    /// @param permitR The permit signature r component
    /// @param permitS The permit signature s component
    function payFeeWithPermit(
        address user,
        address feeToken,
        uint256 feeAmount,
        address feeCollector,
        uint256 deadline,
        uint8 permitV,
        bytes32 permitR,
        bytes32 permitS
    ) external;
}

Settings
{
  "remappings": [
    "@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/",
    "forge-std/=lib/forge-std/src/",
    "erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/",
    "halmos-cheatcodes/=lib/openzeppelin-contracts/lib/halmos-cheatcodes/src/",
    "openzeppelin-contracts/=lib/openzeppelin-contracts/"
  ],
  "optimizer": {
    "enabled": true,
    "runs": 200
  },
  "metadata": {
    "useLiteralContent": false,
    "bytecodeHash": "ipfs",
    "appendCBOR": true
  },
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  },
  "evmVersion": "shanghai",
  "viaIR": true
}

Contract Security Audit

Contract ABI

API
[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"ECDSAInvalidSignature","type":"error"},{"inputs":[{"internalType":"uint256","name":"length","type":"uint256"}],"name":"ECDSAInvalidSignatureLength","type":"error"},{"inputs":[{"internalType":"bytes32","name":"s","type":"bytes32"}],"name":"ECDSAInvalidSignatureS","type":"error"},{"inputs":[],"name":"IntentAlreadyUsed","type":"error"},{"inputs":[],"name":"IntentExpired","type":"error"},{"inputs":[],"name":"InvalidAmount","type":"error"},{"inputs":[],"name":"InvalidIntentAddress","type":"error"},{"inputs":[],"name":"InvalidIntentSignature","type":"error"},{"inputs":[],"name":"InvalidToken","type":"error"},{"inputs":[],"name":"ReentrancyGuardReentrantCall","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"address","name":"feeToken","type":"address"},{"indexed":false,"internalType":"uint256","name":"feeAmount","type":"uint256"},{"indexed":true,"internalType":"address","name":"feeCollector","type":"address"}],"name":"FeePaid","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"address","name":"intentAddress","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"IntentDeposit","type":"event"},{"inputs":[],"name":"DOMAIN_SEPARATOR","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"INTENT_TYPEHASH","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"VERSION","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"},{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"address","name":"intentAddress","type":"address"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"uint8","name":"sigV","type":"uint8"},{"internalType":"bytes32","name":"sigR","type":"bytes32"},{"internalType":"bytes32","name":"sigS","type":"bytes32"}],"name":"depositToIntent","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"},{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"permitAmount","type":"uint256"},{"internalType":"address","name":"intentAddress","type":"address"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"uint8","name":"permitV","type":"uint8"},{"internalType":"bytes32","name":"permitR","type":"bytes32"},{"internalType":"bytes32","name":"permitS","type":"bytes32"},{"internalType":"uint8","name":"sigV","type":"uint8"},{"internalType":"bytes32","name":"sigR","type":"bytes32"},{"internalType":"bytes32","name":"sigS","type":"bytes32"}],"name":"depositToIntentWithPermit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"},{"internalType":"address","name":"feeToken","type":"address"},{"internalType":"uint256","name":"feeAmount","type":"uint256"},{"internalType":"address","name":"feeCollector","type":"address"}],"name":"payFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"},{"internalType":"address","name":"feeToken","type":"address"},{"internalType":"uint256","name":"feeAmount","type":"uint256"},{"internalType":"address","name":"feeCollector","type":"address"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"uint8","name":"permitV","type":"uint8"},{"internalType":"bytes32","name":"permitR","type":"bytes32"},{"internalType":"bytes32","name":"permitS","type":"bytes32"}],"name":"payFeeWithPermit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"usedIntents","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"}]

60a080604052346100f757602060169160015f5561001c816100fb565b828152017f547261696c73496e74656e74456e747279706f696e740000000000000000000081522060016020604051610054816100fb565b82815201603160f81b815220906040519160208301917f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f8352604084015260608301524660808301523060a083015260a0825260c082019180831060018060401b038411176100e35782604052519020608052610cc19081610117823960805181818161023201526109190152f35b634e487b7160e01b5f52604160045260245ffd5b5f80fd5b604081019081106001600160401b038211176100e35760405256fe60806040526004361015610011575f80fd5b5f803560e01c90816312f354e814610097575080633644e515146100925780636336803b1461008d578063722d2b21146100885780637de5214a14610083578063b082a2741461007e578063ced4b1b1146100795763ffa1ad7414610074575f80fd5b610659565b610577565b61053d565b61046f565b6102f2565b610255565b61021b565b346101c85760803660031901126101c8576100b06101cb565b6100b86101e5565b9060443561013d6100c76101fb565b936100d0610870565b6100db831515610b46565b6001600160a01b03908116936100f2851515610b9c565b60208483881697610104891515610bf3565b6040516323b872dd60e01b81526001600160a01b0380861660048301529091166024820152604481019190915293849081906064820190565b03818a895af19283156101c3577ff9bd21d06c2809553dc957f943aead09741297cdd60122e21cd1f1ffeff93b0f9361017d918991610195575b50610824565b6040519384521691602090a461019260015f55565b80f35b6101b6915060203d81116101bc575b6101ae8183610637565b81019061080c565b89610177565b503d6101a4565b610801565b80fd5b600435906001600160a01b03821682036101e157565b5f80fd5b602435906001600160a01b03821682036101e157565b606435906001600160a01b03821682036101e157565b5f9103126101e157565b346101e1575f3660031901126101e15760206040517f00000000000000000000000000000000000000000000000000000000000000008152f35b346101e15760203660031901126101e1576004355f526001602052602060ff60405f2054166040519015158152f35b610124359060ff821682036101e157565b6101009060031901126101e1576001600160a01b039060043582811681036101e1579160243581811681036101e157916044359160643590811681036101e157906084359060a43560ff811681036101e1579060c4359060e43590565b346101e15761030036610295565b9591969061031095949395610870565b61031b851515610b46565b6001600160a01b0392831695610332871515610b9c565b83851697610341891515610bf3565b61034d82421115610c4e565b873b156101e15760405163d505accf60e01b81526001600160a01b038516600482015230602482015260448101889052606481019290925260ff99909916608482015260a481019190915260c48101979097525f96878160e481838a5af180156101c3576103f9946020928792610456575b506040516323b872dd60e01b81526001600160a01b0380861660048301529091166024820152604481019190915293849081906064820190565b03818a895af19283156101c3577ff9bd21d06c2809553dc957f943aead09741297cdd60122e21cd1f1ffeff93b0f9361017d9189916104385750610824565b610450915060203d81116101bc576101ae8183610637565b5f610177565b8061046361046992610602565b80610211565b5f6103bf565b346101e15761049b61048036610295565b92610492989496959798929192610870565b8688878b610891565b6040516323b872dd60e01b81526001600160a01b0385811660048301528381166024830152604482018590529091602090839060649082905f9086165af180156101c3577f09f4cd16d9914abc5d9360254d3fc994fbf62966b22dc73ef9be9412ab8cf1579361051583926020955f916105265750610824565b60405195865216941692a360015f55005b6104509150863d81116101bc576101ae8183610637565b346101e1575f3660031901126101e15760206040517f40587f93b59c9a39c7aafdfd84ed57bbb971ba09582e0a64691fd2b9390f16e88152f35b346101e1576101803660031901126101e1576105916101cb565b6105996101e5565b608435916001600160a01b03831683036101e15760c4359160ff831683036101e1576105ec936105c7610284565b9161016435946101443594610104359360e4359360a4359260643591604435916106cd565b005b634e487b7160e01b5f52604160045260245ffd5b67ffffffffffffffff811161061657604052565b6105ee565b6040810190811067ffffffffffffffff82111761061657604052565b90601f8019910116810190811067ffffffffffffffff82111761061657604052565b346101e1575f3660031901126101e15760408051906106778261061b565b600182526020603160f81b81840152815192818492835281519182828501525f5b8381106106b75750505f83830185015250601f01601f19168101030190f35b8181018301518782018701528694508201610698565b9a909794959899829a87866106f0958f8d909c98999c6106eb610870565b610891565b6001600160a01b0395861696873b156101e15760405163d505accf60e01b81526001600160a01b038b1660048201523060248201526044810193909352606483019490945260ff909316608482015260a481019290925260c48201525f8160e48183885af180156101c3576107ee575b506040516323b872dd60e01b81526001600160a01b038681166004830152821660248201526044810185905292602090849060649082905f905af19283156101c3577f09f4cd16d9914abc5d9360254d3fc994fbf62966b22dc73ef9be9412ab8cf157936107d4915f916104385750610824565b6040519384528116931691602090a36107ec60015f55565b565b806104636107fb92610602565b5f610760565b6040513d5f823e3d90fd5b908160209103126101e1575180151581036101e15790565b1561082b57565b60405162461bcd60e51b815260206004820152601960248201527f4552433230207472616e7366657246726f6d206661696c6564000000000000006044820152606490fd5b60025f541461087f5760025f55565b604051633ee5aeb560e01b8152600490fd5b949690959392919384156109ec576001600160a01b0394878616156109da57858416156109c8578442116109b657601e60c088889761094a9760429560409d8e8051957f40587f93b59c9a39c7aafdfd84ed57bbb971ba09582e0a64691fd2b9390f16e8875260208701528501526060840152608083015260a08201522089519061190182527f000000000000000000000000000000000000000000000000000000000000000060208301528a820152012097886109fe565b92169116036109a65761096f610968835f52600160205260405f2090565b5460ff1690565b61099657506109896107ec915f52600160205260405f2090565b805460ff19166001179055565b5163110ea83560e31b8152600490fd5b5163ebe0522960e01b8152600490fd5b604051631022c88d60e21b8152600490fd5b60405163b6a75fc160e01b8152600490fd5b60405163c1ab6dc160e01b8152600490fd5b60405163162908e360e11b8152600490fd5b91610a169391610a0d93610a19565b90929192610ab9565b90565b91907f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a08411610a9057926020929160ff6080956040519485521684840152604083015260608201525f92839182805260015afa156101c35780516001600160a01b03811615610a8757918190565b50809160019190565b5050505f9160039190565b60041115610aa557565b634e487b7160e01b5f52602160045260245ffd5b610ac281610a9b565b80610acb575050565b610ad481610a9b565b60018103610aee5760405163f645eedf60e01b8152600490fd5b610af781610a9b565b60028103610b185760405163fce698f760e01b815260048101839052602490fd5b80610b24600392610a9b565b14610b2c5750565b6040516335e2f38360e21b81526004810191909152602490fd5b15610b4d57565b60405162461bcd60e51b815260206004820152602160248201527f46656520616d6f756e74206d7573742062652067726561746572207468616e206044820152600360fc1b6064820152608490fd5b15610ba357565b60405162461bcd60e51b815260206004820152602260248201527f46656520746f6b656e206d757374206e6f74206265207a65726f206164647265604482015261737360f01b6064820152608490fd5b15610bfa57565b60405162461bcd60e51b815260206004820152602660248201527f46656520636f6c6c6563746f72206d757374206e6f74206265207a65726f206160448201526564647265737360d01b6064820152608490fd5b15610c5557565b60405162461bcd60e51b815260206004820152600e60248201526d14195c9b5a5d08195e1c1a5c995960921b6044820152606490fdfea26469706673582212203366f801a9dd67a430806205b2fe13555cbb6229ffefa043c3dab8dd1d21fb5164736f6c63430008140033

Deployed Bytecode

0x60806040526004361015610011575f80fd5b5f803560e01c90816312f354e814610097575080633644e515146100925780636336803b1461008d578063722d2b21146100885780637de5214a14610083578063b082a2741461007e578063ced4b1b1146100795763ffa1ad7414610074575f80fd5b610659565b610577565b61053d565b61046f565b6102f2565b610255565b61021b565b346101c85760803660031901126101c8576100b06101cb565b6100b86101e5565b9060443561013d6100c76101fb565b936100d0610870565b6100db831515610b46565b6001600160a01b03908116936100f2851515610b9c565b60208483881697610104891515610bf3565b6040516323b872dd60e01b81526001600160a01b0380861660048301529091166024820152604481019190915293849081906064820190565b03818a895af19283156101c3577ff9bd21d06c2809553dc957f943aead09741297cdd60122e21cd1f1ffeff93b0f9361017d918991610195575b50610824565b6040519384521691602090a461019260015f55565b80f35b6101b6915060203d81116101bc575b6101ae8183610637565b81019061080c565b89610177565b503d6101a4565b610801565b80fd5b600435906001600160a01b03821682036101e157565b5f80fd5b602435906001600160a01b03821682036101e157565b606435906001600160a01b03821682036101e157565b5f9103126101e157565b346101e1575f3660031901126101e15760206040517fb15cea2d8d05bf8f5703cd18450660d438df0267cd1aa41ef554bf2d071d97678152f35b346101e15760203660031901126101e1576004355f526001602052602060ff60405f2054166040519015158152f35b610124359060ff821682036101e157565b6101009060031901126101e1576001600160a01b039060043582811681036101e1579160243581811681036101e157916044359160643590811681036101e157906084359060a43560ff811681036101e1579060c4359060e43590565b346101e15761030036610295565b9591969061031095949395610870565b61031b851515610b46565b6001600160a01b0392831695610332871515610b9c565b83851697610341891515610bf3565b61034d82421115610c4e565b873b156101e15760405163d505accf60e01b81526001600160a01b038516600482015230602482015260448101889052606481019290925260ff99909916608482015260a481019190915260c48101979097525f96878160e481838a5af180156101c3576103f9946020928792610456575b506040516323b872dd60e01b81526001600160a01b0380861660048301529091166024820152604481019190915293849081906064820190565b03818a895af19283156101c3577ff9bd21d06c2809553dc957f943aead09741297cdd60122e21cd1f1ffeff93b0f9361017d9189916104385750610824565b610450915060203d81116101bc576101ae8183610637565b5f610177565b8061046361046992610602565b80610211565b5f6103bf565b346101e15761049b61048036610295565b92610492989496959798929192610870565b8688878b610891565b6040516323b872dd60e01b81526001600160a01b0385811660048301528381166024830152604482018590529091602090839060649082905f9086165af180156101c3577f09f4cd16d9914abc5d9360254d3fc994fbf62966b22dc73ef9be9412ab8cf1579361051583926020955f916105265750610824565b60405195865216941692a360015f55005b6104509150863d81116101bc576101ae8183610637565b346101e1575f3660031901126101e15760206040517f40587f93b59c9a39c7aafdfd84ed57bbb971ba09582e0a64691fd2b9390f16e88152f35b346101e1576101803660031901126101e1576105916101cb565b6105996101e5565b608435916001600160a01b03831683036101e15760c4359160ff831683036101e1576105ec936105c7610284565b9161016435946101443594610104359360e4359360a4359260643591604435916106cd565b005b634e487b7160e01b5f52604160045260245ffd5b67ffffffffffffffff811161061657604052565b6105ee565b6040810190811067ffffffffffffffff82111761061657604052565b90601f8019910116810190811067ffffffffffffffff82111761061657604052565b346101e1575f3660031901126101e15760408051906106778261061b565b600182526020603160f81b81840152815192818492835281519182828501525f5b8381106106b75750505f83830185015250601f01601f19168101030190f35b8181018301518782018701528694508201610698565b9a909794959899829a87866106f0958f8d909c98999c6106eb610870565b610891565b6001600160a01b0395861696873b156101e15760405163d505accf60e01b81526001600160a01b038b1660048201523060248201526044810193909352606483019490945260ff909316608482015260a481019290925260c48201525f8160e48183885af180156101c3576107ee575b506040516323b872dd60e01b81526001600160a01b038681166004830152821660248201526044810185905292602090849060649082905f905af19283156101c3577f09f4cd16d9914abc5d9360254d3fc994fbf62966b22dc73ef9be9412ab8cf157936107d4915f916104385750610824565b6040519384528116931691602090a36107ec60015f55565b565b806104636107fb92610602565b5f610760565b6040513d5f823e3d90fd5b908160209103126101e1575180151581036101e15790565b1561082b57565b60405162461bcd60e51b815260206004820152601960248201527f4552433230207472616e7366657246726f6d206661696c6564000000000000006044820152606490fd5b60025f541461087f5760025f55565b604051633ee5aeb560e01b8152600490fd5b949690959392919384156109ec576001600160a01b0394878616156109da57858416156109c8578442116109b657601e60c088889761094a9760429560409d8e8051957f40587f93b59c9a39c7aafdfd84ed57bbb971ba09582e0a64691fd2b9390f16e8875260208701528501526060840152608083015260a08201522089519061190182527fb15cea2d8d05bf8f5703cd18450660d438df0267cd1aa41ef554bf2d071d976760208301528a820152012097886109fe565b92169116036109a65761096f610968835f52600160205260405f2090565b5460ff1690565b61099657506109896107ec915f52600160205260405f2090565b805460ff19166001179055565b5163110ea83560e31b8152600490fd5b5163ebe0522960e01b8152600490fd5b604051631022c88d60e21b8152600490fd5b60405163b6a75fc160e01b8152600490fd5b60405163c1ab6dc160e01b8152600490fd5b60405163162908e360e11b8152600490fd5b91610a169391610a0d93610a19565b90929192610ab9565b90565b91907f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a08411610a9057926020929160ff6080956040519485521684840152604083015260608201525f92839182805260015afa156101c35780516001600160a01b03811615610a8757918190565b50809160019190565b5050505f9160039190565b60041115610aa557565b634e487b7160e01b5f52602160045260245ffd5b610ac281610a9b565b80610acb575050565b610ad481610a9b565b60018103610aee5760405163f645eedf60e01b8152600490fd5b610af781610a9b565b60028103610b185760405163fce698f760e01b815260048101839052602490fd5b80610b24600392610a9b565b14610b2c5750565b6040516335e2f38360e21b81526004810191909152602490fd5b15610b4d57565b60405162461bcd60e51b815260206004820152602160248201527f46656520616d6f756e74206d7573742062652067726561746572207468616e206044820152600360fc1b6064820152608490fd5b15610ba357565b60405162461bcd60e51b815260206004820152602260248201527f46656520746f6b656e206d757374206e6f74206265207a65726f206164647265604482015261737360f01b6064820152608490fd5b15610bfa57565b60405162461bcd60e51b815260206004820152602660248201527f46656520636f6c6c6563746f72206d757374206e6f74206265207a65726f206160448201526564647265737360d01b6064820152608490fd5b15610c5557565b60405162461bcd60e51b815260206004820152600e60248201526d14195c9b5a5d08195e1c1a5c995960921b6044820152606490fdfea26469706673582212203366f801a9dd67a430806205b2fe13555cbb6229ffefa043c3dab8dd1d21fb5164736f6c63430008140033

Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

Block Uncle Number Difficulty Gas Used Reward
View All Uncles
Loading...
Loading
Loading...
Loading

Validator Index Block Amount
View All Withdrawals

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits
0x92Dc1cCE6767F82494BCBC54235A08B4FD457c26
Loading...
Loading
Loading...
Loading

A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.