Contract 0xc0d9c2de3a341e1df38910c46c08f1c0ce07356f

Txn Hash Method
Block
From
To
Value [Txn Fee]
0x8e7fe414a1205ad90e391edf137cddb1b606b726a795d9a95bf8d0fcad029f110x60a0604033460552022-06-22 3:59:48104 days 9 hrs ago0x0132613b3a1061816f4661ad301612910e3cce0b IN  Create: YPoolVault0 CRO16.7725919626680
[ Download CSV Export 
Parent Txn Hash Block From To Value
Loading
This contract may be a proxy contract. Click on More Options and select Is this a proxy? to confirm and enable the "Read as Proxy" & "Write as Proxy" tabs.

Contract Source Code Verified (Exact Match)

Contract Name:
YPoolVault

Compiler Version
v0.8.2+commit.661d1103

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion, None license
File 1 of 23 : YPoolVault.sol
// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.2;

import "AccessControlUpgradeable.sol";
import "UUPSUpgradeable.sol";
import "PausableUpgradeable.sol";
import "SafeERC20.sol";
import "ERC20.sol";
import { Address } from "Address.sol";
import { XYWrappedToken } from "XYWrappedToken.sol";
import "IGasPriceConsumer.sol";

/// @title YPoolVault provides cross-chain liquidity for swap between chains.
/// Users are allowed to supply the designated deposit token to the pool to earn
/// cross-chain swap fees, and request to withdraw anytime.
contract YPoolVault is AccessControlUpgradeable, UUPSUpgradeable, PausableUpgradeable {
    using SafeERC20 for IERC20;

    /* ========== STRUCTURE ========== */

    // request to deposit
    struct DepositRequest {
        // amount of the deposit token
        uint256 amountDepositToken;
        // depositor
        address sender;
        // is the request completed yet
        bool isComplete;
    }

    // request to withdraw
    struct WithdrawalRequest {
        // amount of xy-wrapped token to be withdrawn
        uint256 amountXYWrappedToken;
        // withdrawer
        address sender;
        // is the request completed yet
        bool isComplete;
    }

    /* ========== STATE VARIABLES ========== */

    // Roles in this contract
    // Owner: able to upgrade contract and change swapper contract address
    bytes32 public constant ROLE_OWNER = keccak256("ROLE_OWNER");
    // Manager: able to pause/unpause contract, set gas provider / gas collector address
    bytes32 public constant ROLE_MANAGER = keccak256("ROLE_MANAGER");
    // Staff: able to set required gas for different requests
    bytes32 public constant ROLE_STAFF = keccak256("ROLE_STAFF");
    // Liquidity Worker: complete the requests
    bytes32 public constant ROLE_LIQUIDITY_WORKER = keccak256("ROLE_LIQUIDITY_WORKER");

    // Native token address
    address public constant ETHER_ADDRESS = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;

    // XY token deciamls
    uint256 public constant XY_TOKEN_DECIMALS = 18;
    // Yield rate decimals
    uint256 public constant YIELD_RATE_DECIMALS = 8;
    // Base point (the denominator) of the reserves ratio. 1 base point means 0.01%.
    uint256 public constant BASE_POINT_RESERVES_RATIO = 10000;

    // Max yield rate bound of deposit/withdraw
    uint256 public maxYieldRateBound;
    // Min yield rate bound of deposit/withdraw
    uint256 public minYieldRateBound;

    // Swapper address
    address public swapper;
    // The address receive the collected gas fee
    address public gasFeeReceiver;
    // The address of token to deposit
    IERC20 public depositToken;
    // Deposit token decimal
    uint8 public depositTokenDecimal;
    // XY-Wrapped token address
    XYWrappedToken public xyWrappedToken;

    // Address of gas consumer
    address public gasPriceConsumer;
    // Gas limit that YPool need to proceed deposit request
    uint256 public completeDepositGasLimit;
    // Gas limit that YPool need to proceed withdraw request
    uint256 public completeWithdrawGasLimit;
    // Current fees collected from deposit and withdraw request gas fee
    uint256 public depositAndWithdrawFees;
    // Swap fees current accumulated
    uint256 public closeSwapGasFees;
    // Number of the deposits
    uint256 public numDeposits;
    // Number of the withdrawal
    uint256 public numWithdrawals;

    // The numerator of the reserves ratio. Reserves ratio is the ratio of XY Fee kept by Y Pool as reserves,
    // and is calcuated by `reservesRate / BASE_POINT_RESERVES_RATIO`.
    // For example, if `reservesRate` is 1, the reserves ratio is `1 / BASE_POINT_RESERVES_RATIO = 0.01%`.
    uint256 public reservesRate;
    // Address who receives the reserves.
    address public reservesReceiver;

    // Mapping of the depsit ID to deposit request struct
    mapping (uint256 => DepositRequest) public depositRequests;
    // Mapping of the withdraw ID to withdraw request struct
    mapping (uint256 => WithdrawalRequest) public withdrawalRequests;

    receive() external payable {}

    function _authorizeUpgrade(address) internal override onlyRole(ROLE_OWNER) {}

    /// @notice Initialize YPoolVault by owner, manager, staff, liquidity worker, deposit token address, wrapped token address, and deposit token decimal
    /// @param owner The owner address
    /// @param manager The manager address
    /// @param staff The staff address
    /// @param liquidityWorker The liquidity worker address
    /// @param _depositToken The deposit token address
    /// @param _xyWrappedToken The XY-Wrapped token address
    /// @param _depositTokenDecimal The deposit token decimal
    function initialize(address owner, address manager, address staff, address liquidityWorker, address _depositToken, address _xyWrappedToken, uint8 _depositTokenDecimal) initializer public {
        if (_depositToken != ETHER_ADDRESS) {
            require(Address.isContract(_depositToken), "ERR_DEPOSIT_TOKEN_NOT_CONTRACT");
        }
        require(Address.isContract(_xyWrappedToken), "ERR_XY_WRPAPPED_TOKEN_NOT_CONTRACT");
        depositToken = IERC20(_depositToken);
        xyWrappedToken = XYWrappedToken(_xyWrappedToken);

        depositTokenDecimal = _depositTokenDecimal;

        _setRoleAdmin(ROLE_OWNER, ROLE_OWNER);
        _setRoleAdmin(ROLE_MANAGER, ROLE_OWNER);
        _setRoleAdmin(ROLE_STAFF, ROLE_OWNER);
        _setRoleAdmin(ROLE_LIQUIDITY_WORKER, ROLE_OWNER);
        _setupRole(ROLE_OWNER, owner);
        _setupRole(ROLE_MANAGER, manager);
        _setupRole(ROLE_STAFF, staff);
        _setupRole(ROLE_LIQUIDITY_WORKER, liquidityWorker);
    }

    /* ========== MODIFIERS ========== */

    modifier onlySwapper() {
        require(msg.sender == swapper, "ERR_NOT_SWAPPER");
        _;
    }

    /* ========== PRIVATE FUNCTIONS ========== */

    /// @notice Get currnet gas price from price consumer
    function _getGasPrice() private view returns (uint256) {
        require(gasPriceConsumer != address(0), "ERR_GAS_PRICE_CONSUMER_NOT_SET");
        return uint256(IGasPriceConsumer(gasPriceConsumer).getLatestGasPrice());
    }

    /// @notice Unify transfer interface for native token and ERC20 token
    /// @param receiver The address to reveice token
    /// @param token The token to be transferred
    /// @param amount Amount of the token to be transferred
    function _safeTransferAsset(address receiver, IERC20 token, uint256 amount) private {
        if (address(token) == ETHER_ADDRESS) {
            payable(receiver).transfer(amount);
        } else {
            token.safeTransfer(receiver, amount);
        }
    }

    /// @notice Transfer ERC20 token from sender to receiver
    /// @param token The token to be transferred
    /// @param sender The address to transfer token from
    /// @param receiver The address to receive token
    /// @param amount Amount of the token to be transferred
    function _safeTransferAssetFrom(IERC20 token, address sender, address receiver, uint256 amount) private {
        require(address(token) != ETHER_ADDRESS, "ERR_TOKEN_ADDRESS");
        uint256 bal = token.balanceOf(receiver);
        token.safeTransferFrom(sender, receiver, amount);
        bal = token.balanceOf(receiver) - bal;
        require(bal == amount, "ERR_AMOUNT_NOT_ENOUGH");
    }

    /// @notice Transfer collected deposit and withdraw request fees to receiver
    /// @param receiver The address to receive fees
    function _collectDepositAndWithdrawGasFees(address receiver) private {
        uint256 _depositAndWithdrawFees = depositAndWithdrawFees;
        depositAndWithdrawFees = 0;
        payable(receiver).transfer(_depositAndWithdrawFees);
        emit DepositAndWithdrawGasFeesCollected(receiver, _depositAndWithdrawFees);
    }

    /// @notice Transfer collected swap fees to receiver
    /// @param receiver The address to receive fees
    function _collectCloseSwapGasFees(address receiver) private {
        uint256 _closeSwapGasFees = closeSwapGasFees;
        closeSwapGasFees = 0;
        if (address(depositToken) == ETHER_ADDRESS) {
            payable(receiver).transfer(_closeSwapGasFees);
        } else {
            depositToken.safeTransfer(receiver, _closeSwapGasFees);
        }
        emit CloseSwapGasFeesCollected(depositToken, receiver, _closeSwapGasFees);
    }

    /* ========== RESTRICTED FUNCTIONS (OWNER) ========== */

    /// @notice Connect YPoolVault to a certain XSwapper (could be set only by owner)
    /// @param _swapper New swapper address
    function setSwapper(address _swapper) external onlyRole(ROLE_OWNER) {
        require(Address.isContract(_swapper), "ERR_SWAPPER_NOT_CONTRACT");
        swapper = _swapper;
    }

    /// @notice Rescue fund accidentally sent to this contract. Can not rescue deposit token or xyWrappedToken
    /// @param tokens List of token address to rescue
    function rescue(IERC20[] memory tokens) external onlyRole(ROLE_OWNER) {
        for (uint256 i; i < tokens.length; i++) {
            IERC20 token = tokens[i];
            require(token != depositToken, "ERR_CAN_NOT_RESCUE_DEPOSIT_TOKEN");
            require(address(token) != address(xyWrappedToken), "ERR_CAN_NOT_RESCUE_XY_WRAPPED_TOKEN");
            uint256 _tokenBalance = token.balanceOf(address(this));
            token.safeTransfer(msg.sender, _tokenBalance);
        }
    }

    /* ========== RESTRICTED FUNCTIONS (MANAGER) ========== */

    /// @notice Set new gas fee receiver. This address receives fees accumulated from deposit / withdraw
    /// requests and swap fees when staff role calls one of the collect fee methods. (could be set only by manager)
    /// @param _gasFeeReceiver New gas receiver address
    function setGasFeeReceiver(address _gasFeeReceiver) external onlyRole(ROLE_MANAGER) {
        gasFeeReceiver = _gasFeeReceiver;
    }

    /// @notice Set the reserves rate. Reserves rate is the numerator of the reserves ratio.
    /// @dev Can only be called by `ROLE_MANAGER`
    /// @param _reservesRate New reserves rate
    function setReservesRate(uint256 _reservesRate) external onlyRole(ROLE_MANAGER) {
        require(_reservesRate <= BASE_POINT_RESERVES_RATIO, "ERR_RESERVES_RATIO_NOT_LESS_THAN_OR_EQUAL_1");
        reservesRate = _reservesRate;
        emit ReservesRateSet(_reservesRate);
    }

    /// @notice Set reserves receiver. This address receives a portion of xy fees accumulated from cross-chain swaps
    /// @dev Can only be called by `ROLE_MANAGER`
    /// @param _reservesReceiver New reserves receiver address
    function setReservesReceiver(address _reservesReceiver) external onlyRole(ROLE_MANAGER) {
        require(_reservesReceiver != address(0), "ERR_ZERO_ADDRESS");
        reservesReceiver = _reservesReceiver;
        emit ReservesReceiverSet(_reservesReceiver);
    }

    /// @notice Set new gas price consumer address that conforms to `IGasPriceConsumer` protocol (could be set only by manager)
    /// @param _gasPriceConsumer New gas price consumer address
    function setGasPriceConsumer(address _gasPriceConsumer) external onlyRole(ROLE_MANAGER) {
        require(Address.isContract(_gasPriceConsumer), "ERR_GAS_PRICE_CONSUMER_NOT_CONTRACT");
        gasPriceConsumer = _gasPriceConsumer;
    }

    /// @notice Set maximum and minimum value of yield rate bound. (could be set only by manager)
    /// These bounds are to make sure the withdraw amount and deposit amount are within a safe range of yields
    /// as unexpected amounts would lead to false yield rate.
    /// This is particularly useful if the Y Pool worker is unfortunately compromised in the worst case.
    /// The bounds can be loosened gradually if there are more fees accumulated and the yield rate has increased.
    /// @param _maxYieldRateBound Maximum yield rate bound
    /// @param _minYieldRateBound Minimum yield rate bound
    function setYieldRateBound(uint256 _maxYieldRateBound, uint256 _minYieldRateBound) external onlyRole(ROLE_MANAGER) {
        require(_maxYieldRateBound >= 10 ** YIELD_RATE_DECIMALS);
        maxYieldRateBound = _maxYieldRateBound;
        minYieldRateBound = _minYieldRateBound;
    }

    /// @notice Pause YPool vault (could be executed only by manager)
    function pause() external onlyRole(ROLE_MANAGER) {
        _pause();
    }

    /// @notice Unpause YPool vault (could be executed only by manager)
    function unpause() external onlyRole(ROLE_MANAGER) {
        _unpause();
    }

    /* ========== RESTRICTED FUNCTIONS (STAFF) ========== */

    /// @notice Set deposit gas limit. This is one of the factors to determine how much gas fee should user paid
    /// upon the deposit request. (could be set only by staff)
    /// @dev Request fee is calculated as `completeDepositGasLimit` * gas price provided from `gasPriceConsumer`
    /// @param gasLimit New deposit gas limit
    function setCompleteDepositGasLimit(uint256 gasLimit) external onlyRole(ROLE_STAFF) {
        completeDepositGasLimit = gasLimit;
    }

    /// @notice Set withdraw gas limit. This is one of the factors to determine how much gas fee should user paid
    /// upon the withdraw request. (could be set only by staff)
    /// @dev Request fee is calculated as `completeWithdrawGasLimit` * gas price provided from `gasPriceConsumer`
    /// @param gasLimit New withdraw gas limit
    function setCompleteWithdrawGasLimit(uint256 gasLimit) external onlyRole(ROLE_STAFF) {
        completeWithdrawGasLimit = gasLimit;
    }

    /// @notice Transfer current accumulated deposit / withdraw request fees to `gasFeeReceiver` (could be executed only by staff)
    function collectDepositAndWithdrawGasFees() external whenNotPaused onlyRole(ROLE_STAFF) {
        _collectDepositAndWithdrawGasFees(gasFeeReceiver);
    }

    /// @notice Transfer current accumulated swap fees to `gasFeeReceiver` (could be executed only by staff)
    function collectCloseSwapGasFees() external whenNotPaused onlyRole(ROLE_STAFF) {
        _collectCloseSwapGasFees(gasFeeReceiver);
    }

    /// @notice Transfer current accumulated deposit / withdraw request fees and swap fees to `gasFeeReceiver` (could be executed only by staff)
    function collectFees() external whenNotPaused onlyRole(ROLE_STAFF) {
        _collectDepositAndWithdrawGasFees(gasFeeReceiver);
        _collectCloseSwapGasFees(gasFeeReceiver);
    }

    /* ========== RESTRICTED FUNCTIONS (SWAPPER) ========== */

    /// @notice Transfer token from YPool liquidity to swapper contract. (could be executed only by swapper)
    /// XSwapper calls this method within `closeSwap` to transfer token from YPool liquidity to swapper
    /// contract in order to close a cross-chain swap request. See XSwapper.sol for more info.
    /// @param token Token to be transferred
    /// @param amount Amount of token to be transferred
    function transferToSwapper(IERC20 token, uint256 amount) external whenNotPaused onlySwapper {
        require(token == depositToken, "ERR_TRANSFER_WRONG_TOKEN_TO_SWAPPER");
        emit TransferToSwapper(swapper, token, amount);
        _safeTransferAsset(swapper, token, amount);
    }

    /// @notice Transfer token from swapper contract to YPool. (could be executed only by swapper)
    /// XSwapper calls this method within `claim` or `batchClaim` to transfer token from XSwapper to YPool
    /// contract in order to claim token back to YPool after liquidity worker completed a cross-chain request.
    /// See XSwapper.sol for more info.
    /// @param token Token to be transferred
    /// @param amount Amount of token to be transferred
    /// @param xyFeeAmount Amount of xyFee colleted
    /// @param gasFeeAmount Amount of gas fee colleted
    function receiveAssetFromSwapper(IERC20 token, uint256 amount, uint256 xyFeeAmount, uint256 gasFeeAmount) external payable whenNotPaused onlySwapper {
        require(token == depositToken, "ERR_TRANSFER_WRONG_TOKEN_FROM_SWAPPER");
        if (address(token) == ETHER_ADDRESS) {
            require(msg.value == amount, "ERR_INVALID_AMOUNT");
        } else {
            _safeTransferAssetFrom(token, swapper, address(this), amount);
        }

        closeSwapGasFees += gasFeeAmount;

        uint256 xyFeeReserves = calculateReserves(xyFeeAmount);

        emit AssetReceived(token, amount, xyFeeAmount, gasFeeAmount, xyFeeReserves);

        _safeTransferAsset(reservesReceiver, token, xyFeeReserves);
    }

    /* ========== RESTRICTED FUNCTIONS (LIQUIDITY WORKER) ========== */

    /// @notice Complete a deposit request by minting XY-Wrapped tokens
    /// according to liquidity condition on settlement chain. (could be executed only by liquidity worker)
    /// @param _depositId The deposit ID to be processed
    /// @param amountXYWrappedToken Amount of XY-Wrapped token to be minted
    function completeDeposit(uint256 _depositId, uint256 amountXYWrappedToken) external whenNotPaused onlyRole(ROLE_LIQUIDITY_WORKER) {
        require(_depositId < numDeposits, "ERR_INVALID_DEPOSIT_ID");
        DepositRequest storage request = depositRequests[_depositId];
        require(!request.isComplete, "ERR_DEPOSIT_ALREADY_COMPLETE");
        // yield rate = (amount ypool token) / (amount wrapped token)
        require(request.amountDepositToken * 10 ** (YIELD_RATE_DECIMALS + XY_TOKEN_DECIMALS - depositTokenDecimal) / amountXYWrappedToken <= maxYieldRateBound, "ERR_YIELD_RATE_OUT_OF_MAX_BOUND");
        require(request.amountDepositToken * 10 ** (YIELD_RATE_DECIMALS + XY_TOKEN_DECIMALS - depositTokenDecimal) / amountXYWrappedToken >= minYieldRateBound, "ERR_YIELD_RATE_OUT_OF_MIN_BOUND");
        emit DepositFulfilled(request.sender, _depositId, amountXYWrappedToken);
        request.isComplete = true;
        xyWrappedToken.mint(request.sender, amountXYWrappedToken);
    }

    /// @notice Complete a withdraw request by burning XY-Wrapped tokens
    /// and transferring back deposit token according to liquidity condition on settlement chain
    /// (could be executed only by liquidity worker)
    /// @param _withdrawId The withdraw ID to be processed
    /// @param amount Amount of the deposit token to be returned to request sender
    /// @param withdrawFee Fee for completing withdraw request
    function completeWithdraw(uint256 _withdrawId, uint256 amount, uint256 withdrawFee) external whenNotPaused onlyRole(ROLE_LIQUIDITY_WORKER) {
        require(_withdrawId < numWithdrawals, "ERR_INVALID_WITHDRAW_ID");
        require(amount > 0, "ERR_WITHDRAW_FEE_NOT_LESS_THAN_AMOUNT");
        WithdrawalRequest storage request = withdrawalRequests[_withdrawId];
        require(!request.isComplete, "ERR_ALREADY_COMPLETED");
        // yield rate = (amount ypool token) / (amount wrapped token)
        require((amount + withdrawFee) * 10 ** (YIELD_RATE_DECIMALS + XY_TOKEN_DECIMALS - depositTokenDecimal) / request.amountXYWrappedToken <= maxYieldRateBound, "ERR_YIELD_RATE_OUT_OF_MAX_BOUND");
        require((amount + withdrawFee) * 10 ** (YIELD_RATE_DECIMALS + XY_TOKEN_DECIMALS - depositTokenDecimal) / request.amountXYWrappedToken >= minYieldRateBound, "ERR_YIELD_RATE_OUT_OF_MIN_BOUND");
        emit WithdrawalFulfilled(request.sender, _withdrawId, amount, withdrawFee);
        request.isComplete = true;
        xyWrappedToken.burn(request.amountXYWrappedToken);
        _safeTransferAsset(request.sender, depositToken, amount);
    }

    /* ========== WRITE FUNCTIONS ========== */

    /// @notice Request to deposit
    /// @dev Gas fee is required and checked upon the deposit request based on current gas
    /// price and deposit gas limit.
    /// @param amount Amount of deposit token to deposit
    function deposit(uint256 amount) external whenNotPaused payable {
        require(amount > 0, "ERR_INVALID_DEPOSIT_AMOUNT");
        uint256 gasFee = completeDepositGasLimit * _getGasPrice();
        uint256 requiredValue = (address(depositToken) == ETHER_ADDRESS) ? gasFee + amount : gasFee;
        require(msg.value >= requiredValue, "ERR_NOT_ENOUGH_FEE");

        depositAndWithdrawFees += gasFee;
        uint256 id = numDeposits++;
        depositRequests[id] = DepositRequest(amount, msg.sender, false);
        payable(msg.sender).transfer(msg.value - requiredValue);
        if (address(depositToken) != ETHER_ADDRESS) {
            _safeTransferAssetFrom(depositToken, msg.sender, address(this), amount);
        }

        emit DepositRequested(msg.sender, id, amount, gasFee);
    }

    /// @notice Request to withdraw
    /// @dev Gas fee is required and checked upon the withdraw request based on current gas
    /// price and withdraw gas limit.
    /// @param amountXYWrappedToken Amount of XY-Wrapped token used to withdraw
    function withdraw(uint256 amountXYWrappedToken) external payable whenNotPaused {
        require(amountXYWrappedToken > 0, "ERR_INVALID_WITHDRAW_AMOUNT");
        uint256 gasFee = completeWithdrawGasLimit * _getGasPrice();
        require(msg.value >= gasFee, "ERR_NOT_ENOUGH_FEE");

        depositAndWithdrawFees += gasFee;
        uint256 id = numWithdrawals++;
        withdrawalRequests[id] = WithdrawalRequest(amountXYWrappedToken, msg.sender, false);
        payable(msg.sender).transfer(msg.value - gasFee);
        _safeTransferAssetFrom(xyWrappedToken, msg.sender, address(this), amountXYWrappedToken);
        emit WithdrawalRequested(msg.sender, id, amountXYWrappedToken, gasFee);
    }

    /* ========== READ-ONLY FUNCTIONS ========== */

    /// @notice Calculate the the expected reserves given `xyFee`.
    /// @param xyFee xy fee amount
    function calculateReserves(uint256 xyFee) public view returns (uint256) {
        return xyFee * reservesRate / BASE_POINT_RESERVES_RATIO;
    }

    /* ========== EVENTS ========== */

    event TransferToSwapper(address swapper, IERC20 token, uint256 amount);
    event DepositRequested(address indexed sender, uint256 indexed depositId, uint256 amountDepositToken, uint256 gasFee);
    event DepositFulfilled(address indexed recipient, uint256 indexed depositId, uint256 amountXYWrappedToken);
    event WithdrawalRequested(address indexed sender, uint256 indexed withdrawId, uint256 amountXYWrappedToken, uint256 gasFee);
    event WithdrawalFulfilled(address indexed recipient, uint256 indexed withdrawId, uint256 amountDepositToken, uint256 withdrawFee);
    event AssetReceived(IERC20 token, uint256 assetAmount, uint256 xyFeeAmount, uint256 gasFeeAmount, uint256 xyFeeReserves);
    event DepositAndWithdrawGasFeesCollected(address recipient, uint256 gasFees);
    event CloseSwapGasFeesCollected(IERC20 token, address recipient, uint256 gasFees);
    event ReservesRateSet(uint256 _reservesRate);
    event ReservesReceiverSet(address _reservesReceiver);
}

File 2 of 23 : AccessControlUpgradeable.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "IAccessControlUpgradeable.sol";
import "ContextUpgradeable.sol";
import "StringsUpgradeable.sol";
import "ERC165Upgradeable.sol";
import "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 initializer {
        __Context_init_unchained();
        __ERC165_init_unchained();
        __AccessControl_init_unchained();
    }

    function __AccessControl_init_unchained() internal initializer {
    }
    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, _msgSender());
        _;
    }

    /**
     * @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 override returns (bool) {
        return _roles[role].members[account];
    }

    /**
     * @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 {
        if (!hasRole(role, account)) {
            revert(
                string(
                    abi.encodePacked(
                        "AccessControl: account ",
                        StringsUpgradeable.toHexString(uint160(account), 20),
                        " 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 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.
     */
    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.
     */
    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 granted `role`, emits a {RoleRevoked}
     * event.
     *
     * Requirements:
     *
     * - the caller must be `account`.
     */
    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.
     *
     * [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}.
     * ====
     */
    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);
    }

    function _grantRole(bytes32 role, address account) private {
        if (!hasRole(role, account)) {
            _roles[role].members[account] = true;
            emit RoleGranted(role, account, _msgSender());
        }
    }

    function _revokeRole(bytes32 role, address account) private {
        if (hasRole(role, account)) {
            _roles[role].members[account] = false;
            emit RoleRevoked(role, account, _msgSender());
        }
    }
    uint256[49] private __gap;
}

