ETH Price: $3,362.37 (-3.57%)

Contract

0xfaeDBb799E52c0a978f7c000A380b0495eDd75BD
 

Overview

ETH Balance

0 ETH

Eth Value

$0.00

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To

There are no matching entries

Please try again later

View more zero value Internal Transactions in Advanced View mode

Advanced mode:
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
StakedBUNI

Compiler Version
v0.8.4+commit.c7e474f2

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion
File 1 of 20 : StakedBUNI.sol
// SPDX-License-Identifier: agpl-3.0
pragma solidity 0.8.4;
pragma abicoder v2;

import {ERC20Detailed} from "../libs/ERC20Detailed.sol";
import {IERC20Upgradeable} from "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol";

import {DistributionTypes} from "./DistributionTypes.sol";
import {SafeMath} from "@openzeppelin/contracts/utils/math/SafeMath.sol";
import {SafeERC20Upgradeable} from "@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol";

import {DistributionManager} from "./DistributionManager.sol";
import {IStaked} from "./interfaces/IStaked.sol";
import {ReentrancyGuardUpgradeable} from "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol";

contract StakedBUNI is
    IStaked,
    ReentrancyGuardUpgradeable,
    ERC20Detailed,
    DistributionManager
{
    using SafeMath for uint256;
    using SafeERC20Upgradeable for IERC20Upgradeable;

    address public stakedToken;
    address public rewardToken;

    address public rewardVault;

    mapping(address => uint256) public stakerRewardsToClaim;

    /**
     * @dev Called by the proxy contract
     **/
    function initialize(
        address _stakedToken,
        address _rewardToken,
        address _rewardVault,
        uint128 distributionDuration
    ) external initializer {
        __ERC20Detailed_init("Staked BEND/ETH UNI", "stkBUNI", 18);
        __DistributionManager_init(distributionDuration);
        __ReentrancyGuard_init();
        stakedToken = _stakedToken;
        rewardToken = _rewardToken;
        rewardVault = _rewardVault;
    }

    /**
     * @dev Configures the distribution of rewards for a list of assets
     * @param emissionPerSecond Representing the total rewards distributed per second per asset unit
     **/

    function configure(uint128 emissionPerSecond) external override onlyOwner {
        DistributionTypes.AssetConfigInput[]
            memory assetsConfigInput = new DistributionTypes.AssetConfigInput[](
                1
            );
        assetsConfigInput[0].emissionPerSecond = emissionPerSecond;
        assetsConfigInput[0].totalStaked = totalSupply();
        assetsConfigInput[0].underlyingAsset = address(this);
        _configureAssets(assetsConfigInput);
    }

    function stake(uint256 amount) external override nonReentrant {
        require(amount != 0, "INVALID_ZERO_AMOUNT");
        uint256 balanceOfUser = balanceOf(msg.sender);

        uint256 accruedRewards = _updateUserAssetInternal(
            msg.sender,
            address(this),
            balanceOfUser,
            totalSupply()
        );
        if (accruedRewards != 0) {
            emit RewardsAccrued(msg.sender, accruedRewards);
            stakerRewardsToClaim[msg.sender] = stakerRewardsToClaim[msg.sender]
                .add(accruedRewards);
        }

        IERC20Upgradeable(stakedToken).safeTransferFrom(
            msg.sender,
            address(this),
            amount
        );

        _mint(msg.sender, amount);

        emit Staked(msg.sender, amount);
    }

    /**
     * @dev Redeems staked tokens, and stop earning rewards
     * @param amount Amount to redeem
     **/
    function redeem(uint256 amount) external override nonReentrant {
        require(amount != 0, "INVALID_ZERO_AMOUNT");

        uint256 balanceOfMessageSender = balanceOf(msg.sender);

        uint256 amountToRedeem = (amount > balanceOfMessageSender)
            ? balanceOfMessageSender
            : amount;

        _updateCurrentUnclaimedRewards(
            msg.sender,
            balanceOfMessageSender,
            true
        );

        _burn(msg.sender, amountToRedeem);

        IERC20Upgradeable(stakedToken).safeTransfer(msg.sender, amountToRedeem);

        emit Redeem(msg.sender, amountToRedeem);
    }

    /**
     * @dev Claims an `amount` of `REWARD_TOKEN` to the address `to`
     * @param amount Amount to stake
     **/
    function claim(uint256 amount) external override nonReentrant {
        require(amount != 0, "INVALID_ZERO_AMOUNT");
        uint256 newTotalRewards = _updateCurrentUnclaimedRewards(
            msg.sender,
            balanceOf(msg.sender),
            false
        );
        uint256 amountToClaim = (amount == type(uint256).max)
            ? newTotalRewards
            : amount;
        stakerRewardsToClaim[msg.sender] = newTotalRewards.sub(
            amountToClaim,
            "INVALID_AMOUNT"
        );

        IERC20Upgradeable(rewardToken).safeTransferFrom(
            rewardVault,
            msg.sender,
            amountToClaim
        );

        emit RewardsClaimed(msg.sender, amountToClaim);
    }

    /**
     * @dev Internal ERC20 _transfer of the tokenized staked tokens
     * @param from Address to transfer from
     * @param to Address to transfer to
     * @param amount Amount to transfer
     **/
    function _transfer(
        address from,
        address to,
        uint256 amount
    ) internal override {
        uint256 balanceOfFrom = balanceOf(from);
        // Sender
        _updateCurrentUnclaimedRewards(from, balanceOfFrom, true);

        // Recipient
        if (from != to) {
            uint256 balanceOfTo = balanceOf(to);
            _updateCurrentUnclaimedRewards(to, balanceOfTo, true);
        }

        super._transfer(from, to, amount);
    }

    /**
     * @dev Updates the user state related with his accrued rewards
     * @param user Address of the user
     * @param userBalance The current balance of the user
     * @param updateStorage Boolean flag used to update or not the stakerRewardsToClaim of the user
     * @return The unclaimed rewards that were added to the total accrued
     **/
    function _updateCurrentUnclaimedRewards(
        address user,
        uint256 userBalance,
        bool updateStorage
    ) internal returns (uint256) {
        uint256 accruedRewards = _updateUserAssetInternal(
            user,
            address(this),
            userBalance,
            totalSupply()
        );
        uint256 unclaimedRewards = stakerRewardsToClaim[user].add(
            accruedRewards
        );

        if (accruedRewards != 0) {
            if (updateStorage) {
                stakerRewardsToClaim[user] = unclaimedRewards;
            }
            emit RewardsAccrued(user, accruedRewards);
        }

        return unclaimedRewards;
    }

    /**
     * @dev Return the total rewards pending to claim by an staker
     * @param staker The staker address
     * @return The rewards
     */
    function claimableRewards(address staker)
        external
        view
        override
        returns (uint256)
    {
        DistributionTypes.UserStakeInput[]
            memory userStakeInputs = new DistributionTypes.UserStakeInput[](1);
        userStakeInputs[0] = DistributionTypes.UserStakeInput({
            underlyingAsset: address(this),
            stakedByUser: balanceOf(staker),
            totalStaked: totalSupply()
        });
        return
            stakerRewardsToClaim[staker].add(
                _getUnclaimedRewards(staker, userStakeInputs)
            );
    }

    function apr() external view returns (uint256) {
        if (totalSupply() == 0) {
            return 0;
        }
        uint256 _bendAmount = IERC20Upgradeable(rewardToken).balanceOf(
            stakedToken
        );
        uint256 _stakedVaueInBend = ((2 * _bendAmount) * totalSupply()) /
            IERC20Upgradeable(stakedToken).totalSupply();
        uint256 _oneYearBendEmission = assets[address(this)].emissionPerSecond *
            31536000;
        return (_oneYearBendEmission * 10**PRECISION) / _stakedVaueInBend;
    }
}

File 2 of 20 : ERC20Detailed.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.4;
import {ERC20PermitUpgradeable} from "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/draft-ERC20PermitUpgradeable.sol";

