ETH Price: $2,958.05 (+1.05%)

Contract

0xeD67a6CbF4b9f3D0D818E158F5E7f4dFB3166783

Overview

ETH Balance

0 ETH

ETH Value

$0.00

More Info

Private Name Tags

Multichain Info

No addresses found
Transaction Hash
Block
From
To
Approve385101612026-01-24 12:42:0032 mins ago1769258520IN
0xeD67a6Cb...FB3166783
0 ETH0.000000030.0006975
Exercise Ve384942412026-01-24 8:16:404 hrs ago1769242600IN
0xeD67a6Cb...FB3166783
0 ETH0.000000450.0006227
Approve384766002026-01-24 3:22:399 hrs ago1769224959IN
0xeD67a6Cb...FB3166783
0 ETH0.000000020.0006227
Approve384732612026-01-24 2:27:0010 hrs ago1769221620IN
0xeD67a6Cb...FB3166783
0 ETH0.000000020.0006227
Exercise Ve384391062026-01-23 16:57:4520 hrs ago1769187465IN
0xeD67a6Cb...FB3166783
0 ETH0.000000360.0005
Approve384243092026-01-23 12:51:0824 hrs ago1769172668IN
0xeD67a6Cb...FB3166783
0 ETH0.000000020.0006227
Approve384029132026-01-23 6:54:3230 hrs ago1769151272IN
0xeD67a6Cb...FB3166783
0 ETH0.000000060.0015
Exercise Ve383952802026-01-23 4:47:1932 hrs ago1769143639IN
0xeD67a6Cb...FB3166783
0 ETH0.000001090.0015
Exercise Ve383946032026-01-23 4:36:0232 hrs ago1769142962IN
0xeD67a6Cb...FB3166783
0 ETH0.000000360.0005
Exercise Ve383928522026-01-23 4:06:5133 hrs ago1769141211IN
0xeD67a6Cb...FB3166783
0 ETH0.000001090.0015
Approve383690462026-01-22 21:30:0539 hrs ago1769117405IN
0xeD67a6Cb...FB3166783
0 ETH0.000000020.00050356
Approve383664692026-01-22 20:47:0840 hrs ago1769114828IN
0xeD67a6Cb...FB3166783
0 ETH0.00000010.00225
Approve383662032026-01-22 20:42:4240 hrs ago1769114562IN
0xeD67a6Cb...FB3166783
0 ETH0.000000060.00225
Exercise Ve383613032026-01-22 19:21:0241 hrs ago1769109662IN
0xeD67a6Cb...FB3166783
0 ETH0.000000430.0006
Approve383486542026-01-22 15:50:1345 hrs ago1769097013IN
0xeD67a6Cb...FB3166783
0 ETH0.000000020.0005
Exercise383108942026-01-22 5:20:532 days ago1769059253IN
0xeD67a6Cb...FB3166783
0 ETH0.000000070.0005
Approve383108672026-01-22 5:20:262 days ago1769059226IN
0xeD67a6Cb...FB3166783
0 ETH0.000000020.0005
Exercise Ve382904272026-01-21 23:39:462 days ago1769038786IN
0xeD67a6Cb...FB3166783
0 ETH0.000000360.0005
Exercise Ve382896512026-01-21 23:26:502 days ago1769038010IN
0xeD67a6Cb...FB3166783
0 ETH0.000000440.0006
Exercise Ve382859612026-01-21 22:25:202 days ago1769034320IN
0xeD67a6Cb...FB3166783
0 ETH0.000000450.0006226
Exercise Ve382857472026-01-21 22:21:462 days ago1769034106IN
0xeD67a6Cb...FB3166783
0 ETH0.00000050.0006973
Exercise Ve382652872026-01-21 16:40:462 days ago1769013646IN
0xeD67a6Cb...FB3166783
0 ETH0.000000480.00060389
Approve382618232026-01-21 15:43:022 days ago1769010182IN
0xeD67a6Cb...FB3166783
0 ETH0.000000030.0006978
Exercise Ve382581752026-01-21 14:42:142 days ago1769006534IN
0xeD67a6Cb...FB3166783
0 ETH0.000000920.0011655
Exercise Ve382572342026-01-21 14:26:332 days ago1769005593IN
0xeD67a6Cb...FB3166783
0 ETH0.000000410.0005
View all transactions

View more zero value Internal Transactions in Advanced View mode

Advanced mode:

Cross-Chain Transactions
Loading...
Loading

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

Contract Name:
OptionTokenV3

Compiler Version
v0.8.13+commit.abaa5c0e

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion

Contract Source Code (Solidity Standard Json-Input format)

File 1 of 36 : OptionTokenV3.sol
// SPDX-License-Identifier: AGPL-3.0
pragma solidity 0.8.13;

