blockscan
Check your 2024 Onchain highlights with Blockscan Wrapped

Contract

0xf5A665732c78847C63cF897E200cf3a3C2d652A6

Overview

S Balance

Sonic LogoSonic LogoSonic Logo0 S

S Value

-

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To
Renounce Role14145822024-12-24 3:28:402 days ago1735010920IN
0xf5A66573...3C2d652A6
0 S0.000028381.1
Grant Role14145692024-12-24 3:28:332 days ago1735010913IN
0xf5A66573...3C2d652A6
0 S0.000057891.1
Grant Role14145652024-12-24 3:28:272 days ago1735010907IN
0xf5A66573...3C2d652A6
0 S0.000057891.1

Parent Transaction Hash Block From To
View All Internal Transactions
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
RewardDistributor

Compiler Version
v0.8.12+commit.f00d7308

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion
File 1 of 18 : RewardDistributor.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.12;

import {AccessControl} from "@openzeppelin/contracts/access/AccessControl.sol";
import {ReentrancyGuard} from "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import {Pausable} from "@openzeppelin/contracts/security/Pausable.sol";
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import {MerkleProof} from "@openzeppelin/contracts/utils/cryptography/MerkleProof.sol";
import {Common} from "./libraries/Common.sol";
import {Errors} from "./libraries/Errors.sol";

contract RewardDistributor is AccessControl, ReentrancyGuard, Pausable {
    using SafeERC20 for IERC20;

    struct Reward {
        address token;
        bytes32 merkleRoot;
        bytes32 proof;
        uint256 activeAt;
    }

    struct Claim {
        bytes32 identifier;
        address account;
        uint256 amount;
        bytes32[] merkleProof;
    }

    uint256 public constant MINIMUM_ACTIVE_TIMER = 3 hours;

    // Maps each of the identifiers to its reward metadata
    mapping(bytes32 => Reward) public rewards;
    // Tracks the amount of claimed reward for the specified identifier+account
    mapping(bytes32 => mapping(address => uint256)) public claimed;
    // Used for calculating the timestamp on which rewards can be claimed after an update
    uint256 public activeTimerDuration;

    event RewardClaimed(
        bytes32 indexed identifier,
        address indexed token,
        address indexed account,
        uint256 amount
    );
    event RewardMetadataUpdated(
        bytes32 indexed identifier,
        address indexed token,
        bytes32 merkleRoot,
        bytes32 proof,
        uint256 activeAt
    );
    event SetActiveTimerDuration(uint256 duration);

    constructor() {
        _grantRole(DEFAULT_ADMIN_ROLE, msg.sender);
        _setActiveTimerDuration(MINIMUM_ACTIVE_TIMER);
    }

    /**
        @notice Claim rewards based on the specified metadata
        @param  _claims  Claim[] List of claim metadata
     */
    function claim(
        Claim[] calldata _claims
    ) external nonReentrant whenNotPaused {
        uint256 cLen = _claims.length;

        if (cLen == 0) revert Errors.InvalidArray();

        for (uint256 i; i < cLen; ) {
            _claim(
                _claims[i].identifier,
                _claims[i].account,
                _claims[i].amount,
                _claims[i].merkleProof
            );

            unchecked {
                ++i;
            }
        }
    }

    /**
        @notice Update rewards metadata
        @param  _distributions  Distribution[] List of reward distribution details
     */
    function updateRewardsMetadata(
        Common.Distribution[] calldata _distributions
    ) external onlyRole(DEFAULT_ADMIN_ROLE) {
        uint256 dLen = _distributions.length;

        if (dLen == 0) revert Errors.InvalidDistribution();

        uint256 activeAt = block.timestamp + activeTimerDuration;

        for (uint256 i; i < dLen; ) {
            // Update the metadata and start the timer until the rewards will be active/claimable
            Common.Distribution calldata distribution = _distributions[i];
            Reward storage reward = rewards[distribution.identifier];
            reward.merkleRoot = distribution.merkleRoot;
            reward.proof = distribution.proof;
            reward.activeAt = activeAt;

            // Should only be set once per identifier
            if (reward.token == address(0)) {
                reward.token = distribution.token;
            }

            emit RewardMetadataUpdated(
                distribution.identifier,
                distribution.token,
                distribution.merkleRoot,
                distribution.proof,
                activeAt
            );

            unchecked {
                ++i;
            }
        }
    }

    /** 
        @notice Set the contract's pause state (ie. before taking snapshot for the harvester)
        @dev    More efficient compared to setting the merkle proofs of all affected rewardIds to 0x
        @param  state  bool  Pause state
    */
    function setPauseState(bool state) external onlyRole(DEFAULT_ADMIN_ROLE) {
        if (state) {
            _pause();
        } else {
            _unpause();
        }
    }

    /**
        @notice Set the active timer duration
        @param  _duration  uint256  Timer duration
    */
    function changeActiveTimerDuration(
        uint256 _duration
    ) external onlyRole(DEFAULT_ADMIN_ROLE) {
        _setActiveTimerDuration(_duration);
    }

    /**
        @notice Claim a reward
        @param  _identifier   bytes32    Merkle identifier
        @param  _account      address    Eligible user account
        @param  _amount       uint256    Reward amount
        @param  _merkleProof  bytes32[]  Merkle proof
     */
    function _claim(
        bytes32 _identifier,
        address _account,
        uint256 _amount,
        bytes32[] calldata _merkleProof
    ) private {
        Reward memory reward = rewards[_identifier];

        if (reward.merkleRoot == 0) revert Errors.InvalidMerkleRoot();
        if (reward.activeAt > block.timestamp) revert Errors.RewardInactive();

        uint256 lifeTimeAmount = claimed[_identifier][_account] + _amount;

        // Verify the merkle proof
        if (
            !MerkleProof.verifyCalldata(
                _merkleProof,
                reward.merkleRoot,
                keccak256(abi.encodePacked(_account, lifeTimeAmount))
            )
        ) revert Errors.InvalidProof();

        // Update the claimed amount to the current total
        claimed[_identifier][_account] = lifeTimeAmount;

        address token = reward.token;

        IERC20(token).safeTransfer(_account, _amount);

        emit RewardClaimed(_identifier, token, _account, _amount);
    }

    /**
        @dev    Internal to set the active timer duration
        @param  _duration  uint256  Timer duration
     */
    function _setActiveTimerDuration(uint256 _duration) internal {
        if (_duration < MINIMUM_ACTIVE_TIMER)
            revert Errors.InvalidTimerDuration();

        activeTimerDuration = _duration;

        emit SetActiveTimerDuration(_duration);
    }
}

File 2 of 18 : AccessControl.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (access/AccessControl.sol)

pragma solidity ^0.8.0;

import "./IAccessControl.sol";
import "../utils/Context.sol";
import "../utils/Strings.sol";
import "../utils/introspection/ERC165.sol";

/**
 * @dev Contract module that allows children to implement role-based access
 * control mechanisms. This is a lightweight version that doesn't allow enumerating role
 * members except through off-chain means by accessing the contract event logs. Some
 * applications may benefit from on-chain enumerability, for those cases see
 * {AccessControlEnumerable}.
 *
 * Roles are referred to by their `bytes32` identifier. These should be exposed
 * in the external API and be unique. The best way to achieve this is by
 * using `public constant` hash digests:
 *
 * ```solidity
 * bytes32 public constant MY_ROLE = keccak256("MY_ROLE");
 * ```
 *
 * Roles can be used to represent a set of permissions. To restrict access to a
 * function call, use {hasRole}:
 *
 * ```solidity
 * function foo() public {
 *     require(hasRole(MY_ROLE, msg.sender));
 *     ...
 * }
 * ```
 *
 * Roles can be granted and revoked dynamically via the {grantRole} and
 * {revokeRole} functions. Each role has an associated admin role, and only
 * accounts that have a role's admin role can call {grantRole} and {revokeRole}.
 *
 * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means
 * that only accounts with this role will be able to grant or revoke other
 * roles. More complex role relationships can be created by using
 * {_setRoleAdmin}.
 *
 * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to
 * grant and revoke this role. Extra precautions should be taken to secure
 * accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules}
 * to enforce additional security measures for this role.
 */
abstract contract AccessControl is Context, IAccessControl, ERC165 {
    struct RoleData {
        mapping(address => bool) members;
        bytes32 adminRole;
    }

    mapping(bytes32 => RoleData) private _roles;

    bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;

    /**
     * @dev Modifier that checks that an account has a specific role. Reverts
     * with a standardized message including the required role.
     *
     * The format of the revert reason is given by the following regular expression:
     *
     *  /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/
     *
     * _Available since v4.1._
     */
    modifier onlyRole(bytes32 role) {
        _checkRole(role);
        _;
    }

    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
        return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);
    }

    /**
     * @dev Returns `true` if `account` has been granted `role`.
     */
    function hasRole(bytes32 role, address account) public view virtual override returns (bool) {
        return _roles[role].members[account];
    }

    /**
     * @dev Revert with a standard message if `_msgSender()` is missing `role`.
     * Overriding this function changes the behavior of the {onlyRole} modifier.
     *
     * Format of the revert message is described in {_checkRole}.
     *
     * _Available since v4.6._
     */
    function _checkRole(bytes32 role) internal view virtual {
        _checkRole(role, _msgSender());
    }

    /**
     * @dev Revert with a standard message if `account` is missing `role`.
     *
     * The format of the revert reason is given by the following regular expression:
     *
     *  /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/
     */
    function _checkRole(bytes32 role, address account) internal view virtual {
        if (!hasRole(role, account)) {
            revert(
                string(
                    abi.encodePacked(
                        "AccessControl: account ",
                        Strings.toHexString(account),
                        " is missing role ",
                        Strings.toHexString(uint256(role), 32)
                    )
                )
            );
        }
    }

    /**
     * @dev Returns the admin role that controls `role`. See {grantRole} and
     * {revokeRole}.
     *
     * To change a role's admin, use {_setRoleAdmin}.
     */
    function getRoleAdmin(bytes32 role) public view virtual override returns (bytes32) {
        return _roles[role].adminRole;
    }

    /**
     * @dev Grants `role` to `account`.
     *
     * If `account` had not been already granted `role`, emits a {RoleGranted}
     * event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     *
     * May emit a {RoleGranted} event.
     */
    function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {
        _grantRole(role, account);
    }

    /**
     * @dev Revokes `role` from `account`.
     *
     * If `account` had been granted `role`, emits a {RoleRevoked} event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     *
     * May emit a {RoleRevoked} event.
     */
    function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {
        _revokeRole(role, account);
    }

    /**
     * @dev Revokes `role` from the calling account.
     *
     * Roles are often managed via {grantRole} and {revokeRole}: this function's
     * purpose is to provide a mechanism for accounts to lose their privileges
     * if they are compromised (such as when a trusted device is misplaced).
     *
     * If the calling account had been revoked `role`, emits a {RoleRevoked}
     * event.
     *
     * Requirements:
     *
     * - the caller must be `account`.
     *
     * May emit a {RoleRevoked} event.
     */
    function renounceRole(bytes32 role, address account) public virtual override {
        require(account == _msgSender(), "AccessControl: can only renounce roles for self");

        _revokeRole(role, account);
    }

    /**
     * @dev Grants `role` to `account`.
     *
     * If `account` had not been already granted `role`, emits a {RoleGranted}
     * event. Note that unlike {grantRole}, this function doesn't perform any
     * checks on the calling account.
     *
     * May emit a {RoleGranted} event.
     *
     * [WARNING]
     * ====
     * This function should only be called from the constructor when setting
     * up the initial roles for the system.
     *
     * Using this function in any other way is effectively circumventing the admin
     * system imposed by {AccessControl}.
     * ====
     *
     * NOTE: This function is deprecated in favor of {_grantRole}.
     */
    function _setupRole(bytes32 role, address account) internal virtual {
        _grantRole(role, account);
    }

    /**
     * @dev Sets `adminRole` as ``role``'s admin role.
     *
     * Emits a {RoleAdminChanged} event.
     */
    function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {
        bytes32 previousAdminRole = getRoleAdmin(role);
        _roles[role].adminRole = adminRole;
        emit RoleAdminChanged(role, previousAdminRole, adminRole);
    }

    /**
     * @dev Grants `role` to `account`.
     *
     * Internal function without access restriction.
     *
     * May emit a {RoleGranted} event.
     */
    function _grantRole(bytes32 role, address account) internal virtual {
        if (!hasRole(role, account)) {
            _roles[role].members[account] = true;
            emit RoleGranted(role, account, _msgSender());
        }
    }

    /**
     * @dev Revokes `role` from `account`.
     *
     * Internal function without access restriction.
     *
     * May emit a {RoleRevoked} event.
     */
    function _revokeRole(bytes32 role, address account) internal virtual {
        if (hasRole(role, account)) {
            _roles[role].members[account] = false;
            emit RoleRevoked(role, account, _msgSender());
        }
    }
}