contract ERC20Detailed is ERC20PermitUpgradeable {
    uint8 private __decimals;

    function __ERC20Detailed_init(
        string memory _name,
        string memory _symbol,
        uint8 _decimals
    ) internal initializer {
        __ERC20_init(_name, _symbol);
        __ERC20Permit_init(_name);
        __decimals = _decimals;
    }

    /**
     * @return the decimals of the token
     **/

    function decimals() public view virtual override returns (uint8) {
        return __decimals;
    }
}

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

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
interface IERC20Upgradeable {
    /**
     * @dev Returns the amount of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

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

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

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

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

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

    /**
     * @dev Emitted when `value` tokens are moved from one account (`from`) to
     * another (`to`).
     *
     * Note that `value` may be zero.
     */
    event Transfer(address indexed from, address indexed to, uint256 value);

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

File 4 of 20 : DistributionTypes.sol
// SPDX-License-Identifier: agpl-3.0
pragma solidity 0.8.4;
pragma abicoder v2;

library DistributionTypes {
    struct AssetConfigInput {
        uint128 emissionPerSecond;
        uint256 totalStaked;
        address underlyingAsset;
    }

    struct UserStakeInput {
        address underlyingAsset;
        uint256 stakedByUser;
        uint256 totalStaked;
    }
}

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

pragma solidity ^0.8.0;

// CAUTION
// This version of SafeMath should only be used with Solidity 0.8 or later,
// because it relies on the compiler's built in overflow checks.

/**
 * @dev Wrappers over Solidity's arithmetic operations.
 *
 * NOTE: `SafeMath` is no longer needed starting with Solidity 0.8. The compiler
 * now has built in overflow checking.
 */
library SafeMath {
    /**
     * @dev Returns the addition of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            uint256 c = a + b;
            if (c < a) return (false, 0);
            return (true, c);
        }
    }

    /**
     * @dev Returns the substraction of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            if (b > a) return (false, 0);
            return (true, a - b);
        }
    }

    /**
     * @dev Returns the multiplication of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            // Gas optimization: this is cheaper than requiring 'a' not being zero, but the
            // benefit is lost if 'b' is also tested.
            // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
            if (a == 0) return (true, 0);
            uint256 c = a * b;
            if (c / a != b) return (false, 0);
            return (true, c);
        }
    }

    /**
     * @dev Returns the division of two unsigned integers, with a division by zero flag.
     *
     * _Available since v3.4._
     */
    function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            if (b == 0) return (false, 0);
            return (true, a / b);
        }
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
     *
     * _Available since v3.4._
     */
    function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            if (b == 0) return (false, 0);
            return (true, a % b);
        }
    }

    /**
     * @dev Returns the addition of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `+` operator.
     *
     * Requirements:
     *
     * - Addition cannot overflow.
     */
    function add(uint256 a, uint256 b) internal pure returns (uint256) {
        return a + b;
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting on
     * overflow (when the result is negative).
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(uint256 a, uint256 b) internal pure returns (uint256) {
        return a - b;
    }

    /**
     * @dev Returns the multiplication of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `*` operator.
     *
     * Requirements:
     *
     * - Multiplication cannot overflow.
     */
    function mul(uint256 a, uint256 b) internal pure returns (uint256) {
        return a * b;
    }

    /**
     * @dev Returns the integer division of two unsigned integers, reverting on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator.
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(uint256 a, uint256 b) internal pure returns (uint256) {
        return a / b;
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * reverting when dividing by zero.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function mod(uint256 a, uint256 b) internal pure returns (uint256) {
        return a % b;
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting with custom message on
     * overflow (when the result is negative).
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {trySub}.
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(
        uint256 a,
        uint256 b,
        string memory errorMessage
    ) internal pure returns (uint256) {
        unchecked {
            require(b <= a, errorMessage);
            return a - b;
        }
    }

    /**
     * @dev Returns the integer division of two unsigned integers, reverting with custom message on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator. Note: this function uses a
     * `revert` opcode (which leaves remaining gas untouched) while Solidity
     * uses an invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(
        uint256 a,
        uint256 b,
        string memory errorMessage
    ) internal pure returns (uint256) {
        unchecked {
            require(b > 0, errorMessage);
            return a / b;
        }
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * reverting with custom message when dividing by zero.
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {tryMod}.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function mod(
        uint256 a,
        uint256 b,
        string memory errorMessage
    ) internal pure returns (uint256) {
        unchecked {
            require(b > 0, errorMessage);
            return a % b;
        }
    }
}

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

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

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

File 7 of 20 : DistributionManager.sol
// SPDX-License-Identifier: agpl-3.0
pragma solidity 0.8.4;
pragma abicoder v2;

import {SafeMath} from "@openzeppelin/contracts/utils/math/SafeMath.sol";
import {DistributionTypes} from "./DistributionTypes.sol";
import {Initializable} from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import {OwnableUpgradeable} from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";

// import "hardhat/console.sol";

/**
 * @title DistributionManager
 * @notice Accounting contract to manage multiple staking distributions
 * @author Bend
 **/
contract DistributionManager is Initializable, OwnableUpgradeable {
    using SafeMath for uint256;

    struct AssetData {
        uint128 emissionPerSecond;
        uint128 lastUpdateTimestamp;
        uint256 index;
        mapping(address => uint256) users;
    }

    uint256 public DISTRIBUTION_END;

    uint8 public constant PRECISION = 18;

    mapping(address => AssetData) public assets;

    event AssetConfigUpdated(
        address indexed _asset,
        uint256 _emissionPerSecond
    );
    event AssetIndexUpdated(address indexed _asset, uint256 _index);
    event DistributionEndUpdated(uint256 newDistributionEnd);

    event UserIndexUpdated(
        address indexed user,
        address indexed asset,
        uint256 index
    );

    function __DistributionManager_init(uint256 _distributionDuration)
        internal
        initializer
    {
        __Ownable_init();
        DISTRIBUTION_END = block.timestamp.add(_distributionDuration);
    }

    function setDistributionEnd(uint256 _distributionEnd) external onlyOwner {
        DISTRIBUTION_END = _distributionEnd;
        emit DistributionEndUpdated(_distributionEnd);
    }

    function _configureAssets(
        DistributionTypes.AssetConfigInput[] memory _assetsConfigInput
    ) internal onlyOwner {
        for (uint256 i = 0; i < _assetsConfigInput.length; i++) {
            AssetData storage assetConfig = assets[
                _assetsConfigInput[i].underlyingAsset
            ];

            _updateAssetStateInternal(
                _assetsConfigInput[i].underlyingAsset,
                assetConfig,
                _assetsConfigInput[i].totalStaked
            );

            assetConfig.emissionPerSecond = _assetsConfigInput[i]
                .emissionPerSecond;

            emit AssetConfigUpdated(
                _assetsConfigInput[i].underlyingAsset,
                _assetsConfigInput[i].emissionPerSecond
            );
        }
    }

    /**
     * @dev Updates the state of one distribution, mainly rewards index and timestamp
     * @param _underlyingAsset The address used as key in the distribution, for example sBEND or the aTokens addresses on Bend
     * @param _assetConfig Storage pointer to the distribution's config
     * @param _totalStaked Current total of staked assets for this distribution
     * @return The new distribution index
     **/
    function _updateAssetStateInternal(
        address _underlyingAsset,
        AssetData storage _assetConfig,
        uint256 _totalStaked
    ) internal returns (uint256) {
        uint256 oldIndex = _assetConfig.index;
        uint128 lastUpdateTimestamp = _assetConfig.lastUpdateTimestamp;

        if (block.timestamp == lastUpdateTimestamp) {
            return oldIndex;
        }
        uint256 newIndex = _getAssetIndex(
            oldIndex,
            _assetConfig.emissionPerSecond,
            lastUpdateTimestamp,
            _totalStaked
        );

        if (newIndex != oldIndex) {
            _assetConfig.index = newIndex;
            emit AssetIndexUpdated(_underlyingAsset, newIndex);
        }

        _assetConfig.lastUpdateTimestamp = uint128(block.timestamp);

        return newIndex;
    }

    /**
     * @dev Updates the state of an user in a distribution
     * @param _user The user's address
     * @param _asset The address of the reference asset of the distribution
     * @param _stakedByUser Amount of tokens staked by the user in the distribution at the moment
     * @param _totalStaked Total tokens staked in the distribution
     * @return The accrued rewards for the user until the moment
     **/
    function _updateUserAssetInternal(
        address _user,
        address _asset,
        uint256 _stakedByUser,
        uint256 _totalStaked
    ) internal returns (uint256) {
        AssetData storage assetData = assets[_asset];
        uint256 userIndex = assetData.users[_user];
        uint256 accruedRewards = 0;

        uint256 newIndex = _updateAssetStateInternal(
            _asset,
            assetData,
            _totalStaked
        );
        if (userIndex != newIndex) {
            if (_stakedByUser != 0) {
                accruedRewards = _getRewards(
                    _stakedByUser,
                    newIndex,
                    userIndex
                );
            }

            assetData.users[_user] = newIndex;
            emit UserIndexUpdated(_user, _asset, newIndex);
        }
        return accruedRewards;
    }

    /**
     * @dev Used by "frontend" stake contracts to update the data of an user when claiming rewards from there
     * @param _user The address of the user
     * @param _stakes List of structs of the user data related with his stake
     * @return The accrued rewards for the user until the moment
     **/
    function _claimRewards(
        address _user,
        DistributionTypes.UserStakeInput[] memory _stakes
    ) internal returns (uint256) {
        uint256 accruedRewards = 0;

        for (uint256 i = 0; i < _stakes.length; i++) {
            accruedRewards = accruedRewards.add(
                _updateUserAssetInternal(
                    _user,
                    _stakes[i].underlyingAsset,
                    _stakes[i].stakedByUser,
                    _stakes[i].totalStaked
                )
            );
        }

        return accruedRewards;
    }

    /**
     * @dev Return the accrued rewards for an user over a list of distribution
     * @param _user The address of the user
     * @param _stakes List of structs of the user data related with his stake
     * @return The accrued rewards for the user until the moment
     **/
    function _getUnclaimedRewards(
        address _user,
        DistributionTypes.UserStakeInput[] memory _stakes
    ) internal view returns (uint256) {
        uint256 accruedRewards = 0;

        for (uint256 i = 0; i < _stakes.length; i++) {
            AssetData storage assetConfig = assets[_stakes[i].underlyingAsset];
            uint256 assetIndex = _getAssetIndex(
                assetConfig.index,
                assetConfig.emissionPerSecond,
                assetConfig.lastUpdateTimestamp,
                _stakes[i].totalStaked
            );

            accruedRewards = accruedRewards.add(
                _getRewards(
                    _stakes[i].stakedByUser,
                    assetIndex,
                    assetConfig.users[_user]
                )
            );
        }
        return accruedRewards;
    }

    /**
     * @dev Internal function for the calculation of user's rewards on a distribution
     * @param _principalUserBalance Amount staked by the user on a distribution
     * @param _reserveIndex Current index of the distribution
     * @param _userIndex Index stored for the user, representation his staking moment
     * @return The rewards
     **/
    function _getRewards(
        uint256 _principalUserBalance,
        uint256 _reserveIndex,
        uint256 _userIndex
    ) internal pure returns (uint256) {
        return
            _principalUserBalance.mul(_reserveIndex.sub(_userIndex)).div(
                10**uint256(PRECISION)
            );
    }

    /**
     * @dev Calculates the next value of an specific distribution index, with validations
     * @param _currentIndex Current index of the distribution
     * @param _emissionPerSecond Representing the total rewards distributed per second per asset unit, on the distribution
     * @param _lastUpdateTimestamp Last moment this distribution was updated
     * @param _totalBalance of tokens considered for the distribution
     * @return The new index.
     **/
    function _getAssetIndex(
        uint256 _currentIndex,
        uint256 _emissionPerSecond,
        uint128 _lastUpdateTimestamp,
        uint256 _totalBalance
    ) internal view returns (uint256) {
        if (
            _emissionPerSecond == 0 ||
            _totalBalance == 0 ||
            _lastUpdateTimestamp == block.timestamp ||
            _lastUpdateTimestamp >= DISTRIBUTION_END
        ) {
            return _currentIndex;
        }

        uint256 currentTimestamp = block.timestamp > DISTRIBUTION_END
            ? DISTRIBUTION_END
            : block.timestamp;
        uint256 timeDelta = currentTimestamp.sub(_lastUpdateTimestamp);
        return
            _emissionPerSecond
                .mul(timeDelta)
                .mul(10**uint256(PRECISION))
                .div(_totalBalance)
                .add(_currentIndex);
    }

    /**
     * @dev Returns the data of an user on a distribution
     * @param _user Address of the user
     * @param _asset The address of the reference asset of the distribution
     * @return The new index
     **/
    function getUserAssetData(address _user, address _asset)
        public
        view
        returns (uint256)
    {
        return assets[_asset].users[_user];
    }
}

File 8 of 20 : IStaked.sol
// SPDX-License-Identifier: agpl-3.0
pragma solidity 0.8.4;

interface IStaked {
    event Staked(address indexed user, uint256 amount);

    event Redeem(address indexed user, uint256 amount);

    event RewardsAccrued(address user, uint256 amount);

    event RewardsClaimed(address indexed user, uint256 amount);

    function configure(uint128 emissionPerSecond) external;

    function stake(uint256 amount) external;

    function redeem(uint256 amount) external;

    function claim(uint256 amount) external;

    function claimableRewards(address staker) external view returns (uint256);
}

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

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

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

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

    uint256 private _status;

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

    function __ReentrancyGuard_init_unchained() internal initializer {
        _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 make it call a
     * `private` function that does the actual work.
     */
    modifier nonReentrant() {
        // On the first call to nonReentrant, _notEntered will be true
        require(_status != _ENTERED, "ReentrancyGuard: reentrant call");

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

        _;

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

File 10 of 20 : draft-ERC20PermitUpgradeable.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "./draft-IERC20PermitUpgradeable.sol";
import "../ERC20Upgradeable.sol";
import "../../../utils/cryptography/draft-EIP712Upgradeable.sol";
import "../../../utils/cryptography/ECDSAUpgradeable.sol";
import "../../../utils/CountersUpgradeable.sol";
import "../../../proxy/utils/Initializable.sol";

/**
 * @dev Implementation 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.
 *
 * _Available since v3.4._
 */
abstract contract ERC20PermitUpgradeable is Initializable, ERC20Upgradeable, IERC20PermitUpgradeable, EIP712Upgradeable {
    using CountersUpgradeable for CountersUpgradeable.Counter;

    mapping(address => CountersUpgradeable.Counter) private _nonces;

    // solhint-disable-next-line var-name-mixedcase
    bytes32 private _PERMIT_TYPEHASH;

    /**
     * @dev Initializes the {EIP712} domain separator using the `name` parameter, and setting `version` to `"1"`.
     *
     * It's a good idea to use the same `name` that is defined as the ERC20 token name.
     */
    function __ERC20Permit_init(string memory name) internal initializer {
        __Context_init_unchained();
        __EIP712_init_unchained(name, "1");
        __ERC20Permit_init_unchained(name);
    }

    function __ERC20Permit_init_unchained(string memory name) internal initializer {
        _PERMIT_TYPEHASH = keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)");}

    /**
     * @dev See {IERC20Permit-permit}.
     */
    function permit(
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) public virtual override {
        require(block.timestamp <= deadline, "ERC20Permit: expired deadline");

        bytes32 structHash = keccak256(abi.encode(_PERMIT_TYPEHASH, owner, spender, value, _useNonce(owner), deadline));

        bytes32 hash = _hashTypedDataV4(structHash);

        address signer = ECDSAUpgradeable.recover(hash, v, r, s);
        require(signer == owner, "ERC20Permit: invalid signature");

        _approve(owner, spender, value);
    }

    /**
     * @dev See {IERC20Permit-nonces}.
     */
    function nonces(address owner) public view virtual override returns (uint256) {
        return _nonces[owner].current();
    }

    /**
     * @dev See {IERC20Permit-DOMAIN_SEPARATOR}.
     */
    // solhint-disable-next-line func-name-mixedcase
    function DOMAIN_SEPARATOR() external view override returns (bytes32) {
        return _domainSeparatorV4();
    }

    /**
     * @dev "Consume a nonce": return the current value and increment.
     *
     * _Available since v4.1._
     */
    function _useNonce(address owner) internal virtual returns (uint256 current) {
        CountersUpgradeable.Counter storage nonce = _nonces[owner];
        current = nonce.current();
        nonce.increment();
    }
    uint256[49] private __gap;
}

File 11 of 20 : draft-IERC20PermitUpgradeable.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
 * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
 *
 * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
 * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't
 * need to send a transaction, and thus is not required to hold Ether at all.
 */
interface IERC20PermitUpgradeable {
    /**
     * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,
     * given ``owner``'s signed approval.
     *
     * IMPORTANT: The same issues {IERC20-approve} has related to transaction
     * ordering also apply here.
     *
     * Emits an {Approval} event.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     * - `deadline` must be a timestamp in the future.
     * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`
     * over the EIP712-formatted function arguments.
     * - the signature must use ``owner``'s current nonce (see {nonces}).
     *
     * For more information on the signature format, see the
     * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP
     * section].
     */
    function permit(
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) external;

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

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

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

pragma solidity ^0.8.0;

import "./IERC20Upgradeable.sol";
import "./extensions/IERC20MetadataUpgradeable.sol";
import "../../utils/ContextUpgradeable.sol";
import "../../proxy/utils/Initializable.sol";

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

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

    uint256 private _totalSupply;

    string private _name;
    string private _symbol;

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

    function __ERC20_init_unchained(string memory name_, string memory symbol_) internal initializer {
        _name = name_;
        _symbol = symbol_;
    }

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

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

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

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

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

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

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

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

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

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

        return true;
    }

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

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

        return true;
    }

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

        _beforeTokenTransfer(sender, recipient, amount);

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

        emit Transfer(sender, recipient, amount);

        _afterTokenTransfer(sender, recipient, amount);
    }

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

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

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

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

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

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

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

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

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

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

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

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

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

File 13 of 20 : draft-EIP712Upgradeable.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "./ECDSAUpgradeable.sol";
import "../../proxy/utils/Initializable.sol";

/**
 * @dev https://eips.ethereum.org/EIPS/eip-712[EIP 712] is a standard for hashing and signing of typed structured data.
 *
 * The encoding specified in the EIP is very generic, and such a generic implementation in Solidity is not feasible,
 * thus this contract does not implement the encoding itself. Protocols need to implement the type-specific encoding
 * they need in their contracts using a combination of `abi.encode` and `keccak256`.
 *
 * This contract implements the EIP 712 domain separator ({_domainSeparatorV4}) that is used as part of the encoding
 * scheme, and the final step of the encoding to obtain the message digest that is then signed via ECDSA
 * ({_hashTypedDataV4}).
 *
 * The implementation of the domain separator was designed to be as efficient as possible while still properly updating
 * the chain id to protect against replay attacks on an eventual fork of the chain.
 *
 * NOTE: This contract implements the version of the encoding known as "v4", as implemented by the JSON RPC method
 * https://docs.metamask.io/guide/signing-data.html[`eth_signTypedDataV4` in MetaMask].
 *
 * _Available since v3.4._
 */
abstract contract EIP712Upgradeable is Initializable {
    /* solhint-disable var-name-mixedcase */
    bytes32 private _HASHED_NAME;
    bytes32 private _HASHED_VERSION;
    bytes32 private constant _TYPE_HASH = keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)");

    /* solhint-enable var-name-mixedcase */

    /**
     * @dev Initializes the domain separator and parameter caches.
     *
     * The meaning of `name` and `version` is specified in
     * https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator[EIP 712]:
     *
     * - `name`: the user readable name of the signing domain, i.e. the name of the DApp or the protocol.
     * - `version`: the current major version of the signing domain.
     *
     * NOTE: These parameters cannot be changed except through a xref:learn::upgrading-smart-contracts.adoc[smart
     * contract upgrade].
     */
    function __EIP712_init(string memory name, string memory version) internal initializer {
        __EIP712_init_unchained(name, version);
    }

    function __EIP712_init_unchained(string memory name, string memory version) internal initializer {
        bytes32 hashedName = keccak256(bytes(name));
        bytes32 hashedVersion = keccak256(bytes(version));
        _HASHED_NAME = hashedName;
        _HASHED_VERSION = hashedVersion;
    }

    /**
     * @dev Returns the domain separator for the current chain.
     */
    function _domainSeparatorV4() internal view returns (bytes32) {
        return _buildDomainSeparator(_TYPE_HASH, _EIP712NameHash(), _EIP712VersionHash());
    }

    function _buildDomainSeparator(
        bytes32 typeHash,
        bytes32 nameHash,
        bytes32 versionHash
    ) private view returns (bytes32) {
        return keccak256(abi.encode(typeHash, nameHash, versionHash, block.chainid, address(this)));
    }

    /**
     * @dev Given an already https://eips.ethereum.org/EIPS/eip-712#definition-of-hashstruct[hashed struct], this
     * function returns the hash of the fully encoded EIP712 message for this domain.
     *
     * This hash can be used together with {ECDSA-recover} to obtain the signer of a message. For example:
     *
     * ```solidity
     * bytes32 digest = _hashTypedDataV4(keccak256(abi.encode(
     *     keccak256("Mail(address to,string contents)"),
     *     mailTo,
     *     keccak256(bytes(mailContents))
     * )));
     * address signer = ECDSA.recover(digest, signature);
     * ```
     */
    function _hashTypedDataV4(bytes32 structHash) internal view virtual returns (bytes32) {
        return ECDSAUpgradeable.toTypedDataHash(_domainSeparatorV4(), structHash);
    }

    /**
     * @dev The hash of the name parameter for the EIP712 domain.
     *
     * NOTE: This function reads from storage by default, but can be redefined to return a constant value if gas costs
     * are a concern.
     */
    function _EIP712NameHash() internal virtual view returns (bytes32) {
        return _HASHED_NAME;
    }

    /**
     * @dev The hash of the version parameter for the EIP712 domain.
     *
     * NOTE: This function reads from storage by default, but can be redefined to return a constant value if gas costs
     * are a concern.
     */
    function _EIP712VersionHash() internal virtual view returns (bytes32) {
        return _HASHED_VERSION;
    }
    uint256[50] private __gap;
}

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