import {AccessControlEnumerable} from "@openzeppelin/contracts/access/AccessControlEnumerable.sol";
import {ERC20, IERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import {Math} from "../libraries/Math.sol";
import {IVotingEscrowV2} from "../VoterV5/VotingEscrow/IVotingEscrowV2.sol";
import {IVoter} from "../interfaces/IVoter.sol";
import {IPair} from "../interfaces/IPair.sol";
import {IGauge} from "../interfaces/IGauge.sol";
import {IRouter} from "../interfaces/IRouter.sol";
import {IDynamicTwapOracle} from "./DynamicTwapOracle/IDynamicTwapOracle.sol";
import {IOptionTokenV3_1} from "./IOptionTokenV3_1.sol";
import {IOptionFeeDistributor} from "./IOptionFeeDistributor.sol";
import {IOption} from "./IOption.sol";
import {IVersionable} from "../interfaces/IVersionable.sol";

/// @title Option Token
/// @notice Option token representing the right to purchase the underlying token
/// at TWAP reduced rate. Similar to call options but with a variable strike
/// price that's always at a certain discount to the market price.
/// @dev
/// - This OptionToken uses an Algebra style TWAP for pricing, but deposits LP tokens into a Solidly type pool.
/// - WARN The accuracy of TWAP oracles relies on sufficient liquidity, and they may not provide real-time price data,
///   which can be an issue for applications requiring up-to-date information.
/// Credit to Velocimeter for the original implementation
contract OptionTokenV3 is IOptionTokenV3_1, IVersionable, ERC20, AccessControlEnumerable {
    using SafeERC20 for IERC20;

    /// -----------------------------------------------------------------------
    /// Constants
    /// -----------------------------------------------------------------------
    string public constant override VERSION = "3.1.0";

    /// @dev MAX_DISCOUNT and MIN_DISCOUNT are handled opposite to discount, lpDiscount and veDiscount where 0 = 100% discount
    uint256 public constant MAX_DISCOUNT = 100; // 100%
    uint256 public constant MIN_DISCOUNT = 0; // 0%
    uint256 public constant MAX_TWAP_SECONDS = 2 days;
    uint256 public constant MIN_TWAP_SECONDS = 1 hours;

    /// @dev Lock set to 2 years
    uint256 public constant FULL_LOCK = 2 * 365 * 1 days; // 2 years

    /// -----------------------------------------------------------------------
    /// Roles
    /// -----------------------------------------------------------------------
    /// @dev The identifier of the role which maintains other roles and settings
    bytes32 public constant override ADMIN_ROLE = keccak256("ADMIN");

    /// @dev The identifier of the role which is allowed to mint options token
    bytes32 public constant override MINTER_ROLE = keccak256("MINTER");

    /// @dev The identifier of the role which allows accounts to pause exercising options
    /// in case of emergency
    bytes32 public constant override PAUSER_ROLE = keccak256("PAUSER");

    /// -----------------------------------------------------------------------
    /// Immutable parameters
    /// -----------------------------------------------------------------------

    /// @notice The token paid by the options token holder during redemption
    IERC20 public override paymentToken;

    /// @notice The underlying token purchased during redemption
    IERC20 public immutable UNDERLYING_TOKEN;

    /// @notice The voter contract
    address public voter;

    /// -----------------------------------------------------------------------
    /// Storage variables
    /// -----------------------------------------------------------------------

    /// @notice The router for adding liquidity
    address public router; // this should not be immutable

    /// @notice The pair contract used to deposit LP option
    IPair public pair;

    /// @notice The guage contract for the pair
    address public gauge;

    /// @notice The oracle contract that provides the current TWAP price to purchase
    /// the underlying token while exercising options (the strike price)
    IDynamicTwapOracle public twapOracle;

    /// @notice The contract that receives the payment tokens when options are exercised
    IOptionFeeDistributor public feeDistributor;

    /// @notice the discount given during exercising with locking to the LP
    uint256 public maxLPDiscount = 20; //  User pays 20%
    uint256 public minLPDiscount = 80; //  User pays 80%

    /// @notice the lock duration for max discount to create locked LP
    uint256 public lockDurationForMaxLpDiscount = FULL_LOCK; // 52 weeks

    /// @notice the lock duration for max discount to create locked LP
    uint256 public lockDurationForMinLpDiscount = 1 weeks;

    /// @notice the lock duration for min discount to create locked veToken
    uint256 public lockDurationForMinVeDiscount = 2 weeks;

    /// @notice the discount given during exercising. 30 = user pays 30%
    uint256 public discount = 40;

    /// @notice the max discount allowed for vote escrow exercise
    uint256 public veMaxDiscount = 0; // User pays 0%
    /// @notice the min discount allowed for vote escrow exercise
    uint256 public veMinDiscount = 40; // User pays 40%

    /// @notice controls the duration of the twap used to calculate the strike price
    uint32 public twapSeconds = 2 hours;

    /// @notice Is exercising options currently paused
    bool public isPaused;

    /// @notice Is minting new options currently permissioned
    bool public permissionedMint = false;

    /// @notice allows to expand options with new contracts
    mapping(address => bool) isExternalOption;

    /// -----------------------------------------------------------------------
    /// Events
    /// -----------------------------------------------------------------------

    event Exercise(address indexed sender, address indexed recipient, uint256 amount, uint256 paymentAmount);
    event ExerciseVe(
        address indexed sender,
        address indexed recipient,
        uint256 amount,
        uint256 paymentAmount,
        uint256 nftId
    );
    event ExerciseLp(
        address indexed sender,
        address indexed recipient,
        uint256 amount,
        uint256 paymentAmount,
        uint256 lpAmount
    );
    event SetPaymentConfiguration(
        IPair indexed pair,
        IDynamicTwapOracle indexed twapOracle,
        address indexed paymentToken
    );
    event SetGauge(address indexed newGauge);
    event SetRouter(address indexed router);
    event SetFeeDistributor(IOptionFeeDistributor indexed newFeeDistributor);
    event SetDiscount(uint256 discount);
    event SetVeMaxDiscount(uint256 veMaxDiscount);
    event SetVeMinDiscount(uint256 veMinDiscount);
    event SetMinLPDiscount(uint256 lpMinDiscount);
    event SetMaxLPDiscount(uint256 lpMaxDiscount);
    event SetLockDurationForMaxLpDiscount(uint256 lockDurationForMaxLpDiscount);
    event SetLockDurationForMinLpDiscount(uint256 lockDurationForMinLpDiscount);
    event SetLockDurationForMinVeDiscount(uint256 lockDurationForMinVeDiscount);
    event PauseStateChanged(bool isPaused);
    event SetTwapSeconds(uint32 twapSeconds);
    event ToggleExternalOption(address option, bool enabled);

    /// -----------------------------------------------------------------------
    /// Errors
    /// -----------------------------------------------------------------------
    error OptionToken_PastDeadline();
    error OptionToken_NoAdminRole();
    error OptionToken_NoMinterRole();
    error OptionToken_NoPauserRole();
    error OptionToken_SlippageTooHigh();
    error OptionToken_PaymentTooHigh();
    error OptionToken_InvalidDiscount();
    error OptionToken_Paused();
    error OptionToken_InvalidTwapSeconds();
    error OptionToken_IncorrectPairToken();
    error OptionToken_IncorrectTwapOracle();
    error OptionToken_InvalidLockDuration();
    error OptionToken_InvalidOption();
    error OptionToken_NoGaugeForLp();

    /// -----------------------------------------------------------------------
    /// Modifiers
    /// -----------------------------------------------------------------------
    /// @dev A modifier which checks that the caller has the admin role.
    modifier onlyAdmin() {
        if (!hasRole(ADMIN_ROLE, msg.sender)) revert OptionToken_NoAdminRole();
        _;
    }

    /// @dev A modifier which checks that the caller has the admin or minter role.
    modifier onlyMinter() {
        if (permissionedMint && !hasRole(ADMIN_ROLE, msg.sender) && !hasRole(MINTER_ROLE, msg.sender))
            revert OptionToken_NoMinterRole();
        _;
    }

    /// @dev A modifier which checks that the caller has the pause role.
    modifier onlyPauser() {
        if (!hasRole(PAUSER_ROLE, msg.sender)) revert OptionToken_NoPauserRole();
        _;
    }

    /// @dev A modifier which checks that the deadline has not passed.
    modifier checkDeadline(uint256 _deadline) {
        if (block.timestamp > _deadline) {
            revert OptionToken_PastDeadline();
        }
        _;
    }

    /// @dev A modifier which checks that the contract is not paused.
    modifier notPaused() {
        if (isPaused) {
            revert OptionToken_Paused();
        }
        _;
    }

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

    constructor(
        string memory _name,
        string memory _symbol,
        address _admin,
        ERC20 _paymentToken,
        ERC20 _underlyingToken,
        IDynamicTwapOracle _twapOracle,
        IOptionFeeDistributor _feeDistributor,
        address _voter,
        IPair _pair,
        address _router
    ) ERC20(_name, _symbol) {
        _grantRole(DEFAULT_ADMIN_ROLE, _admin);
        _grantRole(ADMIN_ROLE, _admin);
        _grantRole(PAUSER_ROLE, _admin);
        _setRoleAdmin(ADMIN_ROLE, ADMIN_ROLE);
        _setRoleAdmin(MINTER_ROLE, ADMIN_ROLE);
        _setRoleAdmin(PAUSER_ROLE, ADMIN_ROLE);

        UNDERLYING_TOKEN = _underlyingToken;
        twapOracle = _twapOracle;
        feeDistributor = _feeDistributor;
        router = _router;
        voter = _voter;

        _setPaymentConfiguration(_pair, _twapOracle, address(_paymentToken));
        updateGauge();
        emit SetRouter(router);
        emit SetFeeDistributor(_feeDistributor);
        emit SetDiscount(discount);
        emit SetVeMaxDiscount(veMaxDiscount);
        emit SetVeMinDiscount(veMinDiscount);
        emit SetMinLPDiscount(minLPDiscount);
        emit SetMaxLPDiscount(maxLPDiscount);
    }

    /// -----------------------------------------------------------------------
    /// External functions
    /// -----------------------------------------------------------------------

    /// @notice Exercises options tokens to purchase the underlying tokens.
    /// @dev The oracle may revert if it cannot give a secure result.
    /// @param _amount The amount of options tokens to exercise
    /// @param _maxPaymentAmount The maximum acceptable amount to pay. Used for slippage protection.
    /// @param _recipient The recipient of the purchased underlying tokens
    /// @return paymentAmount The amount paid to the fee distributor to purchase the underlying tokens
    function exercise(
        uint256 _amount,
        uint256 _maxPaymentAmount,
        address _recipient
    ) external returns (uint256 paymentAmount) {
        return _exercise(_amount, _maxPaymentAmount, _recipient);
    }

    /// @notice Exercises options tokens to purchase the underlying tokens.
    /// @dev The oracle may revert if it cannot give a secure result.
    /// @param _amount The amount of options tokens to exercise
    /// @param _maxPaymentAmount The maximum acceptable amount to pay. Used for slippage protection.
    /// @param _recipient The recipient of the purchased underlying tokens
    /// @param _deadline The Unix timestamp (in seconds) after which the call will revert
    /// @return The amount paid to the fee distributor to purchase the underlying tokens
    function exercise(
        uint256 _amount,
        uint256 _maxPaymentAmount,
        address _recipient,
        uint256 _deadline
    ) external checkDeadline(_deadline) returns (uint256) {
        return _exercise(_amount, _maxPaymentAmount, _recipient);
    }

    /// @notice Exercises options tokens to purchase the underlying tokens.
    /// @dev The oracle may revert if it cannot give a secure result.
    /// @param _amount The amount of options tokens to exercise
    /// @param _maxPaymentAmount The maximum acceptable amount to pay. Used for slippage protection.
    /// @param _recipient The recipient of the purchased underlying tokens
    /// @param _deadline The Unix timestamp (in seconds) after which the call will revert
    /// @return The amount paid to the fee distributor to purchase the underlying tokens
    function exerciseVe(
        uint256 _amount,
        uint256 _maxPaymentAmount,
        address _recipient,
        uint256 _discount,
        uint256 _deadline
    ) external checkDeadline(_deadline) returns (uint256, uint256) {
        return _exerciseVe(_amount, _maxPaymentAmount, _discount, _recipient);
    }

    /// @notice Exercises options tokens to create LP and stake in gauges with lock.
    /// @dev The oracle may revert if it cannot give a secure result.
    /// @param _oTokenRedeemAmount The amount of options tokens to exercise
    /// @param _maxPaymentAmountForExercise The maximum acceptable paymentToken amount to deposit for LP. Used for slippage protection.
    /// @param _minPaymentAmountToAddLiquidity The minimum acceptable paymentToken amount to deposit for LP. Used for slippage protection.
    /// @param _recipient The recipient of the LP tokens created.
    /// @param _discount The desired discount
    /// @param _deadline The Unix timestamp (in seconds) after which the call will revert
    /// @return The amount paid to the treasury to purchase the underlying tokens
    function exerciseLp(
        uint256 _oTokenRedeemAmount,
        uint256 _maxPaymentAmountForExercise,
        uint256 _maxPaymentAmountToAddLiquidity,
        uint256 _minPaymentAmountToAddLiquidity,
        address _recipient,
        uint256 _discount,
        uint256 _deadline
    ) external checkDeadline(_deadline) returns (uint256, uint256) {
        return
            _exerciseLp(
                _oTokenRedeemAmount,
                _maxPaymentAmountForExercise,
                _maxPaymentAmountToAddLiquidity,
                _minPaymentAmountToAddLiquidity,
                _recipient,
                _discount
            );
    }

    /// @notice Exercises options tokens to purchase the underlying tokens from an external option contract.
    /// @param _option The external option contract
    /// @param _amount The amount of options tokens to exercise
    /// @param _deadline The Unix timestamp (in seconds) after which the call will revert
    /// @param _data The data to pass to the external option contract
    function exerciseExternal(
        IOption _option,
        uint256 _amount,
        uint256 _deadline,
        bytes calldata _data
    ) external checkDeadline(_deadline) returns (uint256 paymentAmount) {
        if (!isExternalOption[address(_option)]) {
            revert OptionToken_InvalidOption();
        }
        paymentAmount = _option.getPaymentAmount(_amount, _data);
        _burn(msg.sender, _amount);
        _option.paymentToken().safeTransferFrom(msg.sender, address(_option), paymentAmount);
        UNDERLYING_TOKEN.approve(address(_option), 0);
        UNDERLYING_TOKEN.approve(address(_option), _amount);
        _option.exercise(_amount, msg.sender, _data);
        UNDERLYING_TOKEN.approve(address(_option), 0);
    }

    /// -----------------------------------------------------------------------
    /// Public functions
    /// -----------------------------------------------------------------------

    function getVotingEscrow() external view returns (address votingEscrow) {
        votingEscrow = IVoter(voter).ve();
    }

    /// @notice Returns the discounted price in paymentTokens for a given amount of options tokens
    /// @param _amount The amount of options tokens to exercise
    /// @return The amount of payment tokens to pay to purchase the underlying tokens
    function getDiscountedPrice(uint256 _amount) public view returns (uint256) {
        return getDiscountedPrice(_amount, discount);
    }

    /// @notice Returns the discounted price in paymentTokens for a given amount of options tokens redeemed to veToken
    /// @param _amount The amount of options tokens to exercise
    /// @param _discount The discount amount
    /// @return The amount of payment tokens to pay to purchase the underlying tokens
    function getDiscountedPrice(uint256 _amount, uint256 _discount) public view returns (uint256) {
        return (getTimeWeightedAveragePrice(_amount) * _discount) / 100;
    }

    /// @notice Returns the average price in payment tokens over period defined in twapSeconds for an amount of tokens
    /// @param _amount The amount of underlying tokens to purchase
    /// @return The amount of payment tokens
    function getTimeWeightedAveragePrice(uint256 _amount) public view returns (uint256) {
        return twapOracle.estimateAmountOut(address(UNDERLYING_TOKEN), uint128(_amount), twapSeconds);
    }

    /// @notice Returns the lock duration for a desired discount to create locked LP
    function getLockDurationForLpDiscount(uint256 _discount) public view returns (uint256 duration) {
        (int256 slope, int256 intercept) = getSlopeInterceptForLpDiscount();
        duration = Math.abs(slope * int256(_discount) + intercept);
    }

    /// @notice Returns the lock duration for a desired discount to create locked VE
    function getLockDurationForVeDiscount(uint256 _discount) public view returns (uint256 duration) {
        (int256 slope, int256 intercept) = getSlopeInterceptForVeDiscount();
        duration = Math.abs(slope * int256(_discount) + intercept);
    }

    /// @notice Returns the amount in paymentTokens for a given amount of options tokens required for the LP exercise lp
    /// @param _amount The amount of options tokens to exercise
    /// @param _discount The discount amount
    function getPaymentTokenAmountForExerciseLp(
        uint256 _amount,
        uint256 _discount
    ) public view returns (uint256 paymentAmount, uint256 paymentAmountToAddLiquidity) {
        paymentAmount = getDiscountedPrice(_amount, _discount);
        (uint256 underlyingReserve, uint256 paymentReserve) = IRouter(router).getReserves(
            address(UNDERLYING_TOKEN),
            address(paymentToken),
            false
        );
        paymentAmountToAddLiquidity = (_amount * paymentReserve) / underlyingReserve;
    }

    function getSlopeInterceptForLpDiscount() public view returns (int256 slope, int256 intercept) {
        slope =
            int256(lockDurationForMaxLpDiscount - lockDurationForMinLpDiscount) /
            (int256(maxLPDiscount) - int256(minLPDiscount));
        intercept = int256(lockDurationForMinLpDiscount) - (slope * int256(minLPDiscount));
    }

    function getSlopeInterceptForVeDiscount() public view returns (int256 slope, int256 intercept) {
        slope = int256(FULL_LOCK - lockDurationForMinVeDiscount) / (int256(veMaxDiscount) - int256(veMinDiscount));
        intercept = int256(lockDurationForMinVeDiscount) - (slope * int256(veMinDiscount));
    }

    /// -----------------------------------------------------------------------
    /// Admin functions
    /// -----------------------------------------------------------------------

    /// @notice Sets the twap oracle contract address.
    /// @param _pair The pair contract
    /// @param _twapOracle The twap oracle contract
    /// @param _paymentToken The payment token
    function setPaymentConfiguration(
        IPair _pair,
        IDynamicTwapOracle _twapOracle,
        address _paymentToken
    ) external onlyAdmin {
        _setPaymentConfiguration(_pair, _twapOracle, _paymentToken);
    }

    function _setPaymentConfiguration(IPair _pair, IDynamicTwapOracle _twapOracle, address _paymentToken) internal {
        // Validate Pair
        (address token0, address token1) = _pair.tokens();
        if (
            !((token0 == _paymentToken && token1 == address(UNDERLYING_TOKEN)) ||
                (token0 == address(UNDERLYING_TOKEN) && token1 == _paymentToken))
        ) {
            revert OptionToken_IncorrectPairToken();
        }
        pair = _pair;
        // Validate Twap Oracle
        if (
            !((_twapOracle.token0() == _paymentToken && _twapOracle.token1() == address(UNDERLYING_TOKEN)) ||
                (_twapOracle.token0() == address(UNDERLYING_TOKEN) && _twapOracle.token1() == _paymentToken))
        ) {
            revert OptionToken_IncorrectTwapOracle();
        }
        twapOracle = _twapOracle;
        // Set Payment Token
        if (address(paymentToken) != _paymentToken) {
            if (address(paymentToken) != address(0)) {
                paymentToken.approve(address(feeDistributor), 0);
            }
            paymentToken = ERC20(_paymentToken);
            paymentToken.approve(address(feeDistributor), type(uint256).max);
        }

        emit SetPaymentConfiguration(_pair, _twapOracle, _paymentToken);
    }

    /// @notice Sets the fee distributor. Only callable by the admin.
    /// @param _feeDistributor The new fee distributor.
    function setFeeDistributor(IOptionFeeDistributor _feeDistributor) external onlyAdmin {
        paymentToken.approve(address(feeDistributor), 0);
        feeDistributor = _feeDistributor;
        paymentToken.approve(address(_feeDistributor), type(uint256).max);
        emit SetFeeDistributor(_feeDistributor);
    }

    /// @notice Sets the discount amount. Only callable by the admin.
    /// @param _discount The new discount amount.
    function setDiscount(uint256 _discount) external onlyAdmin {
        if (_discount > MAX_DISCOUNT || _discount == MIN_DISCOUNT) {
            revert OptionToken_InvalidDiscount();
        }
        discount = _discount;
        emit SetDiscount(_discount);
    }

    /// @notice Sets the max discount rate for locking. Only callable by the admin.
    /// @param _veMaxDiscount The new maximum discount amount.
    function setVeMaxDiscount(uint256 _veMaxDiscount) external onlyAdmin {
        if (_veMaxDiscount > MAX_DISCOUNT || _veMaxDiscount == MIN_DISCOUNT || veMinDiscount >= _veMaxDiscount) {
            revert OptionToken_InvalidDiscount();
        }
        veMaxDiscount = _veMaxDiscount;
        emit SetVeMaxDiscount(_veMaxDiscount);
    }

    /// @notice Sets the min discount rate for locking. Only callable by the admin.
    /// @param _veMinDiscount The new minimum discount amount.
    function setVeMinDiscount(uint256 _veMinDiscount) external onlyAdmin {
        if (_veMinDiscount > MAX_DISCOUNT || _veMinDiscount == MIN_DISCOUNT || _veMinDiscount >= veMaxDiscount) {
            revert OptionToken_InvalidDiscount();
        }
        veMinDiscount = _veMinDiscount;
        emit SetVeMinDiscount(_veMinDiscount);
    }

    /// @notice Sets the twap seconds to control the length of our twap
    /// @param _twapSeconds The new twap points.
    function setTwapSeconds(uint32 _twapSeconds) external onlyAdmin {
        if (_twapSeconds > MAX_TWAP_SECONDS || _twapSeconds < MIN_TWAP_SECONDS) {
            revert OptionToken_InvalidTwapSeconds();
        }
        twapSeconds = _twapSeconds;
        emit SetTwapSeconds(_twapSeconds);
    }

    /// @notice Update gauge address to match with Voter contract
    function updateGauge() public {
        address newGauge = IVoter(voter).gauges(address(pair));
        if(newGauge != address(0)) {
            gauge = newGauge;
            emit SetGauge(newGauge);
        }
    }

    /// @notice Sets the gauge address when the gauge is not listed in Voter. Only callable by the admin.
    /// @param _gauge The new treasury address
    function setGauge(address _gauge) external onlyAdmin {
        gauge = _gauge;
        emit SetGauge(_gauge);
    }

    /// @notice Sets the router address. Only callable by the admin.
    /// @param _router The new router address
    function setRouter(address _router) external onlyAdmin {
        router = _router;
        emit SetRouter(_router);
    }

    /// @notice Sets the discount amount for lp. Only callable by the admin.
    /// @param _lpMinDiscount The new discount amount.
    function setMinLPDiscount(uint256 _lpMinDiscount) external onlyAdmin {
        /// @dev Cannot be lower than MIN_DISCOUNT or gte maxLPDiscount
        if (_lpMinDiscount > MAX_DISCOUNT || _lpMinDiscount == MIN_DISCOUNT || maxLPDiscount >= _lpMinDiscount) {
            revert OptionToken_InvalidDiscount();
        }
        minLPDiscount = _lpMinDiscount;
        emit SetMinLPDiscount(_lpMinDiscount);
    }

    /// @notice Sets the discount amount for lp. Only callable by the admin.
    /// @param _lpMaxDiscount The new discount amount.
    function setMaxLPDiscount(uint256 _lpMaxDiscount) external onlyAdmin {
        /// @dev Cannot be higher than MAX_DISCOUNT or lte minLPDiscount
        if (_lpMaxDiscount > MAX_DISCOUNT || _lpMaxDiscount == MIN_DISCOUNT || _lpMaxDiscount >= minLPDiscount) {
            revert OptionToken_InvalidDiscount();
        }
        maxLPDiscount = _lpMaxDiscount;
        emit SetMaxLPDiscount(_lpMaxDiscount);
    }

    /// @notice Sets the lock duration for max discount amount to create LP and stake in gauge.
    /// @param _duration The new lock duration.
    function setLockDurationForMaxLpDiscount(uint256 _duration) external onlyAdmin {
        if (_duration > FULL_LOCK || _duration <= lockDurationForMinLpDiscount) {
            revert OptionToken_InvalidLockDuration();
        }
        lockDurationForMaxLpDiscount = _duration;
        emit SetLockDurationForMaxLpDiscount(_duration);
    }

    // @notice Sets the lock duration for min discount amount to create LP and stake in gauge.
    /// @param _duration The new lock duration.
    function setLockDurationForMinLpDiscount(uint256 _duration) external onlyAdmin {
        if (_duration > lockDurationForMaxLpDiscount) {
            revert OptionToken_InvalidLockDuration();
        }
        lockDurationForMinLpDiscount = _duration;
        emit SetLockDurationForMinLpDiscount(_duration);
    }

    /// @notice Sets the lock duration for min discount amount for locked veToken.
    /// @param _duration The new lock duration.
    function setLockDurationForMinVeDiscount(uint256 _duration) external onlyAdmin {
        if (_duration > FULL_LOCK) {
            revert OptionToken_InvalidLockDuration();
        }
        lockDurationForMinVeDiscount = _duration;
        emit SetLockDurationForMinVeDiscount(_duration);
    }

    /// @notice Called by the admin to burn options tokens and transfer underlying tokens to the caller.
    /// @param _amount The amount of options tokens that will be burned and underlying tokens transferred to the caller
    function burn(uint256 _amount) external onlyAdmin {
        // transfer underlying tokens to the caller
        UNDERLYING_TOKEN.safeTransfer(msg.sender, _amount);
        // burn option tokens
        _burn(msg.sender, _amount);
    }

    /// @notice called by the admin to re-enable option exercising from a paused state.
    function unPause() external onlyAdmin {
        if (!isPaused) return;
        isPaused = false;
        emit PauseStateChanged(false);
    }

    /// @notice called by the admin to re-enable option exercising from a paused state.
    function togglePermissionedMint() external onlyAdmin {
        permissionedMint = !permissionedMint;
    }

    function toggleExternalOption(address option, bool enabled) external onlyAdmin {
        isExternalOption[option] = enabled;
        emit ToggleExternalOption(option, enabled);
    }

    /// -----------------------------------------------------------------------
    /// Minter functions
    /// -----------------------------------------------------------------------

    /// @notice Called by the minter to mint options tokens. Admin must grant token approval.
    /// @param _to The address that will receive the minted options tokens
    /// @param _amount The amount of options tokens that will be minted
    function mint(address _to, uint256 _amount) external onlyMinter {
        // transfer underlying tokens from the caller
        UNDERLYING_TOKEN.safeTransferFrom(msg.sender, address(this), _amount);
        // mint options tokens
        _mint(_to, _amount);
    }

    /// -----------------------------------------------------------------------
    /// Pauser functions
    /// -----------------------------------------------------------------------
    function pause() external onlyPauser {
        if (isPaused) return;
        isPaused = true;
        emit PauseStateChanged(true);
    }

    /// -----------------------------------------------------------------------
    /// Internal functions
    /// -----------------------------------------------------------------------

    function _exercise(
        uint256 _amount,
        uint256 _maxPaymentAmount,
        address _recipient
    ) internal notPaused returns (uint256 paymentAmount) {

        // burn callers tokens
        _burn(msg.sender, _amount);
        paymentAmount = getDiscountedPrice(_amount);
        if (paymentAmount > _maxPaymentAmount) { 
            revert OptionToken_SlippageTooHigh();
        }

        // transfer payment tokens from msg.sender to the fee distributor
        paymentToken.safeTransferFrom(msg.sender, address(this), paymentAmount);
        feeDistributor.distribute(address(paymentToken), paymentAmount);

        // send underlying tokens to recipient
        UNDERLYING_TOKEN.safeTransfer(_recipient, _amount); // will revert on failure

        emit Exercise(msg.sender, _recipient, _amount, paymentAmount);
    }

    function _exerciseVe(
        uint256 _amount,
        uint256 _maxPaymentAmount,
        uint256 _discount,
        address _recipient
    ) internal notPaused returns (uint256 paymentAmount, uint256 nftId) {
        if (_discount > veMinDiscount || _discount < veMaxDiscount) { 
            revert OptionToken_InvalidDiscount();
        }

        // burn callers tokens
        _burn(msg.sender, _amount);
        paymentAmount = getDiscountedPrice(_amount, _discount);
        if (paymentAmount > _maxPaymentAmount) {
            revert OptionToken_SlippageTooHigh();
        }

        // transfer payment tokens from msg.sender to the fee distributor
        paymentToken.safeTransferFrom(msg.sender, address(this), paymentAmount);
        feeDistributor.distribute(address(paymentToken), paymentAmount);

        address votingEscrow = IVoter(voter).ve();

        // lock underlying tokens to vote escrow
        UNDERLYING_TOKEN.approve(votingEscrow, _amount);
        nftId = IVotingEscrowV2(votingEscrow).createLockFor(
            _amount,
            getLockDurationForVeDiscount(_discount),
            _recipient,
            false
        );

        emit ExerciseVe(msg.sender, _recipient, _amount, paymentAmount, nftId);
    }

    function _exerciseLp(
        uint256 _oTokenRedeemAmount,
        uint256 _maxPaymentAmountForExercise,
        uint256 _maxPaymentAmountToAddLiquidity,
        uint256 _minPaymentAmountToAddLiquidity,
        address _recipient,
        uint256 _discount
    ) internal notPaused returns (uint256 paymentAmount, uint256 lpAmount) {
        if(gauge == address(0)) {
            revert OptionToken_NoGaugeForLp();
        }

        if (_discount > minLPDiscount || _discount < maxLPDiscount) {
            revert OptionToken_InvalidDiscount();
        }

        // burn callers tokens
        _burn(msg.sender, _oTokenRedeemAmount);
        uint256 paymentAmountToAddLiquidity;
        (paymentAmount, paymentAmountToAddLiquidity) = getPaymentTokenAmountForExerciseLp(
            _oTokenRedeemAmount,
            _discount
        );

        if (paymentAmount > _maxPaymentAmountForExercise) {
            revert OptionToken_PaymentTooHigh();
        }

        if (
            paymentAmountToAddLiquidity > _maxPaymentAmountToAddLiquidity ||
            paymentAmountToAddLiquidity < _minPaymentAmountToAddLiquidity
        ) {
            revert OptionToken_SlippageTooHigh();
        }

        /// @notice user pays redeem amount + required payment for LP deposit
        paymentToken.safeTransferFrom(msg.sender, address(this), paymentAmount + paymentAmountToAddLiquidity);

        // transfer payment tokens to the fee distributor
        feeDistributor.distribute(address(paymentToken), paymentAmount);

        // Create Lp for users
        UNDERLYING_TOKEN.approve(router, _oTokenRedeemAmount);
        paymentToken.approve(router, paymentAmountToAddLiquidity);
        (, , lpAmount) = IRouter(router).addLiquidity(
            address(UNDERLYING_TOKEN),
            address(paymentToken),
            false,
            _oTokenRedeemAmount,
            paymentAmountToAddLiquidity,
            1,
            _minPaymentAmountToAddLiquidity,
            address(this),
            block.timestamp
        );

        IERC20(address(pair)).approve(gauge, lpAmount);

        IGauge(gauge).depositWithLock(_recipient, lpAmount, getLockDurationForLpDiscount(_discount));

        emit ExerciseLp(msg.sender, _recipient, _oTokenRedeemAmount, paymentAmount, lpAmount);
    }
}

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

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
interface IERC20Upgradeable {
    /**
     * @dev Emitted when `value` tokens are moved from one account (`from`) to
     * another (`to`).
     *
     * Note that `value` may be zero.
     */
    event Transfer(address indexed from, address indexed to, uint256 value);

    /**
     * @dev Emitted when the allowance of a `spender` for an `owner` is set by
     * a call to {approve}. `value` is the new allowance.
     */
    event Approval(address indexed owner, address indexed spender, uint256 value);

    /**
     * @dev Returns the amount of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

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

    /**
     * @dev Moves `amount` tokens from the caller's account to `to`.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transfer(address to, uint256 amount) external returns (bool);

    /**
     * @dev Returns the remaining number of tokens that `spender` will be
     * allowed to spend on behalf of `owner` through {transferFrom}. This is
     * zero by default.
     *
     * This value changes when {approve} or {transferFrom} are called.
     */
    function allowance(address owner, address spender) external view returns (uint256);

    /**
     * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * IMPORTANT: Beware that changing an allowance with this method brings the risk
     * that someone may use both the old and the new allowance by unfortunate
     * transaction ordering. One possible solution to mitigate this race
     * condition is to first reduce the spender's allowance to 0 and set the
     * desired value afterwards:
     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
     *
     * Emits an {Approval} event.
     */
    function approve(address spender, uint256 amount) external returns (bool);

    /**
     * @dev Moves `amount` tokens from `from` to `to` using the
     * allowance mechanism. `amount` is then deducted from the caller's
     * allowance.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(address from, address to, uint256 amount) external returns (bool);
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC721/extensions/IERC721Enumerable.sol)

pragma solidity ^0.8.0;

import "../IERC721Upgradeable.sol";

/**
 * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension
 * @dev See https://eips.ethereum.org/EIPS/eip-721
 */
interface IERC721EnumerableUpgradeable is IERC721Upgradeable {
    /**
     * @dev Returns the total amount of tokens stored by the contract.
     */
    function totalSupply() external view returns (uint256);

    /**
     * @dev Returns a token ID owned by `owner` at a given `index` of its token list.
     * Use along with {balanceOf} to enumerate all of ``owner``'s tokens.
     */
    function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256);

    /**
     * @dev Returns a token ID at a given `index` of all the tokens stored by the contract.
     * Use along with {totalSupply} to enumerate all tokens.
     */
    function tokenByIndex(uint256 index) external view returns (uint256);
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC721/IERC721.sol)

pragma solidity ^0.8.0;

import "../../utils/introspection/IERC165Upgradeable.sol";

/**
 * @dev Required interface of an ERC721 compliant contract.
 */
interface IERC721Upgradeable is IERC165Upgradeable {
    /**
     * @dev Emitted when `tokenId` token is transferred from `from` to `to`.
     */
    event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);

    /**
     * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.
     */
    event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);

    /**
     * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
     */
    event ApprovalForAll(address indexed owner, address indexed operator, bool approved);

    /**
     * @dev Returns the number of tokens in ``owner``'s account.
     */
    function balanceOf(address owner) external view returns (uint256 balance);

    /**
     * @dev Returns the owner of the `tokenId` token.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function ownerOf(uint256 tokenId) external view returns (address owner);

    /**
     * @dev Safely transfers `tokenId` token from `from` to `to`.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must exist and be owned by `from`.
     * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external;

    /**
     * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
     * are aware of the ERC721 protocol to prevent tokens from being forever locked.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must exist and be owned by `from`.
     * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or {setApprovalForAll}.
     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function safeTransferFrom(address from, address to, uint256 tokenId) external;

    /**
     * @dev Transfers `tokenId` token from `from` to `to`.
     *
     * WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721
     * or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must
     * understand this adds an external call which potentially creates a reentrancy vulnerability.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must be owned by `from`.
     * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(address from, address to, uint256 tokenId) external;

    /**
     * @dev Gives permission to `to` to transfer `tokenId` token to another account.
     * The approval is cleared when the token is transferred.
     *
     * Only a single account can be approved at a time, so approving the zero address clears previous approvals.
     *
     * Requirements:
     *
     * - The caller must own the token or be an approved operator.
     * - `tokenId` must exist.
     *
     * Emits an {Approval} event.
     */
    function approve(address to, uint256 tokenId) external;

    /**
     * @dev Approve or remove `operator` as an operator for the caller.
     * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
     *
     * Requirements:
     *
     * - The `operator` cannot be the caller.
     *
     * Emits an {ApprovalForAll} event.
     */
    function setApprovalForAll(address operator, bool approved) external;

    /**
     * @dev Returns the account approved for `tokenId` token.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function getApproved(uint256 tokenId) external view returns (address operator);

    /**
     * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
     *
     * See {setApprovalForAll}
     */
    function isApprovedForAll(address owner, address operator) external view returns (bool);
}

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

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC165 standard, as defined in the
 * https://eips.ethereum.org/EIPS/eip-165[EIP].
 *
 * Implementers can declare support of contract interfaces, which can then be
 * queried by others ({ERC165Checker}).
 *
 * For an implementation, see {ERC165}.
 */
interface IERC165Upgradeable {
    /**
     * @dev Returns true if this contract implements the interface defined by
     * `interfaceId`. See the corresponding
     * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
     * to learn more about how these ids are created.
     *
     * This function call must use less than 30 000 gas.
     */
    function supportsInterface(bytes4 interfaceId) external view returns (bool);
}

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

pragma solidity ^0.8.0;

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

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

    mapping(bytes32 => RoleData) private _roles;

    bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;

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

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

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

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

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

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

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

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

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

        _revokeRole(role, account);
    }

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

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

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

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

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (access/AccessControlEnumerable.sol)

pragma solidity ^0.8.0;

import "./IAccessControlEnumerable.sol";
import "./AccessControl.sol";
import "../utils/structs/EnumerableSet.sol";

/**
 * @dev Extension of {AccessControl} that allows enumerating the members of each role.
 */
abstract contract AccessControlEnumerable is IAccessControlEnumerable, AccessControl {
    using EnumerableSet for EnumerableSet.AddressSet;

    mapping(bytes32 => EnumerableSet.AddressSet) private _roleMembers;

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

    /**
     * @dev Returns one of the accounts that have `role`. `index` must be a
     * value between 0 and {getRoleMemberCount}, non-inclusive.
     *
     * Role bearers are not sorted in any particular way, and their ordering may
     * change at any point.
     *
     * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure
     * you perform all queries on the same block. See the following
     * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]
     * for more information.
     */
    function getRoleMember(bytes32 role, uint256 index) public view virtual override returns (address) {
        return _roleMembers[role].at(index);
    }

    /**
     * @dev Returns the number of accounts that have `role`. Can be used
     * together with {getRoleMember} to enumerate all bearers of a role.
     */
    function getRoleMemberCount(bytes32 role) public view virtual override returns (uint256) {
        return _roleMembers[role].length();
    }

    /**
     * @dev Overload {_grantRole} to track enumerable memberships
     */
    function _grantRole(bytes32 role, address account) internal virtual override {
        super._grantRole(role, account);
        _roleMembers[role].add(account);
    }

    /**
     * @dev Overload {_revokeRole} to track enumerable memberships
     */
    function _revokeRole(bytes32 role, address account) internal virtual override {
        super._revokeRole(role, account);
        _roleMembers[role].remove(account);
    }
}

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

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (access/IAccessControlEnumerable.sol)

pragma solidity ^0.8.0;

import "./IAccessControl.sol";

/**
 * @dev External interface of AccessControlEnumerable declared to support ERC165 detection.
 */
