Arbitrum Sepolia Testnet

Contract

0x9851F23AB63b9a095b59840E1e6D6415D32F9f01
Source Code Source Code

Overview

ETH Balance

0 ETH

More Info

Multichain Info

N/A
Transaction Hash
Method
Block
From
To
Amount

There are no matching entries

Please try again later

Parent Transaction Hash Block From To Amount
View All Internal Transactions

Loading...
Loading

Similar Match Source Code
This contract matches the deployed Bytecode of the Source Code for Contract 0x56666D39...8aFB4A875
The constructor portion of the code might be different and could alter the actual behaviour of the contract

Contract Name:
ClearingHouse

Compiler Version
v0.8.28+commit.7893614a

Optimization Enabled:
Yes with 200 runs

Other Settings:
paris EvmVersion

Contract Source Code (Solidity Standard Json-Input format)

// SPDX-License-Identifier: LicenseRef-P3-DUAL
// For terms and conditions regarding commercial use please see https://license.premia.blue
pragma solidity 0.8.28;

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

import {HashData} from "../libraries/HashData.sol";

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

import {IClearingHouse} from "./IClearingHouse.sol";
import {InactiveWithdrawal} from "./InactiveWithdrawal.sol";

contract ClearingHouse is IClearingHouse, InactiveWithdrawal, SignatureValidation {
    using SafeERC20 for IERC20;

    IERC20 private immutable COLLATERAL;

    constructor(
        address admin,
        address relayer,
        IERC20 collateral
    ) InactiveWithdrawal(relayer, collateral) SignatureValidation(admin) {
        COLLATERAL = collateral;
    }

    /// @inheritdoc IClearingHouse
    function deposit(
        UserSignature calldata sigUser,
        Signature calldata sigProtocol,
        DepositArgs calldata depositArgs
    ) external nonReentrant {
        _revertIfZeroAddress(depositArgs.to);
        _revertIfZeroAmount(depositArgs.amount);

        _revertIfInvalidSignature(
            depositArgs.from,
            HashData.hashDepositOrWithdraw(
                sigUser,
                true,
                depositArgs.to,
                depositArgs.from,
                depositArgs.amount,
                depositArgs.pair
            ),
            sigUser.signature
        );

        _handleProtocolSignatureValidation(
            HashData.hashDepositOrWithdraw(
                sigProtocol,
                true,
                depositArgs.to,
                depositArgs.from,
                depositArgs.amount,
                depositArgs.pair
            ),
            sigProtocol
        );

        COLLATERAL.safeTransferFrom(depositArgs.from, address(this), depositArgs.amount);

        emit Deposit(depositArgs.to, depositArgs.from, depositArgs.pair, depositArgs.amount);
    }

    /// @inheritdoc IClearingHouse
    function withdraw(
        UserSignature calldata sigUser,
        Signature calldata sigProtocol,
        WithdrawArgs calldata withdrawArgs
    ) external nonReentrant {
        _revertIfZeroAddress(withdrawArgs.to);
        _revertIfZeroAmount(withdrawArgs.amount);

        _revertIfInvalidSignature(
            withdrawArgs.from,
            HashData.hashDepositOrWithdraw(
                sigUser,
                false,
                withdrawArgs.to,
                withdrawArgs.from,
                withdrawArgs.amount,
                withdrawArgs.pair
            ),
            sigUser.signature
        );

        _handleProtocolSignatureValidation(
            HashData.hashDepositOrWithdraw(
                sigProtocol,
                false,
                withdrawArgs.to,
                withdrawArgs.from,
                withdrawArgs.amount,
                withdrawArgs.pair
            ),
            sigProtocol
        );

        COLLATERAL.safeTransfer(withdrawArgs.to, withdrawArgs.amount);

        emit Withdraw(withdrawArgs.to, withdrawArgs.from, withdrawArgs.pair, withdrawArgs.amount);
    }

    /// @notice Reverts if `account` is the zero address
    function _revertIfZeroAddress(address account) internal pure {
        if (account == address(0)) revert ClearingHouse_ZeroAddress();
    }

    /// @notice Reverts if `amount` is zero
    function _revertIfZeroAmount(uint256 amount) internal pure {
        if (amount == 0) revert ClearingHouse_ZeroAmount();
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (proxy/utils/Initializable.sol)

pragma solidity ^0.8.20;

/**
 * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
 * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an
 * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
 * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
 *
 * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be
 * reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in
 * case an upgrade adds a module that needs to be initialized.
 *
 * For example:
 *
 * [.hljs-theme-light.nopadding]
 * ```solidity
 * contract MyToken is ERC20Upgradeable {
 *     function initialize() initializer public {
 *         __ERC20_init("MyToken", "MTK");
 *     }
 * }
 *
 * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {
 *     function initializeV2() reinitializer(2) public {
 *         __ERC20Permit_init("MyToken");
 *     }
 * }
 * ```
 *
 * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
 * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.
 *
 * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
 * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
 *
 * [CAUTION]
 * ====
 * Avoid leaving a contract uninitialized.
 *
 * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation
 * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke
 * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:
 *
 * [.hljs-theme-light.nopadding]
 * ```
 * /// @custom:oz-upgrades-unsafe-allow constructor
 * constructor() {
 *     _disableInitializers();
 * }
 * ```
 * ====
 */
abstract contract Initializable {
    /**
     * @dev Storage of the initializable contract.
     *
     * It's implemented on a custom ERC-7201 namespace to reduce the risk of storage collisions
     * when using with upgradeable contracts.
     *
     * @custom:storage-location erc7201:openzeppelin.storage.Initializable
     */
    struct InitializableStorage {
        /**
         * @dev Indicates that the contract has been initialized.
         */
        uint64 _initialized;
        /**
         * @dev Indicates that the contract is in the process of being initialized.
         */
        bool _initializing;
    }

    // keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.Initializable")) - 1)) & ~bytes32(uint256(0xff))
    bytes32 private constant INITIALIZABLE_STORAGE = 0xf0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00;

    /**
     * @dev The contract is already initialized.
     */
    error InvalidInitialization();

    /**
     * @dev The contract is not initializing.
     */
    error NotInitializing();

    /**
     * @dev Triggered when the contract has been initialized or reinitialized.
     */
    event Initialized(uint64 version);

    /**
     * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,
     * `onlyInitializing` functions can be used to initialize parent contracts.
     *
     * Similar to `reinitializer(1)`, except that in the context of a constructor an `initializer` may be invoked any
     * number of times. This behavior in the constructor can be useful during testing and is not expected to be used in
     * production.
     *
     * Emits an {Initialized} event.
     */
    modifier initializer() {
        // solhint-disable-next-line var-name-mixedcase
        InitializableStorage storage $ = _getInitializableStorage();

        // Cache values to avoid duplicated sloads
        bool isTopLevelCall = !$._initializing;
        uint64 initialized = $._initialized;

        // Allowed calls:
        // - initialSetup: the contract is not in the initializing state and no previous version was
        //                 initialized
        // - construction: the contract is initialized at version 1 (no reininitialization) and the
        //                 current contract is just being deployed
        bool initialSetup = initialized == 0 && isTopLevelCall;
        bool construction = initialized == 1 && address(this).code.length == 0;

        if (!initialSetup && !construction) {
            revert InvalidInitialization();
        }
        $._initialized = 1;
        if (isTopLevelCall) {
            $._initializing = true;
        }
        _;
        if (isTopLevelCall) {
            $._initializing = false;
            emit Initialized(1);
        }
    }

    /**
     * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the
     * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be
     * used to initialize parent contracts.
     *
     * A reinitializer may be used after the original initialization step. This is essential to configure modules that
     * are added through upgrades and that require initialization.
     *
     * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`
     * cannot be nested. If one is invoked in the context of another, execution will revert.
     *
     * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in
     * a contract, executing them in the right order is up to the developer or operator.
     *
     * WARNING: Setting the version to 2**64 - 1 will prevent any future reinitialization.
     *
     * Emits an {Initialized} event.
     */
    modifier reinitializer(uint64 version) {
        // solhint-disable-next-line var-name-mixedcase
        InitializableStorage storage $ = _getInitializableStorage();

        if ($._initializing || $._initialized >= version) {
            revert InvalidInitialization();
        }
        $._initialized = version;
        $._initializing = true;
        _;
        $._initializing = false;
        emit Initialized(version);
    }

    /**
     * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the
     * {initializer} and {reinitializer} modifiers, directly or indirectly.
     */
    modifier onlyInitializing() {
        _checkInitializing();
        _;
    }

    /**
     * @dev Reverts if the contract is not in an initializing state. See {onlyInitializing}.
     */
    function _checkInitializing() internal view virtual {
        if (!_isInitializing()) {
            revert NotInitializing();
        }
    }

    /**
     * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.
     * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized
     * to any version. It is recommended to use this to lock implementation contracts that are designed to be called
     * through proxies.
     *
     * Emits an {Initialized} event the first time it is successfully executed.
     */
    function _disableInitializers() internal virtual {
        // solhint-disable-next-line var-name-mixedcase
        InitializableStorage storage $ = _getInitializableStorage();

        if ($._initializing) {
            revert InvalidInitialization();
        }
        if ($._initialized != type(uint64).max) {
            $._initialized = type(uint64).max;
            emit Initialized(type(uint64).max);
        }
    }

    /**
     * @dev Returns the highest version that has been initialized. See {reinitializer}.
     */
    function _getInitializedVersion() internal view returns (uint64) {
        return _getInitializableStorage()._initialized;
    }

    /**
     * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.
     */
    function _isInitializing() internal view returns (bool) {
        return _getInitializableStorage()._initializing;
    }

    /**
     * @dev Returns a pointer to the storage namespace.
     */
    // solhint-disable-next-line var-name-mixedcase
    function _getInitializableStorage() private pure returns (InitializableStorage storage $) {
        assembly {
            $.slot := INITIALIZABLE_STORAGE
        }
    }
}

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

pragma solidity ^0.8.20;
import {Initializable} from "../proxy/utils/Initializable.sol";

/**
 * @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 ReentrancyGuardUpgradeable is Initializable {
    // 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;

    /// @custom:storage-location erc7201:openzeppelin.storage.ReentrancyGuard
    struct ReentrancyGuardStorage {
        uint256 _status;
    }

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

    function _getReentrancyGuardStorage() private pure returns (ReentrancyGuardStorage storage $) {
        assembly {
            $.slot := ReentrancyGuardStorageLocation
        }
    }

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

    function __ReentrancyGuard_init() internal onlyInitializing {
        __ReentrancyGuard_init_unchained();
    }

    function __ReentrancyGuard_init_unchained() internal onlyInitializing {
        ReentrancyGuardStorage storage $ = _getReentrancyGuardStorage();
        $._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 {
        ReentrancyGuardStorage storage $ = _getReentrancyGuardStorage();
        // 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 {
        ReentrancyGuardStorage storage $ = _getReentrancyGuardStorage();
        // 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) {
        ReentrancyGuardStorage storage $ = _getReentrancyGuardStorage();
        return $._status == ENTERED;
    }
}

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

pragma solidity ^0.8.20;

/**
 * @dev Interface of the ERC-1271 standard signature validation method for
 * contracts as defined in https://eips.ethereum.org/EIPS/eip-1271[ERC-1271].
 */
interface IERC1271 {
    /**
     * @dev Should return whether the signature provided is valid for the provided data
     * @param hash      Hash of the data to be signed
     * @param signature Signature byte array associated with _data
     */
    function isValidSignature(bytes32 hash, bytes memory signature) external view returns (bytes4 magicValue);
}

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

pragma solidity ^0.8.20;

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);
}

