ETH Price: $2,591.90 (-3.54%)

Contract

0x76488832A88475AF0aC223d8FD4d053177A012cc
 

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:
Distribution

Compiler Version
v0.8.20+commit.a1b79de6

Optimization Enabled:
Yes with 200 runs

Other Settings:
paris EvmVersion
File 1 of 18 : Distribution.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

import {SafeERC20, IERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import {UUPSUpgradeable} from "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";
import {OwnableUpgradeable} from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";

import {PRECISION} from "@solarity/solidity-lib/utils/Globals.sol";

import {LinearDistributionIntervalDecrease} from "./libs/LinearDistributionIntervalDecrease.sol";

import {IDistribution} from "./interfaces/IDistribution.sol";

contract Distribution is IDistribution, OwnableUpgradeable, UUPSUpgradeable {
    using SafeERC20 for IERC20;

    address private refunderAddress;
    address private fallbackAddress;

    // Modifier to restrict access to the ejectStakedFunds call
    modifier onlyRefunder() {
        require(msg.sender == refunderAddress || msg.sender == fallbackAddress, "DS: Unauthorized to Refund");
        _;
    }

    bool public isNotUpgradeable;

    address public depositToken;
    address public aoDistributionWallet;

    // Pool storage
    Pool[] public pools;
    mapping(uint256 => PoolData) public poolsData;

    // User storage
    mapping(address => mapping(uint256 => UserData)) public usersData;

    // Total deposited storage
    uint256 public totalDepositedInPublicPools;

    /**********************************************************************************************/
    /*** Modifiers                                                                              ***/
    /**********************************************************************************************/
    modifier poolExists(uint256 poolId_) {
        require(_poolExists(poolId_), "DS: pool doesn't exist");
        _;
    }

    modifier poolPublic(uint256 poolId_) {
        require(pools[poolId_].isPublic, "DS: pool isn't public");
        _;
    }

    /**********************************************************************************************/
    /*** Init                                                                                   ***/
    /**********************************************************************************************/

    constructor() {
        _disableInitializers();
    }

    function Distribution_init(
        address depositToken_,
        address aoDistributionWallet_,
        Pool[] calldata poolsInfo_,
        address refunderAddress_,
        address fallbackAddress_
    ) external initializer {
        __Ownable_init();
        __UUPSUpgradeable_init();

        for (uint256 i; i < poolsInfo_.length; ++i) {
            createPool(poolsInfo_[i]);
        }

        // Setting the Multicall address
        refunderAddress = refunderAddress_;
        // Fallback address for non-multicall refunds
        fallbackAddress = fallbackAddress_;

        depositToken = depositToken_;
        aoDistributionWallet = aoDistributionWallet_;
    }

    /**********************************************************************************************/
    /*** Pool managment and data retrieval                                                      ***/
    /**********************************************************************************************/
    function createPool(Pool calldata pool_) public onlyOwner {
        require(pool_.payoutStart > block.timestamp, "DS: invalid payout start value");

        _validatePool(pool_);
        pools.push(pool_);

        emit PoolCreated(pools.length - 1, pool_);
    }

    function getPeriodReward(uint256 poolId_, uint128 startTime_, uint128 endTime_) public view returns (uint256) {
        if (!_poolExists(poolId_)) {
            return 0;
        }

        Pool storage pool = pools[poolId_];

        return
            LinearDistributionIntervalDecrease.getPeriodReward(
                pool.initialReward,
                pool.rewardDecrease,
                pool.payoutStart,
                pool.decreaseInterval,
                startTime_,
                endTime_
            );
    }

    function _validatePool(Pool calldata pool_) private pure {
        require(pool_.decreaseInterval > 0, "DS: invalid decrease interval");
    }

    /**********************************************************************************************/
    /*** Stake, withdraw                                                                 ***/
    /**********************************************************************************************/
    function stake(
        uint256 poolId_,
        uint256 amount_,
        bytes32 arweaveAddress_
    ) external poolExists(poolId_) poolPublic(poolId_) {
        _stake(_msgSender(), poolId_, amount_, _getCurrentPoolRate(poolId_), arweaveAddress_);
    }

    function withdraw(
        uint256 poolId_,
        uint256 amount_,
        bytes32 arweaveAddress_
    ) external poolExists(poolId_) poolPublic(poolId_) {
        _withdraw(_msgSender(), poolId_, amount_, _getCurrentPoolRate(poolId_), arweaveAddress_);
    }

    function getCurrentUserReward(uint256 poolId_, address user_) external view returns (uint256) {
        if (!_poolExists(poolId_)) {
            return 0;
        }

        UserData storage userData = usersData[user_][poolId_];
        uint256 currentPoolRate_ = _getCurrentPoolRate(poolId_);

        return _getCurrentUserReward(currentPoolRate_, userData);
    }

    function _stake(
        address user_,
        uint256 poolId_,
        uint256 amount_,
        uint256 currentPoolRate_,
        bytes32 arweaveAddress_
    ) private {
        require(amount_ > 0, "DS: nothing to stake");

        Pool storage pool = pools[poolId_];
        PoolData storage poolData = poolsData[poolId_];
        UserData storage userData = usersData[user_][poolId_];

        if (pool.isPublic) {
            // https://docs.lido.fi/guides/lido-tokens-integration-guide/#steth-internals-share-mechanics
            uint256 balanceBefore_ = IERC20(depositToken).balanceOf(address(this));
            IERC20(depositToken).safeTransferFrom(_msgSender(), address(this), amount_);
            uint256 balanceAfter_ = IERC20(depositToken).balanceOf(address(this));

            amount_ = balanceAfter_ - balanceBefore_;

            require(userData.deposited + amount_ >= pool.minimalStake, "DS: amount too low");

            totalDepositedInPublicPools += amount_;
        }

        userData.pendingRewards = _getCurrentUserReward(currentPoolRate_, userData);

        // Update pool data
        poolData.lastUpdate = uint128(block.timestamp);
        poolData.rate = currentPoolRate_;
        poolData.totalDeposited += amount_;

        // Update user data
        userData.lastStake = uint128(block.timestamp);
        userData.rate = currentPoolRate_;
        userData.deposited += amount_;

        emit UserStaked(poolId_, user_, amount_, arweaveAddress_);
    }

    function _withdraw(
        address user_,
        uint256 poolId_,
        uint256 amount_,
        uint256 currentPoolRate_,
        bytes32 arweaveAddress_
    ) private {
        Pool storage pool = pools[poolId_];
        PoolData storage poolData = poolsData[poolId_];
        UserData storage userData = usersData[user_][poolId_];

        uint256 deposited_ = userData.deposited;
        require(deposited_ > 0, "DS: user isn't staked");

        if (amount_ > deposited_) {
            amount_ = deposited_;
        }

        uint256 newDeposited_;
        if (pool.isPublic) {
            require(
                block.timestamp < pool.payoutStart ||
                    (block.timestamp > pool.payoutStart + pool.withdrawLockPeriod &&
                        block.timestamp > userData.lastStake + pool.withdrawLockPeriodAfterStake),
                "DS: pool withdraw is locked"
            );

            uint256 depositTokenContractBalance_ = IERC20(depositToken).balanceOf(address(this));
            if (amount_ > depositTokenContractBalance_) {
                amount_ = depositTokenContractBalance_;
            }

            newDeposited_ = deposited_ - amount_;

            require(amount_ > 0, "DS: nothing to withdraw");
            require(newDeposited_ >= pool.minimalStake || newDeposited_ == 0, "DS: invalid withdraw amount");
        } else {
            newDeposited_ = deposited_ - amount_;
        }

        uint256 pendingRewards_ = _getCurrentUserReward(currentPoolRate_, userData);

        // Update pool data
        poolData.lastUpdate = uint128(block.timestamp);
        poolData.rate = currentPoolRate_;
        poolData.totalDeposited -= amount_;

        // Update user data
        userData.rate = currentPoolRate_;
        userData.deposited = newDeposited_;
        userData.pendingRewards = pendingRewards_;

        if (pool.isPublic) {
            totalDepositedInPublicPools -= amount_;

            IERC20(depositToken).safeTransfer(user_, amount_);
        }

        emit UserWithdrawn(poolId_, user_, amount_, arweaveAddress_);
    }

    function _getCurrentUserReward(uint256 currentPoolRate_, UserData memory userData_) private pure returns (uint256) {
        uint256 newRewards_ = ((currentPoolRate_ - userData_.rate) * userData_.deposited) / PRECISION;

        return userData_.pendingRewards + newRewards_;
    }

    function _getCurrentPoolRate(uint256 poolId_) private view returns (uint256) {
        PoolData storage poolData = poolsData[poolId_];

        if (poolData.totalDeposited == 0) {
            return poolData.rate;
        }

        uint256 rewards_ = getPeriodReward(poolId_, poolData.lastUpdate, uint128(block.timestamp));

        return poolData.rate + (rewards_ * PRECISION) / poolData.totalDeposited;
    }

    function _poolExists(uint256 poolId_) private view returns (bool) {
        return poolId_ < pools.length;
    }

    /**********************************************************************************************/
    /*** Bridge                                                                                 ***/
    /**********************************************************************************************/

    function overplus() public view returns (uint256) {
        uint256 depositTokenContractBalance_ = IERC20(depositToken).balanceOf(address(this));
        if (depositTokenContractBalance_ <= totalDepositedInPublicPools) {
            return 0;
        }

        return depositTokenContractBalance_ - totalDepositedInPublicPools;
    }

    function bridgeOverplus() external {
        uint256 overplus_ = overplus();
        require(overplus_ > 0, "DS: overplus is zero");

        IERC20(depositToken).safeTransfer(aoDistributionWallet, overplus_);

        emit OverplusBridged(overplus_);
    }

    /**********************************************************************************************/
    /*** UUPS                                                                                   ***/
    /**********************************************************************************************/

    function removeUpgradeability() external onlyOwner {
        isNotUpgradeable = true;
    }

    function _authorizeUpgrade(address) internal view override onlyOwner {
        require(!isNotUpgradeable, "DS: upgrade isn't available");
    }

    /**********************************************************************************************/
    /*** Ejection Handling                                                                                ***/
    /**********************************************************************************************/

    // Helper function to safely reduce values ensuring no underflow occurs
    function safeReduce(uint256 total, uint256 amount) private pure returns (uint256) {
        return amount > total ? total : amount;
    }

    function ejectStakedFunds(uint256 poolId, address user) external onlyRefunder {
        require(user != address(0), "DS: user is the zero address");

        UserData storage userData = usersData[user][poolId];
        uint256 amountToTransfer = userData.deposited;
        if (amountToTransfer > 0) {
            // Clear userData to prepare for transfer
            userData.deposited = 0;
            userData.pendingRewards = 0;
            userData.rate = 0;

            // Update pool and global state before transferring funds
            PoolData storage poolData = poolsData[poolId];
            Pool storage pool = pools[poolId];

            // Reduce the total deposited amount in the pool data
            uint256 actualAmountToTransfer = safeReduce(poolData.totalDeposited, amountToTransfer);
            poolData.totalDeposited -= actualAmountToTransfer;

            if (pool.isPublic) {
                actualAmountToTransfer = safeReduce(totalDepositedInPublicPools, amountToTransfer);
                totalDepositedInPublicPools -= actualAmountToTransfer;
            }

            // Perform the transfer
            IERC20(depositToken).safeTransfer(user, actualAmountToTransfer);

            bytes32 zeroBytes_ = 0x0000000000000000000000000000000000000000000000000000000000000000;

            // Emit successful withdrawal event
            emit UserWithdrawn(poolId, user, amountToTransfer, zeroBytes_);
        }
    }
}

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

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 onlyInitializing {
        __Ownable_init_unchained();
    }

    function __Ownable_init_unchained() internal onlyInitializing {
        _transferOwnership(_msgSender());
    }

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

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

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

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

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

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

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

File 3 of 18 : draft-IERC1822Upgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (interfaces/draft-IERC1822.sol)

pragma solidity ^0.8.0;

/**
 * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified
 * proxy whose upgrades are fully controlled by the current implementation.
 */
interface IERC1822ProxiableUpgradeable {
    /**
     * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation
     * address.
     *
     * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks
     * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this
     * function revert if invoked through a proxy.
     */
    function proxiableUUID() external view returns (bytes32);
}

File 4 of 18 : IERC1967Upgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (interfaces/IERC1967.sol)

pragma solidity ^0.8.0;

/**
 * @dev ERC-1967: Proxy Storage Slots. This interface contains the events defined in the ERC.
 *
 * _Available since v4.8.3._
 */
interface IERC1967Upgradeable {
    /**
     * @dev Emitted when the implementation is upgraded.
     */
    event Upgraded(address indexed implementation);

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

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

File 5 of 18 : IBeaconUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)

pragma solidity ^0.8.0;

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

File 6 of 18 : ERC1967UpgradeUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (proxy/ERC1967/ERC1967Upgrade.sol)

pragma solidity ^0.8.2;

import "../beacon/IBeaconUpgradeable.sol";
import "../../interfaces/IERC1967Upgradeable.sol";
import "../../interfaces/draft-IERC1822Upgradeable.sol";
import "../../utils/AddressUpgradeable.sol";
import "../../utils/StorageSlotUpgradeable.sol";
import "../utils/Initializable.sol";

/**
 * @dev This abstract contract provides getters and event emitting update functions for
 * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.
 *
 * _Available since v4.1._
 */
abstract contract ERC1967UpgradeUpgradeable is Initializable, IERC1967Upgradeable {
    function __ERC1967Upgrade_init() internal onlyInitializing {
    }

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

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

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

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

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

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

    /**
     * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.
     *
     * Emits an {Upgraded} event.
     */
    function _upgradeToAndCallUUPS(address newImplementation, bytes memory data, bool forceCall) internal {
        // Upgrades from old implementations will perform a rollback test. This test requires the new
        // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing
        // this special case will break upgrade paths from old UUPS implementation to new ones.
        if (StorageSlotUpgradeable.getBooleanSlot(_ROLLBACK_SLOT).value) {
            _setImplementation(newImplementation);
        } else {
            try IERC1822ProxiableUpgradeable(newImplementation).proxiableUUID() returns (bytes32 slot) {
                require(slot == _IMPLEMENTATION_SLOT, "ERC1967Upgrade: unsupported proxiableUUID");
            } catch {
                revert("ERC1967Upgrade: new implementation is not UUPS");
            }
            _upgradeToAndCall(newImplementation, data, forceCall);
        }
    }

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

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

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

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

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

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

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

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

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

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

pragma solidity ^0.8.2;

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

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

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

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

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

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

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

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

    /**
     * @dev Returns the highest version that has been initialized. See {reinitializer}.
     */
    function _getInitializedVersion() internal view returns (uint8) {
        return _initialized;
    }

    /**
     * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.
     */
    function _isInitializing() internal view returns (bool) {
        return _initializing;
    }
}

File 8 of 18 : UUPSUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (proxy/utils/UUPSUpgradeable.sol)

pragma solidity ^0.8.0;

import "../../interfaces/draft-IERC1822Upgradeable.sol";
import "../ERC1967/ERC1967UpgradeUpgradeable.sol";
import "./Initializable.sol";

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

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

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

    /**
     * @dev Check that the execution is not being performed through a delegate call. This allows a function to be
     * callable on the implementing contract but not through proxies.
     */
    modifier notDelegated() {
        require(address(this) == __self, "UUPSUpgradeable: must not be called through delegatecall");
        _;
    }

    /**
     * @dev Implementation of the ERC1822 {proxiableUUID} function. This returns the storage slot used by the
     * implementation. It is used to validate the implementation's compatibility when performing an upgrade.
     *
     * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks
     * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this
     * function revert if invoked through a proxy. This is guaranteed by the `notDelegated` modifier.
     */
    function proxiableUUID() external view virtual override notDelegated returns (bytes32) {
        return _IMPLEMENTATION_SLOT;
    }

    /**
     * @dev Upgrade the implementation of the proxy to `newImplementation`.
     *
     * Calls {_authorizeUpgrade}.
     *
     * Emits an {Upgraded} event.
     *
     * @custom:oz-upgrades-unsafe-allow-reachable delegatecall
     */
    function upgradeTo(address newImplementation) public virtual onlyProxy {
        _authorizeUpgrade(newImplementation);
        _upgradeToAndCallUUPS(newImplementation, new bytes(0), false);
    }

    /**
     * @dev Upgrade the implementation of the proxy to `newImplementation`, and subsequently execute the function call
     * encoded in `data`.
     *
     * Calls {_authorizeUpgrade}.
     *
     * Emits an {Upgraded} event.
     *
     * @custom:oz-upgrades-unsafe-allow-reachable delegatecall
     */
    function upgradeToAndCall(address newImplementation, bytes memory data) public payable virtual onlyProxy {
        _authorizeUpgrade(newImplementation);
        _upgradeToAndCallUUPS(newImplementation, data, true);
    }

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

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

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

pragma solidity ^0.8.1;

/**
 * @dev Collection of functions related to the address type
 */
library 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
     *
     * Furthermore, `isContract` will also return true if the target contract within
     * the same transaction is already scheduled for destruction by `SELFDESTRUCT`,
     * which only has an effect at the end of a transaction.
     * ====
     *
     * [IMPORTANT]
     * ====
     * You shouldn't rely on `isContract` to protect against flash loan attacks!
     *
     * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
     * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
     * constructor.
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // This method relies on extcodesize/address.code.length, which returns 0
        // for contracts in construction, since the code is only stored at the end
        // of the constructor execution.

        return account.code.length > 0;
    }

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

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

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

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

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

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

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

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

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

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

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

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

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