interface IAccessControlEnumerable is IAccessControl {
    /**
     * @dev Returns one of the accounts that have `role`. `index` must be a
     * value between 0 and {getRoleMemberCount}, non-inclusive.
     *
     * Role bearers are not sorted in any particular way, and their ordering may
     * change at any point.
     *
     * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure
     * you perform all queries on the same block. See the following
     * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]
     * for more information.
     */
    function getRoleMember(bytes32 role, uint256 index) external view returns (address);

    /**
     * @dev Returns the number of accounts that have `role`. Can be used
     * together with {getRoleMember} to enumerate all bearers of a role.
     */
    function getRoleMemberCount(bytes32 role) external view returns (uint256);
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/ERC20.sol)

pragma solidity ^0.8.0;

import "./IERC20.sol";
import "./extensions/IERC20Metadata.sol";
import "../../utils/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.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How
 * to implement supply mechanisms].
 *
 * The default value of {decimals} is 18. To change this, you should override
 * this function so it returns a different value.
 *
 * 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}.
     *
     * 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 default value returned by this function, unless
     * it's 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:
     *
     * - `to` cannot be the zero address.
     * - the caller must have a balance of at least `amount`.
     */
    function transfer(address to, uint256 amount) public virtual override returns (bool) {
        address owner = _msgSender();
        _transfer(owner, to, 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}.
     *
     * NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on
     * `transferFrom`. This is semantically equivalent to an infinite approval.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     */
    function approve(address spender, uint256 amount) public virtual override returns (bool) {
        address owner = _msgSender();
        _approve(owner, 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}.
     *
     * NOTE: Does not update the allowance if the current allowance
     * is the maximum `uint256`.
     *
     * Requirements:
     *
     * - `from` and `to` cannot be the zero address.
     * - `from` must have a balance of at least `amount`.
     * - the caller must have allowance for ``from``'s tokens of at least
     * `amount`.
     */
    function transferFrom(address from, address to, uint256 amount) public virtual override returns (bool) {
        address spender = _msgSender();
        _spendAllowance(from, spender, amount);
        _transfer(from, to, 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) {
        address owner = _msgSender();
        _approve(owner, spender, allowance(owner, 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) {
        address owner = _msgSender();
        uint256 currentAllowance = allowance(owner, spender);
        require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
        unchecked {
            _approve(owner, spender, currentAllowance - subtractedValue);
        }

        return true;
    }

    /**
     * @dev Moves `amount` of tokens from `from` to `to`.
     *
     * 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:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `from` must have a balance of at least `amount`.
     */
    function _transfer(address from, address to, uint256 amount) internal virtual {
        require(from != address(0), "ERC20: transfer from the zero address");
        require(to != address(0), "ERC20: transfer to the zero address");

        _beforeTokenTransfer(from, to, amount);

        uint256 fromBalance = _balances[from];
        require(fromBalance >= amount, "ERC20: transfer amount exceeds balance");
        unchecked {
            _balances[from] = fromBalance - amount;
            // Overflow not possible: the sum of all balances is capped by totalSupply, and the sum is preserved by
            // decrementing then incrementing.
            _balances[to] += amount;
        }

        emit Transfer(from, to, amount);

        _afterTokenTransfer(from, to, 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;
        unchecked {
            // Overflow not possible: balance + amount is at most totalSupply + amount, which is checked above.
            _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;
            // Overflow not possible: amount <= accountBalance <= totalSupply.
            _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 Updates `owner` s allowance for `spender` based on spent `amount`.
     *
     * Does not update the allowance amount in case of infinite allowance.
     * Revert if not enough allowance is available.
     *
     * Might emit an {Approval} event.
     */
    function _spendAllowance(address owner, address spender, uint256 amount) internal virtual {
        uint256 currentAllowance = allowance(owner, spender);
        if (currentAllowance != type(uint256).max) {
            require(currentAllowance >= amount, "ERC20: insufficient allowance");
            unchecked {
                _approve(owner, spender, currentAllowance - 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 {}
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)

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

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

pragma solidity ^0.8.0;

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

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

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

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

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
interface IERC20 {
    /**
     * @dev Emitted when `value` tokens are moved from one account (`from`) to
     * another (`to`).
     *
     * Note that `value` may be zero.
     */
    event Transfer(address indexed from, address indexed to, uint256 value);

    /**
     * @dev Emitted when the allowance of a `spender` for an `owner` is set by
     * a call to {approve}. `value` is the new allowance.
     */
    event Approval(address indexed owner, address indexed spender, uint256 value);

    /**
     * @dev Returns the amount of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

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

    /**
     * @dev Moves `amount` tokens from the caller's account to `to`.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transfer(address to, uint256 amount) external returns (bool);

    /**
     * @dev Returns the remaining number of tokens that `spender` will be
     * allowed to spend on behalf of `owner` through {transferFrom}. This is
     * zero by default.
     *
     * This value changes when {approve} or {transferFrom} are called.
     */
    function allowance(address owner, address spender) external view returns (uint256);

    /**
     * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * IMPORTANT: Beware that changing an allowance with this method brings the risk
     * that someone may use both the old and the new allowance by unfortunate
     * transaction ordering. One possible solution to mitigate this race
     * condition is to first reduce the spender's allowance to 0 and set the
     * desired value afterwards:
     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
     *
     * Emits an {Approval} event.
     */
    function approve(address spender, uint256 amount) external returns (bool);

    /**
     * @dev Moves `amount` tokens from `from` to `to` using the
     * allowance mechanism. `amount` is then deducted from the caller's
     * allowance.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(address from, address to, uint256 amount) external returns (bool);
}

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

pragma solidity ^0.8.0;

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

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

    /**
     * @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,
     * non-reverting calls are assumed to be successful.
     */
    function safeTransfer(IERC20 token, address to, uint256 value) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
    }

    /**
     * @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the
     * calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.
     */
    function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
    }

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

    /**
     * @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
     * non-reverting calls are assumed to be successful.
     */
    function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
        uint256 oldAllowance = token.allowance(address(this), spender);
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance + value));
    }

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

    /**
     * @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,
     * non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval
     * to be set to zero before setting it to a non-zero value, such as USDT.
     */
    function forceApprove(IERC20 token, address spender, uint256 value) internal {
        bytes memory approvalCall = abi.encodeWithSelector(token.approve.selector, spender, value);

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

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

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

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

    /**
     * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
     * on the return value: the return value is optional (but if data is returned, it must not be false).
     * @param token The token targeted by the call.
     * @param data The call data (encoded using abi.encode or one of its variants).
     *
     * This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead.
     */
    function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
        // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
        // we're implementing it ourselves. We cannot use {Address-functionCall} here since this should return false
        // and not revert is the subcall reverts.

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

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

pragma solidity ^0.8.1;

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

        return account.code.length > 0;
    }

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

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

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

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

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but also transferring `value` wei to `target`.
     *
     * Requirements:
     *
     * - the calling contract must have an ETH balance of at least `value`.
     * - the called Solidity function must be `payable`.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
        return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
    }

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

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

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

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

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

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

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

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

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

pragma solidity ^0.8.0;

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

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

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

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

pragma solidity ^0.8.0;

import "./IERC165.sol";

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

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

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC165 standard, as defined in the
 * https://eips.ethereum.org/EIPS/eip-165[EIP].
 *
 * Implementers can declare support of contract interfaces, which can then be
 * queried by others ({ERC165Checker}).
 *
 * For an implementation, see {ERC165}.
 */
interface IERC165 {
    /**
     * @dev Returns true if this contract implements the interface defined by
     * `interfaceId`. See the corresponding
     * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
     * to learn more about how these ids are created.
     *
     * This function call must use less than 30 000 gas.
     */
    function supportsInterface(bytes4 interfaceId) external view returns (bool);
}

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

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

pragma solidity ^0.8.0;

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

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

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

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

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

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

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

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

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

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

            return true;
        } else {
            return false;
        }
    }

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

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

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

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

    // Bytes32Set

    struct Bytes32Set {
        Set _inner;
    }

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

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

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

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

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

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

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

        return result;
    }

    // AddressSet

    struct AddressSet {
        Set _inner;
    }

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

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

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

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

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

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

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

        return result;
    }

    // UintSet

    struct UintSet {
        Set _inner;
    }

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

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

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

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

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

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

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

        return result;
    }
}

// SPDX-License-Identifier: MIT
pragma solidity 0.8.13;

interface IGauge {
    function notifyRewardAmount(address token, uint amount) external;

    function getReward(address account, address[] memory tokens) external;

    function getReward(address account) external;

    function claimFees() external returns (uint claimed0, uint claimed1);

    function rewardRate(address _pair) external view returns (uint);

    function balanceOf(address _account) external view returns (uint);

    function isForPair() external view returns (bool);

    function totalSupply() external view returns (uint);

    function earned(address token, address account) external view returns (uint);

    function stakeToken() external view returns (address);

    function setDistribution(address _distro) external;

    function addRewardToken(address _rewardToken) external;

    function removeRewardToken(address _rewardToken) external;

    function updateRewardToken() external;

    function activateEmergencyMode() external;

    function stopEmergencyMode() external;

    function setInternalBribe(address intbribe) external;

    function setGaugeRewarder(address _gr) external;

    function setFeeVault(address _feeVault) external;

    function depositWithLock(address account, uint256 amount, uint256 _lockDuration) external;

    function sweepTokens(address[] memory tokens, uint256[] memory amounts, address to) external;

    function initialize(address _rewardToken,address _ve,address _stakeToken,address _distribution, address _internal_bribe, address _external_bribe, bool _isForPair) external;
    
    }

// SPDX-License-Identifier: MIT
pragma solidity 0.8.13;

interface IPair {
    function metadata() external view returns (uint dec0, uint dec1, uint r0, uint r1, bool st, address t0, address t1);
    function claimFees() external returns (uint, uint);
    function tokens() external view returns (address, address);
    function token0() external view returns (address);
    function token1() external view returns (address);
    function fees() external view returns (address);
    function transferFrom(address src, address dst, uint amount) external returns (bool);
    function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external;
    function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external;
    function burn(address to) external returns (uint amount0, uint amount1);
    function mint(address to) external returns (uint liquidity);
    function getReserves() external view returns (uint _reserve0, uint _reserve1, uint _blockTimestampLast);
    function getAmountOut(uint amountIn, address tokenIn) external view returns (uint);

    function name() external view returns(string memory);
    function symbol() external view returns(string memory);
    function totalSupply() external view returns (uint);
    function decimals() external view returns (uint8);

    function claimable0(address _user) external view returns (uint);
    function claimable1(address _user) external view returns (uint);

    function isStable() external view returns(bool);


}

// SPDX-License-Identifier: MIT
pragma solidity 0.8.13;

interface IRouter { 
    function factory() external view returns (address);
    function pairFor(address tokenA, address tokenB, bool stable) external view returns (address pair);
    function addLiquidity(address tokenA,address tokenB,bool stable,uint amountADesired,uint amountBDesired,uint amountAMin,uint amountBMin,address to,uint deadline) external returns (uint amountA, uint amountB, uint liquidity);
    function getReserves(address tokenA, address tokenB, bool stable) external view returns (uint reserveA, uint reserveB);
}

File 26 of 36 : IVersionable.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

interface IVersionable {
    function VERSION() external view returns (string memory);
}

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

interface IVoter {
    function length() external view returns (uint);
    function pools(uint index) external view returns (address);
    function isAlive(address _gauge) external view returns (bool);
    function ve() external view returns (address);
    function gauges(address _pair) external view returns (address);
    function isGauge(address _gauge) external view returns (bool);
    function poolForGauge(address _gauge) external view returns (address);
    function factory() external view returns (address);
    function minter() external view returns(address);
    function isWhitelisted(address token) external view returns (bool);
    function notifyRewardAmount(uint amount) external;
    function distributeAll() external;
    function distribute(address[] memory _gauges) external;
    function distributeFees(address[] memory _gauges) external;

    function internal_bribes(address _gauge) external view returns (address);
    function external_bribes(address _gauge) external view returns (address);

    function usedWeights(uint id) external view returns(uint);
    function lastVoted(uint id) external view returns(uint);
    function poolVote(uint id, uint _index) external view returns(address _pair);
    function votes(uint id, address _pool) external view returns(uint votes);
    function poolVoteLength(uint tokenId) external view returns(uint);
    
    function attachTokenToGauge(uint _tokenId, address account) external;
    function detachTokenFromGauge(uint _tokenId, address account) external;
}

// SPDX-License-Identifier: MIT
pragma solidity 0.8.13;

library Math {
    function max(uint a, uint b) internal pure returns (uint) {
        return a >= b ? a : b;
    }
    function min(uint a, uint b) internal pure returns (uint) {
        return a < b ? a : b;
    }
    function sqrt(uint y) internal pure returns (uint z) {
        if (y > 3) {
            z = y;
            uint x = y / 2 + 1;
            while (x < z) {
                z = x;
                x = (y / x + x) / 2;
            }
        } else if (y != 0) {
            z = 1;
        }
    }
    function cbrt(uint256 n) internal pure returns (uint256) { unchecked {
        uint256 x = 0;
        for (uint256 y = 1 << 255; y > 0; y >>= 3) {
            x <<= 1;
            uint256 z = 3 * x * (x + 1) + 1;
            if (n / y >= z) {
                n -= y * z;
                x += 1;
            }
        }
        return x;
    }}
    function sub(uint x, uint y) internal pure returns (uint z) {
        require((z = x - y) <= x, 'Math: Sub-underflow');
    }
    function abs(int256 n) internal pure returns (uint256) {
        unchecked {
            // must be unchecked in order to support `n = type(int256).min`
            return uint256(n >= 0 ? n : -n);
        }
    }
}

// SPDX-License-Identifier: GPL-3.0-only
pragma solidity >=0.7.0;

interface IDynamicTwapOracle {
    /**
     * @notice Get the address of the pool
     * @return The address of the pool
     */
    function pool() external view returns (address);

    /**
     * @notice Get the address of the first token in the pool
     * @return The address of the first token
     */
    function token0() external view returns (address);
    
    /**
     * @notice Get the address of the second token in the pool
     * @return The address of the second token
     */
    function token1() external view returns (address);

    /**
     * @notice Estimate the output amount of a trade
     * @param tokenIn The address of the input token
     * @param amountIn The amount of the input token
     * @param secondsAgo The number of seconds ago to start the TWAP
     * @return amountOut The estimated output amount
     */
    function estimateAmountOut(
        address tokenIn,
        uint128 amountIn,
        uint32 secondsAgo
    ) external view returns (uint amountOut);
}

// SPDX-License-Identifier: GPL-3.0-only
pragma solidity 0.8.13;

import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {IAccessControl} from "@openzeppelin/contracts/access/IAccessControl.sol";

interface IOption is IAccessControl {
    function paymentToken() external view returns (IERC20);

    function getPaymentAmount(uint256 _amount, bytes calldata _data) external view returns (uint256);

    function exercise(uint256 _amount, address sender, bytes calldata _data) external returns (uint256);
}

// SPDX-License-Identifier: GPL-3.0-only
pragma solidity 0.8.13;

interface IOptionFeeDistributor {
    function distribute(address token, uint256 amount) external;
}

File 32 of 36 : IOptionTokenV3_1.sol
// SPDX-License-Identifier: GPL-3.0-only
pragma solidity 0.8.13;

import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {IAccessControl} from "@openzeppelin/contracts/access/IAccessControl.sol";
import {IDynamicTwapOracle} from "./DynamicTwapOracle/IDynamicTwapOracle.sol";
import {IOptionFeeDistributor} from "./IOptionFeeDistributor.sol";
import {IPair} from "../interfaces/IPair.sol";
import {IOption} from "./IOption.sol";

interface IOptionTokenV3_1 is IERC20, IAccessControl {
    function ADMIN_ROLE() external view returns (bytes32);

    function MINTER_ROLE() external view returns (bytes32);

    function PAUSER_ROLE() external view returns (bytes32);

    function paymentToken() external view returns (IERC20);

    function UNDERLYING_TOKEN() external view returns (IERC20);

    function voter() external view returns (address);

    function mint(address _to, uint256 _amount) external;

    function exercise(uint256 _amount, uint256 _maxPaymentAmount, address _recipient) external returns (uint256);

    function exercise(
        uint256 _amount,
        uint256 _maxPaymentAmount,
        address _recipient,
        uint256 _deadline
    ) external returns (uint256);

    function exerciseVe(
        uint256 _amount,
        uint256 _maxPaymentAmount,
        address _recipient,
        uint256 _discount,
        uint256 _deadline
    ) external returns (uint256, uint256);

    function exerciseLp(
        uint256 _oTokenRedeemAmount,
        uint256 _maxPaymentAmountForExercise,
        uint256 _maxPaymentAmountToAddLiquidity,
        uint256 _minPaymentAmountToAddLiquidity,
        address _recipient,
        uint256 _discount,
        uint256 _deadline
    ) external returns (uint256, uint256);

    function exerciseExternal(
        IOption _option,
        uint256 _amount,
        uint256 _deadline,
        bytes calldata _data
    ) external returns (uint256);

    function getVotingEscrow() external view returns (address votingEscrow);

    function getLockDurationForVeDiscount(uint256 _discount) external view returns (uint256 duration);

    function getSlopeInterceptForVeDiscount() external view returns (int256 slope, int256 intercept);

    function togglePermissionedMint() external;

    function toggleExternalOption(address option, bool enabled) external;

    function getDiscountedPrice(uint256 _amount) external view returns (uint256);

    function getDiscountedPrice(uint256 _amount, uint256 _discount) external view returns (uint256);

    function getLockDurationForLpDiscount(uint256 _amount) external view returns (uint256);

    function getPaymentTokenAmountForExerciseLp(
        uint256 _amount,
        uint256 _discount
    ) external view returns (uint256, uint256);

    function getSlopeInterceptForLpDiscount() external view returns (int256, int256);

    function getTimeWeightedAveragePrice(uint256 _amount) external view returns (uint256);

    function setPaymentConfiguration(IPair _pair, IDynamicTwapOracle _twapOracle, address _paymentToken) external;

    function setFeeDistributor(IOptionFeeDistributor _feeDistributor) external;

    function setDiscount(uint256 _discount) external;

    function setVeMaxDiscount(uint256 _veMaxDiscount) external;

    function setVeMinDiscount(uint256 _veMinDiscount) external;

    function setMinLPDiscount(uint256 _lpMinDiscount) external;

    function setMaxLPDiscount(uint256 _lpMaxDiscount) external;

    function setLockDurationForMaxLpDiscount(uint256 _duration) external;

    function setLockDurationForMinLpDiscount(uint256 _duration) external;

    function setTwapSeconds(uint32 _twapSeconds) external;

    function burn(uint256 _amount) external;

    function updateGauge() external;

    function setGauge(address _gauge) external;

    function setRouter(address _router) external;

    function unPause() external;

    function pause() external;
}

// SPDX-License-Identifier: CC0-1.0
pragma solidity ^0.8.0;
import "@openzeppelin/contracts-upgradeable/token/ERC721/IERC721Upgradeable.sol";
/**
 * @title Non-Fungible Vesting Token Standard.
 * @notice A non-fungible token standard used to vest ERC-20 tokens over a vesting release curve
 *  scheduled using timestamps.
 * @dev Because this standard relies on timestamps for the vesting schedule, it's important to keep track of the
 *  tokens claimed per Vesting NFT so that a user cannot withdraw more tokens than allotted for a specific Vesting NFT.
 * @custom:interface-id 0xbd3a202b
 */
interface IERC5725Upgradeable is IERC721Upgradeable {
    /**
     *  This event is emitted when the payout is claimed through the claim function.
     *  @param tokenId the NFT tokenId of the assets being claimed.
     *  @param recipient The address which is receiving the payout.
     *  @param claimAmount The amount of tokens being claimed.
     */
    event PayoutClaimed(uint256 indexed tokenId, address indexed recipient, uint256 claimAmount);

    /**
     *  This event is emitted when an `owner` sets an address to manage token claims for all tokens.
     *  @param owner The address setting a manager to manage all tokens.
     *  @param spender The address being permitted to manage all tokens.
     *  @param approved A boolean indicating whether the spender is approved to claim for all tokens.
     */
    event ClaimApprovalForAll(address indexed owner, address indexed spender, bool approved);

    /**
     *  This event is emitted when an `owner` sets an address to manage token claims for a `tokenId`.
     *  @param owner The `owner` of `tokenId`.
     *  @param spender The address being permitted to manage a tokenId.
     *  @param tokenId The unique identifier of the token being managed.
     *  @param approved A boolean indicating whether the spender is approved to claim for `tokenId`.
     */
    event ClaimApproval(address indexed owner, address indexed spender, uint256 indexed tokenId, bool approved);

    /**
     * @notice Claim the pending payout for the NFT.
     * @dev MUST grant the claimablePayout value at the time of claim being called to `msg.sender`.
     *  MUST revert if not called by the token owner or approved users.
     *  MUST emit PayoutClaimed.
     *  SHOULD revert if there is nothing to claim.
     * @param tokenId The NFT token id.
     */
    function claim(uint256 tokenId) external;

    /**
     * @notice Number of tokens for the NFT which have been claimed at the current timestamp.
     * @param tokenId The NFT token id.
     * @return payout The total amount of payout tokens claimed for this NFT.
     */
    function claimedPayout(uint256 tokenId) external view returns (uint256 payout);

    /**
     * @notice Number of tokens for the NFT which can be claimed at the current timestamp.
     * @dev It is RECOMMENDED that this is calculated as the `vestedPayout()` subtracted from `payoutClaimed()`.
     * @param tokenId The NFT token id.
     * @return payout The amount of unlocked payout tokens for the NFT which have not yet been claimed.
     */
    function claimablePayout(uint256 tokenId) external view returns (uint256 payout);

    /**
     * @notice Total amount of tokens which have been vested at the current timestamp.
     *  This number also includes vested tokens which have been claimed.
     * @dev It is RECOMMENDED that this function calls `vestedPayoutAtTime`
     *  with `block.timestamp` as the `timestamp` parameter.
     * @param tokenId The NFT token id.
     * @return payout Total amount of tokens which have been vested at the current timestamp.
     */
    function vestedPayout(uint256 tokenId) external view returns (uint256 payout);