File 3 of 23 : IAccessControlUpgradeable.sol
// SPDX-License-Identifier: MIT

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 23 : ContextUpgradeable.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;
import "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 initializer {
        __Context_init_unchained();
    }

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

    function _msgData() internal view virtual returns (bytes calldata) {
        return msg.data;
    }
    uint256[50] private __gap;
}

File 5 of 23 : Initializable.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/**
 * @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 a proxied contract can't have 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.
 *
 * 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.
 */
abstract contract Initializable {
    /**
     * @dev Indicates that the contract has been initialized.
     */
    bool private _initialized;

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

    /**
     * @dev Modifier to protect an initializer function from being invoked twice.
     */
    modifier initializer() {
        require(_initializing || !_initialized, "Initializable: contract is already initialized");

        bool isTopLevelCall = !_initializing;
        if (isTopLevelCall) {
            _initializing = true;
            _initialized = true;
        }

        _;

        if (isTopLevelCall) {
            _initializing = false;
        }
    }
}

File 6 of 23 : StringsUpgradeable.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/**
 * @dev String operations.
 */
library StringsUpgradeable {
    bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef";

    /**
     * @dev Converts a `uint256` to its ASCII `string` decimal representation.
     */
    function toString(uint256 value) internal pure returns (string memory) {
        // Inspired by OraclizeAPI's implementation - MIT licence
        // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol

        if (value == 0) {
            return "0";
        }
        uint256 temp = value;
        uint256 digits;
        while (temp != 0) {
            digits++;
            temp /= 10;
        }
        bytes memory buffer = new bytes(digits);
        while (value != 0) {
            digits -= 1;
            buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
            value /= 10;
        }
        return string(buffer);
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
     */
    function toHexString(uint256 value) internal pure returns (string memory) {
        if (value == 0) {
            return "0x00";
        }
        uint256 temp = value;
        uint256 length = 0;
        while (temp != 0) {
            length++;
            temp >>= 8;
        }
        return toHexString(value, length);
    }

    /**
     * @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] = _HEX_SYMBOLS[value & 0xf];
            value >>= 4;
        }
        require(value == 0, "Strings: hex length insufficient");
        return string(buffer);
    }
}

File 7 of 23 : ERC165Upgradeable.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "IERC165Upgradeable.sol";
import "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 initializer {
        __ERC165_init_unchained();
    }

    function __ERC165_init_unchained() internal initializer {
    }
    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
        return interfaceId == type(IERC165Upgradeable).interfaceId;
    }
    uint256[50] private __gap;
}

File 8 of 23 : IERC165Upgradeable.sol
// SPDX-License-Identifier: MIT

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 9 of 23 : UUPSUpgradeable.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "ERC1967UpgradeUpgradeable.sol";
import "Initializable.sol";

/**
 * @dev An upgradeability mechanism designed for UUPS proxies. The functions included here can perform an upgrade of an
 * {ERC1967Proxy}, when this contract is set as the implementation behind such a proxy.
 *
 * A security mechanism ensures that an upgrade does not turn off upgradeability accidentally, although this risk is
 * reinstated if the upgrade retains upgradeability but removes the security mechanism, e.g. by replacing
 * `UUPSUpgradeable` with a custom implementation of upgrades.
 *
 * The {_authorizeUpgrade} function must be overridden to include access restriction to the upgrade mechanism.
 *
 * _Available since v4.1._
 */
abstract contract UUPSUpgradeable is Initializable, ERC1967UpgradeUpgradeable {
    function __UUPSUpgradeable_init() internal initializer {
        __ERC1967Upgrade_init_unchained();
        __UUPSUpgradeable_init_unchained();
    }

    function __UUPSUpgradeable_init_unchained() internal initializer {
    }
    /// @custom:oz-upgrades-unsafe-allow state-variable-immutable state-variable-assignment
    address private immutable __self = address(this);

    /**
     * @dev Check that the execution is being performed through a delegatecall call and that the execution context is
     * a proxy contract with an implementation (as defined in ERC1967) pointing to self. This should only be the case
     * for UUPS and transparent proxies that are using the current contract as their implementation. Execution of a
     * function through ERC1167 minimal proxies (clones) would not normally pass this test, but is not guaranteed to
     * fail.
     */
    modifier onlyProxy() {
        require(address(this) != __self, "Function must be called through delegatecall");
        require(_getImplementation() == __self, "Function must be called through active proxy");
        _;
    }

    /**
     * @dev Upgrade the implementation of the proxy to `newImplementation`.
     *
     * Calls {_authorizeUpgrade}.
     *
     * Emits an {Upgraded} event.
     */
    function upgradeTo(address newImplementation) external virtual onlyProxy {
        _authorizeUpgrade(newImplementation);
        _upgradeToAndCallSecure(newImplementation, new bytes(0), false);
    }

    /**
     * @dev Upgrade the implementation of the proxy to `newImplementation`, and subsequently execute the function call
     * encoded in `data`.
     *
     * Calls {_authorizeUpgrade}.
     *
     * Emits an {Upgraded} event.
     */
    function upgradeToAndCall(address newImplementation, bytes memory data) external payable virtual onlyProxy {
        _authorizeUpgrade(newImplementation);
        _upgradeToAndCallSecure(newImplementation, data, true);
    }

    /**
     * @dev Function that should revert when `msg.sender` is not authorized to upgrade the contract. Called by
     * {upgradeTo} and {upgradeToAndCall}.
     *
     * Normally, this function will use an xref:access.adoc[access control] modifier such as {Ownable-onlyOwner}.
     *
     * ```solidity
     * function _authorizeUpgrade(address) internal override onlyOwner {}
     * ```
     */
    function _authorizeUpgrade(address newImplementation) internal virtual;
    uint256[50] private __gap;
}

File 10 of 23 : ERC1967UpgradeUpgradeable.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.2;

import "IBeaconUpgradeable.sol";
import "AddressUpgradeable.sol";
import "StorageSlotUpgradeable.sol";
import "Initializable.sol";

/**
 * @dev This abstract contract provides getters and event emitting update functions for
 * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.
 *
 * _Available since v4.1._
 *
 * @custom:oz-upgrades-unsafe-allow delegatecall
 */
abstract contract ERC1967UpgradeUpgradeable is Initializable {
    function __ERC1967Upgrade_init() internal initializer {
        __ERC1967Upgrade_init_unchained();
    }

    function __ERC1967Upgrade_init_unchained() internal initializer {
    }
    // This is the keccak-256 hash of "eip1967.proxy.rollback" subtracted by 1
    bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;

    /**
     * @dev Storage slot with the address of the current implementation.
     * This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1, and is
     * validated in the constructor.
     */
    bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;

    /**
     * @dev Emitted when the implementation is upgraded.
     */
    event Upgraded(address indexed implementation);

    /**
     * @dev Returns the current implementation address.
     */
    function _getImplementation() internal view returns (address) {
        return StorageSlotUpgradeable.getAddressSlot(_IMPLEMENTATION_SLOT).value;
    }

    /**
     * @dev Stores a new address in the EIP1967 implementation slot.
     */
    function _setImplementation(address newImplementation) private {
        require(AddressUpgradeable.isContract(newImplementation), "ERC1967: new implementation is not a contract");
        StorageSlotUpgradeable.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
    }

    /**
     * @dev Perform implementation upgrade
     *
     * Emits an {Upgraded} event.
     */
    function _upgradeTo(address newImplementation) internal {
        _setImplementation(newImplementation);
        emit Upgraded(newImplementation);
    }

    /**
     * @dev Perform implementation upgrade with additional setup call.
     *
     * Emits an {Upgraded} event.
     */
    function _upgradeToAndCall(
        address newImplementation,
        bytes memory data,
        bool forceCall
    ) internal {
        _upgradeTo(newImplementation);
        if (data.length > 0 || forceCall) {
            _functionDelegateCall(newImplementation, data);
        }
    }

    /**
     * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.
     *
     * Emits an {Upgraded} event.
     */
    function _upgradeToAndCallSecure(
        address newImplementation,
        bytes memory data,
        bool forceCall
    ) internal {
        address oldImplementation = _getImplementation();

        // Initial upgrade and setup call
        _setImplementation(newImplementation);
        if (data.length > 0 || forceCall) {
            _functionDelegateCall(newImplementation, data);
        }

        // Perform rollback test if not already in progress
        StorageSlotUpgradeable.BooleanSlot storage rollbackTesting = StorageSlotUpgradeable.getBooleanSlot(_ROLLBACK_SLOT);
        if (!rollbackTesting.value) {
            // Trigger rollback using upgradeTo from the new implementation
            rollbackTesting.value = true;
            _functionDelegateCall(
                newImplementation,
                abi.encodeWithSignature("upgradeTo(address)", oldImplementation)
            );
            rollbackTesting.value = false;
            // Check rollback was effective
            require(oldImplementation == _getImplementation(), "ERC1967Upgrade: upgrade breaks further upgrades");
            // Finally reset to the new implementation and log the upgrade
            _upgradeTo(newImplementation);
        }
    }

    /**
     * @dev Storage slot with the admin of the contract.
     * This is the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1, and is
     * validated in the constructor.
     */
    bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;

    /**
     * @dev Emitted when the admin account has changed.
     */
    event AdminChanged(address previousAdmin, address newAdmin);

    /**
     * @dev Returns the current admin.
     */
    function _getAdmin() internal view returns (address) {
        return StorageSlotUpgradeable.getAddressSlot(_ADMIN_SLOT).value;
    }

    /**
     * @dev Stores a new address in the EIP1967 admin slot.
     */
    function _setAdmin(address newAdmin) private {
        require(newAdmin != address(0), "ERC1967: new admin is the zero address");
        StorageSlotUpgradeable.getAddressSlot(_ADMIN_SLOT).value = newAdmin;
    }

    /**
     * @dev Changes the admin of the proxy.
     *
     * Emits an {AdminChanged} event.
     */
    function _changeAdmin(address newAdmin) internal {
        emit AdminChanged(_getAdmin(), newAdmin);
        _setAdmin(newAdmin);
    }

    /**
     * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.
     * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.
     */
    bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;

    /**
     * @dev Emitted when the beacon is upgraded.
     */
    event BeaconUpgraded(address indexed beacon);

    /**
     * @dev Returns the current beacon.
     */
    function _getBeacon() internal view returns (address) {
        return StorageSlotUpgradeable.getAddressSlot(_BEACON_SLOT).value;
    }

    /**
     * @dev Stores a new beacon in the EIP1967 beacon slot.
     */
    function _setBeacon(address newBeacon) private {
        require(AddressUpgradeable.isContract(newBeacon), "ERC1967: new beacon is not a contract");
        require(
            AddressUpgradeable.isContract(IBeaconUpgradeable(newBeacon).implementation()),
            "ERC1967: beacon implementation is not a contract"
        );
        StorageSlotUpgradeable.getAddressSlot(_BEACON_SLOT).value = newBeacon;
    }

    /**
     * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does
     * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).
     *
     * Emits a {BeaconUpgraded} event.
     */
    function _upgradeBeaconToAndCall(
        address newBeacon,
        bytes memory data,
        bool forceCall
    ) internal {
        _setBeacon(newBeacon);
        emit BeaconUpgraded(newBeacon);
        if (data.length > 0 || forceCall) {
            _functionDelegateCall(IBeaconUpgradeable(newBeacon).implementation(), data);
        }
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.4._
     */
    function _functionDelegateCall(address target, bytes memory data) private returns (bytes memory) {
        require(AddressUpgradeable.isContract(target), "Address: delegate call to non-contract");

        // solhint-disable-next-line avoid-low-level-calls
        (bool success, bytes memory returndata) = target.delegatecall(data);
        return AddressUpgradeable.verifyCallResult(success, returndata, "Address: low-level delegate call failed");
    }
    uint256[50] private __gap;
}

File 11 of 23 : IBeaconUpgradeable.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/**
 * @dev This is the interface that {BeaconProxy} expects of its beacon.
 */
interface IBeaconUpgradeable {
    /**
     * @dev Must return an address that can be used as a delegate call target.
     *
     * {BeaconProxy} will check that this address is a contract.
     */
    function implementation() external view returns (address);
}

File 12 of 23 : AddressUpgradeable.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/**
 * @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
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // This method relies on extcodesize, which returns 0 for contracts in
        // construction, since the code is only stored at the end of the
        // constructor execution.

        uint256 size;
        assembly {
            size := extcodesize(account)
        }
        return size > 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 functionCall(target, data, "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");
        require(isContract(target), "Address: call to non-contract");

        (bool success, bytes memory returndata) = target.call{value: value}(data);
        return verifyCallResult(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) {
        require(isContract(target), "Address: static call to non-contract");

        (bool success, bytes memory returndata) = target.staticcall(data);
        return verifyCallResult(success, returndata, errorMessage);
    }

    /**
     * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
     * revert reason 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 {
            // Look for revert reason and bubble it up if present
            if (returndata.length > 0) {
                // The easiest way to bubble the revert reason is using memory via assembly

                assembly {
                    let returndata_size := mload(returndata)
                    revert(add(32, returndata), returndata_size)
                }
            } else {
                revert(errorMessage);
            }
        }
    }
}

File 13 of 23 : StorageSlotUpgradeable.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/**
 * @dev Library for reading and writing primitive types to specific storage slots.
 *
 * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.
 * This library helps with reading and writing to such slots without the need for inline assembly.
 *
 * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.
 *
 * Example usage to set ERC1967 implementation slot:
 * ```
 * contract ERC1967 {
 *     bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
 *
 *     function _getImplementation() internal view returns (address) {
 *         return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;
 *     }
 *
 *     function _setImplementation(address newImplementation) internal {
 *         require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract");
 *         StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
 *     }
 * }
 * ```
 *
 * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._
 */
library StorageSlotUpgradeable {
    struct AddressSlot {
        address value;
    }

    struct BooleanSlot {
        bool value;
    }

    struct Bytes32Slot {
        bytes32 value;
    }

    struct Uint256Slot {
        uint256 value;
    }

    /**
     * @dev Returns an `AddressSlot` with member `value` located at `slot`.
     */
    function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {
        assembly {
            r.slot := slot
        }
    }

    /**
     * @dev Returns an `BooleanSlot` with member `value` located at `slot`.
     */
    function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {
        assembly {
            r.slot := slot
        }
    }

    /**
     * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.
     */
    function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {
        assembly {
            r.slot := slot
        }
    }

    /**
     * @dev Returns an `Uint256Slot` with member `value` located at `slot`.
     */
    function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {
        assembly {
            r.slot := slot
        }
    }
}

File 14 of 23 : PausableUpgradeable.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "ContextUpgradeable.sol";
import "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 initializer {
        __Context_init_unchained();
        __Pausable_init_unchained();
    }

    function __Pausable_init_unchained() internal initializer {
        _paused = false;
    }

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

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

    /**
     * @dev Modifier to make a function callable only when the contract is paused.
     *
     * Requirements:
     *
     * - The contract must be paused.
     */
    modifier whenPaused() {
        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());
    }
    uint256[49] private __gap;
}