File 3 of 18 : IAccessControl.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol)

pragma solidity ^0.8.0;

/**
 * @dev External interface of AccessControl declared to support ERC165 detection.
 */
interface IAccessControl {
    /**
     * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`
     *
     * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite
     * {RoleAdminChanged} not being emitted signaling this.
     *
     * _Available since v3.1._
     */
    event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);

    /**
     * @dev Emitted when `account` is granted `role`.
     *
     * `sender` is the account that originated the contract call, an admin role
     * bearer except when using {AccessControl-_setupRole}.
     */
    event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);

    /**
     * @dev Emitted when `account` is revoked `role`.
     *
     * `sender` is the account that originated the contract call:
     *   - if using `revokeRole`, it is the admin role bearer
     *   - if using `renounceRole`, it is the role bearer (i.e. `account`)
     */
    event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);

    /**
     * @dev Returns `true` if `account` has been granted `role`.
     */
    function hasRole(bytes32 role, address account) external view returns (bool);

    /**
     * @dev Returns the admin role that controls `role`. See {grantRole} and
     * {revokeRole}.
     *
     * To change a role's admin, use {AccessControl-_setRoleAdmin}.
     */
    function getRoleAdmin(bytes32 role) external view returns (bytes32);

    /**
     * @dev Grants `role` to `account`.
     *
     * If `account` had not been already granted `role`, emits a {RoleGranted}
     * event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     */
    function grantRole(bytes32 role, address account) external;

    /**
     * @dev Revokes `role` from `account`.
     *
     * If `account` had been granted `role`, emits a {RoleRevoked} event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     */
    function revokeRole(bytes32 role, address account) external;

    /**
     * @dev Revokes `role` from the calling account.
     *
     * Roles are often managed via {grantRole} and {revokeRole}: this function's
     * purpose is to provide a mechanism for accounts to lose their privileges
     * if they are compromised (such as when a trusted device is misplaced).
     *
     * If the calling account had been granted `role`, emits a {RoleRevoked}
     * event.
     *
     * Requirements:
     *
     * - the caller must be `account`.
     */
    function renounceRole(bytes32 role, address account) external;
}

File 4 of 18 : Pausable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (security/Pausable.sol)

pragma solidity ^0.8.0;

import "../utils/Context.sol";

/**
 * @dev Contract module which allows children to implement an emergency stop
 * mechanism that can be triggered by an authorized account.
 *
 * This module is used through inheritance. It will make available the
 * modifiers `whenNotPaused` and `whenPaused`, which can be applied to
 * the functions of your contract. Note that they will not be pausable by
 * simply including this module, only once the modifiers are put in place.
 */
abstract contract Pausable is Context {
    /**
     * @dev Emitted when the pause is triggered by `account`.
     */
    event Paused(address account);

    /**
     * @dev Emitted when the pause is lifted by `account`.
     */
    event Unpaused(address account);

    bool private _paused;

    /**
     * @dev Initializes the contract in unpaused state.
     */
    constructor() {
        _paused = false;
    }

    /**
     * @dev Modifier to make a function callable only when the contract is not paused.
     *
     * Requirements:
     *
     * - The contract must not be paused.
     */
    modifier whenNotPaused() {
        _requireNotPaused();
        _;
    }

    /**
     * @dev Modifier to make a function callable only when the contract is paused.
     *
     * Requirements:
     *
     * - The contract must be paused.
     */
    modifier whenPaused() {
        _requirePaused();
        _;
    }

    /**
     * @dev Returns true if the contract is paused, and false otherwise.
     */
    function paused() public view virtual returns (bool) {
        return _paused;
    }

    /**
     * @dev Throws if the contract is paused.
     */
    function _requireNotPaused() internal view virtual {
        require(!paused(), "Pausable: paused");
    }

    /**
     * @dev Throws if the contract is not paused.
     */
    function _requirePaused() internal view virtual {
        require(paused(), "Pausable: not paused");
    }

    /**
     * @dev Triggers stopped state.
     *
     * Requirements:
     *
     * - The contract must not be paused.
     */
    function _pause() internal virtual whenNotPaused {
        _paused = true;
        emit Paused(_msgSender());
    }

    /**
     * @dev Returns to normal state.
     *
     * Requirements:
     *
     * - The contract must be paused.
     */
    function _unpause() internal virtual whenPaused {
        _paused = false;
        emit Unpaused(_msgSender());
    }
}

File 5 of 18 : ReentrancyGuard.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (security/ReentrancyGuard.sol)

pragma solidity ^0.8.0;

/**
 * @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 you would like to learn more about reentrancy and alternative ways
 * to protect against it, check out our blog post
 * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
 */
abstract contract ReentrancyGuard {
    // Booleans are more expensive than uint256 or any type that takes up a full
    // word because each write operation emits an extra SLOAD to first read the
    // slot's contents, replace the bits taken up by the boolean, and then write
    // back. This is the compiler's defense against contract upgrades and
    // pointer aliasing, and it cannot be disabled.

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

    uint256 private _status;

    constructor() {
        _status = _NOT_ENTERED;
    }

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

    function _nonReentrantBefore() private {
        // On the first call to nonReentrant, _status will be _NOT_ENTERED
        require(_status != _ENTERED, "ReentrancyGuard: reentrant call");

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

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

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

File 6 of 18 : IERC20Permit.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.4) (token/ERC20/extensions/IERC20Permit.sol)

pragma solidity ^0.8.0;

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

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

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

File 7 of 18 : IERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/IERC20.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
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 amount of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

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

    /**
     * @dev Moves `amount` 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 amount) 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 `amount` 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 amount) external returns (bool);

    /**
     * @dev Moves `amount` tokens from `from` to `to` using the
     * allowance mechanism. `amount` 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 amount) external returns (bool);
}

File 8 of 18 : SafeERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.3) (token/ERC20/utils/SafeERC20.sol)

pragma solidity ^0.8.0;

import "../IERC20.sol";
import "../extensions/IERC20Permit.sol";
import "../../../utils/Address.sol";

/**
 * @title SafeERC20
 * @dev Wrappers around ERC20 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 {
    using Address for address;

    /**
     * @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.encodeWithSelector(token.transfer.selector, 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.encodeWithSelector(token.transferFrom.selector, from, to, value));
    }

    /**
     * @dev Deprecated. This function has issues similar to the ones found in
     * {IERC20-approve}, and its usage is discouraged.
     *
     * Whenever possible, use {safeIncreaseAllowance} and
     * {safeDecreaseAllowance} instead.
     */
    function safeApprove(IERC20 token, address spender, uint256 value) internal {
        // safeApprove should only be called when setting an initial allowance,
        // or when resetting it to zero. To increase and decrease it, use
        // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
        require(
            (value == 0) || (token.allowance(address(this), spender) == 0),
            "SafeERC20: approve from non-zero to non-zero allowance"
        );
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, 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.
     */
    function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
        uint256 oldAllowance = token.allowance(address(this), spender);
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance + value));
    }

    /**
     * @dev Decrease the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
     * non-reverting calls are assumed to be successful.
     */
    function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal {
        unchecked {
            uint256 oldAllowance = token.allowance(address(this), spender);
            require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
            _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance - value));
        }
    }

    /**
     * @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.
     */
    function forceApprove(IERC20 token, address spender, uint256 value) internal {
        bytes memory approvalCall = abi.encodeWithSelector(token.approve.selector, spender, value);

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

    /**
     * @dev Use a ERC-2612 signature to set the `owner` approval toward `spender` on `token`.
     * Revert on invalid signature.
     */
    function safePermit(
        IERC20Permit token,
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) internal {
        uint256 nonceBefore = token.nonces(owner);
        token.permit(owner, spender, value, deadline, v, r, s);
        uint256 nonceAfter = token.nonces(owner);
        require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed");
    }

    /**
     * @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).
     */
    function _callOptionalReturn(IERC20 token, bytes memory data) private {
        // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
        // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that
        // the target address contains contract code and also asserts for success in the low-level call.

        bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
        require(returndata.length == 0 || abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
    }

    /**
     * @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 silents catches all reverts and returns a bool instead.
     */
    function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
        // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
        // we're implementing it ourselves. We cannot use {Address-functionCall} here since this should return false
        // and not revert is the subcall reverts.

        (bool success, bytes memory returndata) = address(token).call(data);
        return
            success && (returndata.length == 0 || abi.decode(returndata, (bool))) && Address.isContract(address(token));
    }
}

File 9 of 18 : Address.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol)

pragma solidity ^0.8.1;

/**
 * @dev Collection of functions related to the address type
 */