pragma solidity ^0.8.0;

/**
 * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.
 *
 * These functions can be used to verify that a message was signed by the holder
 * of the private keys of a given address.
 */
library ECDSAUpgradeable {
    enum RecoverError {
        NoError,
        InvalidSignature,
        InvalidSignatureLength,
        InvalidSignatureS,
        InvalidSignatureV
    }

    function _throwError(RecoverError error) private pure {
        if (error == RecoverError.NoError) {
            return; // no error: do nothing
        } else if (error == RecoverError.InvalidSignature) {
            revert("ECDSA: invalid signature");
        } else if (error == RecoverError.InvalidSignatureLength) {
            revert("ECDSA: invalid signature length");
        } else if (error == RecoverError.InvalidSignatureS) {
            revert("ECDSA: invalid signature 's' value");
        } else if (error == RecoverError.InvalidSignatureV) {
            revert("ECDSA: invalid signature 'v' value");
        }
    }

    /**
     * @dev Returns the address that signed a hashed message (`hash`) with
     * `signature` or error string. This address can then be used for verification purposes.
     *
     * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:
     * this function rejects them by requiring the `s` value to be in the lower
     * half order, and the `v` value to be either 27 or 28.
     *
     * IMPORTANT: `hash` _must_ be the result of a hash operation for the
     * verification to be secure: it is possible to craft signatures that
     * recover to arbitrary addresses for non-hashed data. A safe way to ensure
     * this is by receiving a hash of the original message (which may otherwise
     * be too long), and then calling {toEthSignedMessageHash} on it.
     *
     * Documentation for signature generation:
     * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]
     * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]
     *
     * _Available since v4.3._
     */
    function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) {
        // Check the signature length
        // - case 65: r,s,v signature (standard)
        // - case 64: r,vs signature (cf https://eips.ethereum.org/EIPS/eip-2098) _Available since v4.1._
        if (signature.length == 65) {
            bytes32 r;
            bytes32 s;
            uint8 v;
            // ecrecover takes the signature parameters, and the only way to get them
            // currently is to use assembly.
            assembly {
                r := mload(add(signature, 0x20))
                s := mload(add(signature, 0x40))
                v := byte(0, mload(add(signature, 0x60)))
            }
            return tryRecover(hash, v, r, s);
        } else if (signature.length == 64) {
            bytes32 r;
            bytes32 vs;
            // ecrecover takes the signature parameters, and the only way to get them
            // currently is to use assembly.
            assembly {
                r := mload(add(signature, 0x20))
                vs := mload(add(signature, 0x40))
            }
            return tryRecover(hash, r, vs);
        } else {
            return (address(0), RecoverError.InvalidSignatureLength);
        }
    }

    /**
     * @dev Returns the address that signed a hashed message (`hash`) with
     * `signature`. This address can then be used for verification purposes.
     *
     * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:
     * this function rejects them by requiring the `s` value to be in the lower
     * half order, and the `v` value to be either 27 or 28.
     *
     * IMPORTANT: `hash` _must_ be the result of a hash operation for the
     * verification to be secure: it is possible to craft signatures that
     * recover to arbitrary addresses for non-hashed data. A safe way to ensure
     * this is by receiving a hash of the original message (which may otherwise
     * be too long), and then calling {toEthSignedMessageHash} on it.
     */
    function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {
        (address recovered, RecoverError error) = tryRecover(hash, signature);
        _throwError(error);
        return recovered;
    }

    /**
     * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.
     *
     * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]
     *
     * _Available since v4.3._
     */
    function tryRecover(
        bytes32 hash,
        bytes32 r,
        bytes32 vs
    ) internal pure returns (address, RecoverError) {
        bytes32 s;
        uint8 v;
        assembly {
            s := and(vs, 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
            v := add(shr(255, vs), 27)
        }
        return tryRecover(hash, v, r, s);
    }

    /**
     * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.
     *
     * _Available since v4.2._
     */
    function recover(
        bytes32 hash,
        bytes32 r,
        bytes32 vs
    ) internal pure returns (address) {
        (address recovered, RecoverError error) = tryRecover(hash, r, vs);
        _throwError(error);
        return recovered;
    }

    /**
     * @dev Overload of {ECDSA-tryRecover} that receives the `v`,
     * `r` and `s` signature fields separately.
     *
     * _Available since v4.3._
     */
    function tryRecover(
        bytes32 hash,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) internal pure returns (address, RecoverError) {
        // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature
        // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines
        // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most
        // signatures from current libraries generate a unique signature with an s-value in the lower half order.
        //
        // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value
        // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or
        // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept
        // these malleable signatures as well.
        if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {
            return (address(0), RecoverError.InvalidSignatureS);
        }
        if (v != 27 && v != 28) {
            return (address(0), RecoverError.InvalidSignatureV);
        }

        // If the signature is valid (and not malleable), return the signer address
        address signer = ecrecover(hash, v, r, s);
        if (signer == address(0)) {
            return (address(0), RecoverError.InvalidSignature);
        }

        return (signer, RecoverError.NoError);
    }

    /**
     * @dev Overload of {ECDSA-recover} that receives the `v`,
     * `r` and `s` signature fields separately.
     */
    function recover(
        bytes32 hash,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) internal pure returns (address) {
        (address recovered, RecoverError error) = tryRecover(hash, v, r, s);
        _throwError(error);
        return recovered;
    }

    /**
     * @dev Returns an Ethereum Signed Message, created from a `hash`. This
     * produces hash corresponding to the one signed with the
     * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]
     * JSON-RPC method as part of EIP-191.
     *
     * See {recover}.
     */
    function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) {
        // 32 is the length in bytes of hash,
        // enforced by the type signature above
        return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", hash));
    }

    /**
     * @dev Returns an Ethereum Signed Typed Data, created from a
     * `domainSeparator` and a `structHash`. This produces hash corresponding
     * to the one signed with the
     * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`]
     * JSON-RPC method as part of EIP-712.
     *
     * See {recover}.
     */
    function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) {
        return keccak256(abi.encodePacked("\x19\x01", domainSeparator, structHash));
    }
}

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

