ETH Price: $3,252.67 (+2.76%)
Gas: 1 Gwei

Contract

0xd051eF3DBBEA636Fa009A0318ac51e9eE2CBc3bD
 

Overview

ETH Balance

4.90602464810630799 ETH

Eth Value

$15,957.68 (@ $3,252.67/ETH)

Token Holdings

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To
Unstake203919412024-07-26 16:32:5957 mins ago1722011579IN
0xd051eF3D...eE2CBc3bD
0 ETH0.000349743.07457755
Unstake203885472024-07-26 5:11:2312 hrs ago1721970683IN
0xd051eF3D...eE2CBc3bD
0 ETH0.0003062.68944898
Stake203850842024-07-25 17:33:5923 hrs ago1721928839IN
0xd051eF3D...eE2CBc3bD
0 ETH0.002032076.80956951
Unstake203850572024-07-25 17:28:3524 hrs ago1721928515IN
0xd051eF3D...eE2CBc3bD
0 ETH0.000724715.53833315
Unstake203850552024-07-25 17:28:1124 hrs ago1721928491IN
0xd051eF3D...eE2CBc3bD
0 ETH0.00072945.65299012
Unstake203847882024-07-25 16:34:2324 hrs ago1721925263IN
0xd051eF3D...eE2CBc3bD
0 ETH0.000762615.82798123
Restake Rewards203840592024-07-25 14:07:4727 hrs ago1721916467IN
0xd051eF3D...eE2CBc3bD
0 ETH0.0022974710.00748904
Stake203816432024-07-25 6:02:2335 hrs ago1721887343IN
0xd051eF3D...eE2CBc3bD
0 ETH0.00054981.95449939
Unstake203816392024-07-25 6:01:3535 hrs ago1721887295IN
0xd051eF3D...eE2CBc3bD
0 ETH0.000218351.94972414
Claim Rewards203816352024-07-25 6:00:4735 hrs ago1721887247IN
0xd051eF3D...eE2CBc3bD
0 ETH0.000181192.10463438
Unstake203799962024-07-25 0:31:5940 hrs ago1721867519IN
0xd051eF3D...eE2CBc3bD
0 ETH0.00033342.93095184
Unstake203786962024-07-24 20:09:5945 hrs ago1721851799IN
0xd051eF3D...eE2CBc3bD
0 ETH0.000699655.3463175
Unstake203786912024-07-24 20:08:5945 hrs ago1721851739IN
0xd051eF3D...eE2CBc3bD
0 ETH0.000707175.47971131
Unstake203783952024-07-24 19:09:1146 hrs ago1721848151IN
0xd051eF3D...eE2CBc3bD
0 ETH0.000499495.05501339
Unstake203780912024-07-24 18:07:5947 hrs ago1721844479IN
0xd051eF3D...eE2CBc3bD
0 ETH0.000794086.06904725
Unstake203766882024-07-24 13:25:592 days ago1721827559IN
0xd051eF3D...eE2CBc3bD
0 ETH0.000732385.59693998
Unstake203764162024-07-24 12:30:472 days ago1721824247IN
0xd051eF3D...eE2CBc3bD
0 ETH0.000591654.52066655
Claim Rewards203750232024-07-24 7:51:472 days ago1721807507IN
0xd051eF3D...eE2CBc3bD
0 ETH0.000328123.17970166
Unstake203740962024-07-24 4:45:112 days ago1721796311IN
0xd051eF3D...eE2CBc3bD
0 ETH0.000410213.60386765
Restake Rewards203709612024-07-23 18:15:352 days ago1721758535IN
0xd051eF3D...eE2CBc3bD
0 ETH0.001668217.26651044
Unstake203674142024-07-23 6:23:353 days ago1721715815IN
0xd051eF3D...eE2CBc3bD
0 ETH0.00030852.35766166
Unstake203668512024-07-23 4:29:593 days ago1721708999IN
0xd051eF3D...eE2CBc3bD
0 ETH0.000638464.87922574
Unstake203668482024-07-23 4:29:233 days ago1721708963IN
0xd051eF3D...eE2CBc3bD
0 ETH0.000674915.23016029
Stake203635242024-07-22 17:20:594 days ago1721668859IN
0xd051eF3D...eE2CBc3bD
0 ETH0.001829656.13126691
Restake Rewards203625702024-07-22 14:08:594 days ago1721657339IN
0xd051eF3D...eE2CBc3bD
0 ETH0.002049488.92725424
View all transactions

Latest 25 internal transactions (View All)

Advanced mode:
Parent Transaction Hash Block From To
203919412024-07-26 16:32:5957 mins ago1722011579
0xd051eF3D...eE2CBc3bD
0.01508176 ETH
203885472024-07-26 5:11:2312 hrs ago1721970683
0xd051eF3D...eE2CBc3bD
0.00865704 ETH
203850572024-07-25 17:28:3524 hrs ago1721928515
0xd051eF3D...eE2CBc3bD
0.00734792 ETH
203850552024-07-25 17:28:1124 hrs ago1721928491
0xd051eF3D...eE2CBc3bD
0.02281514 ETH
203847882024-07-25 16:34:2324 hrs ago1721925263
0xd051eF3D...eE2CBc3bD
0.00272368 ETH
203840592024-07-25 14:07:4727 hrs ago1721916467
0xd051eF3D...eE2CBc3bD
0.13953474 ETH
203816352024-07-25 6:00:4735 hrs ago1721887247
0xd051eF3D...eE2CBc3bD
0.01392263 ETH
203799962024-07-25 0:31:5940 hrs ago1721867519
0xd051eF3D...eE2CBc3bD
0.0015964 ETH
203786962024-07-24 20:09:5945 hrs ago1721851799
0xd051eF3D...eE2CBc3bD
0.01750684 ETH
203786912024-07-24 20:08:5945 hrs ago1721851739
0xd051eF3D...eE2CBc3bD
0.04419225 ETH
203780912024-07-24 18:07:5947 hrs ago1721844479
0xd051eF3D...eE2CBc3bD
0.00525051 ETH
203766882024-07-24 13:25:592 days ago1721827559
0xd051eF3D...eE2CBc3bD
0.02406182 ETH
203764162024-07-24 12:30:472 days ago1721824247
0xd051eF3D...eE2CBc3bD
0.01882686 ETH
203750232024-07-24 7:51:472 days ago1721807507
0xd051eF3D...eE2CBc3bD
0.00133752 ETH
203709612024-07-23 18:15:352 days ago1721758535
0xd051eF3D...eE2CBc3bD
0.02411397 ETH
203674142024-07-23 6:23:353 days ago1721715815
0xd051eF3D...eE2CBc3bD
0.00283647 ETH
203668512024-07-23 4:29:593 days ago1721708999
0xd051eF3D...eE2CBc3bD
0.0073717 ETH
203668482024-07-23 4:29:233 days ago1721708963
0xd051eF3D...eE2CBc3bD
0.01166868 ETH
203625702024-07-22 14:08:594 days ago1721657339
0xd051eF3D...eE2CBc3bD
0.01348659 ETH
203625662024-07-22 14:08:114 days ago1721657291
0xd051eF3D...eE2CBc3bD
0.05894492 ETH
203618972024-07-22 11:53:114 days ago1721649191
0xd051eF3D...eE2CBc3bD
0.00117249 ETH
203618932024-07-22 11:52:234 days ago1721649143
0xd051eF3D...eE2CBc3bD
0.01447182 ETH
203613942024-07-22 10:12:114 days ago1721643131
0xd051eF3D...eE2CBc3bD
0.08123296 ETH
203591692024-07-22 2:44:234 days ago1721616263
0xd051eF3D...eE2CBc3bD
0.13946594 ETH
203584562024-07-22 0:21:114 days ago1721607671
0xd051eF3D...eE2CBc3bD
0.01573523 ETH
View All Internal Transactions
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
AIXRevenueSharing

Compiler Version
v0.8.6+commit.11564f7e

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion
File 1 of 14 : AIXRevenueSharing.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import "@openzeppelin/contracts/utils/Address.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts/utils/structs/EnumerableMap.sol";
import "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
import "@uniswap/v2-core/contracts/interfaces/IUniswapV2Factory.sol";
import "@uniswap/v2-core/contracts/interfaces/IUniswapV2Pair.sol";
import "@uniswap/v2-periphery/contracts/interfaces/IUniswapV2Router02.sol";

/**
 * @title AIXRevenueSharing
 * @dev A contract to stake AIX tokens and receive ETH as rewards.
 */