library Address {
    /**
     * @dev Returns true if `account` is a contract.
     *
     * [IMPORTANT]
     * ====
     * It is unsafe to assume that an address for which this function returns
     * false is an externally-owned account (EOA) and not a contract.
     *
     * Among others, `isContract` will return false for the following
     * types of addresses:
     *
     *  - an externally-owned account
     *  - a contract in construction
     *  - an address where a contract will be created
     *  - an address where a contract lived, but was destroyed
     *
     * Furthermore, `isContract` will also return true if the target contract within
     * the same transaction is already scheduled for destruction by `SELFDESTRUCT`,
     * which only has an effect at the end of a transaction.
     * ====
     *
     * [IMPORTANT]
     * ====
     * You shouldn't rely on `isContract` to protect against flash loan attacks!
     *
     * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
     * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
     * constructor.
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // This method relies on extcodesize/address.code.length, which returns 0
        // for contracts in construction, since the code is only stored at the end
        // of the constructor execution.

        return account.code.length > 0;
    }

    /**
     * @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.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
     */
    function sendValue(address payable recipient, uint256 amount) internal {
        require(address(this).balance >= amount, "Address: insufficient balance");

        (bool success, ) = recipient.call{value: amount}("");
        require(success, "Address: unable to send value, recipient may have reverted");
    }

    /**
     * @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, it is bubbled up by this
     * function (like regular Solidity function calls).
     *
     * 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.
     *
     * _Available since v3.1._
     */
    function functionCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionCallWithValue(target, data, 0, "Address: low-level call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
     * `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal returns (bytes memory) {
        return functionCallWithValue(target, data, 0, errorMessage);
    }

    /**
     * @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`.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
        return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
    }

    /**
     * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
     * with `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(
        address target,
        bytes memory data,
        uint256 value,
        string memory errorMessage
    ) internal returns (bytes memory) {
        require(address(this).balance >= value, "Address: insufficient balance for call");
        (bool success, bytes memory returndata) = target.call{value: value}(data);
        return verifyCallResultFromTarget(target, success, returndata, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
        return functionStaticCall(target, data, "Address: low-level static call failed");
    }

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

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.4._
     */
    function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionDelegateCall(target, data, "Address: low-level delegate call failed");
    }

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

    /**
     * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling
     * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.
     *
     * _Available since v4.8._
     */
    function verifyCallResultFromTarget(
        address target,
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal view returns (bytes memory) {
        if (success) {
            if (returndata.length == 0) {
                // only check isContract if the call was successful and the return data is empty
                // otherwise we already know that it was a contract
                require(isContract(target), "Address: call to non-contract");
            }
            return returndata;
        } else {
            _revert(returndata, errorMessage);
        }
    }

    /**
     * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the
     * revert reason or using the provided one.
     *
     * _Available since v4.3._
     */
    function verifyCallResult(
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal pure returns (bytes memory) {
        if (success) {
            return returndata;
        } else {
            _revert(returndata, errorMessage);
        }
    }

    function _revert(bytes memory returndata, string memory errorMessage) 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
            /// @solidity memory-safe-assembly
            assembly {
                let returndata_size := mload(returndata)
                revert(add(32, returndata), returndata_size)
            }
        } else {
            revert(errorMessage);
        }
    }
}

File 10 of 18 : Context.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.4) (utils/Context.sol)

pragma solidity ^0.8.0;

/**
 * @dev Provides information about the current execution context, including the
 * sender of the transaction and its data. While these are generally available
 * via msg.sender and msg.data, they should not be accessed in such a direct
 * manner, since when dealing with meta-transactions the account sending and
 * paying for execution may not be the actual sender (as far as an application
 * is concerned).
 *
 * This contract is only required for intermediate, library-like contracts.
 */
abstract contract Context {
    function _msgSender() internal view virtual returns (address) {
        return msg.sender;
    }

    function _msgData() internal view virtual returns (bytes calldata) {
        return msg.data;
    }

    function _contextSuffixLength() internal view virtual returns (uint256) {
        return 0;
    }
}

File 11 of 18 : MerkleProof.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.2) (utils/cryptography/MerkleProof.sol)

pragma solidity ^0.8.0;

/**
 * @dev These functions deal with verification of Merkle Tree proofs.
 *
 * The tree and the proofs can be generated using our
 * https://github.com/OpenZeppelin/merkle-tree[JavaScript library].
 * You will find a quickstart guide in the readme.
 *
 * WARNING: You should avoid using leaf values that are 64 bytes long prior to
 * hashing, or use a hash function other than keccak256 for hashing leaves.
 * This is because the concatenation of a sorted pair of internal nodes in
 * the merkle tree could be reinterpreted as a leaf value.
 * OpenZeppelin's JavaScript library generates merkle trees that are safe
 * against this attack out of the box.
 */
library MerkleProof {
    /**
     * @dev Returns true if a `leaf` can be proved to be a part of a Merkle tree
     * defined by `root`. For this, a `proof` must be provided, containing
     * sibling hashes on the branch from the leaf to the root of the tree. Each
     * pair of leaves and each pair of pre-images are assumed to be sorted.
     */
    function verify(bytes32[] memory proof, bytes32 root, bytes32 leaf) internal pure returns (bool) {
        return processProof(proof, leaf) == root;
    }

    /**
     * @dev Calldata version of {verify}
     *
     * _Available since v4.7._
     */
    function verifyCalldata(bytes32[] calldata proof, bytes32 root, bytes32 leaf) internal pure returns (bool) {
        return processProofCalldata(proof, leaf) == root;
    }

    /**
     * @dev Returns the rebuilt hash obtained by traversing a Merkle tree up
     * from `leaf` using `proof`. A `proof` is valid if and only if the rebuilt
     * hash matches the root of the tree. When processing the proof, the pairs
     * of leafs & pre-images are assumed to be sorted.
     *
     * _Available since v4.4._
     */
    function processProof(bytes32[] memory proof, bytes32 leaf) internal pure returns (bytes32) {
        bytes32 computedHash = leaf;
        for (uint256 i = 0; i < proof.length; i++) {
            computedHash = _hashPair(computedHash, proof[i]);
        }
        return computedHash;
    }

    /**
     * @dev Calldata version of {processProof}
     *
     * _Available since v4.7._
     */
    function processProofCalldata(bytes32[] calldata proof, bytes32 leaf) internal pure returns (bytes32) {
        bytes32 computedHash = leaf;
        for (uint256 i = 0; i < proof.length; i++) {
            computedHash = _hashPair(computedHash, proof[i]);
        }
        return computedHash;
    }

    /**
     * @dev Returns true if the `leaves` can be simultaneously proven to be a part of a merkle tree defined by
     * `root`, according to `proof` and `proofFlags` as described in {processMultiProof}.
     *
     * CAUTION: Not all merkle trees admit multiproofs. See {processMultiProof} for details.
     *
     * _Available since v4.7._
     */
    function multiProofVerify(
        bytes32[] memory proof,
        bool[] memory proofFlags,
        bytes32 root,
        bytes32[] memory leaves
    ) internal pure returns (bool) {
        return processMultiProof(proof, proofFlags, leaves) == root;
    }

    /**
     * @dev Calldata version of {multiProofVerify}
     *
     * CAUTION: Not all merkle trees admit multiproofs. See {processMultiProof} for details.
     *
     * _Available since v4.7._
     */
    function multiProofVerifyCalldata(
        bytes32[] calldata proof,
        bool[] calldata proofFlags,
        bytes32 root,
        bytes32[] memory leaves
    ) internal pure returns (bool) {
        return processMultiProofCalldata(proof, proofFlags, leaves) == root;
    }

    /**
     * @dev Returns the root of a tree reconstructed from `leaves` and sibling nodes in `proof`. The reconstruction
     * proceeds by incrementally reconstructing all inner nodes by combining a leaf/inner node with either another
     * leaf/inner node or a proof sibling node, depending on whether each `proofFlags` item is true or false
     * respectively.
     *
     * CAUTION: Not all merkle trees admit multiproofs. To use multiproofs, it is sufficient to ensure that: 1) the tree
     * is complete (but not necessarily perfect), 2) the leaves to be proven are in the opposite order they are in the
     * tree (i.e., as seen from right to left starting at the deepest layer and continuing at the next layer).
     *
     * _Available since v4.7._
     */
    function processMultiProof(
        bytes32[] memory proof,
        bool[] memory proofFlags,
        bytes32[] memory leaves
    ) internal pure returns (bytes32 merkleRoot) {
        // This function rebuilds the root hash by traversing the tree up from the leaves. The root is rebuilt by
        // consuming and producing values on a queue. The queue starts with the `leaves` array, then goes onto the
        // `hashes` array. At the end of the process, the last hash in the `hashes` array should contain the root of
        // the merkle tree.
        uint256 leavesLen = leaves.length;
        uint256 proofLen = proof.length;
        uint256 totalHashes = proofFlags.length;

        // Check proof validity.
        require(leavesLen + proofLen - 1 == totalHashes, "MerkleProof: invalid multiproof");

        // The xxxPos values are "pointers" to the next value to consume in each array. All accesses are done using
        // `xxx[xxxPos++]`, which return the current value and increment the pointer, thus mimicking a queue's "pop".
        bytes32[] memory hashes = new bytes32[](totalHashes);
        uint256 leafPos = 0;
        uint256 hashPos = 0;
        uint256 proofPos = 0;
        // At each step, we compute the next hash using two values:
        // - a value from the "main queue". If not all leaves have been consumed, we get the next leaf, otherwise we
        //   get the next hash.
        // - depending on the flag, either another value from the "main queue" (merging branches) or an element from the
        //   `proof` array.
        for (uint256 i = 0; i < totalHashes; i++) {
            bytes32 a = leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++];
            bytes32 b = proofFlags[i]
                ? (leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++])
                : proof[proofPos++];
            hashes[i] = _hashPair(a, b);
        }

        if (totalHashes > 0) {
            require(proofPos == proofLen, "MerkleProof: invalid multiproof");
            unchecked {
                return hashes[totalHashes - 1];
            }
        } else if (leavesLen > 0) {
            return leaves[0];
        } else {
            return proof[0];
        }
    }

    /**
     * @dev Calldata version of {processMultiProof}.
     *
     * CAUTION: Not all merkle trees admit multiproofs. See {processMultiProof} for details.
     *
     * _Available since v4.7._
     */
    function processMultiProofCalldata(
        bytes32[] calldata proof,
        bool[] calldata proofFlags,
        bytes32[] memory leaves
    ) internal pure returns (bytes32 merkleRoot) {
        // This function rebuilds the root hash by traversing the tree up from the leaves. The root is rebuilt by
        // consuming and producing values on a queue. The queue starts with the `leaves` array, then goes onto the
        // `hashes` array. At the end of the process, the last hash in the `hashes` array should contain the root of
        // the merkle tree.
        uint256 leavesLen = leaves.length;
        uint256 proofLen = proof.length;
        uint256 totalHashes = proofFlags.length;

        // Check proof validity.
        require(leavesLen + proofLen - 1 == totalHashes, "MerkleProof: invalid multiproof");

        // The xxxPos values are "pointers" to the next value to consume in each array. All accesses are done using
        // `xxx[xxxPos++]`, which return the current value and increment the pointer, thus mimicking a queue's "pop".
        bytes32[] memory hashes = new bytes32[](totalHashes);
        uint256 leafPos = 0;
        uint256 hashPos = 0;
        uint256 proofPos = 0;
        // At each step, we compute the next hash using two values:
        // - a value from the "main queue". If not all leaves have been consumed, we get the next leaf, otherwise we
        //   get the next hash.
        // - depending on the flag, either another value from the "main queue" (merging branches) or an element from the
        //   `proof` array.
        for (uint256 i = 0; i < totalHashes; i++) {
            bytes32 a = leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++];
            bytes32 b = proofFlags[i]
                ? (leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++])
                : proof[proofPos++];
            hashes[i] = _hashPair(a, b);
        }

        if (totalHashes > 0) {
            require(proofPos == proofLen, "MerkleProof: invalid multiproof");
            unchecked {
                return hashes[totalHashes - 1];
            }
        } else if (leavesLen > 0) {
            return leaves[0];
        } else {
            return proof[0];
        }
    }

    function _hashPair(bytes32 a, bytes32 b) private pure returns (bytes32) {
        return a < b ? _efficientHash(a, b) : _efficientHash(b, a);
    }

    function _efficientHash(bytes32 a, bytes32 b) private pure returns (bytes32 value) {
        /// @solidity memory-safe-assembly
        assembly {
            mstore(0x00, a)
            mstore(0x20, b)
            value := keccak256(0x00, 0x40)
        }
    }
}