File 15 of 23 : SafeERC20.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "IERC20.sol";
import "Address.sol";

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

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

    function safeTransferFrom(
        IERC20 token,
        address from,
        address to,
        uint256 value
    ) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
    }

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

    function safeIncreaseAllowance(
        IERC20 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(
        IERC20 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));
        }
    }

    /**
     * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
     * on the return value: the return value is optional (but if data is returned, it must not be false).
     * @param token The token targeted by the call.
     * @param data The call data (encoded using abi.encode or one of its variants).
     */
    function _callOptionalReturn(IERC20 token, bytes memory data) private {
        // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
        // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that
        // the target address contains contract code and also asserts for success in the low-level call.

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

File 16 of 23 : IERC20.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
interface IERC20 {
    /**
     * @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 `recipient`.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transfer(address recipient, 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 `sender` to `recipient` 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 sender,
        address recipient,
        uint256 amount
    ) external returns (bool);

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

File 17 of 23 : Address.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/**
 * @dev Collection of functions related to the address type
 */
library Address {
    /**
     * @dev Returns true if `account` is a contract.
     *
     * [IMPORTANT]
     * ====
     * It is unsafe to assume that an address for which this function returns
     * false is an externally-owned account (EOA) and not a contract.
     *
     * Among others, `isContract` will return false for the following
     * types of addresses:
     *
     *  - an externally-owned account
     *  - a contract in construction
     *  - an address where a contract will be created
     *  - an address where a contract lived, but was destroyed
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // This method relies on extcodesize, which returns 0 for contracts in
        // construction, since the code is only stored at the end of the
        // constructor execution.

        uint256 size;
        assembly {
            size := extcodesize(account)
        }
        return size > 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 functionCall(target, data, "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");
        require(isContract(target), "Address: call to non-contract");

        (bool success, bytes memory returndata) = target.call{value: value}(data);
        return verifyCallResult(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) {
        require(isContract(target), "Address: static call to non-contract");

        (bool success, bytes memory returndata) = target.staticcall(data);
        return verifyCallResult(success, returndata, errorMessage);
    }

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

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.4._
     */
    function functionDelegateCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal returns (bytes memory) {
        require(isContract(target), "Address: delegate call to non-contract");

        (bool success, bytes memory returndata) = target.delegatecall(data);
        return verifyCallResult(success, returndata, errorMessage);
    }

    /**
     * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
     * revert reason 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 {
            // Look for revert reason and bubble it up if present
            if (returndata.length > 0) {
                // The easiest way to bubble the revert reason is using memory via assembly

                assembly {
                    let returndata_size := mload(returndata)
                    revert(add(32, returndata), returndata_size)
                }
            } else {
                revert(errorMessage);
            }
        }
    }
}

File 18 of 23 : ERC20.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "IERC20.sol";
import "IERC20Metadata.sol";
import "Context.sol";

/**
 * @dev Implementation of the {IERC20} interface.
 *
 * This implementation is agnostic to the way tokens are created. This means
 * that a supply mechanism has to be added in a derived contract using {_mint}.
 * For a generic mechanism see {ERC20PresetMinterPauser}.
 *
 * TIP: For a detailed writeup see our guide
 * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
 * to implement supply mechanisms].
 *
 * We have followed general OpenZeppelin Contracts guidelines: functions revert
 * instead returning `false` on failure. This behavior is nonetheless
 * conventional and does not conflict with the expectations of ERC20
 * applications.
 *
 * Additionally, an {Approval} event is emitted on calls to {transferFrom}.
 * This allows applications to reconstruct the allowance for all accounts just
 * by listening to said events. Other implementations of the EIP may not emit
 * these events, as it isn't required by the specification.
 *
 * Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
 * functions have been added to mitigate the well-known issues around setting
 * allowances. See {IERC20-approve}.
 */
contract ERC20 is Context, IERC20, IERC20Metadata {
    mapping(address => uint256) private _balances;

    mapping(address => mapping(address => uint256)) private _allowances;

    uint256 private _totalSupply;

    string private _name;
    string private _symbol;

    /**
     * @dev Sets the values for {name} and {symbol}.
     *
     * The default value of {decimals} is 18. To select a different value for
     * {decimals} you should overload it.
     *
     * All two of these values are immutable: they can only be set once during
     * construction.
     */
    constructor(string memory name_, string memory symbol_) {
        _name = name_;
        _symbol = symbol_;
    }

    /**
     * @dev Returns the name of the token.
     */
    function name() public view virtual override returns (string memory) {
        return _name;
    }

    /**
     * @dev Returns the symbol of the token, usually a shorter version of the
     * name.
     */
    function symbol() public view virtual override returns (string memory) {
        return _symbol;
    }

    /**
     * @dev Returns the number of decimals used to get its user representation.
     * For example, if `decimals` equals `2`, a balance of `505` tokens should
     * be displayed to a user as `5.05` (`505 / 10 ** 2`).
     *
     * Tokens usually opt for a value of 18, imitating the relationship between
     * Ether and Wei. This is the value {ERC20} uses, unless this function is
     * overridden;
     *
     * NOTE: This information is only used for _display_ purposes: it in
     * no way affects any of the arithmetic of the contract, including
     * {IERC20-balanceOf} and {IERC20-transfer}.
     */
    function decimals() public view virtual override returns (uint8) {
        return 18;
    }

    /**
     * @dev See {IERC20-totalSupply}.
     */
    function totalSupply() public view virtual override returns (uint256) {
        return _totalSupply;
    }

    /**
     * @dev See {IERC20-balanceOf}.
     */
    function balanceOf(address account) public view virtual override returns (uint256) {
        return _balances[account];
    }

    /**
     * @dev See {IERC20-transfer}.
     *
     * Requirements:
     *
     * - `recipient` cannot be the zero address.
     * - the caller must have a balance of at least `amount`.
     */
    function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
        _transfer(_msgSender(), recipient, amount);
        return true;
    }

    /**
     * @dev See {IERC20-allowance}.
     */
    function allowance(address owner, address spender) public view virtual override returns (uint256) {
        return _allowances[owner][spender];
    }

    /**
     * @dev See {IERC20-approve}.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     */
    function approve(address spender, uint256 amount) public virtual override returns (bool) {
        _approve(_msgSender(), spender, amount);
        return true;
    }

    /**
     * @dev See {IERC20-transferFrom}.
     *
     * Emits an {Approval} event indicating the updated allowance. This is not
     * required by the EIP. See the note at the beginning of {ERC20}.
     *
     * Requirements:
     *
     * - `sender` and `recipient` cannot be the zero address.
     * - `sender` must have a balance of at least `amount`.
     * - the caller must have allowance for ``sender``'s tokens of at least
     * `amount`.
     */
    function transferFrom(
        address sender,
        address recipient,
        uint256 amount
    ) public virtual override returns (bool) {
        _transfer(sender, recipient, amount);

        uint256 currentAllowance = _allowances[sender][_msgSender()];
        require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance");
        unchecked {
            _approve(sender, _msgSender(), currentAllowance - amount);
        }

        return true;
    }

    /**
     * @dev Atomically increases the allowance granted to `spender` by the caller.
     *
     * This is an alternative to {approve} that can be used as a mitigation for
     * problems described in {IERC20-approve}.
     *
     * Emits an {Approval} event indicating the updated allowance.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     */
    function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
        _approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue);
        return true;
    }

    /**
     * @dev Atomically decreases the allowance granted to `spender` by the caller.
     *
     * This is an alternative to {approve} that can be used as a mitigation for
     * problems described in {IERC20-approve}.
     *
     * Emits an {Approval} event indicating the updated allowance.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     * - `spender` must have allowance for the caller of at least
     * `subtractedValue`.
     */
    function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
        uint256 currentAllowance = _allowances[_msgSender()][spender];
        require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
        unchecked {
            _approve(_msgSender(), spender, currentAllowance - subtractedValue);
        }

        return true;
    }

    /**
     * @dev Moves `amount` of tokens from `sender` to `recipient`.
     *
     * This internal function is equivalent to {transfer}, and can be used to
     * e.g. implement automatic token fees, slashing mechanisms, etc.
     *
     * Emits a {Transfer} event.
     *
     * Requirements:
     *
     * - `sender` cannot be the zero address.
     * - `recipient` cannot be the zero address.
     * - `sender` must have a balance of at least `amount`.
     */
    function _transfer(
        address sender,
        address recipient,
        uint256 amount
    ) internal virtual {
        require(sender != address(0), "ERC20: transfer from the zero address");
        require(recipient != address(0), "ERC20: transfer to the zero address");

        _beforeTokenTransfer(sender, recipient, amount);

        uint256 senderBalance = _balances[sender];
        require(senderBalance >= amount, "ERC20: transfer amount exceeds balance");
        unchecked {
            _balances[sender] = senderBalance - amount;
        }
        _balances[recipient] += amount;

        emit Transfer(sender, recipient, amount);

        _afterTokenTransfer(sender, recipient, amount);
    }

    /** @dev Creates `amount` tokens and assigns them to `account`, increasing
     * the total supply.
     *
     * Emits a {Transfer} event with `from` set to the zero address.
     *
     * Requirements:
     *
     * - `account` cannot be the zero address.
     */
    function _mint(address account, uint256 amount) internal virtual {
        require(account != address(0), "ERC20: mint to the zero address");

        _beforeTokenTransfer(address(0), account, amount);

        _totalSupply += amount;
        _balances[account] += amount;
        emit Transfer(address(0), account, amount);

        _afterTokenTransfer(address(0), account, amount);
    }

    /**
     * @dev Destroys `amount` tokens from `account`, reducing the
     * total supply.
     *
     * Emits a {Transfer} event with `to` set to the zero address.
     *
     * Requirements:
     *
     * - `account` cannot be the zero address.
     * - `account` must have at least `amount` tokens.
     */
    function _burn(address account, uint256 amount) internal virtual {
        require(account != address(0), "ERC20: burn from the zero address");

        _beforeTokenTransfer(account, address(0), amount);

        uint256 accountBalance = _balances[account];
        require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
        unchecked {
            _balances[account] = accountBalance - amount;
        }
        _totalSupply -= amount;

        emit Transfer(account, address(0), amount);

        _afterTokenTransfer(account, address(0), amount);
    }

    /**
     * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
     *
     * This internal function is equivalent to `approve`, and can be used to
     * e.g. set automatic allowances for certain subsystems, etc.
     *
     * Emits an {Approval} event.
     *
     * Requirements:
     *
     * - `owner` cannot be the zero address.
     * - `spender` cannot be the zero address.
     */
    function _approve(
        address owner,
        address spender,
        uint256 amount
    ) internal virtual {
        require(owner != address(0), "ERC20: approve from the zero address");
        require(spender != address(0), "ERC20: approve to the zero address");

        _allowances[owner][spender] = amount;
        emit Approval(owner, spender, amount);
    }

    /**
     * @dev Hook that is called before any transfer of tokens. This includes
     * minting and burning.
     *
     * Calling conditions:
     *
     * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
     * will be transferred to `to`.
     * - when `from` is zero, `amount` tokens will be minted for `to`.
     * - when `to` is zero, `amount` of ``from``'s tokens will be burned.
     * - `from` and `to` are never both zero.
     *
     * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
     */
    function _beforeTokenTransfer(
        address from,
        address to,
        uint256 amount
    ) internal virtual {}

    /**
     * @dev Hook that is called after any transfer of tokens. This includes
     * minting and burning.
     *
     * Calling conditions:
     *
     * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
     * has been transferred to `to`.
     * - when `from` is zero, `amount` tokens have been minted for `to`.
     * - when `to` is zero, `amount` of ``from``'s tokens have been burned.
     * - `from` and `to` are never both zero.
     *
     * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
     */
    function _afterTokenTransfer(
        address from,
        address to,
        uint256 amount
    ) internal virtual {}
}