contract AIXRevenueSharing is Ownable, ReentrancyGuard {
    using EnumerableMap for EnumerableMap.UintToUintMap;
    using EnumerableSet for EnumerableSet.UintSet;
    using Address for address payable;
    using SafeERC20 for IERC20;

    IERC20 public immutable aix;

    uint256 public totalStaked;
    uint256 public totalBoostedStaked;
    uint256 public totalPaidRewards;
    uint256 public totalAssignedRewards;

    uint256 public currentETHPerDay;
    uint256 public accumulatedRewardPerBoostedToken;
    uint256 public lastAccumulatedRewardPerTokenUpdateTimestamp;

    bool public earlyWithdrawalAllowed;
    bool public stakePaused;

    event EarlyWithdrawalAllowedSet(bool earlyWithdrawalAllowed);
    event StakePausedSet(bool stakePaused);

    function setEarlyWithdrawalAllowed(bool _earlyWithdrawalAllowed) external onlyOwner {
        earlyWithdrawalAllowed = _earlyWithdrawalAllowed;
        emit EarlyWithdrawalAllowedSet(_earlyWithdrawalAllowed);
    }

    function setStakePaused(bool _stakePaused) external onlyOwner {
        stakePaused = _stakePaused;
        emit StakePausedSet(_stakePaused);
    }

    uint256 public lastStakeId = 0;

    // mainnet 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D
    // goerli 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D
    IUniswapV2Router02 public immutable uniswapRouter;

    address public controller;
    event ControllerSet(address controller);
    function setController(address _controller) external onlyOwner {
        controller = _controller;
        emit ControllerSet(_controller);
    }
    uint256 public maxETHPerDay;
    event MaxETHPerDaySet(uint256 maxETHPerDay);
    function setMaxETHPerDay(uint256 _maxETHPerDay) external onlyOwner {
        maxETHPerDay = _maxETHPerDay;
        emit MaxETHPerDaySet(_maxETHPerDay);
    }

    // mainnet 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2
    // goerli 0xB4FBF271143F4FBf7B91A5ded31805e42b2208d6
    address public immutable weth;

    struct Stake {
        address user;
        uint256 stakedAmount;
        uint256 boostedStakedAmount;
        uint256 period;
        uint256 unstakeTimestamp;
        uint256 lastRewardPerToken;
        uint256 totalPaidRewards;  // for statistics
    }

    mapping(address => EnumerableSet.UintSet) private _userStakes;
    mapping(uint256 => Stake) public stakes;

    EnumerableMap.UintToUintMap private _stakePeriodBoosts;

    event EmergencyWithdrawn(
        address indexed user,
        uint256 indexed stakeId,
        uint256 amount
    );
    event TransferETH(address indexed to, uint256 value);
    event Staked(
        address indexed user,
        uint256 indexed stakeId,
        uint256 stakedAmount,
        uint256 boostedAmount,
        uint256 unstakeTimestamp,
        uint256 lastRewardPerToken
    );
    event Withdrawn(
        address indexed user,
        uint256 indexed stakeId,
        uint256 amount,
        uint256 newStakedAmount,
        uint256 newBoostedStakedAmount,
        uint256 newUnstakeTimestamp,
        bool isRemoved
    );
    event RewardPaid(
        address indexed user,
        uint256 indexed stakeId,
        uint256 reward,
        uint256 lastRewardPerToken,
        uint256 stakeTotalPaidRewards,
        uint256 totalPaidRewards
    );
    event CurrentETHPerDaySet(uint256 currentETHPerDay);
    event EthReceived(uint256 amount);
    event EthToOwner(uint256 amount);

    struct StakePeriodBoost {
        uint256 period;
        uint256 boost;
    }

    event StakePeriodBoostsSet(uint256 period, uint256 boost);
    event StakePeriodBoostsRemoved(uint256 period);
    event TotalStakedChanged(uint256 totalStaked, uint256 totalBoostedStaked);

    /**
     * @dev Initializes the contract with the AIX token address.
     * @param _aix The AIX token contract address.
     */
    constructor(
        IERC20 _aix,
        IUniswapV2Router02 _uniswapRouter,
        address _weth,
        uint256 _maxETHPerDay
    ) {
        aix = _aix;
        uniswapRouter = _uniswapRouter;
        weth = _weth;
        maxETHPerDay = _maxETHPerDay;
    }

    function setStakePeriodBoosts(StakePeriodBoost[] memory _newStakePeriodBoosts) external onlyOwner {
        for (uint256 i = 0; i < _newStakePeriodBoosts.length; ++i) {
            StakePeriodBoost memory _stakePeriodBoost = _newStakePeriodBoosts[i];
            if (_stakePeriodBoost.boost > 0) {
                _stakePeriodBoosts.set(_stakePeriodBoost.period, _stakePeriodBoost.boost);
                emit StakePeriodBoostsSet(_stakePeriodBoost.period, _stakePeriodBoost.boost);
            } else {
                _stakePeriodBoosts.remove(_stakePeriodBoost.period);
                emit StakePeriodBoostsRemoved(_stakePeriodBoost.period);
            }
        }
    }

    event AccumulatedRewardPerBoostedTokenUpdated(
        uint256 accumulatedRewardPerBoostedToken,
        uint256 lastAccumulatedRewardPerTokenUpdateTimestamp
    );

    function _updateAccumulatedRewardPerToken() internal {
        if (totalBoostedStaked > 0) {
            uint256 assignedRewards = currentETHPerDay *
                (block.timestamp - lastAccumulatedRewardPerTokenUpdateTimestamp) / 1 days;
            totalAssignedRewards += assignedRewards;
            accumulatedRewardPerBoostedToken += 1e18 * assignedRewards / totalBoostedStaked;
        }
        lastAccumulatedRewardPerTokenUpdateTimestamp = block.timestamp;
        emit AccumulatedRewardPerBoostedTokenUpdated(
            accumulatedRewardPerBoostedToken,
            lastAccumulatedRewardPerTokenUpdateTimestamp
        );
    }

    function setCurrentETHPerDay(uint256 _currentETHPerDay) external {
        require(msg.sender == controller || msg.sender == owner(), "AIXRevenueSharing: Access denied");
        require(_currentETHPerDay <= maxETHPerDay, "AIXRevenueSharing: too high");
        _updateAccumulatedRewardPerToken();
        currentETHPerDay = _currentETHPerDay;
        emit CurrentETHPerDaySet(_currentETHPerDay);
    }

    function _payUserReward(address account, uint256 stakeId) internal returns(uint256) {
        Stake storage _stake = stakes[stakeId];
        uint256 reward = _stake.boostedStakedAmount *
            (accumulatedRewardPerBoostedToken - _stake.lastRewardPerToken) / 1e18;
        _stake.lastRewardPerToken = accumulatedRewardPerBoostedToken;
        _stake.totalPaidRewards += reward;
        totalPaidRewards += reward;
        emit RewardPaid(
            account,
            stakeId,
            reward,
            _stake.lastRewardPerToken,
            _stake.totalPaidRewards,
            totalPaidRewards
        );
        return reward;
    }

    /**
     * @dev Public function to stake AIX tokens.
     * @param amount The amount of AIX tokens to stake.
     */
    function stake(uint256 amount, uint256 period) external nonReentrant {
        require(!stakePaused, "AIXRevenueSharing: Staking is paused");
        require(amount >= 1e18, "AIXRevenueSharing: Cannot stake too small");
        uint256 stakeId = ++lastStakeId;

        uint256 boost = getStakePeriodBoost(period);

        _updateAccumulatedRewardPerToken();
        totalStaked += amount;
        uint256 boostedAmount = amount * boost / 10000;
        totalBoostedStaked += boostedAmount;

        stakes[stakeId] = Stake({
            user: msg.sender,
            stakedAmount: amount,
            boostedStakedAmount: boostedAmount,
            period: period,
            unstakeTimestamp: block.timestamp + period,
            lastRewardPerToken: accumulatedRewardPerBoostedToken,
            totalPaidRewards: 0
        });
        _userStakes[msg.sender].add(stakeId);
        aix.safeTransferFrom(msg.sender, address(this), amount);

        emit Staked({
            user: msg.sender,
            stakeId: stakeId,
            stakedAmount: amount,
            boostedAmount: boostedAmount,
            unstakeTimestamp: block.timestamp + period,
            lastRewardPerToken: accumulatedRewardPerBoostedToken
        });
        emit TotalStakedChanged(totalStaked, totalBoostedStaked);
    }

    event EarlyUnstake(address indexed user, uint256 indexed stakeId);

    /**
     * @notice Unstake and relock the rest.
     * @param amount The amount of AIX tokens to withdraw.
     */
    function unstake(
        uint256 stakeId,
        uint256 amount
    ) external nonReentrant {
        require(amount > 0, "AIXRevenueSharing: Cannot withdraw 0");
        Stake storage _stake = stakes[stakeId];
        require(_stake.stakedAmount >= amount, "AIXRevenueSharing: Withdraw amount exceeds balance");

        require(_userStakes[msg.sender].contains(stakeId), "AIXRevenueSharing: Stake does not belong to user");

        _updateAccumulatedRewardPerToken();

        uint256 reward = 0;
        if (_stake.unstakeTimestamp < block.timestamp) {
            reward = _payUserReward(msg.sender, stakeId);
        } else {
            require(earlyWithdrawalAllowed, "AIXRevenueSharing: too early");
            emit EarlyUnstake(msg.sender, stakeId);
            _stake.lastRewardPerToken = accumulatedRewardPerBoostedToken;  // rewards are not paid
        }

        totalStaked -= amount;
        _stake.stakedAmount -= amount;

        totalBoostedStaked -= _stake.boostedStakedAmount;
        if (_stake.stakedAmount == 0) {
            _userStakes[msg.sender].remove(stakeId);
            _stake.boostedStakedAmount = 0;
        } else {  // relock the rest
            _stake.boostedStakedAmount = _stake.stakedAmount * getStakePeriodBoost(_stake.period) / 10000;
            totalBoostedStaked += _stake.boostedStakedAmount;
            _stake.unstakeTimestamp = block.timestamp + _stake.period;
        }

        aix.safeTransfer(msg.sender, amount);
        safeTransferETH(msg.sender, reward);
        emit Withdrawn(
            msg.sender,
            stakeId,
            amount,
            _stake.stakedAmount,
            _stake.boostedStakedAmount,
            _stake.unstakeTimestamp,
            _stake.stakedAmount == 0
        );
        emit TotalStakedChanged(totalStaked, totalBoostedStaked);
    }

    // @notice WARNING! Understand what you are doing before calling this function.
    function emergencyWithdraw(uint256 stakeId) external nonReentrant {
        Stake storage _stake = stakes[stakeId];

        require(earlyWithdrawalAllowed || _stake.unstakeTimestamp < block.timestamp,
            "AIXRevenueSharing: too early");
        require(_userStakes[msg.sender].contains(stakeId), "AIXRevenueSharing: Stake does not belong to user");

        _updateAccumulatedRewardPerToken();
        uint256 amount = _stake.stakedAmount;
        totalStaked -= _stake.stakedAmount;
        totalBoostedStaked -= _stake.boostedStakedAmount;
        _stake.stakedAmount = 0;
        _stake.boostedStakedAmount = 0;
        _userStakes[msg.sender].remove(stakeId);

        aix.safeTransfer(msg.sender, amount);
        emit EmergencyWithdrawn(msg.sender, stakeId, amount);
        emit TotalStakedChanged(totalStaked, totalBoostedStaked);
    }

    event UnstakeTimestampUpdated(address indexed user, uint256 indexed stakeId, uint256 unstakeTimestamp);

    bool public claimRewardsBeforeUnstakeAllowed;
    event ClaimRewardsBeforeUnstakeAllowedSet(bool claimRewardsBeforeUnstakeAllowed);
    function setClaimRewardsBeforeUnstakeAllowed(bool _claimRewardsBeforeUnstakeAllowed) external onlyOwner {
        claimRewardsBeforeUnstakeAllowed = _claimRewardsBeforeUnstakeAllowed;
        emit ClaimRewardsBeforeUnstakeAllowedSet(_claimRewardsBeforeUnstakeAllowed);
    }

    function claimRewards(uint256 stakeId) external nonReentrant {
        require(_userStakes[msg.sender].contains(stakeId), "AIXRevenueSharing: Stake does not belong to user");
        _updateAccumulatedRewardPerToken();
        uint256 reward = _payUserReward(msg.sender, stakeId);
        if (block.timestamp < stakes[stakeId].unstakeTimestamp) {
            require(claimRewardsBeforeUnstakeAllowed, "AIXRevenueSharing: too early");
        }
        stakes[stakeId].unstakeTimestamp = block.timestamp + stakes[stakeId].period;
        emit UnstakeTimestampUpdated(msg.sender, stakeId, stakes[stakeId].unstakeTimestamp);
        safeTransferETH(msg.sender, reward);
    }

    function restakeRewards(
        uint256 stakeId,
        uint256 minAmountOut  // set to 0 to disable, in case of front-running we will use it
    ) external nonReentrant {
        require(!stakePaused, "AIXRevenueSharing: Staking is paused");
        require(_userStakes[msg.sender].contains(stakeId), "AIXRevenueSharing: Stake does not belong to user");
        _updateAccumulatedRewardPerToken();
        Stake storage _stake = stakes[stakeId];
        uint256 reward = _stake.boostedStakedAmount *
            (accumulatedRewardPerBoostedToken - _stake.lastRewardPerToken) / 1e18;
        require(reward > 0, "No rewards to restake");
        _stake.lastRewardPerToken = accumulatedRewardPerBoostedToken;
        totalPaidRewards += reward;
        _stake.totalPaidRewards += reward;

        uint256 aixAmount = _convertEthToAix(reward, minAmountOut);

        _stake.stakedAmount += aixAmount;
        totalBoostedStaked -= _stake.boostedStakedAmount;
        _stake.boostedStakedAmount = _stake.stakedAmount * getStakePeriodBoost(_stake.period) / 10000;
        totalBoostedStaked += _stake.boostedStakedAmount;
        totalStaked += aixAmount;
        _stake.unstakeTimestamp = block.timestamp + _stake.period;
        emit Restaked(
            msg.sender,
            stakeId,
            aixAmount,
            reward,
            _stake.stakedAmount,
            _stake.boostedStakedAmount,
            _stake.unstakeTimestamp
        );
        emit TotalStakedChanged(totalStaked, totalBoostedStaked);
    }

    event Restaked(
        address indexed user,
        uint256 indexed stakeId,
        uint256 amount,
        uint256 reward,
        uint256 stakedAmount,
        uint256 boostedStakedAmount,
        uint256 unstakeTimestamp
    );

    function _convertEthToAix(uint256 ethAmount, uint256 minAmountOut) internal returns (uint256) {
        address[] memory path = new address[](2);
        path[0] = weth;
        path[1] = address(aix);
        uint256[] memory amounts = uniswapRouter.swapExactETHForTokens{value: ethAmount}(
            minAmountOut,
            path,
            address(this),
            block.timestamp
        );
        return amounts[1];
    }

    function safeTransferETH(address to, uint256 value) internal {
        if (value > 0) {
            (bool success, ) = to.call{value: value}("");
            require(success, "ETH transfer failed");
        }
        emit TransferETH(to, value);
    }

    function recoverEth(uint256 amount) external onlyOwner {
        safeTransferETH(owner(), amount);
        emit EthToOwner(amount);
    }

    receive() external payable {
        emit EthReceived(msg.value);
    }

    // ---- view functions ----

    struct StakeInfo {
        address user;
        uint256 stakeId;
        uint256 stakedAmount;
        uint256 boostedStakedAmount;
        uint256 period;
        uint256 unstakeTimestamp;
        uint256 lastRewardPerToken;
        uint256 totalPaidRewards;  // for statistics
        uint256 apr;
        uint256 availableReward;
        uint256 poolShare;  // 100% = 1e18
    }

    function getAPRForPeriod(uint256 period) public view returns (uint256) {
        uint256 boost = getStakePeriodBoost(period);
        return calculateAPRForBoost(boost);
    }

    function getAvailableStakeReward(uint256 stakeId) public view returns (uint256) {
        Stake storage _stake = stakes[stakeId];
        require(totalBoostedStaked != 0, "Invalid contract state");
        uint256 _accumulatedRewardPerBoostedToken = accumulatedRewardPerBoostedToken +
            1e18 * currentETHPerDay *
            (block.timestamp - lastAccumulatedRewardPerTokenUpdateTimestamp) / 1 days / totalBoostedStaked;
        uint256 reward = _stake.boostedStakedAmount *
            (_accumulatedRewardPerBoostedToken - _stake.lastRewardPerToken) / 1e18;
        return reward;
    }

    function getAllStakesAvailableRewards(address account) public view returns (uint256) {
        uint256 result = 0;
        for (uint256 i = 0; i < _userStakes[account].length(); ++i) {
            result += getAvailableStakeReward(_userStakes[account].at(i));
        }
        return result;
    }

    /**
     * @dev Returns the boost factor for a given staking period.
     * @param period The staking period in seconds.
     * @return The boost factor for this staking period.
     */
    function getStakePeriodBoost(uint256 period) public view returns (uint256) {
        require(_stakePeriodBoosts.contains(period), "Staking period does not exist");
        return _stakePeriodBoosts.get(period);
    }

    /**
     * @dev Returns all staking periods with their boost factors.
     */
    function getAllStakesPeriod() public view returns (StakePeriodBoost[] memory) {
        StakePeriodBoost[] memory result = new StakePeriodBoost[](_stakePeriodBoosts.length());
        for (uint256 i = 0; i < _stakePeriodBoosts.length(); ++i) {
            (uint256 period, uint256 boost) = _stakePeriodBoosts.at(i);
            result[i].period = period;
            result[i].boost = boost;
        }
        return result;
    }

    struct StakePeriodBoostAPR {
        uint256 period;
        uint256 boost;
        uint256 apr;
    }

    function getAllStakesPeriodBoostAPR() public view returns (StakePeriodBoostAPR[] memory) {
        StakePeriodBoostAPR[] memory result = new StakePeriodBoostAPR[](_stakePeriodBoosts.length());
        for (uint256 i = 0; i < _stakePeriodBoosts.length(); ++i) {
            (uint256 period, uint256 boost) = _stakePeriodBoosts.at(i);
            result[i].period = period;
            result[i].boost = boost;
            result[i].apr = calculateAPRForBoost(boost);
        }
        return result;
    }

    /**
     * @notice Returns the APR for a given boost factor.
     * @param _boost The boost factor in 1/10000 units.
     * @return The APR for this boost factor (in 1/10000 units).
     */
    function calculateAPRForBoost(
        uint256 _boost
    ) public view returns (uint256) {
        address[] memory path = new address[](2);
        path[0] = weth;
        path[1] = address(aix);
        uint256 smallOne = 1e12;  // to avoid slippage
        uint256[] memory amounts = uniswapRouter.getAmountsOut(smallOne, path);
        uint256 ethInAixPrice = amounts[1];
        if (totalBoostedStaked == 0) {
            return type(uint256).max;
        }
        return _boost * currentETHPerDay * 365 * ethInAixPrice / smallOne / totalBoostedStaked;
    }

    function getUserStakeIds(address account) public view returns (uint256[] memory) {
        uint256[] memory result = new uint256[](_userStakes[account].length());
        for (uint256 i = 0; i < _userStakes[account].length(); ++i) {
            result[i] = _userStakes[account].at(i);
        }
        return result;
    }

    function getStake(uint256 stakeId) public view returns (StakeInfo memory) {
        Stake memory _stake = stakes[stakeId];
        require(_stake.user != address(0), "Stake does not exist");
        return StakeInfo({
            user: _stake.user,
            stakeId: stakeId,
            stakedAmount: _stake.stakedAmount,
            boostedStakedAmount: _stake.boostedStakedAmount,
            period: _stake.period,
            unstakeTimestamp: _stake.unstakeTimestamp,
            lastRewardPerToken: _stake.lastRewardPerToken,
            totalPaidRewards: _stake.totalPaidRewards,
            apr: calculateAPRForBoost(getStakePeriodBoost(_stake.period)),
            availableReward: getAvailableStakeReward(stakeId),
            poolShare: _stake.boostedStakedAmount * 1e18 / totalBoostedStaked
        });
    }

    function getUserStakes(address account) external view returns (StakeInfo[] memory) {
        uint256[] memory stakeIds = getUserStakeIds(account);
        StakeInfo[] memory result = new StakeInfo[](stakeIds.length);
        for (uint256 i = 0; i < stakeIds.length; ++i) {
            result[i] = getStake(stakeIds[i]);
        }
        return result;
    }
}

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