File 10 of 18 : ContextUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)

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

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

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

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

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

File 11 of 18 : StorageSlotUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/StorageSlot.sol)
// This file was procedurally generated from scripts/generate/templates/StorageSlot.js.

pragma solidity ^0.8.0;

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

    struct BooleanSlot {
        bool value;
    }

    struct Bytes32Slot {
        bytes32 value;
    }

    struct Uint256Slot {
        uint256 value;
    }

    struct StringSlot {
        string value;
    }

    struct BytesSlot {
        bytes value;
    }

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

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

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

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

    /**
     * @dev Returns an `StringSlot` with member `value` located at `slot`.
     */
    function getStringSlot(bytes32 slot) internal pure returns (StringSlot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := slot
        }
    }

    /**
     * @dev Returns an `StringSlot` representation of the string storage pointer `store`.
     */
    function getStringSlot(string storage store) internal pure returns (StringSlot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := store.slot
        }
    }

    /**
     * @dev Returns an `BytesSlot` with member `value` located at `slot`.
     */
    function getBytesSlot(bytes32 slot) internal pure returns (BytesSlot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := slot
        }
    }

    /**
     * @dev Returns an `BytesSlot` representation of the bytes storage pointer `store`.
     */
    function getBytesSlot(bytes storage store) internal pure returns (BytesSlot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := store.slot
        }
    }
}

File 12 of 18 : IERC20Permit.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/extensions/IERC20Permit.sol)

pragma solidity ^0.8.0;

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

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

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

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

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

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

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

pragma solidity ^0.8.1;

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

        return account.code.length > 0;
    }

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

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

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

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

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

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

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

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

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

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

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

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

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

File 16 of 18 : Globals.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;

uint256 constant PRECISION = 10 ** 25;
uint256 constant DECIMAL = 10 ** 18;
uint256 constant PERCENTAGE_100 = 10 ** 27;

File 17 of 18 : IDistribution.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