File 6 of 23 : IERC165.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC165.sol)

pragma solidity ^0.8.20;

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

File 7 of 23 : IERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC20.sol)

pragma solidity ^0.8.20;

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

// 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/utils/SafeERC20.sol)

pragma solidity ^0.8.20;

import {IERC20} from "../IERC20.sol";
import {IERC1363} from "../../../interfaces/IERC1363.sol";
import {Address} from "../../../utils/Address.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 {
        _callOptionalReturn(token, abi.encodeCall(token.transfer, (to, value)));
    }

    /**
     * @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 {
        _callOptionalReturn(token, abi.encodeCall(token.transferFrom, (from, to, value)));
    }

    /**
     * @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 {
        bytes memory approvalCall = abi.encodeCall(token.approve, (spender, value));

        if (!_callOptionalReturnBool(token, approvalCall)) {
            _callOptionalReturn(token, abi.encodeCall(token.approve, (spender, 0)));
            _callOptionalReturn(token, approvalCall);
        }
    }

    /**
     * @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 rely 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 rely 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}.
     * Opposedly, 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 high-level call (i.e. a regular function call to a contract), 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 data The call data (encoded using abi.encode or one of its variants).
     *
     * This is a variant of {_callOptionalReturnBool} that reverts if call fails to meet the requirements.
     */
    function _callOptionalReturn(IERC20 token, bytes memory data) private {
        uint256 returnSize;
        uint256 returnValue;
        assembly ("memory-safe") {
            let success := call(gas(), token, 0, add(data, 0x20), mload(data), 0, 0x20)
            // bubble errors
            if iszero(success) {
                let ptr := mload(0x40)
                returndatacopy(ptr, 0, returndatasize())
                revert(ptr, returndatasize())
            }
            returnSize := returndatasize()
            returnValue := mload(0)
        }

        if (returnSize == 0 ? address(token).code.length == 0 : returnValue != 1) {
            revert SafeERC20FailedOperation(address(token));
        }
    }

    /**
     * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), 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 data The call data (encoded using abi.encode or one of its variants).
     *
     * This is a variant of {_callOptionalReturn} that silently catches all reverts and returns a bool instead.
     */
    function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
        bool success;
        uint256 returnSize;
        uint256 returnValue;
        assembly ("memory-safe") {
            success := call(gas(), token, 0, add(data, 0x20), mload(data), 0, 0x20)
            returnSize := returndatasize()
            returnValue := mload(0)
        }
        return success && (returnSize == 0 ? address(token).code.length > 0 : returnValue == 1);
    }
}

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

pragma solidity ^0.8.20;

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

/**
 * @dev Collection of functions related to the address type
 */
library Address {
    /**
     * @dev There's no code at `target` (it is not a contract).
     */
    error AddressEmptyCode(address target);

    /**
     * @dev Replacement for Solidity's `transfer`: sends `amount` wei to
     * `recipient`, forwarding all available gas and reverting on errors.
     *
     * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
     * of certain opcodes, possibly making contracts go over the 2300 gas limit
     * imposed by `transfer`, making them unable to receive funds via
     * `transfer`. {sendValue} removes this limitation.
     *
     * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].
     *
     * IMPORTANT: because control is transferred to `recipient`, care must be
     * taken to not create reentrancy vulnerabilities. Consider using
     * {ReentrancyGuard} or the
     * https://solidity.readthedocs.io/en/v0.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
     */
    function sendValue(address payable recipient, uint256 amount) internal {
        if (address(this).balance < amount) {
            revert Errors.InsufficientBalance(address(this).balance, amount);
        }

        (bool success, ) = recipient.call{value: amount}("");
        if (!success) {
            revert Errors.FailedCall();
        }
    }

    /**
     * @dev Performs a Solidity function call using a low level `call`. A
     * plain `call` is an unsafe replacement for a function call: use this
     * function instead.
     *
     * If `target` reverts with a revert reason or custom error, it is bubbled
     * up by this function (like regular Solidity function calls). However, if
     * the call reverted with no returned reason, this function reverts with a
     * {Errors.FailedCall} error.
     *
     * Returns the raw returned data. To convert to the expected return value,
     * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
     *
     * Requirements:
     *
     * - `target` must be a contract.
     * - calling `target` with `data` must not revert.
     */
    function functionCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionCallWithValue(target, data, 0);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but also transferring `value` wei to `target`.
     *
     * Requirements:
     *
     * - the calling contract must have an ETH balance of at least `value`.
     * - the called Solidity function must be `payable`.
     */
    function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
        if (address(this).balance < value) {
            revert Errors.InsufficientBalance(address(this).balance, value);
        }
        (bool success, bytes memory returndata) = target.call{value: value}(data);
        return verifyCallResultFromTarget(target, success, returndata);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a static call.
     */
    function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
        (bool success, bytes memory returndata) = target.staticcall(data);
        return verifyCallResultFromTarget(target, success, returndata);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a delegate call.
     */
    function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
        (bool success, bytes memory returndata) = target.delegatecall(data);
        return verifyCallResultFromTarget(target, success, returndata);
    }

    /**
     * @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target
     * was not a contract or bubbling up the revert reason (falling back to {Errors.FailedCall}) in case
     * of an unsuccessful call.
     */
    function verifyCallResultFromTarget(
        address target,
        bool success,
        bytes memory returndata
    ) internal view returns (bytes memory) {
        if (!success) {
            _revert(returndata);
        } else {
            // only check if target is a contract if the call was successful and the return data is empty
            // otherwise we already know that it was a contract
            if (returndata.length == 0 && target.code.length == 0) {
                revert AddressEmptyCode(target);
            }
            return returndata;
        }
    }

    /**
     * @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the
     * revert reason or with a default {Errors.FailedCall} error.
     */
    function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) {
        if (!success) {
            _revert(returndata);
        } else {
            return returndata;
        }
    }

    /**
     * @dev Reverts with returndata if present. Otherwise reverts with {Errors.FailedCall}.
     */
    function _revert(bytes memory returndata) private pure {
        // Look for revert reason and bubble it up if present
        if (returndata.length > 0) {
            // The easiest way to bubble the revert reason is using memory via assembly
            assembly ("memory-safe") {
                let returndata_size := mload(returndata)
                revert(add(32, returndata), returndata_size)
            }
        } else {
            revert Errors.FailedCall();
        }
    }
}