pragma solidity ^0.8.0;

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

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

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

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

    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        _checkOwner();
        _;
    }

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

    /**
     * @dev Throws if the sender is not the owner.
     */
    function _checkOwner() internal view virtual {
        require(owner() == _msgSender(), "Ownable: caller is not the owner");
    }

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

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

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Internal function without access restriction.
     */
    function _transferOwnership(address newOwner) internal virtual {
        address oldOwner = _owner;
        _owner = newOwner;
        emit OwnershipTransferred(oldOwner, newOwner);
    }
}

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

pragma solidity ^0.8.0;

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

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

    uint256 private _status;

    constructor() {
        _status = _NOT_ENTERED;
    }

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

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

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

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

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

File 4 of 14 : IERC20Permit.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (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.
 */
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].
     */
    function permit(
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) external;

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

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

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

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

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

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

pragma solidity ^0.8.1;

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

        return account.code.length > 0;
    }

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

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

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

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

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

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

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

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

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

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

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

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

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

File 8 of 14 : Context.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (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;
    }
}

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

pragma solidity ^0.8.0;

import "./EnumerableSet.sol";

/**
 * @dev Library for managing an enumerable variant of Solidity's
 * https://solidity.readthedocs.io/en/latest/types.html#mapping-types[`mapping`]
 * type.
 *
 * Maps have the following properties:
 *
 * - Entries are added, removed, and checked for existence in constant time
 * (O(1)).
 * - Entries are enumerated in O(n). No guarantees are made on the ordering.
 *
 * ```solidity
 * contract Example {
 *     // Add the library methods
 *     using EnumerableMap for EnumerableMap.UintToAddressMap;
 *
 *     // Declare a set state variable
 *     EnumerableMap.UintToAddressMap private myMap;
 * }
 * ```
 *
 * The following map types are supported:
 *
 * - `uint256 -> address` (`UintToAddressMap`) since v3.0.0
 * - `address -> uint256` (`AddressToUintMap`) since v4.6.0
 * - `bytes32 -> bytes32` (`Bytes32ToBytes32Map`) since v4.6.0
 * - `uint256 -> uint256` (`UintToUintMap`) since v4.7.0
 * - `bytes32 -> uint256` (`Bytes32ToUintMap`) since v4.7.0
 *
 * [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 EnumerableMap, you can either remove all elements one by one or create a fresh instance using an
 * array of EnumerableMap.
 * ====
 */
library EnumerableMap {
    using EnumerableSet for EnumerableSet.Bytes32Set;

    // To implement this library for multiple types with as little code
    // repetition as possible, we write it in terms of a generic Map type with
    // bytes32 keys and values.
    // The Map implementation uses private functions, and user-facing
    // implementations (such as Uint256ToAddressMap) are just wrappers around
    // the underlying Map.
    // This means that we can only create new EnumerableMaps for types that fit
    // in bytes32.

    struct Bytes32ToBytes32Map {
        // Storage of keys
        EnumerableSet.Bytes32Set _keys;
        mapping(bytes32 => bytes32) _values;
    }

    /**
     * @dev Adds a key-value pair to a map, or updates the value for an existing
     * key. O(1).
     *
     * Returns true if the key was added to the map, that is if it was not
     * already present.
     */
    function set(Bytes32ToBytes32Map storage map, bytes32 key, bytes32 value) internal returns (bool) {
        map._values[key] = value;
        return map._keys.add(key);
    }

    /**
     * @dev Removes a key-value pair from a map. O(1).
     *
     * Returns true if the key was removed from the map, that is if it was present.
     */
    function remove(Bytes32ToBytes32Map storage map, bytes32 key) internal returns (bool) {
        delete map._values[key];
        return map._keys.remove(key);
    }

    /**
     * @dev Returns true if the key is in the map. O(1).
     */
    function contains(Bytes32ToBytes32Map storage map, bytes32 key) internal view returns (bool) {
        return map._keys.contains(key);
    }

    /**
     * @dev Returns the number of key-value pairs in the map. O(1).
     */
    function length(Bytes32ToBytes32Map storage map) internal view returns (uint256) {
        return map._keys.length();
    }

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

    /**
     * @dev Tries to returns the value associated with `key`. O(1).
     * Does not revert if `key` is not in the map.
     */
    function tryGet(Bytes32ToBytes32Map storage map, bytes32 key) internal view returns (bool, bytes32) {
        bytes32 value = map._values[key];
        if (value == bytes32(0)) {
            return (contains(map, key), bytes32(0));
        } else {
            return (true, value);
        }
    }

    /**
     * @dev Returns the value associated with `key`. O(1).
     *
     * Requirements:
     *
     * - `key` must be in the map.
     */
    function get(Bytes32ToBytes32Map storage map, bytes32 key) internal view returns (bytes32) {
        bytes32 value = map._values[key];
        require(value != 0 || contains(map, key), "EnumerableMap: nonexistent key");
        return value;
    }

    /**
     * @dev Same as {get}, with a custom error message when `key` is not in the map.
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {tryGet}.
     */
    function get(
        Bytes32ToBytes32Map storage map,
        bytes32 key,
        string memory errorMessage
    ) internal view returns (bytes32) {
        bytes32 value = map._values[key];
        require(value != 0 || contains(map, key), errorMessage);
        return value;
    }

    /**
     * @dev Return the an array containing all the keys
     *
     * 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 map grows to a point where copying to memory consumes too much gas to fit in a block.
     */
    function keys(Bytes32ToBytes32Map storage map) internal view returns (bytes32[] memory) {
        return map._keys.values();
    }

    // UintToUintMap

    struct UintToUintMap {
        Bytes32ToBytes32Map _inner;
    }

    /**
     * @dev Adds a key-value pair to a map, or updates the value for an existing
     * key. O(1).
     *
     * Returns true if the key was added to the map, that is if it was not
     * already present.
     */
    function set(UintToUintMap storage map, uint256 key, uint256 value) internal returns (bool) {
        return set(map._inner, bytes32(key), bytes32(value));
    }

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

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

    /**
     * @dev Returns the number of elements in the map. O(1).
     */
    function length(UintToUintMap storage map) internal view returns (uint256) {
        return length(map._inner);
    }

    /**
     * @dev Returns the element stored at position `index` in the map. 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(UintToUintMap storage map, uint256 index) internal view returns (uint256, uint256) {
        (bytes32 key, bytes32 value) = at(map._inner, index);
        return (uint256(key), uint256(value));
    }

    /**
     * @dev Tries to returns the value associated with `key`. O(1).
     * Does not revert if `key` is not in the map.
     */
    function tryGet(UintToUintMap storage map, uint256 key) internal view returns (bool, uint256) {
        (bool success, bytes32 value) = tryGet(map._inner, bytes32(key));
        return (success, uint256(value));
    }

    /**
     * @dev Returns the value associated with `key`. O(1).
     *
     * Requirements:
     *
     * - `key` must be in the map.
     */
    function get(UintToUintMap storage map, uint256 key) internal view returns (uint256) {
        return uint256(get(map._inner, bytes32(key)));
    }

    /**
     * @dev Same as {get}, with a custom error message when `key` is not in the map.
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {tryGet}.
     */
    function get(UintToUintMap storage map, uint256 key, string memory errorMessage) internal view returns (uint256) {
        return uint256(get(map._inner, bytes32(key), errorMessage));
    }

    /**
     * @dev Return the an array containing all the keys
     *
     * 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 map grows to a point where copying to memory consumes too much gas to fit in a block.
     */
    function keys(UintToUintMap storage map) internal view returns (uint256[] memory) {
        bytes32[] memory store = keys(map._inner);
        uint256[] memory result;

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

        return result;
    }

    // UintToAddressMap

    struct UintToAddressMap {
        Bytes32ToBytes32Map _inner;
    }

    /**
     * @dev Adds a key-value pair to a map, or updates the value for an existing
     * key. O(1).
     *
     * Returns true if the key was added to the map, that is if it was not
     * already present.
     */
    function set(UintToAddressMap storage map, uint256 key, address value) internal returns (bool) {
        return set(map._inner, bytes32(key), bytes32(uint256(uint160(value))));
    }

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

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

    /**
     * @dev Returns the number of elements in the map. O(1).
     */
    function length(UintToAddressMap storage map) internal view returns (uint256) {
        return length(map._inner);
    }

    /**
     * @dev Returns the element stored at position `index` in the map. 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(UintToAddressMap storage map, uint256 index) internal view returns (uint256, address) {
        (bytes32 key, bytes32 value) = at(map._inner, index);
        return (uint256(key), address(uint160(uint256(value))));
    }

    /**
     * @dev Tries to returns the value associated with `key`. O(1).
     * Does not revert if `key` is not in the map.
     */
    function tryGet(UintToAddressMap storage map, uint256 key) internal view returns (bool, address) {
        (bool success, bytes32 value) = tryGet(map._inner, bytes32(key));
        return (success, address(uint160(uint256(value))));
    }

    /**
     * @dev Returns the value associated with `key`. O(1).
     *
     * Requirements:
     *
     * - `key` must be in the map.
     */
    function get(UintToAddressMap storage map, uint256 key) internal view returns (address) {
        return address(uint160(uint256(get(map._inner, bytes32(key)))));
    }

    /**
     * @dev Same as {get}, with a custom error message when `key` is not in the map.
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {tryGet}.
     */
    function get(
        UintToAddressMap storage map,
        uint256 key,
        string memory errorMessage
    ) internal view returns (address) {
        return address(uint160(uint256(get(map._inner, bytes32(key), errorMessage))));
    }

    /**
     * @dev Return the an array containing all the keys
     *
     * 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 map grows to a point where copying to memory consumes too much gas to fit in a block.
     */
    function keys(UintToAddressMap storage map) internal view returns (uint256[] memory) {
        bytes32[] memory store = keys(map._inner);
        uint256[] memory result;

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

        return result;
    }

    // AddressToUintMap

    struct AddressToUintMap {
        Bytes32ToBytes32Map _inner;
    }

    /**
     * @dev Adds a key-value pair to a map, or updates the value for an existing
     * key. O(1).
     *
     * Returns true if the key was added to the map, that is if it was not
     * already present.
     */
    function set(AddressToUintMap storage map, address key, uint256 value) internal returns (bool) {
        return set(map._inner, bytes32(uint256(uint160(key))), bytes32(value));
    }

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

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

    /**
     * @dev Returns the number of elements in the map. O(1).
     */
    function length(AddressToUintMap storage map) internal view returns (uint256) {
        return length(map._inner);
    }

    /**
     * @dev Returns the element stored at position `index` in the map. 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(AddressToUintMap storage map, uint256 index) internal view returns (address, uint256) {
        (bytes32 key, bytes32 value) = at(map._inner, index);
        return (address(uint160(uint256(key))), uint256(value));
    }

    /**
     * @dev Tries to returns the value associated with `key`. O(1).
     * Does not revert if `key` is not in the map.
     */
    function tryGet(AddressToUintMap storage map, address key) internal view returns (bool, uint256) {
        (bool success, bytes32 value) = tryGet(map._inner, bytes32(uint256(uint160(key))));
        return (success, uint256(value));
    }

    /**
     * @dev Returns the value associated with `key`. O(1).
     *
     * Requirements:
     *
     * - `key` must be in the map.
     */
    function get(AddressToUintMap storage map, address key) internal view returns (uint256) {
        return uint256(get(map._inner, bytes32(uint256(uint160(key)))));
    }

    /**
     * @dev Same as {get}, with a custom error message when `key` is not in the map.
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {tryGet}.
     */
    function get(
        AddressToUintMap storage map,
        address key,
        string memory errorMessage
    ) internal view returns (uint256) {
        return uint256(get(map._inner, bytes32(uint256(uint160(key))), errorMessage));
    }

    /**
     * @dev Return the an array containing all the keys
     *
     * 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 map grows to a point where copying to memory consumes too much gas to fit in a block.
     */
    function keys(AddressToUintMap storage map) internal view returns (address[] memory) {
        bytes32[] memory store = keys(map._inner);
        address[] memory result;

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

        return result;
    }

    // Bytes32ToUintMap

    struct Bytes32ToUintMap {
        Bytes32ToBytes32Map _inner;
    }

    /**
     * @dev Adds a key-value pair to a map, or updates the value for an existing
     * key. O(1).
     *
     * Returns true if the key was added to the map, that is if it was not
     * already present.
     */
    function set(Bytes32ToUintMap storage map, bytes32 key, uint256 value) internal returns (bool) {
        return set(map._inner, key, bytes32(value));
    }

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

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

    /**
     * @dev Returns the number of elements in the map. O(1).
     */
    function length(Bytes32ToUintMap storage map) internal view returns (uint256) {
        return length(map._inner);
    }

    /**
     * @dev Returns the element stored at position `index` in the map. 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(Bytes32ToUintMap storage map, uint256 index) internal view returns (bytes32, uint256) {
        (bytes32 key, bytes32 value) = at(map._inner, index);
        return (key, uint256(value));
    }

    /**
     * @dev Tries to returns the value associated with `key`. O(1).
     * Does not revert if `key` is not in the map.
     */
    function tryGet(Bytes32ToUintMap storage map, bytes32 key) internal view returns (bool, uint256) {
        (bool success, bytes32 value) = tryGet(map._inner, key);
        return (success, uint256(value));
    }

    /**
     * @dev Returns the value associated with `key`. O(1).
     *
     * Requirements:
     *
     * - `key` must be in the map.
     */
    function get(Bytes32ToUintMap storage map, bytes32 key) internal view returns (uint256) {
        return uint256(get(map._inner, key));
    }

    /**
     * @dev Same as {get}, with a custom error message when `key` is not in the map.
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {tryGet}.
     */
    function get(
        Bytes32ToUintMap storage map,
        bytes32 key,
        string memory errorMessage
    ) internal view returns (uint256) {
        return uint256(get(map._inner, key, errorMessage));
    }

    /**
     * @dev Return the an array containing all the keys
     *
     * 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 map grows to a point where copying to memory consumes too much gas to fit in a block.
     */
    function keys(Bytes32ToUintMap storage map) internal view returns (bytes32[] memory) {
        bytes32[] memory store = keys(map._inner);
        bytes32[] memory result;

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

        return result;
    }
}