/**
 * This is Distribution contract that stores all the pools and users data.
 * It is used to calculate the user's rewards and operate with overpluses.
 */
interface IDistribution {
    /**
     * The structure that stores the core pool's data.
     * @param payoutStart The timestamp when the pool starts to pay out rewards.
     * @param decreaseInterval The interval in seconds between reward decreases.
     * @param withdrawLockPeriod The period in seconds when the user can't withdraw his stake.
     * @param withdrawLockPeriodAfterStake The period in seconds when the user can't withdraw his stake after staking.
     * @param claimLockPeriod The period in seconds when the user can't claim his rewards.
     * @param initialReward The initial reward per interval.
     * @param rewardDecrease The reward decrease per interval.
     * @param minimalStake The minimal stake amount.
     * @param isPublic The flag that indicates if the pool is public.
     */
    struct Pool {
        uint128 payoutStart;
        uint128 decreaseInterval;
        uint128 withdrawLockPeriod;
        uint128 claimLockPeriod;
        uint128 withdrawLockPeriodAfterStake;
        uint256 initialReward;
        uint256 rewardDecrease;
        uint256 minimalStake;
        bool isPublic;
    }

    /**
     * The structure that stores the pool's rate data.
     * @param lastUpdate The timestamp when the pool was updated.
     * @param rate The current reward rate.
     * @param totalDeposited The total amount of tokens deposited in the pool.
     */
    struct PoolData {
        uint128 lastUpdate;
        uint256 rate;
        uint256 totalDeposited;
    }

    /**
     * The structure that stores the user's rate data of pool.
     * @param lastStake The timestamp when the user last staked tokens.
     * @param deposited The amount of tokens deposited in the pool.
     * @param rate The current reward rate.
     * @param pendingRewards The amount of pending rewards.
     */
    struct UserData {
        uint128 lastStake;
        uint256 deposited;
        uint256 rate;
        uint256 pendingRewards;
    }

    /**
     * The event that is emitted when the pool is created.
     * @param poolId The pool's id.
     * @param pool The pool's data.
     */
    event PoolCreated(uint256 indexed poolId, Pool pool);

    /**
     * The event that is emitted when the pool is edited.
     * @param poolId The pool's id.
     * @param pool The pool's data.
     */
    event PoolEdited(uint256 indexed poolId, Pool pool);

    /**
     * The event that is emitted when the user stakes tokens in the pool.
     * @param poolId The pool's id.
     * @param user The user's address.
     * @param amount The amount of tokens.
     * @param arweaveAddress The arweave address.
     */
    event UserStaked(uint256 indexed poolId, address indexed user, uint256 amount, bytes32 arweaveAddress);

    /**
     * The event that is emitted when the user claims rewards from the pool.
     * @param poolId The pool's id.
     * @param user The user's address.
     * @param receiver The receiver's address.
     * @param amount The amount of tokens.
     */
    event UserClaimed(uint256 indexed poolId, address indexed user, address receiver, uint256 amount);

    /**
     * The event that is emitted when the user withdraws tokens from the pool.
     * @param poolId The pool's id.
     * @param user The user's address.
     * @param amount The amount of tokens.
     * @param arweaveAddress The arweave address.
     */
    event UserWithdrawn(uint256 indexed poolId, address indexed user, uint256 amount, bytes32 arweaveAddress);

    /**
     * The event that is emitted when the overplus of the deposit tokens is bridged.
     */
    event OverplusBridged(uint256 amount);

    /**
     * The function to initialize the contract.
     * @param depositToken_ The address of deposit token.
     * @param aoDistributionWallet_ The address of distribution wallet.
     * @param poolsInfo_ The array of initial pools.
     */
    function Distribution_init(
        address depositToken_,
        address aoDistributionWallet_,
        Pool[] calldata poolsInfo_,
        address refunderAddress,
        address fallbackAddress
    ) external;

    /**
     * The function to create a new pool.
     * @param pool_ The pool's data.
     */
    function createPool(Pool calldata pool_) external;

    /**
     * The function to calculate the total pool's reward for the specified period.
     * @param poolId_ The pool's id.
     * @param startTime_ The start timestamp.
     * @param endTime_ The end timestamp.
     * @return The total reward amount.
     */
    function getPeriodReward(uint256 poolId_, uint128 startTime_, uint128 endTime_) external view returns (uint256);

    /**
     * The function to stake tokens in the public pool.
     * @param poolId_ The pool's id.
     * @param amount_ The amount of tokens to stake.
     * @param arweaveAddress_ The arweave address.
     */
    function stake(uint256 poolId_, uint256 amount_, bytes32 arweaveAddress_) external;

    /**
     * The function to withdraw tokens from the pool.
     * @param poolId_ The pool's id.
     * @param amount_ The amount of tokens to withdraw.
     * @param arweaveAddress_ The arweave address.
     */
    function withdraw(uint256 poolId_, uint256 amount_, bytes32 arweaveAddress_) external;

    /**
     * The function to get the user's reward for the specified pool.
     * @param poolId_ The pool's id.
     * @param user_ The user's address.
     * @return The user's reward amount.
     */
    function getCurrentUserReward(uint256 poolId_, address user_) external view returns (uint256);

    /**
     * The function to calculate the total overplus of the staked deposit tokens.
     * @return The total overplus amount.
     */
    function overplus() external view returns (uint256);

    /**
     * The function to bridge the overplus of the staked deposit tokens.
     */
    function bridgeOverplus() external;

    /**
     * The function to remove upgradeability.
     */
    function removeUpgradeability() external;

    /**
     * The function to check if the contract is upgradeable.
     * @return The flag that indicates if the contract is upgradeable.
     */
    function isNotUpgradeable() external view returns (bool);

    /**
     * The function to get the address of deposit token.
     * @return The address of deposit token.
     */
    function depositToken() external view returns (address);

    /**
     * The function to get the address of bridge contract.
     * @return The address of bridge contract.
     */
    function aoDistributionWallet() external view returns (address);

    /**
     * The function to get the amount of deposit tokens that are staked in all of the public pools.
     * @dev The value accumulates the amount amount despite the rate differences.
     * @return The amount of deposit tokens.
     */
    function totalDepositedInPublicPools() external view returns (uint256);

    /**
     * The function to eject funds for a user.
     * Can only be called by the Refunder contract.
     * @param poolId The pool's id.
     * @param user The address of the user to refund.
     */
    function ejectStakedFunds(uint256 poolId, address user) external;
}

File 18 of 18 : LinearDistributionIntervalDecrease.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

/**
 * This is the library that calculates the reward for the period with linear distribution and interval decrease.
 * Supports the constant reward amount (decreaseAmount_ = 0)
 */
library LinearDistributionIntervalDecrease {
    /**
     * The function to calculate the reward for the period.
     * @param initialAmount_ The initial reward amount.
     * @param decreaseAmount_ The reward decrease amount.
     * @param payoutStart_ The timestamp when the period starts to pay out rewards.
     * @param interval_ The interval in seconds between reward decreases.
     * @param startTime_ The timestamp when the period starts.
     * @param endTime_ The timestamp when the period ends.
     * @return The reward amount.
     */
    function getPeriodReward(
        uint256 initialAmount_,
        uint256 decreaseAmount_,
        uint128 payoutStart_,
        uint128 interval_,
        uint128 startTime_,
        uint128 endTime_
    ) external pure returns (uint256) {
        if (interval_ == 0) {
            return 0;
        }

        // 'startTime_' can't be less than 'payoutStart_'
        if (startTime_ < payoutStart_) {
            startTime_ = payoutStart_;
        }

        uint128 maxEndTime_ = _calculateMaxEndTime(payoutStart_, interval_, initialAmount_, decreaseAmount_);

        if (endTime_ > maxEndTime_) {
            endTime_ = maxEndTime_;
        }

        // Return 0 when calculation 'startTime_' is bigger then 'endTime_'...
        if (startTime_ >= endTime_) {
            return 0;
        }

        // Calculate interval that less then 'interval_' range
        uint256 timePassedBefore_ = startTime_ - payoutStart_;
        if ((timePassedBefore_ / interval_) == ((endTime_ - payoutStart_) / interval_)) {
            uint256 intervalsPassed_ = timePassedBefore_ / interval_;
            uint256 intervalFullReward_ = initialAmount_ - intervalsPassed_ * decreaseAmount_;

            return (intervalFullReward_ * (endTime_ - startTime_)) / interval_;
        }

        // Calculate interval that more then 'interval_' range
        uint256 firstPeriodReward_ = _calculatePartPeriodReward(
            payoutStart_,
            startTime_,
            interval_,
            initialAmount_,
            decreaseAmount_,
            true
        );

        uint256 secondPeriodReward_ = _calculateFullPeriodReward(
            payoutStart_,
            startTime_,
            endTime_,
            interval_,
            initialAmount_,
            decreaseAmount_
        );

        uint256 thirdPeriodReward_ = _calculatePartPeriodReward(
            payoutStart_,
            endTime_,
            interval_,
            initialAmount_,
            decreaseAmount_,
            false
        );

        return firstPeriodReward_ + secondPeriodReward_ + thirdPeriodReward_;
    }

    function _calculateMaxEndTime(
        uint128 payoutStart_,
        uint128 interval_,
        uint256 initialAmount_,
        uint256 decreaseAmount_
    ) private pure returns (uint128) {
        if (decreaseAmount_ == 0) {
            return type(uint128).max;
        }

        uint256 maxIntervals_ = _divideCeil(initialAmount_, decreaseAmount_);

        return uint128(payoutStart_ + maxIntervals_ * interval_);
    }

    function _calculatePartPeriodReward(
        uint128 payoutStart_,
        uint128 startTime_,
        uint128 interval_,
        uint256 initialAmount_,
        uint256 decreaseAmount_,
        bool toEnd_
    ) private pure returns (uint256) {
        uint256 intervalsPassed_ = (startTime_ - payoutStart_) / interval_;
        uint256 decreaseRewardAmount_ = intervalsPassed_ * decreaseAmount_;
        if (decreaseRewardAmount_ >= initialAmount_) {
            return 0;
        }
        uint256 intervalFullReward_ = initialAmount_ - decreaseRewardAmount_;

        uint256 intervalPart_;
        if (toEnd_) {
            intervalPart_ = interval_ * (intervalsPassed_ + 1) + payoutStart_ - startTime_;
        } else {
            intervalPart_ = startTime_ - interval_ * intervalsPassed_ - payoutStart_;
        }

        if (intervalPart_ == interval_) {
            return 0;
        }

        return (intervalFullReward_ * intervalPart_) / interval_;
    }

    function _calculateFullPeriodReward(
        uint128 payoutStart_,
        uint128 startTime_,
        uint128 endTime_,
        uint128 interval_,
        uint256 initialAmount_,
        uint256 decreaseAmount_
    ) private pure returns (uint256) {
        // START calculate initial reward when period start
        uint256 timePassedBefore_ = startTime_ - payoutStart_;
        uint256 intervalsPassedBefore_ = _divideCeil(timePassedBefore_, interval_);

        uint256 decreaseRewardAmount_ = intervalsPassedBefore_ * decreaseAmount_;

        if (decreaseRewardAmount_ >= initialAmount_) {
            return 0;
        }

        uint256 initialReward_ = initialAmount_ - decreaseRewardAmount_;
        // END

        // Intervals passed
        uint256 ip_ = ((endTime_ - payoutStart_ - intervalsPassedBefore_ * interval_) / interval_);
        if (ip_ == 0) {
            return 0;
        }

        return initialReward_ * ip_ - (decreaseAmount_ * (ip_ * (ip_ - 1))) / 2;
    }

    function _divideCeil(uint256 a_, uint256 b_) private pure returns (uint256) {
        return (a_ + b_ - 1) / b_;
    }
}