// 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/cryptography/SignatureChecker.sol)

pragma solidity ^0.8.20;

import {ECDSA} from "./ECDSA.sol";
import {IERC1271} from "../../interfaces/IERC1271.sol";

/**
 * @dev Signature verification helper that can be used instead of `ECDSA.recover` to seamlessly support both ECDSA
 * signatures from externally owned accounts (EOAs) as well as ERC-1271 signatures from smart contract wallets like
 * Argent and Safe Wallet (previously Gnosis Safe).
 */
library SignatureChecker {
    /**
     * @dev Checks if a signature is valid for a given signer and data hash. If the signer is a smart contract, the
     * signature is validated against that smart contract using ERC-1271, otherwise it's validated using `ECDSA.recover`.
     *
     * NOTE: Unlike ECDSA signatures, contract signatures are revocable, and the outcome of this function can thus
     * change through time. It could return true at block N and false at block N+1 (or the opposite).
     */
    function isValidSignatureNow(address signer, bytes32 hash, bytes memory signature) internal view returns (bool) {
        if (signer.code.length == 0) {
            (address recovered, ECDSA.RecoverError err, ) = ECDSA.tryRecover(hash, signature);
            return err == ECDSA.RecoverError.NoError && recovered == signer;
        } else {
            return isValidERC1271SignatureNow(signer, hash, signature);
        }
    }

    /**
     * @dev Checks if a signature is valid for a given signer and data hash. The signature is validated
     * against the signer smart contract using ERC-1271.
     *
     * NOTE: Unlike ECDSA signatures, contract signatures are revocable, and the outcome of this function can thus
     * change through time. It could return true at block N and false at block N+1 (or the opposite).
     */
    function isValidERC1271SignatureNow(
        address signer,
        bytes32 hash,
        bytes memory signature
    ) internal view returns (bool) {
        (bool success, bytes memory result) = signer.staticcall(
            abi.encodeCall(IERC1271.isValidSignature, (hash, signature))
        );
        return (success &&
            result.length >= 32 &&
            abi.decode(result, (bytes32)) == bytes32(IERC1271.isValidSignature.selector));
    }
}

File 13 of 23 : Errors.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/Errors.sol)

pragma solidity ^0.8.20;

/**
 * @dev Collection of common custom errors used in multiple contracts
 *
 * IMPORTANT: Backwards compatibility is not guaranteed in future versions of the library.
 * It is recommended to avoid relying on the error API for critical functionality.
 *
 * _Available since v5.1._
 */
library Errors {
    /**
     * @dev The ETH balance of the account is not enough to perform the operation.
     */
    error InsufficientBalance(uint256 balance, uint256 needed);

    /**
     * @dev A call to an address target failed. The target may have reverted.
     */
    error FailedCall();

    /**
     * @dev The deployment failed.
     */
    error FailedDeployment();

    /**
     * @dev A necessary precompile is missing.
     */
    error MissingPrecompile(address);
}

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

pragma solidity ^0.8.20;

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

// SPDX-License-Identifier: LGPL-3.0-or-later
// For terms and conditions regarding commercial use please see https://license.premia.blue
pragma solidity ^0.8.28;

import {IERC20} from "@openzeppelin/contracts/interfaces/IERC20.sol";

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

interface IClearingHouse is ISignatureValidation {
    error ClearingHouse_ArrayLengthsMismatched();
    error ClearingHouse_ZeroAddress();
    error ClearingHouse_ZeroAmount();

    event Deposit(address indexed to, address indexed from, Pair pair, uint256 amount);
    event Withdraw(address indexed to, address indexed from, Pair pair, uint256 amount);

    struct Pair {
        // The base asset
        IERC20 base;
        // The quote asset
        IERC20 quote;
    }

    struct DepositArgs {
        // The address receiving the deposit
        address to;
        // The address depositing `amount`
        address from;
        // The amount deposited (6 decimals)
        uint256 amount;
        // The pair credited
        Pair pair;
    }

    struct WithdrawArgs {
        // The address receiving the withdrawal
        address to;
        // The address withdrawing `amount`
        address from;
        // The amount withdrawn (6 decimals)
        uint256 amount;
        // The pair debited
        Pair pair;
    }

    // @notice Deposit an amount of a token into `ClearingHouse`
    /// @param sigUser The signature of the user
    /// @param sigProtocol The signature of the protocol
    /// @param depositArgs Deposit argument struct, used to reduce stack depth
    function deposit(
        UserSignature calldata sigUser,
        Signature calldata sigProtocol,
        DepositArgs calldata depositArgs
    ) external;

    /// @notice Withdraw an amount of a token from `ClearingHouse`
    /// @param sigUser The signature of the user
    /// @param sigProtocol The signature of the protocol
    /// @param withdrawArgs Withdraw argument struct, used to reduce stack depth
    function withdraw(
        UserSignature calldata sigUser,
        Signature calldata sigProtocol,
        WithdrawArgs calldata withdrawArgs
    ) external;
}

// SPDX-License-Identifier: LGPL-3.0-or-later
// For terms and conditions regarding commercial use please see https://license.premia.blue
pragma solidity ^0.8.28;

interface IInactiveWithdrawal {
    error InactiveWithdrawal_MsgSenderNotRelayer();
    error InactiveWithdrawal_NotInactive();
    error InactiveWithdrawal_ZeroAmount();

    event InactiveWithdrawalAmountsUpdated(address[] accounts, uint256[] amounts, uint256 total);

    event InactiveWithdrawalSuccess(address indexed account, uint256 amount);

    /// @notice Update equity amounts for accounts. Only callable by the relayer.
    /// @param accounts The accounts to update
    /// @param amounts The amounts to set for each account
    function updateInactiveWithdrawalAmounts(address[] calldata accounts, uint256[] calldata amounts) external;

    /// @notice Returns the total amount accounted for in total, available for withdrawal in case of inactivity.
    ///         This can be compared to token balance of the contract for verification purpose
    function getInactiveWithdrawalTotal() external view returns (uint256);

    /// @notice Get the withdrawal equity amount for the given account, if contract becomes inactive.
    function getInactiveWithdrawalAmount(address account) external view returns (uint256);

    /// @notice Withdraw allocated equity from the inactive withdrawal contract. Only callable if inactive.
    function inactiveWithdrawal() external;
}

// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.28;

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

import {IInactiveWithdrawal} from "./IInactiveWithdrawal.sol";
import {InactiveWithdrawalStorage} from "./InactiveWithdrawalStorage.sol";

// Let users withdraw their equity from the contract if the contract becomes inactive.
abstract contract InactiveWithdrawal is IInactiveWithdrawal, ReentrancyGuardUpgradeable {
    using SafeERC20 for IERC20;

    uint256 private constant INACTIVE_DELAY = 30 days;
    address private immutable RELAYER;
    IERC20 private immutable COLLATERAL;

    constructor(address relayer, IERC20 collateral) {
        RELAYER = relayer;
        COLLATERAL = collateral;
    }

    // @inheritdoc IInactiveWithdrawal
    function updateInactiveWithdrawalAmounts(
        address[] calldata accounts,
        uint256[] calldata amounts
    ) external nonReentrant {
        _revertIfMsgSenderNotRelayer();

        InactiveWithdrawalStorage.Layout storage $ = InactiveWithdrawalStorage.layout();

        uint256 total = $.total;

        for (uint256 i = 0; i < accounts.length; i++) {
            address account = accounts[i];
            uint256 amount = amounts[i];

            uint256 previousAmount = $.amounts[account];
            total = total + amount - previousAmount;
            $.amounts[account] = amount;
        }

        $.total = total;
        $.lastUpdateTimestamp = block.timestamp;

        emit InactiveWithdrawalAmountsUpdated(accounts, amounts, total);
    }

    // @inheritdoc IInactiveWithdrawal
    function getInactiveWithdrawalTotal() external view returns (uint256) {
        return InactiveWithdrawalStorage.layout().total;
    }

    // @inheritdoc IInactiveWithdrawal
    function getInactiveWithdrawalAmount(address account) external view returns (uint256) {
        return InactiveWithdrawalStorage.layout().amounts[account];
    }

    // @inheritdoc IInactiveWithdrawal
    function inactiveWithdrawal() external nonReentrant {
        _revertIfNotInactive();

        InactiveWithdrawalStorage.Layout storage $ = InactiveWithdrawalStorage.layout();

        uint256 amount = $.amounts[msg.sender];
        if (amount == 0) revert InactiveWithdrawal_ZeroAmount();

        delete $.amounts[msg.sender];
        $.total -= amount;
        COLLATERAL.safeTransfer(msg.sender, amount);

        emit InactiveWithdrawalSuccess(msg.sender, amount);
    }

    function _revertIfNotInactive() internal view {
        if (InactiveWithdrawalStorage.layout().lastUpdateTimestamp + INACTIVE_DELAY > block.timestamp) {
            revert InactiveWithdrawal_NotInactive();
        }
    }

    function _revertIfMsgSenderNotRelayer() internal view {
        if (msg.sender != RELAYER) revert InactiveWithdrawal_MsgSenderNotRelayer();
    }
}

