ETH Price: $3,106.58 (+1.46%)
Gas: 5 Gwei

Contract

0x333762311D3918d8B9CB23ec1b02aBD176353333
 

Overview

ETH Balance

0 ETH

Eth Value

$0.00

Multichain Info

Transaction Hash
Method
Block
From
To
Value
Instant Trade162607802022-12-25 9:10:59562 days ago1671959459IN
0x33376231...176353333
0.00084599 ETH0.0030511812.51463819
Instant Trade162594532022-12-25 4:43:59563 days ago1671943439IN
0x33376231...176353333
0.00084599 ETH0.0026542910.39200851
Instant Trade162573292022-12-24 21:37:59563 days ago1671917879IN
0x33376231...176353333
0.00084599 ETH0.0025155311.21409515
Instant Trade Na...162572562022-12-24 21:23:23563 days ago1671917003IN
0x33376231...176353333
0.00184599 ETH0.0017586510.62977742
Instant Trade Na...162572562022-12-24 21:23:23563 days ago1671917003IN
0x33376231...176353333
0.00184599 ETH0.001848119.5704755
Instant Trade162561982022-12-24 17:50:23563 days ago1671904223IN
0x33376231...176353333
0.00084599 ETH0.0033431212.12404369
Instant Trade Na...162535902022-12-24 9:06:35563 days ago1671872795IN
0x33376231...176353333
0.02184599 ETH0.0021056211.86556998
Instant Trade162532762022-12-24 8:03:35563 days ago1671869015IN
0x33376231...176353333
0.00084599 ETH0.0030845513.00813634
Instant Trade Na...162531962022-12-24 7:47:35563 days ago1671868055IN
0x33376231...176353333
0.08084599 ETH0.0021655211.50080607
Instant Trade162527422022-12-24 6:16:23564 days ago1671862583IN
0x33376231...176353333
0.00084599 ETH0.0035936311.13951666
Instant Trade Na...162527372022-12-24 6:15:23564 days ago1671862523IN
0x33376231...176353333
0.02884599 ETH0.0018390110.37810469
Instant Trade Na...162526382022-12-24 5:55:35564 days ago1671861335IN
0x33376231...176353333
0.75084599 ETH0.003620812.39731697
Instant Trade Na...162525562022-12-24 5:38:59564 days ago1671860339IN
0x33376231...176353333
0.03584599 ETH0.0019831711.03713909
Instant Trade162519192022-12-24 3:30:11564 days ago1671852611IN
0x33376231...176353333
0.00084599 ETH0.0027901812.41093235
Instant Trade162518482022-12-24 3:15:59564 days ago1671851759IN
0x33376231...176353333
0.00084599 ETH0.0043023711.4785604
Instant Trade162518202022-12-24 3:10:23564 days ago1671851423IN
0x33376231...176353333
0.00084599 ETH0.0057332112.20319353
Instant Trade162517682022-12-24 2:59:59564 days ago1671850799IN
0x33376231...176353333
0.00084599 ETH0.004109111.41865944
Instant Trade162516972022-12-24 2:45:47564 days ago1671849947IN
0x33376231...176353333
0.00084599 ETH0.0032197513.23715276
Instant Trade162514082022-12-24 1:47:47564 days ago1671846467IN
0x33376231...176353333
0.00084599 ETH0.0032594210.47277461
Instant Trade162483972022-12-23 15:44:23564 days ago1671810263IN
0x33376231...176353333
0.00084599 ETH0.0046336413.53805869
Instant Trade Na...162479752022-12-23 14:19:35564 days ago1671805175IN
0x33376231...176353333
0.86113915 ETH0.0020443513.74652328
Instant Trade162463212022-12-23 8:47:47564 days ago1671785267IN
0x33376231...176353333
0.00084599 ETH0.002741513.82517015
Instant Trade Na...162462422022-12-23 8:31:59564 days ago1671784319IN
0x33376231...176353333
0.01367916 ETH0.002912712.81869765
Instant Trade162458002022-12-23 7:03:35565 days ago1671779015IN
0x33376231...176353333
0.00084599 ETH0.0029636212.45723921
Instant Trade162453222022-12-23 5:27:59565 days ago1671773279IN
0x33376231...176353333
0.00084599 ETH0.0027998910.97428301
View all transactions

Latest 25 internal transactions (View All)

Advanced mode:
Parent Transaction Hash Block From To Value
167415952023-03-02 14:53:47495 days ago1677768827
0x33376231...176353333
0.10496743 ETH
162572562022-12-24 21:23:23563 days ago1671917003
0x33376231...176353333
0.001 ETH
162572562022-12-24 21:23:23563 days ago1671917003
0x33376231...176353333
0.001 ETH
162535902022-12-24 9:06:35563 days ago1671872795
0x33376231...176353333
0.021 ETH
162531962022-12-24 7:47:35563 days ago1671868055
0x33376231...176353333
0.08 ETH
162527372022-12-24 6:15:23564 days ago1671862523
0x33376231...176353333
0.028 ETH
162526382022-12-24 5:55:35564 days ago1671861335
0x33376231...176353333
0.75 ETH
162525562022-12-24 5:38:59564 days ago1671860339
0x33376231...176353333
0.035 ETH
162479752022-12-23 14:19:35564 days ago1671805175
0x33376231...176353333
0.86029316 ETH
162462422022-12-23 8:31:59564 days ago1671784319
0x33376231...176353333
0.01283317 ETH
162433252022-12-22 22:46:47565 days ago1671749207
0x33376231...176353333
0.008 ETH
162432292022-12-22 22:27:35565 days ago1671748055
0x33376231...176353333
0.03759226 ETH
162419722022-12-22 18:15:47565 days ago1671732947
0x33376231...176353333
0.15133866 ETH
162414642022-12-22 16:33:35565 days ago1671726815
0x33376231...176353333
0.9 ETH
162402722022-12-22 12:34:11565 days ago1671712451
0x33376231...176353333
0.15 ETH
162401882022-12-22 12:17:23565 days ago1671711443
0x33376231...176353333
1.5 ETH
162399812022-12-22 11:35:23565 days ago1671708923
0x33376231...176353333
0.07 ETH
162394712022-12-22 9:53:11565 days ago1671702791
0x33376231...176353333
0.004 ETH
162394582022-12-22 9:50:35565 days ago1671702635
0x33376231...176353333
0.001 ETH
162394472022-12-22 9:48:23565 days ago1671702503
0x33376231...176353333
0.163 ETH
162366022022-12-22 0:17:47566 days ago1671668267
0x33376231...176353333
0.41 ETH
162346012022-12-21 17:34:47566 days ago1671644087
0x33376231...176353333
0.02 ETH
162331752022-12-21 12:48:11566 days ago1671626891
0x33376231...176353333
0.02 ETH
162331722022-12-21 12:47:35566 days ago1671626855
0x33376231...176353333
0.02 ETH
162329422022-12-21 12:01:23566 days ago1671624083
0x33376231...176353333
0.035 ETH
View All Internal Transactions
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
InstantProxy

Compiler Version
v0.8.15+commit.e14f2714

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion
File 1 of 20 : InstantTradesProxy.sol
pragma solidity >0.8.0;

import '@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol';
import '@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol';
import '@openzeppelin/contracts-upgradeable/utils/structs/EnumerableSetUpgradeable.sol';
import 'rubic-bridge-base/contracts/errors/Errors.sol';
import 'rubic-bridge-base/contracts/BridgeBase.sol';
import 'rubic-whitelist-contract/contracts/interfaces/IRubicWhitelist.sol';

error DexNotAvailable();
error DifferentAmountSpent();
error TooFewReceived();
error ZeroToken();
error NotANativeToken();

contract InstantProxy is BridgeBase {
    using EnumerableSetUpgradeable for EnumerableSetUpgradeable.AddressSet;
    using SafeERC20Upgradeable for IERC20Upgradeable;

    IRubicWhitelist public whitelistRegistry;

    struct InstantTradesParams {
        address inputToken;
        uint256 inputAmount;
        address outputToken;
        uint256 minOutputAmount;
        address recipient;
        address integrator;
        address dex;
    }

    event DexSwap(InstantTradesParams parameters);

    modifier onlyAvailableDex(address _dex) {
        checkDex(_dex);
        _;
    }

    function checkDex(address _dex) private view {
        if (!whitelistRegistry.isWhitelistedDEX(_dex)) revert DexNotAvailable();
    }

    constructor(
        uint256 _fixedCryptoFee,
        uint256 _RubicPlatformFee,
        address[] memory _tokens,
        uint256[] memory _minTokenAmounts,
        uint256[] memory _maxTokenAmounts,
        address _admin,
        IRubicWhitelist _whitelistRegistry
    ) {
        if (address(_whitelistRegistry) == address(0)) {
            revert ZeroAddress();
        }

        whitelistRegistry = _whitelistRegistry;

        initialize(_fixedCryptoFee, _RubicPlatformFee, _tokens, _minTokenAmounts, _maxTokenAmounts, _admin);
    }

    function initialize(
        uint256 _fixedCryptoFee,
        uint256 _RubicPlatformFee,
        address[] memory _tokens,
        uint256[] memory _minTokenAmounts,
        uint256[] memory _maxTokenAmounts,
        address _admin
    ) private initializer {
        __BridgeBaseInit(_fixedCryptoFee, _RubicPlatformFee, _tokens, _minTokenAmounts, _maxTokenAmounts, _admin);
    }

    // MAIN FUNCTIONALITY //

    /**
     * @dev Performs an instant trade from users ERC-20 tokens
     * @param _params Info about the trade
     * @param _data The data passed to the DEX
     */
    function instantTrade(
        InstantTradesParams memory _params,
        bytes calldata _data
    ) external payable nonReentrant whenNotPaused onlyAvailableDex(_params.dex) {
        _params.inputAmount = _receiveTokens(_params.inputToken, _params.inputAmount);

        IntegratorFeeInfo memory _info = integratorToFeeInfo[_params.integrator];

        _params.inputAmount = accrueTokenFees(_params.integrator, _info, _params.inputAmount, 0, _params.inputToken);

        accrueFixedCryptoFee(_params.integrator, _info);

        _callDexWithChecksTokenInput(_params, _data);

        emit DexSwap(_params);
    }

    /**
     * @dev Performs an instant trade from users native tokens
     * @param _params Info about the trade
     * @param _data The data passed to the DEX
     */
    function instantTradeNative(
        InstantTradesParams memory _params,
        bytes calldata _data
    ) external payable nonReentrant whenNotPaused onlyAvailableDex(_params.dex) {
        if (_params.inputToken != address(0)) revert NotANativeToken();

        IntegratorFeeInfo memory _info = integratorToFeeInfo[_params.integrator];

        _params.inputAmount = accrueTokenFees(
            _params.integrator,
            _info,
            accrueFixedCryptoFee(_params.integrator, _info),
            0,
            _params.inputToken
        );

        _callDexWithChecksNativeInput(_params, _data);

        emit DexSwap(_params);
    }

    function _callDexWithChecksNativeInput(InstantTradesParams memory _params, bytes calldata _data) private {
        uint256 balanceOutBefore = _getBalance(_params.recipient, _params.outputToken);

        AddressUpgradeable.functionCallWithValue(_params.dex, _data, _params.inputAmount);

        uint256 balanceOutAfter = _getBalance(_params.recipient, _params.outputToken);

        if (balanceOutAfter - balanceOutBefore < _params.minOutputAmount) revert TooFewReceived();
    }

    function _callDexWithChecksTokenInput(InstantTradesParams memory _params, bytes calldata _data) private {
        IERC20Upgradeable(_params.inputToken).safeApprove(_params.dex, _params.inputAmount);

        uint256 balanceOutBefore = _getBalance(_params.recipient, _params.outputToken);
        uint256 balanceInBefore = IERC20Upgradeable(_params.inputToken).balanceOf(address(this));

        AddressUpgradeable.functionCall(_params.dex, _data);

        uint256 balanceOutAfter = _getBalance(_params.recipient, _params.outputToken);
        uint256 balanceInAfter = IERC20Upgradeable(_params.inputToken).balanceOf(address(this));

        if (balanceInBefore - balanceInAfter != _params.inputAmount) revert DifferentAmountSpent();
        if (balanceOutAfter - balanceOutBefore < _params.minOutputAmount) revert TooFewReceived();
    }

    function _receiveTokens(address _tokenIn, uint256 _amountIn) private returns (uint256) {
        if (_tokenIn == address(0)) revert ZeroToken();

        uint256 balanceBeforeTransfer = IERC20Upgradeable(_tokenIn).balanceOf(address(this));

        IERC20Upgradeable(_tokenIn).safeTransferFrom(msg.sender, address(this), _amountIn);

        uint256 balanceAfterTransfer = IERC20Upgradeable(_tokenIn).balanceOf(address(this));

        _amountIn = balanceAfterTransfer - balanceBeforeTransfer;

        return _amountIn;
    }

    function _getBalance(address _wallet, address _token) private view returns (uint256) {
        return _token == address(0) ? address(_wallet).balance : IERC20Upgradeable(_token).balanceOf(_wallet);
    }

    // MANAGEMENT FUNCTIONS //

    /**
     * @dev Sets the address of a new whitelist registry contract
     * @param _newWhitelistRegistry The address of the registry
     */
    function setWhitelistRegistry(IRubicWhitelist _newWhitelistRegistry) external onlyAdmin {
        if (address(_newWhitelistRegistry) == address(0)) {
            revert ZeroAddress();
        }

        whitelistRegistry = _newWhitelistRegistry;
    }
}

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