File 10 of 14 : EnumerableSet.sol
// 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;
    }
}

File 11 of 14 : IUniswapV2Factory.sol
pragma solidity >=0.5.0;

interface IUniswapV2Factory {
    event PairCreated(address indexed token0, address indexed token1, address pair, uint);

    function feeTo() external view returns (address);
    function feeToSetter() external view returns (address);

    function getPair(address tokenA, address tokenB) external view returns (address pair);
    function allPairs(uint) external view returns (address pair);
    function allPairsLength() external view returns (uint);

    function createPair(address tokenA, address tokenB) external returns (address pair);

    function setFeeTo(address) external;
    function setFeeToSetter(address) external;
}

File 12 of 14 : IUniswapV2Pair.sol
pragma solidity >=0.5.0;

interface IUniswapV2Pair {
    event Approval(address indexed owner, address indexed spender, uint value);
    event Transfer(address indexed from, address indexed to, uint value);

    function name() external pure returns (string memory);
    function symbol() external pure returns (string memory);
    function decimals() external pure returns (uint8);
    function totalSupply() external view returns (uint);
    function balanceOf(address owner) external view returns (uint);
    function allowance(address owner, address spender) external view returns (uint);

    function approve(address spender, uint value) external returns (bool);
    function transfer(address to, uint value) external returns (bool);
    function transferFrom(address from, address to, uint value) external returns (bool);

    function DOMAIN_SEPARATOR() external view returns (bytes32);
    function PERMIT_TYPEHASH() external pure returns (bytes32);
    function nonces(address owner) external view returns (uint);

    function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external;

    event Mint(address indexed sender, uint amount0, uint amount1);
    event Burn(address indexed sender, uint amount0, uint amount1, address indexed to);
    event Swap(
        address indexed sender,
        uint amount0In,
        uint amount1In,
        uint amount0Out,
        uint amount1Out,
        address indexed to
    );
    event Sync(uint112 reserve0, uint112 reserve1);

    function MINIMUM_LIQUIDITY() external pure returns (uint);
    function factory() external view returns (address);
    function token0() external view returns (address);
    function token1() external view returns (address);
    function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast);
    function price0CumulativeLast() external view returns (uint);
    function price1CumulativeLast() external view returns (uint);
    function kLast() external view returns (uint);

    function mint(address to) external returns (uint liquidity);
    function burn(address to) external returns (uint amount0, uint amount1);
    function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external;
    function skim(address to) external;
    function sync() external;

    function initialize(address, address) external;
}

File 13 of 14 : IUniswapV2Router01.sol
pragma solidity >=0.6.2;

interface IUniswapV2Router01 {
    function factory() external pure returns (address);
    function WETH() external pure returns (address);

    function addLiquidity(
        address tokenA,
        address tokenB,
        uint amountADesired,
        uint amountBDesired,
        uint amountAMin,
        uint amountBMin,
        address to,
        uint deadline
    ) external returns (uint amountA, uint amountB, uint liquidity);
    function addLiquidityETH(
        address token,
        uint amountTokenDesired,
        uint amountTokenMin,
        uint amountETHMin,
        address to,
        uint deadline
    ) external payable returns (uint amountToken, uint amountETH, uint liquidity);
    function removeLiquidity(
        address tokenA,
        address tokenB,
        uint liquidity,
        uint amountAMin,
        uint amountBMin,
        address to,
        uint deadline
    ) external returns (uint amountA, uint amountB);
    function removeLiquidityETH(
        address token,
        uint liquidity,
        uint amountTokenMin,
        uint amountETHMin,
        address to,
        uint deadline
    ) external returns (uint amountToken, uint amountETH);
    function removeLiquidityWithPermit(
        address tokenA,
        address tokenB,
        uint liquidity,
        uint amountAMin,
        uint amountBMin,
        address to,
        uint deadline,
        bool approveMax, uint8 v, bytes32 r, bytes32 s
    ) external returns (uint amountA, uint amountB);
    function removeLiquidityETHWithPermit(
        address token,
        uint liquidity,
        uint amountTokenMin,
        uint amountETHMin,
        address to,
        uint deadline,
        bool approveMax, uint8 v, bytes32 r, bytes32 s
    ) external returns (uint amountToken, uint amountETH);
    function swapExactTokensForTokens(
        uint amountIn,
        uint amountOutMin,
        address[] calldata path,
        address to,
        uint deadline
    ) external returns (uint[] memory amounts);
    function swapTokensForExactTokens(
        uint amountOut,
        uint amountInMax,
        address[] calldata path,
        address to,
        uint deadline
    ) external returns (uint[] memory amounts);
    function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline)
        external
        payable
        returns (uint[] memory amounts);
    function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline)
        external
        returns (uint[] memory amounts);
    function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline)
        external
        returns (uint[] memory amounts);
    function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline)
        external
        payable
        returns (uint[] memory amounts);

    function quote(uint amountA, uint reserveA, uint reserveB) external pure returns (uint amountB);
    function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) external pure returns (uint amountOut);
    function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) external pure returns (uint amountIn);
    function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts);
    function getAmountsIn(uint amountOut, address[] calldata path) external view returns (uint[] memory amounts);
}

File 14 of 14 : IUniswapV2Router02.sol
pragma solidity >=0.6.2;

import './IUniswapV2Router01.sol';

interface IUniswapV2Router02 is IUniswapV2Router01 {
    function removeLiquidityETHSupportingFeeOnTransferTokens(
        address token,
        uint liquidity,
        uint amountTokenMin,
        uint amountETHMin,
        address to,
        uint deadline
    ) external returns (uint amountETH);
    function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens(
        address token,
        uint liquidity,
        uint amountTokenMin,
        uint amountETHMin,
        address to,
        uint deadline,
        bool approveMax, uint8 v, bytes32 r, bytes32 s
    ) external returns (uint amountETH);