File 18 of 23 : InactiveWithdrawalStorage.sol
// SPDX-License-Identifier: LGPL-3.0-or-later
// For terms and conditions regarding commercial use please see https://license.premia.blue
pragma solidity ^0.8.28;

library InactiveWithdrawalStorage {
    // solhint-disable max-line-length
    // keccak256(abi.encode(uint256(keccak256("premia.contracts.storage.InactiveWithdrawal")) - 1)) & ~bytes32(uint256(0xff))
    bytes32 internal constant STORAGE_SLOT = 0x485f19e8579a45ae2ad3a7bba9fcb0ca2811febe4da08488f5c42f3456bca400;

    /// @custom:storage-location erc7201:premia.contracts.storage.InactiveWithdrawal
    struct Layout {
        mapping(address account => uint256) amounts;
        uint256 total;
        uint256 lastUpdateTimestamp;
    }

    function layout() internal pure returns (Layout storage $) {
        assembly {
            $.slot := STORAGE_SLOT
        }
    }
}

// SPDX-License-Identifier: LGPL-3.0-or-later
// For terms and conditions regarding commercial use please see https://license.premia.blue
pragma solidity ^0.8.28;

interface ISignatureValidation {
    error SignatureValidation_InvalidNonce(bytes32 nonce);
    error SignatureValidation_InvalidSignature(address signer, bytes32 hash, bytes signature);
    error SignatureValidation_MsgSenderNotAdmin();
    error SignatureValidation_SignatureExpired(uint256 blockTimestamp, uint256 sigDeadline);

    event UpdateAuthorizedSigner(address indexed authorizedSigner);

    struct UserSignature {
        uint256 deadline; // for off-chain use only
        bytes signature;
    }

    struct Signature {
        bytes32 nonce;
        uint256 deadline;
        bytes signature;
    }

    /// @notice Returns whether a nonce is valid
    /// @return Whether a nonce is valid
    function isValidNonce(bytes32 nonce) external view returns (bool);

    /// @notice Returns the authorized signer
    /// @return The authorized signer
    function getAuthorizedSigner() external view returns (address);

    /// @notice Update the authorized signer. Only callable by admin.
    /// @param newAuthorizedSigner The new authorized signer
    function updateAuthorizedSigner(address newAuthorizedSigner) external;

    /// @notice Invalidate the current nonce
    /// @param sigProtocol The signature of the protocol
    function invalidateNonce(Signature calldata sigProtocol) external;
}

// SPDX-License-Identifier: LicenseRef-P3-DUAL
// For terms and conditions regarding commercial use please see https://license.premia.blue
pragma solidity 0.8.28;

import {SignatureChecker} from "@openzeppelin/contracts/utils/cryptography/SignatureChecker.sol";
import {ReentrancyGuardUpgradeable} from "@openzeppelin/contracts-upgradeable/utils/ReentrancyGuardUpgradeable.sol";

import {HashData} from "../libraries/HashData.sol";

import {ISignatureValidation} from "./ISignatureValidation.sol";
import {SignatureValidationStorage} from "./SignatureValidationStorage.sol";

abstract contract SignatureValidation is ISignatureValidation, ReentrancyGuardUpgradeable {
    using SignatureValidationStorage for SignatureValidationStorage.Layout;

    address private immutable ADMIN;

    constructor(address admin) {
        ADMIN = admin;
    }

    /// @inheritdoc ISignatureValidation
    function isValidNonce(bytes32 nonce) external view returns (bool) {
        return !SignatureValidationStorage.layout().nonces[nonce];
    }

    /// @inheritdoc ISignatureValidation
    function getAuthorizedSigner() external view returns (address) {
        return SignatureValidationStorage.layout().authorizedSigner;
    }

    /// @inheritdoc ISignatureValidation
    function updateAuthorizedSigner(address newAuthorizedSigner) external nonReentrant {
        _revertIfMsgSenderNotAdmin();
        SignatureValidationStorage.layout().authorizedSigner = newAuthorizedSigner;
        emit UpdateAuthorizedSigner(newAuthorizedSigner);
    }

    /// @inheritdoc ISignatureValidation
    function invalidateNonce(Signature calldata sigProtocol) external nonReentrant {
        _handleProtocolSignatureValidation(HashData.hashInvalidateNonce(sigProtocol), sigProtocol);
    }

    /// @notice Validates the protocol signature and increments nonce
    function _handleProtocolSignatureValidation(bytes32 hash, Signature memory sigProtocol) internal {
        SignatureValidationStorage.Layout storage $ = SignatureValidationStorage.layout();
        _isSigProtocolValid($, sigProtocol, hash);
        _invalidateNonce($, sigProtocol.nonce);
    }

    /// @notice Returns true if the `sigProtocol` is valid, reverts otherwise
    function _isSigProtocolValid(
        SignatureValidationStorage.Layout storage $,
        Signature memory sigProtocol,
        bytes32 hash
    ) internal view returns (bool) {
        if ($.nonces[sigProtocol.nonce]) {
            revert SignatureValidation_InvalidNonce(sigProtocol.nonce);
        }

        if (block.timestamp > sigProtocol.deadline) {
            revert SignatureValidation_SignatureExpired(block.timestamp, sigProtocol.deadline);
        }

        _revertIfInvalidSignature($.authorizedSigner, hash, sigProtocol.signature);

        return true;
    }

    /// @notice Invalidates the nonce so signature cannot be replayed
    function _invalidateNonce(SignatureValidationStorage.Layout storage $, bytes32 nonce) internal {
        $.nonces[nonce] = true;
    }

    /// @notice Reverts if `signature` is invalid
    function _revertIfInvalidSignature(address signer, bytes32 hash, bytes memory signature) internal view {
        if (!SignatureChecker.isValidSignatureNow(signer, hash, signature)) {
            revert SignatureValidation_InvalidSignature(signer, hash, signature);
        }
    }

    /// @notice Reverts if `msg.sender` is not the admin
    function _revertIfMsgSenderNotAdmin() internal view {
        if (msg.sender != ADMIN) revert SignatureValidation_MsgSenderNotAdmin();
    }
}

File 21 of 23 : SignatureValidationStorage.sol
// SPDX-License-Identifier: LGPL-3.0-or-later
// For terms and conditions regarding commercial use please see https://license.premia.blue
pragma solidity ^0.8.28;

library SignatureValidationStorage {
    // solhint-disable max-line-length
    // keccak256(abi.encode(uint256(keccak256("premia.contracts.storage.SignatureValidation")) - 1)) & ~bytes32(uint256(0xff))
    bytes32 internal constant STORAGE_SLOT = 0x85b5f04927eaaf239153468141c2b533a4d7c40a442dfda1da227f2cba882300;

    /// @custom:storage-location erc7201:premia.contracts.storage.SignatureValidation
    struct Layout {
        address authorizedSigner;
        mapping(bytes32 => bool) nonces;
    }

    function layout() internal pure returns (Layout storage $) {
        assembly {
            $.slot := STORAGE_SLOT
        }
    }
}

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