File 19 of 23 : IERC20Metadata.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "IERC20.sol";

/**
 * @dev Interface for the optional metadata functions from the ERC20 standard.
 *
 * _Available since v4.1._
 */
interface IERC20Metadata is IERC20 {
    /**
     * @dev Returns the name of the token.
     */
    function name() external view returns (string memory);

    /**
     * @dev Returns the symbol of the token.
     */
    function symbol() external view returns (string memory);

    /**
     * @dev Returns the decimals places of the token.
     */
    function decimals() external view returns (uint8);
}

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

pragma solidity ^0.8.0;

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

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

File 21 of 23 : XYWrappedToken.sol
// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.2;

import "Ownable.sol";
import "ERC20.sol";


contract XYWrappedToken is ERC20, Ownable {

    event SetMinter(address minter, bool isMinter);

    mapping (address => bool) public isMinter;

    modifier onlyMinter {
        require(isMinter[msg.sender], "ERR_NOT_MINTER");
        _;
    }

    constructor(string memory name_, string memory symbol_) ERC20(name_, symbol_) {
        isMinter[owner()] = true;
    }

    function setMinter(address minter, bool _isMinter) external onlyOwner {
        isMinter[minter] = _isMinter;

        emit SetMinter(minter, _isMinter);
    }

    function mint(address account, uint256 amount) external onlyMinter {
        _mint(account, amount);
    }

    function burn(uint256 amount) external {
        _burn(msg.sender, amount);
    }
}