File 12 of 18 : ERC165.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)

pragma solidity ^0.8.0;

import "./IERC165.sol";

/**
 * @dev Implementation of the {IERC165} interface.
 *
 * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check
 * for the additional interface id that will be supported. For example:
 *
 * ```solidity
 * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
 *     return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
 * }
 * ```
 *
 * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.
 */
abstract contract ERC165 is IERC165 {
    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
        return interfaceId == type(IERC165).interfaceId;
    }
}

File 13 of 18 : IERC165.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC165 standard, as defined in the
 * https://eips.ethereum.org/EIPS/eip-165[EIP].
 *
 * 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[EIP 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);
}

File 14 of 18 : Math.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/math/Math.sol)

pragma solidity ^0.8.0;

/**
 * @dev Standard math utilities missing in the Solidity language.
 */
library Math {
    enum Rounding {
        Down, // Toward negative infinity
        Up, // Toward infinity
        Zero // Toward zero
    }

    /**
     * @dev Returns the largest of two numbers.
     */
    function max(uint256 a, uint256 b) internal pure returns (uint256) {
        return a > b ? a : b;
    }

    /**
     * @dev Returns the smallest of two numbers.
     */
    function min(uint256 a, uint256 b) internal pure returns (uint256) {
        return a < b ? a : b;
    }

    /**
     * @dev Returns the average of two numbers. The result is rounded towards
     * zero.
     */
    function average(uint256 a, uint256 b) internal pure returns (uint256) {
        // (a + b) / 2 can overflow.
        return (a & b) + (a ^ b) / 2;
    }

    /**
     * @dev Returns the ceiling of the division of two numbers.
     *
     * This differs from standard division with `/` in that it rounds up instead
     * of rounding down.
     */
    function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
        // (a + b - 1) / b can overflow on addition, so we distribute.
        return a == 0 ? 0 : (a - 1) / b + 1;
    }

    /**
     * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0
     * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)
     * with further edits by Uniswap Labs also under MIT license.
     */
    function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) {
        unchecked {
            // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use
            // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256
            // variables such that product = prod1 * 2^256 + prod0.
            uint256 prod0; // Least significant 256 bits of the product
            uint256 prod1; // Most significant 256 bits of the product
            assembly {
                let mm := mulmod(x, y, not(0))
                prod0 := mul(x, y)
                prod1 := sub(sub(mm, prod0), lt(mm, prod0))
            }

            // Handle non-overflow cases, 256 by 256 division.
            if (prod1 == 0) {
                // Solidity will revert if denominator == 0, unlike the div opcode on its own.
                // The surrounding unchecked block does not change this fact.
                // See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic.
                return prod0 / denominator;
            }

            // Make sure the result is less than 2^256. Also prevents denominator == 0.
            require(denominator > prod1, "Math: mulDiv overflow");

            ///////////////////////////////////////////////
            // 512 by 256 division.
            ///////////////////////////////////////////////

            // Make division exact by subtracting the remainder from [prod1 prod0].
            uint256 remainder;
            assembly {
                // Compute remainder using mulmod.
                remainder := mulmod(x, y, denominator)

                // Subtract 256 bit number from 512 bit number.
                prod1 := sub(prod1, gt(remainder, prod0))
                prod0 := sub(prod0, remainder)
            }

            // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.
            // See https://cs.stackexchange.com/q/138556/92363.

            // Does not overflow because the denominator cannot be zero at this stage in the function.
            uint256 twos = denominator & (~denominator + 1);
            assembly {
                // Divide denominator by twos.
                denominator := div(denominator, twos)

                // Divide [prod1 prod0] by twos.
                prod0 := div(prod0, twos)

                // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.
                twos := add(div(sub(0, twos), twos), 1)
            }

            // Shift in bits from prod1 into prod0.
            prod0 |= prod1 * twos;

            // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such
            // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for
            // four bits. That is, denominator * inv = 1 mod 2^4.
            uint256 inverse = (3 * denominator) ^ 2;

            // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works
            // in modular arithmetic, doubling the correct bits in each step.
            inverse *= 2 - denominator * inverse; // inverse mod 2^8
            inverse *= 2 - denominator * inverse; // inverse mod 2^16
            inverse *= 2 - denominator * inverse; // inverse mod 2^32
            inverse *= 2 - denominator * inverse; // inverse mod 2^64
            inverse *= 2 - denominator * inverse; // inverse mod 2^128
            inverse *= 2 - denominator * inverse; // inverse mod 2^256

            // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.
            // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is
            // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1
            // is no longer required.
            result = prod0 * inverse;
            return result;
        }
    }

    /**
     * @notice Calculates x * y / denominator with full precision, following the selected rounding direction.
     */
    function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) {
        uint256 result = mulDiv(x, y, denominator);
        if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {
            result += 1;
        }
        return result;
    }

    /**
     * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down.
     *
     * Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11).
     */
    function sqrt(uint256 a) internal pure returns (uint256) {
        if (a == 0) {
            return 0;
        }

        // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.
        //
        // We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have
        // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.
        //
        // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`
        // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`
        // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`
        //
        // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.
        uint256 result = 1 << (log2(a) >> 1);

        // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,
        // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at
        // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision
        // into the expected uint128 result.
        unchecked {
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            return min(result, a / result);
        }
    }

    /**
     * @notice Calculates sqrt(a), following the selected rounding direction.
     */
    function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = sqrt(a);
            return result + (rounding == Rounding.Up && result * result < a ? 1 : 0);
        }
    }

    /**
     * @dev Return the log in base 2, rounded down, of a positive value.
     * Returns 0 if given 0.
     */
    function log2(uint256 value) internal pure returns (uint256) {
        uint256 result = 0;
        unchecked {
            if (value >> 128 > 0) {
                value >>= 128;
                result += 128;
            }
            if (value >> 64 > 0) {
                value >>= 64;
                result += 64;
            }
            if (value >> 32 > 0) {
                value >>= 32;
                result += 32;
            }
            if (value >> 16 > 0) {
                value >>= 16;
                result += 16;
            }
            if (value >> 8 > 0) {
                value >>= 8;
                result += 8;
            }
            if (value >> 4 > 0) {
                value >>= 4;
                result += 4;
            }
            if (value >> 2 > 0) {
                value >>= 2;
                result += 2;
            }
            if (value >> 1 > 0) {
                result += 1;
            }
        }
        return result;
    }

    /**
     * @dev Return the log in base 2, following the selected rounding direction, of a positive value.
     * Returns 0 if given 0.
     */
    function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = log2(value);
            return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);
        }
    }

    /**
     * @dev Return the log in base 10, rounded down, of a positive value.
     * Returns 0 if given 0.
     */
    function log10(uint256 value) internal pure returns (uint256) {
        uint256 result = 0;
        unchecked {
            if (value >= 10 ** 64) {
                value /= 10 ** 64;
                result += 64;
            }
            if (value >= 10 ** 32) {
                value /= 10 ** 32;
                result += 32;
            }
            if (value >= 10 ** 16) {
                value /= 10 ** 16;
                result += 16;
            }
            if (value >= 10 ** 8) {
                value /= 10 ** 8;
                result += 8;
            }
            if (value >= 10 ** 4) {
                value /= 10 ** 4;
                result += 4;
            }
            if (value >= 10 ** 2) {
                value /= 10 ** 2;
                result += 2;
            }
            if (value >= 10 ** 1) {
                result += 1;
            }
        }
        return result;
    }

    /**
     * @dev Return the log in base 10, following the selected rounding direction, of a positive value.
     * Returns 0 if given 0.
     */
    function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = log10(value);
            return result + (rounding == Rounding.Up && 10 ** result < value ? 1 : 0);
        }
    }

    /**
     * @dev Return the log in base 256, rounded down, of a positive value.
     * Returns 0 if given 0.
     *
     * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.
     */
    function log256(uint256 value) internal pure returns (uint256) {
        uint256 result = 0;
        unchecked {
            if (value >> 128 > 0) {
                value >>= 128;
                result += 16;
            }
            if (value >> 64 > 0) {
                value >>= 64;
                result += 8;
            }
            if (value >> 32 > 0) {
                value >>= 32;
                result += 4;
            }
            if (value >> 16 > 0) {
                value >>= 16;
                result += 2;
            }
            if (value >> 8 > 0) {
                result += 1;
            }
        }
        return result;
    }

    /**
     * @dev Return the log in base 256, following the selected rounding direction, of a positive value.
     * Returns 0 if given 0.
     */
    function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = log256(value);
            return result + (rounding == Rounding.Up && 1 << (result << 3) < value ? 1 : 0);
        }
    }
}

File 15 of 18 : SignedMath.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SignedMath.sol)

pragma solidity ^0.8.0;

/**
 * @dev Standard signed math utilities missing in the Solidity language.
 */