// solhint-disable-next-line max-line-length
/// @notice Derived from https://github.com/solidstate-network/solidstate-solidity/blob/d1ba52d0981e3d1e1feda525dca8dd0c07ea4a00/contracts/cryptography/EIP712.sol
/// @title EIP-712 typed structured data hashing and signing
/// @dev see https://eips.ethereum.org/EIPS/eip-712
library EIP712 {
    bytes32 internal constant EIP712_TYPE_HASH =
        keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)");

    /// @notice calculate unique EIP-712 domain separator
    /// @dev name and version inputs are hashed as required by EIP-712 because they are of dynamic-length types
    /// @dev implementation of EIP712Domain struct type excludes the optional salt parameter
    /// @param nameHash hash of human-readable signing domain name
    /// @param versionHash hash of signing domain version
    /// @return domainSeparator domain separator
    function calculateDomainSeparator(
        bytes32 nameHash,
        bytes32 versionHash
    ) internal view returns (bytes32 domainSeparator) {
        // execute EIP-712 hashStruct procedure using assembly, equivalent to:
        //
        // domainSeparator = keccak256(
        //   abi.encode(
        //     EIP712_TYPE_HASH,
        //     nameHash,
        //     versionHash,
        //     block.chainid,
        //     address(this)
        //   )
        // );

        bytes32 typeHash = EIP712_TYPE_HASH;

        assembly {
            // load free memory pointer
            let pointer := mload(64)

            mstore(pointer, typeHash)
            mstore(add(pointer, 32), nameHash)
            mstore(add(pointer, 64), versionHash)
            mstore(add(pointer, 96), chainid())
            mstore(add(pointer, 128), address())

            domainSeparator := keccak256(pointer, 160)
        }
    }

    /// @notice Returns hash of data with domain separator
    function hashDataWithDomainSeparator(bytes32 hash) internal view returns (bytes32) {
        return
            keccak256(
                abi.encodePacked("\x19\x01", calculateDomainSeparator(keccak256("Premia"), keccak256("1")), hash)
            );
    }
}

// SPDX-License-Identifier: LGPL-3.0-or-later
// For terms and conditions regarding commercial use please see https://license.premia.blue
pragma solidity ^0.8.28;

import {IClearingHouse} from "../clearingHouse/IClearingHouse.sol";
import {ISignatureValidation} from "../clearingHouse/ISignatureValidation.sol";

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

library HashData {
    /* solhint-disable max-line-length */
    bytes32 internal constant PROTOCOL_DEPOSIT_TYPE_HASH =
        keccak256(
            "ProtocolDeposit(bytes32 nonce,uint256 deadline,address to,address from,uint256 amount,Pair pair)Pair(address base,address quote)"
        );

    bytes32 internal constant USER_DEPOSIT_TYPE_HASH =
        keccak256(
            "UserDeposit(uint256 deadline,address to,address from,uint256 amount,Pair pair)Pair(address base,address quote)"
        );

    bytes32 internal constant PROTOCOL_WITHDRAW_TYPE_HASH =
        keccak256(
            "ProtocolWithdraw(bytes32 nonce,uint256 deadline,address to,address from,uint256 amount,Pair pair)Pair(address base,address quote)"
        );

    bytes32 internal constant USER_WITHDRAW_TYPE_HASH =
        keccak256(
            "UserWithdraw(uint256 deadline,address to,address from,uint256 amount,Pair pair)Pair(address base,address quote)"
        );

    bytes32 internal constant PAIR_TYPE_HASH = keccak256("Pair(address base,address quote)");

    bytes32 internal constant PROTOCOL_INVALIDATE_NONCE_TYPE_HASH =
        keccak256("ProtocolInvalidateNonce(bytes32 nonce,uint256 deadline)");
    /* solhint-enable max-line-length */

    /// @notice Returns hash of `pair`
    function hashPair(IClearingHouse.Pair memory pair, bool includeTypeHash) internal pure returns (bytes32) {
        if (includeTypeHash) {
            return keccak256(abi.encode(PAIR_TYPE_HASH, pair.base, pair.quote));
        } else {
            return keccak256(abi.encode(pair.base, pair.quote));
        }
    }

    /// @notice Returns hash of deposit or withdrawal signed by protocol
    function hashDepositOrWithdraw(
        ISignatureValidation.Signature memory sigProtocol,
        bool isDeposit,
        address to,
        address from,
        uint256 amount,
        IClearingHouse.Pair memory pair
    ) internal view returns (bytes32) {
        return
            EIP712.hashDataWithDomainSeparator(
                keccak256(
                    abi.encode(
                        isDeposit ? PROTOCOL_DEPOSIT_TYPE_HASH : PROTOCOL_WITHDRAW_TYPE_HASH,
                        sigProtocol.nonce,
                        sigProtocol.deadline,
                        to,
                        from,
                        amount,
                        hashPair(pair, true)
                    )
                )
            );
    }

    /// @notice Returns hash of deposit or withdrawal signed by user
    function hashDepositOrWithdraw(
        ISignatureValidation.UserSignature memory sigUser,
        bool isDeposit,
        address to,
        address from,
        uint256 amount,
        IClearingHouse.Pair memory pair
    ) internal view returns (bytes32) {
        return
            EIP712.hashDataWithDomainSeparator(
                keccak256(
                    abi.encode(
                        isDeposit ? USER_DEPOSIT_TYPE_HASH : USER_WITHDRAW_TYPE_HASH,
                        sigUser.deadline,
                        to,
                        from,
                        amount,
                        hashPair(pair, true)
                    )
                )
            );
    }

    /// @notice Returns hash of nonce invalidation signed by protocol
    function hashInvalidateNonce(ISignatureValidation.Signature memory sigProtocol) internal view returns (bytes32) {
        return
            EIP712.hashDataWithDomainSeparator(
                keccak256(abi.encode(PROTOCOL_INVALIDATE_NONCE_TYPE_HASH, sigProtocol.nonce, sigProtocol.deadline))
            );
    }
}

Settings
{
  "viaIR": true,
  "optimizer": {
    "enabled": true,
    "runs": 200
  },
  "evmVersion": "paris",
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  },
  "libraries": {}
}

Contract ABI

API
[{"inputs":[{"internalType":"address","name":"admin","type":"address"},{"internalType":"address","name":"relayer","type":"address"},{"internalType":"contract IERC20","name":"collateral","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"ClearingHouse_ArrayLengthsMismatched","type":"error"},{"inputs":[],"name":"ClearingHouse_ZeroAddress","type":"error"},{"inputs":[],"name":"ClearingHouse_ZeroAmount","type":"error"},{"inputs":[],"name":"InactiveWithdrawal_MsgSenderNotRelayer","type":"error"},{"inputs":[],"name":"InactiveWithdrawal_NotInactive","type":"error"},{"inputs":[],"name":"InactiveWithdrawal_ZeroAmount","type":"error"},{"inputs":[],"name":"InvalidInitialization","type":"error"},{"inputs":[],"name":"NotInitializing","type":"error"},{"inputs":[],"name":"ReentrancyGuardReentrantCall","type":"error"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"SafeERC20FailedOperation","type":"error"},{"inputs":[{"internalType":"bytes32","name":"nonce","type":"bytes32"}],"name":"SignatureValidation_InvalidNonce","type":"error"},{"inputs":[{"internalType":"address","name":"signer","type":"address"},{"internalType":"bytes32","name":"hash","type":"bytes32"},{"internalType":"bytes","name":"signature","type":"bytes"}],"name":"SignatureValidation_InvalidSignature","type":"error"},{"inputs":[],"name":"SignatureValidation_MsgSenderNotAdmin","type":"error"},{"inputs":[{"internalType":"uint256","name":"blockTimestamp","type":"uint256"},{"internalType":"uint256","name":"sigDeadline","type":"uint256"}],"name":"SignatureValidation_SignatureExpired","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":true,"internalType":"address","name":"from","type":"address"},{"components":[{"internalType":"contract IERC20","name":"base","type":"address"},{"internalType":"contract IERC20","name":"quote","type":"address"}],"indexed":false,"internalType":"struct IClearingHouse.Pair","name":"pair","type":"tuple"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Deposit","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address[]","name":"accounts","type":"address[]"},{"indexed":false,"internalType":"uint256[]","name":"amounts","type":"uint256[]"},{"indexed":false,"internalType":"uint256","name":"total","type":"uint256"}],"name":"InactiveWithdrawalAmountsUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"InactiveWithdrawalSuccess","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint64","name":"version","type":"uint64"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"authorizedSigner","type":"address"}],"name":"UpdateAuthorizedSigner","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":true,"internalType":"address","name":"from","type":"address"},{"components":[{"internalType":"contract IERC20","name":"base","type":"address"},{"internalType":"contract IERC20","name":"quote","type":"address"}],"indexed":false,"internalType":"struct IClearingHouse.Pair","name":"pair","type":"tuple"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Withdraw","type":"event"},{"inputs":[{"components":[{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"bytes","name":"signature","type":"bytes"}],"internalType":"struct ISignatureValidation.UserSignature","name":"sigUser","type":"tuple"},{"components":[{"internalType":"bytes32","name":"nonce","type":"bytes32"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"bytes","name":"signature","type":"bytes"}],"internalType":"struct ISignatureValidation.Signature","name":"sigProtocol","type":"tuple"},{"components":[{"internalType":"address","name":"to","type":"address"},{"internalType":"address","name":"from","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"components":[{"internalType":"contract IERC20","name":"base","type":"address"},{"internalType":"contract IERC20","name":"quote","type":"address"}],"internalType":"struct IClearingHouse.Pair","name":"pair","type":"tuple"}],"internalType":"struct IClearingHouse.DepositArgs","name":"depositArgs","type":"tuple"}],"name":"deposit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getAuthorizedSigner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"getInactiveWithdrawalAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getInactiveWithdrawalTotal","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"inactiveWithdrawal","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"bytes32","name":"nonce","type":"bytes32"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"bytes","name":"signature","type":"bytes"}],"internalType":"struct ISignatureValidation.Signature","name":"sigProtocol","type":"tuple"}],"name":"invalidateNonce","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"nonce","type":"bytes32"}],"name":"isValidNonce","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newAuthorizedSigner","type":"address"}],"name":"updateAuthorizedSigner","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"accounts","type":"address[]"},{"internalType":"uint256[]","name":"amounts","type":"uint256[]"}],"name":"updateInactiveWithdrawalAmounts","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"bytes","name":"signature","type":"bytes"}],"internalType":"struct ISignatureValidation.UserSignature","name":"sigUser","type":"tuple"},{"components":[{"internalType":"bytes32","name":"nonce","type":"bytes32"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"bytes","name":"signature","type":"bytes"}],"internalType":"struct ISignatureValidation.Signature","name":"sigProtocol","type":"tuple"},{"components":[{"internalType":"address","name":"to","type":"address"},{"internalType":"address","name":"from","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"components":[{"internalType":"contract IERC20","name":"base","type":"address"},{"internalType":"contract IERC20","name":"quote","type":"address"}],"internalType":"struct IClearingHouse.Pair","name":"pair","type":"tuple"}],"internalType":"struct IClearingHouse.WithdrawArgs","name":"withdrawArgs","type":"tuple"}],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"}]