Settings
{
  "optimizer": {
    "enabled": true,
    "runs": 200
  },
  "evmVersion": "paris",
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  },
  "libraries": {
    "contracts/libs/LinearDistributionIntervalDecrease.sol": {
      "LinearDistributionIntervalDecrease": "0x7e209b1833ae5313c2923116c78baedf14d1d482"
    }
  }
}

Contract Security Audit

Contract ABI

[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"previousAdmin","type":"address"},{"indexed":false,"internalType":"address","name":"newAdmin","type":"address"}],"name":"AdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"beacon","type":"address"}],"name":"BeaconUpgraded","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"version","type":"uint8"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"OverplusBridged","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":"uint256","name":"poolId","type":"uint256"},{"components":[{"internalType":"uint128","name":"payoutStart","type":"uint128"},{"internalType":"uint128","name":"decreaseInterval","type":"uint128"},{"internalType":"uint128","name":"withdrawLockPeriod","type":"uint128"},{"internalType":"uint128","name":"claimLockPeriod","type":"uint128"},{"internalType":"uint128","name":"withdrawLockPeriodAfterStake","type":"uint128"},{"internalType":"uint256","name":"initialReward","type":"uint256"},{"internalType":"uint256","name":"rewardDecrease","type":"uint256"},{"internalType":"uint256","name":"minimalStake","type":"uint256"},{"internalType":"bool","name":"isPublic","type":"bool"}],"indexed":false,"internalType":"struct IDistribution.Pool","name":"pool","type":"tuple"}],"name":"PoolCreated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"poolId","type":"uint256"},{"components":[{"internalType":"uint128","name":"payoutStart","type":"uint128"},{"internalType":"uint128","name":"decreaseInterval","type":"uint128"},{"internalType":"uint128","name":"withdrawLockPeriod","type":"uint128"},{"internalType":"uint128","name":"claimLockPeriod","type":"uint128"},{"internalType":"uint128","name":"withdrawLockPeriodAfterStake","type":"uint128"},{"internalType":"uint256","name":"initialReward","type":"uint256"},{"internalType":"uint256","name":"rewardDecrease","type":"uint256"},{"internalType":"uint256","name":"minimalStake","type":"uint256"},{"internalType":"bool","name":"isPublic","type":"bool"}],"indexed":false,"internalType":"struct IDistribution.Pool","name":"pool","type":"tuple"}],"name":"PoolEdited","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"implementation","type":"address"}],"name":"Upgraded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"poolId","type":"uint256"},{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"address","name":"receiver","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"UserClaimed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"poolId","type":"uint256"},{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"bytes32","name":"arweaveAddress","type":"bytes32"}],"name":"UserStaked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"poolId","type":"uint256"},{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"bytes32","name":"arweaveAddress","type":"bytes32"}],"name":"UserWithdrawn","type":"event"},{"inputs":[{"internalType":"address","name":"depositToken_","type":"address"},{"internalType":"address","name":"aoDistributionWallet_","type":"address"},{"components":[{"internalType":"uint128","name":"payoutStart","type":"uint128"},{"internalType":"uint128","name":"decreaseInterval","type":"uint128"},{"internalType":"uint128","name":"withdrawLockPeriod","type":"uint128"},{"internalType":"uint128","name":"claimLockPeriod","type":"uint128"},{"internalType":"uint128","name":"withdrawLockPeriodAfterStake","type":"uint128"},{"internalType":"uint256","name":"initialReward","type":"uint256"},{"internalType":"uint256","name":"rewardDecrease","type":"uint256"},{"internalType":"uint256","name":"minimalStake","type":"uint256"},{"internalType":"bool","name":"isPublic","type":"bool"}],"internalType":"struct IDistribution.Pool[]","name":"poolsInfo_","type":"tuple[]"},{"internalType":"address","name":"refunderAddress_","type":"address"},{"internalType":"address","name":"fallbackAddress_","type":"address"}],"name":"Distribution_init","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"aoDistributionWallet","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"bridgeOverplus","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"uint128","name":"payoutStart","type":"uint128"},{"internalType":"uint128","name":"decreaseInterval","type":"uint128"},{"internalType":"uint128","name":"withdrawLockPeriod","type":"uint128"},{"internalType":"uint128","name":"claimLockPeriod","type":"uint128"},{"internalType":"uint128","name":"withdrawLockPeriodAfterStake","type":"uint128"},{"internalType":"uint256","name":"initialReward","type":"uint256"},{"internalType":"uint256","name":"rewardDecrease","type":"uint256"},{"internalType":"uint256","name":"minimalStake","type":"uint256"},{"internalType":"bool","name":"isPublic","type":"bool"}],"internalType":"struct IDistribution.Pool","name":"pool_","type":"tuple"}],"name":"createPool","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"depositToken","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"poolId","type":"uint256"},{"internalType":"address","name":"user","type":"address"}],"name":"ejectStakedFunds","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"poolId_","type":"uint256"},{"internalType":"address","name":"user_","type":"address"}],"name":"getCurrentUserReward","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"poolId_","type":"uint256"},{"internalType":"uint128","name":"startTime_","type":"uint128"},{"internalType":"uint128","name":"endTime_","type":"uint128"}],"name":"getPeriodReward","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"isNotUpgradeable","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"overplus","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"pools","outputs":[{"internalType":"uint128","name":"payoutStart","type":"uint128"},{"internalType":"uint128","name":"decreaseInterval","type":"uint128"},{"internalType":"uint128","name":"withdrawLockPeriod","type":"uint128"},{"internalType":"uint128","name":"claimLockPeriod","type":"uint128"},{"internalType":"uint128","name":"withdrawLockPeriodAfterStake","type":"uint128"},{"internalType":"uint256","name":"initialReward","type":"uint256"},{"internalType":"uint256","name":"rewardDecrease","type":"uint256"},{"internalType":"uint256","name":"minimalStake","type":"uint256"},{"internalType":"bool","name":"isPublic","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"poolsData","outputs":[{"internalType":"uint128","name":"lastUpdate","type":"uint128"},{"internalType":"uint256","name":"rate","type":"uint256"},{"internalType":"uint256","name":"totalDeposited","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"proxiableUUID","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"removeUpgradeability","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"poolId_","type":"uint256"},{"internalType":"uint256","name":"amount_","type":"uint256"},{"internalType":"bytes32","name":"arweaveAddress_","type":"bytes32"}],"name":"stake","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"totalDepositedInPublicPools","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newImplementation","type":"address"}],"name":"upgradeTo","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newImplementation","type":"address"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"upgradeToAndCall","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"usersData","outputs":[{"internalType":"uint128","name":"lastStake","type":"uint128"},{"internalType":"uint256","name":"deposited","type":"uint256"},{"internalType":"uint256","name":"rate","type":"uint256"},{"internalType":"uint256","name":"pendingRewards","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"poolId_","type":"uint256"},{"internalType":"uint256","name":"amount_","type":"uint256"},{"internalType":"bytes32","name":"arweaveAddress_","type":"bytes32"}],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"}]