library SignedMath {
    /**
     * @dev Returns the largest of two signed numbers.
     */
    function max(int256 a, int256 b) internal pure returns (int256) {
        return a > b ? a : b;
    }

    /**
     * @dev Returns the smallest of two signed numbers.
     */
    function min(int256 a, int256 b) internal pure returns (int256) {
        return a < b ? a : b;
    }

    /**
     * @dev Returns the average of two signed numbers without overflow.
     * The result is rounded towards zero.
     */
    function average(int256 a, int256 b) internal pure returns (int256) {
        // Formula from the book "Hacker's Delight"
        int256 x = (a & b) + ((a ^ b) >> 1);
        return x + (int256(uint256(x) >> 255) & (a ^ b));
    }

    /**
     * @dev Returns the absolute unsigned value of a signed value.
     */
    function abs(int256 n) internal pure returns (uint256) {
        unchecked {
            // must be unchecked in order to support `n = type(int256).min`
            return uint256(n >= 0 ? n : -n);
        }
    }
}

File 16 of 18 : Strings.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/Strings.sol)

pragma solidity ^0.8.0;

import "./math/Math.sol";
import "./math/SignedMath.sol";

/**
 * @dev String operations.
 */
library Strings {
    bytes16 private constant _SYMBOLS = "0123456789abcdef";
    uint8 private constant _ADDRESS_LENGTH = 20;

    /**
     * @dev Converts a `uint256` to its ASCII `string` decimal representation.
     */
    function toString(uint256 value) internal pure returns (string memory) {
        unchecked {
            uint256 length = Math.log10(value) + 1;
            string memory buffer = new string(length);
            uint256 ptr;
            /// @solidity memory-safe-assembly
            assembly {
                ptr := add(buffer, add(32, length))
            }
            while (true) {
                ptr--;
                /// @solidity memory-safe-assembly
                assembly {
                    mstore8(ptr, byte(mod(value, 10), _SYMBOLS))
                }
                value /= 10;
                if (value == 0) break;
            }
            return buffer;
        }
    }

    /**
     * @dev Converts a `int256` to its ASCII `string` decimal representation.
     */
    function toString(int256 value) internal pure returns (string memory) {
        return string(abi.encodePacked(value < 0 ? "-" : "", toString(SignedMath.abs(value))));
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
     */
    function toHexString(uint256 value) internal pure returns (string memory) {
        unchecked {
            return toHexString(value, Math.log256(value) + 1);
        }
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
     */
    function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
        bytes memory buffer = new bytes(2 * length + 2);
        buffer[0] = "0";
        buffer[1] = "x";
        for (uint256 i = 2 * length + 1; i > 1; --i) {
            buffer[i] = _SYMBOLS[value & 0xf];
            value >>= 4;
        }
        require(value == 0, "Strings: hex length insufficient");
        return string(buffer);
    }

    /**
     * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.
     */
    function toHexString(address addr) internal pure returns (string memory) {
        return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);
    }

    /**
     * @dev Returns true if the two strings are equal.
     */
    function equal(string memory a, string memory b) internal pure returns (bool) {
        return keccak256(bytes(a)) == keccak256(bytes(b));
    }
}

File 17 of 18 : Common.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.12;

library Common {
    /**
     * @param identifier  bytes32  Identifier of the distribution
     * @param token       address  Address of the token to distribute
     * @param merkleRoot  bytes32  Merkle root of the distribution
     * @param proof       bytes32  Proof of the distribution
     */
    struct Distribution {
        bytes32 identifier;
        address token;
        bytes32 merkleRoot;
        bytes32 proof;
    }

    /**
     * @param proposal          bytes32  Proposal to bribe
     * @param token             address  Token to bribe with
     * @param briber            address  Address of the briber
     * @param amount            uint256  Amount of tokens to bribe with
     * @param maxTokensPerVote  uint256  Maximum amount of tokens to use per vote
     * @param periods           uint256  Number of periods to bribe for
     * @param periodDuration    uint256  Duration of each period
     * @param proposalDeadline  uint256  Deadline for the proposal
     * @param permitDeadline    uint256  Deadline for the permit2 signature
     * @param signature         bytes    Permit2 signature
     */
    struct DepositBribeParams {
        bytes32 proposal;
        address token;
        address briber;
        uint256 amount;
        uint256 maxTokensPerVote;
        uint256 periods;
        uint256 periodDuration;
        uint256 proposalDeadline;
        uint256 permitDeadline;
        bytes signature;
    }

    /**
     * @param rwIdentifier      bytes32    Identifier for claiming reward
     * @param fromToken         address    Address of token to swap from
     * @param toToken           address    Address of token to swap to
     * @param fromAmount        uint256    Amount of fromToken to swap
     * @param toAmount          uint256    Amount of toToken to receive
     * @param deadline          uint256    Timestamp until which swap may be fulfilled
     * @param callees           address[]  Array of addresses to call (DEX addresses)
     * @param callLengths       uint256[]  Index of the beginning of each call in exchangeData
     * @param values            uint256[]  Array of encoded values for each call in exchangeData
     * @param exchangeData      bytes      Calldata to execute on callees
     * @param rwMerkleProof     bytes32[]  Merkle proof for the reward claim
     */
    struct ClaimAndSwapData {
        bytes32 rwIdentifier;
        address fromToken;
        address toToken;
        uint256 fromAmount;
        uint256 toAmount;
        uint256 deadline;
        address[] callees;
        uint256[] callLengths;
        uint256[] values;
        bytes exchangeData;
        bytes32[] rwMerkleProof;
    }

    /**
     * @param identifier   bytes32    Identifier for claiming reward
     * @param account      address    Address of the account to claim for
     * @param amount       uint256    Amount of tokens to claim
     * @param merkleProof  bytes32[]  Merkle proof for the reward claim
     */
    struct Claim {
        bytes32 identifier;
        address account;
        uint256 amount;
        bytes32[] merkleProof;
    }
}

File 18 of 18 : Errors.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.12;

library Errors {
    /**
     * @notice max period 0 or greater than MAX_PERIODS
     */
    error InvalidMaxPeriod();

    /**
     * @notice period duration 0 or greater than MAX_PERIOD_DURATION
     */
    error InvalidPeriodDuration();

    /**
     * @notice address provided is not a contract
     */
    error NotAContract();

    /**
     * @notice not authorized
     */
    error NotAuthorized();

    /**
     * @notice contract already initialized
     */
    error AlreadyInitialized();

    /**
     * @notice address(0)
     */
    error InvalidAddress();

    /**
     * @notice empty bytes identifier
     */
    error InvalidIdentifier();

    /**
     * @notice invalid protocol name
     */
    error InvalidProtocol();

    /**
     * @notice invalid number of choices
     */
    error InvalidChoiceCount();

    /**
     * @notice invalid input amount
     */
    error InvalidAmount();

    /**
     * @notice not team member
     */
    error NotTeamMember();

    /**
     * @notice cannot whitelist BRIBE_VAULT
     */
    error NoWhitelistBribeVault();

    /**
     * @notice token already whitelisted
     */
    error TokenWhitelisted();

    /**
     * @notice token not whitelisted
     */
    error TokenNotWhitelisted();

    /**
     * @notice voter already blacklisted
     */
    error VoterBlacklisted();

    /**
     * @notice voter not blacklisted
     */
    error VoterNotBlacklisted();

    /**
     * @notice deadline has passed
     */
    error DeadlinePassed();

    /**
     * @notice invalid period
     */
    error InvalidPeriod();

    /**
     * @notice invalid deadline
     */
    error InvalidDeadline();

    /**
     * @notice invalid max fee
     */
    error InvalidMaxFee();

    /**
     * @notice invalid fee
     */
    error InvalidFee();

    /**
     * @notice invalid fee recipient
     */
    error InvalidFeeRecipient();

    /**
     * @notice invalid distributor
     */
    error InvalidDistributor();

    /**
     * @notice invalid briber
     */
    error InvalidBriber();

    /**
     * @notice address does not have DEPOSITOR_ROLE
     */
    error NotDepositor();

    /**
     * @notice no array given
     */
    error InvalidArray();

    /**
     * @notice invalid reward identifier
     */
    error InvalidRewardIdentifier();

    /**
     * @notice bribe has already been transferred
     */
    error BribeAlreadyTransferred();

    /**
     * @notice distribution does not exist
     */
    error InvalidDistribution();

    /**
     * @notice invalid merkle root
     */
    error InvalidMerkleRoot();

    /**
     * @notice token is address(0)
     */
    error InvalidToken();

    /**
     * @notice claim does not exist
     */
    error InvalidClaim();

    /**
     * @notice reward is not yet active for claiming
     */
    error RewardInactive();

    /**
     * @notice timer duration is invalid
     */
    error InvalidTimerDuration();

    /**
     * @notice merkle proof is invalid
     */
    error InvalidProof();

    /**
     * @notice ETH transfer failed
     */
    error ETHTransferFailed();

    /**
     * @notice Invalid operator address
     */
    error InvalidOperator();

    /**
     * @notice call to TokenTransferProxy contract
     */
    error TokenTransferProxyCall();

    /**
     * @notice calling TransferFrom
     */
    error TransferFromCall();

    /**
     * @notice external call failed
     */
    error ExternalCallFailure();

    /**
     * @notice returned tokens too few
     */
    error InsufficientReturn();

    /**
     * @notice swapDeadline expired
     */
    error DeadlineBreach();

    /**
     * @notice expected tokens returned are 0
     */
    error ZeroExpectedReturns();

    /**
     * @notice arrays in SwapData.exchangeData have wrong lengths
     */
    error ExchangeDataArrayMismatch();

    /**
     * @notice market to deposit bribe from the helper contract is invalid
     */
    error InvalidMarket();
}

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

Contract Security Audit

Contract ABI

[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"InvalidArray","type":"error"},{"inputs":[],"name":"InvalidDistribution","type":"error"},{"inputs":[],"name":"InvalidMerkleRoot","type":"error"},{"inputs":[],"name":"InvalidProof","type":"error"},{"inputs":[],"name":"InvalidTimerDuration","type":"error"},{"inputs":[],"name":"RewardInactive","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"identifier","type":"bytes32"},{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"RewardClaimed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"identifier","type":"bytes32"},{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"bytes32","name":"merkleRoot","type":"bytes32"},{"indexed":false,"internalType":"bytes32","name":"proof","type":"bytes32"},{"indexed":false,"internalType":"uint256","name":"activeAt","type":"uint256"}],"name":"RewardMetadataUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"duration","type":"uint256"}],"name":"SetActiveTimerDuration","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MINIMUM_ACTIVE_TIMER","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"activeTimerDuration","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_duration","type":"uint256"}],"name":"changeActiveTimerDuration","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"bytes32","name":"identifier","type":"bytes32"},{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bytes32[]","name":"merkleProof","type":"bytes32[]"}],"internalType":"struct RewardDistributor.Claim[]","name":"_claims","type":"tuple[]"}],"name":"claim","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"},{"internalType":"address","name":"","type":"address"}],"name":"claimed","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"rewards","outputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"bytes32","name":"merkleRoot","type":"bytes32"},{"internalType":"bytes32","name":"proof","type":"bytes32"},{"internalType":"uint256","name":"activeAt","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"state","type":"bool"}],"name":"setPauseState","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"bytes32","name":"identifier","type":"bytes32"},{"internalType":"address","name":"token","type":"address"},{"internalType":"bytes32","name":"merkleRoot","type":"bytes32"},{"internalType":"bytes32","name":"proof","type":"bytes32"}],"internalType":"struct Common.Distribution[]","name":"_distributions","type":"tuple[]"}],"name":"updateRewardsMetadata","outputs":[],"stateMutability":"nonpayable","type":"function"}]