0x610100346100b157601f6115b838819003918201601f19168301916001600160401b038311848410176100b6578084926060946040528339810103126100b157610048816100cc565b6040610056602084016100cc565b920151916001600160a01b03831683036100b1576080528160a05260c05260e0526040516114d790816100e18239608051816105e2015260a051816107b8015260c051816104a3015260e05181818161024301526103d30152f35b600080fd5b634e487b7160e01b600052604160045260246000fd5b51906001600160a01b03821682036100b15756fe6080604052600436101561001257600080fd5b60003560e01c80634744d639146100b757806351a4d7fd146100b2578063565119b8146100ad578063669ed935146100a8578063769e31df146100a3578063954ca5711461009e578063b7afeac914610099578063ba0f263714610094578063c70670361461008f5763ed4b83911461008a57600080fd5b6109a0565b610958565b610909565b610848565b610719565b610589565b61047c565b6102dd565b61014e565b346100e15760003660031901126100e1576000805160206114628339815191525460805260206080f35b600080fd5b908160609103126100e15790565b60e06003198201126100e1576004356001600160401b0381116100e1576004016040818303126100e157916024356001600160401b0381116100e15761013f8360a0926004016100e6565b9260431901126100e157604490565b346100e15761015c366100f4565b9091610166610d25565b61016f826109fc565b61017890610d61565b60408201359161018783610d82565b6020810193610195856109fc565b61019e836109fc565b936101a8876109fc565b6060850195876101b83685610acd565b926101c3368a610b12565b926101cd94610d9a565b90602081016101db91610b4c565b36906101e692610a7b565b906101f092610e83565b6101f9826109fc565b610202866109fc565b908561020e3685610b7e565b926102193688610b12565b9261022394610edb565b903661022e91610b7e565b61023791610f99565b610240816109fc565b837f00000000000000000000000000000000000000000000000000000000000000009161026c9261107f565b610275906109fc565b9261027f906109fc565b6040516001600160a01b039182169490911692909182916102a09183610bd8565b037fe327254294d0da9c9c13a373b10603276efaa2d40c1d63e6aa3b00a648b5165791a36102db600160008051602061148283398151915255565b005b346100e1576102eb366100f4565b90916102f5610d25565b6102fe826109fc565b61030790610d61565b60408201359161031683610d82565b6020810193610324856109fc565b61032d836109fc565b93610337876109fc565b6060850195876103473685610acd565b92610352368a610b12565b9261035c94610e10565b906020810161036a91610b4c565b369061037592610a7b565b9061037f92610e83565b610388826109fc565b610391866109fc565b908561039d3685610b7e565b926103a83688610b12565b926103b294610f5f565b90366103bd91610b7e565b6103c691610f99565b6103cf846109fc565b83307f0000000000000000000000000000000000000000000000000000000000000000926103fc936110c1565b610405906109fc565b9261040f906109fc565b6040516001600160a01b039182169490911692909182916104309183610bd8565b037f9e2c756d1227177f8059a957c2f41e3a3301ffffbd039c41ea0a1fd20259eef191a36102db600160008051602061148283398151915255565b6001600160a01b038116036100e157565b346100e15760203660031901126100e1576004356104998161046b565b6104a1610d25565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03163303610548577f85b5f04927eaaf239153468141c2b533a4d7c40a442dfda1da227f2cba88230080546001600160a01b0319166001600160a01b039290921691821790557f4281c21093dd43d02269fb5321042b36422aa69fec34019fd757c31c1b5c0d23600080a2600160008051602061148283398151915255005b632e3806e360e11b60005260046000fd5b9181601f840112156100e1578235916001600160401b0383116100e1576020808501948460051b0101116100e157565b346100e15760403660031901126100e1576004356001600160401b0381116100e1576105b9903690600401610559565b6024356001600160401b0381116100e1576105d8903690600401610559565b6105e0610d25565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316330361070857600080516020611462833981519152549160005b8481106106b857509161069e917f729ccfa6f08f1e12ac367cd2e61a237f4756cef1377ad6982e9eced6ded13660959361066a8360008051602061146283398151915255565b610692427f485f19e8579a45ae2ad3a7bba9fcb0ca2811febe4da08488f5c42f3456bca40255565b60405195869586610ca8565b0390a16102db600160008051602061148283398151915255565b806106ce6106c9600193888a610c19565b6109fc565b946107016106fb6106e0848888610c19565b35926106f6846106ef8b610c3f565b5492610c8e565b610c9b565b96610c3f565b5501610624565b631e3866e160e21b60005260046000fd5b346100e15760003660031901126100e157610732610d25565b7f485f19e8579a45ae2ad3a7bba9fcb0ca2811febe4da08488f5c42f3456bca4025462278d0081018091116108435742106108325761077033610c3f565b54801561082157600061078233610c3f565b556107b161079f8260008051602061146283398151915254610c9b565b60008051602061146283398151915255565b6107dc81337f000000000000000000000000000000000000000000000000000000000000000061107f565b60405190815233907f3c76da0f1181537049a48ee84d3b04f64689e8c567f5c1df62bc3491f647f84690602090a26102db600160008051602061148283398151915255565b63209f02c560e11b60005260046000fd5b6329a32fc760e11b60005260046000fd5b610c78565b346100e15760203660031901126100e1576004356001600160401b0381116100e15761087b6108f59136906004016100e6565b610883610d25565b6108ef6108e76108933684610b7e565b602081519101516040519060208201927fc74373fae2851731e1ef8ef41ee5ea148f562faa331e52c0ea7ff2009390f798845260408301526060820152606081526108df608082610a3f565b519020611168565b913690610b7e565b90610f99565b600160008051602061148283398151915255005b346100e15760203660031901126100e1576004356000527f85b5f04927eaaf239153468141c2b533a4d7c40a442dfda1da227f2cba882301602052602060ff6040600020541615604051908152f35b346100e15760003660031901126100e1577f85b5f04927eaaf239153468141c2b533a4d7c40a442dfda1da227f2cba882300546040516001600160a01b039091168152602090f35b346100e15760203660031901126100e1576004356109bd8161046b565b60018060a01b03166000527f485f19e8579a45ae2ad3a7bba9fcb0ca2811febe4da08488f5c42f3456bca4006020526020604060002054604051908152f35b35610a068161046b565b90565b634e487b7160e01b600052604160045260246000fd5b604081019081106001600160401b03821117610a3a57604052565b610a09565b90601f801991011681019081106001600160401b03821117610a3a57604052565b6001600160401b038111610a3a57601f01601f191660200190565b929192610a8782610a60565b91610a956040519384610a3f565b8294818452818301116100e1578281602093846000960137010152565b9080601f830112156100e157816020610a0693359101610a7b565b91906040838203126100e15760405190610ae682610a1f565b8193803583526020810135916001600160401b0383116100e157602092610b0d9201610ab2565b910152565b91908260409103126100e157604051610b2a81610a1f565b60208082948035610b3a8161046b565b8452013591610b488361046b565b0152565b903590601e19813603018212156100e157018035906001600160401b0382116100e1576020019181360383136100e157565b91906060838203126100e15760405190606082018281106001600160401b03821117610a3a57604052819380358352602081013560208401526040810135916001600160401b0383116100e157604092610b0d9201610ab2565b60409093929193602060608201958035610bf18161046b565b6001600160a01b031683520135610c078161046b565b6001600160a01b031660208201520152565b9190811015610c295760051b0190565b634e487b7160e01b600052603260045260246000fd5b6001600160a01b031660009081527f485f19e8579a45ae2ad3a7bba9fcb0ca2811febe4da08488f5c42f3456bca4006020526040902090565b634e487b7160e01b600052601160045260246000fd5b9190820180921161084357565b9190820391821161084357565b959493919290928060608801606089525260808701939060005b818110610cfb5750505085830360208701528183526001600160fb1b0382116100e15760409260209260051b8092848301370101930152565b9091946020806001928835610d0f8161046b565b848060a01b031681520196019101919091610cc2565b60026000805160206114828339815191525414610d5057600260008051602061148283398151915255565b633ee5aeb560e01b60005260046000fd5b6001600160a01b031615610d7157565b63059d8acb60e01b60005260046000fd5b15610d8957565b631a785bcd60e31b60005260046000fd5b92610a069492610dcc7f96f2cdb9a049063b748813dd3c7eecf012af56a1033700263a14ce1b6120b005955194611105565b6040805160208101978852908101959095526001600160a01b0393841660608601529216608084015260a083015260c08083019190915281526108df60e082610a3f565b92610a069492610dcc7f0e75072ac01fb58c4bc1b977c5f9233f0374516b1c3a7c9734a0d1d06e604535955194611105565b919082519283825260005b848110610e6e575050826000602080949584010152601f8019910116010190565b80602080928401015182828601015201610e4d565b9091610e90818484611234565b15610e9a57505050565b604051630ed57a3760e41b81526001600160a01b039092166004830152602482019290925260606044820152908190610ed7906064830190610e42565b0390fd5b9192610a069491937f7632ecb72edf8b3289531a13dd4b7d57f04baaec962371de905bf984bb8d83fd94610f156020865196015194611105565b9360405195602087019788526040870152606086015260018060a01b0316608085015260018060a01b031660a084015260c083015260e082015260e081526108df61010082610a3f565b9192610a069491937f01dbba47a578ac1db5b74012579d6dfce5d7d46cefb3a7fe8f81f5b066df4efd94610f156020865196015194611105565b81516000527f85b5f04927eaaf239153468141c2b533a4d7c40a442dfda1da227f2cba88230160205260ff6040600020541661106957602082015180421161105157507f85b5f04927eaaf239153468141c2b533a4d7c40a442dfda1da227f2cba8823005460408301516110179290916001600160a01b0316610e83565b516000527f85b5f04927eaaf239153468141c2b533a4d7c40a442dfda1da227f2cba8823016020526040600020600160ff19825416179055565b63bcf389f960e01b6000524260045260245260446000fd5b505163111aec3360e01b60005260045260246000fd5b60405163a9059cbb60e01b60208201526001600160a01b0390921660248301526044808301939093529181526110bf916110ba606483610a3f565b611326565b565b6040516323b872dd60e01b60208201526001600160a01b0392831660248201529290911660448301526064808301939093529181526110bf916110ba608483610a3f565b8051602091820151604080517f05fe8c43bd0362f7e639286acf742edf16d41ece8ce1448a4ad0aec90f3c45b29481019485526001600160a01b039384169181019190915291166060808301919091528152611162608082610a3f565b51902090565b60a06040517f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f81527feea53d927f4cea79beb0900a6146c8df639ac3d1267bb8ee296cf282ab4ebb3660208201527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc66040820152466060820152306080820152209060405190602082019261190160f01b84526022830152604282015260428152611162606282610a3f565b6004111561121e57565b634e487b7160e01b600052602160045260246000fd5b9190823b61126f57906112469161139c565b5061125081611214565b15918261125c57505090565b6001600160a01b03918216911614919050565b916000926112a66112b485946040519283916020830195630b135d3f60e11b87526024840152604060448401526064830190610e42565b03601f198101835282610a3f565b51915afa3d1561131f573d6112c881610a60565b906112d66040519283610a3f565b81523d6000602083013e5b81611311575b816112f0575090565b905061130d630b135d3f60e11b916020808251830101910161138d565b1490565b9050602081511015906112e7565b60606112e1565b906000602091828151910182855af115611381576000513d61137857506001600160a01b0381163b155b6113575750565b635274afe760e01b60009081526001600160a01b0391909116600452602490fd5b60011415611350565b6040513d6000823e3d90fd5b908160209103126100e1575190565b81519190604183036113cd576113c692506020820151906060604084015193015160001a906113d8565b9192909190565b505060009160029190565b91907f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a08411611455579160209360809260ff60009560405194855216868401526040830152606082015282805260015afa15611381576000516001600160a01b038116156114495790600090600090565b50600090600190600090565b5050506000916003919056fe485f19e8579a45ae2ad3a7bba9fcb0ca2811febe4da08488f5c42f3456bca4019b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f00a2646970667358221220ad25c35486cc82df63c46437d4cf76aceafb5f035e03b43163cf0add1083579864736f6c634300081c00330000000000000000000000000e2ff9cbb1b0866b9988311c4d55bbc3e584bb5400000000000000000000000097ee136f3b03fea4aab359eeb6493536aa1fc081000000000000000000000000a4387e780091ca2c479f71bf5ac0cf729098c0c3