pragma solidity ^0.8.0;

/**
 * @title Counters
 * @author Matt Condon (@shrugs)
 * @dev Provides counters that can only be incremented, decremented or reset. This can be used e.g. to track the number
 * of elements in a mapping, issuing ERC721 ids, or counting request ids.
 *
 * Include with `using Counters for Counters.Counter;`
 */
library CountersUpgradeable {
    struct Counter {
        // This variable should never be directly accessed by users of the library: interactions must be restricted to
        // the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add
        // this feature: see https://github.com/ethereum/solidity/issues/4637
        uint256 _value; // default: 0
    }

    function current(Counter storage counter) internal view returns (uint256) {
        return counter._value;
    }

    function increment(Counter storage counter) internal {
        unchecked {
            counter._value += 1;
        }
    }

    function decrement(Counter storage counter) internal {
        uint256 value = counter._value;
        require(value > 0, "Counter: decrement overflow");
        unchecked {
            counter._value = value - 1;
        }
    }

    function reset(Counter storage counter) internal {
        counter._value = 0;
    }
}

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

pragma solidity ^0.8.0;

/**
 * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
 * behind a proxy. Since a proxied contract can't have a constructor, it's common to move constructor logic to an
 * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
 * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
 *
 * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
 * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.
 *
 * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
 * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
 */
abstract contract Initializable {
    /**
     * @dev Indicates that the contract has been initialized.
     */
    bool private _initialized;

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

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

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

        _;

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

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

pragma solidity ^0.8.0;

import "../IERC20Upgradeable.sol";

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

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

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

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

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

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

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

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

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

pragma solidity ^0.8.0;

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

        uint256 size;
        assembly {
            size := extcodesize(account)
        }
        return size > 0;
    }

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

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

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

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

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

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

        (bool success, bytes memory returndata) = target.call{value: value}(data);
        return verifyCallResult(success, returndata, errorMessage);
    }

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

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

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

    /**
     * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
     * revert reason using the provided one.
     *
     * _Available since v4.3._
     */
    function verifyCallResult(
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal pure returns (bytes memory) {
        if (success) {
            return returndata;
        } else {
            // Look for revert reason and bubble it up if present
            if (returndata.length > 0) {
                // The easiest way to bubble the revert reason is using memory via assembly

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

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

pragma solidity ^0.8.0;

import "../utils/ContextUpgradeable.sol";
import "../proxy/utils/Initializable.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 OwnableUpgradeable is Initializable, ContextUpgradeable {
    address private _owner;

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

    /**
     * @dev Initializes the contract setting the deployer as the initial owner.
     */
    function __Ownable_init() internal initializer {
        __Context_init_unchained();
        __Ownable_init_unchained();
    }

    function __Ownable_init_unchained() internal initializer {
        _setOwner(_msgSender());
    }

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

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

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

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

    function _setOwner(address newOwner) private {
        address oldOwner = _owner;
        _owner = newOwner;
        emit OwnershipTransferred(oldOwner, newOwner);
    }
    uint256[49] private __gap;
}

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

Contract Security Audit

Contract ABI

[{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_asset","type":"address"},{"indexed":false,"internalType":"uint256","name":"_emissionPerSecond","type":"uint256"}],"name":"AssetConfigUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_asset","type":"address"},{"indexed":false,"internalType":"uint256","name":"_index","type":"uint256"}],"name":"AssetIndexUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"newDistributionEnd","type":"uint256"}],"name":"DistributionEndUpdated","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":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Redeem","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"RewardsAccrued","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"RewardsClaimed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Staked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"address","name":"asset","type":"address"},{"indexed":false,"internalType":"uint256","name":"index","type":"uint256"}],"name":"UserIndexUpdated","type":"event"},{"inputs":[],"name":"DISTRIBUTION_END","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"DOMAIN_SEPARATOR","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"PRECISION","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"apr","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"assets","outputs":[{"internalType":"uint128","name":"emissionPerSecond","type":"uint128"},{"internalType":"uint128","name":"lastUpdateTimestamp","type":"uint128"},{"internalType":"uint256","name":"index","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"claim","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"staker","type":"address"}],"name":"claimableRewards","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint128","name":"emissionPerSecond","type":"uint128"}],"name":"configure","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"subtractedValue","type":"uint256"}],"name":"decreaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"address","name":"_asset","type":"address"}],"name":"getUserAssetData","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"addedValue","type":"uint256"}],"name":"increaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_stakedToken","type":"address"},{"internalType":"address","name":"_rewardToken","type":"address"},{"internalType":"address","name":"_rewardVault","type":"address"},{"internalType":"uint128","name":"distributionDuration","type":"uint128"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"nonces","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":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"name":"permit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"redeem","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"rewardToken","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"rewardVault","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_distributionEnd","type":"uint256"}],"name":"setDistributionEnd","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"stake","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"stakedToken","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"stakerRewardsToClaim","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}]