File 22 of 23 : Ownable.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "Context.sol";

/**
 * @dev Contract module which provides a basic access control mechanism, where
 * there is an account (an owner) that can be granted exclusive access to
 * specific functions.
 *
 * By default, the owner account will be the one that deploys the contract. This
 * can later be changed with {transferOwnership}.
 *
 * This module is used through inheritance. It will make available the modifier
 * `onlyOwner`, which can be applied to your functions to restrict their use to
 * the owner.
 */
abstract contract Ownable is Context {
    address private _owner;

    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);

    /**
     * @dev Initializes the contract setting the deployer as the initial owner.
     */
    constructor() {
        _setOwner(_msgSender());
    }

    /**
     * @dev Returns the address of the current owner.
     */
    function owner() public view virtual returns (address) {
        return _owner;
    }

    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        require(owner() == _msgSender(), "Ownable: caller is not the owner");
        _;
    }

    /**
     * @dev Leaves the contract without owner. It will not be possible to call
     * `onlyOwner` functions anymore. Can only be called by the current owner.
     *
     * NOTE: Renouncing ownership will leave the contract without an owner,
     * thereby removing any functionality that is only available to the owner.
     */
    function renounceOwnership() public virtual onlyOwner {
        _setOwner(address(0));
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Can only be called by the current owner.
     */
    function transferOwnership(address newOwner) public virtual onlyOwner {
        require(newOwner != address(0), "Ownable: new owner is the zero address");
        _setOwner(newOwner);
    }

    function _setOwner(address newOwner) private {
        address oldOwner = _owner;
        _owner = newOwner;
        emit OwnershipTransferred(oldOwner, newOwner);
    }
}

File 23 of 23 : IGasPriceConsumer.sol
// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.2;

interface IGasPriceConsumer {
    function getLatestGasPrice() external view returns (int);
}

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

Contract ABI