Deployed Bytecode

0x6080604052600436101561001257600080fd5b60003560e01c80634744d639146100b757806351a4d7fd146100b2578063565119b8146100ad578063669ed935146100a8578063769e31df146100a3578063954ca5711461009e578063b7afeac914610099578063ba0f263714610094578063c70670361461008f5763ed4b83911461008a57600080fd5b6109a0565b610958565b610909565b610848565b610719565b610589565b61047c565b6102dd565b61014e565b346100e15760003660031901126100e1576000805160206114628339815191525460805260206080f35b600080fd5b908160609103126100e15790565b60e06003198201126100e1576004356001600160401b0381116100e1576004016040818303126100e157916024356001600160401b0381116100e15761013f8360a0926004016100e6565b9260431901126100e157604490565b346100e15761015c366100f4565b9091610166610d25565b61016f826109fc565b61017890610d61565b60408201359161018783610d82565b6020810193610195856109fc565b61019e836109fc565b936101a8876109fc565b6060850195876101b83685610acd565b926101c3368a610b12565b926101cd94610d9a565b90602081016101db91610b4c565b36906101e692610a7b565b906101f092610e83565b6101f9826109fc565b610202866109fc565b908561020e3685610b7e565b926102193688610b12565b9261022394610edb565b903661022e91610b7e565b61023791610f99565b610240816109fc565b837f000000000000000000000000a4387e780091ca2c479f71bf5ac0cf729098c0c39161026c9261107f565b610275906109fc565b9261027f906109fc565b6040516001600160a01b039182169490911692909182916102a09183610bd8565b037fe327254294d0da9c9c13a373b10603276efaa2d40c1d63e6aa3b00a648b5165791a36102db600160008051602061148283398151915255565b005b346100e1576102eb366100f4565b90916102f5610d25565b6102fe826109fc565b61030790610d61565b60408201359161031683610d82565b6020810193610324856109fc565b61032d836109fc565b93610337876109fc565b6060850195876103473685610acd565b92610352368a610b12565b9261035c94610e10565b906020810161036a91610b4c565b369061037592610a7b565b9061037f92610e83565b610388826109fc565b610391866109fc565b908561039d3685610b7e565b926103a83688610b12565b926103b294610f5f565b90366103bd91610b7e565b6103c691610f99565b6103cf846109fc565b83307f000000000000000000000000a4387e780091ca2c479f71bf5ac0cf729098c0c3926103fc936110c1565b610405906109fc565b9261040f906109fc565b6040516001600160a01b039182169490911692909182916104309183610bd8565b037f9e2c756d1227177f8059a957c2f41e3a3301ffffbd039c41ea0a1fd20259eef191a36102db600160008051602061148283398151915255565b6001600160a01b038116036100e157565b346100e15760203660031901126100e1576004356104998161046b565b6104a1610d25565b7f0000000000000000000000000e2ff9cbb1b0866b9988311c4d55bbc3e584bb546001600160a01b03163303610548577f85b5f04927eaaf239153468141c2b533a4d7c40a442dfda1da227f2cba88230080546001600160a01b0319166001600160a01b039290921691821790557f4281c21093dd43d02269fb5321042b36422aa69fec34019fd757c31c1b5c0d23600080a2600160008051602061148283398151915255005b632e3806e360e11b60005260046000fd5b9181601f840112156100e1578235916001600160401b0383116100e1576020808501948460051b0101116100e157565b346100e15760403660031901126100e1576004356001600160401b0381116100e1576105b9903690600401610559565b6024356001600160401b0381116100e1576105d8903690600401610559565b6105e0610d25565b7f00000000000000000000000097ee136f3b03fea4aab359eeb6493536aa1fc0816001600160a01b0316330361070857600080516020611462833981519152549160005b8481106106b857509161069e917f729ccfa6f08f1e12ac367cd2e61a237f4756cef1377ad6982e9eced6ded13660959361066a8360008051602061146283398151915255565b610692427f485f19e8579a45ae2ad3a7bba9fcb0ca2811febe4da08488f5c42f3456bca40255565b60405195869586610ca8565b0390a16102db600160008051602061148283398151915255565b806106ce6106c9600193888a610c19565b6109fc565b946107016106fb6106e0848888610c19565b35926106f6846106ef8b610c3f565b5492610c8e565b610c9b565b96610c3f565b5501610624565b631e3866e160e21b60005260046000fd5b346100e15760003660031901126100e157610732610d25565b7f485f19e8579a45ae2ad3a7bba9fcb0ca2811febe4da08488f5c42f3456bca4025462278d0081018091116108435742106108325761077033610c3f565b54801561082157600061078233610c3f565b556107b161079f8260008051602061146283398151915254610c9b565b60008051602061146283398151915255565b6107dc81337f000000000000000000000000a4387e780091ca2c479f71bf5ac0cf729098c0c361107f565b60405190815233907f3c76da0f1181537049a48ee84d3b04f64689e8c567f5c1df62bc3491f647f84690602090a26102db600160008051602061148283398151915255565b63209f02c560e11b60005260046000fd5b6329a32fc760e11b60005260046000fd5b610c78565b346100e15760203660031901126100e1576004356001600160401b0381116100e15761087b6108f59136906004016100e6565b610883610d25565b6108ef6108e76108933684610b7e565b602081519101516040519060208201927fc74373fae2851731e1ef8ef41ee5ea148f562faa331e52c0ea7ff2009390f798845260408301526060820152606081526108df608082610a3f565b519020611168565b913690610b7e565b90610f99565b600160008051602061148283398151915255005b346100e15760203660031901126100e1576004356000527f85b5f04927eaaf239153468141c2b533a4d7c40a442dfda1da227f2cba882301602052602060ff6040600020541615604051908152f35b346100e15760003660031901126100e1577f85b5f04927eaaf239153468141c2b533a4d7c40a442dfda1da227f2cba882300546040516001600160a01b039091168152602090f35b346100e15760203660031901126100e1576004356109bd8161046b565b60018060a01b03166000527f485f19e8579a45ae2ad3a7bba9fcb0ca2811febe4da08488f5c42f3456bca4006020526020604060002054604051908152f35b35610a068161046b565b90565b634e487b7160e01b600052604160045260246000fd5b604081019081106001600160401b03821117610a3a57604052565b610a09565b90601f801991011681019081106001600160401b03821117610a3a57604052565b6001600160401b038111610a3a57601f01601f191660200190565b929192610a8782610a60565b91610a956040519384610a3f565b8294818452818301116100e1578281602093846000960137010152565b9080601f830112156100e157816020610a0693359101610a7b565b91906040838203126100e15760405190610ae682610a1f565b8193803583526020810135916001600160401b0383116100e157602092610b0d9201610ab2565b910152565b91908260409103126100e157604051610b2a81610a1f565b60208082948035610b3a8161046b565b8452013591610b488361046b565b0152565b903590601e19813603018212156100e157018035906001600160401b0382116100e1576020019181360383136100e157565b91906060838203126100e15760405190606082018281106001600160401b03821117610a3a57604052819380358352602081013560208401526040810135916001600160401b0383116100e157604092610b0d9201610ab2565b60409093929193602060608201958035610bf18161046b565b6001600160a01b031683520135610c078161046b565b6001600160a01b031660208201520152565b9190811015610c295760051b0190565b634e487b7160e01b600052603260045260246000fd5b6001600160a01b031660009081527f485f19e8579a45ae2ad3a7bba9fcb0ca2811febe4da08488f5c42f3456bca4006020526040902090565b634e487b7160e01b600052601160045260246000fd5b9190820180921161084357565b9190820391821161084357565b959493919290928060608801606089525260808701939060005b818110610cfb5750505085830360208701528183526001600160fb1b0382116100e15760409260209260051b8092848301370101930152565b9091946020806001928835610d0f8161046b565b848060a01b031681520196019101919091610cc2565b60026000805160206114828339815191525414610d5057600260008051602061148283398151915255565b633ee5aeb560e01b60005260046000fd5b6001600160a01b031615610d7157565b63059d8acb60e01b60005260046000fd5b15610d8957565b631a785bcd60e31b60005260046000fd5b92610a069492610dcc7f96f2cdb9a049063b748813dd3c7eecf012af56a1033700263a14ce1b6120b005955194611105565b6040805160208101978852908101959095526001600160a01b0393841660608601529216608084015260a083015260c08083019190915281526108df60e082610a3f565b92610a069492610dcc7f0e75072ac01fb58c4bc1b977c5f9233f0374516b1c3a7c9734a0d1d06e604535955194611105565b919082519283825260005b848110610e6e575050826000602080949584010152601f8019910116010190565b80602080928401015182828601015201610e4d565b9091610e90818484611234565b15610e9a57505050565b604051630ed57a3760e41b81526001600160a01b039092166004830152602482019290925260606044820152908190610ed7906064830190610e42565b0390fd5b9192610a069491937f7632ecb72edf8b3289531a13dd4b7d57f04baaec962371de905bf984bb8d83fd94610f156020865196015194611105565b9360405195602087019788526040870152606086015260018060a01b0316608085015260018060a01b031660a084015260c083015260e082015260e081526108df61010082610a3f565b9192610a069491937f01dbba47a578ac1db5b74012579d6dfce5d7d46cefb3a7fe8f81f5b066df4efd94610f156020865196015194611105565b81516000527f85b5f04927eaaf239153468141c2b533a4d7c40a442dfda1da227f2cba88230160205260ff6040600020541661106957602082015180421161105157507f85b5f04927eaaf239153468141c2b533a4d7c40a442dfda1da227f2cba8823005460408301516110179290916001600160a01b0316610e83565b516000527f85b5f04927eaaf239153468141c2b533a4d7c40a442dfda1da227f2cba8823016020526040600020600160ff19825416179055565b63bcf389f960e01b6000524260045260245260446000fd5b505163111aec3360e01b60005260045260246000fd5b60405163a9059cbb60e01b60208201526001600160a01b0390921660248301526044808301939093529181526110bf916110ba606483610a3f565b611326565b565b6040516323b872dd60e01b60208201526001600160a01b0392831660248201529290911660448301526064808301939093529181526110bf916110ba608483610a3f565b8051602091820151604080517f05fe8c43bd0362f7e639286acf742edf16d41ece8ce1448a4ad0aec90f3c45b29481019485526001600160a01b039384169181019190915291166060808301919091528152611162608082610a3f565b51902090565b60a06040517f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f81527feea53d927f4cea79beb0900a6146c8df639ac3d1267bb8ee296cf282ab4ebb3660208201527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc66040820152466060820152306080820152209060405190602082019261190160f01b84526022830152604282015260428152611162606282610a3f565b6004111561121e57565b634e487b7160e01b600052602160045260246000fd5b9190823b61126f57906112469161139c565b5061125081611214565b15918261125c57505090565b6001600160a01b03918216911614919050565b916000926112a66112b485946040519283916020830195630b135d3f60e11b87526024840152604060448401526064830190610e42565b03601f198101835282610a3f565b51915afa3d1561131f573d6112c881610a60565b906112d66040519283610a3f565b81523d6000602083013e5b81611311575b816112f0575090565b905061130d630b135d3f60e11b916020808251830101910161138d565b1490565b9050602081511015906112e7565b60606112e1565b906000602091828151910182855af115611381576000513d61137857506001600160a01b0381163b155b6113575750565b635274afe760e01b60009081526001600160a01b0391909116600452602490fd5b60011415611350565b6040513d6000823e3d90fd5b908160209103126100e1575190565b81519190604183036113cd576113c692506020820151906060604084015193015160001a906113d8565b9192909190565b505060009160029190565b91907f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a08411611455579160209360809260ff60009560405194855216868401526040830152606082015282805260015afa15611381576000516001600160a01b038116156114495790600090600090565b50600090600190600090565b5050506000916003919056fe485f19e8579a45ae2ad3a7bba9fcb0ca2811febe4da08488f5c42f3456bca4019b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f00a2646970667358221220ad25c35486cc82df63c46437d4cf76aceafb5f035e03b43163cf0add1083579864736f6c634300081c0033

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
0x9851F23AB63b9a095b59840E1e6D6415D32F9f01
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.