pragma solidity ^0.8.0;

import "./IAccessControlUpgradeable.sol";
import "../utils/ContextUpgradeable.sol";
import "../utils/StringsUpgradeable.sol";
import "../utils/introspection/ERC165Upgradeable.sol";
import "../proxy/utils/Initializable.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:
 *
 * ```
 * 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}:
 *
 * ```
 * 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.
 */
abstract contract AccessControlUpgradeable is Initializable, ContextUpgradeable, IAccessControlUpgradeable, ERC165Upgradeable {
    function __AccessControl_init() internal onlyInitializing {
    }

    function __AccessControl_init_unchained() internal onlyInitializing {
    }
    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(IAccessControlUpgradeable).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 ",
                        StringsUpgradeable.toHexString(account),
                        " is missing role ",
                        StringsUpgradeable.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());
        }
    }

    /**
     * @dev This empty reserved space is put in place to allow future versions to add new
     * variables without shifting down storage in the inheritance chain.
     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
     */
    uint256[49] private __gap;
}

File 3 of 20 : IAccessControlUpgradeable.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 IAccessControlUpgradeable {
    /**
     * @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 20 : Initializable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (proxy/utils/Initializable.sol)

pragma solidity ^0.8.2;

import "../../utils/AddressUpgradeable.sol";

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

    /**
     * @dev Indicates that the contract is in the process of being initialized.
     */
    bool private _initializing;

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

    /**
     * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,
     * `onlyInitializing` functions can be used to initialize parent contracts.
     *
     * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a
     * constructor.
     *
     * Emits an {Initialized} event.
     */
    modifier initializer() {
        bool isTopLevelCall = !_initializing;
        require(
            (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),
            "Initializable: contract is already initialized"
        );
        _initialized = 1;
        if (isTopLevelCall) {
            _initializing = true;
        }
        _;
        if (isTopLevelCall) {
            _initializing = false;
            emit Initialized(1);
        }
    }

    /**
     * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the
     * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be
     * used to initialize parent contracts.
     *
     * A reinitializer may be used after the original initialization step. This is essential to configure modules that
     * are added through upgrades and that require initialization.
     *
     * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`
     * cannot be nested. If one is invoked in the context of another, execution will revert.
     *
     * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in
     * a contract, executing them in the right order is up to the developer or operator.
     *
     * WARNING: setting the version to 255 will prevent any future reinitialization.
     *
     * Emits an {Initialized} event.
     */
    modifier reinitializer(uint8 version) {
        require(!_initializing && _initialized < version, "Initializable: contract is already initialized");
        _initialized = version;
        _initializing = true;
        _;
        _initializing = false;
        emit Initialized(version);
    }

    /**
     * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the
     * {initializer} and {reinitializer} modifiers, directly or indirectly.
     */
    modifier onlyInitializing() {
        require(_initializing, "Initializable: contract is not initializing");
        _;
    }

    /**
     * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.
     * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized
     * to any version. It is recommended to use this to lock implementation contracts that are designed to be called
     * through proxies.
     *
     * Emits an {Initialized} event the first time it is successfully executed.
     */
    function _disableInitializers() internal virtual {
        require(!_initializing, "Initializable: contract is initializing");
        if (_initialized < type(uint8).max) {
            _initialized = type(uint8).max;
            emit Initialized(type(uint8).max);
        }
    }

    /**
     * @dev Internal function that returns the initialized version. Returns `_initialized`
     */
    function _getInitializedVersion() internal view returns (uint8) {
        return _initialized;
    }

    /**
     * @dev Internal function that returns the initialized version. Returns `_initializing`
     */
    function _isInitializing() internal view returns (bool) {
        return _initializing;
    }
}

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

pragma solidity ^0.8.0;

import "../utils/ContextUpgradeable.sol";
import "../proxy/utils/Initializable.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 PausableUpgradeable is Initializable, ContextUpgradeable {
    /**
     * @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.
     */
    function __Pausable_init() internal onlyInitializing {
        __Pausable_init_unchained();
    }

    function __Pausable_init_unchained() internal onlyInitializing {
        _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());
    }

    /**
     * @dev This empty reserved space is put in place to allow future versions to add new
     * variables without shifting down storage in the inheritance chain.
     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
     */
    uint256[49] private __gap;
}

File 6 of 20 : ReentrancyGuardUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (security/ReentrancyGuard.sol)

pragma solidity ^0.8.0;
import "../proxy/utils/Initializable.sol";

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

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

    uint256 private _status;

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

    function __ReentrancyGuard_init_unchained() internal onlyInitializing {
        _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 This empty reserved space is put in place to allow future versions to add new
     * variables without shifting down storage in the inheritance chain.
     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
     */
    uint256[49] private __gap;
}

File 7 of 20 : draft-IERC20PermitUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-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.
 */
interface IERC20PermitUpgradeable {
    /**
     * @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].
     */
    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 8 of 20 : IERC20Upgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
interface IERC20Upgradeable {
    /**
     * @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 9 of 20 : SafeERC20Upgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/utils/SafeERC20.sol)

pragma solidity ^0.8.0;

import "../IERC20Upgradeable.sol";
import "../extensions/draft-IERC20PermitUpgradeable.sol";
import "../../../utils/AddressUpgradeable.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 SafeERC20Upgradeable {
    using AddressUpgradeable for address;

    function safeTransfer(
        IERC20Upgradeable token,
        address to,
        uint256 value
    ) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
    }

    function safeTransferFrom(
        IERC20Upgradeable 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(
        IERC20Upgradeable 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));
    }

    function safeIncreaseAllowance(
        IERC20Upgradeable token,
        address spender,
        uint256 value
    ) internal {
        uint256 newAllowance = token.allowance(address(this), spender) + value;
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
    }

    function safeDecreaseAllowance(
        IERC20Upgradeable token,
        address spender,
        uint256 value
    ) internal {
        unchecked {
            uint256 oldAllowance = token.allowance(address(this), spender);
            require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
            uint256 newAllowance = oldAllowance - value;
            _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
        }
    }

    function safePermit(
        IERC20PermitUpgradeable 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(IERC20Upgradeable 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");
        if (returndata.length > 0) {
            // Return data is optional
            require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
        }
    }
}

File 10 of 20 : AddressUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol)

pragma solidity ^0.8.1;

/**
 * @dev Collection of functions related to the address type
 */
library AddressUpgradeable {
    /**
     * @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
     * ====
     *
     * [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://diligence.consensys.net/posts/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.5.11/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 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 11 of 20 : ContextUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)

pragma solidity ^0.8.0;
import "../proxy/utils/Initializable.sol";

/**
 * @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 ContextUpgradeable is Initializable {
    function __Context_init() internal onlyInitializing {
    }

    function __Context_init_unchained() internal onlyInitializing {
    }
    function _msgSender() internal view virtual returns (address) {
        return msg.sender;
    }

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

    /**
     * @dev This empty reserved space is put in place to allow future versions to add new
     * variables without shifting down storage in the inheritance chain.
     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
     */
    uint256[50] private __gap;
}

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

pragma solidity ^0.8.0;

import "./IERC165Upgradeable.sol";
import "../../proxy/utils/Initializable.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 ERC165Upgradeable is Initializable, IERC165Upgradeable {
    function __ERC165_init() internal onlyInitializing {
    }

    function __ERC165_init_unchained() internal onlyInitializing {
    }
    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
        return interfaceId == type(IERC165Upgradeable).interfaceId;
    }

    /**
     * @dev This empty reserved space is put in place to allow future versions to add new
     * variables without shifting down storage in the inheritance chain.
     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
     */
    uint256[50] private __gap;
}

File 13 of 20 : IERC165Upgradeable.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 IERC165Upgradeable {
    /**
     * @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 20 : MathUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/Math.sol)

pragma solidity ^0.8.0;

/**
 * @dev Standard math utilities missing in the Solidity language.
 */
library MathUpgradeable {
    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) {
                return prod0 / denominator;
            }

            // Make sure the result is less than 2^256. Also prevents denominator == 0.
            require(denominator > prod1);

            ///////////////////////////////////////////////
            // 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 10, 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 * 8) < value ? 1 : 0);
        }
    }
}

File 15 of 20 : StringsUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/Strings.sol)

pragma solidity ^0.8.0;

import "./math/MathUpgradeable.sol";

/**
 * @dev String operations.
 */
library StringsUpgradeable {
    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 = MathUpgradeable.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 `uint256` to its ASCII `string` hexadecimal representation.
     */
    function toHexString(uint256 value) internal pure returns (string memory) {
        unchecked {
            return toHexString(value, MathUpgradeable.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);
    }
}

File 16 of 20 : EnumerableSetUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/structs/EnumerableSet.sol)
// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.

pragma solidity ^0.8.0;

/**
 * @dev Library for managing
 * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive
 * types.
 *
 * Sets have the following properties:
 *
 * - Elements are added, removed, and checked for existence in constant time
 * (O(1)).
 * - Elements are enumerated in O(n). No guarantees are made on the ordering.
 *
 * ```
 * contract Example {
 *     // Add the library methods
 *     using EnumerableSet for EnumerableSet.AddressSet;
 *
 *     // Declare a set state variable
 *     EnumerableSet.AddressSet private mySet;
 * }
 * ```
 *
 * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)
 * and `uint256` (`UintSet`) are supported.
 *
 * [WARNING]
 * ====
 * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure
 * unusable.
 * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.
 *
 * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an
 * array of EnumerableSet.
 * ====
 */