[{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"previousAdmin","type":"address"},{"indexed":false,"internalType":"address","name":"newAdmin","type":"address"}],"name":"AdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"contract IERC20","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"assetAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"xyFeeAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"gasFeeAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"xyFeeReserves","type":"uint256"}],"name":"AssetReceived","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"beacon","type":"address"}],"name":"BeaconUpgraded","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"contract IERC20","name":"token","type":"address"},{"indexed":false,"internalType":"address","name":"recipient","type":"address"},{"indexed":false,"internalType":"uint256","name":"gasFees","type":"uint256"}],"name":"CloseSwapGasFeesCollected","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"recipient","type":"address"},{"indexed":false,"internalType":"uint256","name":"gasFees","type":"uint256"}],"name":"DepositAndWithdrawGasFeesCollected","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"recipient","type":"address"},{"indexed":true,"internalType":"uint256","name":"depositId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amountXYWrappedToken","type":"uint256"}],"name":"DepositFulfilled","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"sender","type":"address"},{"indexed":true,"internalType":"uint256","name":"depositId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amountDepositToken","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"gasFee","type":"uint256"}],"name":"DepositRequested","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"_reservesRate","type":"uint256"}],"name":"ReservesRateSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_reservesReceiver","type":"address"}],"name":"ReservesReceiverSet","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":"address","name":"swapper","type":"address"},{"indexed":false,"internalType":"contract IERC20","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"TransferToSwapper","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"implementation","type":"address"}],"name":"Upgraded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"recipient","type":"address"},{"indexed":true,"internalType":"uint256","name":"withdrawId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amountDepositToken","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"withdrawFee","type":"uint256"}],"name":"WithdrawalFulfilled","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"sender","type":"address"},{"indexed":true,"internalType":"uint256","name":"withdrawId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amountXYWrappedToken","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"gasFee","type":"uint256"}],"name":"WithdrawalRequested","type":"event"},{"inputs":[],"name":"BASE_POINT_RESERVES_RATIO","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ETHER_ADDRESS","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ROLE_LIQUIDITY_WORKER","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ROLE_MANAGER","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ROLE_OWNER","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ROLE_STAFF","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"XY_TOKEN_DECIMALS","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"YIELD_RATE_DECIMALS","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"xyFee","type":"uint256"}],"name":"calculateReserves","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"closeSwapGasFees","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"collectCloseSwapGasFees","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"collectDepositAndWithdrawGasFees","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"collectFees","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_depositId","type":"uint256"},{"internalType":"uint256","name":"amountXYWrappedToken","type":"uint256"}],"name":"completeDeposit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"completeDepositGasLimit","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_withdrawId","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"withdrawFee","type":"uint256"}],"name":"completeWithdraw","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"completeWithdrawGasLimit","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"deposit","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"depositAndWithdrawFees","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"depositRequests","outputs":[{"internalType":"uint256","name":"amountDepositToken","type":"uint256"},{"internalType":"address","name":"sender","type":"address"},{"internalType":"bool","name":"isComplete","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"depositToken","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"depositTokenDecimal","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"gasFeeReceiver","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"gasPriceConsumer","outputs":[{"internalType":"address","name":"","type":"address"}],"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":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"manager","type":"address"},{"internalType":"address","name":"staff","type":"address"},{"internalType":"address","name":"liquidityWorker","type":"address"},{"internalType":"address","name":"_depositToken","type":"address"},{"internalType":"address","name":"_xyWrappedToken","type":"address"},{"internalType":"uint8","name":"_depositTokenDecimal","type":"uint8"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"maxYieldRateBound","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"minYieldRateBound","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"numDeposits","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"numWithdrawals","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"token","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"xyFeeAmount","type":"uint256"},{"internalType":"uint256","name":"gasFeeAmount","type":"uint256"}],"name":"receiveAssetFromSwapper","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IERC20[]","name":"tokens","type":"address[]"}],"name":"rescue","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"reservesRate","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"reservesReceiver","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","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":"gasLimit","type":"uint256"}],"name":"setCompleteDepositGasLimit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"gasLimit","type":"uint256"}],"name":"setCompleteWithdrawGasLimit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_gasFeeReceiver","type":"address"}],"name":"setGasFeeReceiver","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_gasPriceConsumer","type":"address"}],"name":"setGasPriceConsumer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_reservesRate","type":"uint256"}],"name":"setReservesRate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_reservesReceiver","type":"address"}],"name":"setReservesReceiver","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_swapper","type":"address"}],"name":"setSwapper","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_maxYieldRateBound","type":"uint256"},{"internalType":"uint256","name":"_minYieldRateBound","type":"uint256"}],"name":"setYieldRateBound","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":[],"name":"swapper","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"token","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferToSwapper","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newImplementation","type":"address"}],"name":"upgradeTo","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newImplementation","type":"address"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"upgradeToAndCall","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amountXYWrappedToken","type":"uint256"}],"name":"withdraw","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"withdrawalRequests","outputs":[{"internalType":"uint256","name":"amountXYWrappedToken","type":"uint256"},{"internalType":"address","name":"sender","type":"address"},{"internalType":"bool","name":"isComplete","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"xyWrappedToken","outputs":[{"internalType":"contract XYWrappedToken","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"stateMutability":"payable","type":"receive"}]

60a06040523060601b60805234801561001757600080fd5b5060805160601c613c0361004b6000396000818161110801528181611148015281816111ef015261122f0152613c036000f3fe6080604052600436106103855760003560e01c8063937b2581116101d1578063c3a77a5511610102578063cf1d21c0116100a0578063edd3c0da1161006f578063edd3c0da14610a24578063f5b944eb14610a45578063fabd034114610a67578063fe9d33e114610ab15761038c565b8063cf1d21c0146109a5578063d547741f146109cd578063d9158876146109ed578063ec2fd88f14610a045761038c565b8063c6b9d286116100dc578063c6b9d2861461091b578063c87965721461094f578063c89039c514610964578063cd4395d0146109855761038c565b8063c3a77a55146108c2578063c44d4605146108e2578063c4a103c3146109045761038c565b8063b24f42761161016f578063ba66d72f11610149578063ba66d72f14610855578063bb0d68871461086b578063bbd4e8c91461088b578063c2fc2110146108a25761038c565b8063b24f427614610801578063b6b55f2514610821578063b9982dd2146108345761038c565b80639d4f5296116101ab5780639d4f5296146107975780639d5121f2146107ac578063a217fddf146107cc578063a3ef20a0146107e15761038c565b8063937b2581146106e857806397d14456146107575780639c82f2a4146107775761038c565b80633f4ba83a116102b65780636e995de8116102545780638da2c04d116102235780638da2c04d14610680578063910857db1461069557806391d14854146106b557806392dace96146106d55761038c565b80636e995de8146106125780638456cb5914610632578063870b9a6d146106475780638ad682af1461065e5761038c565b80635e67651e116102905780635e67651e146105af57806364e685bb146105c45780636aced503146105db5780636c3f3917146105f25761038c565b80633f4ba83a1461056f5780634f1ef286146105845780635c975abb146105975761038c565b80632b3297f9116103235780632f6b9eab116102fd5780632f6b9eab146105015780633531ac6e1461051857806336568abe1461052f5780633659cfe61461054f5761038c565b80632b3297f9146104ad5780632e1a7d4d146104ce5780632f2ff15d146104e15761038c565b8063166959f81161035f578063166959f8146104025780631799a2a11461042257806322bf2e241461045b578063248a9ca31461047d5761038c565b806301ffc9a714610391578063157e3945146103c65780631660218a146103eb5761038c565b3661038c57005b600080fd5b34801561039d57600080fd5b506103b16103ac36600461365d565b610ad2565b60405190151581526020015b60405180910390f35b3480156103d257600080fd5b506103dd6101395481565b6040519081526020016103bd565b3480156103f757600080fd5b50610400610b09565b005b34801561040e57600080fd5b5061040061041d366004613702565b610b68565b34801561042e57600080fd5b5061013254610443906001600160a01b031681565b6040516001600160a01b0390911681526020016103bd565b34801561046757600080fd5b506103dd600080516020613b6e83398151915281565b34801561048957600080fd5b506103dd610498366004613616565b60009081526065602052604090206001015490565b3480156104b957600080fd5b5061012f54610443906001600160a01b031681565b6104006104dc366004613616565b610e53565b3480156104ed57600080fd5b506104006104fc36600461362e565b611054565b34801561050d57600080fd5b506103dd6101355481565b34801561052457600080fd5b506103dd6101375481565b34801561053b57600080fd5b5061040061054a36600461362e565b61107f565b34801561055b57600080fd5b5061040061056a3660046133eb565b6110fd565b34801561057b57600080fd5b506104006111c3565b6104006105923660046134a1565b6111e4565b3480156105a357600080fd5b5060fb5460ff166103b1565b3480156105bb57600080fd5b506103dd601281565b3480156105d057600080fd5b506103dd61012e5481565b3480156105e757600080fd5b506103dd61013a5481565b3480156105fe57600080fd5b5061040061060d366004613543565b61129a565b34801561061e57600080fd5b5061040061062d366004613702565b61145e565b34801561063e57600080fd5b5061040061149d565b34801561065357600080fd5b506103dd6101345481565b34801561066a57600080fd5b506103dd600080516020613bae83398151915281565b34801561068c57600080fd5b506104006114be565b3480156106a157600080fd5b506104006106b0366004613616565b611510565b3480156106c157600080fd5b506103b16106d036600461362e565b611530565b6104006106e33660046136b0565b61155b565b3480156106f457600080fd5b50610732610703366004613616565b61013d60205260009081526040902080546001909101546001600160a01b03811690600160a01b900460ff1683565b604080519384526001600160a01b0390921660208401521515908201526060016103bd565b34801561076357600080fd5b506104006107723660046133eb565b61175d565b34801561078357600080fd5b506104006107923660046133eb565b6117f4565b3480156107a357600080fd5b506103dd600881565b3480156107b857600080fd5b506104006107c73660046133eb565b61187f565b3480156107d857600080fd5b506103dd600081565b3480156107ed57600080fd5b506104006107fc366004613616565b611938565b34801561080d57600080fd5b5061040061081c366004613723565b611958565b61040061082f366004613616565b611ccf565b34801561084057600080fd5b5061013054610443906001600160a01b031681565b34801561086157600080fd5b506103dd61271081565b34801561087757600080fd5b506103dd610886366004613616565b611f35565b34801561089757600080fd5b506103dd6101385481565b3480156108ae57600080fd5b506104006108bd366004613685565b611f53565b3480156108ce57600080fd5b506104006108dd366004613407565b612094565b3480156108ee57600080fd5b506103dd600080516020613b8e83398151915281565b34801561091057600080fd5b506103dd6101365481565b34801561092757600080fd5b506101315461093d90600160a01b900460ff1681565b60405160ff90911681526020016103bd565b34801561095b57600080fd5b5061040061234c565b34801561097057600080fd5b5061013154610443906001600160a01b031681565b34801561099157600080fd5b506104006109a0366004613616565b61239e565b3480156109b157600080fd5b5061044373eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee81565b3480156109d957600080fd5b506104006109e836600461362e565b612453565b3480156109f957600080fd5b506103dd61012d5481565b348015610a1057600080fd5b50610400610a1f3660046133eb565b612479565b348015610a3057600080fd5b5061013354610443906001600160a01b031681565b348015610a5157600080fd5b506103dd600080516020613b2783398151915281565b348015610a7357600080fd5b50610732610a82366004613616565b61013c60205260009081526040902080546001909101546001600160a01b03811690600160a01b900460ff1683565b348015610abd57600080fd5b5061013b54610443906001600160a01b031681565b60006001600160e01b03198216637965db0b60e01b1480610b0357506301ffc9a760e01b6001600160e01b03198316145b92915050565b60fb5460ff1615610b355760405162461bcd60e51b8152600401610b2c906138aa565b60405180910390fd5b600080516020613b6e833981519152610b4f81335b6124b6565b61013054610b65906001600160a01b031661251a565b50565b60fb5460ff1615610b8b5760405162461bcd60e51b8152600401610b2c906138aa565b600080516020613b8e833981519152610ba48133610b4a565b610138548310610bef5760405162461bcd60e51b815260206004820152601660248201527511549497d253959053125117d1115413d4d25517d25160521b6044820152606401610b2c565b600083815261013c602052604090206001810154600160a01b900460ff1615610c5a5760405162461bcd60e51b815260206004820152601c60248201527f4552525f4445504f5349545f414c52454144595f434f4d504c455445000000006044820152606401610b2c565b61012d54610131548490600160a01b900460ff16610c7a60126008613905565b610c849190613a70565b610c8f90600a613983565b8354610c9b9190613a51565b610ca5919061391d565b1115610cf35760405162461bcd60e51b815260206004820152601f60248201527f4552525f5949454c445f524154455f4f55545f4f465f4d41585f424f554e44006044820152606401610b2c565b61012e54610131548490600160a01b900460ff16610d1360126008613905565b610d1d9190613a70565b610d2890600a613983565b8354610d349190613a51565b610d3e919061391d565b1015610d8c5760405162461bcd60e51b815260206004820152601f60248201527f4552525f5949454c445f524154455f4f55545f4f465f4d494e5f424f554e44006044820152606401610b2c565b600181015460405184815285916001600160a01b0316907f823f0e221d1509d3ab923032e7f0f46943d22de228379fd5579aa72355c1b7ab9060200160405180910390a360018101805460ff60a01b1916600160a01b1790819055610132546040516340c10f1960e01b81526001600160a01b039283166004820152602481018690529116906340c10f1990604401600060405180830381600087803b158015610e3557600080fd5b505af1158015610e49573d6000803e3d6000fd5b5050505050505050565b60fb5460ff1615610e765760405162461bcd60e51b8152600401610b2c906138aa565b60008111610ec65760405162461bcd60e51b815260206004820152601b60248201527f4552525f494e56414c49445f57495448445241575f414d4f554e5400000000006044820152606401610b2c565b6000610ed061259c565b61013554610ede9190613a51565b905080341015610f255760405162461bcd60e51b81526020600482015260126024820152714552525f4e4f545f454e4f5547485f46454560701b6044820152606401610b2c565b806101366000828254610f389190613905565b9091555050610139805460009182610f4f83613aca565b9091555060408051606081018252858152336020808301828152600084860181815287825261013d909352949094209251835592516001909201805493511515600160a01b0260ff60a01b196001600160a01b039094166001600160a01b031990951694909417929092169290921790559091506108fc610fd08434613a70565b6040518115909202916000818181858888f19350505050158015610ff8573d6000803e3d6000fd5b5061013254611012906001600160a01b0316333086612684565b6040805184815260208101849052829133917f38e3d972947cfef94205163d483d6287ef27eb312e20cb8e0b13a49989db232e910160405180910390a3505050565b6000828152606560205260409020600101546110708133610b4a565b61107a8383612848565b505050565b6001600160a01b03811633146110ef5760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b6064820152608401610b2c565b6110f982826128ce565b5050565b306001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001614156111465760405162461bcd60e51b8152600401610b2c90613812565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316611178612935565b6001600160a01b03161461119e5760405162461bcd60e51b8152600401610b2c9061385e565b6111a781612963565b60408051600080825260208201909252610b659183919061297c565b600080516020613b278339815191526111dc8133610b4a565b610b65612ac0565b306001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016141561122d5760405162461bcd60e51b8152600401610b2c90613812565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031661125f612935565b6001600160a01b0316146112855760405162461bcd60e51b8152600401610b2c9061385e565b61128e82612963565b6110f98282600161297c565b600080516020613bae8339815191526112b38133610b4a565b60005b825181101561107a5760008382815181106112e157634e487b7160e01b600052603260045260246000fd5b6020908102919091010151610131549091506001600160a01b038083169116141561134e5760405162461bcd60e51b815260206004820181905260248201527f4552525f43414e5f4e4f545f5245534355455f4445504f5349545f544f4b454e6044820152606401610b2c565b610132546001600160a01b03828116911614156113b95760405162461bcd60e51b815260206004820152602360248201527f4552525f43414e5f4e4f545f5245534355455f58595f575241505045445f544f60448201526225a2a760e91b6064820152608401610b2c565b6040516370a0823160e01b81523060048201526000906001600160a01b038316906370a082319060240160206040518083038186803b1580156113fb57600080fd5b505afa15801561140f573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061143391906136ea565b90506114496001600160a01b0383163383612b53565b5050808061145690613aca565b9150506112b6565b600080516020613b278339815191526114778133610b4a565b6114836008600a613983565b83101561148f57600080fd5b5061012d9190915561012e55565b600080516020613b278339815191526114b68133610b4a565b610b65612bb6565b60fb5460ff16156114e15760405162461bcd60e51b8152600401610b2c906138aa565b600080516020613b6e8339815191526114fa8133610b4a565b61013054610b65906001600160a01b0316612c0e565b600080516020613b6e8339815191526115298133610b4a565b5061013455565b60009182526065602090815260408084206001600160a01b0393909316845291905290205460ff1690565b60fb5460ff161561157e5760405162461bcd60e51b8152600401610b2c906138aa565b61012f546001600160a01b031633146115cb5760405162461bcd60e51b815260206004820152600f60248201526e22a9292fa727aa2fa9aba0a82822a960891b6044820152606401610b2c565b610131546001600160a01b038581169116146116375760405162461bcd60e51b815260206004820152602560248201527f4552525f5452414e534645525f57524f4e475f544f4b454e5f46524f4d5f535760448201526420a82822a960d91b6064820152608401610b2c565b6001600160a01b03841673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee14156116a5578234146116a05760405162461bcd60e51b815260206004820152601260248201527111549497d253959053125117d05353d5539560721b6044820152606401610b2c565b6116bf565b61012f546116bf9085906001600160a01b03163086612684565b8061013760008282546116d29190613905565b90915550600090506116e383611f35565b604080516001600160a01b03881681526020810187905290810185905260608101849052608081018290529091507fb51e3d4222f0b9ba090ac9562cd95348e59e9a48631d01a41bf11ad3c95290f59060a00160405180910390a161013b54611756906001600160a01b03168683612ce0565b5050505050565b600080516020613b278339815191526117768133610b4a565b813b6117d05760405162461bcd60e51b815260206004820152602360248201527f4552525f4741535f50524943455f434f4e53554d45525f4e4f545f434f4e54526044820152621050d560ea1b6064820152608401610b2c565b5061013380546001600160a01b0319166001600160a01b0392909216919091179055565b600080516020613bae83398151915261180d8133610b4a565b813b61185b5760405162461bcd60e51b815260206004820152601860248201527f4552525f535741505045525f4e4f545f434f4e545241435400000000000000006044820152606401610b2c565b5061012f80546001600160a01b0319166001600160a01b0392909216919091179055565b600080516020613b278339815191526118988133610b4a565b6001600160a01b0382166118e15760405162461bcd60e51b815260206004820152601060248201526f4552525f5a45524f5f4144445245535360801b6044820152606401610b2c565b61013b80546001600160a01b0319166001600160a01b0384169081179091556040519081527f58db74d58b651756d158c41988415677c84a3388e7e54bc622898502a91a56a5906020015b60405180910390a15050565b600080516020613b6e8339815191526119518133610b4a565b5061013555565b60fb5460ff161561197b5760405162461bcd60e51b8152600401610b2c906138aa565b600080516020613b8e8339815191526119948133610b4a565b6101395484106119e65760405162461bcd60e51b815260206004820152601760248201527f4552525f494e56414c49445f57495448445241575f49440000000000000000006044820152606401610b2c565b60008311611a445760405162461bcd60e51b815260206004820152602560248201527f4552525f57495448445241575f4645455f4e4f545f4c4553535f5448414e5f416044820152641353d5539560da1b6064820152608401610b2c565b600084815261013d602052604090206001810154600160a01b900460ff1615611aa75760405162461bcd60e51b815260206004820152601560248201527411549497d053149150511657d0d3d3541311551151605a1b6044820152606401610b2c565b61012d54815461013154600160a01b900460ff16611ac760126008613905565b611ad19190613a70565b611adc90600a613983565b611ae68688613905565b611af09190613a51565b611afa919061391d565b1115611b485760405162461bcd60e51b815260206004820152601f60248201527f4552525f5949454c445f524154455f4f55545f4f465f4d41585f424f554e44006044820152606401610b2c565b61012e54815461013154600160a01b900460ff16611b6860126008613905565b611b729190613a70565b611b7d90600a613983565b611b878688613905565b611b919190613a51565b611b9b919061391d565b1015611be95760405162461bcd60e51b815260206004820152601f60248201527f4552525f5949454c445f524154455f4f55545f4f465f4d494e5f424f554e44006044820152606401610b2c565b6001810154604080518681526020810186905287926001600160a01b0316917f567289124f980c60ab6be9d631895db98cf8d567e8ef80f55d8be6474ad2d0a6910160405180910390a360018101805460ff60a01b1916600160a01b179055610132548154604051630852cd8d60e31b81526001600160a01b03909216916342966c6891611c7d9160040190815260200190565b600060405180830381600087803b158015611c9757600080fd5b505af1158015611cab573d6000803e3d6000fd5b50505060018201546101315461175692506001600160a01b03918216911686612ce0565b60fb5460ff1615611cf25760405162461bcd60e51b8152600401610b2c906138aa565b60008111611d425760405162461bcd60e51b815260206004820152601a60248201527f4552525f494e56414c49445f4445504f5349545f414d4f554e540000000000006044820152606401610b2c565b6000611d4c61259c565b61013454611d5a9190613a51565b610131549091506000906001600160a01b031673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee14611d8d5781611d97565b611d978383613905565b905080341015611dde5760405162461bcd60e51b81526020600482015260126024820152714552525f4e4f545f454e4f5547485f46454560701b6044820152606401610b2c565b816101366000828254611df19190613905565b9091555050610138805460009182611e0883613aca565b9091555060408051606081018252868152336020808301828152600084860181815287825261013c909352949094209251835592516001909201805493511515600160a01b0260ff60a01b196001600160a01b039094166001600160a01b031990951694909417929092169290921790559091506108fc611e898434613a70565b6040518115909202916000818181858888f19350505050158015611eb1573d6000803e3d6000fd5b50610131546001600160a01b031673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee14611ef25761013154611ef2906001600160a01b0316333087612684565b6040805185815260208101859052829133917f827893a5f98dbfaba92dbe0bb2cafe8b9fd5573711d9768ce5cd4e2af44601ac910160405180910390a350505050565b600061271061013a5483611f499190613a51565b610b03919061391d565b60fb5460ff1615611f765760405162461bcd60e51b8152600401610b2c906138aa565b61012f546001600160a01b03163314611fc35760405162461bcd60e51b815260206004820152600f60248201526e22a9292fa727aa2fa9aba0a82822a960891b6044820152606401610b2c565b610131546001600160a01b0383811691161461202d5760405162461bcd60e51b815260206004820152602360248201527f4552525f5452414e534645525f57524f4e475f544f4b454e5f544f5f535741506044820152622822a960e91b6064820152608401610b2c565b61012f54604080516001600160a01b039283168152918416602083015281018290527f2f670cae6f7939ad46a6678914017bf731232a1f7e5ea0e6068fbd2cc1b0a57f9060600160405180910390a161012f546110f9906001600160a01b03168383612ce0565b600054610100900460ff16806120ad575060005460ff16155b6121105760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610b2c565b600054610100900460ff1615801561213b576000805460ff1961ff0019909116610100171660011790555b6001600160a01b03841673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee146121ad57833b6121ad5760405162461bcd60e51b815260206004820152601e60248201527f4552525f4445504f5349545f544f4b454e5f4e4f545f434f4e545241435400006044820152606401610b2c565b823b6122065760405162461bcd60e51b815260206004820152602260248201527f4552525f58595f57525041505045445f544f4b454e5f4e4f545f434f4e54524160448201526110d560f21b6064820152608401610b2c565b610131805461013280546001600160a01b038781166001600160a01b03199283161790925560ff8616600160a01b0260ff60a01b1992891691909316171617905561225f600080516020613bae83398151915280612d55565b612285600080516020613b27833981519152600080516020613bae833981519152612d55565b6122ab600080516020613b6e833981519152600080516020613bae833981519152612d55565b6122d1600080516020613b8e833981519152600080516020613bae833981519152612d55565b6122e9600080516020613bae83398151915289612da0565b612301600080516020613b2783398151915288612da0565b612319600080516020613b6e83398151915287612da0565b612331600080516020613b8e83398151915286612da0565b8015610e49576000805461ff00191690555050505050505050565b60fb5460ff161561236f5760405162461bcd60e51b8152600401610b2c906138aa565b600080516020613b6e8339815191526123888133610b4a565b610130546114fa906001600160a01b031661251a565b600080516020613b278339815191526123b78133610b4a565b61271082111561241d5760405162461bcd60e51b815260206004820152602b60248201527f4552525f52455345525645535f524154494f5f4e4f545f4c4553535f5448414e60448201526a5f4f525f455155414c5f3160a81b6064820152608401610b2c565b61013a8290556040518281527f154632fa271f5a6b6da0c95f6abd4fc38b5a7db8a1d87d06ecf4aca9e567885d9060200161192c565b60008281526065602052604090206001015461246f8133610b4a565b61107a83836128ce565b600080516020613b278339815191526124928133610b4a565b5061013080546001600160a01b0319166001600160a01b0392909216919091179055565b6124c08282611530565b6110f9576124d8816001600160a01b03166014612daa565b6124e3836020612daa565b6040516020016124f492919061376a565b60408051601f198184030181529082905262461bcd60e51b8252610b2c916004016137df565b610136805460009182905560405190916001600160a01b0384169183156108fc0291849190818181858888f1935050505015801561255c573d6000803e3d6000fd5b50604080516001600160a01b0384168152602081018390527f4f7e88c568b8b073ad35fbbd0b6d389b7196e43468942ae77975e092e2caf6a9910161192c565b610133546000906001600160a01b03166125f85760405162461bcd60e51b815260206004820152601e60248201527f4552525f4741535f50524943455f434f4e53554d45525f4e4f545f53455400006044820152606401610b2c565b61013360009054906101000a90046001600160a01b03166001600160a01b031663565f93376040518163ffffffff1660e01b815260040160206040518083038186803b15801561264757600080fd5b505afa15801561265b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061267f91906136ea565b905090565b6001600160a01b03841673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee14156126e55760405162461bcd60e51b81526020600482015260116024820152704552525f544f4b454e5f4144445245535360781b6044820152606401610b2c565b6040516370a0823160e01b81526001600160a01b038381166004830152600091908616906370a082319060240160206040518083038186803b15801561272a57600080fd5b505afa15801561273e573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061276291906136ea565b90506127796001600160a01b038616858585612f93565b6040516370a0823160e01b81526001600160a01b0384811660048301528291908716906370a082319060240160206040518083038186803b1580156127bd57600080fd5b505afa1580156127d1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127f591906136ea565b6127ff9190613a70565b90508181146117565760405162461bcd60e51b815260206004820152601560248201527408aa4a4be829a9eaa9ca8be9c9ea8be8a9c9eaa8e9605b1b6044820152606401610b2c565b6128528282611530565b6110f95760008281526065602090815260408083206001600160a01b03851684529091529020805460ff1916600117905561288a3390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b6128d88282611530565b156110f95760008281526065602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b600080516020613bae8339815191526110f98133610b4a565b6000612986612935565b905061299184612fd1565b60008351118061299e5750815b156129af576129ad8484613076565b505b7f4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143805460ff1661175657805460ff191660011781556040516001600160a01b0383166024820152612a2e90869060440160408051601f198184030181529190526020810180516001600160e01b0316631b2ce7f360e11b179052613076565b50805460ff19168155612a3f612935565b6001600160a01b0316826001600160a01b031614612ab75760405162461bcd60e51b815260206004820152602f60248201527f45524331393637557067726164653a207570677261646520627265616b73206660448201526e75727468657220757067726164657360881b6064820152608401610b2c565b61175685613161565b60fb5460ff16612b095760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b6044820152606401610b2c565b60fb805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b6040516001600160a01b03831660248201526044810182905261107a90849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b0319909316929092179091526131a1565b60fb5460ff1615612bd95760405162461bcd60e51b8152600401610b2c906138aa565b60fb805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258612b363390565b61013780546000909155610131546001600160a01b031673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee1415612c7c576040516001600160a01b0383169082156108fc029083906000818181858888f19350505050158015612c76573d6000803e3d6000fd5b50612c94565b61013154612c94906001600160a01b03168383612b53565b61013154604080516001600160a01b039283168152918416602083015281018290527fd07b88bc5333ca866820627716b1c6c09d5e43515f6b3a4a980ce147bd6d00479060600161192c565b6001600160a01b03821673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee1415612d41576040516001600160a01b0384169082156108fc029083906000818181858888f19350505050158015612d3b573d6000803e3d6000fd5b5061107a565b61107a6001600160a01b0383168483612b53565b600082815260656020526040808220600101805490849055905190918391839186917fbd79b86ffe0ab8e8776151514217cd7cacd52c909f66475c3af44e129f0b00ff9190a4505050565b6110f98282612848565b60606000612db9836002613a51565b612dc4906002613905565b67ffffffffffffffff811115612dea57634e487b7160e01b600052604160045260246000fd5b6040519080825280601f01601f191660200182016040528015612e14576020820181803683370190505b509050600360fc1b81600081518110612e3d57634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a905350600f60fb1b81600181518110612e7a57634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a9053506000612e9e846002613a51565b612ea9906001613905565b90505b6001811115612f3d576f181899199a1a9b1b9c1cb0b131b232b360811b85600f1660108110612eeb57634e487b7160e01b600052603260045260246000fd5b1a60f81b828281518110612f0f57634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a90535060049490941c93612f3681613ab3565b9050612eac565b508315612f8c5760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610b2c565b9392505050565b6040516001600160a01b0380851660248301528316604482015260648101829052612fcb9085906323b872dd60e01b90608401612b7f565b50505050565b803b6130355760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b6064820152608401610b2c565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc80546001600160a01b0319166001600160a01b0392909216919091179055565b6060823b6130d55760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b6064820152608401610b2c565b600080846001600160a01b0316846040516130f0919061374e565b600060405180830381855af49150503d806000811461312b576040519150601f19603f3d011682016040523d82523d6000602084013e613130565b606091505b50915091506131588282604051806060016040528060278152602001613b4760279139613273565b95945050505050565b61316a81612fd1565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b60006131f6826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166132ac9092919063ffffffff16565b80519091501561107a578080602001905181019061321491906135f6565b61107a5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610b2c565b60608315613282575081612f8c565b8251156132925782518084602001fd5b8160405162461bcd60e51b8152600401610b2c91906137df565b60606132bb84846000856132c3565b949350505050565b6060824710156133245760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401610b2c565b843b6133725760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610b2c565b600080866001600160a01b0316858760405161338e919061374e565b60006040518083038185875af1925050503d80600081146133cb576040519150601f19603f3d011682016040523d82523d6000602084013e6133d0565b606091505b50915091506133e0828286613273565b979650505050505050565b6000602082840312156133fc578081fd5b8135612f8c81613b11565b600080600080600080600060e0888a031215613421578283fd5b873561342c81613b11565b9650602088013561343c81613b11565b9550604088013561344c81613b11565b9450606088013561345c81613b11565b9350608088013561346c81613b11565b925060a088013561347c81613b11565b915060c088013560ff81168114613491578182fd5b8091505092959891949750929550565b600080604083850312156134b3578182fd5b82356134be81613b11565b915060208381013567ffffffffffffffff808211156134db578384fd5b818601915086601f8301126134ee578384fd5b81358181111561350057613500613afb565b613512601f8201601f191685016138d4565b91508082528784828501011115613527578485fd5b8084840185840137810190920192909252919491935090915050565b60006020808385031215613555578182fd5b823567ffffffffffffffff8082111561356c578384fd5b818501915085601f83011261357f578384fd5b81358181111561359157613591613afb565b83810291506135a18483016138d4565b8181528481019084860184860187018a10156135bb578788fd5b8795505b838610156135e957803594506135d485613b11565b848352600195909501949186019186016135bf565b5098975050505050505050565b600060208284031215613607578081fd5b81518015158114612f8c578182fd5b600060208284031215613627578081fd5b5035919050565b60008060408385031215613640578182fd5b82359150602083013561365281613b11565b809150509250929050565b60006020828403121561366e578081fd5b81356001600160e01b031981168114612f8c578182fd5b60008060408385031215613697578182fd5b82356136a281613b11565b946020939093013593505050565b600080600080608085870312156136c5578384fd5b84356136d081613b11565b966020860135965060408601359560600135945092505050565b6000602082840312156136fb578081fd5b5051919050565b60008060408385031215613714578182fd5b50508035926020909101359150565b600080600060608486031215613737578081fd5b505081359360208301359350604090920135919050565b60008251613760818460208701613a87565b9190910192915050565b60007f416363657373436f6e74726f6c3a206163636f756e7420000000000000000000825283516137a2816017850160208801613a87565b7001034b99036b4b9b9b4b733903937b6329607d1b60179184019182015283516137d3816028840160208801613a87565b01602801949350505050565b60006020825282518060208401526137fe816040850160208701613a87565b601f01601f19169190910160400192915050565b6020808252602c908201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060408201526b19195b1959d85d1958d85b1b60a21b606082015260800190565b6020808252602c908201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060408201526b6163746976652070726f787960a01b606082015260800190565b60208082526010908201526f14185d5cd8589b194e881c185d5cd95960821b604082015260600190565b604051601f8201601f1916810167ffffffffffffffff811182821017156138fd576138fd613afb565b604052919050565b6000821982111561391857613918613ae5565b500190565b60008261393857634e487b7160e01b81526012600452602481fd5b500490565b80825b600180861161394f575061397a565b81870482111561396157613961613ae5565b8086161561396e57918102915b9490941c938002613940565b94509492505050565b6000612f8c600019848460008261399c57506001612f8c565b816139a957506000612f8c565b81600181146139bf57600281146139c9576139f6565b6001915050612f8c565b60ff8411156139da576139da613ae5565b6001841b9150848211156139f0576139f0613ae5565b50612f8c565b5060208310610133831016604e8410600b8410161715613a29575081810a83811115613a2457613a24613ae5565b612f8c565b613a36848484600161393d565b808604821115613a4857613a48613ae5565b02949350505050565b6000816000190483118215151615613a6b57613a6b613ae5565b500290565b600082821015613a8257613a82613ae5565b500390565b60005b83811015613aa2578181015183820152602001613a8a565b83811115612fcb5750506000910152565b600081613ac257613ac2613ae5565b506000190190565b6000600019821415613ade57613ade613ae5565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b0381168114610b6557600080fdfef206625bad3d9112d5609b8d356e6fbd514cd1f69980d4ce2b3e6e68e1789ace416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564358933fb1b4f9e62c7cd3651025ad8825acb20ebbb23b09160e3867d71501ddd2e8819b7ff4c0052fe9f7185768f0bfabc666b59f4a166549bbdbfb928d23eb19f4e1c871d5fdd0aee1cd182666698a4492b24c6832aac230d07b11046af5a89a26469706673582212204aef0ef2efeddb9649dcc0ef81277d5ed796b18e4dbd15b7d722e693245dd5e364736f6c63430008020033

Block Transaction Gas Used Reward
Age Block Fee Address BC Fee Address Voting Power Jailed Incoming
Block Uncle Number Difficulty Gas Used Reward
Loading
Make sure to use the "Vote Down" button for any spammy posts, and the "Vote Up" for interesting conversations.