608060405234801561001057600080fd5b506131af806100206000396000f3fe608060405234801561001057600080fd5b50600436106101fb5760003560e01c80637e90d7ef1161011a578063aaf5eb68116100ad578063dc01f60d1161007c578063dc01f60d1461044d578063dd62ed3e14610460578063f11b818814610499578063f2fde38b146104fc578063f7c618c11461050f57600080fd5b8063aaf5eb681461040b578063cc7a262e14610413578063d505accf14610427578063db006a751461043a57600080fd5b806395d89b41116100e957806395d89b41146103ca578063a457c2d7146103d2578063a694fc3a146103e5578063a9059cbb146103f857600080fd5b80637e90d7ef146103765780637ecebe00146103975780638da5cb5b146103aa578063919cd40f146103c057600080fd5b8063395093511161019257806357ded9c91161016157806357ded9c91461034057806370a0823114610348578063715018a61461035b578063724a480d1461036357600080fd5b806339509351146102db57806339ccbdd3146102ee5780633a2c6777146103015780634a163fc11461032d57600080fd5b8063313ce567116101ce578063313ce567146102665780633373ee4c1461027f5780633644e515146102be578063379607f5146102c657600080fd5b806306fdde0314610200578063095ea7b31461021e57806318160ddd1461024157806323b872dd14610253575b600080fd5b610208610523565b6040516102159190612e35565b60405180910390f35b61023161022c366004612d86565b6105b5565b6040519015158152602001610215565b6067545b604051908152602001610215565b610231610261366004612cda565b6105cc565b60fe5460ff165b60405160ff9091168152602001610215565b61024561028d366004612c55565b6001600160a01b03808216600090815261013160209081526040808320938616835260029093019052205492915050565b61024561067d565b6102d96102d4366004612de9565b61068c565b005b6102316102e9366004612d86565b6107ae565b6102d96102fc366004612de9565b6107ea565b61013454610315906001600160a01b031681565b6040516001600160a01b039091168152602001610215565b6102d961033b366004612c87565b610856565b610245610976565b610245610356366004612c3b565b610b1e565b6102d9610b39565b6102d9610371366004612dcf565b610b75565b610245610384366004612c3b565b6101356020526000908152604090205481565b6102456103a5366004612c3b565b610cb2565b60fe5461010090046001600160a01b0316610315565b6102456101305481565b610208610cd0565b6102316103e0366004612d86565b610cdf565b6102d96103f3366004612de9565b610d78565b610231610406366004612d86565b610ea3565b61026d601281565b61013254610315906001600160a01b031681565b6102d9610435366004612d15565b610eb0565b6102d9610448366004612de9565b610ff6565b61024561045b366004612c3b565b6110bc565b61024561046e366004612c55565b6001600160a01b03918216600090815260666020908152604080832093909416825291909152205490565b6104d66104a7366004612c3b565b61013160205260009081526040902080546001909101546001600160801b0380831692600160801b9004169083565b604080516001600160801b03948516815293909216602084015290820152606001610215565b6102d961050a366004612c3b565b6111a5565b61013354610315906001600160a01b031681565b60606068805461053290613113565b80601f016020809104026020016040519081016040528092919081815260200182805461055e90613113565b80156105ab5780601f10610580576101008083540402835291602001916105ab565b820191906000526020600020905b81548152906001019060200180831161058e57829003601f168201915b5050505050905090565b60006105c2338484611246565b5060015b92915050565b60006105d984848461136b565b6001600160a01b0384166000908152606660209081526040808320338452909152902054828110156106635760405162461bcd60e51b815260206004820152602860248201527f45524332303a207472616e7366657220616d6f756e74206578636565647320616044820152676c6c6f77616e636560c01b60648201526084015b60405180910390fd5b6106708533858403611246565b60019150505b9392505050565b60006106876113cb565b905090565b600260015414156106af5760405162461bcd60e51b815260040161065a90612f18565b6002600155806106d15760405162461bcd60e51b815260040161065a90612e68565b60006106e7336106e033610b1e565b6000611446565b9050600060001983146106fa57826106fc565b815b9050610739816040518060400160405280600e81526020016d1253959053125117d05353d5539560921b815250846114f79092919063ffffffff16565b3360008181526101356020526040902091909155610134546101335461076f926001600160a01b03918216929091169084611523565b60405181815233907ffc30cddea38e2bf4d6ea7d3f9ed3b6ad7f176419f4963bd81318067a4aee73fe906020015b60405180910390a250506001805550565b3360008181526066602090815260408083206001600160a01b038716845290915281205490916105c29185906107e5908690612f4f565b611246565b60fe546001600160a01b0361010090910416331461081a5760405162461bcd60e51b815260040161065a90612ee3565b6101308190556040518181527f1cc1849a6602c3e91f2088cadea4381cc5717f2f28584197060ed2ebb434c16f9060200160405180910390a150565b600054610100900460ff168061086f575060005460ff16155b61088b5760405162461bcd60e51b815260040161065a90612e95565b600054610100900460ff161580156108ad576000805461ffff19166101011790555b610903604051806040016040528060138152602001725374616b65642042454e442f45544820554e4960681b8152506040518060400160405280600781526020016673746b42554e4960c81b815250601261158e565b610915826001600160801b031661161e565b61091d6116a0565b61013280546001600160a01b038088166001600160a01b0319928316179092556101338054878416908316179055610134805492861692909116919091179055801561096f576000805461ff00191690555b5050505050565b600061098160675490565b61098b5750600090565b61013354610132546040516370a0823160e01b81526001600160a01b03918216600482015260009291909116906370a082319060240160206040518083038186803b1580156109d957600080fd5b505afa1580156109ed573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a119190612e01565b9050600061013260009054906101000a90046001600160a01b03166001600160a01b03166318160ddd6040518163ffffffff1660e01b815260040160206040518083038186803b158015610a6457600080fd5b505afa158015610a78573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a9c9190612e01565b606754610aaa8460026130b1565b610ab491906130b1565b610abe9190612f67565b306000908152610131602052604081205491925090610aea906001600160801b03166301e13380613082565b6001600160801b0316905081610b026012600a612fd6565b610b0c90836130b1565b610b169190612f67565b935050505090565b6001600160a01b031660009081526065602052604090205490565b60fe546001600160a01b03610100909104163314610b695760405162461bcd60e51b815260040161065a90612ee3565b610b736000611713565b565b60fe546001600160a01b03610100909104163314610ba55760405162461bcd60e51b815260040161065a90612ee3565b604080516001808252818301909252600091816020015b6040805160608101825260008082526020808301829052928201528252600019909201910181610bbc5790505090508181600081518110610c0d57634e487b7160e01b600052603260045260246000fd5b60209081029190910101516001600160801b039091169052610c2e60675490565b81600081518110610c4f57634e487b7160e01b600052603260045260246000fd5b602002602001015160200181815250503081600081518110610c8157634e487b7160e01b600052603260045260246000fd5b6020026020010151604001906001600160a01b031690816001600160a01b031681525050610cae8161176d565b5050565b6001600160a01b038116600090815260cb60205260408120546105c6565b60606069805461053290613113565b3360009081526066602090815260408083206001600160a01b038616845290915281205482811015610d615760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77604482015264207a65726f60d81b606482015260840161065a565b610d6e3385858403611246565b5060019392505050565b60026001541415610d9b5760405162461bcd60e51b815260040161065a90612f18565b600260015580610dbd5760405162461bcd60e51b815260040161065a90612e68565b6000610dc833610b1e565b90506000610de0333084610ddb60675490565b611960565b90508015610e4e5760408051338152602081018390527f2468f9268c60ad90e2d49edb0032c8a001e733ae888b3ab8e982edf535be1a76910160405180910390a13360009081526101356020526040902054610e3c9082611a24565b33600090815261013560205260409020555b61013254610e67906001600160a01b0316333086611523565b610e713384611a30565b60405183815233907f9e71bc8eea02a63969f509818f2dafb9254532904319f9dbda79b67bd34a5f3d9060200161079d565b60006105c233848461136b565b83421115610f005760405162461bcd60e51b815260206004820152601d60248201527f45524332305065726d69743a206578706972656420646561646c696e65000000604482015260640161065a565b600060cc54888888610f118c611b0f565b6040805160208101969096526001600160a01b0394851690860152929091166060840152608083015260a082015260c0810186905260e0016040516020818303038152906040528051906020012090506000610f6c82611b37565b90506000610f7c82878787611b85565b9050896001600160a01b0316816001600160a01b031614610fdf5760405162461bcd60e51b815260206004820152601e60248201527f45524332305065726d69743a20696e76616c6964207369676e61747572650000604482015260640161065a565b610fea8a8a8a611246565b50505050505050505050565b600260015414156110195760405162461bcd60e51b815260040161065a90612f18565b60026001558061103b5760405162461bcd60e51b815260040161065a90612e68565b600061104633610b1e565b905060008183116110575782611059565b815b905061106733836001611446565b506110723382611bad565b6101325461108a906001600160a01b03163383611cf8565b60405181815233907f222838db2794d11532d940e8dec38ae307ed0b63cd97c233322e221f998767a69060200161079d565b604080516001808252818301909252600091829190816020015b611103604051806060016040528060006001600160a01b0316815260200160008152602001600081525090565b8152602001906001900390816110d65790505090506040518060600160405280306001600160a01b0316815260200161113b85610b1e565b815260200161114960675490565b8152508160008151811061116d57634e487b7160e01b600052603260045260246000fd5b60200260200101819052506106766111858483611d28565b6001600160a01b0385166000908152610135602052604090205490611a24565b60fe546001600160a01b036101009091041633146111d55760405162461bcd60e51b815260040161065a90612ee3565b6001600160a01b03811661123a5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b606482015260840161065a565b61124381611713565b50565b6001600160a01b0383166112a85760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b606482015260840161065a565b6001600160a01b0382166113095760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b606482015260840161065a565b6001600160a01b0383811660008181526066602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591015b60405180910390a3505050565b600061137684610b1e565b905061138484826001611446565b50826001600160a01b0316846001600160a01b0316146113ba5760006113a984610b1e565b90506113b784826001611446565b50505b6113c5848484611e61565b50505050565b60006106877f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f6113fa60975490565b6098546040805160208101859052908101839052606081018290524660808201523060a082015260009060c0016040516020818303038152906040528051906020012090509392505050565b600080611458853086610ddb60675490565b6001600160a01b03861660009081526101356020526040812054919250906114809083611a24565b905081156114ee5783156114ab576001600160a01b0386166000908152610135602052604090208190555b604080516001600160a01b0388168152602081018490527f2468f9268c60ad90e2d49edb0032c8a001e733ae888b3ab8e982edf535be1a76910160405180910390a15b95945050505050565b6000818484111561151b5760405162461bcd60e51b815260040161065a9190612e35565b505050900390565b6040516001600160a01b03808516602483015283166044820152606481018290526113c59085906323b872dd60e01b906084015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b03199093169290921790915261202f565b600054610100900460ff16806115a7575060005460ff16155b6115c35760405162461bcd60e51b815260040161065a90612e95565b600054610100900460ff161580156115e5576000805461ffff19166101011790555b6115ef8484612101565b6115f884612180565b60fe805460ff191660ff841617905580156113c5576000805461ff001916905550505050565b600054610100900460ff1680611637575060005460ff16155b6116535760405162461bcd60e51b815260040161065a90612e95565b600054610100900460ff16158015611675576000805461ffff19166101011790555b61167d612220565b6116874283611a24565b610130558015610cae576000805461ff00191690555050565b600054610100900460ff16806116b9575060005460ff16155b6116d55760405162461bcd60e51b815260040161065a90612e95565b600054610100900460ff161580156116f7576000805461ffff19166101011790555b6116ff612287565b8015611243576000805461ff001916905550565b60fe80546001600160a01b03838116610100818102610100600160a81b031985161790945560405193909204169182907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b60fe546001600160a01b0361010090910416331461179d5760405162461bcd60e51b815260040161065a90612ee3565b60005b8151811015610cae57600061013160008484815181106117d057634e487b7160e01b600052603260045260246000fd5b6020026020010151604001516001600160a01b03166001600160a01b03168152602001908152602001600020905061185f83838151811061182157634e487b7160e01b600052603260045260246000fd5b6020026020010151604001518285858151811061184e57634e487b7160e01b600052603260045260246000fd5b6020026020010151602001516122f6565b5082828151811061188057634e487b7160e01b600052603260045260246000fd5b60209081029190910101515181546fffffffffffffffffffffffffffffffff19166001600160801b0390911617815582518390839081106118d157634e487b7160e01b600052603260045260246000fd5b6020026020010151604001516001600160a01b03167f87fa03892a0556cb6b8f97e6d533a150d4d55fcbf275fff5fa003fa636bcc7fa84848151811061192757634e487b7160e01b600052603260045260246000fd5b602090810291909101810151516040516001600160801b0390911681520160405180910390a2508061195881613148565b9150506117a0565b6001600160a01b03808416600090815261013160209081526040808320938816835260028401909152812054909190828061199c8885886122f6565b9050808314611a165786156119b9576119b68782856123ae565b91505b6001600160a01b03808a1660008181526002870160205260409081902084905551918a16917fbb123b5c06d5408bbea3c4fef481578175cfb432e3b482c6186f02ed9086585b90611a0d9085815260200190565b60405180910390a35b50925050505b949350505050565b60006106768284612f4f565b6001600160a01b038216611a865760405162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f206164647265737300604482015260640161065a565b8060676000828254611a989190612f4f565b90915550506001600160a01b03821660009081526065602052604081208054839290611ac5908490612f4f565b90915550506040518181526001600160a01b038316906000907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9060200160405180910390a35050565b6001600160a01b038116600090815260cb602052604090208054600181018255905b50919050565b60006105c6611b446113cb565b8360405161190160f01b6020820152602281018390526042810182905260009060620160405160208183030381529060405280519060200120905092915050565b6000806000611b96878787876123d9565b91509150611ba3816124c6565b5095945050505050565b6001600160a01b038216611c0d5760405162461bcd60e51b815260206004820152602160248201527f45524332303a206275726e2066726f6d20746865207a65726f206164647265736044820152607360f81b606482015260840161065a565b6001600160a01b03821660009081526065602052604090205481811015611c815760405162461bcd60e51b815260206004820152602260248201527f45524332303a206275726e20616d6f756e7420657863656564732062616c616e604482015261636560f01b606482015260840161065a565b6001600160a01b0383166000908152606560205260408120838303905560678054849290611cb09084906130d0565b90915550506040518281526000906001600160a01b038516907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9060200161135e565b505050565b6040516001600160a01b038316602482015260448101829052611cf390849063a9059cbb60e01b90606401611557565b600080805b8351811015611e595760006101316000868481518110611d5d57634e487b7160e01b600052603260045260246000fd5b602090810291909101810151516001600160a01b031682528101919091526040016000908120600181015481548851929450611dd9926001600160801b0380831692600160801b900416908a9088908110611dc857634e487b7160e01b600052603260045260246000fd5b6020026020010151604001516126c7565b9050611e42611e3b878581518110611e0157634e487b7160e01b600052603260045260246000fd5b602002602001015160200151838560020160008c6001600160a01b03166001600160a01b03168152602001908152602001600020546123ae565b8590611a24565b935050508080611e5190613148565b915050611d2d565b509392505050565b6001600160a01b038316611ec55760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b606482015260840161065a565b6001600160a01b038216611f275760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b606482015260840161065a565b6001600160a01b03831660009081526065602052604090205481811015611f9f5760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e7420657863656564732062604482015265616c616e636560d01b606482015260840161065a565b6001600160a01b03808516600090815260656020526040808220858503905591851681529081208054849290611fd6908490612f4f565b92505081905550826001600160a01b0316846001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8460405161202291815260200190565b60405180910390a36113c5565b6000612084826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166127729092919063ffffffff16565b805190915015611cf357808060200190518101906120a29190612daf565b611cf35760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b606482015260840161065a565b600054610100900460ff168061211a575060005460ff16155b6121365760405162461bcd60e51b815260040161065a90612e95565b600054610100900460ff16158015612158576000805461ffff19166101011790555b612160612781565b61216a83836127eb565b8015611cf3576000805461ff0019169055505050565b600054610100900460ff1680612199575060005460ff16155b6121b55760405162461bcd60e51b815260040161065a90612e95565b600054610100900460ff161580156121d7576000805461ffff19166101011790555b6121df612781565b61220282604051806040016040528060018152602001603160f81b815250612880565b61220b8261290a565b8015610cae576000805461ff00191690555050565b600054610100900460ff1680612239575060005460ff16155b6122555760405162461bcd60e51b815260040161065a90612e95565b600054610100900460ff16158015612277576000805461ffff19166101011790555b61227f612781565b6116ff61299a565b600054610100900460ff16806122a0575060005460ff16155b6122bc5760405162461bcd60e51b815260040161065a90612e95565b600054610100900460ff161580156122de576000805461ffff19166101011790555b600180558015611243576000805461ff001916905550565b6001820154825460009190600160801b90046001600160801b03164281141561232157509050610676565b845460009061233c9084906001600160801b031684886126c7565b905082811461238b57600186018190556040518181526001600160a01b038816907f5777ca300dfe5bead41006fbce4389794dbc0ed8d6cccebfaf94630aa04184bc9060200160405180910390a25b85546001600160801b03428116600160801b029116178655925050509392505050565b6000611a1c6123bf6012600a612fca565b6123d36123cc86866129fa565b8790612a06565b90612a12565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a083111561241057506000905060036124bd565b8460ff16601b1415801561242857508460ff16601c14155b1561243957506000905060046124bd565b6040805160008082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa15801561248d573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b0381166124b6576000600192509250506124bd565b9150600090505b94509492505050565b60008160048111156124e857634e487b7160e01b600052602160045260246000fd5b14156124f15750565b600181600481111561251357634e487b7160e01b600052602160045260246000fd5b14156125615760405162461bcd60e51b815260206004820152601860248201527f45434453413a20696e76616c6964207369676e61747572650000000000000000604482015260640161065a565b600281600481111561258357634e487b7160e01b600052602160045260246000fd5b14156125d15760405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e67746800604482015260640161065a565b60038160048111156125f357634e487b7160e01b600052602160045260246000fd5b141561264c5760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c604482015261756560f01b606482015260840161065a565b600481600481111561266e57634e487b7160e01b600052602160045260246000fd5b14156112435760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202776272076616c604482015261756560f01b606482015260840161065a565b60008315806126d4575081155b806126e7575042836001600160801b0316145b806126fe575061013054836001600160801b031610155b1561270a575083611a1c565b600061013054421161271c5742612721565b610130545b90506000612738826001600160801b0387166129fa565b905061276787612761866123d36127516012600a612fca565b61275b8c88612a06565b90612a06565b90611a24565b979650505050505050565b6060611a1c8484600085612a1e565b600054610100900460ff168061279a575060005460ff16155b6127b65760405162461bcd60e51b815260040161065a90612e95565b600054610100900460ff161580156116ff576000805461ffff19166101011790558015611243576000805461ff001916905550565b600054610100900460ff1680612804575060005460ff16155b6128205760405162461bcd60e51b815260040161065a90612e95565b600054610100900460ff16158015612842576000805461ffff19166101011790555b8251612855906068906020860190612b6f565b508151612869906069906020850190612b6f565b508015611cf3576000805461ff0019169055505050565b600054610100900460ff1680612899575060005460ff16155b6128b55760405162461bcd60e51b815260040161065a90612e95565b600054610100900460ff161580156128d7576000805461ffff19166101011790555b82516020808501919091208351918401919091206097919091556098558015611cf3576000805461ff0019169055505050565b600054610100900460ff1680612923575060005460ff16155b61293f5760405162461bcd60e51b815260040161065a90612e95565b600054610100900460ff16158015612961576000805461ffff19166101011790555b7f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c960cc558015610cae576000805461ff00191690555050565b600054610100900460ff16806129b3575060005460ff16155b6129cf5760405162461bcd60e51b815260040161065a90612e95565b600054610100900460ff161580156129f1576000805461ffff19166101011790555b6116ff33611713565b600061067682846130d0565b600061067682846130b1565b60006106768284612f67565b606082471015612a7f5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b606482015260840161065a565b843b612acd5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015260640161065a565b600080866001600160a01b03168587604051612ae99190612e19565b60006040518083038185875af1925050503d8060008114612b26576040519150601f19603f3d011682016040523d82523d6000602084013e612b2b565b606091505b509150915061276782828660608315612b45575081610676565b825115612b555782518084602001fd5b8160405162461bcd60e51b815260040161065a9190612e35565b828054612b7b90613113565b90600052602060002090601f016020900481019282612b9d5760008555612be3565b82601f10612bb657805160ff1916838001178555612be3565b82800160010185558215612be3579182015b82811115612be3578251825591602001919060010190612bc8565b50612bef929150612bf3565b5090565b5b80821115612bef5760008155600101612bf4565b80356001600160a01b0381168114612c1f57600080fd5b919050565b80356001600160801b0381168114612c1f57600080fd5b600060208284031215612c4c578081fd5b61067682612c08565b60008060408385031215612c67578081fd5b612c7083612c08565b9150612c7e60208401612c08565b90509250929050565b60008060008060808587031215612c9c578182fd5b612ca585612c08565b9350612cb360208601612c08565b9250612cc160408601612c08565b9150612ccf60608601612c24565b905092959194509250565b600080600060608486031215612cee578283fd5b612cf784612c08565b9250612d0560208501612c08565b9150604084013590509250925092565b600080600080600080600060e0888a031215612d2f578283fd5b612d3888612c08565b9650612d4660208901612c08565b95506040880135945060608801359350608088013560ff81168114612d69578384fd5b9699959850939692959460a0840135945060c09093013592915050565b60008060408385031215612d98578182fd5b612da183612c08565b946020939093013593505050565b600060208284031215612dc0578081fd5b81518015158114610676578182fd5b600060208284031215612de0578081fd5b61067682612c24565b600060208284031215612dfa578081fd5b5035919050565b600060208284031215612e12578081fd5b5051919050565b60008251612e2b8184602087016130e7565b9190910192915050565b6020815260008251806020840152612e548160408501602087016130e7565b601f01601f19169190910160400192915050565b6020808252601390820152721253959053125117d6915493d7d05353d55395606a1b604082015260600190565b6020808252602e908201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160408201526d191e481a5b9a5d1a585b1a5e995960921b606082015260800190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b60008219821115612f6257612f62613163565b500190565b600082612f8257634e487b7160e01b81526012600452602481fd5b500490565b600181815b80851115612fc2578160001904821115612fa857612fa8613163565b80851615612fb557918102915b93841c9390800290612f8c565b509250929050565b60006106768383612fe1565b600061067660ff8416835b600082612ff0575060016105c6565b81612ffd575060006105c6565b8160018114613013576002811461301d57613039565b60019150506105c6565b60ff84111561302e5761302e613163565b50506001821b6105c6565b5060208310610133831016604e8410600b841016171561305c575081810a6105c6565b6130668383612f87565b806000190482111561307a5761307a613163565b029392505050565b60006001600160801b03808316818516818304811182151516156130a8576130a8613163565b02949350505050565b60008160001904831182151516156130cb576130cb613163565b500290565b6000828210156130e2576130e2613163565b500390565b60005b838110156131025781810151838201526020016130ea565b838111156113c55750506000910152565b600181811c9082168061312757607f821691505b60208210811415611b3157634e487b7160e01b600052602260045260246000fd5b600060001982141561315c5761315c613163565b5060010190565b634e487b7160e01b600052601160045260246000fdfea2646970667358221220b9322569a6c78ecf7209953cb9c4ab38011b9141c42d35dc6a57598aa11ec4a664736f6c63430008040033