    /**
     * @notice Total amount of vested tokens at the provided timestamp.
     *  This number also includes vested tokens which have been claimed.
     * @dev `timestamp` MAY be both in the future and in the past.
     *  Zero MUST be returned if the timestamp is before the token was minted.
     * @param tokenId The NFT token id.
     * @param timestamp The timestamp to check on, can be both in the past and the future.
     * @return payout Total amount of tokens which have been vested at the provided timestamp.
     */
    function vestedPayoutAtTime(uint256 tokenId, uint256 timestamp) external view returns (uint256 payout);

    /**
     * @notice Number of tokens for an NFT which are currently vesting.
     * @dev The sum of vestedPayout and vestingPayout SHOULD always be the total payout.
     * @param tokenId The NFT token id.
     * @return payout The number of tokens for the NFT which are vesting until a future date.
     */
    function vestingPayout(uint256 tokenId) external view returns (uint256 payout);

    /**
     * @notice The start and end timestamps for the vesting of the provided NFT.
     *  MUST return the timestamp where no further increase in vestedPayout occurs for `vestingEnd`.
     * @param tokenId The NFT token id.
     * @return vestingStart The beginning of the vesting as a unix timestamp.
     * @return vestingEnd The ending of the vesting as a unix timestamp.
     */
    function vestingPeriod(uint256 tokenId) external view returns (uint256 vestingStart, uint256 vestingEnd);

    /**
     * @notice Token which is used to pay out the vesting claims.
     * @param tokenId The NFT token id.
     * @return token The token which is used to pay out the vesting claims.
     */
    function payoutToken(uint256 tokenId) external view returns (address token);

    /**
     * @notice Sets a global `operator` with permission to manage all tokens owned by the current `msg.sender`.
     * @param operator The address to let manage all tokens.
     * @param approved A boolean indicating whether the spender is approved to claim for all tokens.
     */
    function setClaimApprovalForAll(address operator, bool approved) external;

    /**
     * @notice Sets a tokenId `operator` with permission to manage a single `tokenId` owned by the `msg.sender`.
     * @param operator The address to let manage a single `tokenId`.
     * @param tokenId the `tokenId` to be managed.
     * @param approved A boolean indicating whether the spender is approved to claim for all tokens.
     */
    function setClaimApproval(address operator, bool approved, uint256 tokenId) external;

    /**
     * @notice Returns true if `owner` has set `operator` to manage all `tokenId`s.
     * @param owner The owner allowing `operator` to manage all `tokenId`s.
     * @param operator The address who is given permission to spend tokens on behalf of the `owner`.
     */
    function isClaimApprovedForAll(address owner, address operator) external view returns (bool isClaimApproved);

    /**
     * @notice Returns the operating address for a `tokenId`.
     *  If `tokenId` is not managed, then returns the zero address.
     * @param tokenId The NFT `tokenId` to query for a `tokenId` manager.
     */
    function getClaimApproved(uint256 tokenId) external view returns (address operator);
}

interface IERC5725_ExtendedApproval is IERC5725Upgradeable {
    /**
     * @notice Returns true if `operator` is allowed to transfer the `tokenId` NFT.
     * @param operator The address to check if it is approved for the transfer
     * @param tokenId The token id to check if the operator is approved for
     */
    function isApprovedOrOwner(address operator, uint tokenId) external view returns (bool);

    /**
     * @notice Returns true if `operator` is allowed to claim for the provided tokenId
     * @param operator The address to check if it is approved for the claim or owner of the token
     * @param tokenId The token id to check if the operator is approved for
     */
    function isApprovedClaimOrOwner(address operator, uint256 tokenId) external view returns (bool);
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (governance/utils/IVotes.sol)
pragma solidity ^0.8.0;

/**
 * @dev Common interface for {ERC20Votes}, {ERC721Votes}, and other {Votes}-enabled contracts.
 *
 * _Available since v4.5._
 */
interface IVotes {
    /**
     * @dev Emitted when an account changes their delegate.
     */
    event DelegateChanged(address indexed delegator, address indexed fromDelegate, address indexed toDelegate);

    /**
     * @dev Emitted when a token transfer or delegate change results in changes to a delegate's number of votes.
     */
    event DelegateVotesChanged(address indexed delegate, uint256 previousBalance, uint256 newBalance);

    /**
     * @dev Returns the current amount of votes that `account` has.
     */
    function getVotes(address account) external view returns (uint256);

    /**
     * @dev Returns the amount of votes that `account` had at a specific moment in the past. If the `clock()` is
     * configured to use block numbers, this will return the value at the end of the corresponding block.
     */
    function getPastVotes(address account, uint256 timepoint) external view returns (uint256);

    /**
     * @dev Returns the total supply of votes available at a specific moment in the past. If the `clock()` is
     * configured to use block numbers, this will return the value at the end of the corresponding block.
     *
     * NOTE: This value is the sum of all available votes, which is not necessarily the sum of all delegated votes.
     * Votes that have not been delegated are still part of total supply, even though they would not participate in a
     * vote.
     */
    function getPastTotalSupply(uint256 timepoint) external view returns (uint256);

    /**
     * @dev Returns the delegate that `account` has chosen.
     */
    function delegates(address account) external view returns (address);

    /**
     * @dev Delegates votes from the sender to `delegatee`.
     */
    function delegate(address delegatee) external;

    /**
     * @notice Removed from the interface to avoid signature conflicts.
     * @dev Delegates votes from signer to `delegatee`.
     */
    // function delegateBySig(address delegatee, uint256 nonce, uint256 expiry, uint8 v, bytes32 r, bytes32 s) external;
}

// SPDX-License-Identifier: MIT
pragma solidity 0.8.13;

import {IVotes} from "./interfaces/IVotes.sol";
import {Checkpoints} from "./libraries/Checkpoints.sol";
import {IERC5725_ExtendedApproval} from "./erc5725/IERC5725Upgradeable.sol";
import {IERC20Upgradeable} from "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol";
import {IERC721EnumerableUpgradeable} from "@openzeppelin/contracts-upgradeable/token/ERC721/extensions/IERC721EnumerableUpgradeable.sol";
import {IVersionable} from "../../interfaces/IVersionable.sol";

/**
 * @title Voting Escrow V2 Interface for Upgrades
 */
interface IVotingEscrowV2 is IVotes, IERC5725_ExtendedApproval, IERC721EnumerableUpgradeable, IVersionable {
    struct LockDetails {
        uint256 amount; /// @dev amount of tokens locked
        uint256 startTime; /// @dev when locking started
        uint256 endTime; /// @dev when locking ends
        bool isPermanent; /// @dev if its a permanent lock
    }

    /// -----------------------------------------------------------------------
    /// Events
    /// -----------------------------------------------------------------------

    event SupplyUpdated(uint256 oldSupply, uint256 newSupply);
    /// @notice Lock events
    event LockCreated(uint256 indexed tokenId, address indexed to, uint256 value, uint256 unlockTime, bool isPermanent);
    event LockUpdated(uint256 indexed tokenId, uint256 value, uint256 unlockTime, bool isPermanent);
    event LockMerged(
        uint256 indexed fromTokenId,
        uint256 indexed toTokenId,
        uint256 totalValue,
        uint256 unlockTime,
        bool isPermanent
    );
    event LockSplit(uint256[] splitWeights, uint256 indexed _tokenId);
    event LockDurationExtended(uint256 indexed tokenId, uint256 newUnlockTime, bool isPermanent);
    event LockAmountIncreased(uint256 indexed tokenId, uint256 value);
    event UnlockPermanent(uint256 indexed tokenId, address indexed sender, uint256 unlockTime);
    /// @notice Delegate events
    event LockDelegateChanged(
        uint256 indexed tokenId,
        address indexed delegator,
        address fromDelegate,
        address indexed toDelegate
    );

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

    error AlreadyVoted();
    error InvalidNonce();
    error InvalidDelegatee();
    error InvalidSignature();
    error InvalidSignatureS();
    error InvalidWeights();
    error LockDurationNotInFuture();
    error LockDurationTooLong();
    error LockExpired();
    error LockNotExpired();
    error LockHoldsValue();
    error LockModifiedDelay();
    error NotPermanentLock();
    error PermanentLock();
    error PermanentLockMismatch();
    error SameNFT();
    error SignatureExpired();
    error ZeroAmount();
    error NotLockOwner();

    function supply() external view returns (uint);

    function token() external view returns (IERC20Upgradeable);

    function totalNftsMinted() external view returns (uint256);

    function balanceOfNFT(uint256 _tokenId) external view returns (uint256);

    function balanceOfNFTAt(uint256 _tokenId, uint256 _timestamp) external view returns (uint256);

    function delegates(uint256 tokenId, uint48 timestamp) external view returns (address);

    function lockDetails(uint256 tokenId) external view returns (LockDetails calldata);

    function getPastEscrowPoint(
        uint256 _tokenId,
        uint256 _timePoint
    ) external view returns (Checkpoints.Point memory, uint48);

    function getFirstEscrowPoint(uint256 _tokenId) external view returns (Checkpoints.Point memory, uint48);

    function checkpoint() external;

    function increaseAmount(uint256 _tokenId, uint256 _value) external;

    function createLockFor(
        uint256 _value,
        uint256 _lockDuration,
        address _to,
        bool _permanent
    ) external returns (uint256);

    function createDelegatedLockFor(
        uint256 _value,
        uint256 _lockDuration,
        address _to,
        address _delegatee,
        bool _permanent
    ) external returns (uint256);

    function split(uint256[] memory _weights, uint256 _tokenId) external;

    function merge(uint256 _from, uint256 _to) external;

    function burn(uint256 _tokenId) external;

    function decimals() external view returns (uint8);
}

// SPDX-License-Identifier: MIT
// This file was derived from OpenZeppelin Contracts (last updated v5.0.0) (utils/structs/Checkpoints.sol)

pragma solidity 0.8.13;

import {Math} from "@openzeppelin/contracts/utils/math/Math.sol";

/**
 * @dev This library defines the `Trace*` struct, for checkpointing values as they change at different points in
 * time, and later looking up past values by block number. See {Votes} as an example.
 *
 * To create a history of checkpoints define a variable type `Checkpoints.Trace*` in your contract, and store a new
 * checkpoint for the current transaction block using the {push} function.
 */
library Checkpoints {
    struct Trace {
        Checkpoint[] _checkpoints;
    }

    /**
     * @dev Struct to keep track of the voting power over time.
     */
    struct Point {
        /// @dev The voting power at a specific time
        /// - MUST never be negative.
        int128 bias;
        /// @dev The rate at which the voting power decreases over time.
        int128 slope;
        /// @dev The value of tokens which do not decrease over time, representing permanent voting power
        /// - MUST never be negative.
        int128 permanent;
    }

    struct Checkpoint {
        uint48 _key;
        Point _value;
    }

    /**
     * @dev A value was attempted to be inserted on a past checkpoint.
     */
    error CheckpointUnorderedInsertions();

    /**
     * @dev Pushes a (`key`, `value`) pair into a Trace so that it is stored as the checkpoint.
     *
     * Returns previous value and new value.
     *
     * IMPORTANT: Never accept `key` as a user input, since an arbitrary `type(uint48).max` key set will disable the
     * library.
     */
    function push(Trace storage self, uint48 key, Point memory value) internal returns (Point memory, Point memory) {
        return _insert(self._checkpoints, key, value);
    }

    /**
     * @dev Returns the value in the first (oldest) checkpoint with key greater or equal than the search key, or zero if
     * there is none.
     */
    function lowerLookup(Trace storage self, uint48 key) internal view returns (Point memory) {
        uint256 len = self._checkpoints.length;
        uint256 pos = _lowerBinaryLookup(self._checkpoints, key, 0, len);
        return pos == len ? blankPoint() : _unsafeAccess(self._checkpoints, pos)._value;
    }

    /**
     * @dev Returns the value in the last (most recent) checkpoint with key lower or equal than the search key, or zero
     * if there is none.
     */
    function upperLookup(
        Trace storage self,
        uint48 key
    ) internal view returns (bool exists, uint48 _key, Point memory _value) {
        uint256 len = self._checkpoints.length;
        uint256 pos = _upperBinaryLookup(self._checkpoints, key, 0, len);

        exists = pos != 0;
        _value = exists ? _unsafeAccess(self._checkpoints, pos - 1)._value : blankPoint();
        _key = exists ? _unsafeAccess(self._checkpoints, pos - 1)._key : 0;
    }

    /**
     * @dev Returns the value in the last (most recent) checkpoint with key lower or equal than the search key, or zero
     * if there is none.
     *
     * NOTE: This is a variant of {upperLookup} that is optimised to find "recent" checkpoint (checkpoints with high
     * keys).
     */
    function upperLookupRecent(
        Trace storage self,
        uint48 key
    ) internal view returns (bool exists, uint48 _key, Point memory _value) {
        uint256 len = self._checkpoints.length;

        uint256 low = 0;
        uint256 high = len;

        if (len > 5) {
            uint256 mid = len - Math.sqrt(len);
            if (key < _unsafeAccess(self._checkpoints, mid)._key) {
                high = mid;
            } else {
                low = mid + 1;
            }
        }

        uint256 pos = _upperBinaryLookup(self._checkpoints, key, low, high);

        exists = pos != 0;
        _value = exists ? _unsafeAccess(self._checkpoints, pos - 1)._value : blankPoint();
        _key = exists ? _unsafeAccess(self._checkpoints, pos - 1)._key : 0;
    }

    /**
     * @dev Returns the value in the most recent checkpoint, or zero if there are no checkpoints.
     */
    function latest(Trace storage self) internal view returns (Point memory) {
        uint256 pos = self._checkpoints.length;
        return pos == 0 ? blankPoint() : _unsafeAccess(self._checkpoints, pos - 1)._value;
    }

    /**
     * @dev Returns whether there is a checkpoint in the structure (i.e. it is not empty), and if so the key and value
     * in the most recent checkpoint.
     */
    function latestCheckpoint(
        Trace storage self
    ) internal view returns (bool exists, uint48 _key, Point memory _value) {
        uint256 pos = self._checkpoints.length;
        if (pos == 0) {
            return (false, 0, blankPoint());
        } else {
            Checkpoint memory ckpt = _unsafeAccess(self._checkpoints, pos - 1);
            return (true, ckpt._key, ckpt._value);
        }
    }

    /**
     * @dev Returns whether there is a checkpoint in the structure (i.e. it is not empty), and if so the key and value
     * in the most recent checkpoint.
     */
    function firstCheckpoint(
        Trace storage self
    ) internal view returns (bool exists, uint48 _key, Point memory _value) {
        uint256 pos = self._checkpoints.length;
        if (pos == 0) {
            return (false, 0, blankPoint());
        } else {
            Checkpoint memory ckpt = _unsafeAccess(self._checkpoints, 0);
            return (true, ckpt._key, ckpt._value);
        }
    }

    /**
     * @dev Returns the number of checkpoint.
     */
    function length(Trace storage self) internal view returns (uint256) {
        return self._checkpoints.length;
    }

    /**
     * @dev Returns checkpoint at given position.
     */
    function at(Trace storage self, uint48 pos) internal view returns (Checkpoint memory) {
        return self._checkpoints[pos];
    }

    /**
     * @dev Pushes a (`key`, `value`) pair into an ordered list of checkpoints, either by inserting a new checkpoint,
     * or by updating the last one.
     */
    function _insert(
        Checkpoint[] storage self,
        uint48 key,
        Point memory value
    ) private returns (Point memory, Point memory) {
        uint256 pos = self.length;

        if (pos > 0) {
            // Copying to memory is important here.
            Checkpoint memory last = _unsafeAccess(self, pos - 1);

            // Checkpoint keys must be non-decreasing.
            if (last._key > key) {
                revert CheckpointUnorderedInsertions();
            }

            // Update or push new checkpoint
            if (last._key == key) {
                _unsafeAccess(self, pos - 1)._value = value;
            } else {
                self.push(Checkpoint({_key: key, _value: value}));
            }
            return (last._value, value);
        } else {
            self.push(Checkpoint({_key: key, _value: value}));
            return (blankPoint(), value);
        }
    }

    /**
     * @dev Return the index of the last (most recent) checkpoint with key lower or equal than the search key, or `high`
     * if there is none. `low` and `high` define a section where to do the search, with inclusive `low` and exclusive
     * `high`.
     *
     * WARNING: `high` should not be greater than the array's length.
     */
    function _upperBinaryLookup(
        Checkpoint[] storage self,
        uint48 key,
        uint256 low,
        uint256 high
    ) private view returns (uint256) {
        while (low < high) {
            uint256 mid = Math.average(low, high);
            if (_unsafeAccess(self, mid)._key > key) {
                high = mid;
            } else {
                low = mid + 1;
            }
        }
        return high;
    }

    /**
     * @dev Return the index of the first (oldest) checkpoint with key is greater or equal than the search key, or
     * `high` if there is none. `low` and `high` define a section where to do the search, with inclusive `low` and
     * exclusive `high`.
     *
     * WARNING: `high` should not be greater than the array's length.
     */
    function _lowerBinaryLookup(
        Checkpoint[] storage self,
        uint48 key,
        uint256 low,
        uint256 high
    ) private view returns (uint256) {
        while (low < high) {
            uint256 mid = Math.average(low, high);
            if (_unsafeAccess(self, mid)._key < key) {
                low = mid + 1;
            } else {
                high = mid;
            }
        }
        return high;
    }

    /**
     * @dev Access an element of the array without performing bounds check. The position is assumed to be within bounds.
     */
    function _unsafeAccess(Checkpoint[] storage self, uint256 pos) private view returns (Checkpoint storage result) {
        return self[pos];
    }

    /**
     * @dev Access an element of the array without performing bounds check. The position is assumed to be within bounds.
     */
    function _realUnsafeAccess(
        Checkpoint[] storage self,
        uint256 pos
    ) private pure returns (Checkpoint storage result) {
        assembly {
            mstore(0, self.slot)
            result.slot := add(keccak256(0, 0x20), pos)
        }
    }

    function blankPoint() internal pure returns (Point memory) {
        return Point({bias: 0, slope: 0, permanent: 0});
    }

    struct TraceAddress {
        CheckpointAddress[] _checkpoints;
    }

    struct CheckpointAddress {
        uint48 _key;
        address _value;
    }

    /**
     * @dev Pushes a (`key`, `value`) pair into a TraceAddress so that it is stored as the checkpoint.
     *
     * Returns previous value and new value.
     *
     * IMPORTANT: Never accept `key` as a user input, since an arbitrary `type(uint48).max` key set will disable the
     * library.
     */
    function push(TraceAddress storage self, uint48 key, address value) internal returns (address, address) {
        return _insert(self._checkpoints, key, value);
    }

    /**
     * @dev Returns the value in the first (oldest) checkpoint with key greater or equal than the search key, or zero if
     * there is none.
     */
    function lowerLookup(TraceAddress storage self, uint48 key) internal view returns (address) {
        uint256 len = self._checkpoints.length;
        uint256 pos = _lowerBinaryLookup(self._checkpoints, key, 0, len);
        return pos == len ? address(0) : _unsafeAccess(self._checkpoints, pos)._value;
    }

    /**
     * @dev Returns the value in the last (most recent) checkpoint with key lower or equal than the search key, or zero
     * if there is none.
     */
    function upperLookup(TraceAddress storage self, uint48 key) internal view returns (address) {
        uint256 len = self._checkpoints.length;
        uint256 pos = _upperBinaryLookup(self._checkpoints, key, 0, len);
        return pos == 0 ? address(0) : _unsafeAccess(self._checkpoints, pos - 1)._value;
    }

    /**
     * @dev Returns the value in the last (most recent) checkpoint with key lower or equal than the search key, or zero
     * if there is none.
     *
     * NOTE: This is a variant of {upperLookup} that is optimised to find "recent" checkpoint (checkpoints with high
     * keys).
     */
    function upperLookupRecent(TraceAddress storage self, uint48 key) internal view returns (address) {
        uint256 len = self._checkpoints.length;

        uint256 low = 0;
        uint256 high = len;

        if (len > 5) {
            uint256 mid = len - Math.sqrt(len);
            if (key < _unsafeAccess(self._checkpoints, mid)._key) {
                high = mid;
            } else {
                low = mid + 1;
            }
        }

        uint256 pos = _upperBinaryLookup(self._checkpoints, key, low, high);

        return pos == 0 ? address(0) : _unsafeAccess(self._checkpoints, pos - 1)._value;
    }

    /**
     * @dev Returns the value in the most recent checkpoint, or zero if there are no checkpoints.
     */
    function latest(TraceAddress storage self) internal view returns (address) {
        uint256 pos = self._checkpoints.length;
        return pos == 0 ? address(0) : _unsafeAccess(self._checkpoints, pos - 1)._value;
    }

    /**
     * @dev Returns whether there is a checkpoint in the structure (i.e. it is not empty), and if so the key and value
     * in the most recent checkpoint.
     */
    function latestCheckpoint(
        TraceAddress storage self
    ) internal view returns (bool exists, uint48 _key, address _value) {
        uint256 pos = self._checkpoints.length;
        if (pos == 0) {
            return (false, 0, address(0));
        } else {
            CheckpointAddress memory ckpt = _unsafeAccess(self._checkpoints, pos - 1);
            return (true, ckpt._key, ckpt._value);
        }
    }

    /**
     * @dev Returns the number of checkpoint.
     */
    function length(TraceAddress storage self) internal view returns (uint256) {
        return self._checkpoints.length;
    }

    /**
     * @dev Returns checkpoint at given position.
     */
    function at(TraceAddress storage self, uint48 pos) internal view returns (CheckpointAddress memory) {
        return self._checkpoints[pos];
    }

    /**
     * @dev Pushes a (`key`, `value`) pair into an ordered list of checkpoints, either by inserting a new checkpoint,
     * or by updating the last one.
     */
    function _insert(CheckpointAddress[] storage self, uint48 key, address value) private returns (address, address) {
        uint256 pos = self.length;

        if (pos > 0) {
            // Copying to memory is important here.
            CheckpointAddress memory last = _unsafeAccess(self, pos - 1);

            // Checkpoint keys must be non-decreasing.
            if (last._key > key) {
                revert CheckpointUnorderedInsertions();
            }

            // Update or push new checkpoint
            if (last._key == key) {
                _unsafeAccess(self, pos - 1)._value = value;
            } else {
                self.push(CheckpointAddress({_key: key, _value: value}));
            }
            return (last._value, value);
        } else {
            self.push(CheckpointAddress({_key: key, _value: value}));
            return (address(0), value);
        }
    }

    /**
     * @dev Return the index of the last (most recent) checkpoint with key lower or equal than the search key, or `high`
     * if there is none. `low` and `high` define a section where to do the search, with inclusive `low` and exclusive
     * `high`.
     *
     * WARNING: `high` should not be greater than the array's length.
     */
    function _upperBinaryLookup(
        CheckpointAddress[] storage self,
        uint48 key,
        uint256 low,
        uint256 high
    ) private view returns (uint256) {
        while (low < high) {
            uint256 mid = Math.average(low, high);
            if (_unsafeAccess(self, mid)._key > key) {
                high = mid;
            } else {
                low = mid + 1;
            }
        }
        return high;
    }

    /**
     * @dev Return the index of the first (oldest) checkpoint with key is greater or equal than the search key, or
     * `high` if there is none. `low` and `high` define a section where to do the search, with inclusive `low` and
     * exclusive `high`.
     *
     * WARNING: `high` should not be greater than the array's length.
     */
    function _lowerBinaryLookup(
        CheckpointAddress[] storage self,
        uint48 key,
        uint256 low,
        uint256 high
    ) private view returns (uint256) {
        while (low < high) {
            uint256 mid = Math.average(low, high);
            if (_unsafeAccess(self, mid)._key < key) {
                low = mid + 1;
            } else {
                high = mid;
            }
        }
        return high;
    }

    /**
     * @dev Access an element of the array without performing bounds check. The position is assumed to be within bounds.
     */
    function _unsafeAccess(
        CheckpointAddress[] storage self,
        uint256 pos
    ) private pure returns (CheckpointAddress storage result) {
        assembly {
            mstore(0, self.slot)
            result.slot := add(keccak256(0, 0x20), pos)
        }
    }
}

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

Contract Security Audit

Contract ABI

API
[{"inputs":[{"internalType":"string","name":"_name","type":"string"},{"internalType":"string","name":"_symbol","type":"string"},{"internalType":"address","name":"_admin","type":"address"},{"internalType":"contract ERC20","name":"_paymentToken","type":"address"},{"internalType":"contract ERC20","name":"_underlyingToken","type":"address"},{"internalType":"contract IDynamicTwapOracle","name":"_twapOracle","type":"address"},{"internalType":"contract IOptionFeeDistributor","name":"_feeDistributor","type":"address"},{"internalType":"address","name":"_voter","type":"address"},{"internalType":"contract IPair","name":"_pair","type":"address"},{"internalType":"address","name":"_router","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"OptionToken_IncorrectPairToken","type":"error"},{"inputs":[],"name":"OptionToken_IncorrectTwapOracle","type":"error"},{"inputs":[],"name":"OptionToken_InvalidDiscount","type":"error"},{"inputs":[],"name":"OptionToken_InvalidLockDuration","type":"error"},{"inputs":[],"name":"OptionToken_InvalidOption","type":"error"},{"inputs":[],"name":"OptionToken_InvalidTwapSeconds","type":"error"},{"inputs":[],"name":"OptionToken_NoAdminRole","type":"error"},{"inputs":[],"name":"OptionToken_NoGaugeForLp","type":"error"},{"inputs":[],"name":"OptionToken_NoMinterRole","type":"error"},{"inputs":[],"name":"OptionToken_NoPauserRole","type":"error"},{"inputs":[],"name":"OptionToken_PastDeadline","type":"error"},{"inputs":[],"name":"OptionToken_Paused","type":"error"},{"inputs":[],"name":"OptionToken_PaymentTooHigh","type":"error"},{"inputs":[],"name":"OptionToken_SlippageTooHigh","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"sender","type":"address"},{"indexed":true,"internalType":"address","name":"recipient","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"paymentAmount","type":"uint256"}],"name":"Exercise","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"sender","type":"address"},{"indexed":true,"internalType":"address","name":"recipient","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"paymentAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"lpAmount","type":"uint256"}],"name":"ExerciseLp","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"sender","type":"address"},{"indexed":true,"internalType":"address","name":"recipient","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"paymentAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"nftId","type":"uint256"}],"name":"ExerciseVe","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bool","name":"isPaused","type":"bool"}],"name":"PauseStateChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"discount","type":"uint256"}],"name":"SetDiscount","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract IOptionFeeDistributor","name":"newFeeDistributor","type":"address"}],"name":"SetFeeDistributor","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"newGauge","type":"address"}],"name":"SetGauge","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"lockDurationForMaxLpDiscount","type":"uint256"}],"name":"SetLockDurationForMaxLpDiscount","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"lockDurationForMinLpDiscount","type":"uint256"}],"name":"SetLockDurationForMinLpDiscount","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"lockDurationForMinVeDiscount","type":"uint256"}],"name":"SetLockDurationForMinVeDiscount","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"lpMaxDiscount","type":"uint256"}],"name":"SetMaxLPDiscount","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"lpMinDiscount","type":"uint256"}],"name":"SetMinLPDiscount","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract IPair","name":"pair","type":"address"},{"indexed":true,"internalType":"contract IDynamicTwapOracle","name":"twapOracle","type":"address"},{"indexed":true,"internalType":"address","name":"paymentToken","type":"address"}],"name":"SetPaymentConfiguration","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"router","type":"address"}],"name":"SetRouter","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint32","name":"twapSeconds","type":"uint32"}],"name":"SetTwapSeconds","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"veMaxDiscount","type":"uint256"}],"name":"SetVeMaxDiscount","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"veMinDiscount","type":"uint256"}],"name":"SetVeMinDiscount","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"option","type":"address"},{"indexed":false,"internalType":"bool","name":"enabled","type":"bool"}],"name":"ToggleExternalOption","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"inputs":[],"name":"ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"FULL_LOCK","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MAX_DISCOUNT","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MAX_TWAP_SECONDS","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MINTER_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MIN_DISCOUNT","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MIN_TWAP_SECONDS","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"PAUSER_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"UNDERLYING_TOKEN","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"VERSION","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"burn","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"subtractedValue","type":"uint256"}],"name":"decreaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"discount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"uint256","name":"_maxPaymentAmount","type":"uint256"},{"internalType":"address","name":"_recipient","type":"address"},{"internalType":"uint256","name":"_deadline","type":"uint256"}],"name":"exercise","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"uint256","name":"_maxPaymentAmount","type":"uint256"},{"internalType":"address","name":"_recipient","type":"address"}],"name":"exercise","outputs":[{"internalType":"uint256","name":"paymentAmount","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IOption","name":"_option","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"uint256","name":"_deadline","type":"uint256"},{"internalType":"bytes","name":"_data","type":"bytes"}],"name":"exerciseExternal","outputs":[{"internalType":"uint256","name":"paymentAmount","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_oTokenRedeemAmount","type":"uint256"},{"internalType":"uint256","name":"_maxPaymentAmountForExercise","type":"uint256"},{"internalType":"uint256","name":"_maxPaymentAmountToAddLiquidity","type":"uint256"},{"internalType":"uint256","name":"_minPaymentAmountToAddLiquidity","type":"uint256"},{"internalType":"address","name":"_recipient","type":"address"},{"internalType":"uint256","name":"_discount","type":"uint256"},{"internalType":"uint256","name":"_deadline","type":"uint256"}],"name":"exerciseLp","outputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"uint256","name":"_maxPaymentAmount","type":"uint256"},{"internalType":"address","name":"_recipient","type":"address"},{"internalType":"uint256","name":"_discount","type":"uint256"},{"internalType":"uint256","name":"_deadline","type":"uint256"}],"name":"exerciseVe","outputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"feeDistributor","outputs":[{"internalType":"contract IOptionFeeDistributor","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"gauge","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"uint256","name":"_discount","type":"uint256"}],"name":"getDiscountedPrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"getDiscountedPrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_discount","type":"uint256"}],"name":"getLockDurationForLpDiscount","outputs":[{"internalType":"uint256","name":"duration","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_discount","type":"uint256"}],"name":"getLockDurationForVeDiscount","outputs":[{"internalType":"uint256","name":"duration","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"uint256","name":"_discount","type":"uint256"}],"name":"getPaymentTokenAmountForExerciseLp","outputs":[{"internalType":"uint256","name":"paymentAmount","type":"uint256"},{"internalType":"uint256","name":"paymentAmountToAddLiquidity","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"uint256","name":"index","type":"uint256"}],"name":"getRoleMember","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleMemberCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getSlopeInterceptForLpDiscount","outputs":[{"internalType":"int256","name":"slope","type":"int256"},{"internalType":"int256","name":"intercept","type":"int256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getSlopeInterceptForVeDiscount","outputs":[{"internalType":"int256","name":"slope","type":"int256"},{"internalType":"int256","name":"intercept","type":"int256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"getTimeWeightedAveragePrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getVotingEscrow","outputs":[{"internalType":"address","name":"votingEscrow","type":"address"}],"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":"spender","type":"address"},{"internalType":"uint256","name":"addedValue","type":"uint256"}],"name":"increaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"isPaused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lockDurationForMaxLpDiscount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lockDurationForMinLpDiscount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lockDurationForMinVeDiscount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxLPDiscount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"minLPDiscount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"mint","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pair","outputs":[{"internalType":"contract IPair","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paymentToken","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"permissionedMint","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"router","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_discount","type":"uint256"}],"name":"setDiscount","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IOptionFeeDistributor","name":"_feeDistributor","type":"address"}],"name":"setFeeDistributor","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_gauge","type":"address"}],"name":"setGauge","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_duration","type":"uint256"}],"name":"setLockDurationForMaxLpDiscount","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_duration","type":"uint256"}],"name":"setLockDurationForMinLpDiscount","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_duration","type":"uint256"}],"name":"setLockDurationForMinVeDiscount","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_lpMaxDiscount","type":"uint256"}],"name":"setMaxLPDiscount","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_lpMinDiscount","type":"uint256"}],"name":"setMinLPDiscount","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IPair","name":"_pair","type":"address"},{"internalType":"contract IDynamicTwapOracle","name":"_twapOracle","type":"address"},{"internalType":"address","name":"_paymentToken","type":"address"}],"name":"setPaymentConfiguration","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_router","type":"address"}],"name":"setRouter","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint32","name":"_twapSeconds","type":"uint32"}],"name":"setTwapSeconds","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_veMaxDiscount","type":"uint256"}],"name":"setVeMaxDiscount","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_veMinDiscount","type":"uint256"}],"name":"setVeMinDiscount","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":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"option","type":"address"},{"internalType":"bool","name":"enabled","type":"bool"}],"name":"toggleExternalOption","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"togglePermissionedMint","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"twapOracle","outputs":[{"internalType":"contract IDynamicTwapOracle","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"twapSeconds","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"unPause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"updateGauge","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"veMaxDiscount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"veMinDiscount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"voter","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"}]