60a0604052306080523480156200001557600080fd5b506200002062000026565b620000e7565b600054610100900460ff1615620000935760405162461bcd60e51b815260206004820152602760248201527f496e697469616c697a61626c653a20636f6e747261637420697320696e697469604482015266616c697a696e6760c81b606482015260840160405180910390fd5b60005460ff90811614620000e5576000805460ff191660ff9081179091556040519081527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b565b6080516129516200011f6000396000818161052001528181610569015281816107b9015281816107f9015261088c01526129516000f3fe6080604052600436106101405760003560e01c80638901579e116100b6578063d2ba5e3a1161006f578063d2ba5e3a14610404578063dd2518f31461041a578063e0b4b3861461043a578063f2fde38b1461046b578063f343e8581461048b578063f3b122e0146104f657600080fd5b80638901579e146102ed5780638da5cb5b14610302578063a06b2a3914610334578063ac4afa3814610354578063beee9fa9146103cf578063c89039c5146103e457600080fd5b806352d1902d1161010857806352d1902d14610240578063535f583f146102635780635bd2e38714610283578063715018a6146102a357806378df87b2146102b85780638468a4c4146102cd57600080fd5b806330dc6308146101455780633659cfe6146101cb5780633756c011146101ed5780633d0a42e71461020d5780634f1ef2861461022d575b600080fd5b34801561015157600080fd5b5061019c6101603660046121bc565b60cf60209081526000928352604080842090915290825290208054600182015460028301546003909301546001600160801b0390921692909184565b604080516001600160801b03909516855260208501939093529183015260608201526080015b60405180910390f35b3480156101d757600080fd5b506101eb6101e63660046121e6565b610516565b005b3480156101f957600080fd5b506101eb610208366004612201565b6105fe565b34801561021957600080fd5b506101eb610228366004612201565b6106da565b6101eb61023b366004612243565b6107af565b34801561024c57600080fd5b5061025561087f565b6040519081526020016101c2565b34801561026f57600080fd5b5061025561027e366004612325565b610932565b34801561028f57600080fd5b506101eb61029e366004612367565b610a33565b3480156102af57600080fd5b506101eb610b34565b3480156102c457600080fd5b50610255610b48565b3480156102d957600080fd5b506102556102e8366004612380565b610bdf565b3480156102f957600080fd5b506101eb610c75565b34801561030e57600080fd5b506033546001600160a01b03165b6040516001600160a01b0390911681526020016101c2565b34801561034057600080fd5b5060cc5461031c906001600160a01b031681565b34801561036057600080fd5b5061037461036f3660046123ac565b610d1b565b604080516001600160801b039a8b168152988a1660208a015296891696880196909652938716606087015295909116608085015260a084015260c083019390935260e0820192909252901515610100820152610120016101c2565b3480156103db57600080fd5b506101eb610d89565b3480156103f057600080fd5b5060cb5461031c906001600160a01b031681565b34801561041057600080fd5b5061025560d05481565b34801561042657600080fd5b506101eb610435366004612380565b610da6565b34801561044657600080fd5b5060ca5461045b90600160a01b900460ff1681565b60405190151581526020016101c2565b34801561047757600080fd5b506101eb6104863660046121e6565b610fad565b34801561049757600080fd5b506104d16104a63660046123ac565b60ce602052600090815260409020805460018201546002909201546001600160801b03909116919083565b604080516001600160801b0390941684526020840192909252908201526060016101c2565b34801561050257600080fd5b506101eb6105113660046123c5565b611023565b6001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001630036105675760405162461bcd60e51b815260040161055e9061247d565b60405180910390fd5b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166105b06000805160206128d5833981519152546001600160a01b031690565b6001600160a01b0316146105d65760405162461bcd60e51b815260040161055e906124c9565b6105df816111c9565b604080516000808252602082019092526105fb9183919061122b565b50565b8261060a8160cd541190565b61064f5760405162461bcd60e51b81526020600482015260166024820152751114ce881c1bdbdb08191bd95cdb89dd08195e1a5cdd60521b604482015260640161055e565b8360cd818154811061066357610663612515565b600091825260209091206006600790920201015460ff166106be5760405162461bcd60e51b815260206004820152601560248201527444533a20706f6f6c2069736e2774207075626c696360581b604482015260640161055e565b6106d33386866106cd8961139b565b87611416565b5050505050565b826106e68160cd541190565b61072b5760405162461bcd60e51b81526020600482015260166024820152751114ce881c1bdbdb08191bd95cdb89dd08195e1a5cdd60521b604482015260640161055e565b8360cd818154811061073f5761073f612515565b600091825260209091206006600790920201015460ff1661079a5760405162461bcd60e51b815260206004820152601560248201527444533a20706f6f6c2069736e2774207075626c696360581b604482015260640161055e565b6106d33386866107a98961139b565b876117f3565b6001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001630036107f75760405162461bcd60e51b815260040161055e9061247d565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166108406000805160206128d5833981519152546001600160a01b031690565b6001600160a01b0316146108665760405162461bcd60e51b815260040161055e906124c9565b61086f826111c9565b61087b8282600161122b565b5050565b6000306001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000161461091f5760405162461bcd60e51b815260206004820152603860248201527f555550535570677261646561626c653a206d757374206e6f742062652063616c60448201527f6c6564207468726f7567682064656c656761746563616c6c0000000000000000606482015260840161055e565b506000805160206128d583398151915290565b600061093f8460cd541190565b61094b57506000610a2c565b600060cd858154811061096057610960612515565b6000918252602090912060079091020160038101546004808301548354604051638ef1035b60e01b81529283019390935260248201526001600160801b038083166044830152600160801b90920482166064820152868216608482015290851660a4820152909150737e209b1833ae5313c2923116c78baedf14d1d48290638ef1035b9060c401602060405180830381865af4158015610a04573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a28919061252b565b9150505b9392505050565b610a3b611b10565b42610a496020830183612544565b6001600160801b031611610a9f5760405162461bcd60e51b815260206004820152601e60248201527f44533a20696e76616c6964207061796f75742073746172742076616c75650000604482015260640161055e565b610aa881611b6a565b60cd805460018101825560009190915281906007027f83978b4c69c48dd978ab43fe30f077615294f938fb7f936d9eb340e51ea7db2e01610ae98282612589565b505060cd54610afa90600190612691565b7f9b9b09f76d4db7c7b0d783b9ba64d003e95462ef13cbb7cb782d74b085548cac82604051610b2991906126af565b60405180910390a250565b610b3c611b10565b610b466000611bd2565b565b60cb546040516370a0823160e01b815230600482015260009182916001600160a01b03909116906370a0823190602401602060405180830381865afa158015610b95573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bb9919061252b565b905060d0548111610bcc57600091505090565b60d054610bd99082612691565b91505090565b6000610bec8360cd541190565b610bf857506000610c6f565b6001600160a01b038216600090815260cf60209081526040808320868452909152812090610c258561139b565b6040805160808101825284546001600160801b031681526001850154602082015260028501549181019190915260038401546060820152909150610c6a908290611c24565b925050505b92915050565b6000610c7f610b48565b905060008111610cc85760405162461bcd60e51b815260206004820152601460248201527344533a206f766572706c7573206973207a65726f60601b604482015260640161055e565b60cc5460cb54610ce5916001600160a01b03918216911683611c6e565b6040518181527f1c1beeacf263316031be95f61cdcab6d052033248371579d5a954667ee9df8ad9060200160405180910390a150565b60cd8181548110610d2b57600080fd5b600091825260209091206007909102018054600182015460028301546003840154600485015460058601546006909601546001600160801b038087169850600160801b96879004811697868216979096048116959416939060ff1689565b610d91611b10565b60ca805460ff60a01b1916600160a01b179055565b60c9546001600160a01b0316331480610dc9575060ca546001600160a01b031633145b610e155760405162461bcd60e51b815260206004820152601a60248201527f44533a20556e617574686f72697a656420746f20526566756e64000000000000604482015260640161055e565b6001600160a01b038116610e6b5760405162461bcd60e51b815260206004820152601c60248201527f44533a207573657220697320746865207a65726f206164647265737300000000604482015260640161055e565b6001600160a01b038116600090815260cf60209081526040808320858452909152902060018101548015610fa757600060018301819055600383018190556002830181905584815260ce6020526040812060cd805491929187908110610ed357610ed3612515565b906000526020600020906007020190506000610ef3836002015485611cd1565b905080836002016000828254610f099190612691565b9091555050600682015460ff1615610f4157610f2760d05485611cd1565b90508060d06000828254610f3b9190612691565b90915550505b60cb54610f58906001600160a01b03168783611c6e565b60408051858152600060208201819052916001600160a01b038916918a917fa746a3d46437245ec92a03d65f8e29d475586c621a9c23e71fffbdbecdcf07ca91015b60405180910390a3505050505b50505050565b610fb5611b10565b6001600160a01b03811661101a5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b606482015260840161055e565b6105fb81611bd2565b600054610100900460ff16158080156110435750600054600160ff909116105b8061105d5750303b15801561105d575060005460ff166001145b6110c05760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b606482015260840161055e565b6000805460ff1916600117905580156110e3576000805461ff0019166101001790555b6110eb611ce7565b6110f3611d16565b60005b8481101561112f5761111f86868381811061111357611113612515565b90506101200201610a33565b6111288161276d565b90506110f6565b5060c980546001600160a01b038086166001600160a01b03199283161790925560ca805485841690831617905560cb80548a841690831617905560cc80549289169290911691909117905580156111c0576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b50505050505050565b6111d1611b10565b60ca54600160a01b900460ff16156105fb5760405162461bcd60e51b815260206004820152601b60248201527f44533a20757067726164652069736e277420617661696c61626c650000000000604482015260640161055e565b7f4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd91435460ff16156112635761125e83611d3d565b505050565b826001600160a01b03166352d1902d6040518163ffffffff1660e01b8152600401602060405180830381865afa9250505080156112bd575060408051601f3d908101601f191682019092526112ba9181019061252b565b60015b6113205760405162461bcd60e51b815260206004820152602e60248201527f45524331393637557067726164653a206e657720696d706c656d656e7461746960448201526d6f6e206973206e6f74205555505360901b606482015260840161055e565b6000805160206128d5833981519152811461138f5760405162461bcd60e51b815260206004820152602960248201527f45524331393637557067726164653a20756e737570706f727465642070726f786044820152681a58589b195555525160ba1b606482015260840161055e565b5061125e838383611dd9565b600081815260ce60205260408120600281015482036113be576001015492915050565b80546000906113d89085906001600160801b031642610932565b60028301549091506113f56a084595161401484a00000083612786565b6113ff919061279d565b826001015461140e91906127bf565b949350505050565b600060cd858154811061142b5761142b612515565b6000918252602080832088845260ce825260408085206001600160a01b038c16865260cf84528186208b87529093529093206001810154600790930290930193509190806114b35760405162461bcd60e51b81526020600482015260156024820152741114ce881d5cd95c881a5cdb89dd081cdd185ad959605a1b604482015260640161055e565b808711156114bf578096505b600684015460009060ff16156116c05784546001600160801b031642108061153a5750600185015485546114ff916001600160801b0390811691166127d2565b6001600160801b03164211801561153a57506002850154835461152e916001600160801b0390811691166127d2565b6001600160801b031642115b6115865760405162461bcd60e51b815260206004820152601b60248201527f44533a20706f6f6c207769746864726177206973206c6f636b65640000000000604482015260640161055e565b60cb546040516370a0823160e01b81523060048201526000916001600160a01b0316906370a0823190602401602060405180830381865afa1580156115cf573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115f3919061252b565b905080891115611601578098505b61160b8984612691565b91506000891161165d5760405162461bcd60e51b815260206004820152601760248201527f44533a206e6f7468696e6720746f207769746864726177000000000000000000604482015260640161055e565b85600501548210158061166e575081155b6116ba5760405162461bcd60e51b815260206004820152601b60248201527f44533a20696e76616c696420776974686472617720616d6f756e740000000000604482015260640161055e565b506116cd565b6116ca8883612691565b90505b6040805160808101825284546001600160801b031681526001850154602082015260028501549181019190915260038401546060820152600090611712908990611c24565b85546001600160801b031916426001600160801b0316178655600186018990556002860180549192508a9160009061174b908490612691565b9091555050600284018890556001840182905560038401819055600686015460ff16156117a0578860d060008282546117849190612691565b909155505060cb546117a0906001600160a01b03168c8b611c6e565b604080518a8152602081018990526001600160a01b038d16918c917fa746a3d46437245ec92a03d65f8e29d475586c621a9c23e71fffbdbecdcf07ca910160405180910390a35050505050505050505050565b6000831161183a5760405162461bcd60e51b815260206004820152601460248201527344533a206e6f7468696e6720746f207374616b6560601b604482015260640161055e565b600060cd858154811061184f5761184f612515565b6000918252602080832088845260ce825260408085206001600160a01b038c16865260cf84528186208b8752909352909320600792909202909201600681015490935060ff1615611a0e5760cb546040516370a0823160e01b81523060048201526000916001600160a01b0316906370a0823190602401602060405180830381865afa1580156118e3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611907919061252b565b90506119213360cb546001600160a01b031690308a611dfe565b60cb546040516370a0823160e01b81523060048201526000916001600160a01b0316906370a0823190602401602060405180830381865afa15801561196a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061198e919061252b565b905061199a8282612691565b975084600501548884600101546119b191906127bf565b10156119f45760405162461bcd60e51b815260206004820152601260248201527144533a20616d6f756e7420746f6f206c6f7760701b604482015260640161055e565b8760d06000828254611a0691906127bf565b909155505050505b6040805160808101825282546001600160801b031681526001830154602082015260028301549181019190915260038201546060820152611a50908690611c24565b600382015581546001600160801b031916426001600160801b031617825560018201859055600282018054879190600090611a8c9084906127bf565b909155505080546001600160801b031916426001600160801b031617815560028101859055600181018054879190600090611ac89084906127bf565b909155505060408051878152602081018690526001600160a01b038a169189917f9612520d2ead6ce7570316d46e8b55381a1a66b9d591b1a2e770a36ba276a3889101610f9a565b6033546001600160a01b03163314610b465760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161055e565b6000611b7c6040830160208401612544565b6001600160801b0316116105fb5760405162461bcd60e51b815260206004820152601d60248201527f44533a20696e76616c696420646563726561736520696e74657276616c000000604482015260640161055e565b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6000806a084595161401484a0000008360200151846040015186611c489190612691565b611c529190612786565b611c5c919061279d565b905080836060015161140e91906127bf565b6040516001600160a01b03831660248201526044810182905261125e90849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152611e36565b6000828211611ce05781610a2c565b5090919050565b600054610100900460ff16611d0e5760405162461bcd60e51b815260040161055e906127f9565b610b46611f0b565b600054610100900460ff16610b465760405162461bcd60e51b815260040161055e906127f9565b6001600160a01b0381163b611daa5760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b606482015260840161055e565b6000805160206128d583398151915280546001600160a01b0319166001600160a01b0392909216919091179055565b611de283611f3b565b600082511180611def5750805b1561125e57610fa78383611f7b565b6040516001600160a01b0380851660248301528316604482015260648101829052610fa79085906323b872dd60e01b90608401611c9a565b6000611e8b826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316611fa09092919063ffffffff16565b9050805160001480611eac575080806020019051810190611eac9190612844565b61125e5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b606482015260840161055e565b600054610100900460ff16611f325760405162461bcd60e51b815260040161055e906127f9565b610b4633611bd2565b611f4481611d3d565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b6060610a2c83836040518060600160405280602781526020016128f560279139611faf565b606061140e8484600085612027565b6060600080856001600160a01b031685604051611fcc9190612885565b600060405180830381855af49150503d8060008114612007576040519150601f19603f3d011682016040523d82523d6000602084013e61200c565b606091505b509150915061201d86838387612102565b9695505050505050565b6060824710156120885760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b606482015260840161055e565b600080866001600160a01b031685876040516120a49190612885565b60006040518083038185875af1925050503d80600081146120e1576040519150601f19603f3d011682016040523d82523d6000602084013e6120e6565b606091505b50915091506120f787838387612102565b979650505050505050565b6060831561217157825160000361216a576001600160a01b0385163b61216a5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015260640161055e565b508161140e565b61140e83838151156121865781518083602001fd5b8060405162461bcd60e51b815260040161055e91906128a1565b80356001600160a01b03811681146121b757600080fd5b919050565b600080604083850312156121cf57600080fd5b6121d8836121a0565b946020939093013593505050565b6000602082840312156121f857600080fd5b610a2c826121a0565b60008060006060848603121561221657600080fd5b505081359360208301359350604090920135919050565b634e487b7160e01b600052604160045260246000fd5b6000806040838503121561225657600080fd5b61225f836121a0565b9150602083013567ffffffffffffffff8082111561227c57600080fd5b818501915085601f83011261229057600080fd5b8135818111156122a2576122a261222d565b604051601f8201601f19908116603f011681019083821181831017156122ca576122ca61222d565b816040528281528860208487010111156122e357600080fd5b8260208601602083013760006020848301015280955050505050509250929050565b6001600160801b03811681146105fb57600080fd5b80356121b781612305565b60008060006060848603121561233a57600080fd5b83359250602084013561234c81612305565b9150604084013561235c81612305565b809150509250925092565b6000610120828403121561237a57600080fd5b50919050565b6000806040838503121561239357600080fd5b823591506123a3602084016121a0565b90509250929050565b6000602082840312156123be57600080fd5b5035919050565b60008060008060008060a087890312156123de57600080fd5b6123e7876121a0565b95506123f5602088016121a0565b9450604087013567ffffffffffffffff8082111561241257600080fd5b818901915089601f83011261242657600080fd5b81358181111561243557600080fd5b8a60206101208302850101111561244b57600080fd5b602083019650809550505050612463606088016121a0565b9150612471608088016121a0565b90509295509295509295565b6020808252602c908201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060408201526b19195b1959d85d1958d85b1b60a21b606082015260800190565b6020808252602c908201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060408201526b6163746976652070726f787960a01b606082015260800190565b634e487b7160e01b600052603260045260246000fd5b60006020828403121561253d57600080fd5b5051919050565b60006020828403121561255657600080fd5b8135610a2c81612305565b60008135610c6f81612305565b80151581146105fb57600080fd5b60008135610c6f8161256e565b6125b261259583612561565b82546001600160801b0319166001600160801b0391909116178255565b6125e16125c160208401612561565b82546001600160801b031660809190911b6001600160801b031916178255565b600181016125f461259560408501612561565b6126036125c160608501612561565b5061263461261360808401612561565b600283016001600160801b0382166001600160801b03198254161781555050565b60a0820135600382015560c0820135600482015560e0820135600582015561087b612662610100840161257c565b6006830160ff1981541660ff8315151681178255505050565b634e487b7160e01b600052601160045260246000fd5b81810381811115610c6f57610c6f61267b565b80356121b78161256e565b610120810182356126bf81612305565b6001600160801b031682526126d66020840161231a565b6001600160801b031660208301526126f06040840161231a565b6001600160801b0316604083015261270a6060840161231a565b6001600160801b031660608301526127246080840161231a565b6001600160801b03811660808401525060a083013560a083015260c083013560c083015260e083013560e08301526101006127608185016126a4565b1515920191909152919050565b60006001820161277f5761277f61267b565b5060010190565b8082028115828204841417610c6f57610c6f61267b565b6000826127ba57634e487b7160e01b600052601260045260246000fd5b500490565b80820180821115610c6f57610c6f61267b565b6001600160801b038181168382160190808211156127f2576127f261267b565b5092915050565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b60006020828403121561285657600080fd5b8151610a2c8161256e565b60005b8381101561287c578181015183820152602001612864565b50506000910152565b60008251612897818460208701612861565b9190910192915050565b60208152600082518060208401526128c0816040850160208701612861565b601f01601f1916919091016040019291505056fe360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220e41daf02333ab8c389934bfd6bb8711a45134a1e7e1d76bb93e92e43eb76af3e64736f6c63430008140033