    function swapExactTokensForTokensSupportingFeeOnTransferTokens(
        uint amountIn,
        uint amountOutMin,
        address[] calldata path,
        address to,
        uint deadline
    ) external;
    function swapExactETHForTokensSupportingFeeOnTransferTokens(
        uint amountOutMin,
        address[] calldata path,
        address to,
        uint deadline
    ) external payable;
    function swapExactTokensForETHSupportingFeeOnTransferTokens(
        uint amountIn,
        uint amountOutMin,
        address[] calldata path,
        address to,
        uint deadline
    ) external;
}

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

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"contract IERC20","name":"_aix","type":"address"},{"internalType":"contract IUniswapV2Router02","name":"_uniswapRouter","type":"address"},{"internalType":"address","name":"_weth","type":"address"},{"internalType":"uint256","name":"_maxETHPerDay","type":"uint256"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"accumulatedRewardPerBoostedToken","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"lastAccumulatedRewardPerTokenUpdateTimestamp","type":"uint256"}],"name":"AccumulatedRewardPerBoostedTokenUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bool","name":"claimRewardsBeforeUnstakeAllowed","type":"bool"}],"name":"ClaimRewardsBeforeUnstakeAllowedSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"controller","type":"address"}],"name":"ControllerSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"currentETHPerDay","type":"uint256"}],"name":"CurrentETHPerDaySet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"uint256","name":"stakeId","type":"uint256"}],"name":"EarlyUnstake","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bool","name":"earlyWithdrawalAllowed","type":"bool"}],"name":"EarlyWithdrawalAllowedSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"uint256","name":"stakeId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"EmergencyWithdrawn","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"EthReceived","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"EthToOwner","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"maxETHPerDay","type":"uint256"}],"name":"MaxETHPerDaySet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"uint256","name":"stakeId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"reward","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"stakedAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"boostedStakedAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"unstakeTimestamp","type":"uint256"}],"name":"Restaked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"uint256","name":"stakeId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"reward","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"lastRewardPerToken","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"stakeTotalPaidRewards","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"totalPaidRewards","type":"uint256"}],"name":"RewardPaid","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bool","name":"stakePaused","type":"bool"}],"name":"StakePausedSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"period","type":"uint256"}],"name":"StakePeriodBoostsRemoved","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"period","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"boost","type":"uint256"}],"name":"StakePeriodBoostsSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"uint256","name":"stakeId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"stakedAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"boostedAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"unstakeTimestamp","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"lastRewardPerToken","type":"uint256"}],"name":"Staked","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"totalStaked","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"totalBoostedStaked","type":"uint256"}],"name":"TotalStakedChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"TransferETH","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"uint256","name":"stakeId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"unstakeTimestamp","type":"uint256"}],"name":"UnstakeTimestampUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"uint256","name":"stakeId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newStakedAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newBoostedStakedAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newUnstakeTimestamp","type":"uint256"},{"indexed":false,"internalType":"bool","name":"isRemoved","type":"bool"}],"name":"Withdrawn","type":"event"},{"inputs":[],"name":"accumulatedRewardPerBoostedToken","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"aix","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_boost","type":"uint256"}],"name":"calculateAPRForBoost","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"stakeId","type":"uint256"}],"name":"claimRewards","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"claimRewardsBeforeUnstakeAllowed","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"controller","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"currentETHPerDay","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"earlyWithdrawalAllowed","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"stakeId","type":"uint256"}],"name":"emergencyWithdraw","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"period","type":"uint256"}],"name":"getAPRForPeriod","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"getAllStakesAvailableRewards","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getAllStakesPeriod","outputs":[{"components":[{"internalType":"uint256","name":"period","type":"uint256"},{"internalType":"uint256","name":"boost","type":"uint256"}],"internalType":"struct AIXRevenueSharing.StakePeriodBoost[]","name":"","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getAllStakesPeriodBoostAPR","outputs":[{"components":[{"internalType":"uint256","name":"period","type":"uint256"},{"internalType":"uint256","name":"boost","type":"uint256"},{"internalType":"uint256","name":"apr","type":"uint256"}],"internalType":"struct AIXRevenueSharing.StakePeriodBoostAPR[]","name":"","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"stakeId","type":"uint256"}],"name":"getAvailableStakeReward","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"stakeId","type":"uint256"}],"name":"getStake","outputs":[{"components":[{"internalType":"address","name":"user","type":"address"},{"internalType":"uint256","name":"stakeId","type":"uint256"},{"internalType":"uint256","name":"stakedAmount","type":"uint256"},{"internalType":"uint256","name":"boostedStakedAmount","type":"uint256"},{"internalType":"uint256","name":"period","type":"uint256"},{"internalType":"uint256","name":"unstakeTimestamp","type":"uint256"},{"internalType":"uint256","name":"lastRewardPerToken","type":"uint256"},{"internalType":"uint256","name":"totalPaidRewards","type":"uint256"},{"internalType":"uint256","name":"apr","type":"uint256"},{"internalType":"uint256","name":"availableReward","type":"uint256"},{"internalType":"uint256","name":"poolShare","type":"uint256"}],"internalType":"struct AIXRevenueSharing.StakeInfo","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"period","type":"uint256"}],"name":"getStakePeriodBoost","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"getUserStakeIds","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"getUserStakes","outputs":[{"components":[{"internalType":"address","name":"user","type":"address"},{"internalType":"uint256","name":"stakeId","type":"uint256"},{"internalType":"uint256","name":"stakedAmount","type":"uint256"},{"internalType":"uint256","name":"boostedStakedAmount","type":"uint256"},{"internalType":"uint256","name":"period","type":"uint256"},{"internalType":"uint256","name":"unstakeTimestamp","type":"uint256"},{"internalType":"uint256","name":"lastRewardPerToken","type":"uint256"},{"internalType":"uint256","name":"totalPaidRewards","type":"uint256"},{"internalType":"uint256","name":"apr","type":"uint256"},{"internalType":"uint256","name":"availableReward","type":"uint256"},{"internalType":"uint256","name":"poolShare","type":"uint256"}],"internalType":"struct AIXRevenueSharing.StakeInfo[]","name":"","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lastAccumulatedRewardPerTokenUpdateTimestamp","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lastStakeId","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxETHPerDay","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"recoverEth","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"stakeId","type":"uint256"},{"internalType":"uint256","name":"minAmountOut","type":"uint256"}],"name":"restakeRewards","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"_claimRewardsBeforeUnstakeAllowed","type":"bool"}],"name":"setClaimRewardsBeforeUnstakeAllowed","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_controller","type":"address"}],"name":"setController","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_currentETHPerDay","type":"uint256"}],"name":"setCurrentETHPerDay","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"_earlyWithdrawalAllowed","type":"bool"}],"name":"setEarlyWithdrawalAllowed","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_maxETHPerDay","type":"uint256"}],"name":"setMaxETHPerDay","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"_stakePaused","type":"bool"}],"name":"setStakePaused","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"period","type":"uint256"},{"internalType":"uint256","name":"boost","type":"uint256"}],"internalType":"struct AIXRevenueSharing.StakePeriodBoost[]","name":"_newStakePeriodBoosts","type":"tuple[]"}],"name":"setStakePeriodBoosts","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"period","type":"uint256"}],"name":"stake","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"stakePaused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"stakes","outputs":[{"internalType":"address","name":"user","type":"address"},{"internalType":"uint256","name":"stakedAmount","type":"uint256"},{"internalType":"uint256","name":"boostedStakedAmount","type":"uint256"},{"internalType":"uint256","name":"period","type":"uint256"},{"internalType":"uint256","name":"unstakeTimestamp","type":"uint256"},{"internalType":"uint256","name":"lastRewardPerToken","type":"uint256"},{"internalType":"uint256","name":"totalPaidRewards","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalAssignedRewards","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalBoostedStaked","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalPaidRewards","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalStaked","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"uniswapRouter","outputs":[{"internalType":"contract IUniswapV2Router02","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"stakeId","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"unstake","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"weth","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"stateMutability":"payable","type":"receive"}]

60e06040526000600a553480156200001657600080fd5b5060405162003519380380620035198339810160408190526200003991620000c2565b620000443362000072565b600180556001600160601b0319606094851b811660805292841b831660a052921b1660c052600c5562000135565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60008060008060808587031215620000d957600080fd5b8451620000e6816200011c565b6020860151909450620000f9816200011c565b60408601519093506200010c816200011c565b6060959095015193969295505050565b6001600160a01b03811681146200013257600080fd5b50565b60805160601c60a05160601c60c05160601c61336c620001ad600039600081816103df01528181610a55015261254701526000818161056101528181610b0a01526125f501526000818161082e01528181610aa901528181610f740152818161161901528181611c25015261259b015261336c6000f3fe6080604052600436106102605760003560e01c8063735de9f7116101445780639e2c8a5b116100b6578063ce325bf81161007a578063ce325bf81461074e578063d5a44f861461077b578063dad7ad9e1461081c578063f2fde38b14610850578063f77c479114610870578063f85277bc1461089057600080fd5b80639e2c8a5b146106ac578063a47350ac146106cc578063a5f93b10146106ee578063b0ef25131461070e578063b62d7fa51461072e57600080fd5b8063862e6de911610108578063862e6de9146105fc578063862ee7731461061c5780638da5cb5b1461063e57806392eefe9b1461065c57806394f68a0c1461067c578063993e0f9d1461069257600080fd5b8063735de9f71461054f5780637b0472f0146105835780637f8bc677146105a3578063817b1cd2146105b9578063842e2981146105cf57600080fd5b806347cacd2a116101dd578063533ecfa1116101a1578063533ecfa1146104a557806355f6b7d3146104c55780635e942556146104db57806360ffdc16146104fb5780636bd91c331461051a578063715018a61461053a57600080fd5b806347cacd2a146104195780634af3211c1461042f5780634d31ccdb146104455780634e25b08b146104655780635312ea8e1461048557600080fd5b806324a4afd51161022457806324a4afd51461034a57806327190e6a14610360578063313da78f14610380578063334d7e53146103ad5780633fc8cef3146103cd57600080fd5b80630962ef791461029f5780631385ae5b146102c15780631578e193146102ea5780631748e84c146103005780631c4ccd131461032a57600080fd5b3661029a576040513481527f353bcaaf167a6add95a753d39727e3d3beb865129a69a10ed774b0b8996714039060200160405180910390a1005b600080fd5b3480156102ab57600080fd5b506102bf6102ba366004612e08565b6108b0565b005b3480156102cd57600080fd5b506102d760035481565b6040519081526020015b60405180910390f35b3480156102f657600080fd5b506102d760085481565b34801561030c57600080fd5b5060095461031a9060ff1681565b60405190151581526020016102e1565b34801561033657600080fd5b506102bf610345366004612dce565b6109d2565b34801561035657600080fd5b506102d7600a5481565b34801561036c57600080fd5b506102d761037b366004612e08565b610a2e565b34801561038c57600080fd5b506103a061039b366004612c4d565b610c17565b6040516102e19190613008565b3480156103b957600080fd5b506102bf6103c8366004612e08565b610d01565b3480156103d957600080fd5b506104017f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b0390911681526020016102e1565b34801561042557600080fd5b506102d7600c5481565b34801561043b57600080fd5b506102d760065481565b34801561045157600080fd5b506102d7610460366004612e08565b610d3e565b34801561047157600080fd5b506102bf610480366004612e08565b610e2a565b34801561049157600080fd5b506102bf6104a0366004612e08565b610e7d565b3480156104b157600080fd5b506102d76104c0366004612e08565b611023565b3480156104d157600080fd5b506102d760045481565b3480156104e757600080fd5b506102bf6104f6366004612e21565b61108d565b34801561050757600080fd5b5060095461031a90610100900460ff1681565b34801561052657600080fd5b506102bf610535366004612c76565b61133b565b34801561054657600080fd5b506102bf611427565b34801561055b57600080fd5b506104017f000000000000000000000000000000000000000000000000000000000000000081565b34801561058f57600080fd5b506102bf61059e366004612e21565b61143b565b3480156105af57600080fd5b506102d760075481565b3480156105c557600080fd5b506102d760025481565b3480156105db57600080fd5b506105ef6105ea366004612c4d565b611693565b6040516102e19190612f1e565b34801561060857600080fd5b506102bf610617366004612e08565b61175e565b34801561062857600080fd5b5061063161185c565b6040516102e19190612fc6565b34801561064a57600080fd5b506000546001600160a01b0316610401565b34801561066857600080fd5b506102bf610677366004612c4d565b61194f565b34801561068857600080fd5b506102d760055481565b34801561069e57600080fd5b5060125461031a9060ff1681565b3480156106b857600080fd5b506102bf6106c7366004612e21565b6119a5565b3480156106d857600080fd5b506106e1611d08565b6040516102e19190612f6d565b3480156106fa57600080fd5b506102d7610709366004612c4d565b611e30565b34801561071a57600080fd5b506102bf610729366004612dce565b611e9f565b34801561073a57600080fd5b506102d7610749366004612e08565b611ee8565b34801561075a57600080fd5b5061076e610769366004612e08565b611f06565b6040516102e1919061313e565b34801561078757600080fd5b506107dd610796366004612e08565b600e6020526000908152604090208054600182015460028301546003840154600485015460058601546006909601546001600160a01b039095169593949293919290919087565b604080516001600160a01b0390981688526020880196909652948601939093526060850191909152608084015260a083015260c082015260e0016102e1565b34801561082857600080fd5b506104017f000000000000000000000000000000000000000000000000000000000000000081565b34801561085c57600080fd5b506102bf61086b366004612c4d565b61206a565b34801561087c57600080fd5b50600b54610401906001600160a01b031681565b34801561089c57600080fd5b506102bf6108ab366004612dce565b6120e0565b6108b8612129565b336000908152600d602090815260408083208484526001019091529020546108fb5760405162461bcd60e51b81526004016108f290613073565b60405180910390fd5b610903612183565b600061090f338361224f565b6000838152600e602052604090206004015490915042101561094d5760125460ff1661094d5760405162461bcd60e51b81526004016108f2906130c3565b6000828152600e60205260409020600301546109699042613219565b6000838152600e60205260409081902060040182905551839133917f567af1ae5124187b5426da6d961677abe4a9f921bf06107c2a56364fbdbc2cec916109b39190815260200190565b60405180910390a36109c5338261233c565b506109cf60018055565b50565b6109da612424565b600980548215156101000261ff00199091161790556040517f39c6622545aee57f6da3d44c470d1642afca7ca6a93b5f1f2f045d496fb2f15c90610a2390831515815260200190565b60405180910390a150565b604080516002808252606082018352600092839291906020830190803683370190505090507f000000000000000000000000000000000000000000000000000000000000000081600081518110610a8757610a876132fc565b60200260200101906001600160a01b031690816001600160a01b0316815250507f000000000000000000000000000000000000000000000000000000000000000081600181518110610adb57610adb6132fc565b6001600160a01b03928316602091820292909201015260405163d06ca61f60e01b815264e8d4a51000916000917f00000000000000000000000000000000000000000000000000000000000000009091169063d06ca61f90610b43908590879060040161314d565b60006040518083038186803b158015610b5b57600080fd5b505afa158015610b6f573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610b979190810190612d36565b9050600081600181518110610bae57610bae6132fc565b6020026020010151905060035460001415610bd0575060001995945050505050565b600354838260065489610be39190613253565b610bef9061016d613253565b610bf99190613253565b610c039190613231565b610c0d9190613231565b9695505050505050565b6001600160a01b0381166000908152600d6020526040812060609190610c3c9061247e565b67ffffffffffffffff811115610c5457610c54613312565b604051908082528060200260200182016040528015610c7d578160200160208202803683370190505b50905060005b6001600160a01b0384166000908152600d60205260409020610ca49061247e565b811015610cfa576001600160a01b0384166000908152600d60205260409020610ccd9082612488565b828281518110610cdf57610cdf6132fc565b6020908102919091010152610cf3816132b5565b9050610c83565b5092915050565b610d09612424565b600c8190556040518181527f697f37d5c125ace1cbc4127272485e94a60b4bb5ad10be994b441e2c312b7e6890602001610a23565b6000818152600e60205260408120600354610d945760405162461bcd60e51b8152602060048201526016602482015275496e76616c696420636f6e747261637420737461746560501b60448201526064016108f2565b60006003546201518060085442610dab9190613272565b600654610dc090670de0b6b3a7640000613253565b610dca9190613253565b610dd49190613231565b610dde9190613231565b600754610deb9190613219565b90506000670de0b6b3a7640000836005015483610e089190613272565b8460020154610e179190613253565b610e219190613231565b95945050505050565b610e32612424565b610e4d610e476000546001600160a01b031690565b8261233c565b6040518181527f493f5fc7cacabcb6ba5f9ae8168f4bdd534259a32379d22db77206898d9b9f5e90602001610a23565b610e85612129565b6000818152600e6020526040902060095460ff1680610ea75750428160040154105b610ec35760405162461bcd60e51b81526004016108f2906130c3565b336000908152600d60209081526040808320858452600101909152902054610efd5760405162461bcd60e51b81526004016108f290613073565b610f05612183565b600181015460028054829190600090610f1f908490613272565b9091555050600282015460038054600090610f3b908490613272565b909155505060006001830181905560028301819055338152600d60205260409020610f669084612494565b50610f9b6001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001633836124a0565b604051818152839033907fb47853100b79d8afa66237bdb4f7f09d96628ee23aa8aac8a8c21a901c67ddb29060200160405180910390a37f710f527818bfa032ab1185a29deb411f70cc3ecb9eb24bdc93d93a0df5e86a63600254600354604051611010929190918252602082015260400190565b60405180910390a150506109cf60018055565b6000611030600f83612508565b61107c5760405162461bcd60e51b815260206004820152601d60248201527f5374616b696e6720706572696f6420646f6573206e6f7420657869737400000060448201526064016108f2565b611087600f83612514565b92915050565b611095612129565b600954610100900460ff16156110bd5760405162461bcd60e51b81526004016108f2906130fa565b336000908152600d602090815260408083208584526001019091529020546110f75760405162461bcd60e51b81526004016108f290613073565b6110ff612183565b6000828152600e602052604081206005810154600754919291670de0b6b3a76400009161112b91613272565b836002015461113a9190613253565b6111449190613231565b90506000811161118e5760405162461bcd60e51b81526020600482015260156024820152744e6f207265776172647320746f2072657374616b6560581b60448201526064016108f2565b600754826005018190555080600460008282546111ab9190613219565b92505081905550808260060160008282546111c69190613219565b90915550600090506111d88285612520565b9050808360010160008282546111ee9190613219565b909155505060028301546003805460009061120a908490613272565b925050819055506127106112218460030154611023565b84600101546112309190613253565b61123a9190613231565b6002840181905560038054600090611253908490613219565b92505081905550806002600082825461126c9190613219565b909155505060038301546112809042613219565b600484018190556001840154600285015460408051858152602081018790529081019290925260608201526080810191909152859033907f5139bc88ac9aa018a361de04bab7e7bfd0c127df2e4be783c222f0a1b48bb4f19060a0015b60405180910390a37f710f527818bfa032ab1185a29deb411f70cc3ecb9eb24bdc93d93a0df5e86a63600254600354604051611323929190918252602082015260400190565b60405180910390a150505061133760018055565b5050565b611343612424565b60005b8151811015611337576000828281518110611363576113636132fc565b602002602001015190506000816020015111156113d1578051602082015161138d91600f916126af565b50805160208083015160408051938452918301527f79cec334fdf120033998ffa4c9913fd617d37070d76dd98619a42b7c1e5bfadc910160405180910390a1611416565b80516113df90600f906126c4565b5080516040519081527f40e6c80f041ab36089264c7d6fa3c7f8c8e9182b828fb0979b6bb278e326f4bd9060200160405180910390a15b50611420816132b5565b9050611346565b61142f612424565b61143960006126d0565b565b611443612129565b600954610100900460ff161561146b5760405162461bcd60e51b81526004016108f2906130fa565b670de0b6b3a76400008210156114d55760405162461bcd60e51b815260206004820152602960248201527f414958526576656e756553686172696e673a2043616e6e6f74207374616b65206044820152681d1bdbc81cdb585b1b60ba1b60648201526084016108f2565b6000600a600081546114e6906132b5565b9182905550905060006114f883611023565b9050611502612183565b83600260008282546115149190613219565b90915550600090506127106115298387613253565b6115339190613231565b905080600360008282546115479190613219565b90915550506040805160e08101825233815260208101879052908101829052606081018590526080810161157b8642613219565b815260075460208083019190915260006040928301819052868152600e8252828120845181546001600160a01b0319166001600160a01b03909116178155848301516001820155848401516002820155606085015160038201556080850151600482015560a0850151600582015560c090940151600690940193909355338352600d9052902061160b9084612720565b506116416001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001633308861272c565b82337f6381ea17a5324d29cc015352644672ead5185c1c61a0d3a521eda97e35cec97e87846116708942613219565b6007546040805194855260208501939093529183015260608201526080016112dd565b606060006116a083610c17565b90506000815167ffffffffffffffff8111156116be576116be613312565b6040519080825280602002602001820160405280156116f757816020015b6116e4612bea565b8152602001906001900390816116dc5790505b50905060005b82518110156117565761172883828151811061171b5761171b6132fc565b6020026020010151611f06565b82828151811061173a5761173a6132fc565b60200260200101819052508061174f906132b5565b90506116fd565b509392505050565b600b546001600160a01b031633148061178157506000546001600160a01b031633145b6117cd5760405162461bcd60e51b815260206004820181905260248201527f414958526576656e756553686172696e673a204163636573732064656e69656460448201526064016108f2565b600c5481111561181f5760405162461bcd60e51b815260206004820152601b60248201527f414958526576656e756553686172696e673a20746f6f2068696768000000000060448201526064016108f2565b611827612183565b60068190556040518181527f80c29ffccc25678a74926dde5be98c46623591d4175330efa89197e64798e7c390602001610a23565b6060600061186a600f61276a565b67ffffffffffffffff81111561188257611882613312565b6040519080825280602002602001820160405280156118c757816020015b60408051808201909152600080825260208201528152602001906001900390816118a05790505b50905060005b6118d7600f61276a565b811015611949576000806118ec600f84612775565b9150915081848481518110611903576119036132fc565b6020026020010151600001818152505080848481518110611926576119266132fc565b60200260200101516020018181525050505080611942906132b5565b90506118cd565b50919050565b611957612424565b600b80546001600160a01b0319166001600160a01b0383169081179091556040519081527f79f74fd5964b6943d8a1865abfb7f668c92fa3f32c0a2e3195da7d0946703ad790602001610a23565b6119ad612129565b60008111611a095760405162461bcd60e51b8152602060048201526024808201527f414958526576656e756553686172696e673a2043616e6e6f74207769746864726044820152630617720360e41b60648201526084016108f2565b6000828152600e602052604090206001810154821115611a865760405162461bcd60e51b815260206004820152603260248201527f414958526576656e756553686172696e673a20576974686472617720616d6f756044820152716e7420657863656564732062616c616e636560701b60648201526084016108f2565b336000908152600d60209081526040808320868452600101909152902054611ac05760405162461bcd60e51b81526004016108f290613073565b611ac8612183565b60004282600401541015611ae757611ae0338561224f565b9050611b3f565b60095460ff16611b095760405162461bcd60e51b81526004016108f2906130c3565b604051849033907f7f0c0a5ae64764439bfe2d11b5b9c2eefa1318071154ce368bdd0267f9398a1d90600090a360075460058301555b8260026000828254611b519190613272565b9250508190555082826001016000828254611b6c9190613272565b9091555050600282015460038054600090611b88908490613272565b90915550506001820154611bbc57336000908152600d60205260409020611baf9085612494565b5060006002830155611c18565b612710611bcc8360030154611023565b8360010154611bdb9190613253565b611be59190613231565b6002830181905560038054600090611bfe908490613219565b90915550506003820154611c129042613219565b60048301555b611c4c6001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001633856124a0565b611c56338261233c565b600182015460028301546004840154604080518781526020810185905290810192909252606082015290156080820152849033907f111b200afbd38e85f739e7392193530fbad770e481920fc49701f5ca108f8c659060a00160405180910390a37f710f527818bfa032ab1185a29deb411f70cc3ecb9eb24bdc93d93a0df5e86a63600254600354604051611cf5929190918252602082015260400190565b60405180910390a1505061133760018055565b60606000611d16600f61276a565b67ffffffffffffffff811115611d2e57611d2e613312565b604051908082528060200260200182016040528015611d8357816020015b611d7060405180606001604052806000815260200160008152602001600081525090565b815260200190600190039081611d4c5790505b50905060005b611d93600f61276a565b81101561194957600080611da8600f84612775565b9150915081848481518110611dbf57611dbf6132fc565b6020026020010151600001818152505080848481518110611de257611de26132fc565b60200260200101516020018181525050611dfb81610a2e565b848481518110611e0d57611e0d6132fc565b60200260200101516040018181525050505080611e29906132b5565b9050611d89565b600080805b6001600160a01b0384166000908152600d60205260409020611e569061247e565b811015610cfa576001600160a01b0384166000908152600d60205260409020611e83906104609083612488565b611e8d9083613219565b9150611e98816132b5565b9050611e35565b611ea7612424565b6012805460ff19168215159081179091556040519081527fac01945f43eb167b56e310bc1fc6e5b311013329ec4e1d966a3ce77b1ae4a5d190602001610a23565b600080611ef483611023565b9050611eff81610a2e565b9392505050565b611f0e612bea565b6000828152600e6020908152604091829020825160e08101845281546001600160a01b03168082526001830154938201939093526002820154938101939093526003810154606084015260048101546080840152600581015460a08401526006015460c0830152611fb85760405162461bcd60e51b815260206004820152601460248201527314dd185ad948191bd95cc81b9bdd08195e1a5cdd60621b60448201526064016108f2565b60405180610160016040528082600001516001600160a01b03168152602001848152602001826020015181526020018260400151815260200182606001518152602001826080015181526020018260a0015181526020018260c00151815260200161202961037b8460600151611023565b815260200161203785610d3e565b81526020016003548360400151670de0b6b3a76400006120579190613253565b6120619190613231565b90529392505050565b612072612424565b6001600160a01b0381166120d75760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016108f2565b6109cf816126d0565b6120e8612424565b6009805460ff19168215159081179091556040519081527fa9a253aa4e8bda7c44e27a7e80525798ab443de4d1ed21d2c0bf5ef21c7a6eb190602001610a23565b6002600154141561217c5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016108f2565b6002600155565b60035415612206576000620151806008544261219f9190613272565b6006546121ac9190613253565b6121b69190613231565b905080600560008282546121ca9190613219565b90915550506003546121e482670de0b6b3a7640000613253565b6121ee9190613231565b600760008282546121ff9190613219565b9091555050505b4260088190556007546040517f07c8c1e0b9fdc68defdff8357d6bfb6a46eab344c2e6007a7786958b513b8d9292612245928252602082015260400190565b60405180910390a1565b6000818152600e6020526040812060058101546007548391670de0b6b3a76400009161227b9190613272565b836002015461228a9190613253565b6122949190613231565b90506007548260050181905550808260060160008282546122b59190613219565b9250508190555080600460008282546122ce9190613219565b909155505060058201546006830154600454604080518581526020810194909452830191909152606082015284906001600160a01b038716907f6a1c9812f6d42eaf5c00058b4fc1d00233e24805a4965009d650401f50adc53e9060800160405180910390a3949350505050565b80156123dd576000826001600160a01b03168260405160006040518083038185875af1925050503d806000811461238f576040519150601f19603f3d011682016040523d82523d6000602084013e612394565b606091505b50509050806123db5760405162461bcd60e51b8152602060048201526013602482015272115512081d1c985b9cd9995c8819985a5b1959606a1b60448201526064016108f2565b505b816001600160a01b03167ffd69c215b8b91dab5e96ff0bcbaf5dc372919948eea2003ae16481c036f816f88260405161241891815260200190565b60405180910390a25050565b6000546001600160a01b031633146114395760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016108f2565b6000611087825490565b6000611eff8383612791565b6000611eff83836127bb565b6040516001600160a01b03831660248201526044810182905261250390849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b0319909316929092179091526128ae565b505050565b6000611eff8383612983565b6000611eff838361299b565b604080516002808252606082018352600092839291906020830190803683370190505090507f000000000000000000000000000000000000000000000000000000000000000081600081518110612579576125796132fc565b60200260200101906001600160a01b031690816001600160a01b0316815250507f0000000000000000000000000000000000000000000000000000000000000000816001815181106125cd576125cd6132fc565b6001600160a01b039283166020918202929092010152604051637ff36ab560e01b81526000917f00000000000000000000000000000000000000000000000000000000000000001690637ff36ab5908790612632908890879030904290600401613166565b6000604051808303818588803b15801561264b57600080fd5b505af115801561265f573d6000803e3d6000fd5b50505050506040513d6000823e601f3d908101601f191682016040526126889190810190612d36565b90508060018151811061269d5761269d6132fc565b60200260200101519250505092915050565b60006126bc848484612a0b565b949350505050565b6000611eff8383612a28565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6000611eff8383612a45565b6040516001600160a01b03808516602483015283166044820152606481018290526127649085906323b872dd60e01b906084016124cc565b50505050565b600061108782612a94565b60008080806127848686612a9f565b9097909650945050505050565b60008260000182815481106127a8576127a86132fc565b9060005260206000200154905092915050565b600081815260018301602052604081205480156128a45760006127df600183613272565b85549091506000906127f390600190613272565b9050818114612858576000866000018281548110612813576128136132fc565b9060005260206000200154905080876000018481548110612836576128366132fc565b6000918252602080832090910192909255918252600188019052604090208390555b8554869080612869576128696132e6565b600190038181906000526020600020016000905590558560010160008681526020019081526020016000206000905560019350505050611087565b6000915050611087565b6000612903826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316612aca9092919063ffffffff16565b90508051600014806129245750808060200190518101906129249190612deb565b6125035760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b60648201526084016108f2565b60008181526001830160205260408120541515611eff565b6000818152600283016020526040812054801515806129bf57506129bf8484612983565b611eff5760405162461bcd60e51b815260206004820152601e60248201527f456e756d657261626c654d61703a206e6f6e6578697374656e74206b6579000060448201526064016108f2565b600082815260028401602052604081208290556126bc8484612720565b60008181526002830160205260408120819055611eff8383612494565b6000818152600183016020526040812054612a8c57508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155611087565b506000611087565b60006110878261247e565b60008080612aad8585612488565b600081815260029690960160205260409095205494959350505050565b60606126bc848460008585600080866001600160a01b03168587604051612af19190612f02565b60006040518083038185875af1925050503d8060008114612b2e576040519150601f19603f3d011682016040523d82523d6000602084013e612b33565b606091505b5091509150612b4487838387612b4f565b979650505050505050565b60608315612bbb578251612bb4576001600160a01b0385163b612bb45760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016108f2565b50816126bc565b6126bc8383815115612bd05781518083602001fd5b8060405162461bcd60e51b81526004016108f29190613040565b60405180610160016040528060006001600160a01b03168152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081525090565b600060208284031215612c5f57600080fd5b81356001600160a01b0381168114611eff57600080fd5b60006020808385031215612c8957600080fd5b823567ffffffffffffffff811115612ca057600080fd5b8301601f81018513612cb157600080fd5b8035612cc4612cbf826131f5565b6131c4565b80828252848201915084840188868560061b8701011115612ce457600080fd5b60009450845b84811015612d2857604080838c031215612d02578687fd5b612d0a61319b565b83358152888401358982015285529387019390910190600101612cea565b509098975050505050505050565b60006020808385031215612d4957600080fd5b825167ffffffffffffffff811115612d6057600080fd5b8301601f81018513612d7157600080fd5b8051612d7f612cbf826131f5565b80828252848201915084840188868560051b8701011115612d9f57600080fd5b600094505b83851015612dc2578051835260019490940193918501918501612da4565b50979650505050505050565b600060208284031215612de057600080fd5b8135611eff81613328565b600060208284031215612dfd57600080fd5b8151611eff81613328565b600060208284031215612e1a57600080fd5b5035919050565b60008060408385031215612e3457600080fd5b50508035926020909101359150565b600081518084526020808501945080840160005b83811015612e7c5781516001600160a01b031687529582019590820190600101612e57565b509495945050505050565b80516001600160a01b031682526020810151602083015260408101516040830152606081015160608301526080810151608083015260a081015160a083015260c081015160c083015260e081015160e08301526101008082015181840152506101208082015181840152506101408082015181840152505050565b60008251612f14818460208701613289565b9190910192915050565b6020808252825182820181905260009190848201906040850190845b81811015612f6157612f4d838551612e87565b928401926101609290920191600101612f3a565b50909695505050505050565b602080825282518282018190526000919060409081850190868401855b82811015612fb95781518051855286810151878601528501518585015260609093019290850190600101612f8a565b5091979650505050505050565b602080825282518282018190526000919060409081850190868401855b82811015612fb957815180518552860151868501529284019290850190600101612fe3565b6020808252825182820181905260009190848201906040850190845b81811015612f6157835183529284019291840191600101613024565b602081526000825180602084015261305f816040850160208701613289565b601f01601f19169190910160400192915050565b60208082526030908201527f414958526576656e756553686172696e673a205374616b6520646f6573206e6f60408201526f3a103132b637b733903a37903ab9b2b960811b606082015260800190565b6020808252601c908201527f414958526576656e756553686172696e673a20746f6f206561726c7900000000604082015260600190565b60208082526024908201527f414958526576656e756553686172696e673a205374616b696e672069732070616040820152631d5cd95960e21b606082015260800190565b61016081016110878284612e87565b8281526040602082015260006126bc6040830184612e43565b84815260806020820152600061317f6080830186612e43565b6001600160a01b03949094166040830152506060015292915050565b6040805190810167ffffffffffffffff811182821017156131be576131be613312565b60405290565b604051601f8201601f1916810167ffffffffffffffff811182821017156131ed576131ed613312565b604052919050565b600067ffffffffffffffff82111561320f5761320f613312565b5060051b60200190565b6000821982111561322c5761322c6132d0565b500190565b60008261324e57634e487b7160e01b600052601260045260246000fd5b500490565b600081600019048311821515161561326d5761326d6132d0565b500290565b600082821015613284576132846132d0565b500390565b60005b838110156132a457818101518382015260200161328c565b838111156127645750506000910152565b60006000198214156132c9576132c96132d0565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052603160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b80151581146109cf57600080fdfea264697066735822122018c2c81294beb9ff8212a515381f3051c5780e7bfedb7dcabaece1c0008c8f6064736f6c6343000806003300000000000000000000000040e9187078032afe1a30cfcf76e4fe3d7ab5c6c50000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000001bc16d674ec80000

Deployed Bytecode

0x6080604052600436106102605760003560e01c8063735de9f7116101445780639e2c8a5b116100b6578063ce325bf81161007a578063ce325bf81461074e578063d5a44f861461077b578063dad7ad9e1461081c578063f2fde38b14610850578063f77c479114610870578063f85277bc1461089057600080fd5b80639e2c8a5b146106ac578063a47350ac146106cc578063a5f93b10146106ee578063b0ef25131461070e578063b62d7fa51461072e57600080fd5b8063862e6de911610108578063862e6de9146105fc578063862ee7731461061c5780638da5cb5b1461063e57806392eefe9b1461065c57806394f68a0c1461067c578063993e0f9d1461069257600080fd5b8063735de9f71461054f5780637b0472f0146105835780637f8bc677146105a3578063817b1cd2146105b9578063842e2981146105cf57600080fd5b806347cacd2a116101dd578063533ecfa1116101a1578063533ecfa1146104a557806355f6b7d3146104c55780635e942556146104db57806360ffdc16146104fb5780636bd91c331461051a578063715018a61461053a57600080fd5b806347cacd2a146104195780634af3211c1461042f5780634d31ccdb146104455780634e25b08b146104655780635312ea8e1461048557600080fd5b806324a4afd51161022457806324a4afd51461034a57806327190e6a14610360578063313da78f14610380578063334d7e53146103ad5780633fc8cef3146103cd57600080fd5b80630962ef791461029f5780631385ae5b146102c15780631578e193146102ea5780631748e84c146103005780631c4ccd131461032a57600080fd5b3661029a576040513481527f353bcaaf167a6add95a753d39727e3d3beb865129a69a10ed774b0b8996714039060200160405180910390a1005b600080fd5b3480156102ab57600080fd5b506102bf6102ba366004612e08565b6108b0565b005b3480156102cd57600080fd5b506102d760035481565b6040519081526020015b60405180910390f35b3480156102f657600080fd5b506102d760085481565b34801561030c57600080fd5b5060095461031a9060ff1681565b60405190151581526020016102e1565b34801561033657600080fd5b506102bf610345366004612dce565b6109d2565b34801561035657600080fd5b506102d7600a5481565b34801561036c57600080fd5b506102d761037b366004612e08565b610a2e565b34801561038c57600080fd5b506103a061039b366004612c4d565b610c17565b6040516102e19190613008565b3480156103b957600080fd5b506102bf6103c8366004612e08565b610d01565b3480156103d957600080fd5b506104017f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc281565b6040516001600160a01b0390911681526020016102e1565b34801561042557600080fd5b506102d7600c5481565b34801561043b57600080fd5b506102d760065481565b34801561045157600080fd5b506102d7610460366004612e08565b610d3e565b34801561047157600080fd5b506102bf610480366004612e08565b610e2a565b34801561049157600080fd5b506102bf6104a0366004612e08565b610e7d565b3480156104b157600080fd5b506102d76104c0366004612e08565b611023565b3480156104d157600080fd5b506102d760045481565b3480156104e757600080fd5b506102bf6104f6366004612e21565b61108d565b34801561050757600080fd5b5060095461031a90610100900460ff1681565b34801561052657600080fd5b506102bf610535366004612c76565b61133b565b34801561054657600080fd5b506102bf611427565b34801561055b57600080fd5b506104017f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d81565b34801561058f57600080fd5b506102bf61059e366004612e21565b61143b565b3480156105af57600080fd5b506102d760075481565b3480156105c557600080fd5b506102d760025481565b3480156105db57600080fd5b506105ef6105ea366004612c4d565b611693565b6040516102e19190612f1e565b34801561060857600080fd5b506102bf610617366004612e08565b61175e565b34801561062857600080fd5b5061063161185c565b6040516102e19190612fc6565b34801561064a57600080fd5b506000546001600160a01b0316610401565b34801561066857600080fd5b506102bf610677366004612c4d565b61194f565b34801561068857600080fd5b506102d760055481565b34801561069e57600080fd5b5060125461031a9060ff1681565b3480156106b857600080fd5b506102bf6106c7366004612e21565b6119a5565b3480156106d857600080fd5b506106e1611d08565b6040516102e19190612f6d565b3480156106fa57600080fd5b506102d7610709366004612c4d565b611e30565b34801561071a57600080fd5b506102bf610729366004612dce565b611e9f565b34801561073a57600080fd5b506102d7610749366004612e08565b611ee8565b34801561075a57600080fd5b5061076e610769366004612e08565b611f06565b6040516102e1919061313e565b34801561078757600080fd5b506107dd610796366004612e08565b600e6020526000908152604090208054600182015460028301546003840154600485015460058601546006909601546001600160a01b039095169593949293919290919087565b604080516001600160a01b0390981688526020880196909652948601939093526060850191909152608084015260a083015260c082015260e0016102e1565b34801561082857600080fd5b506104017f00000000000000000000000040e9187078032afe1a30cfcf76e4fe3d7ab5c6c581565b34801561085c57600080fd5b506102bf61086b366004612c4d565b61206a565b34801561087c57600080fd5b50600b54610401906001600160a01b031681565b34801561089c57600080fd5b506102bf6108ab366004612dce565b6120e0565b6108b8612129565b336000908152600d602090815260408083208484526001019091529020546108fb5760405162461bcd60e51b81526004016108f290613073565b60405180910390fd5b610903612183565b600061090f338361224f565b6000838152600e602052604090206004015490915042101561094d5760125460ff1661094d5760405162461bcd60e51b81526004016108f2906130c3565b6000828152600e60205260409020600301546109699042613219565b6000838152600e60205260409081902060040182905551839133917f567af1ae5124187b5426da6d961677abe4a9f921bf06107c2a56364fbdbc2cec916109b39190815260200190565b60405180910390a36109c5338261233c565b506109cf60018055565b50565b6109da612424565b600980548215156101000261ff00199091161790556040517f39c6622545aee57f6da3d44c470d1642afca7ca6a93b5f1f2f045d496fb2f15c90610a2390831515815260200190565b60405180910390a150565b604080516002808252606082018352600092839291906020830190803683370190505090507f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc281600081518110610a8757610a876132fc565b60200260200101906001600160a01b031690816001600160a01b0316815250507f00000000000000000000000040e9187078032afe1a30cfcf76e4fe3d7ab5c6c581600181518110610adb57610adb6132fc565b6001600160a01b03928316602091820292909201015260405163d06ca61f60e01b815264e8d4a51000916000917f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d9091169063d06ca61f90610b43908590879060040161314d565b60006040518083038186803b158015610b5b57600080fd5b505afa158015610b6f573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610b979190810190612d36565b9050600081600181518110610bae57610bae6132fc565b6020026020010151905060035460001415610bd0575060001995945050505050565b600354838260065489610be39190613253565b610bef9061016d613253565b610bf99190613253565b610c039190613231565b610c0d9190613231565b9695505050505050565b6001600160a01b0381166000908152600d6020526040812060609190610c3c9061247e565b67ffffffffffffffff811115610c5457610c54613312565b604051908082528060200260200182016040528015610c7d578160200160208202803683370190505b50905060005b6001600160a01b0384166000908152600d60205260409020610ca49061247e565b811015610cfa576001600160a01b0384166000908152600d60205260409020610ccd9082612488565b828281518110610cdf57610cdf6132fc565b6020908102919091010152610cf3816132b5565b9050610c83565b5092915050565b610d09612424565b600c8190556040518181527f697f37d5c125ace1cbc4127272485e94a60b4bb5ad10be994b441e2c312b7e6890602001610a23565b6000818152600e60205260408120600354610d945760405162461bcd60e51b8152602060048201526016602482015275496e76616c696420636f6e747261637420737461746560501b60448201526064016108f2565b60006003546201518060085442610dab9190613272565b600654610dc090670de0b6b3a7640000613253565b610dca9190613253565b610dd49190613231565b610dde9190613231565b600754610deb9190613219565b90506000670de0b6b3a7640000836005015483610e089190613272565b8460020154610e179190613253565b610e219190613231565b95945050505050565b610e32612424565b610e4d610e476000546001600160a01b031690565b8261233c565b6040518181527f493f5fc7cacabcb6ba5f9ae8168f4bdd534259a32379d22db77206898d9b9f5e90602001610a23565b610e85612129565b6000818152600e6020526040902060095460ff1680610ea75750428160040154105b610ec35760405162461bcd60e51b81526004016108f2906130c3565b336000908152600d60209081526040808320858452600101909152902054610efd5760405162461bcd60e51b81526004016108f290613073565b610f05612183565b600181015460028054829190600090610f1f908490613272565b9091555050600282015460038054600090610f3b908490613272565b909155505060006001830181905560028301819055338152600d60205260409020610f669084612494565b50610f9b6001600160a01b037f00000000000000000000000040e9187078032afe1a30cfcf76e4fe3d7ab5c6c51633836124a0565b604051818152839033907fb47853100b79d8afa66237bdb4f7f09d96628ee23aa8aac8a8c21a901c67ddb29060200160405180910390a37f710f527818bfa032ab1185a29deb411f70cc3ecb9eb24bdc93d93a0df5e86a63600254600354604051611010929190918252602082015260400190565b60405180910390a150506109cf60018055565b6000611030600f83612508565b61107c5760405162461bcd60e51b815260206004820152601d60248201527f5374616b696e6720706572696f6420646f6573206e6f7420657869737400000060448201526064016108f2565b611087600f83612514565b92915050565b611095612129565b600954610100900460ff16156110bd5760405162461bcd60e51b81526004016108f2906130fa565b336000908152600d602090815260408083208584526001019091529020546110f75760405162461bcd60e51b81526004016108f290613073565b6110ff612183565b6000828152600e602052604081206005810154600754919291670de0b6b3a76400009161112b91613272565b836002015461113a9190613253565b6111449190613231565b90506000811161118e5760405162461bcd60e51b81526020600482015260156024820152744e6f207265776172647320746f2072657374616b6560581b60448201526064016108f2565b600754826005018190555080600460008282546111ab9190613219565b92505081905550808260060160008282546111c69190613219565b90915550600090506111d88285612520565b9050808360010160008282546111ee9190613219565b909155505060028301546003805460009061120a908490613272565b925050819055506127106112218460030154611023565b84600101546112309190613253565b61123a9190613231565b6002840181905560038054600090611253908490613219565b92505081905550806002600082825461126c9190613219565b909155505060038301546112809042613219565b600484018190556001840154600285015460408051858152602081018790529081019290925260608201526080810191909152859033907f5139bc88ac9aa018a361de04bab7e7bfd0c127df2e4be783c222f0a1b48bb4f19060a0015b60405180910390a37f710f527818bfa032ab1185a29deb411f70cc3ecb9eb24bdc93d93a0df5e86a63600254600354604051611323929190918252602082015260400190565b60405180910390a150505061133760018055565b5050565b611343612424565b60005b8151811015611337576000828281518110611363576113636132fc565b602002602001015190506000816020015111156113d1578051602082015161138d91600f916126af565b50805160208083015160408051938452918301527f79cec334fdf120033998ffa4c9913fd617d37070d76dd98619a42b7c1e5bfadc910160405180910390a1611416565b80516113df90600f906126c4565b5080516040519081527f40e6c80f041ab36089264c7d6fa3c7f8c8e9182b828fb0979b6bb278e326f4bd9060200160405180910390a15b50611420816132b5565b9050611346565b61142f612424565b61143960006126d0565b565b611443612129565b600954610100900460ff161561146b5760405162461bcd60e51b81526004016108f2906130fa565b670de0b6b3a76400008210156114d55760405162461bcd60e51b815260206004820152602960248201527f414958526576656e756553686172696e673a2043616e6e6f74207374616b65206044820152681d1bdbc81cdb585b1b60ba1b60648201526084016108f2565b6000600a600081546114e6906132b5565b9182905550905060006114f883611023565b9050611502612183565b83600260008282546115149190613219565b90915550600090506127106115298387613253565b6115339190613231565b905080600360008282546115479190613219565b90915550506040805160e08101825233815260208101879052908101829052606081018590526080810161157b8642613219565b815260075460208083019190915260006040928301819052868152600e8252828120845181546001600160a01b0319166001600160a01b03909116178155848301516001820155848401516002820155606085015160038201556080850151600482015560a0850151600582015560c090940151600690940193909355338352600d9052902061160b9084612720565b506116416001600160a01b037f00000000000000000000000040e9187078032afe1a30cfcf76e4fe3d7ab5c6c51633308861272c565b82337f6381ea17a5324d29cc015352644672ead5185c1c61a0d3a521eda97e35cec97e87846116708942613219565b6007546040805194855260208501939093529183015260608201526080016112dd565b606060006116a083610c17565b90506000815167ffffffffffffffff8111156116be576116be613312565b6040519080825280602002602001820160405280156116f757816020015b6116e4612bea565b8152602001906001900390816116dc5790505b50905060005b82518110156117565761172883828151811061171b5761171b6132fc565b6020026020010151611f06565b82828151811061173a5761173a6132fc565b60200260200101819052508061174f906132b5565b90506116fd565b509392505050565b600b546001600160a01b031633148061178157506000546001600160a01b031633145b6117cd5760405162461bcd60e51b815260206004820181905260248201527f414958526576656e756553686172696e673a204163636573732064656e69656460448201526064016108f2565b600c5481111561181f5760405162461bcd60e51b815260206004820152601b60248201527f414958526576656e756553686172696e673a20746f6f2068696768000000000060448201526064016108f2565b611827612183565b60068190556040518181527f80c29ffccc25678a74926dde5be98c46623591d4175330efa89197e64798e7c390602001610a23565b6060600061186a600f61276a565b67ffffffffffffffff81111561188257611882613312565b6040519080825280602002602001820160405280156118c757816020015b60408051808201909152600080825260208201528152602001906001900390816118a05790505b50905060005b6118d7600f61276a565b811015611949576000806118ec600f84612775565b9150915081848481518110611903576119036132fc565b6020026020010151600001818152505080848481518110611926576119266132fc565b60200260200101516020018181525050505080611942906132b5565b90506118cd565b50919050565b611957612424565b600b80546001600160a01b0319166001600160a01b0383169081179091556040519081527f79f74fd5964b6943d8a1865abfb7f668c92fa3f32c0a2e3195da7d0946703ad790602001610a23565b6119ad612129565b60008111611a095760405162461bcd60e51b8152602060048201526024808201527f414958526576656e756553686172696e673a2043616e6e6f74207769746864726044820152630617720360e41b60648201526084016108f2565b6000828152600e602052604090206001810154821115611a865760405162461bcd60e51b815260206004820152603260248201527f414958526576656e756553686172696e673a20576974686472617720616d6f756044820152716e7420657863656564732062616c616e636560701b60648201526084016108f2565b336000908152600d60209081526040808320868452600101909152902054611ac05760405162461bcd60e51b81526004016108f290613073565b611ac8612183565b60004282600401541015611ae757611ae0338561224f565b9050611b3f565b60095460ff16611b095760405162461bcd60e51b81526004016108f2906130c3565b604051849033907f7f0c0a5ae64764439bfe2d11b5b9c2eefa1318071154ce368bdd0267f9398a1d90600090a360075460058301555b8260026000828254611b519190613272565b9250508190555082826001016000828254611b6c9190613272565b9091555050600282015460038054600090611b88908490613272565b90915550506001820154611bbc57336000908152600d60205260409020611baf9085612494565b5060006002830155611c18565b612710611bcc8360030154611023565b8360010154611bdb9190613253565b611be59190613231565b6002830181905560038054600090611bfe908490613219565b90915550506003820154611c129042613219565b60048301555b611c4c6001600160a01b037f00000000000000000000000040e9187078032afe1a30cfcf76e4fe3d7ab5c6c51633856124a0565b611c56338261233c565b600182015460028301546004840154604080518781526020810185905290810192909252606082015290156080820152849033907f111b200afbd38e85f739e7392193530fbad770e481920fc49701f5ca108f8c659060a00160405180910390a37f710f527818bfa032ab1185a29deb411f70cc3ecb9eb24bdc93d93a0df5e86a63600254600354604051611cf5929190918252602082015260400190565b60405180910390a1505061133760018055565b60606000611d16600f61276a565b67ffffffffffffffff811115611d2e57611d2e613312565b604051908082528060200260200182016040528015611d8357816020015b611d7060405180606001604052806000815260200160008152602001600081525090565b815260200190600190039081611d4c5790505b50905060005b611d93600f61276a565b81101561194957600080611da8600f84612775565b9150915081848481518110611dbf57611dbf6132fc565b6020026020010151600001818152505080848481518110611de257611de26132fc565b60200260200101516020018181525050611dfb81610a2e565b848481518110611e0d57611e0d6132fc565b60200260200101516040018181525050505080611e29906132b5565b9050611d89565b600080805b6001600160a01b0384166000908152600d60205260409020611e569061247e565b811015610cfa576001600160a01b0384166000908152600d60205260409020611e83906104609083612488565b611e8d9083613219565b9150611e98816132b5565b9050611e35565b611ea7612424565b6012805460ff19168215159081179091556040519081527fac01945f43eb167b56e310bc1fc6e5b311013329ec4e1d966a3ce77b1ae4a5d190602001610a23565b600080611ef483611023565b9050611eff81610a2e565b9392505050565b611f0e612bea565b6000828152600e6020908152604091829020825160e08101845281546001600160a01b03168082526001830154938201939093526002820154938101939093526003810154606084015260048101546080840152600581015460a08401526006015460c0830152611fb85760405162461bcd60e51b815260206004820152601460248201527314dd185ad948191bd95cc81b9bdd08195e1a5cdd60621b60448201526064016108f2565b60405180610160016040528082600001516001600160a01b03168152602001848152602001826020015181526020018260400151815260200182606001518152602001826080015181526020018260a0015181526020018260c00151815260200161202961037b8460600151611023565b815260200161203785610d3e565b81526020016003548360400151670de0b6b3a76400006120579190613253565b6120619190613231565b90529392505050565b612072612424565b6001600160a01b0381166120d75760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016108f2565b6109cf816126d0565b6120e8612424565b6009805460ff19168215159081179091556040519081527fa9a253aa4e8bda7c44e27a7e80525798ab443de4d1ed21d2c0bf5ef21c7a6eb190602001610a23565b6002600154141561217c5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016108f2565b6002600155565b60035415612206576000620151806008544261219f9190613272565b6006546121ac9190613253565b6121b69190613231565b905080600560008282546121ca9190613219565b90915550506003546121e482670de0b6b3a7640000613253565b6121ee9190613231565b600760008282546121ff9190613219565b9091555050505b4260088190556007546040517f07c8c1e0b9fdc68defdff8357d6bfb6a46eab344c2e6007a7786958b513b8d9292612245928252602082015260400190565b60405180910390a1565b6000818152600e6020526040812060058101546007548391670de0b6b3a76400009161227b9190613272565b836002015461228a9190613253565b6122949190613231565b90506007548260050181905550808260060160008282546122b59190613219565b9250508190555080600460008282546122ce9190613219565b909155505060058201546006830154600454604080518581526020810194909452830191909152606082015284906001600160a01b038716907f6a1c9812f6d42eaf5c00058b4fc1d00233e24805a4965009d650401f50adc53e9060800160405180910390a3949350505050565b80156123dd576000826001600160a01b03168260405160006040518083038185875af1925050503d806000811461238f576040519150601f19603f3d011682016040523d82523d6000602084013e612394565b606091505b50509050806123db5760405162461bcd60e51b8152602060048201526013602482015272115512081d1c985b9cd9995c8819985a5b1959606a1b60448201526064016108f2565b505b816001600160a01b03167ffd69c215b8b91dab5e96ff0bcbaf5dc372919948eea2003ae16481c036f816f88260405161241891815260200190565b60405180910390a25050565b6000546001600160a01b031633146114395760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016108f2565b6000611087825490565b6000611eff8383612791565b6000611eff83836127bb565b6040516001600160a01b03831660248201526044810182905261250390849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b0319909316929092179091526128ae565b505050565b6000611eff8383612983565b6000611eff838361299b565b604080516002808252606082018352600092839291906020830190803683370190505090507f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc281600081518110612579576125796132fc565b60200260200101906001600160a01b031690816001600160a01b0316815250507f00000000000000000000000040e9187078032afe1a30cfcf76e4fe3d7ab5c6c5816001815181106125cd576125cd6132fc565b6001600160a01b039283166020918202929092010152604051637ff36ab560e01b81526000917f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d1690637ff36ab5908790612632908890879030904290600401613166565b6000604051808303818588803b15801561264b57600080fd5b505af115801561265f573d6000803e3d6000fd5b50505050506040513d6000823e601f3d908101601f191682016040526126889190810190612d36565b90508060018151811061269d5761269d6132fc565b60200260200101519250505092915050565b60006126bc848484612a0b565b949350505050565b6000611eff8383612a28565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6000611eff8383612a45565b6040516001600160a01b03808516602483015283166044820152606481018290526127649085906323b872dd60e01b906084016124cc565b50505050565b600061108782612a94565b60008080806127848686612a9f565b9097909650945050505050565b60008260000182815481106127a8576127a86132fc565b9060005260206000200154905092915050565b600081815260018301602052604081205480156128a45760006127df600183613272565b85549091506000906127f390600190613272565b9050818114612858576000866000018281548110612813576128136132fc565b9060005260206000200154905080876000018481548110612836576128366132fc565b6000918252602080832090910192909255918252600188019052604090208390555b8554869080612869576128696132e6565b600190038181906000526020600020016000905590558560010160008681526020019081526020016000206000905560019350505050611087565b6000915050611087565b6000612903826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316612aca9092919063ffffffff16565b90508051600014806129245750808060200190518101906129249190612deb565b6125035760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b60648201526084016108f2565b60008181526001830160205260408120541515611eff565b6000818152600283016020526040812054801515806129bf57506129bf8484612983565b611eff5760405162461bcd60e51b815260206004820152601e60248201527f456e756d657261626c654d61703a206e6f6e6578697374656e74206b6579000060448201526064016108f2565b600082815260028401602052604081208290556126bc8484612720565b60008181526002830160205260408120819055611eff8383612494565b6000818152600183016020526040812054612a8c57508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155611087565b506000611087565b60006110878261247e565b60008080612aad8585612488565b600081815260029690960160205260409095205494959350505050565b60606126bc848460008585600080866001600160a01b03168587604051612af19190612f02565b60006040518083038185875af1925050503d8060008114612b2e576040519150601f19603f3d011682016040523d82523d6000602084013e612b33565b606091505b5091509150612b4487838387612b4f565b979650505050505050565b60608315612bbb578251612bb4576001600160a01b0385163b612bb45760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016108f2565b50816126bc565b6126bc8383815115612bd05781518083602001fd5b8060405162461bcd60e51b81526004016108f29190613040565b60405180610160016040528060006001600160a01b03168152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081525090565b600060208284031215612c5f57600080fd5b81356001600160a01b0381168114611eff57600080fd5b60006020808385031215612c8957600080fd5b823567ffffffffffffffff811115612ca057600080fd5b8301601f81018513612cb157600080fd5b8035612cc4612cbf826131f5565b6131c4565b80828252848201915084840188868560061b8701011115612ce457600080fd5b60009450845b84811015612d2857604080838c031215612d02578687fd5b612d0a61319b565b83358152888401358982015285529387019390910190600101612cea565b509098975050505050505050565b60006020808385031215612d4957600080fd5b825167ffffffffffffffff811115612d6057600080fd5b8301601f81018513612d7157600080fd5b8051612d7f612cbf826131f5565b80828252848201915084840188868560051b8701011115612d9f57600080fd5b600094505b83851015612dc2578051835260019490940193918501918501612da4565b50979650505050505050565b600060208284031215612de057600080fd5b8135611eff81613328565b600060208284031215612dfd57600080fd5b8151611eff81613328565b600060208284031215612e1a57600080fd5b5035919050565b60008060408385031215612e3457600080fd5b50508035926020909101359150565b600081518084526020808501945080840160005b83811015612e7c5781516001600160a01b031687529582019590820190600101612e57565b509495945050505050565b80516001600160a01b031682526020810151602083015260408101516040830152606081015160608301526080810151608083015260a081015160a083015260c081015160c083015260e081015160e08301526101008082015181840152506101208082015181840152506101408082015181840152505050565b60008251612f14818460208701613289565b9190910192915050565b6020808252825182820181905260009190848201906040850190845b81811015612f6157612f4d838551612e87565b928401926101609290920191600101612f3a565b50909695505050505050565b602080825282518282018190526000919060409081850190868401855b82811015612fb95781518051855286810151878601528501518585015260609093019290850190600101612f8a565b5091979650505050505050565b602080825282518282018190526000919060409081850190868401855b82811015612fb957815180518552860151868501529284019290850190600101612fe3565b6020808252825182820181905260009190848201906040850190845b81811015612f6157835183529284019291840191600101613024565b602081526000825180602084015261305f816040850160208701613289565b601f01601f19169190910160400192915050565b60208082526030908201527f414958526576656e756553686172696e673a205374616b6520646f6573206e6f60408201526f3a103132b637b733903a37903ab9b2b960811b606082015260800190565b6020808252601c908201527f414958526576656e756553686172696e673a20746f6f206561726c7900000000604082015260600190565b60208082526024908201527f414958526576656e756553686172696e673a205374616b696e672069732070616040820152631d5cd95960e21b606082015260800190565b61016081016110878284612e87565b8281526040602082015260006126bc6040830184612e43565b84815260806020820152600061317f6080830186612e43565b6001600160a01b03949094166040830152506060015292915050565b6040805190810167ffffffffffffffff811182821017156131be576131be613312565b60405290565b604051601f8201601f1916810167ffffffffffffffff811182821017156131ed576131ed613312565b604052919050565b600067ffffffffffffffff82111561320f5761320f613312565b5060051b60200190565b6000821982111561322c5761322c6132d0565b500190565b60008261324e57634e487b7160e01b600052601260045260246000fd5b500490565b600081600019048311821515161561326d5761326d6132d0565b500290565b600082821015613284576132846132d0565b500390565b60005b838110156132a457818101518382015260200161328c565b838111156127645750506000910152565b60006000198214156132c9576132c96132d0565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052603160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b80151581146109cf57600080fdfea264697066735822122018c2c81294beb9ff8212a515381f3051c5780e7bfedb7dcabaece1c0008c8f6064736f6c63430008060033

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

00000000000000000000000040e9187078032afe1a30cfcf76e4fe3d7ab5c6c50000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000001bc16d674ec80000

-----Decoded View---------------
Arg [0] : _aix (address): 0x40e9187078032AfE1a30cfcF76E4fe3D7aB5c6C5
Arg [1] : _uniswapRouter (address): 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D
Arg [2] : _weth (address): 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2
Arg [3] : _maxETHPerDay (uint256): 2000000000000000000

-----Encoded View---------------
4 Constructor Arguments found :
Arg [0] : 00000000000000000000000040e9187078032afe1a30cfcf76e4fe3d7ab5c6c5
Arg [1] : 0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d
Arg [2] : 000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2
Arg [3] : 0000000000000000000000000000000000000000000000001bc16d674ec80000


Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

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

Validator Index Block Amount
View All Withdrawals

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

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