library EnumerableSetUpgradeable {
    // To implement this library for multiple types with as little code
    // repetition as possible, we write it in terms of a generic Set type with
    // bytes32 values.
    // The Set implementation uses private functions, and user-facing
    // implementations (such as AddressSet) are just wrappers around the
    // underlying Set.
    // This means that we can only create new EnumerableSets for types that fit
    // in bytes32.

    struct Set {
        // Storage of set values
        bytes32[] _values;
        // Position of the value in the `values` array, plus 1 because index 0
        // means a value is not in the set.
        mapping(bytes32 => uint256) _indexes;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function _add(Set storage set, bytes32 value) private returns (bool) {
        if (!_contains(set, value)) {
            set._values.push(value);
            // The value is stored at length-1, but we add 1 to all indexes
            // and use 0 as a sentinel value
            set._indexes[value] = set._values.length;
            return true;
        } else {
            return false;
        }
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function _remove(Set storage set, bytes32 value) private returns (bool) {
        // We read and store the value's index to prevent multiple reads from the same storage slot
        uint256 valueIndex = set._indexes[value];

        if (valueIndex != 0) {
            // Equivalent to contains(set, value)
            // To delete an element from the _values array in O(1), we swap the element to delete with the last one in
            // the array, and then remove the last element (sometimes called as 'swap and pop').
            // This modifies the order of the array, as noted in {at}.

            uint256 toDeleteIndex = valueIndex - 1;
            uint256 lastIndex = set._values.length - 1;

            if (lastIndex != toDeleteIndex) {
                bytes32 lastValue = set._values[lastIndex];

                // Move the last value to the index where the value to delete is
                set._values[toDeleteIndex] = lastValue;
                // Update the index for the moved value
                set._indexes[lastValue] = valueIndex; // Replace lastValue's index to valueIndex
            }

            // Delete the slot where the moved value was stored
            set._values.pop();

            // Delete the index for the deleted slot
            delete set._indexes[value];

            return true;
        } else {
            return false;
        }
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function _contains(Set storage set, bytes32 value) private view returns (bool) {
        return set._indexes[value] != 0;
    }

    /**
     * @dev Returns the number of values on the set. O(1).
     */
    function _length(Set storage set) private view returns (uint256) {
        return set._values.length;
    }

    /**
     * @dev Returns the value stored at position `index` in the set. O(1).
     *
     * Note that there are no guarantees on the ordering of values inside the
     * array, and it may change when more values are added or removed.
     *
     * Requirements:
     *
     * - `index` must be strictly less than {length}.
     */
    function _at(Set storage set, uint256 index) private view returns (bytes32) {
        return set._values[index];
    }

    /**
     * @dev Return the entire set in an array
     *
     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
     * this function has an unbounded cost, and using it as part of a state-changing function may render the function
     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
     */
    function _values(Set storage set) private view returns (bytes32[] memory) {
        return set._values;
    }

    // Bytes32Set

    struct Bytes32Set {
        Set _inner;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {
        return _add(set._inner, value);
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {
        return _remove(set._inner, value);
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {
        return _contains(set._inner, value);
    }

    /**
     * @dev Returns the number of values in the set. O(1).
     */
    function length(Bytes32Set storage set) internal view returns (uint256) {
        return _length(set._inner);
    }

    /**
     * @dev Returns the value stored at position `index` in the set. O(1).
     *
     * Note that there are no guarantees on the ordering of values inside the
     * array, and it may change when more values are added or removed.
     *
     * Requirements:
     *
     * - `index` must be strictly less than {length}.
     */
    function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {
        return _at(set._inner, index);
    }

    /**
     * @dev Return the entire set in an array
     *
     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
     * this function has an unbounded cost, and using it as part of a state-changing function may render the function
     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
     */
    function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {
        bytes32[] memory store = _values(set._inner);
        bytes32[] memory result;

        /// @solidity memory-safe-assembly
        assembly {
            result := store
        }

        return result;
    }

    // AddressSet

    struct AddressSet {
        Set _inner;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function add(AddressSet storage set, address value) internal returns (bool) {
        return _add(set._inner, bytes32(uint256(uint160(value))));
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function remove(AddressSet storage set, address value) internal returns (bool) {
        return _remove(set._inner, bytes32(uint256(uint160(value))));
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function contains(AddressSet storage set, address value) internal view returns (bool) {
        return _contains(set._inner, bytes32(uint256(uint160(value))));
    }

    /**
     * @dev Returns the number of values in the set. O(1).
     */
    function length(AddressSet storage set) internal view returns (uint256) {
        return _length(set._inner);
    }

    /**
     * @dev Returns the value stored at position `index` in the set. O(1).
     *
     * Note that there are no guarantees on the ordering of values inside the
     * array, and it may change when more values are added or removed.
     *
     * Requirements:
     *
     * - `index` must be strictly less than {length}.
     */
    function at(AddressSet storage set, uint256 index) internal view returns (address) {
        return address(uint160(uint256(_at(set._inner, index))));
    }

    /**
     * @dev Return the entire set in an array
     *
     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
     * this function has an unbounded cost, and using it as part of a state-changing function may render the function
     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
     */
    function values(AddressSet storage set) internal view returns (address[] memory) {
        bytes32[] memory store = _values(set._inner);
        address[] memory result;

        /// @solidity memory-safe-assembly
        assembly {
            result := store
        }

        return result;
    }

    // UintSet

    struct UintSet {
        Set _inner;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function add(UintSet storage set, uint256 value) internal returns (bool) {
        return _add(set._inner, bytes32(value));
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function remove(UintSet storage set, uint256 value) internal returns (bool) {
        return _remove(set._inner, bytes32(value));
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function contains(UintSet storage set, uint256 value) internal view returns (bool) {
        return _contains(set._inner, bytes32(value));
    }

    /**
     * @dev Returns the number of values in the set. O(1).
     */
    function length(UintSet storage set) internal view returns (uint256) {
        return _length(set._inner);
    }

    /**
     * @dev Returns the value stored at position `index` in the set. O(1).
     *
     * Note that there are no guarantees on the ordering of values inside the
     * array, and it may change when more values are added or removed.
     *
     * Requirements:
     *
     * - `index` must be strictly less than {length}.
     */
    function at(UintSet storage set, uint256 index) internal view returns (uint256) {
        return uint256(_at(set._inner, index));
    }

    /**
     * @dev Return the entire set in an array
     *
     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
     * this function has an unbounded cost, and using it as part of a state-changing function may render the function
     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
     */
    function values(UintSet storage set) internal view returns (uint256[] memory) {
        bytes32[] memory store = _values(set._inner);
        uint256[] memory result;

        /// @solidity memory-safe-assembly
        assembly {
            result := store
        }

        return result;
    }
}

File 17 of 20 : BridgeBase.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.4;

import '@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol';
import '@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol';
import '@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol';
import '@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol';
import '@openzeppelin/contracts-upgradeable/utils/structs/EnumerableSetUpgradeable.sol';
import '@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol';

import './libraries/FullMath.sol';

import './errors/Errors.sol';

contract BridgeBase is AccessControlUpgradeable, PausableUpgradeable, ReentrancyGuardUpgradeable {
    using EnumerableSetUpgradeable for EnumerableSetUpgradeable.AddressSet;
    using SafeERC20Upgradeable for IERC20Upgradeable;

    // Denominator for setting fees
    uint256 internal constant DENOMINATOR = 1e6;

    bytes32 public constant MANAGER_ROLE = keccak256('MANAGER_ROLE');

    // Struct with all info about integrator fees
    mapping(address => IntegratorFeeInfo) public integratorToFeeInfo;
    // Amount of collected fees in native token integrator -> native fees
    mapping(address => uint256) public availableIntegratorCryptoFee;

    // token -> minAmount for swap
    mapping(address => uint256) public minTokenAmount;
    // token -> maxAmount for swap
    mapping(address => uint256) public maxTokenAmount;

    // token -> rubic collected fees
    mapping(address => uint256) public availableRubicTokenFee;
    // token -> integrator collected fees
    mapping(address => mapping(address => uint256)) public availableIntegratorTokenFee;

    // limit the max Rubic token fee
    uint256 public maxRubicPlatformFee = 250_000; // 25%
    // Rubic token fee
    uint256 public RubicPlatformFee;
    // Rubic fixed fee for swap
    uint256 public fixedCryptoFee;
    // Collected rubic fees in native token
    uint256 public availableRubicCryptoFee;

    // Pending admin in transfer process
    address private pendingAdmin;
    // Admin who transfers its role
    address private previousAdmin;

    event FixedCryptoFee(uint256 RubicPart, uint256 integratorPart, address indexed integrator);
    event FixedCryptoFeeCollected(uint256 amount, address collector);
    event TokenFee(uint256 RubicPart, uint256 integratorPart, address indexed integrator, address token);
    event IntegratorTokenFeeCollected(uint256 amount, address indexed integrator, address token);
    event RubicTokenFeeCollected(uint256 amount, address token);
    event InitAdminTransfer(address admintShifter, address newAdmin);
    event AcceptAdmin(address adminShifter, address newAdmin);

    struct IntegratorFeeInfo {
        bool isIntegrator; // flag for setting 0 fees for integrator      - 1 byte
        uint32 tokenFee; // total fee percent gathered from user          - 4 bytes
        uint32 RubicTokenShare; // token share of platform commission     - 4 bytes
        uint32 RubicFixedCryptoShare; // native share of fixed commission - 4 bytes
        uint128 fixedFeeAmount; // custom fixed fee amount                - 16 bytes
    } //                                                            total - 29 bytes <= 32 bytes

    struct BaseCrossChainParams {
        address srcInputToken;
        uint256 srcInputAmount;
        uint256 dstChainID;
        address dstOutputToken;
        uint256 dstMinOutputAmount;
        address recipient;
        address integrator;
        address router;
    }

    // reference to https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3347/
    modifier onlyAdmin() {
        checkIsAdmin();
        _;
    }

    modifier onlyManagerOrAdmin() {
        checkIsManagerOrAdmin();
        _;
    }

    modifier onlyEOA() {
        if (msg.sender != tx.origin) {
            revert OnlyEOA();
        }
        _;
    }

    function __BridgeBaseInit(
        uint256 _fixedCryptoFee,
        uint256 _RubicPlatformFee,
        address[] memory _tokens,
        uint256[] memory _minTokenAmounts,
        uint256[] memory _maxTokenAmounts,
        address _admin
    ) internal onlyInitializing {
        if (_admin == address(0)) {
            revert ZeroAddress();
        }

        __Pausable_init_unchained();

        fixedCryptoFee = _fixedCryptoFee;

        if (_RubicPlatformFee > DENOMINATOR) {
            revert FeeTooHigh();
        }

        RubicPlatformFee = _RubicPlatformFee;

        uint256 tokensLength = _tokens.length;
        for (uint256 i; i < tokensLength; ) {
            if (_minTokenAmounts[i] > _maxTokenAmounts[i]) {
                revert MinMustBeLowerThanMax();
            }
            minTokenAmount[_tokens[i]] = _minTokenAmounts[i];
            maxTokenAmount[_tokens[i]] = _maxTokenAmounts[i];
            unchecked {
                ++i;
            }
        }

        _setupRole(DEFAULT_ADMIN_ROLE, _admin);
    }

    /**
     * @dev Calculates and accrues fixed crypto fee
     * @param _integrator Integrator's address if there is one
     * @param _info A struct with integrator fee info
     * @return The msg.value without fixedCryptoFee
     */
    function accrueFixedCryptoFee(address _integrator, IntegratorFeeInfo memory _info) internal returns (uint256) {
        uint256 _fixedCryptoFee;
        uint256 _RubicPart;
        if (_info.isIntegrator) {
            _fixedCryptoFee = uint256(_info.fixedFeeAmount);

            if (_fixedCryptoFee > 0) {
                _RubicPart = (_fixedCryptoFee * _info.RubicFixedCryptoShare) / DENOMINATOR;

                availableIntegratorCryptoFee[_integrator] += _fixedCryptoFee - _RubicPart;
            }
        } else {
            _fixedCryptoFee = fixedCryptoFee;
            _RubicPart = _fixedCryptoFee;
        }

        availableRubicCryptoFee += _RubicPart;

        emit FixedCryptoFee(_RubicPart, _fixedCryptoFee - _RubicPart, _integrator);

        // Underflow is prevented by sol 0.8
        return (msg.value - _fixedCryptoFee);
    }

    /**
     * @dev Calculates token fees and accrues them
     * @param _integrator Integrator's address if there is one
     * @param _info A struct with fee info about integrator
     * @param _amountWithFee Total amount passed by the user
     * @param _token The token in which the fees are collected
     * @param _initBlockchainNum Used if the _calculateFee is overriden by
     * WithDestinationFunctionality, otherwise is ignored
     * @return Amount of tokens without fee
     */
    function accrueTokenFees(
        address _integrator,
        IntegratorFeeInfo memory _info,
        uint256 _amountWithFee,
        uint256 _initBlockchainNum,
        address _token
    ) internal returns (uint256) {
        (uint256 _totalFees, uint256 _RubicFee) = _calculateFee(_info, _amountWithFee, _initBlockchainNum);

        if (_integrator != address(0)) {
            availableIntegratorTokenFee[_token][_integrator] += _totalFees - _RubicFee;
        }
        availableRubicTokenFee[_token] += _RubicFee;

        emit TokenFee(_RubicFee, _totalFees - _RubicFee, _integrator, _token);

        return _amountWithFee - _totalFees;
    }

    /**
     * @dev Calculates fee amount for integrator and rubic, used in architecture
     * @param _amountWithFee the users initial amount
     * @param _info the struct with data about integrator
     * @return _totalFee the amount of Rubic + integrator fee
     * @return _RubicFee the amount of Rubic fee only
     */
    function _calculateFeeWithIntegrator(
        uint256 _amountWithFee,
        IntegratorFeeInfo memory _info
    ) internal pure returns (uint256 _totalFee, uint256 _RubicFee) {
        if (_info.tokenFee > 0) {
            _totalFee = FullMath.mulDiv(_amountWithFee, _info.tokenFee, DENOMINATOR);

            _RubicFee = FullMath.mulDiv(_totalFee, _info.RubicTokenShare, DENOMINATOR);
        }
    }

    function _calculateFee(
        IntegratorFeeInfo memory _info,
        uint256 _amountWithFee,
        uint256
    ) internal view returns (uint256 _totalFee, uint256 _RubicFee) {
        if (_info.isIntegrator) {
            (_totalFee, _RubicFee) = _calculateFeeWithIntegrator(_amountWithFee, _info);
        } else {
            _totalFee = FullMath.mulDiv(_amountWithFee, RubicPlatformFee, DENOMINATOR);

            _RubicFee = _totalFee;
        }
    }

    /// COLLECT FUNCTIONS ///

    function _collectIntegrator(address _integrator, address _token) private {
        uint256 _amount;

        if (_token == address(0)) {
            _amount = availableIntegratorCryptoFee[_integrator];
            availableIntegratorCryptoFee[_integrator] = 0;
            emit FixedCryptoFeeCollected(_amount, _integrator);
        }

        _amount += availableIntegratorTokenFee[_token][_integrator];

        if (_amount == 0) {
            revert ZeroAmount();
        }

        availableIntegratorTokenFee[_token][_integrator] = 0;

        sendToken(_token, _amount, _integrator);

        emit IntegratorTokenFeeCollected(_amount, _integrator, _token);
    }

    /**
     * @dev Integrator can collect fees calling this function
     * @param _token The token to collect fees in
     */
    function collectIntegratorFee(address _token) external nonReentrant {
        _collectIntegrator(msg.sender, _token);
    }

    /**
     * @dev Managers can collect integrator's fees calling this function
     * Fees go to the integrator
     * @param _integrator Address of the integrator
     * @param _token The token to collect fees in
     */
    function collectIntegratorFee(address _integrator, address _token) external onlyManagerOrAdmin {
        _collectIntegrator(_integrator, _token);
    }

    /**
     * @dev Calling this function managers can collect Rubic's token fee
     * @param _token The token to collect fees in
     * @param _recipient The recipient
     */
    function collectRubicFee(address _token, address _recipient) external onlyAdmin {
        uint256 _amount = availableRubicTokenFee[_token];
        if (_amount == 0) {
            revert ZeroAmount();
        }

        availableRubicTokenFee[_token] = 0;
        sendToken(_token, _amount, _recipient);

        emit RubicTokenFeeCollected(_amount, _token);
    }

    /**
     * @dev Calling this function managers can collect Rubic's fixed crypto fee
     * @param _recipient The recipient
     */
    function collectRubicCryptoFee(address _recipient) external onlyAdmin {
        uint256 _cryptoFee = availableRubicCryptoFee;
        availableRubicCryptoFee = 0;

        sendToken(address(0), _cryptoFee, _recipient);

        emit FixedCryptoFeeCollected(_cryptoFee, msg.sender);
    }

    /**
     * @dev A function to rescue stuck tokens from the contract
     * @param _token The token to sweep
     * @param _amount The amount of tokens
     * @param _recipient The recipient
     */
    function sweepTokens(address _token, uint256 _amount, address _recipient) external onlyAdmin {
        sendToken(_token, _amount, _recipient);
    }

    /// CONTROL FUNCTIONS ///

    function pauseExecution() external onlyManagerOrAdmin {
        _pause();
    }

    function unpauseExecution() external onlyManagerOrAdmin {
        _unpause();
    }

    /**
     * @dev Sets fee info associated with an integrator
     * @param _integrator Address of the integrator
     * @param _info Struct with fee info
     */
    function setIntegratorInfo(address _integrator, IntegratorFeeInfo memory _info) external onlyManagerOrAdmin {
        if (_info.tokenFee > DENOMINATOR) {
            revert FeeTooHigh();
        }
        if (_info.RubicTokenShare > DENOMINATOR || _info.RubicFixedCryptoShare > DENOMINATOR) {
            revert ShareTooHigh();
        }

        integratorToFeeInfo[_integrator] = _info;
    }

    /**
     * @dev Sets fixed crypto fee
     * @param _fixedCryptoFee Fixed crypto fee
     */
    function setFixedCryptoFee(uint256 _fixedCryptoFee) external onlyManagerOrAdmin {
        fixedCryptoFee = _fixedCryptoFee;
    }

    /**
     * @dev Sets Rubic token fee
     * @notice Cannot be higher than limit set only by an admin
     * @param _platformFee Fixed crypto fee
     */
    function setRubicPlatformFee(uint256 _platformFee) external onlyManagerOrAdmin {
        if (_platformFee > maxRubicPlatformFee) {
            revert FeeTooHigh();
        }

        RubicPlatformFee = _platformFee;
    }

    /**
     * @dev Sets the limit of Rubic token fee
     * @param _maxFee The limit
     */
    function setMaxRubicPlatformFee(uint256 _maxFee) external onlyAdmin {
        if (_maxFee > DENOMINATOR) {
            revert FeeTooHigh();
        }

        maxRubicPlatformFee = _maxFee;
    }

    /**
     * @dev Changes requirement for minimal token amount on transfers
     * @param _token The token address to setup
     * @param _minTokenAmount Amount of tokens
     */
    function setMinTokenAmount(address _token, uint256 _minTokenAmount) external onlyManagerOrAdmin {
        if (_minTokenAmount > maxTokenAmount[_token]) {
            // can be equal in case we want them to be zero
            revert MinMustBeLowerThanMax();
        }
        minTokenAmount[_token] = _minTokenAmount;
    }

    /**
     * @dev Changes requirement for maximum token amount on transfers
     * @param _token The token address to setup
     * @param _maxTokenAmount Amount of tokens
     */
    function setMaxTokenAmount(address _token, uint256 _maxTokenAmount) external onlyManagerOrAdmin {
        if (_maxTokenAmount < minTokenAmount[_token]) {
            // can be equal in case we want them to be zero
            revert MaxMustBeBiggerThanMin();
        }
        maxTokenAmount[_token] = _maxTokenAmount;
    }

    /**
     * @dev Transfers admin role
     * @param _newAdmin New admin's address
     */
    function transferAdmin(address _newAdmin) external onlyAdmin {
        pendingAdmin = _newAdmin;
        previousAdmin = msg.sender;

        emit InitAdminTransfer(msg.sender, _newAdmin);
    }

    function acceptAdmin() external {
        if (pendingAdmin != msg.sender) revert NotPendingAdmin();

        _revokeRole(DEFAULT_ADMIN_ROLE, previousAdmin);
        _grantRole(DEFAULT_ADMIN_ROLE, msg.sender);

        emit AcceptAdmin(previousAdmin, msg.sender);

        pendingAdmin = address(0);
        previousAdmin = address(0);
    }

    /// VIEW FUNCTIONS ///

    /**
     * @notice Used in modifiers
     * @dev Function to check if address is belongs to manager or admin role
     */
    function checkIsManagerOrAdmin() internal view {
        if (!(hasRole(MANAGER_ROLE, msg.sender) || hasRole(DEFAULT_ADMIN_ROLE, msg.sender))) {
            revert NotAManager();
        }
    }

    /**
     * @notice Used in modifiers
     * @dev Function to check if address is belongs to default admin role
     */
    function checkIsAdmin() internal view {
        if (!hasRole(DEFAULT_ADMIN_ROLE, msg.sender)) {
            revert NotAnAdmin();
        }
    }

    function sendToken(address _token, uint256 _amount, address _receiver) internal virtual {
        if (_token == address(0)) {
            AddressUpgradeable.sendValue(payable(_receiver), _amount);
        } else {
            IERC20Upgradeable(_token).safeTransfer(_receiver, _amount);
        }
    }

    /**
     * @dev Plain fallback function to receive native
     */
    receive() external payable {}

    /**
     * @dev Plain fallback function
     */
    fallback() external {}
}

File 18 of 20 : Errors.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.4;

error NotAnAdmin();
error NotAManager();
error NotARelayer();
error OnlyEOA();
error FeeTooHigh();
error ShareTooHigh();
error ZeroAddress();
error ZeroAmount();
error InefficientFixedFee();
error ApproveFailed();
error MinMustBeLowerThanMax();
error MaxMustBeBiggerThanMin();
error CantSetToNull();
error Unchangeable();
error LengthMismatch();
error NotPendingAdmin();

File 19 of 20 : FullMath.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.4;

/// @title Contains 512-bit math functions
/// @notice Facilitates multiplication and division that can have overflow of an intermediate value without any loss of precision
/// @dev Handles "phantom overflow" i.e., allows multiplication and division where an intermediate value overflows 256 bits
library FullMath {
    /// @notice Calculates floor(a×b÷denominator) with full precision. Throws if result overflows a uint256 or denominator == 0
    /// @param a The multiplicand
    /// @param b The multiplier
    /// @param denominator The divisor
    /// @return result The 256-bit result
    /// @dev Credit to Remco Bloemen under MIT license https://xn--2-umb.com/21/muldiv
    function mulDiv(uint256 a, uint256 b, uint256 denominator) internal pure returns (uint256 result) {
        unchecked {
            // 512-bit multiply [prod1 prod0] = a * b
            // Compute the product mod 2**256 and mod 2**256 - 1
            // then 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(a, b, not(0))
                prod0 := mul(a, b)
                prod1 := sub(sub(mm, prod0), lt(mm, prod0))
            }

            // Handle non-overflow cases, 256 by 256 division
            if (prod1 == 0) {
                require(denominator > 0);
                assembly {
                    result := div(prod0, denominator)
                }
                return result;
            }

            // Make sure the result is less than 2**256.
            // Also prevents denominator == 0
            require(denominator > prod1);

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

            // Make division exact by subtracting the remainder from [prod1 prod0]
            // Compute remainder using mulmod
            uint256 remainder;
            assembly {
                remainder := mulmod(a, b, denominator)
            }
            // Subtract 256 bit number from 512 bit number
            assembly {
                prod1 := sub(prod1, gt(remainder, prod0))
                prod0 := sub(prod0, remainder)
            }

            // Factor powers of two out of denominator
            // Compute largest power of two divisor of denominator.
            // Always >= 1.
            uint256 twos = (0 - denominator) & denominator;
            // Divide denominator by power of two
            assembly {
                denominator := div(denominator, twos)
            }

            // Divide [prod1 prod0] by the factors of two
            assembly {
                prod0 := div(prod0, twos)
            }
            // Shift in bits from prod1 into prod0. For this we need
            // to flip `twos` such that it is 2**256 / twos.
            // If twos is zero, then it becomes one
            assembly {
                twos := add(div(sub(0, twos), twos), 1)
            }
            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
            // correct for four bits. That is, denominator * inv = 1 mod 2**4
            uint256 inv = (3 * denominator) ^ 2;
            // Now use 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.
            inv *= 2 - denominator * inv; // inverse mod 2**8
            inv *= 2 - denominator * inv; // inverse mod 2**16
            inv *= 2 - denominator * inv; // inverse mod 2**32
            inv *= 2 - denominator * inv; // inverse mod 2**64
            inv *= 2 - denominator * inv; // inverse mod 2**128
            inv *= 2 - denominator * inv; // 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 precoditions 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 * inv;
            return result;
        }
    }
}

File 20 of 20 : IRubicWhitelist.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.4;

interface IRubicWhitelist {
    function addOperators(address[] calldata _operators) external;

    function removeOperators(address[] calldata _operators) external;

    function getAvailableOperators() external view returns (address[] memory);

    function isOperator(address _operator) external view returns (bool);

    function addCrossChains(address[] calldata _crossChains) external;

    function removeCrossChains(address[] calldata _crossChains) external;

    function getAvailableCrossChains() external view returns (address[] memory);

    function isWhitelistedCrossChain(address _crossChain) external view returns (bool);

    function addDEXs(address[] calldata _dexs) external;

    function removeDEXs(address[] calldata _dexs) external;

    function getAvailableDEXs() external view returns (address[] memory);

    function isWhitelistedDEX(address _dex) external view returns (bool);

    function addAnyRouters(address[] calldata _anyRouters) external;

    function removeAnyRouters(address[] calldata _anyRouters) external;

    function getAvailableAnyRouters() external view returns (address[] memory);

    function isWhitelistedAnyRouter(address _anyRouter) external view returns (bool);

    function addToBlackList(address[] calldata _blackAddrs) external;

    function removeFromBlackList(address[] calldata _blackAddrs) external;

    function getBlackList() external view returns (address[] memory);

    function isBlacklisted(address _router) external view returns (bool);
}

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

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"uint256","name":"_fixedCryptoFee","type":"uint256"},{"internalType":"uint256","name":"_RubicPlatformFee","type":"uint256"},{"internalType":"address[]","name":"_tokens","type":"address[]"},{"internalType":"uint256[]","name":"_minTokenAmounts","type":"uint256[]"},{"internalType":"uint256[]","name":"_maxTokenAmounts","type":"uint256[]"},{"internalType":"address","name":"_admin","type":"address"},{"internalType":"contract IRubicWhitelist","name":"_whitelistRegistry","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"DexNotAvailable","type":"error"},{"inputs":[],"name":"DifferentAmountSpent","type":"error"},{"inputs":[],"name":"FeeTooHigh","type":"error"},{"inputs":[],"name":"MaxMustBeBiggerThanMin","type":"error"},{"inputs":[],"name":"MinMustBeLowerThanMax","type":"error"},{"inputs":[],"name":"NotAManager","type":"error"},{"inputs":[],"name":"NotANativeToken","type":"error"},{"inputs":[],"name":"NotAnAdmin","type":"error"},{"inputs":[],"name":"NotPendingAdmin","type":"error"},{"inputs":[],"name":"ShareTooHigh","type":"error"},{"inputs":[],"name":"TooFewReceived","type":"error"},{"inputs":[],"name":"ZeroAddress","type":"error"},{"inputs":[],"name":"ZeroAmount","type":"error"},{"inputs":[],"name":"ZeroToken","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"adminShifter","type":"address"},{"indexed":false,"internalType":"address","name":"newAdmin","type":"address"}],"name":"AcceptAdmin","type":"event"},{"anonymous":false,"inputs":[{"components":[{"internalType":"address","name":"inputToken","type":"address"},{"internalType":"uint256","name":"inputAmount","type":"uint256"},{"internalType":"address","name":"outputToken","type":"address"},{"internalType":"uint256","name":"minOutputAmount","type":"uint256"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"address","name":"integrator","type":"address"},{"internalType":"address","name":"dex","type":"address"}],"indexed":false,"internalType":"struct InstantProxy.InstantTradesParams","name":"parameters","type":"tuple"}],"name":"DexSwap","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"RubicPart","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"integratorPart","type":"uint256"},{"indexed":true,"internalType":"address","name":"integrator","type":"address"}],"name":"FixedCryptoFee","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"address","name":"collector","type":"address"}],"name":"FixedCryptoFeeCollected","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"admintShifter","type":"address"},{"indexed":false,"internalType":"address","name":"newAdmin","type":"address"}],"name":"InitAdminTransfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"version","type":"uint8"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":true,"internalType":"address","name":"integrator","type":"address"},{"indexed":false,"internalType":"address","name":"token","type":"address"}],"name":"IntegratorTokenFeeCollected","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","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":"amount","type":"uint256"},{"indexed":false,"internalType":"address","name":"token","type":"address"}],"name":"RubicTokenFeeCollected","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"RubicPart","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"integratorPart","type":"uint256"},{"indexed":true,"internalType":"address","name":"integrator","type":"address"},{"indexed":false,"internalType":"address","name":"token","type":"address"}],"name":"TokenFee","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"stateMutability":"nonpayable","type":"fallback"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MANAGER_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"RubicPlatformFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"acceptAdmin","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"availableIntegratorCryptoFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"}],"name":"availableIntegratorTokenFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"availableRubicCryptoFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"availableRubicTokenFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"}],"name":"collectIntegratorFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_integrator","type":"address"},{"internalType":"address","name":"_token","type":"address"}],"name":"collectIntegratorFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_recipient","type":"address"}],"name":"collectRubicCryptoFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"},{"internalType":"address","name":"_recipient","type":"address"}],"name":"collectRubicFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"fixedCryptoFee","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":[{"components":[{"internalType":"address","name":"inputToken","type":"address"},{"internalType":"uint256","name":"inputAmount","type":"uint256"},{"internalType":"address","name":"outputToken","type":"address"},{"internalType":"uint256","name":"minOutputAmount","type":"uint256"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"address","name":"integrator","type":"address"},{"internalType":"address","name":"dex","type":"address"}],"internalType":"struct InstantProxy.InstantTradesParams","name":"_params","type":"tuple"},{"internalType":"bytes","name":"_data","type":"bytes"}],"name":"instantTrade","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"inputToken","type":"address"},{"internalType":"uint256","name":"inputAmount","type":"uint256"},{"internalType":"address","name":"outputToken","type":"address"},{"internalType":"uint256","name":"minOutputAmount","type":"uint256"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"address","name":"integrator","type":"address"},{"internalType":"address","name":"dex","type":"address"}],"internalType":"struct InstantProxy.InstantTradesParams","name":"_params","type":"tuple"},{"internalType":"bytes","name":"_data","type":"bytes"}],"name":"instantTradeNative","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"integratorToFeeInfo","outputs":[{"internalType":"bool","name":"isIntegrator","type":"bool"},{"internalType":"uint32","name":"tokenFee","type":"uint32"},{"internalType":"uint32","name":"RubicTokenShare","type":"uint32"},{"internalType":"uint32","name":"RubicFixedCryptoShare","type":"uint32"},{"internalType":"uint128","name":"fixedFeeAmount","type":"uint128"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxRubicPlatformFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"maxTokenAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"minTokenAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pauseExecution","outputs":[],"stateMutability":"nonpayable","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":"uint256","name":"_fixedCryptoFee","type":"uint256"}],"name":"setFixedCryptoFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_integrator","type":"address"},{"components":[{"internalType":"bool","name":"isIntegrator","type":"bool"},{"internalType":"uint32","name":"tokenFee","type":"uint32"},{"internalType":"uint32","name":"RubicTokenShare","type":"uint32"},{"internalType":"uint32","name":"RubicFixedCryptoShare","type":"uint32"},{"internalType":"uint128","name":"fixedFeeAmount","type":"uint128"}],"internalType":"struct BridgeBase.IntegratorFeeInfo","name":"_info","type":"tuple"}],"name":"setIntegratorInfo","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_maxFee","type":"uint256"}],"name":"setMaxRubicPlatformFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"},{"internalType":"uint256","name":"_maxTokenAmount","type":"uint256"}],"name":"setMaxTokenAmount","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"},{"internalType":"uint256","name":"_minTokenAmount","type":"uint256"}],"name":"setMinTokenAmount","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_platformFee","type":"uint256"}],"name":"setRubicPlatformFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IRubicWhitelist","name":"_newWhitelistRegistry","type":"address"}],"name":"setWhitelistRegistry","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":[{"internalType":"address","name":"_token","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"address","name":"_recipient","type":"address"}],"name":"sweepTokens","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_newAdmin","type":"address"}],"name":"transferAdmin","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"unpauseExecution","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"whitelistRegistry","outputs":[{"internalType":"contract IRubicWhitelist","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"stateMutability":"payable","type":"receive"}]

60806040526203d090610101553480156200001957600080fd5b5060405162003219380380620032198339810160408190526200003c916200060d565b6001600160a01b038116620000645760405163d92e233d60e01b815260040160405180910390fd5b61010780546001600160a01b0319166001600160a01b038316179055620000908787878787876200009d565b5050505050505062000757565b600054610100900460ff1615808015620000be5750600054600160ff909116105b80620000ee5750620000db30620001db60201b620010ae1760201c565b158015620000ee575060005460ff166001145b620001575760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b60648201526084015b60405180910390fd5b6000805460ff1916600117905580156200017b576000805461ff0019166101001790555b6200018b878787878787620001ea565b8015620001d2576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b50505050505050565b6001600160a01b03163b151590565b600054610100900460ff16620002465760405162461bcd60e51b815260206004820152602b6024820152600080516020620031f983398151915260448201526a6e697469616c697a696e6760a81b60648201526084016200014e565b6001600160a01b0381166200026e5760405163d92e233d60e01b815260040160405180910390fd5b62000278620003e4565b610103869055620f4240851115620002a35760405163cd4e616760e01b815260040160405180910390fd5b610102859055835160005b81811015620003d657838181518110620002cc57620002cc62000741565b6020026020010151858281518110620002e957620002e962000741565b60200260200101511115620003115760405163129c63a160e31b815260040160405180910390fd5b84818151811062000326576200032662000741565b602002602001015160fd600088848151811062000347576200034762000741565b60200260200101516001600160a01b03166001600160a01b031681526020019081526020016000208190555083818151811062000388576200038862000741565b602002602001015160fe6000888481518110620003a957620003a962000741565b6020908102919091018101516001600160a01b0316825281019190915260400160002055600101620002ae565b50620001d26000836200044c565b600054610100900460ff16620004405760405162461bcd60e51b815260206004820152602b6024820152600080516020620031f983398151915260448201526a6e697469616c697a696e6760a81b60648201526084016200014e565b6097805460ff19169055565b6200045882826200045c565b5050565b60008281526065602090815260408083206001600160a01b038516845290915290205460ff16620004585760008281526065602090815260408083206001600160a01b03851684529091529020805460ff19166001179055620004bc3390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f191681016001600160401b038111828210171562000541576200054162000500565b604052919050565b60006001600160401b0382111562000565576200056562000500565b5060051b60200190565b6001600160a01b03811681146200058557600080fd5b50565b805162000595816200056f565b919050565b600082601f830112620005ac57600080fd5b81516020620005c5620005bf8362000549565b62000516565b82815260059290921b84018101918181019086841115620005e557600080fd5b8286015b84811015620006025780518352918301918301620005e9565b509695505050505050565b600080600080600080600060e0888a0312156200062957600080fd5b87516020808a015160408b01519299509750906001600160401b03808211156200065257600080fd5b818b0191508b601f8301126200066757600080fd5b815162000678620005bf8262000549565b81815260059190911b8301840190848101908e8311156200069857600080fd5b938501935b82851015620006c3578451620006b3816200056f565b825293850193908501906200069d565b60608e0151909a509450505080831115620006dd57600080fd5b620006eb8c848d016200059a565b965060808b01519250808311156200070257600080fd5b5050620007128a828b016200059a565b9350506200072360a0890162000588565b91506200073360c0890162000588565b905092959891949750929550565b634e487b7160e01b600052603260045260246000fd5b612a9280620007676000396000f3fe6080604052600436106102295760003560e01c8063772f8c2d11610123578063a217fddf116100ab578063ce6b112f1161006f578063ce6b112f146106f6578063d1712ccb1461070d578063d547741f1461072d578063ec87621c1461074d578063ed9506381461078157610230565b8063a217fddf1461065d578063a61986d414610672578063bcd97c2514610692578063c4707686146106b2578063c75b3d41146106df57610230565b8063859806cc116100f2578063859806cc146105d15780638ac2e981146105e657806391d148541461060657806395c54f5a146106265780639e3692351461064657610230565b8063772f8c2d146104c357806379e65062146104f05780637cd5083f14610510578063825dc415146105b157610230565b80632f2ff15d116101b157806348d8b9a41161017557806348d8b9a4146104285780635c975abb1461043f57806369fe30e81461045757806375829def1461049057806376fece74146104b057610230565b80632f2ff15d14610395578063352c9dd6146103b557806336568abe146103d55780633c4ac4b8146103f55780633f979a9a1461040857610230565b8063162dfb0d116101f8578063162dfb0d146102e35780631bceb8d4146103035780631e2c0314146103305780631f041ec614610350578063248a9ca31461036557610230565b806301ffc9a71461023e57806307598f62146102735780630e18b681146102935780630f4fb373146102a857610230565b3661023057005b34801561023c57600080fd5b005b34801561024a57600080fd5b5061025e6102593660046124d9565b6107ba565b60405190151581526020015b60405180910390f35b34801561027f57600080fd5b5061023c61028e366004612528565b6107f1565b34801561029f57600080fd5b5061023c610810565b3480156102b457600080fd5b506102d56102c3366004612528565b60fe6020526000908152604090205481565b60405190815260200161026a565b3480156102ef57600080fd5b5061023c6102fe366004612545565b6108c6565b34801561030f57600080fd5b506102d561031e366004612528565b60fd6020526000908152604090205481565b34801561033c57600080fd5b5061023c61034b36600461257e565b6108dc565b34801561035c57600080fd5b5061023c6108ea565b34801561037157600080fd5b506102d561038036600461257e565b60009081526065602052604090206001015490565b3480156103a157600080fd5b5061023c6103b0366004612597565b6108fc565b3480156103c157600080fd5b5061023c6103d0366004612528565b610926565b3480156103e157600080fd5b5061023c6103f0366004612597565b610978565b61023c61040336600461267c565b6109f7565b34801561041457600080fd5b5061023c61042336600461274a565b610b75565b34801561043457600080fd5b506102d56101035481565b34801561044b57600080fd5b5060975460ff1661025e565b34801561046357600080fd5b506102d5610472366004612545565b61010060209081526000928352604080842090915290825290205481565b34801561049c57600080fd5b5061023c6104ab366004612528565b610bd2565b61023c6104be36600461267c565b610c44565b3480156104cf57600080fd5b506102d56104de366004612528565b60fc6020526000908152604090205481565b3480156104fc57600080fd5b5061023c61050b36600461274a565b610d2d565b34801561051c57600080fd5b5061057361052b366004612528565b60fb6020526000908152604090205460ff81169063ffffffff6101008204811691600160281b8104821691600160481b820416906001600160801b03600160681b9091041685565b60408051951515865263ffffffff94851660208701529284169285019290925290911660608301526001600160801b0316608082015260a00161026a565b3480156105bd57600080fd5b5061023c6105cc366004612798565b610d8a565b3480156105dd57600080fd5b5061023c610ed0565b3480156105f257600080fd5b5061023c610601366004612545565b610ee0565b34801561061257600080fd5b5061025e610621366004612597565b610f8c565b34801561063257600080fd5b5061023c61064136600461257e565b610fb7565b34801561065257600080fd5b506102d56101045481565b34801561066957600080fd5b506102d5600081565b34801561067e57600080fd5b5061023c61068d366004612528565b610fe9565b34801561069e57600080fd5b5061023c6106ad36600461257e565b611044565b3480156106be57600080fd5b506102d56106cd366004612528565b60ff6020526000908152604090205481565b3480156106eb57600080fd5b506102d56101025481565b34801561070257600080fd5b506102d56101015481565b34801561071957600080fd5b5061023c610728366004612841565b611076565b34801561073957600080fd5b5061023c610748366004612597565b611089565b34801561075957600080fd5b506102d57f241ecf16d79d0f8dbfb92cbc07fe17840425976cf0667f022fe9877caa831b0881565b34801561078d57600080fd5b50610107546107a2906001600160a01b031681565b6040516001600160a01b03909116815260200161026a565b60006001600160e01b03198216637965db0b60e01b14806107eb57506301ffc9a760e01b6001600160e01b03198316145b92915050565b6107f96110bd565b6108033382611116565b61080d600160c955565b50565b610105546001600160a01b0316331461083c5760405163058d9a1b60e01b815260040160405180910390fd5b61010654610855906000906001600160a01b0316611253565b6108606000336112ba565b61010654604080516001600160a01b0390921682523360208301527f70994a41fc1886170c6242f151e958b9329102a0efaae1daa60c82cd5aea11c7910160405180910390a161010580546001600160a01b031990811690915561010680549091169055565b6108ce611340565b6108d88282611116565b5050565b6108e4611340565b61010355565b6108f2611340565b6108fa611398565b565b600082815260656020526040902060010154610917816113f2565b61092183836112ba565b505050565b61092e6113fc565b6001600160a01b0381166109555760405163d92e233d60e01b815260040160405180910390fd5b61010780546001600160a01b0319166001600160a01b0392909216919091179055565b6001600160a01b03811633146109ed5760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b60648201526084015b60405180910390fd5b6108d88282611253565b6109ff6110bd565b610a07611424565b8260c00151610a158161146a565b610a27846000015185602001516114f6565b602085810191825260a080870180516001600160a01b0316600090815260fb84526040808220815194850182525460ff811615158552610100810463ffffffff90811696860196909652600160281b8104861691850191909152600160481b81049094166060840152600160681b9093046001600160801b0316608083015251925187519193610abc93909285929190611621565b602086015260a0850151610ad0908261172e565b50610adc85858561182e565b7f2bc450c6200674bc17d097f338cb6e2ef4c5d48e2d0049bd5905fa426bc42c7085604051610b61919081516001600160a01b039081168252602080840151908301526040808401518216908301526060808401519083015260808084015182169083015260a08381015182169083015260c092830151169181019190915260e00190565b60405180910390a15050610921600160c955565b610b7d611340565b6001600160a01b038216600090815260fd6020526040902054811015610bb657604051635909a3b560e11b815260040160405180910390fd5b6001600160a01b03909116600090815260fe6020526040902055565b610bda6113fc565b61010580546001600160a01b03199081166001600160a01b0384169081179092556101068054339216821790556040805191825260208201929092527f551692d6181925be42a9902ebd0f1268341087490ad9b895558cd9e53031c5d2910160405180910390a150565b610c4c6110bd565b610c54611424565b8260c00151610c628161146a565b83516001600160a01b031615610c8b5760405163e59e4d6960e01b815260040160405180910390fd5b60a080850180516001600160a01b0316600090815260fb6020908152604091829020825194850183525460ff81161515855263ffffffff6101008204811692860192909252600160281b8104821692850192909252600160481b82041660608401526001600160801b03600160681b90910416608083015251610d1d9082610d13828261172e565b8851600090611621565b6020860152610adc858585611a07565b610d35611340565b6001600160a01b038216600090815260fe6020526040902054811115610d6e5760405163129c63a160e31b815260040160405180910390fd5b6001600160a01b03909116600090815260fd6020526040902055565b610d92611340565b620f4240816020015163ffffffff161115610dc05760405163cd4e616760e01b815260040160405180910390fd5b620f4240816040015163ffffffff161180610de75750620f4240816060015163ffffffff16115b15610e0557604051630a81ff1360e21b815260040160405180910390fd5b6001600160a01b03909116600090815260fb602090815260409182902083518154928501519385015160608601516080909601516001600160801b0316600160681b026fffffffffffffffffffffffffffffffff60681b1963ffffffff978816600160481b026cffffffff00000000000000000019938916600160281b02939093166cffffffffffffffff000000000019989097166101000264ffffffff00199415159490941664ffffffffff19909616959095179290921795909516939093179390931716179055565b610ed8611340565b6108fa611ab2565b610ee86113fc565b6001600160a01b038216600090815260ff602052604081205490819003610f2257604051631f2a200560e01b815260040160405180910390fd5b6001600160a01b038316600090815260ff6020526040812055610f46838284611aeb565b604080518281526001600160a01b03851660208201527f9216fa2f918153a5852ce98e7929c12cd94e0adeda8117f80e761c216157b27c910160405180910390a1505050565b60009182526065602090815260408084206001600160a01b0393909316845291905290205460ff1690565b610fbf611340565b61010154811115610fe35760405163cd4e616760e01b815260040160405180910390fd5b61010255565b610ff16113fc565b610104805460009182905590611008908284611aeb565b604080518281523360208201527f445ea353dd3cfa91aaa8ea899f31ffb4d03e783c45f0ef3717b46c32ea17969d910160405180910390a15050565b61104c6113fc565b620f42408111156110705760405163cd4e616760e01b815260040160405180910390fd5b61010155565b61107e6113fc565b610921838383611aeb565b6000828152606560205260409020600101546110a4816113f2565b6109218383611253565b6001600160a01b03163b151590565b600260c9540361110f5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016109e4565b600260c955565b60006001600160a01b03821661118157506001600160a01b038216600081815260fc60209081526040808320805493905580518381529182019390935290917f445ea353dd3cfa91aaa8ea899f31ffb4d03e783c45f0ef3717b46c32ea17969d910160405180910390a15b6001600160a01b03808316600090815261010060209081526040808320938716835292905220546111b29082612899565b9050806000036111d557604051631f2a200560e01b815260040160405180910390fd5b6001600160a01b03808316600090815261010060209081526040808320938716835292905290812055611209828285611aeb565b604080518281526001600160a01b0384811660208301528516917f6f83ca8ce48e63b2a223b9f9e7ef1ea7bf3a8385c7a9bd63baae22963b2b26e0910160405180910390a2505050565b61125d8282610f8c565b156108d85760008281526065602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b6112c48282610f8c565b6108d85760008281526065602090815260408083206001600160a01b03851684529091529020805460ff191660011790556112fc3390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b61136a7f241ecf16d79d0f8dbfb92cbc07fe17840425976cf0667f022fe9877caa831b0833610f8c565b8061137b575061137b600033610f8c565b6108fa57604051633a4af34560e21b815260040160405180910390fd5b6113a0611424565b6097805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586113d53390565b6040516001600160a01b03909116815260200160405180910390a1565b61080d8133611b17565b611407600033610f8c565b6108fa576040516355098f2760e01b815260040160405180910390fd5b60975460ff16156108fa5760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b60448201526064016109e4565b6101075460405163ae19ae2b60e01b81526001600160a01b0383811660048301529091169063ae19ae2b90602401602060405180830381865afa1580156114b5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114d991906128b1565b61080d5760405163442fd07160e11b815260040160405180910390fd5b60006001600160a01b03831661151f5760405163ad1991f560e01b815260040160405180910390fd5b6040516370a0823160e01b81523060048201526000906001600160a01b038516906370a0823190602401602060405180830381865afa158015611566573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061158a91906128ce565b90506115a16001600160a01b038516333086611b70565b6040516370a0823160e01b81523060048201526000906001600160a01b038616906370a0823190602401602060405180830381865afa1580156115e8573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061160c91906128ce565b905061161882826128e7565b95945050505050565b6000806000611631878787611be1565b90925090506001600160a01b0388161561168d5761164f81836128e7565b6001600160a01b03808616600090815261010060209081526040808320938d1683529290529081208054909190611687908490612899565b90915550505b6001600160a01b038416600090815260ff6020526040812080548392906116b5908490612899565b90915550506001600160a01b0388167f25471ec9f39b4ceb20d58f63c37f9c738011f0babcc4b6af69bdd82984ca5f8e826116f081866128e7565b6040805192835260208301919091526001600160a01b0388169082015260600160405180910390a261172282876128e7565b98975050505050505050565b60008060008360000151156117b65760808401516001600160801b0316915081156117b157620f4240846060015163ffffffff168361176d91906128fe565b611777919061291d565b905061178381836128e7565b6001600160a01b038616600090815260fc6020526040812080549091906117ab908490612899565b90915550505b6117be565b505061010354805b8061010460008282546117d19190612899565b90915550506001600160a01b0385167f3a84e53f89d2f7779a9c9a54779858ae0eb0b7760d607b445b6fd175c30a04d48261180c81866128e7565b6040805192835260208301919091520160405180910390a261161882346128e7565b60c08301516020840151845161184f926001600160a01b0390911691611c21565b600061186384608001518560400151611d36565b84516040516370a0823160e01b81523060048201529192506000916001600160a01b03909116906370a0823190602401602060405180830381865afa1580156118b0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118d491906128ce565b905061191a8560c0015185858080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250611dc992505050565b50600061192f86608001518760400151611d36565b86516040516370a0823160e01b81523060048201529192506000916001600160a01b03909116906370a0823190602401602060405180830381865afa15801561197c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119a091906128ce565b60208801519091506119b282856128e7565b146119d05760405163119e050560e01b815260040160405180910390fd5b60608701516119df85846128e7565b10156119fe5760405163db047cd960e01b815260040160405180910390fd5b50505050505050565b6000611a1b84608001518560400151611d36565b9050611a658460c0015184848080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152505050506020870151611e0d565b506000611a7a85608001518660400151611d36565b6060860151909150611a8c83836128e7565b1015611aab5760405163db047cd960e01b815260040160405180910390fd5b5050505050565b611aba611e3b565b6097805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa336113d5565b6001600160a01b038316611b03576109218183611e84565b6109216001600160a01b0384168284611f9d565b611b218282610f8c565b6108d857611b2e81611fcd565b611b39836020611fdf565b604051602001611b4a92919061296b565b60408051601f198184030181529082905262461bcd60e51b82526109e4916004016129e0565b6040516001600160a01b0380851660248301528316604482015260648101829052611bdb9085906323b872dd60e01b906084015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b03199093169290921790915261217b565b50505050565b600080846000015115611c0257611bf8848661224d565b9092509050611c19565b611c138461010254620f424061229f565b91508190505b935093915050565b801580611c9b5750604051636eb1769f60e11b81523060048201526001600160a01b03838116602483015284169063dd62ed3e90604401602060405180830381865afa158015611c75573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c9991906128ce565b155b611d065760405162461bcd60e51b815260206004820152603660248201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60448201527520746f206e6f6e2d7a65726f20616c6c6f77616e636560501b60648201526084016109e4565b6040516001600160a01b03831660248201526044810182905261092190849063095ea7b360e01b90606401611ba4565b60006001600160a01b03821615611db6576040516370a0823160e01b81526001600160a01b0384811660048301528316906370a0823190602401602060405180830381865afa158015611d8d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611db191906128ce565b611dc2565b826001600160a01b0316315b9392505050565b6060611dc2838360006040518060400160405280601e81526020017f416464726573733a206c6f772d6c6576656c2063616c6c206661696c65640000815250612351565b6060611e33848484604051806060016040528060298152602001612a5d60299139612351565b949350505050565b60975460ff166108fa5760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b60448201526064016109e4565b80471015611ed45760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a20696e73756666696369656e742062616c616e636500000060448201526064016109e4565b6000826001600160a01b03168260405160006040518083038185875af1925050503d8060008114611f21576040519150601f19603f3d011682016040523d82523d6000602084013e611f26565b606091505b50509050806109215760405162461bcd60e51b815260206004820152603a60248201527f416464726573733a20756e61626c6520746f2073656e642076616c75652c207260448201527f6563697069656e74206d6179206861766520726576657274656400000000000060648201526084016109e4565b6040516001600160a01b03831660248201526044810182905261092190849063a9059cbb60e01b90606401611ba4565b60606107eb6001600160a01b03831660145b60606000611fee8360026128fe565b611ff9906002612899565b67ffffffffffffffff811115612011576120116125bc565b6040519080825280601f01601f19166020018201604052801561203b576020820181803683370190505b509050600360fc1b8160008151811061205657612056612a13565b60200101906001600160f81b031916908160001a905350600f60fb1b8160018151811061208557612085612a13565b60200101906001600160f81b031916908160001a90535060006120a98460026128fe565b6120b4906001612899565b90505b600181111561212c576f181899199a1a9b1b9c1cb0b131b232b360811b85600f16601081106120e8576120e8612a13565b1a60f81b8282815181106120fe576120fe612a13565b60200101906001600160f81b031916908160001a90535060049490941c9361212581612a29565b90506120b7565b508315611dc25760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e7460448201526064016109e4565b60006121d0826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b031661242c9092919063ffffffff16565b80519091501561092157808060200190518101906121ee91906128b1565b6109215760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b60648201526084016109e4565b6000806000836020015163ffffffff1611156122985761227b84846020015163ffffffff16620f424061229f565b915061229582846040015163ffffffff16620f424061229f565b90505b9250929050565b60008080600019858709858702925082811083820303915050806000036122d857600084116122cd57600080fd5b508290049050611dc2565b8084116122e457600080fd5b6000848688096000868103871696879004966002600389028118808a02820302808a02820302808a02820302808a02820302808a02820302808a02909103029181900381900460010186841190950394909402919094039290920491909117919091029150509392505050565b6060824710156123b25760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b60648201526084016109e4565b600080866001600160a01b031685876040516123ce9190612a40565b60006040518083038185875af1925050503d806000811461240b576040519150601f19603f3d011682016040523d82523d6000602084013e612410565b606091505b50915091506124218783838761243b565b979650505050505050565b6060611e338484600085612351565b606083156124aa5782516000036124a3576001600160a01b0385163b6124a35760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016109e4565b5081611e33565b611e3383838151156124bf5781518083602001fd5b8060405162461bcd60e51b81526004016109e491906129e0565b6000602082840312156124eb57600080fd5b81356001600160e01b031981168114611dc257600080fd5b6001600160a01b038116811461080d57600080fd5b803561252381612503565b919050565b60006020828403121561253a57600080fd5b8135611dc281612503565b6000806040838503121561255857600080fd5b823561256381612503565b9150602083013561257381612503565b809150509250929050565b60006020828403121561259057600080fd5b5035919050565b600080604083850312156125aa57600080fd5b82359150602083013561257381612503565b634e487b7160e01b600052604160045260246000fd5b60405160e0810167ffffffffffffffff8111828210171561260357634e487b7160e01b600052604160045260246000fd5b60405290565b60405160a0810167ffffffffffffffff8111828210171561260357634e487b7160e01b600052604160045260246000fd5b60008083601f84011261264c57600080fd5b50813567ffffffffffffffff81111561266457600080fd5b60208301915083602082850101111561229857600080fd5b600080600083850361010081121561269357600080fd5b60e08112156126a157600080fd5b506126aa6125d2565b84356126b581612503565b81526020858101359082015260408501356126cf81612503565b60408201526060858101359082015260808501356126ec81612503565b608082015260a08501356126ff81612503565b60a082015261271060c08601612518565b60c0820152925060e084013567ffffffffffffffff81111561273157600080fd5b61273d8682870161263a565b9497909650939450505050565b6000806040838503121561275d57600080fd5b823561276881612503565b946020939093013593505050565b801515811461080d57600080fd5b803563ffffffff8116811461252357600080fd5b60008082840360c08112156127ac57600080fd5b83356127b781612503565b925060a0601f19820112156127cb57600080fd5b506127d4612609565b60208401356127e281612776565b81526127f060408501612784565b602082015261280160608501612784565b604082015261281260808501612784565b606082015260a08401356001600160801b038116811461283157600080fd5b6080820152919491935090915050565b60008060006060848603121561285657600080fd5b833561286181612503565b925060208401359150604084013561287881612503565b809150509250925092565b634e487b7160e01b600052601160045260246000fd5b600082198211156128ac576128ac612883565b500190565b6000602082840312156128c357600080fd5b8151611dc281612776565b6000602082840312156128e057600080fd5b5051919050565b6000828210156128f9576128f9612883565b500390565b600081600019048311821515161561291857612918612883565b500290565b60008261293a57634e487b7160e01b600052601260045260246000fd5b500490565b60005b8381101561295a578181015183820152602001612942565b83811115611bdb5750506000910152565b7f416363657373436f6e74726f6c3a206163636f756e74200000000000000000008152600083516129a381601785016020880161293f565b7001034b99036b4b9b9b4b733903937b6329607d1b60179184019182015283516129d481602884016020880161293f565b01602801949350505050565b60208152600082518060208401526129ff81604085016020870161293f565b601f01601f19169190910160400192915050565b634e487b7160e01b600052603260045260246000fd5b600081612a3857612a38612883565b506000190190565b60008251612a5281846020870161293f565b919091019291505056fe416464726573733a206c6f772d6c6576656c2063616c6c20776974682076616c7565206661696c6564a164736f6c634300080f000a496e697469616c697a61626c653a20636f6e7472616374206973206e6f742069000000000000000000000000000000000000000000000000000305120c0f2000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000120000000000000000000000000e5d47fc6186b77e314560adc435fb93495c357170000000000000000000000003330ee066fc570d56b4dff6de707c6a2998fd723000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000

Deployed Bytecode

0x6080604052600436106102295760003560e01c8063772f8c2d11610123578063a217fddf116100ab578063ce6b112f1161006f578063ce6b112f146106f6578063d1712ccb1461070d578063d547741f1461072d578063ec87621c1461074d578063ed9506381461078157610230565b8063a217fddf1461065d578063a61986d414610672578063bcd97c2514610692578063c4707686146106b2578063c75b3d41146106df57610230565b8063859806cc116100f2578063859806cc146105d15780638ac2e981146105e657806391d148541461060657806395c54f5a146106265780639e3692351461064657610230565b8063772f8c2d146104c357806379e65062146104f05780637cd5083f14610510578063825dc415146105b157610230565b80632f2ff15d116101b157806348d8b9a41161017557806348d8b9a4146104285780635c975abb1461043f57806369fe30e81461045757806375829def1461049057806376fece74146104b057610230565b80632f2ff15d14610395578063352c9dd6146103b557806336568abe146103d55780633c4ac4b8146103f55780633f979a9a1461040857610230565b8063162dfb0d116101f8578063162dfb0d146102e35780631bceb8d4146103035780631e2c0314146103305780631f041ec614610350578063248a9ca31461036557610230565b806301ffc9a71461023e57806307598f62146102735780630e18b681146102935780630f4fb373146102a857610230565b3661023057005b34801561023c57600080fd5b005b34801561024a57600080fd5b5061025e6102593660046124d9565b6107ba565b60405190151581526020015b60405180910390f35b34801561027f57600080fd5b5061023c61028e366004612528565b6107f1565b34801561029f57600080fd5b5061023c610810565b3480156102b457600080fd5b506102d56102c3366004612528565b60fe6020526000908152604090205481565b60405190815260200161026a565b3480156102ef57600080fd5b5061023c6102fe366004612545565b6108c6565b34801561030f57600080fd5b506102d561031e366004612528565b60fd6020526000908152604090205481565b34801561033c57600080fd5b5061023c61034b36600461257e565b6108dc565b34801561035c57600080fd5b5061023c6108ea565b34801561037157600080fd5b506102d561038036600461257e565b60009081526065602052604090206001015490565b3480156103a157600080fd5b5061023c6103b0366004612597565b6108fc565b3480156103c157600080fd5b5061023c6103d0366004612528565b610926565b3480156103e157600080fd5b5061023c6103f0366004612597565b610978565b61023c61040336600461267c565b6109f7565b34801561041457600080fd5b5061023c61042336600461274a565b610b75565b34801561043457600080fd5b506102d56101035481565b34801561044b57600080fd5b5060975460ff1661025e565b34801561046357600080fd5b506102d5610472366004612545565b61010060209081526000928352604080842090915290825290205481565b34801561049c57600080fd5b5061023c6104ab366004612528565b610bd2565b61023c6104be36600461267c565b610c44565b3480156104cf57600080fd5b506102d56104de366004612528565b60fc6020526000908152604090205481565b3480156104fc57600080fd5b5061023c61050b36600461274a565b610d2d565b34801561051c57600080fd5b5061057361052b366004612528565b60fb6020526000908152604090205460ff81169063ffffffff6101008204811691600160281b8104821691600160481b820416906001600160801b03600160681b9091041685565b60408051951515865263ffffffff94851660208701529284169285019290925290911660608301526001600160801b0316608082015260a00161026a565b3480156105bd57600080fd5b5061023c6105cc366004612798565b610d8a565b3480156105dd57600080fd5b5061023c610ed0565b3480156105f257600080fd5b5061023c610601366004612545565b610ee0565b34801561061257600080fd5b5061025e610621366004612597565b610f8c565b34801561063257600080fd5b5061023c61064136600461257e565b610fb7565b34801561065257600080fd5b506102d56101045481565b34801561066957600080fd5b506102d5600081565b34801561067e57600080fd5b5061023c61068d366004612528565b610fe9565b34801561069e57600080fd5b5061023c6106ad36600461257e565b611044565b3480156106be57600080fd5b506102d56106cd366004612528565b60ff6020526000908152604090205481565b3480156106eb57600080fd5b506102d56101025481565b34801561070257600080fd5b506102d56101015481565b34801561071957600080fd5b5061023c610728366004612841565b611076565b34801561073957600080fd5b5061023c610748366004612597565b611089565b34801561075957600080fd5b506102d57f241ecf16d79d0f8dbfb92cbc07fe17840425976cf0667f022fe9877caa831b0881565b34801561078d57600080fd5b50610107546107a2906001600160a01b031681565b6040516001600160a01b03909116815260200161026a565b60006001600160e01b03198216637965db0b60e01b14806107eb57506301ffc9a760e01b6001600160e01b03198316145b92915050565b6107f96110bd565b6108033382611116565b61080d600160c955565b50565b610105546001600160a01b0316331461083c5760405163058d9a1b60e01b815260040160405180910390fd5b61010654610855906000906001600160a01b0316611253565b6108606000336112ba565b61010654604080516001600160a01b0390921682523360208301527f70994a41fc1886170c6242f151e958b9329102a0efaae1daa60c82cd5aea11c7910160405180910390a161010580546001600160a01b031990811690915561010680549091169055565b6108ce611340565b6108d88282611116565b5050565b6108e4611340565b61010355565b6108f2611340565b6108fa611398565b565b600082815260656020526040902060010154610917816113f2565b61092183836112ba565b505050565b61092e6113fc565b6001600160a01b0381166109555760405163d92e233d60e01b815260040160405180910390fd5b61010780546001600160a01b0319166001600160a01b0392909216919091179055565b6001600160a01b03811633146109ed5760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b60648201526084015b60405180910390fd5b6108d88282611253565b6109ff6110bd565b610a07611424565b8260c00151610a158161146a565b610a27846000015185602001516114f6565b602085810191825260a080870180516001600160a01b0316600090815260fb84526040808220815194850182525460ff811615158552610100810463ffffffff90811696860196909652600160281b8104861691850191909152600160481b81049094166060840152600160681b9093046001600160801b0316608083015251925187519193610abc93909285929190611621565b602086015260a0850151610ad0908261172e565b50610adc85858561182e565b7f2bc450c6200674bc17d097f338cb6e2ef4c5d48e2d0049bd5905fa426bc42c7085604051610b61919081516001600160a01b039081168252602080840151908301526040808401518216908301526060808401519083015260808084015182169083015260a08381015182169083015260c092830151169181019190915260e00190565b60405180910390a15050610921600160c955565b610b7d611340565b6001600160a01b038216600090815260fd6020526040902054811015610bb657604051635909a3b560e11b815260040160405180910390fd5b6001600160a01b03909116600090815260fe6020526040902055565b610bda6113fc565b61010580546001600160a01b03199081166001600160a01b0384169081179092556101068054339216821790556040805191825260208201929092527f551692d6181925be42a9902ebd0f1268341087490ad9b895558cd9e53031c5d2910160405180910390a150565b610c4c6110bd565b610c54611424565b8260c00151610c628161146a565b83516001600160a01b031615610c8b5760405163e59e4d6960e01b815260040160405180910390fd5b60a080850180516001600160a01b0316600090815260fb6020908152604091829020825194850183525460ff81161515855263ffffffff6101008204811692860192909252600160281b8104821692850192909252600160481b82041660608401526001600160801b03600160681b90910416608083015251610d1d9082610d13828261172e565b8851600090611621565b6020860152610adc858585611a07565b610d35611340565b6001600160a01b038216600090815260fe6020526040902054811115610d6e5760405163129c63a160e31b815260040160405180910390fd5b6001600160a01b03909116600090815260fd6020526040902055565b610d92611340565b620f4240816020015163ffffffff161115610dc05760405163cd4e616760e01b815260040160405180910390fd5b620f4240816040015163ffffffff161180610de75750620f4240816060015163ffffffff16115b15610e0557604051630a81ff1360e21b815260040160405180910390fd5b6001600160a01b03909116600090815260fb602090815260409182902083518154928501519385015160608601516080909601516001600160801b0316600160681b026fffffffffffffffffffffffffffffffff60681b1963ffffffff978816600160481b026cffffffff00000000000000000019938916600160281b02939093166cffffffffffffffff000000000019989097166101000264ffffffff00199415159490941664ffffffffff19909616959095179290921795909516939093179390931716179055565b610ed8611340565b6108fa611ab2565b610ee86113fc565b6001600160a01b038216600090815260ff602052604081205490819003610f2257604051631f2a200560e01b815260040160405180910390fd5b6001600160a01b038316600090815260ff6020526040812055610f46838284611aeb565b604080518281526001600160a01b03851660208201527f9216fa2f918153a5852ce98e7929c12cd94e0adeda8117f80e761c216157b27c910160405180910390a1505050565b60009182526065602090815260408084206001600160a01b0393909316845291905290205460ff1690565b610fbf611340565b61010154811115610fe35760405163cd4e616760e01b815260040160405180910390fd5b61010255565b610ff16113fc565b610104805460009182905590611008908284611aeb565b604080518281523360208201527f445ea353dd3cfa91aaa8ea899f31ffb4d03e783c45f0ef3717b46c32ea17969d910160405180910390a15050565b61104c6113fc565b620f42408111156110705760405163cd4e616760e01b815260040160405180910390fd5b61010155565b61107e6113fc565b610921838383611aeb565b6000828152606560205260409020600101546110a4816113f2565b6109218383611253565b6001600160a01b03163b151590565b600260c9540361110f5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016109e4565b600260c955565b60006001600160a01b03821661118157506001600160a01b038216600081815260fc60209081526040808320805493905580518381529182019390935290917f445ea353dd3cfa91aaa8ea899f31ffb4d03e783c45f0ef3717b46c32ea17969d910160405180910390a15b6001600160a01b03808316600090815261010060209081526040808320938716835292905220546111b29082612899565b9050806000036111d557604051631f2a200560e01b815260040160405180910390fd5b6001600160a01b03808316600090815261010060209081526040808320938716835292905290812055611209828285611aeb565b604080518281526001600160a01b0384811660208301528516917f6f83ca8ce48e63b2a223b9f9e7ef1ea7bf3a8385c7a9bd63baae22963b2b26e0910160405180910390a2505050565b61125d8282610f8c565b156108d85760008281526065602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b6112c48282610f8c565b6108d85760008281526065602090815260408083206001600160a01b03851684529091529020805460ff191660011790556112fc3390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b61136a7f241ecf16d79d0f8dbfb92cbc07fe17840425976cf0667f022fe9877caa831b0833610f8c565b8061137b575061137b600033610f8c565b6108fa57604051633a4af34560e21b815260040160405180910390fd5b6113a0611424565b6097805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586113d53390565b6040516001600160a01b03909116815260200160405180910390a1565b61080d8133611b17565b611407600033610f8c565b6108fa576040516355098f2760e01b815260040160405180910390fd5b60975460ff16156108fa5760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b60448201526064016109e4565b6101075460405163ae19ae2b60e01b81526001600160a01b0383811660048301529091169063ae19ae2b90602401602060405180830381865afa1580156114b5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114d991906128b1565b61080d5760405163442fd07160e11b815260040160405180910390fd5b60006001600160a01b03831661151f5760405163ad1991f560e01b815260040160405180910390fd5b6040516370a0823160e01b81523060048201526000906001600160a01b038516906370a0823190602401602060405180830381865afa158015611566573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061158a91906128ce565b90506115a16001600160a01b038516333086611b70565b6040516370a0823160e01b81523060048201526000906001600160a01b038616906370a0823190602401602060405180830381865afa1580156115e8573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061160c91906128ce565b905061161882826128e7565b95945050505050565b6000806000611631878787611be1565b90925090506001600160a01b0388161561168d5761164f81836128e7565b6001600160a01b03808616600090815261010060209081526040808320938d1683529290529081208054909190611687908490612899565b90915550505b6001600160a01b038416600090815260ff6020526040812080548392906116b5908490612899565b90915550506001600160a01b0388167f25471ec9f39b4ceb20d58f63c37f9c738011f0babcc4b6af69bdd82984ca5f8e826116f081866128e7565b6040805192835260208301919091526001600160a01b0388169082015260600160405180910390a261172282876128e7565b98975050505050505050565b60008060008360000151156117b65760808401516001600160801b0316915081156117b157620f4240846060015163ffffffff168361176d91906128fe565b611777919061291d565b905061178381836128e7565b6001600160a01b038616600090815260fc6020526040812080549091906117ab908490612899565b90915550505b6117be565b505061010354805b8061010460008282546117d19190612899565b90915550506001600160a01b0385167f3a84e53f89d2f7779a9c9a54779858ae0eb0b7760d607b445b6fd175c30a04d48261180c81866128e7565b6040805192835260208301919091520160405180910390a261161882346128e7565b60c08301516020840151845161184f926001600160a01b0390911691611c21565b600061186384608001518560400151611d36565b84516040516370a0823160e01b81523060048201529192506000916001600160a01b03909116906370a0823190602401602060405180830381865afa1580156118b0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118d491906128ce565b905061191a8560c0015185858080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250611dc992505050565b50600061192f86608001518760400151611d36565b86516040516370a0823160e01b81523060048201529192506000916001600160a01b03909116906370a0823190602401602060405180830381865afa15801561197c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119a091906128ce565b60208801519091506119b282856128e7565b146119d05760405163119e050560e01b815260040160405180910390fd5b60608701516119df85846128e7565b10156119fe5760405163db047cd960e01b815260040160405180910390fd5b50505050505050565b6000611a1b84608001518560400151611d36565b9050611a658460c0015184848080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152505050506020870151611e0d565b506000611a7a85608001518660400151611d36565b6060860151909150611a8c83836128e7565b1015611aab5760405163db047cd960e01b815260040160405180910390fd5b5050505050565b611aba611e3b565b6097805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa336113d5565b6001600160a01b038316611b03576109218183611e84565b6109216001600160a01b0384168284611f9d565b611b218282610f8c565b6108d857611b2e81611fcd565b611b39836020611fdf565b604051602001611b4a92919061296b565b60408051601f198184030181529082905262461bcd60e51b82526109e4916004016129e0565b6040516001600160a01b0380851660248301528316604482015260648101829052611bdb9085906323b872dd60e01b906084015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b03199093169290921790915261217b565b50505050565b600080846000015115611c0257611bf8848661224d565b9092509050611c19565b611c138461010254620f424061229f565b91508190505b935093915050565b801580611c9b5750604051636eb1769f60e11b81523060048201526001600160a01b03838116602483015284169063dd62ed3e90604401602060405180830381865afa158015611c75573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c9991906128ce565b155b611d065760405162461bcd60e51b815260206004820152603660248201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60448201527520746f206e6f6e2d7a65726f20616c6c6f77616e636560501b60648201526084016109e4565b6040516001600160a01b03831660248201526044810182905261092190849063095ea7b360e01b90606401611ba4565b60006001600160a01b03821615611db6576040516370a0823160e01b81526001600160a01b0384811660048301528316906370a0823190602401602060405180830381865afa158015611d8d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611db191906128ce565b611dc2565b826001600160a01b0316315b9392505050565b6060611dc2838360006040518060400160405280601e81526020017f416464726573733a206c6f772d6c6576656c2063616c6c206661696c65640000815250612351565b6060611e33848484604051806060016040528060298152602001612a5d60299139612351565b949350505050565b60975460ff166108fa5760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b60448201526064016109e4565b80471015611ed45760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a20696e73756666696369656e742062616c616e636500000060448201526064016109e4565b6000826001600160a01b03168260405160006040518083038185875af1925050503d8060008114611f21576040519150601f19603f3d011682016040523d82523d6000602084013e611f26565b606091505b50509050806109215760405162461bcd60e51b815260206004820152603a60248201527f416464726573733a20756e61626c6520746f2073656e642076616c75652c207260448201527f6563697069656e74206d6179206861766520726576657274656400000000000060648201526084016109e4565b6040516001600160a01b03831660248201526044810182905261092190849063a9059cbb60e01b90606401611ba4565b60606107eb6001600160a01b03831660145b60606000611fee8360026128fe565b611ff9906002612899565b67ffffffffffffffff811115612011576120116125bc565b6040519080825280601f01601f19166020018201604052801561203b576020820181803683370190505b509050600360fc1b8160008151811061205657612056612a13565b60200101906001600160f81b031916908160001a905350600f60fb1b8160018151811061208557612085612a13565b60200101906001600160f81b031916908160001a90535060006120a98460026128fe565b6120b4906001612899565b90505b600181111561212c576f181899199a1a9b1b9c1cb0b131b232b360811b85600f16601081106120e8576120e8612a13565b1a60f81b8282815181106120fe576120fe612a13565b60200101906001600160f81b031916908160001a90535060049490941c9361212581612a29565b90506120b7565b508315611dc25760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e7460448201526064016109e4565b60006121d0826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b031661242c9092919063ffffffff16565b80519091501561092157808060200190518101906121ee91906128b1565b6109215760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b60648201526084016109e4565b6000806000836020015163ffffffff1611156122985761227b84846020015163ffffffff16620f424061229f565b915061229582846040015163ffffffff16620f424061229f565b90505b9250929050565b60008080600019858709858702925082811083820303915050806000036122d857600084116122cd57600080fd5b508290049050611dc2565b8084116122e457600080fd5b6000848688096000868103871696879004966002600389028118808a02820302808a02820302808a02820302808a02820302808a02820302808a02909103029181900381900460010186841190950394909402919094039290920491909117919091029150509392505050565b6060824710156123b25760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b60648201526084016109e4565b600080866001600160a01b031685876040516123ce9190612a40565b60006040518083038185875af1925050503d806000811461240b576040519150601f19603f3d011682016040523d82523d6000602084013e612410565b606091505b50915091506124218783838761243b565b979650505050505050565b6060611e338484600085612351565b606083156124aa5782516000036124a3576001600160a01b0385163b6124a35760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016109e4565b5081611e33565b611e3383838151156124bf5781518083602001fd5b8060405162461bcd60e51b81526004016109e491906129e0565b6000602082840312156124eb57600080fd5b81356001600160e01b031981168114611dc257600080fd5b6001600160a01b038116811461080d57600080fd5b803561252381612503565b919050565b60006020828403121561253a57600080fd5b8135611dc281612503565b6000806040838503121561255857600080fd5b823561256381612503565b9150602083013561257381612503565b809150509250929050565b60006020828403121561259057600080fd5b5035919050565b600080604083850312156125aa57600080fd5b82359150602083013561257381612503565b634e487b7160e01b600052604160045260246000fd5b60405160e0810167ffffffffffffffff8111828210171561260357634e487b7160e01b600052604160045260246000fd5b60405290565b60405160a0810167ffffffffffffffff8111828210171561260357634e487b7160e01b600052604160045260246000fd5b60008083601f84011261264c57600080fd5b50813567ffffffffffffffff81111561266457600080fd5b60208301915083602082850101111561229857600080fd5b600080600083850361010081121561269357600080fd5b60e08112156126a157600080fd5b506126aa6125d2565b84356126b581612503565b81526020858101359082015260408501356126cf81612503565b60408201526060858101359082015260808501356126ec81612503565b608082015260a08501356126ff81612503565b60a082015261271060c08601612518565b60c0820152925060e084013567ffffffffffffffff81111561273157600080fd5b61273d8682870161263a565b9497909650939450505050565b6000806040838503121561275d57600080fd5b823561276881612503565b946020939093013593505050565b801515811461080d57600080fd5b803563ffffffff8116811461252357600080fd5b60008082840360c08112156127ac57600080fd5b83356127b781612503565b925060a0601f19820112156127cb57600080fd5b506127d4612609565b60208401356127e281612776565b81526127f060408501612784565b602082015261280160608501612784565b604082015261281260808501612784565b606082015260a08401356001600160801b038116811461283157600080fd5b6080820152919491935090915050565b60008060006060848603121561285657600080fd5b833561286181612503565b925060208401359150604084013561287881612503565b809150509250925092565b634e487b7160e01b600052601160045260246000fd5b600082198211156128ac576128ac612883565b500190565b6000602082840312156128c357600080fd5b8151611dc281612776565b6000602082840312156128e057600080fd5b5051919050565b6000828210156128f9576128f9612883565b500390565b600081600019048311821515161561291857612918612883565b500290565b60008261293a57634e487b7160e01b600052601260045260246000fd5b500490565b60005b8381101561295a578181015183820152602001612942565b83811115611bdb5750506000910152565b7f416363657373436f6e74726f6c3a206163636f756e74200000000000000000008152600083516129a381601785016020880161293f565b7001034b99036b4b9b9b4b733903937b6329607d1b60179184019182015283516129d481602884016020880161293f565b01602801949350505050565b60208152600082518060208401526129ff81604085016020870161293f565b601f01601f19169190910160400192915050565b634e487b7160e01b600052603260045260246000fd5b600081612a3857612a38612883565b506000190190565b60008251612a5281846020870161293f565b919091019291505056fe416464726573733a206c6f772d6c6576656c2063616c6c20776974682076616c7565206661696c6564a164736f6c634300080f000a

Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)

000000000000000000000000000000000000000000000000000305120c0f2000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000120000000000000000000000000e5d47fc6186b77e314560adc435fb93495c357170000000000000000000000003330ee066fc570d56b4dff6de707c6a2998fd723000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000

-----Decoded View---------------
Arg [0] : _fixedCryptoFee (uint256): 850000000000000
Arg [1] : _RubicPlatformFee (uint256): 0

-----Encoded View---------------
10 Constructor Arguments found :
Arg [0] : 000000000000000000000000000000000000000000000000000305120c0f2000
Arg [1] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [2] : 00000000000000000000000000000000000000000000000000000000000000e0
Arg [3] : 0000000000000000000000000000000000000000000000000000000000000100
Arg [4] : 0000000000000000000000000000000000000000000000000000000000000120
Arg [5] : 000000000000000000000000e5d47fc6186b77e314560adc435fb93495c35717
Arg [6] : 0000000000000000000000003330ee066fc570d56b4dff6de707c6a2998fd723
Arg [7] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [8] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [9] : 0000000000000000000000000000000000000000000000000000000000000000


Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

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

Validator Index Block Amount
View All Withdrawals

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits
Loading...
Loading
[ Download: CSV Export  ]
[ 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.