60806040523462000027575b6200001562000069565b604051611bc9620002cd8239611bc990f35b6200003162000037565b6200000b565b50600080fd5b6200004d6200004d6200004d9290565b90565b6200004d60006200003d565b6200004d612a306200003d565b62000073620000d3565b620000896200008162000050565b339062000192565b6200009d620000976200005c565b62000254565b565b9060ff905b9181191691161790565b151590565b90620000c76200004d620000cf92620000ae565b82546200009f565b9055565b620000dd6200011e565b6200009d60006002620000b3565b6200004d60016200003d565b9060001990620000a4565b90620001166200004d620000cf926200003d565b8254620000f7565b6200009d6200012c620000eb565b600162000102565b9062000140906200004d565b600052602052604060002090565b6200004d9062000164906001600160a01b031682565b6001600160a01b031690565b6200004d906200014e565b6200004d9062000170565b9062000140906200017b565b90620001a7620001a3828462000236565b1590565b620001b0575050565b620001d66001620001d0836000620001c9878262000134565b0162000186565b620000b3565b3390620002136200020c6200020c7f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d956200004d565b926200017b565b926200021e60405190565b600090a4565b60ff1690565b6200004d905462000224565b6200004d916200024e91620001c96000918262000134565b6200022a565b620002626200004d6200005c565b8110620002b8576200027681600562000102565b620002b37f676dc704f22ddab12a141690a96616ef0128413803c63394aba7ffe658681a1691620002a660405190565b9182918290815260200190565b0390a1565b50506040516367e00a0760e01b8152600490fdfe60806040526004361015610018575b6100166103a0565b005b60003560e01c806301ffc9a714610376578063248a9ca31461034c5780632f2ff15d1461032457806333f642f6146102fa57806336568abe146102d257806356853398146102aa5780635c975abb146102805780637fdba5f61461025657806391d1485414610219578063938d967a146101d9578063960d264d146101b2578063a217fddf14610188578063cdb88ad114610161578063d547741f14610139578063df45c752146101115763dfcae622146100d25761000e565b34610104575b6101006100ef6100e936600461044d565b9061070d565b6040515b9182918290815260200190565b0390f35b61010c6103a0565b6100d8565b503461012c575b61001661012636600461069a565b9061137a565b6101346103a0565b610118565b5034610154575b61001661014e36600461044d565b906109e1565b61015c6103a0565b610140565b503461017b575b61001661017636600461062d565b6113a8565b6101836103a0565b610168565b50346101a5575b61019a36600461047e565b6101006100ef610610565b6101ad6103a0565b61018f565b50346101cc575b6100166101c7366004610404565b6114d5565b6101d46103a0565b6101b9565b503461020c575b6101006101f66101f1366004610404565b610587565b9061020394929460405190565b948594856105ca565b6102146103a0565b6101e0565b5034610249575b61010061023761023136600461044d565b9061077b565b60405191829182901515815260200190565b6102516103a0565b610220565b5034610273575b61026836600461047e565b6101006100ef61055e565b61027b6103a0565b61025d565b503461029d575b61029236600461047e565b610100610237610b6f565b6102a56103a0565b610287565b50346102c5575b6100166102bf3660046104ff565b90611040565b6102cd6103a0565b6102b1565b50346102ed575b6100166102e736600461044d565b90610a50565b6102f56103a0565b6102d9565b5034610317575b61030c36600461047e565b6101006100ef6104a7565b61031f6103a0565b610301565b503461033f575b61001661033936600461044d565b906107d9565b6103476103a0565b61032b565b5034610369575b6101006100ef610364366004610404565b61079a565b6103716103a0565b610353565b5034610393575b61010061023761038e3660046103c9565b61072c565b61039b6103a0565b61037d565b50600080fd5b6001600160e01b031981165b14156103a057565b905035906103c7826103a6565b565b906103dd916020818303126103e0576103ba565b90565b6103e86103a0565b6103ba565b9052565b806103b2565b905035906103c7826103f1565b906103dd91602081830312610418576103f7565b6104206103a0565b6103f7565b6001600160a01b031690565b6001600160a01b0381166103b2565b905035906103c782610431565b91906103dd90604084820312610471575b61046881856103f7565b93602001610440565b6104796103a0565b61045e565b600091031261048957565b6103c76103a0565b6103dd916008021c81565b906103dd9154610491565b6103dd6000600561049c565b909182601f830112156104f2575b602082359267ffffffffffffffff84116104e5575b01926020830284011161048957565b6104ed6103a0565b6104d6565b6104fa6103a0565b6104c1565b9061052891602081830312610539575b80359067ffffffffffffffff821161052c575b016104b3565b9091565b6105346103a0565b610522565b6105416103a0565b61050f565b6103dd6103dd6103dd9290565b6103dd612a30610546565b6103dd610553565b905b600052602052604060002090565b6103dd9081565b6103dd9054610576565b610592906003610566565b906105a482546001600160a01b031690565b916105b16001820161057d565b916103dd60036105c36002850161057d565b930161057d565b6106026103c7946105fb6060949897956105f4608086019a60008701906001600160a01b03169052565b6020850152565b6040830152565b0152565b6103dd6000610546565b6103dd610606565b8015156103b2565b905035906103c782610618565b906103dd9160208183031261064157610620565b6106496103a0565b610620565b909182601f8301121561068d575b602082359267ffffffffffffffff8411610680575b01926080830284011161048957565b6106886103a0565b610671565b6106956103a0565b61065c565b90610528916020818303126106d0575b80359067ffffffffffffffff82116106c3575b0161064e565b6106cb6103a0565b6106bd565b6106d86103a0565b6106aa565b6103dd90610425906001600160a01b031682565b6103dd906106dd565b6103dd906106f1565b90610568906106fa565b6107276103dd92610722600493600094610566565b610703565b61049c565b637965db0b60e01b6001600160e01b031982161490811561074b575090565b6103dd91506001600160e01b0319166301ffc9a760e01b1490565b6103dd905b60ff1690565b6103dd9054610766565b6103dd916107959161078f60009182610566565b01610703565b610771565b60016107b36103dd926107ab600090565b506000610566565b0161057d565b906103c7916107cf6107ca8261079a565b6107e3565b906103c791610aa0565b906103c7916107b9565b6103c7903390610937565b6103dd90610546565b0190565b918091926000905b82821061081b575011610814575050565b6000910152565b91508060209183015181860152018291610803565b6107f761084892602092610842815190565b94859290565b938491016107fb565b61088f6103dd9392610889610889937f416363657373436f6e74726f6c3a206163636f756e7420000000000000000000815260170190565b90610830565b7001034b99036b4b9b9b4b733903937b6329607d1b815260110190565b601f01601f191690565b50634e487b7160e01b600052604160045260246000fd5b90601f01601f1916810190811067ffffffffffffffff8211176108ef57604052565b6108f76108b6565b604052565b61091d6108ac6020936107f793610911815190565b80835293849260200190565b958691016107fb565b60208082526103dd929101906108fc565b90610949610945828461077b565b1590565b610951575050565b6109c29250906103dd61096f6109696109a994610e78565b926107ee565b61098460209161097e83610546565b90610d18565b9261099d61099160405190565b94859384019283610851565b908103825203826108cd565b6040515b62461bcd60e51b815291829160048301610926565b0390fd5b906103c7916109d76107ca8261079a565b906103c791610b18565b906103c7916109c6565b156109f257565b5060405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b6064820152608490fd5b6103c79190610a71610a6133610425565b6001600160a01b038416146109eb565b610b18565b9060ff905b9181191691161790565b90610a956103dd610a9c92151590565b8254610a76565b9055565b90610aae610945828461077b565b610ab6575050565b610ad06001610acb83600061078f8782610566565b610a85565b3390610b06610b00610b007f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d9590565b926106fa565b92610b1060405190565b80805b0390a4565b90610b23818361077b565b610b2b575050565b610b3f6000610acb838261078f8782610566565b3390610b06610b00610b007ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9590565b6103dd6002610771565b50634e487b7160e01b600052601160045260246000fd5b90610b9a565b9190565b908060001904821181151516610bae570290565b610bb6610b79565b0290565b81198111610bc6570190565b6107f7610b79565b906103c7610bdb60405190565b92836108cd565b6107f760209167ffffffffffffffff8111610c0157601f01601f191690565b6108ac6108b6565b90610c1b610c1683610be2565b610bce565b918252565b369037565b906103c7610c3b610c3584610c09565b93610be2565b601f190160208401610c20565b50634e487b7160e01b600052603260045260246000fd5b906001602091610c6d845190565b811015610c7b575b02010190565b610c83610c48565b610c75565b6001908015610c95570390565b610c9d610b79565b0390565b61076b6103dd6103dd9290565b6103dd90610cc2610b966103dd9460ff1690565b901c90565b15610cce57565b5060405162461bcd60e51b8152806109c2600482016020808252818101527f537472696e67733a20686578206c656e67746820696e73756666696369656e74604082015260600190565b9190600290610d49610d44610d3583610d3086610546565b610b90565b610d3e85610546565b90610bba565b610c25565b916000916030610d61610d5b85610546565b86610c5f565b53610d99610d90600f60fb1b92610d306001958695881a610d8a610d8488610546565b8b610c5f565b53610546565b610d3e83610546565b915b610dbc575b50506103dd9293610db6610b966103dd93610546565b14610cc7565b9094610dc782610546565b861115610e4657610e33610e2d8392610e10610df36f181899199a1a9b1b9c1cb0b131b232b360811b90565b610dfd600f610546565b83166010811015610e39575b1a60f81b90565b861a610e1c8a89610c5f565b53610e276004610ca1565b90610cae565b96610c88565b91610d9b565b610e41610c48565b610e09565b94610da0565b6103dd9081906001600160a01b031681565b6103dd6014610ca1565b6103dd6103dd6103dd9260ff1690565b610e95610e906103dd92610e8a606090565b506106f1565b610e4c565b61097e610ea0610e5e565b610e68565b1490565b90610ebb91610eb6611115565b610ec3565b6103c7611147565b906103c791610ed061108a565b610f80565b903590607e193682900301821215610eeb570190565b6107f76103a0565b906103dd92602091811015610f0c575b02810190610ed5565b610f14610c48565b610f03565b356103dd816103f1565b356103dd81610431565b903590601e193682900301821215610f73575b01602081359167ffffffffffffffff8311610f66575b0191602082023603831361048957565b610f6e6103a0565b610f56565b610f7b6103a0565b610f40565b9091908291600090610f9182610546565b84146110235760005b845b81101561101b576110148161100e86808a611006610ffc86610ff56040610fdd838f610fef610f9c9f610fe9818c610fe38f96610fdd60209684809a610ef3565b01610f19565b9e610ef3565b01610f23565b9a610ef3565b938d610ef3565b6060810190610f2d565b939092611583565b60010190565b9050610f9a565b509350505050565b505050505061103160405190565b631ec5aa5160e01b8152600490fd5b906103c791610ea9565b1561105157565b5060405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b6044820152606490fd5b6103c7611098610945610b6f565b61104a565b6103dd6002610546565b156110ae57565b5060405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606490fd5b9060001990610a7b565b9061110e6103dd610a9c92610546565b82546110f4565b6103c7611122600161057d565b61113661112d61109d565b918214156110a7565b60016110fe565b6103dd6001610546565b6103c761113661113d565b906103c7916111626107ca610606565b6111eb565b9160809181101561117757020190565b61117f610c48565b020190565b9061110e6103dd610a9c9290565b6104256103dd6103dd9290565b6103dd90611192565b906001600160a01b0390610a7b565b906111c76103dd610a9c926106fa565b82546111a8565b9081526060810193926103c7929091604091610602906020830152565b91816000936111f985610546565b841461135d5761120d42610d3e600561057d565b9260005b855b81101561135457611225818585611167565b80880191600361123484610f19565b61123e9082610566565b8a604085019161124d83610f19565b61125a9060018301611184565b8a606087019461126986610f19565b6112769060028501611184565b820190611282916110fe565b019361129585546001600160a01b031690565b61129e8d61119f565b6001600160a01b0316906001600160a01b0316146112db6112db60206112d46112139a6113329a6112e196611339575b50610f19565b9401610f23565b93610f19565b61131261130c7f1d0b6716ec306cca1346fdec2c918d00831bd1239f2d28acf62e94f2373355fc9390565b936106fa565b936113298c61132060405190565b938493846111ce565b0390a360010190565b9050611211565b61134e90611348858a01610f23565b906111b7565b386112ce565b50945050505050565b505050505061136b60405190565b630d16b83360e31b8152600490fd5b906103c791611152565b6103c7906113936107ca610606565b156113a0576103c7611413565b6103c7611461565b6103c790611384565b6113b961108a565b6103c76113c860016002610a85565b3361140e7f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258916113f760405190565b918291826001600160a01b03909116815260200190565b0390a1565b6103c76113b1565b6114236114ad565b6103c761143260006002610a85565b3361140e7f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa916113f760405190565b6103c761141b565b1561147057565b5060405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b6044820152606490fd5b6103c76114b8610b6f565b611469565b6103c7906114cc6107ca610606565b6103c790611b27565b6103c7906114bd565b6103dd6080610bce565b906103c761154760036114f96114de565b9461151b61150e82546001600160a01b031690565b6001600160a01b03168752565b61153161152a6001830161057d565b6020880152565b6107b36115406002830161057d565b6040880152565b6060840152565b6103dd906114e8565b6103ed906001600160a01b031660601b90565b60148161157d6107f79360209695611557565b01918252565b919392909261159b611596846003610566565b61154e565b9060208201906115a9825190565b936000946115b9610b9687610546565b146116fd57606084015142106116dc576109456116329187936115fb6115f68c6115f16115ec8e61072260049b8c610566565b61057d565b610bba565b965190565b9061160560405190565b611619818d61099d8b60208401928361156a565b61162b611624825190565b9160200190565b2092611a74565b6116b55761166093929161164d876107228861165295610566565b6110fe565b01516001600160a01b031690565b90611674848461166f856106fa565b611761565b610b136116ab6116a56116a57f5eb306c17229e0da0cbf33aae2020ca276e63db4818b8060786e49ae516231109490565b946106fa565b946100f360405190565b955050505050506109c291506116ca60405190565b6309bde33960e01b8152918291820190565b5050505050505050506116ee60405190565b630995309b60e01b8152600490fd5b50505050505050505061170f60405190565b639dd854d360e01b8152600490fd5b6117376117316103dd9263ffffffff1690565b60e01b90565b6001600160e01b03191690565b6001600160a01b0390911681526040810192916103c79160200152565b6117a46004926117956103c79561177b63a9059cbb61171e565b9261178560405190565b9687946020860190815201611744565b602082018103825203836108cd565b611872565b6117b36020610c09565b7f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564602082015290565b6103dd6117a9565b905051906103c782610618565b906103dd91602081830312611805576117e4565b61180d6103a0565b6117e4565b1561181957565b5060405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608490fd5b6103c791611882611891926106fa565b9061188b6117dc565b916118cf565b80516118a0610b966000610546565b149081156118af575b50611812565b6118c9915060206118be825190565b8183010191016117f1565b386118a9565b6103dd92916118de6000610546565b9161195f565b156118eb57565b5060405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608490fd5b3d1561195a5761194f3d610c09565b903d6000602084013e565b606090565b9060006103dd94938192611971606090565b5061198861197e306106fa565b83903110156118e4565b60208101905191855af161199a611940565b916119ed565b156119a757565b5060405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606490fd5b919260609115611a225750508151611a08610b966000610546565b14611a11575090565b611a1d6103dd91611a2f565b6119a0565b9093926103c79250611a41565b3b611a3d610b966000610546565b1190565b9150611a4b825190565b611a58610b966000610546565b1115611a675750805190602001fd5b6040516109c292506109ad565b610ea59293610b9692611a8f92611a89600090565b50611ab3565b9290565b6001906000198114610bc6570190565b9160209181101561117757020190565b611abd6000610546565b925b82841015611af357611ae7611aed91611ae1611adc878787611aa3565b610f19565b90611afa565b93611a93565b92611abf565b9250505090565b81811015611b1557906103dd91600052602052604060002090565b6103dd91600052602052604060002090565b611b326103dd610553565b8110611b7157611b438160056110fe565b61140e7f676dc704f22ddab12a141690a96616ef0128413803c63394aba7ffe658681a16916100f360405190565b50506040516367e00a0760e01b8152600490fdfea364697066735822122008f93cb8422fcd0189a91dc221cfb274c380a4fee6363f191b6fd7c4c3ca762b6c6578706572696d656e74616cf564736f6c634300080c0041