0x60a06040526014600e8190556050600f556303c2670060105562093a80601155621275006012556028601381905560009091556015556016805465ff00ffffffff1916611c201790553480156200005557600080fd5b506040516200548438038062005484833981016040819052620000789162000c91565b89518a908a906200009190600390602085019062000af6565b508051620000a790600490602084019062000af6565b50620000b9915060009050896200039d565b620000d460008051602062005464833981519152896200039d565b620001007f539440820030c4994db4e31b6b800deafd503688728f932addfe7a410515c14c896200039d565b6200011b6000805160206200546483398151915280620003e0565b620001567ff0887ba65ee2024ea881d91b74c2450ef19e1557f03bed3ea9f16b037cbe2dc960008051602062005464833981519152620003e0565b620001917f539440820030c4994db4e31b6b800deafd503688728f932addfe7a410515c14c60008051602062005464833981519152620003e0565b6001600160a01b03868116608052600c80546001600160a01b031990811688841617909155600d8054821687841617905560098054821684841617905560088054909116918516919091179055620001eb8286896200042b565b620001f56200090a565b6009546040516001600160a01b03909116907f6de4326a8b9054d72d9dbab97d27bc4edffadee7d966f5af9cc4eafdaf8e545590600090a26040516001600160a01b038516907f9e9a9a4a82acd1b28aab6bf1d43aad70ae6d290549c0d6183e2e91ebcdf5744190600090a27ff247e4dd947ab13ba6c46412e403447a26e67109ba13945a20e3170e9acef8836013546040516200029591815260200190565b60405180910390a17f5e08a24ce41a50207cd6c60d4c0b135c6385789570e226d4672e781c49855025601454604051620002d191815260200190565b60405180910390a17f0b5cc1380abb95639d90f536a9af619d222cffe2fe5c9e825728b6d7d05e68de6015546040516200030d91815260200190565b60405180910390a17feccba1be6a56ca0e2c089e59a99f130b3f0bbe23d7bb2d085c278d51b3842058600f546040516200034991815260200190565b60405180910390a17f09734b71a2b91b11a979f46fe8751cc0a22e29af3006d1ba5196a7ace08798b4600e546040516200038591815260200190565b60405180910390a15050505050505050505062000e58565b620003b48282620009df60201b6200217b1760201c565b6000828152600660209081526040909120620003db9183906200220162000a84821b17901c565b505050565b600082815260056020526040808220600101805490849055905190918391839186917fbd79b86ffe0ab8e8776151514217cd7cacd52c909f66475c3af44e129f0b00ff9190a4505050565b600080846001600160a01b0316639d63848a6040518163ffffffff1660e01b81526004016040805180830381865afa1580156200046c573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000492919062000d92565b91509150826001600160a01b0316826001600160a01b0316148015620004cb57506080516001600160a01b0316816001600160a01b0316145b806200050757506080516001600160a01b0316826001600160a01b0316148015620005075750826001600160a01b0316816001600160a01b0316145b620005255760405163a818b0ad60e01b815260040160405180910390fd5b84600a60006101000a8154816001600160a01b0302191690836001600160a01b03160217905550826001600160a01b0316846001600160a01b0316630dfe16816040518163ffffffff1660e01b8152600401602060405180830381865afa15801562000595573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620005bb919062000dd1565b6001600160a01b03161480156200064957506080516001600160a01b0316846001600160a01b031663d21220a76040518163ffffffff1660e01b8152600401602060405180830381865afa15801562000618573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200063e919062000dd1565b6001600160a01b0316145b806200074d57506080516001600160a01b0316846001600160a01b0316630dfe16816040518163ffffffff1660e01b8152600401602060405180830381865afa1580156200069b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620006c1919062000dd1565b6001600160a01b03161480156200074d5750826001600160a01b0316846001600160a01b031663d21220a76040518163ffffffff1660e01b8152600401602060405180830381865afa1580156200071c573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000742919062000dd1565b6001600160a01b0316145b6200076b57604051631bf31bfb60e31b815260040160405180910390fd5b600c80546001600160a01b0319166001600160a01b0386811691909117909155600754848216911614620008b9576007546001600160a01b0316156200082957600754600d5460405163095ea7b360e01b81526001600160a01b0391821660048201526000602482015291169063095ea7b3906044016020604051808303816000875af115801562000801573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000827919062000df8565b505b600780546001600160a01b0319166001600160a01b03858116918217909255600d5460405163095ea7b360e01b81529216600483015260001960248301529063095ea7b3906044016020604051808303816000875af115801562000891573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620008b7919062000df8565b505b826001600160a01b0316846001600160a01b0316866001600160a01b03167f9393b560cd26f49fe024dd267863e33175eac92055a63c0151d12dd81f5cec5360405160405180910390a45050505050565b600854600a5460405163b9a09fd560e01b81526001600160a01b039182166004820152600092919091169063b9a09fd590602401602060405180830381865afa1580156200095c573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000982919062000dd1565b90506001600160a01b03811615620009dc57600b80546001600160a01b0319166001600160a01b0383169081179091556040517f17228b08e4c958112a0827a6d8dc8475dba58dd068a3d400800a606794db02a690600090a25b50565b60008281526005602090815260408083206001600160a01b038516845290915290205460ff1662000a805760008281526005602090815260408083206001600160a01b03851684529091529020805460ff1916600117905562000a3f3390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45b5050565b600062000a9b836001600160a01b03841662000aa4565b90505b92915050565b600081815260018301602052604081205462000aed5750815460018181018455600084815260208082209093018490558454848252828601909352604090209190915562000a9e565b50600062000a9e565b82805462000b049062000e1c565b90600052602060002090601f01602090048101928262000b28576000855562000b73565b82601f1062000b4357805160ff191683800117855562000b73565b8280016001018555821562000b73579182015b8281111562000b7357825182559160200191906001019062000b56565b5062000b8192915062000b85565b5090565b5b8082111562000b81576000815560010162000b86565b634e487b7160e01b600052604160045260246000fd5b600082601f83011262000bc457600080fd5b81516001600160401b038082111562000be15762000be162000b9c565b604051601f8301601f19908116603f0116810190828211818310171562000c0c5762000c0c62000b9c565b8160405283815260209250868385880101111562000c2957600080fd5b600091505b8382101562000c4d578582018301518183018401529082019062000c2e565b8382111562000c5f5760008385830101525b9695505050505050565b6001600160a01b0381168114620009dc57600080fd5b805162000c8c8162000c69565b919050565b6000806000806000806000806000806101408b8d03121562000cb257600080fd5b8a516001600160401b038082111562000cca57600080fd5b62000cd88e838f0162000bb2565b9b5060208d015191508082111562000cef57600080fd5b5062000cfe8d828e0162000bb2565b99505062000d0f60408c0162000c7f565b975062000d1f60608c0162000c7f565b965062000d2f60808c0162000c7f565b955062000d3f60a08c0162000c7f565b945062000d4f60c08c0162000c7f565b935062000d5f60e08c0162000c7f565b925062000d706101008c0162000c7f565b915062000d816101208c0162000c7f565b90509295989b9194979a5092959850565b6000806040838503121562000da657600080fd5b825162000db38162000c69565b602084015190925062000dc68162000c69565b809150509250929050565b60006020828403121562000de457600080fd5b815162000df18162000c69565b9392505050565b60006020828403121562000e0b57600080fd5b8151801515811462000df157600080fd5b600181811c9082168062000e3157607f821691505b60208210810362000e5257634e487b7160e01b600052602260045260246000fd5b50919050565b60805161458762000edd600039600081816105b201528181611066015281816110da015281816112780152818161130b01528181611413015281816119ae01528181611fb601528181612a0a01528181612b1f01528181612e1801528181613036015281816132280152818161326401528181613377015261341401526145876000f3fe608060405234801561001057600080fd5b50600436106104965760003560e01c8063787dd9e411610262578063a9f6ee3311610151578063d6379b72116100ce578063e8772bb211610092578063e8772bb214610a27578063f595c5ad14610a3a578063f7b188a514610a4d578063f887ea4014610a55578063fc54989014610a68578063ffa1ad7414610a7157600080fd5b8063d6379b72146109bf578063dabd2719146109d2578063dd62ed3e146109e5578063e3495569146109f8578063e63ab1e914610a0057600080fd5b8063c0d7865511610115578063c0d786551461094c578063ca15c8731461095f578063ccfc2e8d14610972578063d539139314610985578063d547741f146109ac57600080fd5b8063a9f6ee33146108f6578063b181d9f814610909578063b187bd261461091c578063b342757614610930578063b4aa27371461093957600080fd5b806391eccc92116101df578063a457c2d7116101a3578063a457c2d7146108a2578063a6f19c84146108b5578063a7f32719146108c8578063a8aa1b31146108d0578063a9059cbb146108e357600080fd5b806391eccc921461086157806395d89b41146108745780639e66645b1461087c578063a1d50c3a1461088f578063a217fddf146105d457600080fd5b80638d6d8b09116102265780638d6d8b09146107ff5780638f536050146108155780639010d07c146108285780639043292a1461083b57806391d148541461084e57600080fd5b8063787dd9e4146107c957806379c79707146107dc5780638447120b146107e45780638456cb59146107ee578063860ca9bb146107f657600080fd5b8063313ce5671161038957806347d17ede1161030657806355a68ed3116102ca57806355a68ed31461075457806362f43dea146107675780636b6f4a9d1461076f5780636c2f972b1461077857806370a082311461078b57806375b238fc146107b457600080fd5b806347d17ede146106eb5780634b85f96c146106fe5780634bbf453c1461072357806350a566c51461073657806354cb03841461074957600080fd5b80633cdfed561161034d5780633cdfed561461068c57806340452c4c146106a957806340c10f19146106b257806342966c68146106c557806346c96aac146106d857600080fd5b8063313ce56714610631578063339ccade1461064057806336568abe1461065357806339509351146106665780633cd12e4b1461067957600080fd5b806323b872dd116104175780632f2ff15d116103db5780632f2ff15d146105dc5780632fc1b057146105ef5780633013ce2914610602578063310be9391461061557806331268b691461062857600080fd5b806323b872dd14610564578063248a9ca314610577578063293c5d431461059a57806329db1be6146105ad5780632ac8a92c146105d457600080fd5b8063095ea7b31161045e578063095ea7b3146105245780630d135cab146105375780630d43e8ad1461054057806318160ddd146105535780631adb040a1461055b57600080fd5b806301ffc9a71461049b578063062e5bbe146104c35780630694d1f1146104da57806306fdde03146104ef57806308b0308a14610504575b600080fd5b6104ae6104a9366004613ccf565b610a95565b60405190151581526020015b60405180910390f35b6104cc600e5481565b6040519081526020016104ba565b6104ed6104e8366004613cf9565b610ac0565b005b6104f7610b63565b6040516104ba9190613d3e565b61050c610bf5565b6040516001600160a01b0390911681526020016104ba565b6104ae610532366004613d86565b610c68565b6104cc60155481565b600d5461050c906001600160a01b031681565b6002546104cc565b6104cc60105481565b6104ae610572366004613db2565b610c80565b6104cc610585366004613cf9565b60009081526005602052604090206001015490565b6104ed6105a8366004613df3565b610ca4565b61050c7f000000000000000000000000000000000000000000000000000000000000000081565b6104cc600081565b6104ed6105ea366004613e19565b610d5d565b6104ed6105fd366004613cf9565b610d87565b60075461050c906001600160a01b031681565b6104cc610623366004613e49565b610e14565b6104cc610e1081565b604051601281526020016104ba565b6104cc61064e366004613cf9565b610e3d565b6104ed610661366004613e19565b610e4b565b6104ae610674366004613d86565b610ece565b6104ed610687366004613e79565b610ef0565b610694610f88565b604080519283526020830191909152016104ba565b6104cc60145481565b6104ed6106c0366004613d86565b610fd8565b6104ed6106d3366004613cf9565b611098565b60085461050c906001600160a01b031681565b6104cc6106f9366004613ea7565b61110e565b60165461070e9063ffffffff1681565b60405163ffffffff90911681526020016104ba565b6104cc610731366004613cf9565b611499565b6104ed610744366004613cf9565b6114d0565b6104cc6303c2670081565b6104ed610762366004613f3d565b611572565b6106946115f1565b6104cc60135481565b6104ed610786366004613cf9565b61163c565b6104cc610799366004613f3d565b6001600160a01b031660009081526020819052604090205490565b6104cc60008051602061453283398151915281565b6104cc6107d7366004613cf9565b6116cb565b6104ed6116d8565b6104cc6202a30081565b6104ed6117a8565b6104cc600f5481565b6016546104ae9065010000000000900460ff1681565b6104ed610823366004613cf9565b61184c565b61050c610836366004613e49565b6118ee565b600c5461050c906001600160a01b031681565b6104ae61085c366004613e19565b611906565b61069461086f366004613f5a565b611931565b6104f7611975565b61069461088a366004613e49565b611984565b6104cc61089d366004613fb9565b611a5d565b6104ae6108b0366004613d86565b611a96565b600b5461050c906001600160a01b031681565b6104ed611b11565b600a5461050c906001600160a01b031681565b6104ae6108f1366004613d86565b611b6b565b610694610904366004613ff8565b611b79565b6104ed610917366004614041565b611bb9565b6016546104ae90600160201b900460ff1681565b6104cc60115481565b6104ed610947366004613cf9565b611bf9565b6104ed61095a366004613f3d565b611c9b565b6104cc61096d366004613cf9565b611d1a565b6104ed610980366004613f3d565b611d31565b6104cc7ff0887ba65ee2024ea881d91b74c2450ef19e1557f03bed3ea9f16b037cbe2dc981565b6104ed6109ba366004613e19565b611ea7565b6104cc6109cd36600461408c565b611ecc565b6104ed6109e0366004613cf9565b611ed9565b6104cc6109f33660046140ba565b611f6e565b6104cc606481565b6104cc7f539440820030c4994db4e31b6b800deafd503688728f932addfe7a410515c14c81565b6104cc610a35366004613cf9565b611f99565b6104ed610a48366004613cf9565b612053565b6104ed6120f5565b60095461050c906001600160a01b031681565b6104cc60125481565b6104f7604051806040016040528060058152602001640332e312e360dc1b81525081565b60006001600160e01b03198216635a05180f60e01b1480610aba5750610aba82612216565b92915050565b610ad860008051602061453283398151915233611906565b610af55760405163f982dd0f60e01b815260040160405180910390fd5b6303c26700811180610b0957506011548111155b15610b2757604051634dd99fe760e01b815260040160405180910390fd5b60108190556040518181527f9604eee1326ca00c5073dfa77c88157865a7db1ed7323c9b1e0bc2aa17fa2ea2906020015b60405180910390a150565b606060038054610b72906140e8565b80601f0160208091040260200160405190810160405280929190818152602001828054610b9e906140e8565b8015610beb5780601f10610bc057610100808354040283529160200191610beb565b820191906000526020600020905b815481529060010190602001808311610bce57829003601f168201915b5050505050905090565b60085460408051630fc2838b60e11b815290516000926001600160a01b031691631f8507169160048083019260209291908290030181865afa158015610c3f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c639190614122565b905090565b600033610c7681858561224b565b5060019392505050565b600033610c8e85828561236f565b610c998585856123e9565b506001949350505050565b610cbc60008051602061453283398151915233611906565b610cd95760405163f982dd0f60e01b815260040160405180910390fd5b6202a3008163ffffffff161180610cf75750610e108163ffffffff16105b15610d1557604051634b3cbe9f60e01b815260040160405180910390fd5b6016805463ffffffff191663ffffffff83169081179091556040519081527f9e10c351c733c6502669ada15411f45b7ca0f96b4df8709801405cae172f56bf90602001610b58565b600082815260056020526040902060010154610d788161258d565b610d828383612597565b505050565b610d9f60008051602061453283398151915233611906565b610dbc5760405163f982dd0f60e01b815260040160405180910390fd5b601054811115610ddf57604051634dd99fe760e01b815260040160405180910390fd5b60118190556040518181527f5de612882d01106e49434ea40eed209dc8ad1a1f752a3388f45824f19b07abbb90602001610b58565b6000606482610e2285611f99565b610e2c9190614155565b610e36919061418a565b9392505050565b6000610aba82601354610e14565b6001600160a01b0381163314610ec05760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b60648201526084015b60405180910390fd5b610eca82826125b9565b5050565b600033610c76818585610ee18383611f6e565b610eeb919061419e565b61224b565b610f0860008051602061453283398151915233611906565b610f255760405163f982dd0f60e01b815260040160405180910390fd5b6001600160a01b038216600081815260176020908152604091829020805460ff19168515159081179091558251938452908301527ff5cba05a0edd1dca702978822f7c89a2dc71ede45f00892767eac09822ff74cc910160405180910390a15050565b600080600f54600e54610f9b91906141b6565b601154601054610fab91906141f5565b610fb5919061420c565b9150600f5482610fc5919061423a565b601154610fd291906141b6565b90509091565b60165465010000000000900460ff168015611008575061100660008051602061453283398151915233611906565b155b801561103b57506110397ff0887ba65ee2024ea881d91b74c2450ef19e1557f03bed3ea9f16b037cbe2dc933611906565b155b1561105957604051634fcb6d0160e01b815260040160405180910390fd5b61108e6001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000163330846125db565b610eca8282612646565b6110b060008051602061453283398151915233611906565b6110cd5760405163f982dd0f60e01b815260040160405180910390fd5b6111016001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000163383612705565b61110b3382612724565b50565b6000838042111561113257604051632d56313160e11b815260040160405180910390fd5b6001600160a01b03871660009081526017602052604090205460ff1661116b57604051631b42d91560e21b815260040160405180910390fd5b60405163b984a4f360e01b81526001600160a01b0388169063b984a4f39061119b908990889088906004016142e8565b602060405180830381865afa1580156111b8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111dc919061430b565b91506111e83387612724565b6112613388848a6001600160a01b0316633013ce296040518163ffffffff1660e01b8152600401602060405180830381865afa15801561122c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112509190614122565b6001600160a01b03169291906125db565b60405163095ea7b360e01b81526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169063095ea7b3906112b0908a90600090600401614324565b6020604051808303816000875af11580156112cf573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112f3919061433d565b5060405163095ea7b360e01b81526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169063095ea7b390611342908a908a90600401614324565b6020604051808303816000875af1158015611361573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611385919061433d565b506040516302f3d9e560e61b81526001600160a01b0388169063bcf67940906113b890899033908990899060040161435a565b6020604051808303816000875af11580156113d7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113fb919061430b565b5060405163095ea7b360e01b81526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169063095ea7b39061144b908a90600090600401614324565b6020604051808303816000875af115801561146a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061148e919061433d565b505095945050505050565b60008060006114a66115f1565b90925090506114c8816114b9868561423a565b6114c39190614385565b612856565b949350505050565b6114e860008051602061453283398151915233611906565b6115055760405163f982dd0f60e01b815260040160405180910390fd5b6064811180611512575080155b8061151f575080600e5410155b1561153d576040516304a5f22d60e41b815260040160405180910390fd5b600f8190556040518181527feccba1be6a56ca0e2c089e59a99f130b3f0bbe23d7bb2d085c278d51b384205890602001610b58565b61158a60008051602061453283398151915233611906565b6115a75760405163f982dd0f60e01b815260040160405180910390fd5b600b80546001600160a01b0319166001600160a01b0383169081179091556040517f17228b08e4c958112a0827a6d8dc8475dba58dd068a3d400800a606794db02a690600090a250565b60008060155460145461160491906141b6565b601254611615906303c267006141f5565b61161f919061420c565b91506015548261162f919061423a565b601254610fd291906141b6565b61165460008051602061453283398151915233611906565b6116715760405163f982dd0f60e01b815260040160405180910390fd5b6303c2670081111561169657604051634dd99fe760e01b815260040160405180910390fd5b60128190556040518181527f0dc65610e962e121ab28ec7730827bb42384fa8c24e76a975357a1365c0828da90602001610b58565b60008060006114a6610f88565b600854600a5460405163b9a09fd560e01b81526001600160a01b039182166004820152600092919091169063b9a09fd590602401602060405180830381865afa158015611729573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061174d9190614122565b90506001600160a01b0381161561110b57600b80546001600160a01b0319166001600160a01b0383169081179091556040517f17228b08e4c958112a0827a6d8dc8475dba58dd068a3d400800a606794db02a690600090a250565b6117d27f539440820030c4994db4e31b6b800deafd503688728f932addfe7a410515c14c33611906565b6117ef576040516316390a3f60e31b815260040160405180910390fd5b601654600160201b900460ff1661184a576016805464ff000000001916600160201b179055604051600181527f4543baa938cb97f5073ec206ad35638cdb1f4db8f677d31579b2f6fe7d18c14a906020015b60405180910390a15b565b61186460008051602061453283398151915233611906565b6118815760405163f982dd0f60e01b815260040160405180910390fd5b606481118061188e575080155b8061189b57506014548110155b156118b9576040516304a5f22d60e41b815260040160405180910390fd5b60158190556040518181527f0b5cc1380abb95639d90f536a9af619d222cffe2fe5c9e825728b6d7d05e68de90602001610b58565b6000828152600660205260408120610e36908361286d565b60009182526005602090815260408084206001600160a01b0393909316845291905290205460ff1690565b600080828042111561195657604051632d56313160e11b815260040160405180910390fd5b6119648a8a8a8a8a8a612879565b925092505097509795505050505050565b606060048054610b72906140e8565b6000806119918484610e14565b600954600754604051635e60dab560e01b81526001600160a01b037f000000000000000000000000000000000000000000000000000000000000000081166004830152918216602482015260006044820181905293955083929190911690635e60dab5906064016040805180830381865afa158015611a14573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a3891906143c6565b909250905081611a488288614155565b611a52919061418a565b925050509250929050565b60008180421115611a8157604051632d56313160e11b815260040160405180910390fd5b611a8c868686612d28565b9695505050505050565b60003381611aa48286611f6e565b905083811015611b045760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77604482015264207a65726f60d81b6064820152608401610eb7565b610c99828686840361224b565b611b2960008051602061453283398151915233611906565b611b465760405163f982dd0f60e01b815260040160405180910390fd5b6016805465ff0000000000198116650100000000009182900460ff1615909102179055565b600033610c768185856123e9565b6000808280421115611b9e57604051632d56313160e11b815260040160405180910390fd5b611baa88888789612e8e565b92509250509550959350505050565b611bd160008051602061453283398151915233611906565b611bee5760405163f982dd0f60e01b815260040160405180910390fd5b610d828383836131a2565b611c1160008051602061453283398151915233611906565b611c2e5760405163f982dd0f60e01b815260040160405180910390fd5b6064811180611c3b575080155b80611c4857508060155410155b15611c66576040516304a5f22d60e41b815260040160405180910390fd5b60148190556040518181527f5e08a24ce41a50207cd6c60d4c0b135c6385789570e226d4672e781c4985502590602001610b58565b611cb360008051602061453283398151915233611906565b611cd05760405163f982dd0f60e01b815260040160405180910390fd5b600980546001600160a01b0319166001600160a01b0383169081179091556040517f6de4326a8b9054d72d9dbab97d27bc4edffadee7d966f5af9cc4eafdaf8e545590600090a250565b6000818152600660205260408120610aba906136de565b611d4960008051602061453283398151915233611906565b611d665760405163f982dd0f60e01b815260040160405180910390fd5b600754600d5460405163095ea7b360e01b81526001600160a01b039283169263095ea7b392611d9d92911690600090600401614324565b6020604051808303816000875af1158015611dbc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611de0919061433d565b50600d80546001600160a01b0319166001600160a01b038381169190911790915560075460405163095ea7b360e01b815291169063095ea7b390611e2c90849060001990600401614324565b6020604051808303816000875af1158015611e4b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e6f919061433d565b506040516001600160a01b038216907f9e9a9a4a82acd1b28aab6bf1d43aad70ae6d290549c0d6183e2e91ebcdf5744190600090a250565b600082815260056020526040902060010154611ec28161258d565b610d8283836125b9565b60006114c8848484612d28565b611ef160008051602061453283398151915233611906565b611f0e5760405163f982dd0f60e01b815260040160405180910390fd5b6064811180611f1b575080155b15611f39576040516304a5f22d60e41b815260040160405180910390fd5b60138190556040518181527ff247e4dd947ab13ba6c46412e403447a26e67109ba13945a20e3170e9acef88390602001610b58565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b600c54601654604051638f2e819960e01b81526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000811660048301526fffffffffffffffffffffffffffffffff8516602483015263ffffffff90921660448201526000929190911690638f2e819990606401602060405180830381865afa15801561202f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610aba919061430b565b61206b60008051602061453283398151915233611906565b6120885760405163f982dd0f60e01b815260040160405180910390fd5b6064811180612095575080155b806120a25750600f548110155b156120c0576040516304a5f22d60e41b815260040160405180910390fd5b600e8190556040518181527f09734b71a2b91b11a979f46fe8751cc0a22e29af3006d1ba5196a7ace08798b490602001610b58565b61210d60008051602061453283398151915233611906565b61212a5760405163f982dd0f60e01b815260040160405180910390fd5b601654600160201b900460ff161561184a576016805464ff0000000019169055604051600081527f4543baa938cb97f5073ec206ad35638cdb1f4db8f677d31579b2f6fe7d18c14a90602001611841565b6121858282611906565b610eca5760008281526005602090815260408083206001600160a01b03851684529091529020805460ff191660011790556121bd3390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b6000610e36836001600160a01b0384166136e8565b60006001600160e01b03198216637965db0b60e01b1480610aba57506301ffc9a760e01b6001600160e01b0319831614610aba565b6001600160a01b0383166122ad5760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b6064820152608401610eb7565b6001600160a01b03821661230e5760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b6064820152608401610eb7565b6001600160a01b0383811660008181526001602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b600061237b8484611f6e565b905060001981146123e357818110156123d65760405162461bcd60e51b815260206004820152601d60248201527f45524332303a20696e73756666696369656e7420616c6c6f77616e63650000006044820152606401610eb7565b6123e3848484840361224b565b50505050565b6001600160a01b03831661244d5760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b6064820152608401610eb7565b6001600160a01b0382166124af5760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b6064820152608401610eb7565b6001600160a01b038316600090815260208190526040902054818110156125275760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e7420657863656564732062604482015265616c616e636560d01b6064820152608401610eb7565b6001600160a01b03848116600081815260208181526040808320878703905593871680835291849020805487019055925185815290927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a36123e3565b61110b8133613737565b6125a1828261217b565b6000828152600660205260409020610d829082612201565b6125c38282613790565b6000828152600660205260409020610d8290826137f7565b6040516001600160a01b03808516602483015283166044820152606481018290526123e39085906323b872dd60e01b906084015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b03199093169290921790915261380c565b6001600160a01b03821661269c5760405162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f2061646472657373006044820152606401610eb7565b80600260008282546126ae919061419e565b90915550506001600160a01b038216600081815260208181526040808320805486019055518481527fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a35050565b610d828363a9059cbb60e01b848460405160240161260f929190614324565b6001600160a01b0382166127845760405162461bcd60e51b815260206004820152602160248201527f45524332303a206275726e2066726f6d20746865207a65726f206164647265736044820152607360f81b6064820152608401610eb7565b6001600160a01b038216600090815260208190526040902054818110156127f85760405162461bcd60e51b815260206004820152602260248201527f45524332303a206275726e20616d6f756e7420657863656564732062616c616e604482015261636560f01b6064820152608401610eb7565b6001600160a01b0383166000818152602081815260408083208686039055600280548790039055518581529192917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a3505050565b6000808212156128695781600003610aba565b5090565b6000610e3683836138e1565b6016546000908190600160201b900460ff16156128a85760405162b4aa3760e01b815260040160405180910390fd5b600b546001600160a01b03166128d1576040516325493da160e21b815260040160405180910390fd5b600f548311806128e25750600e5483105b15612900576040516304a5f22d60e41b815260040160405180910390fd5b61290a3389612724565b60006129168985611984565b90935090508783111561293c57604051630f993ed160e11b815260040160405180910390fd5b8681118061294957508581105b15612967576040516323a4850d60e21b815260040160405180910390fd5b61298a3330612976848761419e565b6007546001600160a01b03169291906125db565b600d54600754604051631f72642160e31b81526001600160a01b039283169263fb932108926129c0929116908790600401614324565b600060405180830381600087803b1580156129da57600080fd5b505af11580156129ee573d6000803e3d6000fd5b505060095460405163095ea7b360e01b81526001600160a01b037f00000000000000000000000000000000000000000000000000000000000000008116945063095ea7b39350612a449216908d90600401614324565b6020604051808303816000875af1158015612a63573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a87919061433d565b5060075460095460405163095ea7b360e01b81526001600160a01b039283169263095ea7b392612abe929116908590600401614324565b6020604051808303816000875af1158015612add573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612b01919061433d565b50600954600754604051635a47ddc360e01b81526001600160a01b037f000000000000000000000000000000000000000000000000000000000000000081166004830152918216602482015260006044820152606481018c905260848101849052600160a482015260c481018990523060e482015242610104820152911690635a47ddc390610124016060604051808303816000875af1158015612ba9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612bcd91906143ea565b600a54600b5460405163095ea7b360e01b81529296506001600160a01b03918216945063095ea7b39350612c08929116908690600401614324565b6020604051808303816000875af1158015612c27573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612c4b919061433d565b50600b546001600160a01b0316631f933c2d8684612c68886116cb565b6040516001600160e01b031960e086901b1681526001600160a01b03909316600484015260248301919091526044820152606401600060405180830381600087803b158015612cb657600080fd5b505af1158015612cca573d6000803e3d6000fd5b5050604080518c8152602081018790529081018590526001600160a01b03881692503391507f49a80f92a21531b6bccc1cf51cb96a7f814282e7d6a69d0a4dea0167193cd3589060600160405180910390a350965096945050505050565b601654600090600160201b900460ff1615612d555760405162b4aa3760e01b815260040160405180910390fd5b612d5f3385612724565b612d6884610e3d565b905082811115612d8b576040516323a4850d60e21b815260040160405180910390fd5b600754612da3906001600160a01b03163330846125db565b600d54600754604051631f72642160e31b81526001600160a01b039283169263fb93210892612dd9929116908590600401614324565b600060405180830381600087803b158015612df357600080fd5b505af1158015612e07573d6000803e3d6000fd5b50612e419250506001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001690508386612705565b60408051858152602081018390526001600160a01b0384169133917fb1c971764663d561c0ec2baf395a55f33f0a79fabb35bbad580247ba2959523d910160405180910390a39392505050565b6016546000908190600160201b900460ff1615612ebd5760405162b4aa3760e01b815260040160405180910390fd5b601554841180612ece575060145484105b15612eec576040516304a5f22d60e41b815260040160405180910390fd5b612ef63387612724565b612f008685610e14565b915084821115612f23576040516323a4850d60e21b815260040160405180910390fd5b600754612f3b906001600160a01b03163330856125db565b600d54600754604051631f72642160e31b81526001600160a01b039283169263fb93210892612f71929116908690600401614324565b600060405180830381600087803b158015612f8b57600080fd5b505af1158015612f9f573d6000803e3d6000fd5b505050506000600860009054906101000a90046001600160a01b03166001600160a01b0316631f8507166040518163ffffffff1660e01b8152600401602060405180830381865afa158015612ff8573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061301c9190614122565b60405163095ea7b360e01b81529091506001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169063095ea7b39061306d9084908b90600401614324565b6020604051808303816000875af115801561308c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906130b0919061433d565b50806001600160a01b0316630a2abdb3886130ca88611499565b6040516001600160e01b031960e085901b168152600481019290925260248201526001600160a01b0387166044820152600060648201526084016020604051808303816000875af1158015613123573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613147919061430b565b60408051898152602081018690529081018290529092506001600160a01b0385169033907f74b7132649649ee4ac2519ff0bb963ce812aaa4c8a0ad0f73c9ac1149fa6e3f49060600160405180910390a35094509492505050565b600080846001600160a01b0316639d63848a6040518163ffffffff1660e01b81526004016040805180830381865afa1580156131e2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906132069190614418565b91509150826001600160a01b0316826001600160a01b031614801561325c57507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316816001600160a01b0316145b806132b457507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316826001600160a01b03161480156132b45750826001600160a01b0316816001600160a01b0316145b6132d15760405163a818b0ad60e01b815260040160405180910390fd5b84600a60006101000a8154816001600160a01b0302191690836001600160a01b03160217905550826001600160a01b0316846001600160a01b0316630dfe16816040518163ffffffff1660e01b8152600401602060405180830381865afa158015613340573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906133649190614122565b6001600160a01b031614801561340c57507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316846001600160a01b031663d21220a76040518163ffffffff1660e01b8152600401602060405180830381865afa1580156133dd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906134019190614122565b6001600160a01b0316145b8061352657507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316846001600160a01b0316630dfe16816040518163ffffffff1660e01b8152600401602060405180830381865afa15801561347a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061349e9190614122565b6001600160a01b03161480156135265750826001600160a01b0316846001600160a01b031663d21220a76040518163ffffffff1660e01b8152600401602060405180830381865afa1580156134f7573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061351b9190614122565b6001600160a01b0316145b61354357604051631bf31bfb60e31b815260040160405180910390fd5b600c80546001600160a01b0319166001600160a01b038681169190911790915560075484821691161461368d576007546001600160a01b0316156135fd57600754600d5460405163095ea7b360e01b81526001600160a01b039283169263095ea7b3926135b892911690600090600401614324565b6020604051808303816000875af11580156135d7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906135fb919061433d565b505b600780546001600160a01b0319166001600160a01b03858116918217909255600d5460405163095ea7b360e01b8152919263095ea7b392613648929091169060001990600401614324565b6020604051808303816000875af1158015613667573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061368b919061433d565b505b826001600160a01b0316846001600160a01b0316866001600160a01b03167f9393b560cd26f49fe024dd267863e33175eac92055a63c0151d12dd81f5cec5360405160405180910390a45050505050565b6000610aba825490565b600081815260018301602052604081205461372f57508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610aba565b506000610aba565b6137418282611906565b610eca5761374e8161390b565b61375983602061391d565b60405160200161376a929190614447565b60408051601f198184030181529082905262461bcd60e51b8252610eb791600401613d3e565b61379a8282611906565b15610eca5760008281526005602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b6000610e36836001600160a01b038416613ab9565b6000613861826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316613bac9092919063ffffffff16565b9050805160001480613882575080806020019051810190613882919061433d565b610d825760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610eb7565b60008260000182815481106138f8576138f86144bc565b9060005260206000200154905092915050565b6060610aba6001600160a01b03831660145b6060600061392c836002614155565b61393790600261419e565b67ffffffffffffffff81111561394f5761394f6144d2565b6040519080825280601f01601f191660200182016040528015613979576020820181803683370190505b509050600360fc1b81600081518110613994576139946144bc565b60200101906001600160f81b031916908160001a905350600f60fb1b816001815181106139c3576139c36144bc565b60200101906001600160f81b031916908160001a90535060006139e7846002614155565b6139f290600161419e565b90505b6001811115613a6a576f181899199a1a9b1b9c1cb0b131b232b360811b85600f1660108110613a2657613a266144bc565b1a60f81b828281518110613a3c57613a3c6144bc565b60200101906001600160f81b031916908160001a90535060049490941c93613a63816144e8565b90506139f5565b508315610e365760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610eb7565b60008181526001830160205260408120548015613ba2576000613add6001836141f5565b8554909150600090613af1906001906141f5565b9050818114613b56576000866000018281548110613b1157613b116144bc565b9060005260206000200154905080876000018481548110613b3457613b346144bc565b6000918252602080832090910192909255918252600188019052604090208390555b8554869080613b6757613b676144ff565b600190038181906000526020600020016000905590558560010160008681526020019081526020016000206000905560019350505050610aba565b6000915050610aba565b60606114c8848460008585600080866001600160a01b03168587604051613bd39190614515565b60006040518083038185875af1925050503d8060008114613c10576040519150601f19603f3d011682016040523d82523d6000602084013e613c15565b606091505b5091509150613c2687838387613c31565b979650505050505050565b60608315613ca0578251600003613c99576001600160a01b0385163b613c995760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610eb7565b50816114c8565b6114c88383815115613cb55781518083602001fd5b8060405162461bcd60e51b8152600401610eb79190613d3e565b600060208284031215613ce157600080fd5b81356001600160e01b031981168114610e3657600080fd5b600060208284031215613d0b57600080fd5b5035919050565b60005b83811015613d2d578181015183820152602001613d15565b838111156123e35750506000910152565b6020815260008251806020840152613d5d816040850160208701613d12565b601f01601f19169190910160400192915050565b6001600160a01b038116811461110b57600080fd5b60008060408385031215613d9957600080fd5b8235613da481613d71565b946020939093013593505050565b600080600060608486031215613dc757600080fd5b8335613dd281613d71565b92506020840135613de281613d71565b929592945050506040919091013590565b600060208284031215613e0557600080fd5b813563ffffffff81168114610e3657600080fd5b60008060408385031215613e2c57600080fd5b823591506020830135613e3e81613d71565b809150509250929050565b60008060408385031215613e5c57600080fd5b50508035926020909101359150565b801515811461110b57600080fd5b60008060408385031215613e8c57600080fd5b8235613e9781613d71565b91506020830135613e3e81613e6b565b600080600080600060808688031215613ebf57600080fd5b8535613eca81613d71565b94506020860135935060408601359250606086013567ffffffffffffffff80821115613ef557600080fd5b818801915088601f830112613f0957600080fd5b813581811115613f1857600080fd5b896020828501011115613f2a57600080fd5b9699959850939650602001949392505050565b600060208284031215613f4f57600080fd5b8135610e3681613d71565b600080600080600080600060e0888a031215613f7557600080fd5b873596506020880135955060408801359450606088013593506080880135613f9c81613d71565b9699959850939692959460a0840135945060c09093013592915050565b60008060008060808587031215613fcf57600080fd5b84359350602085013592506040850135613fe881613d71565b9396929550929360600135925050565b600080600080600060a0868803121561401057600080fd5b8535945060208601359350604086013561402981613d71565b94979396509394606081013594506080013592915050565b60008060006060848603121561405657600080fd5b833561406181613d71565b9250602084013561407181613d71565b9150604084013561408181613d71565b809150509250925092565b6000806000606084860312156140a157600080fd5b8335925060208401359150604084013561408181613d71565b600080604083850312156140cd57600080fd5b82356140d881613d71565b91506020830135613e3e81613d71565b600181811c908216806140fc57607f821691505b60208210810361411c57634e487b7160e01b600052602260045260246000fd5b50919050565b60006020828403121561413457600080fd5b8151610e3681613d71565b634e487b7160e01b600052601160045260246000fd5b600081600019048311821515161561416f5761416f61413f565b500290565b634e487b7160e01b600052601260045260246000fd5b60008261419957614199614174565b500490565b600082198211156141b1576141b161413f565b500190565b60008083128015600160ff1b8501841216156141d4576141d461413f565b6001600160ff1b03840183138116156141ef576141ef61413f565b50500390565b6000828210156142075761420761413f565b500390565b60008261421b5761421b614174565b600160ff1b8214600019841416156142355761423561413f565b500590565b60006001600160ff1b03818413828413808216868404861116156142605761426061413f565b600160ff1b600087128281168783058912161561427f5761427f61413f565b6000871292508782058712848416161561429b5761429b61413f565b878505871281841616156142b1576142b161413f565b505050929093029392505050565b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b8381526040602082015260006143026040830184866142bf565b95945050505050565b60006020828403121561431d57600080fd5b5051919050565b6001600160a01b03929092168252602082015260400190565b60006020828403121561434f57600080fd5b8151610e3681613e6b565b8481526001600160a01b0384166020820152606060408201819052600090611a8c90830184866142bf565b600080821280156001600160ff1b03849003851316156143a7576143a761413f565b600160ff1b83900384128116156143c0576143c061413f565b50500190565b600080604083850312156143d957600080fd5b505080516020909101519092909150565b6000806000606084860312156143ff57600080fd5b8351925060208401519150604084015190509250925092565b6000806040838503121561442b57600080fd5b825161443681613d71565b6020840151909250613e3e81613d71565b7f416363657373436f6e74726f6c3a206163636f756e742000000000000000000081526000835161447f816017850160208801613d12565b7001034b99036b4b9b9b4b733903937b6329607d1b60179184019182015283516144b0816028840160208801613d12565b01602801949350505050565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6000816144f7576144f761413f565b506000190190565b634e487b7160e01b600052603160045260246000fd5b60008251614527818460208701613d12565b919091019291505056fedf8b4c520ffe197c5343c6f5aec59570151ef9a492f2c624fd45ddde6135ec42a2646970667358221220db6534cff304af69722a000cbafedf8b3e5049defcebd1560dc414059af9970c64736f6c634300080d0033df8b4c520ffe197c5343c6f5aec59570151ef9a492f2c624fd45ddde6135ec42000000000000000000000000000000000000000000000000000000000000014000000000000000000000000000000000000000000000000000000000000001800000000000000000000000001ac02baf72fa0c7348ee839b15af1be42a2d2a300000000000000000000000008f187aa05619a017077f5308904739877ce9ea21000000000000000000000000756ee6857f915a2b5366f2ef56d8d13857aef8ad0000000000000000000000005b55252af9f20a713921de4258c80b202f5dd0c200000000000000000000000016e0ed0bc8fe82c3f8670027d919bc17bfffaa3400000000000000000000000091ce198d363328ae2f3c06581fb0fcd7ba2cfbc300000000000000000000000001a6309c942a6f79bc1c543eb40146697ada93660000000000000000000000003104423870c008661aa137de21db86af3c51c5c900000000000000000000000000000000000000000000000000000000000000194f7074696f6e20746f20627579204341545820772f20554e490000000000000000000000000000000000000000000000000000000000000000000000000000056f43415458000000000000000000000000000000000000000000000000000000