Deployed Bytecode

0x6080604052600436106101405760003560e01c80638901579e116100b6578063d2ba5e3a1161006f578063d2ba5e3a14610404578063dd2518f31461041a578063e0b4b3861461043a578063f2fde38b1461046b578063f343e8581461048b578063f3b122e0146104f657600080fd5b80638901579e146102ed5780638da5cb5b14610302578063a06b2a3914610334578063ac4afa3814610354578063beee9fa9146103cf578063c89039c5146103e457600080fd5b806352d1902d1161010857806352d1902d14610240578063535f583f146102635780635bd2e38714610283578063715018a6146102a357806378df87b2146102b85780638468a4c4146102cd57600080fd5b806330dc6308146101455780633659cfe6146101cb5780633756c011146101ed5780633d0a42e71461020d5780634f1ef2861461022d575b600080fd5b34801561015157600080fd5b5061019c6101603660046121bc565b60cf60209081526000928352604080842090915290825290208054600182015460028301546003909301546001600160801b0390921692909184565b604080516001600160801b03909516855260208501939093529183015260608201526080015b60405180910390f35b3480156101d757600080fd5b506101eb6101e63660046121e6565b610516565b005b3480156101f957600080fd5b506101eb610208366004612201565b6105fe565b34801561021957600080fd5b506101eb610228366004612201565b6106da565b6101eb61023b366004612243565b6107af565b34801561024c57600080fd5b5061025561087f565b6040519081526020016101c2565b34801561026f57600080fd5b5061025561027e366004612325565b610932565b34801561028f57600080fd5b506101eb61029e366004612367565b610a33565b3480156102af57600080fd5b506101eb610b34565b3480156102c457600080fd5b50610255610b48565b3480156102d957600080fd5b506102556102e8366004612380565b610bdf565b3480156102f957600080fd5b506101eb610c75565b34801561030e57600080fd5b506033546001600160a01b03165b6040516001600160a01b0390911681526020016101c2565b34801561034057600080fd5b5060cc5461031c906001600160a01b031681565b34801561036057600080fd5b5061037461036f3660046123ac565b610d1b565b604080516001600160801b039a8b168152988a1660208a015296891696880196909652938716606087015295909116608085015260a084015260c083019390935260e0820192909252901515610100820152610120016101c2565b3480156103db57600080fd5b506101eb610d89565b3480156103f057600080fd5b5060cb5461031c906001600160a01b031681565b34801561041057600080fd5b5061025560d05481565b34801561042657600080fd5b506101eb610435366004612380565b610da6565b34801561044657600080fd5b5060ca5461045b90600160a01b900460ff1681565b60405190151581526020016101c2565b34801561047757600080fd5b506101eb6104863660046121e6565b610fad565b34801561049757600080fd5b506104d16104a63660046123ac565b60ce602052600090815260409020805460018201546002909201546001600160801b03909116919083565b604080516001600160801b0390941684526020840192909252908201526060016101c2565b34801561050257600080fd5b506101eb6105113660046123c5565b611023565b6001600160a01b037f00000000000000000000000076488832a88475af0ac223d8fd4d053177a012cc1630036105675760405162461bcd60e51b815260040161055e9061247d565b60405180910390fd5b7f00000000000000000000000076488832a88475af0ac223d8fd4d053177a012cc6001600160a01b03166105b06000805160206128d5833981519152546001600160a01b031690565b6001600160a01b0316146105d65760405162461bcd60e51b815260040161055e906124c9565b6105df816111c9565b604080516000808252602082019092526105fb9183919061122b565b50565b8261060a8160cd541190565b61064f5760405162461bcd60e51b81526020600482015260166024820152751114ce881c1bdbdb08191bd95cdb89dd08195e1a5cdd60521b604482015260640161055e565b8360cd818154811061066357610663612515565b600091825260209091206006600790920201015460ff166106be5760405162461bcd60e51b815260206004820152601560248201527444533a20706f6f6c2069736e2774207075626c696360581b604482015260640161055e565b6106d33386866106cd8961139b565b87611416565b5050505050565b826106e68160cd541190565b61072b5760405162461bcd60e51b81526020600482015260166024820152751114ce881c1bdbdb08191bd95cdb89dd08195e1a5cdd60521b604482015260640161055e565b8360cd818154811061073f5761073f612515565b600091825260209091206006600790920201015460ff1661079a5760405162461bcd60e51b815260206004820152601560248201527444533a20706f6f6c2069736e2774207075626c696360581b604482015260640161055e565b6106d33386866107a98961139b565b876117f3565b6001600160a01b037f00000000000000000000000076488832a88475af0ac223d8fd4d053177a012cc1630036107f75760405162461bcd60e51b815260040161055e9061247d565b7f00000000000000000000000076488832a88475af0ac223d8fd4d053177a012cc6001600160a01b03166108406000805160206128d5833981519152546001600160a01b031690565b6001600160a01b0316146108665760405162461bcd60e51b815260040161055e906124c9565b61086f826111c9565b61087b8282600161122b565b5050565b6000306001600160a01b037f00000000000000000000000076488832a88475af0ac223d8fd4d053177a012cc161461091f5760405162461bcd60e51b815260206004820152603860248201527f555550535570677261646561626c653a206d757374206e6f742062652063616c60448201527f6c6564207468726f7567682064656c656761746563616c6c0000000000000000606482015260840161055e565b506000805160206128d583398151915290565b600061093f8460cd541190565b61094b57506000610a2c565b600060cd858154811061096057610960612515565b6000918252602090912060079091020160038101546004808301548354604051638ef1035b60e01b81529283019390935260248201526001600160801b038083166044830152600160801b90920482166064820152868216608482015290851660a4820152909150737e209b1833ae5313c2923116c78baedf14d1d48290638ef1035b9060c401602060405180830381865af4158015610a04573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a28919061252b565b9150505b9392505050565b610a3b611b10565b42610a496020830183612544565b6001600160801b031611610a9f5760405162461bcd60e51b815260206004820152601e60248201527f44533a20696e76616c6964207061796f75742073746172742076616c75650000604482015260640161055e565b610aa881611b6a565b60cd805460018101825560009190915281906007027f83978b4c69c48dd978ab43fe30f077615294f938fb7f936d9eb340e51ea7db2e01610ae98282612589565b505060cd54610afa90600190612691565b7f9b9b09f76d4db7c7b0d783b9ba64d003e95462ef13cbb7cb782d74b085548cac82604051610b2991906126af565b60405180910390a250565b610b3c611b10565b610b466000611bd2565b565b60cb546040516370a0823160e01b815230600482015260009182916001600160a01b03909116906370a0823190602401602060405180830381865afa158015610b95573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bb9919061252b565b905060d0548111610bcc57600091505090565b60d054610bd99082612691565b91505090565b6000610bec8360cd541190565b610bf857506000610c6f565b6001600160a01b038216600090815260cf60209081526040808320868452909152812090610c258561139b565b6040805160808101825284546001600160801b031681526001850154602082015260028501549181019190915260038401546060820152909150610c6a908290611c24565b925050505b92915050565b6000610c7f610b48565b905060008111610cc85760405162461bcd60e51b815260206004820152601460248201527344533a206f766572706c7573206973207a65726f60601b604482015260640161055e565b60cc5460cb54610ce5916001600160a01b03918216911683611c6e565b6040518181527f1c1beeacf263316031be95f61cdcab6d052033248371579d5a954667ee9df8ad9060200160405180910390a150565b60cd8181548110610d2b57600080fd5b600091825260209091206007909102018054600182015460028301546003840154600485015460058601546006909601546001600160801b038087169850600160801b96879004811697868216979096048116959416939060ff1689565b610d91611b10565b60ca805460ff60a01b1916600160a01b179055565b60c9546001600160a01b0316331480610dc9575060ca546001600160a01b031633145b610e155760405162461bcd60e51b815260206004820152601a60248201527f44533a20556e617574686f72697a656420746f20526566756e64000000000000604482015260640161055e565b6001600160a01b038116610e6b5760405162461bcd60e51b815260206004820152601c60248201527f44533a207573657220697320746865207a65726f206164647265737300000000604482015260640161055e565b6001600160a01b038116600090815260cf60209081526040808320858452909152902060018101548015610fa757600060018301819055600383018190556002830181905584815260ce6020526040812060cd805491929187908110610ed357610ed3612515565b906000526020600020906007020190506000610ef3836002015485611cd1565b905080836002016000828254610f099190612691565b9091555050600682015460ff1615610f4157610f2760d05485611cd1565b90508060d06000828254610f3b9190612691565b90915550505b60cb54610f58906001600160a01b03168783611c6e565b60408051858152600060208201819052916001600160a01b038916918a917fa746a3d46437245ec92a03d65f8e29d475586c621a9c23e71fffbdbecdcf07ca91015b60405180910390a3505050505b50505050565b610fb5611b10565b6001600160a01b03811661101a5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b606482015260840161055e565b6105fb81611bd2565b600054610100900460ff16158080156110435750600054600160ff909116105b8061105d5750303b15801561105d575060005460ff166001145b6110c05760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b606482015260840161055e565b6000805460ff1916600117905580156110e3576000805461ff0019166101001790555b6110eb611ce7565b6110f3611d16565b60005b8481101561112f5761111f86868381811061111357611113612515565b90506101200201610a33565b6111288161276d565b90506110f6565b5060c980546001600160a01b038086166001600160a01b03199283161790925560ca805485841690831617905560cb80548a841690831617905560cc80549289169290911691909117905580156111c0576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b50505050505050565b6111d1611b10565b60ca54600160a01b900460ff16156105fb5760405162461bcd60e51b815260206004820152601b60248201527f44533a20757067726164652069736e277420617661696c61626c650000000000604482015260640161055e565b7f4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd91435460ff16156112635761125e83611d3d565b505050565b826001600160a01b03166352d1902d6040518163ffffffff1660e01b8152600401602060405180830381865afa9250505080156112bd575060408051601f3d908101601f191682019092526112ba9181019061252b565b60015b6113205760405162461bcd60e51b815260206004820152602e60248201527f45524331393637557067726164653a206e657720696d706c656d656e7461746960448201526d6f6e206973206e6f74205555505360901b606482015260840161055e565b6000805160206128d5833981519152811461138f5760405162461bcd60e51b815260206004820152602960248201527f45524331393637557067726164653a20756e737570706f727465642070726f786044820152681a58589b195555525160ba1b606482015260840161055e565b5061125e838383611dd9565b600081815260ce60205260408120600281015482036113be576001015492915050565b80546000906113d89085906001600160801b031642610932565b60028301549091506113f56a084595161401484a00000083612786565b6113ff919061279d565b826001015461140e91906127bf565b949350505050565b600060cd858154811061142b5761142b612515565b6000918252602080832088845260ce825260408085206001600160a01b038c16865260cf84528186208b87529093529093206001810154600790930290930193509190806114b35760405162461bcd60e51b81526020600482015260156024820152741114ce881d5cd95c881a5cdb89dd081cdd185ad959605a1b604482015260640161055e565b808711156114bf578096505b600684015460009060ff16156116c05784546001600160801b031642108061153a5750600185015485546114ff916001600160801b0390811691166127d2565b6001600160801b03164211801561153a57506002850154835461152e916001600160801b0390811691166127d2565b6001600160801b031642115b6115865760405162461bcd60e51b815260206004820152601b60248201527f44533a20706f6f6c207769746864726177206973206c6f636b65640000000000604482015260640161055e565b60cb546040516370a0823160e01b81523060048201526000916001600160a01b0316906370a0823190602401602060405180830381865afa1580156115cf573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115f3919061252b565b905080891115611601578098505b61160b8984612691565b91506000891161165d5760405162461bcd60e51b815260206004820152601760248201527f44533a206e6f7468696e6720746f207769746864726177000000000000000000604482015260640161055e565b85600501548210158061166e575081155b6116ba5760405162461bcd60e51b815260206004820152601b60248201527f44533a20696e76616c696420776974686472617720616d6f756e740000000000604482015260640161055e565b506116cd565b6116ca8883612691565b90505b6040805160808101825284546001600160801b031681526001850154602082015260028501549181019190915260038401546060820152600090611712908990611c24565b85546001600160801b031916426001600160801b0316178655600186018990556002860180549192508a9160009061174b908490612691565b9091555050600284018890556001840182905560038401819055600686015460ff16156117a0578860d060008282546117849190612691565b909155505060cb546117a0906001600160a01b03168c8b611c6e565b604080518a8152602081018990526001600160a01b038d16918c917fa746a3d46437245ec92a03d65f8e29d475586c621a9c23e71fffbdbecdcf07ca910160405180910390a35050505050505050505050565b6000831161183a5760405162461bcd60e51b815260206004820152601460248201527344533a206e6f7468696e6720746f207374616b6560601b604482015260640161055e565b600060cd858154811061184f5761184f612515565b6000918252602080832088845260ce825260408085206001600160a01b038c16865260cf84528186208b8752909352909320600792909202909201600681015490935060ff1615611a0e5760cb546040516370a0823160e01b81523060048201526000916001600160a01b0316906370a0823190602401602060405180830381865afa1580156118e3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611907919061252b565b90506119213360cb546001600160a01b031690308a611dfe565b60cb546040516370a0823160e01b81523060048201526000916001600160a01b0316906370a0823190602401602060405180830381865afa15801561196a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061198e919061252b565b905061199a8282612691565b975084600501548884600101546119b191906127bf565b10156119f45760405162461bcd60e51b815260206004820152601260248201527144533a20616d6f756e7420746f6f206c6f7760701b604482015260640161055e565b8760d06000828254611a0691906127bf565b909155505050505b6040805160808101825282546001600160801b031681526001830154602082015260028301549181019190915260038201546060820152611a50908690611c24565b600382015581546001600160801b031916426001600160801b031617825560018201859055600282018054879190600090611a8c9084906127bf565b909155505080546001600160801b031916426001600160801b031617815560028101859055600181018054879190600090611ac89084906127bf565b909155505060408051878152602081018690526001600160a01b038a169189917f9612520d2ead6ce7570316d46e8b55381a1a66b9d591b1a2e770a36ba276a3889101610f9a565b6033546001600160a01b03163314610b465760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161055e565b6000611b7c6040830160208401612544565b6001600160801b0316116105fb5760405162461bcd60e51b815260206004820152601d60248201527f44533a20696e76616c696420646563726561736520696e74657276616c000000604482015260640161055e565b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6000806a084595161401484a0000008360200151846040015186611c489190612691565b611c529190612786565b611c5c919061279d565b905080836060015161140e91906127bf565b6040516001600160a01b03831660248201526044810182905261125e90849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152611e36565b6000828211611ce05781610a2c565b5090919050565b600054610100900460ff16611d0e5760405162461bcd60e51b815260040161055e906127f9565b610b46611f0b565b600054610100900460ff16610b465760405162461bcd60e51b815260040161055e906127f9565b6001600160a01b0381163b611daa5760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b606482015260840161055e565b6000805160206128d583398151915280546001600160a01b0319166001600160a01b0392909216919091179055565b611de283611f3b565b600082511180611def5750805b1561125e57610fa78383611f7b565b6040516001600160a01b0380851660248301528316604482015260648101829052610fa79085906323b872dd60e01b90608401611c9a565b6000611e8b826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316611fa09092919063ffffffff16565b9050805160001480611eac575080806020019051810190611eac9190612844565b61125e5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b606482015260840161055e565b600054610100900460ff16611f325760405162461bcd60e51b815260040161055e906127f9565b610b4633611bd2565b611f4481611d3d565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b6060610a2c83836040518060600160405280602781526020016128f560279139611faf565b606061140e8484600085612027565b6060600080856001600160a01b031685604051611fcc9190612885565b600060405180830381855af49150503d8060008114612007576040519150601f19603f3d011682016040523d82523d6000602084013e61200c565b606091505b509150915061201d86838387612102565b9695505050505050565b6060824710156120885760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b606482015260840161055e565b600080866001600160a01b031685876040516120a49190612885565b60006040518083038185875af1925050503d80600081146120e1576040519150601f19603f3d011682016040523d82523d6000602084013e6120e6565b606091505b50915091506120f787838387612102565b979650505050505050565b6060831561217157825160000361216a576001600160a01b0385163b61216a5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015260640161055e565b508161140e565b61140e83838151156121865781518083602001fd5b8060405162461bcd60e51b815260040161055e91906128a1565b80356001600160a01b03811681146121b757600080fd5b919050565b600080604083850312156121cf57600080fd5b6121d8836121a0565b946020939093013593505050565b6000602082840312156121f857600080fd5b610a2c826121a0565b60008060006060848603121561221657600080fd5b505081359360208301359350604090920135919050565b634e487b7160e01b600052604160045260246000fd5b6000806040838503121561225657600080fd5b61225f836121a0565b9150602083013567ffffffffffffffff8082111561227c57600080fd5b818501915085601f83011261229057600080fd5b8135818111156122a2576122a261222d565b604051601f8201601f19908116603f011681019083821181831017156122ca576122ca61222d565b816040528281528860208487010111156122e357600080fd5b8260208601602083013760006020848301015280955050505050509250929050565b6001600160801b03811681146105fb57600080fd5b80356121b781612305565b60008060006060848603121561233a57600080fd5b83359250602084013561234c81612305565b9150604084013561235c81612305565b809150509250925092565b6000610120828403121561237a57600080fd5b50919050565b6000806040838503121561239357600080fd5b823591506123a3602084016121a0565b90509250929050565b6000602082840312156123be57600080fd5b5035919050565b60008060008060008060a087890312156123de57600080fd5b6123e7876121a0565b95506123f5602088016121a0565b9450604087013567ffffffffffffffff8082111561241257600080fd5b818901915089601f83011261242657600080fd5b81358181111561243557600080fd5b8a60206101208302850101111561244b57600080fd5b602083019650809550505050612463606088016121a0565b9150612471608088016121a0565b90509295509295509295565b6020808252602c908201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060408201526b19195b1959d85d1958d85b1b60a21b606082015260800190565b6020808252602c908201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060408201526b6163746976652070726f787960a01b606082015260800190565b634e487b7160e01b600052603260045260246000fd5b60006020828403121561253d57600080fd5b5051919050565b60006020828403121561255657600080fd5b8135610a2c81612305565b60008135610c6f81612305565b80151581146105fb57600080fd5b60008135610c6f8161256e565b6125b261259583612561565b82546001600160801b0319166001600160801b0391909116178255565b6125e16125c160208401612561565b82546001600160801b031660809190911b6001600160801b031916178255565b600181016125f461259560408501612561565b6126036125c160608501612561565b5061263461261360808401612561565b600283016001600160801b0382166001600160801b03198254161781555050565b60a0820135600382015560c0820135600482015560e0820135600582015561087b612662610100840161257c565b6006830160ff1981541660ff8315151681178255505050565b634e487b7160e01b600052601160045260246000fd5b81810381811115610c6f57610c6f61267b565b80356121b78161256e565b610120810182356126bf81612305565b6001600160801b031682526126d66020840161231a565b6001600160801b031660208301526126f06040840161231a565b6001600160801b0316604083015261270a6060840161231a565b6001600160801b031660608301526127246080840161231a565b6001600160801b03811660808401525060a083013560a083015260c083013560c083015260e083013560e08301526101006127608185016126a4565b1515920191909152919050565b60006001820161277f5761277f61267b565b5060010190565b8082028115828204841417610c6f57610c6f61267b565b6000826127ba57634e487b7160e01b600052601260045260246000fd5b500490565b80820180821115610c6f57610c6f61267b565b6001600160801b038181168382160190808211156127f2576127f261267b565b5092915050565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b60006020828403121561285657600080fd5b8151610a2c8161256e565b60005b8381101561287c578181015183820152602001612864565b50506000910152565b60008251612897818460208701612861565b9190910192915050565b60208152600082518060208401526128c0816040850160208701612861565b601f01601f1916919091016040019291505056fe360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220e41daf02333ab8c389934bfd6bb8711a45134a1e7e1d76bb93e92e43eb76af3e64736f6c63430008140033

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.