Deployed Bytecode

0x608060405234801561001057600080fd5b50600436106101fb5760003560e01c80637e90d7ef1161011a578063aaf5eb68116100ad578063dc01f60d1161007c578063dc01f60d1461044d578063dd62ed3e14610460578063f11b818814610499578063f2fde38b146104fc578063f7c618c11461050f57600080fd5b8063aaf5eb681461040b578063cc7a262e14610413578063d505accf14610427578063db006a751461043a57600080fd5b806395d89b41116100e957806395d89b41146103ca578063a457c2d7146103d2578063a694fc3a146103e5578063a9059cbb146103f857600080fd5b80637e90d7ef146103765780637ecebe00146103975780638da5cb5b146103aa578063919cd40f146103c057600080fd5b8063395093511161019257806357ded9c91161016157806357ded9c91461034057806370a0823114610348578063715018a61461035b578063724a480d1461036357600080fd5b806339509351146102db57806339ccbdd3146102ee5780633a2c6777146103015780634a163fc11461032d57600080fd5b8063313ce567116101ce578063313ce567146102665780633373ee4c1461027f5780633644e515146102be578063379607f5146102c657600080fd5b806306fdde0314610200578063095ea7b31461021e57806318160ddd1461024157806323b872dd14610253575b600080fd5b610208610523565b6040516102159190612e35565b60405180910390f35b61023161022c366004612d86565b6105b5565b6040519015158152602001610215565b6067545b604051908152602001610215565b610231610261366004612cda565b6105cc565b60fe5460ff165b60405160ff9091168152602001610215565b61024561028d366004612c55565b6001600160a01b03808216600090815261013160209081526040808320938616835260029093019052205492915050565b61024561067d565b6102d96102d4366004612de9565b61068c565b005b6102316102e9366004612d86565b6107ae565b6102d96102fc366004612de9565b6107ea565b61013454610315906001600160a01b031681565b6040516001600160a01b039091168152602001610215565b6102d961033b366004612c87565b610856565b610245610976565b610245610356366004612c3b565b610b1e565b6102d9610b39565b6102d9610371366004612dcf565b610b75565b610245610384366004612c3b565b6101356020526000908152604090205481565b6102456103a5366004612c3b565b610cb2565b60fe5461010090046001600160a01b0316610315565b6102456101305481565b610208610cd0565b6102316103e0366004612d86565b610cdf565b6102d96103f3366004612de9565b610d78565b610231610406366004612d86565b610ea3565b61026d601281565b61013254610315906001600160a01b031681565b6102d9610435366004612d15565b610eb0565b6102d9610448366004612de9565b610ff6565b61024561045b366004612c3b565b6110bc565b61024561046e366004612c55565b6001600160a01b03918216600090815260666020908152604080832093909416825291909152205490565b6104d66104a7366004612c3b565b61013160205260009081526040902080546001909101546001600160801b0380831692600160801b9004169083565b604080516001600160801b03948516815293909216602084015290820152606001610215565b6102d961050a366004612c3b565b6111a5565b61013354610315906001600160a01b031681565b60606068805461053290613113565b80601f016020809104026020016040519081016040528092919081815260200182805461055e90613113565b80156105ab5780601f10610580576101008083540402835291602001916105ab565b820191906000526020600020905b81548152906001019060200180831161058e57829003601f168201915b5050505050905090565b60006105c2338484611246565b5060015b92915050565b60006105d984848461136b565b6001600160a01b0384166000908152606660209081526040808320338452909152902054828110156106635760405162461bcd60e51b815260206004820152602860248201527f45524332303a207472616e7366657220616d6f756e74206578636565647320616044820152676c6c6f77616e636560c01b60648201526084015b60405180910390fd5b6106708533858403611246565b60019150505b9392505050565b60006106876113cb565b905090565b600260015414156106af5760405162461bcd60e51b815260040161065a90612f18565b6002600155806106d15760405162461bcd60e51b815260040161065a90612e68565b60006106e7336106e033610b1e565b6000611446565b9050600060001983146106fa57826106fc565b815b9050610739816040518060400160405280600e81526020016d1253959053125117d05353d5539560921b815250846114f79092919063ffffffff16565b3360008181526101356020526040902091909155610134546101335461076f926001600160a01b03918216929091169084611523565b60405181815233907ffc30cddea38e2bf4d6ea7d3f9ed3b6ad7f176419f4963bd81318067a4aee73fe906020015b60405180910390a250506001805550565b3360008181526066602090815260408083206001600160a01b038716845290915281205490916105c29185906107e5908690612f4f565b611246565b60fe546001600160a01b0361010090910416331461081a5760405162461bcd60e51b815260040161065a90612ee3565b6101308190556040518181527f1cc1849a6602c3e91f2088cadea4381cc5717f2f28584197060ed2ebb434c16f9060200160405180910390a150565b600054610100900460ff168061086f575060005460ff16155b61088b5760405162461bcd60e51b815260040161065a90612e95565b600054610100900460ff161580156108ad576000805461ffff19166101011790555b610903604051806040016040528060138152602001725374616b65642042454e442f45544820554e4960681b8152506040518060400160405280600781526020016673746b42554e4960c81b815250601261158e565b610915826001600160801b031661161e565b61091d6116a0565b61013280546001600160a01b038088166001600160a01b0319928316179092556101338054878416908316179055610134805492861692909116919091179055801561096f576000805461ff00191690555b5050505050565b600061098160675490565b61098b5750600090565b61013354610132546040516370a0823160e01b81526001600160a01b03918216600482015260009291909116906370a082319060240160206040518083038186803b1580156109d957600080fd5b505afa1580156109ed573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a119190612e01565b9050600061013260009054906101000a90046001600160a01b03166001600160a01b03166318160ddd6040518163ffffffff1660e01b815260040160206040518083038186803b158015610a6457600080fd5b505afa158015610a78573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a9c9190612e01565b606754610aaa8460026130b1565b610ab491906130b1565b610abe9190612f67565b306000908152610131602052604081205491925090610aea906001600160801b03166301e13380613082565b6001600160801b0316905081610b026012600a612fd6565b610b0c90836130b1565b610b169190612f67565b935050505090565b6001600160a01b031660009081526065602052604090205490565b60fe546001600160a01b03610100909104163314610b695760405162461bcd60e51b815260040161065a90612ee3565b610b736000611713565b565b60fe546001600160a01b03610100909104163314610ba55760405162461bcd60e51b815260040161065a90612ee3565b604080516001808252818301909252600091816020015b6040805160608101825260008082526020808301829052928201528252600019909201910181610bbc5790505090508181600081518110610c0d57634e487b7160e01b600052603260045260246000fd5b60209081029190910101516001600160801b039091169052610c2e60675490565b81600081518110610c4f57634e487b7160e01b600052603260045260246000fd5b602002602001015160200181815250503081600081518110610c8157634e487b7160e01b600052603260045260246000fd5b6020026020010151604001906001600160a01b031690816001600160a01b031681525050610cae8161176d565b5050565b6001600160a01b038116600090815260cb60205260408120546105c6565b60606069805461053290613113565b3360009081526066602090815260408083206001600160a01b038616845290915281205482811015610d615760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77604482015264207a65726f60d81b606482015260840161065a565b610d6e3385858403611246565b5060019392505050565b60026001541415610d9b5760405162461bcd60e51b815260040161065a90612f18565b600260015580610dbd5760405162461bcd60e51b815260040161065a90612e68565b6000610dc833610b1e565b90506000610de0333084610ddb60675490565b611960565b90508015610e4e5760408051338152602081018390527f2468f9268c60ad90e2d49edb0032c8a001e733ae888b3ab8e982edf535be1a76910160405180910390a13360009081526101356020526040902054610e3c9082611a24565b33600090815261013560205260409020555b61013254610e67906001600160a01b0316333086611523565b610e713384611a30565b60405183815233907f9e71bc8eea02a63969f509818f2dafb9254532904319f9dbda79b67bd34a5f3d9060200161079d565b60006105c233848461136b565b83421115610f005760405162461bcd60e51b815260206004820152601d60248201527f45524332305065726d69743a206578706972656420646561646c696e65000000604482015260640161065a565b600060cc54888888610f118c611b0f565b6040805160208101969096526001600160a01b0394851690860152929091166060840152608083015260a082015260c0810186905260e0016040516020818303038152906040528051906020012090506000610f6c82611b37565b90506000610f7c82878787611b85565b9050896001600160a01b0316816001600160a01b031614610fdf5760405162461bcd60e51b815260206004820152601e60248201527f45524332305065726d69743a20696e76616c6964207369676e61747572650000604482015260640161065a565b610fea8a8a8a611246565b50505050505050505050565b600260015414156110195760405162461bcd60e51b815260040161065a90612f18565b60026001558061103b5760405162461bcd60e51b815260040161065a90612e68565b600061104633610b1e565b905060008183116110575782611059565b815b905061106733836001611446565b506110723382611bad565b6101325461108a906001600160a01b03163383611cf8565b60405181815233907f222838db2794d11532d940e8dec38ae307ed0b63cd97c233322e221f998767a69060200161079d565b604080516001808252818301909252600091829190816020015b611103604051806060016040528060006001600160a01b0316815260200160008152602001600081525090565b8152602001906001900390816110d65790505090506040518060600160405280306001600160a01b0316815260200161113b85610b1e565b815260200161114960675490565b8152508160008151811061116d57634e487b7160e01b600052603260045260246000fd5b60200260200101819052506106766111858483611d28565b6001600160a01b0385166000908152610135602052604090205490611a24565b60fe546001600160a01b036101009091041633146111d55760405162461bcd60e51b815260040161065a90612ee3565b6001600160a01b03811661123a5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b606482015260840161065a565b61124381611713565b50565b6001600160a01b0383166112a85760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b606482015260840161065a565b6001600160a01b0382166113095760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b606482015260840161065a565b6001600160a01b0383811660008181526066602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591015b60405180910390a3505050565b600061137684610b1e565b905061138484826001611446565b50826001600160a01b0316846001600160a01b0316146113ba5760006113a984610b1e565b90506113b784826001611446565b50505b6113c5848484611e61565b50505050565b60006106877f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f6113fa60975490565b6098546040805160208101859052908101839052606081018290524660808201523060a082015260009060c0016040516020818303038152906040528051906020012090509392505050565b600080611458853086610ddb60675490565b6001600160a01b03861660009081526101356020526040812054919250906114809083611a24565b905081156114ee5783156114ab576001600160a01b0386166000908152610135602052604090208190555b604080516001600160a01b0388168152602081018490527f2468f9268c60ad90e2d49edb0032c8a001e733ae888b3ab8e982edf535be1a76910160405180910390a15b95945050505050565b6000818484111561151b5760405162461bcd60e51b815260040161065a9190612e35565b505050900390565b6040516001600160a01b03808516602483015283166044820152606481018290526113c59085906323b872dd60e01b906084015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b03199093169290921790915261202f565b600054610100900460ff16806115a7575060005460ff16155b6115c35760405162461bcd60e51b815260040161065a90612e95565b600054610100900460ff161580156115e5576000805461ffff19166101011790555b6115ef8484612101565b6115f884612180565b60fe805460ff191660ff841617905580156113c5576000805461ff001916905550505050565b600054610100900460ff1680611637575060005460ff16155b6116535760405162461bcd60e51b815260040161065a90612e95565b600054610100900460ff16158015611675576000805461ffff19166101011790555b61167d612220565b6116874283611a24565b610130558015610cae576000805461ff00191690555050565b600054610100900460ff16806116b9575060005460ff16155b6116d55760405162461bcd60e51b815260040161065a90612e95565b600054610100900460ff161580156116f7576000805461ffff19166101011790555b6116ff612287565b8015611243576000805461ff001916905550565b60fe80546001600160a01b03838116610100818102610100600160a81b031985161790945560405193909204169182907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b60fe546001600160a01b0361010090910416331461179d5760405162461bcd60e51b815260040161065a90612ee3565b60005b8151811015610cae57600061013160008484815181106117d057634e487b7160e01b600052603260045260246000fd5b6020026020010151604001516001600160a01b03166001600160a01b03168152602001908152602001600020905061185f83838151811061182157634e487b7160e01b600052603260045260246000fd5b6020026020010151604001518285858151811061184e57634e487b7160e01b600052603260045260246000fd5b6020026020010151602001516122f6565b5082828151811061188057634e487b7160e01b600052603260045260246000fd5b60209081029190910101515181546fffffffffffffffffffffffffffffffff19166001600160801b0390911617815582518390839081106118d157634e487b7160e01b600052603260045260246000fd5b6020026020010151604001516001600160a01b03167f87fa03892a0556cb6b8f97e6d533a150d4d55fcbf275fff5fa003fa636bcc7fa84848151811061192757634e487b7160e01b600052603260045260246000fd5b602090810291909101810151516040516001600160801b0390911681520160405180910390a2508061195881613148565b9150506117a0565b6001600160a01b03808416600090815261013160209081526040808320938816835260028401909152812054909190828061199c8885886122f6565b9050808314611a165786156119b9576119b68782856123ae565b91505b6001600160a01b03808a1660008181526002870160205260409081902084905551918a16917fbb123b5c06d5408bbea3c4fef481578175cfb432e3b482c6186f02ed9086585b90611a0d9085815260200190565b60405180910390a35b50925050505b949350505050565b60006106768284612f4f565b6001600160a01b038216611a865760405162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f206164647265737300604482015260640161065a565b8060676000828254611a989190612f4f565b90915550506001600160a01b03821660009081526065602052604081208054839290611ac5908490612f4f565b90915550506040518181526001600160a01b038316906000907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9060200160405180910390a35050565b6001600160a01b038116600090815260cb602052604090208054600181018255905b50919050565b60006105c6611b446113cb565b8360405161190160f01b6020820152602281018390526042810182905260009060620160405160208183030381529060405280519060200120905092915050565b6000806000611b96878787876123d9565b91509150611ba3816124c6565b5095945050505050565b6001600160a01b038216611c0d5760405162461bcd60e51b815260206004820152602160248201527f45524332303a206275726e2066726f6d20746865207a65726f206164647265736044820152607360f81b606482015260840161065a565b6001600160a01b03821660009081526065602052604090205481811015611c815760405162461bcd60e51b815260206004820152602260248201527f45524332303a206275726e20616d6f756e7420657863656564732062616c616e604482015261636560f01b606482015260840161065a565b6001600160a01b0383166000908152606560205260408120838303905560678054849290611cb09084906130d0565b90915550506040518281526000906001600160a01b038516907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9060200161135e565b505050565b6040516001600160a01b038316602482015260448101829052611cf390849063a9059cbb60e01b90606401611557565b600080805b8351811015611e595760006101316000868481518110611d5d57634e487b7160e01b600052603260045260246000fd5b602090810291909101810151516001600160a01b031682528101919091526040016000908120600181015481548851929450611dd9926001600160801b0380831692600160801b900416908a9088908110611dc857634e487b7160e01b600052603260045260246000fd5b6020026020010151604001516126c7565b9050611e42611e3b878581518110611e0157634e487b7160e01b600052603260045260246000fd5b602002602001015160200151838560020160008c6001600160a01b03166001600160a01b03168152602001908152602001600020546123ae565b8590611a24565b935050508080611e5190613148565b915050611d2d565b509392505050565b6001600160a01b038316611ec55760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b606482015260840161065a565b6001600160a01b038216611f275760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b606482015260840161065a565b6001600160a01b03831660009081526065602052604090205481811015611f9f5760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e7420657863656564732062604482015265616c616e636560d01b606482015260840161065a565b6001600160a01b03808516600090815260656020526040808220858503905591851681529081208054849290611fd6908490612f4f565b92505081905550826001600160a01b0316846001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8460405161202291815260200190565b60405180910390a36113c5565b6000612084826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166127729092919063ffffffff16565b805190915015611cf357808060200190518101906120a29190612daf565b611cf35760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b606482015260840161065a565b600054610100900460ff168061211a575060005460ff16155b6121365760405162461bcd60e51b815260040161065a90612e95565b600054610100900460ff16158015612158576000805461ffff19166101011790555b612160612781565b61216a83836127eb565b8015611cf3576000805461ff0019169055505050565b600054610100900460ff1680612199575060005460ff16155b6121b55760405162461bcd60e51b815260040161065a90612e95565b600054610100900460ff161580156121d7576000805461ffff19166101011790555b6121df612781565b61220282604051806040016040528060018152602001603160f81b815250612880565b61220b8261290a565b8015610cae576000805461ff00191690555050565b600054610100900460ff1680612239575060005460ff16155b6122555760405162461bcd60e51b815260040161065a90612e95565b600054610100900460ff16158015612277576000805461ffff19166101011790555b61227f612781565b6116ff61299a565b600054610100900460ff16806122a0575060005460ff16155b6122bc5760405162461bcd60e51b815260040161065a90612e95565b600054610100900460ff161580156122de576000805461ffff19166101011790555b600180558015611243576000805461ff001916905550565b6001820154825460009190600160801b90046001600160801b03164281141561232157509050610676565b845460009061233c9084906001600160801b031684886126c7565b905082811461238b57600186018190556040518181526001600160a01b038816907f5777ca300dfe5bead41006fbce4389794dbc0ed8d6cccebfaf94630aa04184bc9060200160405180910390a25b85546001600160801b03428116600160801b029116178655925050509392505050565b6000611a1c6123bf6012600a612fca565b6123d36123cc86866129fa565b8790612a06565b90612a12565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a083111561241057506000905060036124bd565b8460ff16601b1415801561242857508460ff16601c14155b1561243957506000905060046124bd565b6040805160008082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa15801561248d573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b0381166124b6576000600192509250506124bd565b9150600090505b94509492505050565b60008160048111156124e857634e487b7160e01b600052602160045260246000fd5b14156124f15750565b600181600481111561251357634e487b7160e01b600052602160045260246000fd5b14156125615760405162461bcd60e51b815260206004820152601860248201527f45434453413a20696e76616c6964207369676e61747572650000000000000000604482015260640161065a565b600281600481111561258357634e487b7160e01b600052602160045260246000fd5b14156125d15760405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e67746800604482015260640161065a565b60038160048111156125f357634e487b7160e01b600052602160045260246000fd5b141561264c5760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c604482015261756560f01b606482015260840161065a565b600481600481111561266e57634e487b7160e01b600052602160045260246000fd5b14156112435760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202776272076616c604482015261756560f01b606482015260840161065a565b60008315806126d4575081155b806126e7575042836001600160801b0316145b806126fe575061013054836001600160801b031610155b1561270a575083611a1c565b600061013054421161271c5742612721565b610130545b90506000612738826001600160801b0387166129fa565b905061276787612761866123d36127516012600a612fca565b61275b8c88612a06565b90612a06565b90611a24565b979650505050505050565b6060611a1c8484600085612a1e565b600054610100900460ff168061279a575060005460ff16155b6127b65760405162461bcd60e51b815260040161065a90612e95565b600054610100900460ff161580156116ff576000805461ffff19166101011790558015611243576000805461ff001916905550565b600054610100900460ff1680612804575060005460ff16155b6128205760405162461bcd60e51b815260040161065a90612e95565b600054610100900460ff16158015612842576000805461ffff19166101011790555b8251612855906068906020860190612b6f565b508151612869906069906020850190612b6f565b508015611cf3576000805461ff0019169055505050565b600054610100900460ff1680612899575060005460ff16155b6128b55760405162461bcd60e51b815260040161065a90612e95565b600054610100900460ff161580156128d7576000805461ffff19166101011790555b82516020808501919091208351918401919091206097919091556098558015611cf3576000805461ff0019169055505050565b600054610100900460ff1680612923575060005460ff16155b61293f5760405162461bcd60e51b815260040161065a90612e95565b600054610100900460ff16158015612961576000805461ffff19166101011790555b7f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c960cc558015610cae576000805461ff00191690555050565b600054610100900460ff16806129b3575060005460ff16155b6129cf5760405162461bcd60e51b815260040161065a90612e95565b600054610100900460ff161580156129f1576000805461ffff19166101011790555b6116ff33611713565b600061067682846130d0565b600061067682846130b1565b60006106768284612f67565b606082471015612a7f5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b606482015260840161065a565b843b612acd5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015260640161065a565b600080866001600160a01b03168587604051612ae99190612e19565b60006040518083038185875af1925050503d8060008114612b26576040519150601f19603f3d011682016040523d82523d6000602084013e612b2b565b606091505b509150915061276782828660608315612b45575081610676565b825115612b555782518084602001fd5b8160405162461bcd60e51b815260040161065a9190612e35565b828054612b7b90613113565b90600052602060002090601f016020900481019282612b9d5760008555612be3565b82601f10612bb657805160ff1916838001178555612be3565b82800160010185558215612be3579182015b82811115612be3578251825591602001919060010190612bc8565b50612bef929150612bf3565b5090565b5b80821115612bef5760008155600101612bf4565b80356001600160a01b0381168114612c1f57600080fd5b919050565b80356001600160801b0381168114612c1f57600080fd5b600060208284031215612c4c578081fd5b61067682612c08565b60008060408385031215612c67578081fd5b612c7083612c08565b9150612c7e60208401612c08565b90509250929050565b60008060008060808587031215612c9c578182fd5b612ca585612c08565b9350612cb360208601612c08565b9250612cc160408601612c08565b9150612ccf60608601612c24565b905092959194509250565b600080600060608486031215612cee578283fd5b612cf784612c08565b9250612d0560208501612c08565b9150604084013590509250925092565b600080600080600080600060e0888a031215612d2f578283fd5b612d3888612c08565b9650612d4660208901612c08565b95506040880135945060608801359350608088013560ff81168114612d69578384fd5b9699959850939692959460a0840135945060c09093013592915050565b60008060408385031215612d98578182fd5b612da183612c08565b946020939093013593505050565b600060208284031215612dc0578081fd5b81518015158114610676578182fd5b600060208284031215612de0578081fd5b61067682612c24565b600060208284031215612dfa578081fd5b5035919050565b600060208284031215612e12578081fd5b5051919050565b60008251612e2b8184602087016130e7565b9190910192915050565b6020815260008251806020840152612e548160408501602087016130e7565b601f01601f19169190910160400192915050565b6020808252601390820152721253959053125117d6915493d7d05353d55395606a1b604082015260600190565b6020808252602e908201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160408201526d191e481a5b9a5d1a585b1a5e995960921b606082015260800190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b60008219821115612f6257612f62613163565b500190565b600082612f8257634e487b7160e01b81526012600452602481fd5b500490565b600181815b80851115612fc2578160001904821115612fa857612fa8613163565b80851615612fb557918102915b93841c9390800290612f8c565b509250929050565b60006106768383612fe1565b600061067660ff8416835b600082612ff0575060016105c6565b81612ffd575060006105c6565b8160018114613013576002811461301d57613039565b60019150506105c6565b60ff84111561302e5761302e613163565b50506001821b6105c6565b5060208310610133831016604e8410600b841016171561305c575081810a6105c6565b6130668383612f87565b806000190482111561307a5761307a613163565b029392505050565b60006001600160801b03808316818516818304811182151516156130a8576130a8613163565b02949350505050565b60008160001904831182151516156130cb576130cb613163565b500290565b6000828210156130e2576130e2613163565b500390565b60005b838110156131025781810151838201526020016130ea565b838111156113c55750506000910152565b600181811c9082168061312757607f821691505b60208210811415611b3157634e487b7160e01b600052602260045260246000fd5b600060001982141561315c5761315c613163565b5060010190565b634e487b7160e01b600052601160045260246000fdfea2646970667358221220b9322569a6c78ecf7209953cb9c4ab38011b9141c42d35dc6a57598aa11ec4a664736f6c63430008040033

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

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.