Deployed Bytecode

0x608060405234801561001057600080fd5b50600436106104965760003560e01c8063787dd9e411610262578063a9f6ee3311610151578063d6379b72116100ce578063e8772bb211610092578063e8772bb214610a27578063f595c5ad14610a3a578063f7b188a514610a4d578063f887ea4014610a55578063fc54989014610a68578063ffa1ad7414610a7157600080fd5b8063d6379b72146109bf578063dabd2719146109d2578063dd62ed3e146109e5578063e3495569146109f8578063e63ab1e914610a0057600080fd5b8063c0d7865511610115578063c0d786551461094c578063ca15c8731461095f578063ccfc2e8d14610972578063d539139314610985578063d547741f146109ac57600080fd5b8063a9f6ee33146108f6578063b181d9f814610909578063b187bd261461091c578063b342757614610930578063b4aa27371461093957600080fd5b806391eccc92116101df578063a457c2d7116101a3578063a457c2d7146108a2578063a6f19c84146108b5578063a7f32719146108c8578063a8aa1b31146108d0578063a9059cbb146108e357600080fd5b806391eccc921461086157806395d89b41146108745780639e66645b1461087c578063a1d50c3a1461088f578063a217fddf146105d457600080fd5b80638d6d8b09116102265780638d6d8b09146107ff5780638f536050146108155780639010d07c146108285780639043292a1461083b57806391d148541461084e57600080fd5b8063787dd9e4146107c957806379c79707146107dc5780638447120b146107e45780638456cb59146107ee578063860ca9bb146107f657600080fd5b8063313ce5671161038957806347d17ede1161030657806355a68ed3116102ca57806355a68ed31461075457806362f43dea146107675780636b6f4a9d1461076f5780636c2f972b1461077857806370a082311461078b57806375b238fc146107b457600080fd5b806347d17ede146106eb5780634b85f96c146106fe5780634bbf453c1461072357806350a566c51461073657806354cb03841461074957600080fd5b80633cdfed561161034d5780633cdfed561461068c57806340452c4c146106a957806340c10f19146106b257806342966c68146106c557806346c96aac146106d857600080fd5b8063313ce56714610631578063339ccade1461064057806336568abe1461065357806339509351146106665780633cd12e4b1461067957600080fd5b806323b872dd116104175780632f2ff15d116103db5780632f2ff15d146105dc5780632fc1b057146105ef5780633013ce2914610602578063310be9391461061557806331268b691461062857600080fd5b806323b872dd14610564578063248a9ca314610577578063293c5d431461059a57806329db1be6146105ad5780632ac8a92c146105d457600080fd5b8063095ea7b31161045e578063095ea7b3146105245780630d135cab146105375780630d43e8ad1461054057806318160ddd146105535780631adb040a1461055b57600080fd5b806301ffc9a71461049b578063062e5bbe146104c35780630694d1f1146104da57806306fdde03146104ef57806308b0308a14610504575b600080fd5b6104ae6104a9366004613ccf565b610a95565b60405190151581526020015b60405180910390f35b6104cc600e5481565b6040519081526020016104ba565b6104ed6104e8366004613cf9565b610ac0565b005b6104f7610b63565b6040516104ba9190613d3e565b61050c610bf5565b6040516001600160a01b0390911681526020016104ba565b6104ae610532366004613d86565b610c68565b6104cc60155481565b600d5461050c906001600160a01b031681565b6002546104cc565b6104cc60105481565b6104ae610572366004613db2565b610c80565b6104cc610585366004613cf9565b60009081526005602052604090206001015490565b6104ed6105a8366004613df3565b610ca4565b61050c7f000000000000000000000000756ee6857f915a2b5366f2ef56d8d13857aef8ad81565b6104cc600081565b6104ed6105ea366004613e19565b610d5d565b6104ed6105fd366004613cf9565b610d87565b60075461050c906001600160a01b031681565b6104cc610623366004613e49565b610e14565b6104cc610e1081565b604051601281526020016104ba565b6104cc61064e366004613cf9565b610e3d565b6104ed610661366004613e19565b610e4b565b6104ae610674366004613d86565b610ece565b6104ed610687366004613e79565b610ef0565b610694610f88565b604080519283526020830191909152016104ba565b6104cc60145481565b6104ed6106c0366004613d86565b610fd8565b6104ed6106d3366004613cf9565b611098565b60085461050c906001600160a01b031681565b6104cc6106f9366004613ea7565b61110e565b60165461070e9063ffffffff1681565b60405163ffffffff90911681526020016104ba565b6104cc610731366004613cf9565b611499565b6104ed610744366004613cf9565b6114d0565b6104cc6303c2670081565b6104ed610762366004613f3d565b611572565b6106946115f1565b6104cc60135481565b6104ed610786366004613cf9565b61163c565b6104cc610799366004613f3d565b6001600160a01b031660009081526020819052604090205490565b6104cc60008051602061453283398151915281565b6104cc6107d7366004613cf9565b6116cb565b6104ed6116d8565b6104cc6202a30081565b6104ed6117a8565b6104cc600f5481565b6016546104ae9065010000000000900460ff1681565b6104ed610823366004613cf9565b61184c565b61050c610836366004613e49565b6118ee565b600c5461050c906001600160a01b031681565b6104ae61085c366004613e19565b611906565b61069461086f366004613f5a565b611931565b6104f7611975565b61069461088a366004613e49565b611984565b6104cc61089d366004613fb9565b611a5d565b6104ae6108b0366004613d86565b611a96565b600b5461050c906001600160a01b031681565b6104ed611b11565b600a5461050c906001600160a01b031681565b6104ae6108f1366004613d86565b611b6b565b610694610904366004613ff8565b611b79565b6104ed610917366004614041565b611bb9565b6016546104ae90600160201b900460ff1681565b6104cc60115481565b6104ed610947366004613cf9565b611bf9565b6104ed61095a366004613f3d565b611c9b565b6104cc61096d366004613cf9565b611d1a565b6104ed610980366004613f3d565b611d31565b6104cc7ff0887ba65ee2024ea881d91b74c2450ef19e1557f03bed3ea9f16b037cbe2dc981565b6104ed6109ba366004613e19565b611ea7565b6104cc6109cd36600461408c565b611ecc565b6104ed6109e0366004613cf9565b611ed9565b6104cc6109f33660046140ba565b611f6e565b6104cc606481565b6104cc7f539440820030c4994db4e31b6b800deafd503688728f932addfe7a410515c14c81565b6104cc610a35366004613cf9565b611f99565b6104ed610a48366004613cf9565b612053565b6104ed6120f5565b60095461050c906001600160a01b031681565b6104cc60125481565b6104f7604051806040016040528060058152602001640332e312e360dc1b81525081565b60006001600160e01b03198216635a05180f60e01b1480610aba5750610aba82612216565b92915050565b610ad860008051602061453283398151915233611906565b610af55760405163f982dd0f60e01b815260040160405180910390fd5b6303c26700811180610b0957506011548111155b15610b2757604051634dd99fe760e01b815260040160405180910390fd5b60108190556040518181527f9604eee1326ca00c5073dfa77c88157865a7db1ed7323c9b1e0bc2aa17fa2ea2906020015b60405180910390a150565b606060038054610b72906140e8565b80601f0160208091040260200160405190810160405280929190818152602001828054610b9e906140e8565b8015610beb5780601f10610bc057610100808354040283529160200191610beb565b820191906000526020600020905b815481529060010190602001808311610bce57829003601f168201915b5050505050905090565b60085460408051630fc2838b60e11b815290516000926001600160a01b031691631f8507169160048083019260209291908290030181865afa158015610c3f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c639190614122565b905090565b600033610c7681858561224b565b5060019392505050565b600033610c8e85828561236f565b610c998585856123e9565b506001949350505050565b610cbc60008051602061453283398151915233611906565b610cd95760405163f982dd0f60e01b815260040160405180910390fd5b6202a3008163ffffffff161180610cf75750610e108163ffffffff16105b15610d1557604051634b3cbe9f60e01b815260040160405180910390fd5b6016805463ffffffff191663ffffffff83169081179091556040519081527f9e10c351c733c6502669ada15411f45b7ca0f96b4df8709801405cae172f56bf90602001610b58565b600082815260056020526040902060010154610d788161258d565b610d828383612597565b505050565b610d9f60008051602061453283398151915233611906565b610dbc5760405163f982dd0f60e01b815260040160405180910390fd5b601054811115610ddf57604051634dd99fe760e01b815260040160405180910390fd5b60118190556040518181527f5de612882d01106e49434ea40eed209dc8ad1a1f752a3388f45824f19b07abbb90602001610b58565b6000606482610e2285611f99565b610e2c9190614155565b610e36919061418a565b9392505050565b6000610aba82601354610e14565b6001600160a01b0381163314610ec05760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b60648201526084015b60405180910390fd5b610eca82826125b9565b5050565b600033610c76818585610ee18383611f6e565b610eeb919061419e565b61224b565b610f0860008051602061453283398151915233611906565b610f255760405163f982dd0f60e01b815260040160405180910390fd5b6001600160a01b038216600081815260176020908152604091829020805460ff19168515159081179091558251938452908301527ff5cba05a0edd1dca702978822f7c89a2dc71ede45f00892767eac09822ff74cc910160405180910390a15050565b600080600f54600e54610f9b91906141b6565b601154601054610fab91906141f5565b610fb5919061420c565b9150600f5482610fc5919061423a565b601154610fd291906141b6565b90509091565b60165465010000000000900460ff168015611008575061100660008051602061453283398151915233611906565b155b801561103b57506110397ff0887ba65ee2024ea881d91b74c2450ef19e1557f03bed3ea9f16b037cbe2dc933611906565b155b1561105957604051634fcb6d0160e01b815260040160405180910390fd5b61108e6001600160a01b037f000000000000000000000000756ee6857f915a2b5366f2ef56d8d13857aef8ad163330846125db565b610eca8282612646565b6110b060008051602061453283398151915233611906565b6110cd5760405163f982dd0f60e01b815260040160405180910390fd5b6111016001600160a01b037f000000000000000000000000756ee6857f915a2b5366f2ef56d8d13857aef8ad163383612705565b61110b3382612724565b50565b6000838042111561113257604051632d56313160e11b815260040160405180910390fd5b6001600160a01b03871660009081526017602052604090205460ff1661116b57604051631b42d91560e21b815260040160405180910390fd5b60405163b984a4f360e01b81526001600160a01b0388169063b984a4f39061119b908990889088906004016142e8565b602060405180830381865afa1580156111b8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111dc919061430b565b91506111e83387612724565b6112613388848a6001600160a01b0316633013ce296040518163ffffffff1660e01b8152600401602060405180830381865afa15801561122c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112509190614122565b6001600160a01b03169291906125db565b60405163095ea7b360e01b81526001600160a01b037f000000000000000000000000756ee6857f915a2b5366f2ef56d8d13857aef8ad169063095ea7b3906112b0908a90600090600401614324565b6020604051808303816000875af11580156112cf573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112f3919061433d565b5060405163095ea7b360e01b81526001600160a01b037f000000000000000000000000756ee6857f915a2b5366f2ef56d8d13857aef8ad169063095ea7b390611342908a908a90600401614324565b6020604051808303816000875af1158015611361573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611385919061433d565b506040516302f3d9e560e61b81526001600160a01b0388169063bcf67940906113b890899033908990899060040161435a565b6020604051808303816000875af11580156113d7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113fb919061430b565b5060405163095ea7b360e01b81526001600160a01b037f000000000000000000000000756ee6857f915a2b5366f2ef56d8d13857aef8ad169063095ea7b39061144b908a90600090600401614324565b6020604051808303816000875af115801561146a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061148e919061433d565b505095945050505050565b60008060006114a66115f1565b90925090506114c8816114b9868561423a565b6114c39190614385565b612856565b949350505050565b6114e860008051602061453283398151915233611906565b6115055760405163f982dd0f60e01b815260040160405180910390fd5b6064811180611512575080155b8061151f575080600e5410155b1561153d576040516304a5f22d60e41b815260040160405180910390fd5b600f8190556040518181527feccba1be6a56ca0e2c089e59a99f130b3f0bbe23d7bb2d085c278d51b384205890602001610b58565b61158a60008051602061453283398151915233611906565b6115a75760405163f982dd0f60e01b815260040160405180910390fd5b600b80546001600160a01b0319166001600160a01b0383169081179091556040517f17228b08e4c958112a0827a6d8dc8475dba58dd068a3d400800a606794db02a690600090a250565b60008060155460145461160491906141b6565b601254611615906303c267006141f5565b61161f919061420c565b91506015548261162f919061423a565b601254610fd291906141b6565b61165460008051602061453283398151915233611906565b6116715760405163f982dd0f60e01b815260040160405180910390fd5b6303c2670081111561169657604051634dd99fe760e01b815260040160405180910390fd5b60128190556040518181527f0dc65610e962e121ab28ec7730827bb42384fa8c24e76a975357a1365c0828da90602001610b58565b60008060006114a6610f88565b600854600a5460405163b9a09fd560e01b81526001600160a01b039182166004820152600092919091169063b9a09fd590602401602060405180830381865afa158015611729573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061174d9190614122565b90506001600160a01b0381161561110b57600b80546001600160a01b0319166001600160a01b0383169081179091556040517f17228b08e4c958112a0827a6d8dc8475dba58dd068a3d400800a606794db02a690600090a250565b6117d27f539440820030c4994db4e31b6b800deafd503688728f932addfe7a410515c14c33611906565b6117ef576040516316390a3f60e31b815260040160405180910390fd5b601654600160201b900460ff1661184a576016805464ff000000001916600160201b179055604051600181527f4543baa938cb97f5073ec206ad35638cdb1f4db8f677d31579b2f6fe7d18c14a906020015b60405180910390a15b565b61186460008051602061453283398151915233611906565b6118815760405163f982dd0f60e01b815260040160405180910390fd5b606481118061188e575080155b8061189b57506014548110155b156118b9576040516304a5f22d60e41b815260040160405180910390fd5b60158190556040518181527f0b5cc1380abb95639d90f536a9af619d222cffe2fe5c9e825728b6d7d05e68de90602001610b58565b6000828152600660205260408120610e36908361286d565b60009182526005602090815260408084206001600160a01b0393909316845291905290205460ff1690565b600080828042111561195657604051632d56313160e11b815260040160405180910390fd5b6119648a8a8a8a8a8a612879565b925092505097509795505050505050565b606060048054610b72906140e8565b6000806119918484610e14565b600954600754604051635e60dab560e01b81526001600160a01b037f000000000000000000000000756ee6857f915a2b5366f2ef56d8d13857aef8ad81166004830152918216602482015260006044820181905293955083929190911690635e60dab5906064016040805180830381865afa158015611a14573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a3891906143c6565b909250905081611a488288614155565b611a52919061418a565b925050509250929050565b60008180421115611a8157604051632d56313160e11b815260040160405180910390fd5b611a8c868686612d28565b9695505050505050565b60003381611aa48286611f6e565b905083811015611b045760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77604482015264207a65726f60d81b6064820152608401610eb7565b610c99828686840361224b565b611b2960008051602061453283398151915233611906565b611b465760405163f982dd0f60e01b815260040160405180910390fd5b6016805465ff0000000000198116650100000000009182900460ff1615909102179055565b600033610c768185856123e9565b6000808280421115611b9e57604051632d56313160e11b815260040160405180910390fd5b611baa88888789612e8e565b92509250509550959350505050565b611bd160008051602061453283398151915233611906565b611bee5760405163f982dd0f60e01b815260040160405180910390fd5b610d828383836131a2565b611c1160008051602061453283398151915233611906565b611c2e5760405163f982dd0f60e01b815260040160405180910390fd5b6064811180611c3b575080155b80611c4857508060155410155b15611c66576040516304a5f22d60e41b815260040160405180910390fd5b60148190556040518181527f5e08a24ce41a50207cd6c60d4c0b135c6385789570e226d4672e781c4985502590602001610b58565b611cb360008051602061453283398151915233611906565b611cd05760405163f982dd0f60e01b815260040160405180910390fd5b600980546001600160a01b0319166001600160a01b0383169081179091556040517f6de4326a8b9054d72d9dbab97d27bc4edffadee7d966f5af9cc4eafdaf8e545590600090a250565b6000818152600660205260408120610aba906136de565b611d4960008051602061453283398151915233611906565b611d665760405163f982dd0f60e01b815260040160405180910390fd5b600754600d5460405163095ea7b360e01b81526001600160a01b039283169263095ea7b392611d9d92911690600090600401614324565b6020604051808303816000875af1158015611dbc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611de0919061433d565b50600d80546001600160a01b0319166001600160a01b038381169190911790915560075460405163095ea7b360e01b815291169063095ea7b390611e2c90849060001990600401614324565b6020604051808303816000875af1158015611e4b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e6f919061433d565b506040516001600160a01b038216907f9e9a9a4a82acd1b28aab6bf1d43aad70ae6d290549c0d6183e2e91ebcdf5744190600090a250565b600082815260056020526040902060010154611ec28161258d565b610d8283836125b9565b60006114c8848484612d28565b611ef160008051602061453283398151915233611906565b611f0e5760405163f982dd0f60e01b815260040160405180910390fd5b6064811180611f1b575080155b15611f39576040516304a5f22d60e41b815260040160405180910390fd5b60138190556040518181527ff247e4dd947ab13ba6c46412e403447a26e67109ba13945a20e3170e9acef88390602001610b58565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b600c54601654604051638f2e819960e01b81526001600160a01b037f000000000000000000000000756ee6857f915a2b5366f2ef56d8d13857aef8ad811660048301526fffffffffffffffffffffffffffffffff8516602483015263ffffffff90921660448201526000929190911690638f2e819990606401602060405180830381865afa15801561202f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610aba919061430b565b61206b60008051602061453283398151915233611906565b6120885760405163f982dd0f60e01b815260040160405180910390fd5b6064811180612095575080155b806120a25750600f548110155b156120c0576040516304a5f22d60e41b815260040160405180910390fd5b600e8190556040518181527f09734b71a2b91b11a979f46fe8751cc0a22e29af3006d1ba5196a7ace08798b490602001610b58565b61210d60008051602061453283398151915233611906565b61212a5760405163f982dd0f60e01b815260040160405180910390fd5b601654600160201b900460ff161561184a576016805464ff0000000019169055604051600081527f4543baa938cb97f5073ec206ad35638cdb1f4db8f677d31579b2f6fe7d18c14a90602001611841565b6121858282611906565b610eca5760008281526005602090815260408083206001600160a01b03851684529091529020805460ff191660011790556121bd3390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b6000610e36836001600160a01b0384166136e8565b60006001600160e01b03198216637965db0b60e01b1480610aba57506301ffc9a760e01b6001600160e01b0319831614610aba565b6001600160a01b0383166122ad5760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b6064820152608401610eb7565b6001600160a01b03821661230e5760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b6064820152608401610eb7565b6001600160a01b0383811660008181526001602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b600061237b8484611f6e565b905060001981146123e357818110156123d65760405162461bcd60e51b815260206004820152601d60248201527f45524332303a20696e73756666696369656e7420616c6c6f77616e63650000006044820152606401610eb7565b6123e3848484840361224b565b50505050565b6001600160a01b03831661244d5760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b6064820152608401610eb7565b6001600160a01b0382166124af5760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b6064820152608401610eb7565b6001600160a01b038316600090815260208190526040902054818110156125275760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e7420657863656564732062604482015265616c616e636560d01b6064820152608401610eb7565b6001600160a01b03848116600081815260208181526040808320878703905593871680835291849020805487019055925185815290927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a36123e3565b61110b8133613737565b6125a1828261217b565b6000828152600660205260409020610d829082612201565b6125c38282613790565b6000828152600660205260409020610d8290826137f7565b6040516001600160a01b03808516602483015283166044820152606481018290526123e39085906323b872dd60e01b906084015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b03199093169290921790915261380c565b6001600160a01b03821661269c5760405162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f2061646472657373006044820152606401610eb7565b80600260008282546126ae919061419e565b90915550506001600160a01b038216600081815260208181526040808320805486019055518481527fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a35050565b610d828363a9059cbb60e01b848460405160240161260f929190614324565b6001600160a01b0382166127845760405162461bcd60e51b815260206004820152602160248201527f45524332303a206275726e2066726f6d20746865207a65726f206164647265736044820152607360f81b6064820152608401610eb7565b6001600160a01b038216600090815260208190526040902054818110156127f85760405162461bcd60e51b815260206004820152602260248201527f45524332303a206275726e20616d6f756e7420657863656564732062616c616e604482015261636560f01b6064820152608401610eb7565b6001600160a01b0383166000818152602081815260408083208686039055600280548790039055518581529192917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a3505050565b6000808212156128695781600003610aba565b5090565b6000610e3683836138e1565b6016546000908190600160201b900460ff16156128a85760405162b4aa3760e01b815260040160405180910390fd5b600b546001600160a01b03166128d1576040516325493da160e21b815260040160405180910390fd5b600f548311806128e25750600e5483105b15612900576040516304a5f22d60e41b815260040160405180910390fd5b61290a3389612724565b60006129168985611984565b90935090508783111561293c57604051630f993ed160e11b815260040160405180910390fd5b8681118061294957508581105b15612967576040516323a4850d60e21b815260040160405180910390fd5b61298a3330612976848761419e565b6007546001600160a01b03169291906125db565b600d54600754604051631f72642160e31b81526001600160a01b039283169263fb932108926129c0929116908790600401614324565b600060405180830381600087803b1580156129da57600080fd5b505af11580156129ee573d6000803e3d6000fd5b505060095460405163095ea7b360e01b81526001600160a01b037f000000000000000000000000756ee6857f915a2b5366f2ef56d8d13857aef8ad8116945063095ea7b39350612a449216908d90600401614324565b6020604051808303816000875af1158015612a63573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a87919061433d565b5060075460095460405163095ea7b360e01b81526001600160a01b039283169263095ea7b392612abe929116908590600401614324565b6020604051808303816000875af1158015612add573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612b01919061433d565b50600954600754604051635a47ddc360e01b81526001600160a01b037f000000000000000000000000756ee6857f915a2b5366f2ef56d8d13857aef8ad81166004830152918216602482015260006044820152606481018c905260848101849052600160a482015260c481018990523060e482015242610104820152911690635a47ddc390610124016060604051808303816000875af1158015612ba9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612bcd91906143ea565b600a54600b5460405163095ea7b360e01b81529296506001600160a01b03918216945063095ea7b39350612c08929116908690600401614324565b6020604051808303816000875af1158015612c27573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612c4b919061433d565b50600b546001600160a01b0316631f933c2d8684612c68886116cb565b6040516001600160e01b031960e086901b1681526001600160a01b03909316600484015260248301919091526044820152606401600060405180830381600087803b158015612cb657600080fd5b505af1158015612cca573d6000803e3d6000fd5b5050604080518c8152602081018790529081018590526001600160a01b03881692503391507f49a80f92a21531b6bccc1cf51cb96a7f814282e7d6a69d0a4dea0167193cd3589060600160405180910390a350965096945050505050565b601654600090600160201b900460ff1615612d555760405162b4aa3760e01b815260040160405180910390fd5b612d5f3385612724565b612d6884610e3d565b905082811115612d8b576040516323a4850d60e21b815260040160405180910390fd5b600754612da3906001600160a01b03163330846125db565b600d54600754604051631f72642160e31b81526001600160a01b039283169263fb93210892612dd9929116908590600401614324565b600060405180830381600087803b158015612df357600080fd5b505af1158015612e07573d6000803e3d6000fd5b50612e419250506001600160a01b037f000000000000000000000000756ee6857f915a2b5366f2ef56d8d13857aef8ad1690508386612705565b60408051858152602081018390526001600160a01b0384169133917fb1c971764663d561c0ec2baf395a55f33f0a79fabb35bbad580247ba2959523d910160405180910390a39392505050565b6016546000908190600160201b900460ff1615612ebd5760405162b4aa3760e01b815260040160405180910390fd5b601554841180612ece575060145484105b15612eec576040516304a5f22d60e41b815260040160405180910390fd5b612ef63387612724565b612f008685610e14565b915084821115612f23576040516323a4850d60e21b815260040160405180910390fd5b600754612f3b906001600160a01b03163330856125db565b600d54600754604051631f72642160e31b81526001600160a01b039283169263fb93210892612f71929116908690600401614324565b600060405180830381600087803b158015612f8b57600080fd5b505af1158015612f9f573d6000803e3d6000fd5b505050506000600860009054906101000a90046001600160a01b03166001600160a01b0316631f8507166040518163ffffffff1660e01b8152600401602060405180830381865afa158015612ff8573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061301c9190614122565b60405163095ea7b360e01b81529091506001600160a01b037f000000000000000000000000756ee6857f915a2b5366f2ef56d8d13857aef8ad169063095ea7b39061306d9084908b90600401614324565b6020604051808303816000875af115801561308c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906130b0919061433d565b50806001600160a01b0316630a2abdb3886130ca88611499565b6040516001600160e01b031960e085901b168152600481019290925260248201526001600160a01b0387166044820152600060648201526084016020604051808303816000875af1158015613123573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613147919061430b565b60408051898152602081018690529081018290529092506001600160a01b0385169033907f74b7132649649ee4ac2519ff0bb963ce812aaa4c8a0ad0f73c9ac1149fa6e3f49060600160405180910390a35094509492505050565b600080846001600160a01b0316639d63848a6040518163ffffffff1660e01b81526004016040805180830381865afa1580156131e2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906132069190614418565b91509150826001600160a01b0316826001600160a01b031614801561325c57507f000000000000000000000000756ee6857f915a2b5366f2ef56d8d13857aef8ad6001600160a01b0316816001600160a01b0316145b806132b457507f000000000000000000000000756ee6857f915a2b5366f2ef56d8d13857aef8ad6001600160a01b0316826001600160a01b03161480156132b45750826001600160a01b0316816001600160a01b0316145b6132d15760405163a818b0ad60e01b815260040160405180910390fd5b84600a60006101000a8154816001600160a01b0302191690836001600160a01b03160217905550826001600160a01b0316846001600160a01b0316630dfe16816040518163ffffffff1660e01b8152600401602060405180830381865afa158015613340573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906133649190614122565b6001600160a01b031614801561340c57507f000000000000000000000000756ee6857f915a2b5366f2ef56d8d13857aef8ad6001600160a01b0316846001600160a01b031663d21220a76040518163ffffffff1660e01b8152600401602060405180830381865afa1580156133dd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906134019190614122565b6001600160a01b0316145b8061352657507f000000000000000000000000756ee6857f915a2b5366f2ef56d8d13857aef8ad6001600160a01b0316846001600160a01b0316630dfe16816040518163ffffffff1660e01b8152600401602060405180830381865afa15801561347a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061349e9190614122565b6001600160a01b03161480156135265750826001600160a01b0316846001600160a01b031663d21220a76040518163ffffffff1660e01b8152600401602060405180830381865afa1580156134f7573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061351b9190614122565b6001600160a01b0316145b61354357604051631bf31bfb60e31b815260040160405180910390fd5b600c80546001600160a01b0319166001600160a01b038681169190911790915560075484821691161461368d576007546001600160a01b0316156135fd57600754600d5460405163095ea7b360e01b81526001600160a01b039283169263095ea7b3926135b892911690600090600401614324565b6020604051808303816000875af11580156135d7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906135fb919061433d565b505b600780546001600160a01b0319166001600160a01b03858116918217909255600d5460405163095ea7b360e01b8152919263095ea7b392613648929091169060001990600401614324565b6020604051808303816000875af1158015613667573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061368b919061433d565b505b826001600160a01b0316846001600160a01b0316866001600160a01b03167f9393b560cd26f49fe024dd267863e33175eac92055a63c0151d12dd81f5cec5360405160405180910390a45050505050565b6000610aba825490565b600081815260018301602052604081205461372f57508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610aba565b506000610aba565b6137418282611906565b610eca5761374e8161390b565b61375983602061391d565b60405160200161376a929190614447565b60408051601f198184030181529082905262461bcd60e51b8252610eb791600401613d3e565b61379a8282611906565b15610eca5760008281526005602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b6000610e36836001600160a01b038416613ab9565b6000613861826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316613bac9092919063ffffffff16565b9050805160001480613882575080806020019051810190613882919061433d565b610d825760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610eb7565b60008260000182815481106138f8576138f86144bc565b9060005260206000200154905092915050565b6060610aba6001600160a01b03831660145b6060600061392c836002614155565b61393790600261419e565b67ffffffffffffffff81111561394f5761394f6144d2565b6040519080825280601f01601f191660200182016040528015613979576020820181803683370190505b509050600360fc1b81600081518110613994576139946144bc565b60200101906001600160f81b031916908160001a905350600f60fb1b816001815181106139c3576139c36144bc565b60200101906001600160f81b031916908160001a90535060006139e7846002614155565b6139f290600161419e565b90505b6001811115613a6a576f181899199a1a9b1b9c1cb0b131b232b360811b85600f1660108110613a2657613a266144bc565b1a60f81b828281518110613a3c57613a3c6144bc565b60200101906001600160f81b031916908160001a90535060049490941c93613a63816144e8565b90506139f5565b508315610e365760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610eb7565b60008181526001830160205260408120548015613ba2576000613add6001836141f5565b8554909150600090613af1906001906141f5565b9050818114613b56576000866000018281548110613b1157613b116144bc565b9060005260206000200154905080876000018481548110613b3457613b346144bc565b6000918252602080832090910192909255918252600188019052604090208390555b8554869080613b6757613b676144ff565b600190038181906000526020600020016000905590558560010160008681526020019081526020016000206000905560019350505050610aba565b6000915050610aba565b60606114c8848460008585600080866001600160a01b03168587604051613bd39190614515565b60006040518083038185875af1925050503d8060008114613c10576040519150601f19603f3d011682016040523d82523d6000602084013e613c15565b606091505b5091509150613c2687838387613c31565b979650505050505050565b60608315613ca0578251600003613c99576001600160a01b0385163b613c995760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610eb7565b50816114c8565b6114c88383815115613cb55781518083602001fd5b8060405162461bcd60e51b8152600401610eb79190613d3e565b600060208284031215613ce157600080fd5b81356001600160e01b031981168114610e3657600080fd5b600060208284031215613d0b57600080fd5b5035919050565b60005b83811015613d2d578181015183820152602001613d15565b838111156123e35750506000910152565b6020815260008251806020840152613d5d816040850160208701613d12565b601f01601f19169190910160400192915050565b6001600160a01b038116811461110b57600080fd5b60008060408385031215613d9957600080fd5b8235613da481613d71565b946020939093013593505050565b600080600060608486031215613dc757600080fd5b8335613dd281613d71565b92506020840135613de281613d71565b929592945050506040919091013590565b600060208284031215613e0557600080fd5b813563ffffffff81168114610e3657600080fd5b60008060408385031215613e2c57600080fd5b823591506020830135613e3e81613d71565b809150509250929050565b60008060408385031215613e5c57600080fd5b50508035926020909101359150565b801515811461110b57600080fd5b60008060408385031215613e8c57600080fd5b8235613e9781613d71565b91506020830135613e3e81613e6b565b600080600080600060808688031215613ebf57600080fd5b8535613eca81613d71565b94506020860135935060408601359250606086013567ffffffffffffffff80821115613ef557600080fd5b818801915088601f830112613f0957600080fd5b813581811115613f1857600080fd5b896020828501011115613f2a57600080fd5b9699959850939650602001949392505050565b600060208284031215613f4f57600080fd5b8135610e3681613d71565b600080600080600080600060e0888a031215613f7557600080fd5b873596506020880135955060408801359450606088013593506080880135613f9c81613d71565b9699959850939692959460a0840135945060c09093013592915050565b60008060008060808587031215613fcf57600080fd5b84359350602085013592506040850135613fe881613d71565b9396929550929360600135925050565b600080600080600060a0868803121561401057600080fd5b8535945060208601359350604086013561402981613d71565b94979396509394606081013594506080013592915050565b60008060006060848603121561405657600080fd5b833561406181613d71565b9250602084013561407181613d71565b9150604084013561408181613d71565b809150509250925092565b6000806000606084860312156140a157600080fd5b8335925060208401359150604084013561408181613d71565b600080604083850312156140cd57600080fd5b82356140d881613d71565b91506020830135613e3e81613d71565b600181811c908216806140fc57607f821691505b60208210810361411c57634e487b7160e01b600052602260045260246000fd5b50919050565b60006020828403121561413457600080fd5b8151610e3681613d71565b634e487b7160e01b600052601160045260246000fd5b600081600019048311821515161561416f5761416f61413f565b500290565b634e487b7160e01b600052601260045260246000fd5b60008261419957614199614174565b500490565b600082198211156141b1576141b161413f565b500190565b60008083128015600160ff1b8501841216156141d4576141d461413f565b6001600160ff1b03840183138116156141ef576141ef61413f565b50500390565b6000828210156142075761420761413f565b500390565b60008261421b5761421b614174565b600160ff1b8214600019841416156142355761423561413f565b500590565b60006001600160ff1b03818413828413808216868404861116156142605761426061413f565b600160ff1b600087128281168783058912161561427f5761427f61413f565b6000871292508782058712848416161561429b5761429b61413f565b878505871281841616156142b1576142b161413f565b505050929093029392505050565b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b8381526040602082015260006143026040830184866142bf565b95945050505050565b60006020828403121561431d57600080fd5b5051919050565b6001600160a01b03929092168252602082015260400190565b60006020828403121561434f57600080fd5b8151610e3681613e6b565b8481526001600160a01b0384166020820152606060408201819052600090611a8c90830184866142bf565b600080821280156001600160ff1b03849003851316156143a7576143a761413f565b600160ff1b83900384128116156143c0576143c061413f565b50500190565b600080604083850312156143d957600080fd5b505080516020909101519092909150565b6000806000606084860312156143ff57600080fd5b8351925060208401519150604084015190509250925092565b6000806040838503121561442b57600080fd5b825161443681613d71565b6020840151909250613e3e81613d71565b7f416363657373436f6e74726f6c3a206163636f756e742000000000000000000081526000835161447f816017850160208801613d12565b7001034b99036b4b9b9b4b733903937b6329607d1b60179184019182015283516144b0816028840160208801613d12565b01602801949350505050565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6000816144f7576144f761413f565b506000190190565b634e487b7160e01b600052603160045260246000fd5b60008251614527818460208701613d12565b919091019291505056fedf8b4c520ffe197c5343c6f5aec59570151ef9a492f2c624fd45ddde6135ec42a2646970667358221220db6534cff304af69722a000cbafedf8b3e5049defcebd1560dc414059af9970c64736f6c634300080d0033

Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

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

Validator Index Block Amount
View All Withdrawals

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits
Loading...
Loading
[ Download: CSV Export  ]

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