Deployed Bytecode

0x60806040526004361015610018575b6100166103a0565b005b60003560e01c806301ffc9a714610376578063248a9ca31461034c5780632f2ff15d1461032457806333f642f6146102fa57806336568abe146102d257806356853398146102aa5780635c975abb146102805780637fdba5f61461025657806391d1485414610219578063938d967a146101d9578063960d264d146101b2578063a217fddf14610188578063cdb88ad114610161578063d547741f14610139578063df45c752146101115763dfcae622146100d25761000e565b34610104575b6101006100ef6100e936600461044d565b9061070d565b6040515b9182918290815260200190565b0390f35b61010c6103a0565b6100d8565b503461012c575b61001661012636600461069a565b9061137a565b6101346103a0565b610118565b5034610154575b61001661014e36600461044d565b906109e1565b61015c6103a0565b610140565b503461017b575b61001661017636600461062d565b6113a8565b6101836103a0565b610168565b50346101a5575b61019a36600461047e565b6101006100ef610610565b6101ad6103a0565b61018f565b50346101cc575b6100166101c7366004610404565b6114d5565b6101d46103a0565b6101b9565b503461020c575b6101006101f66101f1366004610404565b610587565b9061020394929460405190565b948594856105ca565b6102146103a0565b6101e0565b5034610249575b61010061023761023136600461044d565b9061077b565b60405191829182901515815260200190565b6102516103a0565b610220565b5034610273575b61026836600461047e565b6101006100ef61055e565b61027b6103a0565b61025d565b503461029d575b61029236600461047e565b610100610237610b6f565b6102a56103a0565b610287565b50346102c5575b6100166102bf3660046104ff565b90611040565b6102cd6103a0565b6102b1565b50346102ed575b6100166102e736600461044d565b90610a50565b6102f56103a0565b6102d9565b5034610317575b61030c36600461047e565b6101006100ef6104a7565b61031f6103a0565b610301565b503461033f575b61001661033936600461044d565b906107d9565b6103476103a0565b61032b565b5034610369575b6101006100ef610364366004610404565b61079a565b6103716103a0565b610353565b5034610393575b61010061023761038e3660046103c9565b61072c565b61039b6103a0565b61037d565b50600080fd5b6001600160e01b031981165b14156103a057565b905035906103c7826103a6565b565b906103dd916020818303126103e0576103ba565b90565b6103e86103a0565b6103ba565b9052565b806103b2565b905035906103c7826103f1565b906103dd91602081830312610418576103f7565b6104206103a0565b6103f7565b6001600160a01b031690565b6001600160a01b0381166103b2565b905035906103c782610431565b91906103dd90604084820312610471575b61046881856103f7565b93602001610440565b6104796103a0565b61045e565b600091031261048957565b6103c76103a0565b6103dd916008021c81565b906103dd9154610491565b6103dd6000600561049c565b909182601f830112156104f2575b602082359267ffffffffffffffff84116104e5575b01926020830284011161048957565b6104ed6103a0565b6104d6565b6104fa6103a0565b6104c1565b9061052891602081830312610539575b80359067ffffffffffffffff821161052c575b016104b3565b9091565b6105346103a0565b610522565b6105416103a0565b61050f565b6103dd6103dd6103dd9290565b6103dd612a30610546565b6103dd610553565b905b600052602052604060002090565b6103dd9081565b6103dd9054610576565b610592906003610566565b906105a482546001600160a01b031690565b916105b16001820161057d565b916103dd60036105c36002850161057d565b930161057d565b6106026103c7946105fb6060949897956105f4608086019a60008701906001600160a01b03169052565b6020850152565b6040830152565b0152565b6103dd6000610546565b6103dd610606565b8015156103b2565b905035906103c782610618565b906103dd9160208183031261064157610620565b6106496103a0565b610620565b909182601f8301121561068d575b602082359267ffffffffffffffff8411610680575b01926080830284011161048957565b6106886103a0565b610671565b6106956103a0565b61065c565b90610528916020818303126106d0575b80359067ffffffffffffffff82116106c3575b0161064e565b6106cb6103a0565b6106bd565b6106d86103a0565b6106aa565b6103dd90610425906001600160a01b031682565b6103dd906106dd565b6103dd906106f1565b90610568906106fa565b6107276103dd92610722600493600094610566565b610703565b61049c565b637965db0b60e01b6001600160e01b031982161490811561074b575090565b6103dd91506001600160e01b0319166301ffc9a760e01b1490565b6103dd905b60ff1690565b6103dd9054610766565b6103dd916107959161078f60009182610566565b01610703565b610771565b60016107b36103dd926107ab600090565b506000610566565b0161057d565b906103c7916107cf6107ca8261079a565b6107e3565b906103c791610aa0565b906103c7916107b9565b6103c7903390610937565b6103dd90610546565b0190565b918091926000905b82821061081b575011610814575050565b6000910152565b91508060209183015181860152018291610803565b6107f761084892602092610842815190565b94859290565b938491016107fb565b61088f6103dd9392610889610889937f416363657373436f6e74726f6c3a206163636f756e7420000000000000000000815260170190565b90610830565b7001034b99036b4b9b9b4b733903937b6329607d1b815260110190565b601f01601f191690565b50634e487b7160e01b600052604160045260246000fd5b90601f01601f1916810190811067ffffffffffffffff8211176108ef57604052565b6108f76108b6565b604052565b61091d6108ac6020936107f793610911815190565b80835293849260200190565b958691016107fb565b60208082526103dd929101906108fc565b90610949610945828461077b565b1590565b610951575050565b6109c29250906103dd61096f6109696109a994610e78565b926107ee565b61098460209161097e83610546565b90610d18565b9261099d61099160405190565b94859384019283610851565b908103825203826108cd565b6040515b62461bcd60e51b815291829160048301610926565b0390fd5b906103c7916109d76107ca8261079a565b906103c791610b18565b906103c7916109c6565b156109f257565b5060405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b6064820152608490fd5b6103c79190610a71610a6133610425565b6001600160a01b038416146109eb565b610b18565b9060ff905b9181191691161790565b90610a956103dd610a9c92151590565b8254610a76565b9055565b90610aae610945828461077b565b610ab6575050565b610ad06001610acb83600061078f8782610566565b610a85565b3390610b06610b00610b007f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d9590565b926106fa565b92610b1060405190565b80805b0390a4565b90610b23818361077b565b610b2b575050565b610b3f6000610acb838261078f8782610566565b3390610b06610b00610b007ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9590565b6103dd6002610771565b50634e487b7160e01b600052601160045260246000fd5b90610b9a565b9190565b908060001904821181151516610bae570290565b610bb6610b79565b0290565b81198111610bc6570190565b6107f7610b79565b906103c7610bdb60405190565b92836108cd565b6107f760209167ffffffffffffffff8111610c0157601f01601f191690565b6108ac6108b6565b90610c1b610c1683610be2565b610bce565b918252565b369037565b906103c7610c3b610c3584610c09565b93610be2565b601f190160208401610c20565b50634e487b7160e01b600052603260045260246000fd5b906001602091610c6d845190565b811015610c7b575b02010190565b610c83610c48565b610c75565b6001908015610c95570390565b610c9d610b79565b0390565b61076b6103dd6103dd9290565b6103dd90610cc2610b966103dd9460ff1690565b901c90565b15610cce57565b5060405162461bcd60e51b8152806109c2600482016020808252818101527f537472696e67733a20686578206c656e67746820696e73756666696369656e74604082015260600190565b9190600290610d49610d44610d3583610d3086610546565b610b90565b610d3e85610546565b90610bba565b610c25565b916000916030610d61610d5b85610546565b86610c5f565b53610d99610d90600f60fb1b92610d306001958695881a610d8a610d8488610546565b8b610c5f565b53610546565b610d3e83610546565b915b610dbc575b50506103dd9293610db6610b966103dd93610546565b14610cc7565b9094610dc782610546565b861115610e4657610e33610e2d8392610e10610df36f181899199a1a9b1b9c1cb0b131b232b360811b90565b610dfd600f610546565b83166010811015610e39575b1a60f81b90565b861a610e1c8a89610c5f565b53610e276004610ca1565b90610cae565b96610c88565b91610d9b565b610e41610c48565b610e09565b94610da0565b6103dd9081906001600160a01b031681565b6103dd6014610ca1565b6103dd6103dd6103dd9260ff1690565b610e95610e906103dd92610e8a606090565b506106f1565b610e4c565b61097e610ea0610e5e565b610e68565b1490565b90610ebb91610eb6611115565b610ec3565b6103c7611147565b906103c791610ed061108a565b610f80565b903590607e193682900301821215610eeb570190565b6107f76103a0565b906103dd92602091811015610f0c575b02810190610ed5565b610f14610c48565b610f03565b356103dd816103f1565b356103dd81610431565b903590601e193682900301821215610f73575b01602081359167ffffffffffffffff8311610f66575b0191602082023603831361048957565b610f6e6103a0565b610f56565b610f7b6103a0565b610f40565b9091908291600090610f9182610546565b84146110235760005b845b81101561101b576110148161100e86808a611006610ffc86610ff56040610fdd838f610fef610f9c9f610fe9818c610fe38f96610fdd60209684809a610ef3565b01610f19565b9e610ef3565b01610f23565b9a610ef3565b938d610ef3565b6060810190610f2d565b939092611583565b60010190565b9050610f9a565b509350505050565b505050505061103160405190565b631ec5aa5160e01b8152600490fd5b906103c791610ea9565b1561105157565b5060405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b6044820152606490fd5b6103c7611098610945610b6f565b61104a565b6103dd6002610546565b156110ae57565b5060405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606490fd5b9060001990610a7b565b9061110e6103dd610a9c92610546565b82546110f4565b6103c7611122600161057d565b61113661112d61109d565b918214156110a7565b60016110fe565b6103dd6001610546565b6103c761113661113d565b906103c7916111626107ca610606565b6111eb565b9160809181101561117757020190565b61117f610c48565b020190565b9061110e6103dd610a9c9290565b6104256103dd6103dd9290565b6103dd90611192565b906001600160a01b0390610a7b565b906111c76103dd610a9c926106fa565b82546111a8565b9081526060810193926103c7929091604091610602906020830152565b91816000936111f985610546565b841461135d5761120d42610d3e600561057d565b9260005b855b81101561135457611225818585611167565b80880191600361123484610f19565b61123e9082610566565b8a604085019161124d83610f19565b61125a9060018301611184565b8a606087019461126986610f19565b6112769060028501611184565b820190611282916110fe565b019361129585546001600160a01b031690565b61129e8d61119f565b6001600160a01b0316906001600160a01b0316146112db6112db60206112d46112139a6113329a6112e196611339575b50610f19565b9401610f23565b93610f19565b61131261130c7f1d0b6716ec306cca1346fdec2c918d00831bd1239f2d28acf62e94f2373355fc9390565b936106fa565b936113298c61132060405190565b938493846111ce565b0390a360010190565b9050611211565b61134e90611348858a01610f23565b906111b7565b386112ce565b50945050505050565b505050505061136b60405190565b630d16b83360e31b8152600490fd5b906103c791611152565b6103c7906113936107ca610606565b156113a0576103c7611413565b6103c7611461565b6103c790611384565b6113b961108a565b6103c76113c860016002610a85565b3361140e7f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258916113f760405190565b918291826001600160a01b03909116815260200190565b0390a1565b6103c76113b1565b6114236114ad565b6103c761143260006002610a85565b3361140e7f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa916113f760405190565b6103c761141b565b1561147057565b5060405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b6044820152606490fd5b6103c76114b8610b6f565b611469565b6103c7906114cc6107ca610606565b6103c790611b27565b6103c7906114bd565b6103dd6080610bce565b906103c761154760036114f96114de565b9461151b61150e82546001600160a01b031690565b6001600160a01b03168752565b61153161152a6001830161057d565b6020880152565b6107b36115406002830161057d565b6040880152565b6060840152565b6103dd906114e8565b6103ed906001600160a01b031660601b90565b60148161157d6107f79360209695611557565b01918252565b919392909261159b611596846003610566565b61154e565b9060208201906115a9825190565b936000946115b9610b9687610546565b146116fd57606084015142106116dc576109456116329187936115fb6115f68c6115f16115ec8e61072260049b8c610566565b61057d565b610bba565b965190565b9061160560405190565b611619818d61099d8b60208401928361156a565b61162b611624825190565b9160200190565b2092611a74565b6116b55761166093929161164d876107228861165295610566565b6110fe565b01516001600160a01b031690565b90611674848461166f856106fa565b611761565b610b136116ab6116a56116a57f5eb306c17229e0da0cbf33aae2020ca276e63db4818b8060786e49ae516231109490565b946106fa565b946100f360405190565b955050505050506109c291506116ca60405190565b6309bde33960e01b8152918291820190565b5050505050505050506116ee60405190565b630995309b60e01b8152600490fd5b50505050505050505061170f60405190565b639dd854d360e01b8152600490fd5b6117376117316103dd9263ffffffff1690565b60e01b90565b6001600160e01b03191690565b6001600160a01b0390911681526040810192916103c79160200152565b6117a46004926117956103c79561177b63a9059cbb61171e565b9261178560405190565b9687946020860190815201611744565b602082018103825203836108cd565b611872565b6117b36020610c09565b7f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564602082015290565b6103dd6117a9565b905051906103c782610618565b906103dd91602081830312611805576117e4565b61180d6103a0565b6117e4565b1561181957565b5060405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608490fd5b6103c791611882611891926106fa565b9061188b6117dc565b916118cf565b80516118a0610b966000610546565b149081156118af575b50611812565b6118c9915060206118be825190565b8183010191016117f1565b386118a9565b6103dd92916118de6000610546565b9161195f565b156118eb57565b5060405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608490fd5b3d1561195a5761194f3d610c09565b903d6000602084013e565b606090565b9060006103dd94938192611971606090565b5061198861197e306106fa565b83903110156118e4565b60208101905191855af161199a611940565b916119ed565b156119a757565b5060405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606490fd5b919260609115611a225750508151611a08610b966000610546565b14611a11575090565b611a1d6103dd91611a2f565b6119a0565b9093926103c79250611a41565b3b611a3d610b966000610546565b1190565b9150611a4b825190565b611a58610b966000610546565b1115611a675750805190602001fd5b6040516109c292506109ad565b610ea59293610b9692611a8f92611a89600090565b50611ab3565b9290565b6001906000198114610bc6570190565b9160209181101561117757020190565b611abd6000610546565b925b82841015611af357611ae7611aed91611ae1611adc878787611aa3565b610f19565b90611afa565b93611a93565b92611abf565b9250505090565b81811015611b1557906103dd91600052602052604060002090565b6103dd91600052602052604060002090565b611b326103dd610553565b8110611b7157611b438160056110fe565b61140e7f676dc704f22ddab12a141690a96616ef0128413803c63394aba7ffe658681a16916100f360405190565b50506040516367e00a0760e01b8152600490fdfea364697066735822122008f93cb8422fcd0189a91dc221cfb274c380a4fee6363f191b6fd7c4c3ca762b6c6578706572696d656e74616cf564736f6c634300080c0041

Block Transaction 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
[ Download: CSV Export  ]

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.