ETH Price: $2,275.95 (+7.38%)
Gas: 0.25 Gwei

Contract

0xAeAc20d418D38bB7dcf9AABe4E2883a9093CEF46
 

Overview

ETH Balance

0 ETH

Eth Value

$0.00

More Info

Private Name Tags

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
Loading...
Loading
Cross-Chain Transactions

Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

Validator Index Block Amount
View All Withdrawals

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
MWARStake

Compiler Version
v0.8.27+commit.40a35a09

Optimization Enabled:
Yes with 200 runs

Other Settings:
paris EvmVersion
// SPDX-License-Identifier: MIT
/*
  __  __      _        __        __          
 |  \/  | ___| |_ __ _ \ \      / /__ _ _ __ 
 | |\/| |/ _ \ __/ _` | \ \ /\ / / _ ` | '__|
 | |  | |  __/ || (_| |  \ V  V / (_)| | |   
 |_|  |_|\___|\__\__,_|   \_/\_/ \___,_|_|   
*/
pragma solidity ^0.8.20;

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

/**
 * @title MWARStake
 * @dev MWARStake contract for staking tokens
 */
contract MWARStake is Initializable, OwnableUpgradeable {
  using SafeERC20 for IERC20; // Wrappers around ERC20 operations that throw on failure

  IERC20 public stakeToken; // Token to be staked and rewarded
  address public presaleContract; // Presale contract address
  uint256 public tokensStaked; // Total tokens staked

  uint256 private lastRewardedBlock; // Last block number the user had their rewards calculated
  uint256 private accumulatedRewardsPerShare; // Accumulated rewards per share times REWARDS_PRECISION
  uint256 public rewardTokensPerBlock; // Number of reward tokens minted per block
  uint256 private constant REWARDS_PRECISION = 1e12; // A big number to perform mul and div operations

  uint256 public lockedTime; // To lock the tokens in contract for a definite time
  uint256 public endBlock; // At this block, the rewards generation will be stopped
  uint256 public claimStart; // Users can claim after this time in epoch

  // Staking user for a pool
  struct PoolStaker {
    uint256 amount; // The tokens quantity the user has staked
    uint256 stakedTime; // The time at which tokens were staked
    uint256 rewardDebt; // The amount relative to accumulatedRewardsPerShare the user can't get as reward
  }  

  // Mappings
  mapping(address => PoolStaker) public poolStakers;     // Staking information
  mapping(address => bool) public isBlacklisted;         // Blacklist
  mapping(address => uint256) public userLockedRewards;  // Locked rewards
  uint256 public totalStakers; // Total stakers

  // Stakers array
  address[] public stakers;
  mapping(address => bool) public stakerExists;            // Whether the staker exists

  // Events
  event Staked(address user, uint256 amount);
  event Unstaked(address user, uint256 amount);

  function initialize(
    address _tokenAddress, 
    address _presaleContract, 
    uint256 _rewardTokensPerBlock, 
    uint256 _lockTime, 
    uint256 _endBlock,
    address _admin
  ) public initializer {
    __Ownable_init(_admin);
    rewardTokensPerBlock = _rewardTokensPerBlock;
    stakeToken = IERC20(_tokenAddress);
    presaleContract = _presaleContract;
    lockedTime = _lockTime;
    endBlock = _endBlock;
  }

  /**
   * @dev to initialize
   */
  function initializeUpgrade() public reinitializer(2) {}  

  /**
   * @dev To check if the caller is presale contract
   */
  modifier onlyPresale() {
    require(msg.sender == presaleContract, 'This method is only for presale Contract');
    _;
  }

  /**
   * @dev Get stakers array
   */
  function getStakers() external view returns (address[] memory) {
    return stakers;
  }

  /**
   * @dev Stake tokens
   * @param _amount The amount of tokens to stake
   */
  function stake(uint256 _amount) external {
    require(block.number < endBlock, 'Staking has been ended');
    require(_amount > 0, "Deposit amount can't be zero");

    PoolStaker storage staker = poolStakers[msg.sender];
    // Add staker to stakers array if not already present
    if (!stakerExists[msg.sender]) {
      stakers.push(msg.sender);
      stakerExists[msg.sender] = true;
      totalStakers++;
    }

    // Update pool stakers
    _harvestRewards(msg.sender);

    // Update current staker
    staker.amount += _amount;
    staker.rewardDebt = (staker.amount * accumulatedRewardsPerShare) / REWARDS_PRECISION;
    staker.stakedTime = block.timestamp;
    
    // Update pool
    tokensStaked += _amount;

    // Stake tokens
    emit Staked(msg.sender, _amount);
    stakeToken.safeTransferFrom(msg.sender, address(this), _amount);
  }

  /**
   * @dev Stake tokens by presale contract
   * @param _user The user to stake tokens for
   * @param _amount The amount of tokens to stake
   */
  function stakeByPresale(address _user, uint256 _amount) external onlyPresale {
    require(block.number < endBlock, 'Staking has been ended');
    require(_amount > 0, "Deposit amount can't be zero");

    PoolStaker storage staker = poolStakers[_user];
    // Add staker to stakers array if not already present
    if (!stakerExists[_user]) {
      stakers.push(_user);
      stakerExists[_user] = true;
      totalStakers++;
    }

    // Update pool stakers
    _harvestRewards(_user);

    // Update current staker
    staker.amount += _amount;
    staker.rewardDebt = (staker.amount * accumulatedRewardsPerShare) / REWARDS_PRECISION;
    staker.stakedTime = block.timestamp;

    // Update pool
    tokensStaked += _amount;

    // Stake tokens
    emit Staked(_user, _amount);
    stakeToken.safeTransferFrom(presaleContract, address(this), _amount);
  }

  /**
   * @dev Unstake tokens
   */
  function unstake() external {
    PoolStaker memory staker = poolStakers[msg.sender];
    uint256 amount = staker.amount;
    require(staker.stakedTime + lockedTime <= block.timestamp && claimStart + lockedTime <= block.timestamp, 'You are not allowed to unstake before locked time');
    require(amount > 0, "Unstake amount can't be zero");

    _harvestRewards(msg.sender);

    delete poolStakers[msg.sender];
    // Find the staker in the array and remove them
    for (uint256 i = 0; i < stakers.length; i++) {
      if (stakers[i] == msg.sender) {
        stakers[i] = stakers[stakers.length - 1];
        stakers.pop();
        break;
      }
    }
    
    // Update pool
    tokensStaked -= amount;

    // Unstake tokens
    emit Unstaked(msg.sender, amount);
    stakeToken.safeTransfer(msg.sender, amount);
  }

  /**
   * @dev Harvest user rewards
   */
  function harvestRewards() public {
    _harvestRewards(msg.sender);
  }

  /**
   * @dev Harvest user rewards
   * @param user The user to harvest rewards for
   */
  function _harvestRewards(address user) private {
    require(!isBlacklisted[user], 'This address is blacklisted');

    updatePoolRewards();
    PoolStaker storage staker = poolStakers[user];
    uint256 rewardsToHarvest = ((staker.amount * accumulatedRewardsPerShare) / REWARDS_PRECISION) - staker.rewardDebt;
    if (rewardsToHarvest == 0) {
      return;
    }

    staker.rewardDebt = (staker.amount * accumulatedRewardsPerShare) / REWARDS_PRECISION;    
    userLockedRewards[user] += rewardsToHarvest;
  }

  /**
   * @dev Update pool's accumulatedRewardsPerShare and lastRewardedBlock
   */
  function updatePoolRewards() private {
    if (tokensStaked == 0) {
      lastRewardedBlock = block.number;
      return;
    }
    uint256 blocksSinceLastReward = block.number > endBlock ? endBlock - lastRewardedBlock : block.number - lastRewardedBlock;
    uint256 rewards = blocksSinceLastReward * rewardTokensPerBlock;
    accumulatedRewardsPerShare = accumulatedRewardsPerShare + ((rewards * REWARDS_PRECISION) / tokensStaked);
    lastRewardedBlock = block.number > endBlock ? endBlock : block.number;
  }

  /**
   *@dev To get the number of rewards that user can get
   * @param _user The user to get the rewards for
   * @return totalReward The total rewards that the user can get
   */
  function getRewards(address _user) public view returns (uint) {
    if (tokensStaked == 0) {
      return 0;
    }

    uint256 blocksSinceLastReward = block.number > endBlock ? endBlock - lastRewardedBlock : block.number - lastRewardedBlock;
    uint256 rewards = blocksSinceLastReward * rewardTokensPerBlock;
    uint256 accCalc = accumulatedRewardsPerShare + ((rewards * REWARDS_PRECISION) / tokensStaked);

    PoolStaker memory staker = poolStakers[_user];
    return ((staker.amount * accCalc) / REWARDS_PRECISION) - staker.rewardDebt + userLockedRewards[_user];
  }

  /**
   * @dev Set the presale contract
   * @param _presale The presale contract
   */
  function setPresale(address _presale) external onlyOwner {
    presaleContract = _presale;
  }

  /**
   * @dev Set the stake token
   * @param _stakeToken The stake token
   */
  function setStakeToken(address _stakeToken) external onlyOwner {
    stakeToken = IERC20(_stakeToken);
  }

  /**
   * @dev Set the locked time
   * @param _time The locked time
   */
  function setLockedTime(uint _time) external onlyOwner {
    lockedTime = _time;
  }

  /**
   * @dev Set the end block
   * @param _endBlock The end block
   */
  function setEndBlock(uint _endBlock) external onlyOwner {
    endBlock = _endBlock;
  }

  /**
   * @dev Set the claim start time
   * @param _claimStart The claim start time
   */
  function setClaimStart(uint _claimStart) external onlyOwner {
    claimStart = _claimStart;
  }
  
  /**
   * @dev Set the number of reward tokens minted per block
   * @param _rewardTokensPerBlock The number of reward tokens minted per block
   */
  function setRewardTokensPerBlock(uint256 _rewardTokensPerBlock) external onlyOwner {
    rewardTokensPerBlock = _rewardTokensPerBlock;
  }

  /**
   * @dev To add users to blacklist which restricts blacklisted users from claiming
   * @param _usersToBlacklist Addresses of the users
   */
  function blacklistUsers(address[] calldata _usersToBlacklist) external onlyOwner {
    for (uint256 i = 0; i < _usersToBlacklist.length; i++) {
      isBlacklisted[_usersToBlacklist[i]] = true;
    }
  }

  /**
   * @dev To remove users from blacklist which restricts blacklisted users from claiming
   * @param _userToRemoveFromBlacklist Addresses of the users
   */
  function removeFromBlacklist(address[] calldata _userToRemoveFromBlacklist) external onlyOwner {
    for (uint256 i = 0; i < _userToRemoveFromBlacklist.length; i++) {
      isBlacklisted[_userToRemoveFromBlacklist[i]] = false;
    }
  }

  /**
   * @dev Get staking state variables
   */
  function getStakingState() external view returns (uint256, uint256) {
    return (
      tokensStaked,
      rewardTokensPerBlock
    );
  }

  /**
   * @dev Get last rewarded block
   */
  function getLastRewardedBlock() external view onlyOwner returns (uint256) {
    return lastRewardedBlock;
  }

  /**
   * @dev Get accumulated rewards per share
   */
  function getAccumulatedRewardsPerShare() external view onlyOwner returns (uint256) {
    return accumulatedRewardsPerShare;
  }

  /**
   * @dev Function to update staking state variables
   * @param _tokensStaked Total tokens staked
   */
  function updateStakingState(
    uint256 _tokensStaked
  ) external onlyOwner {
    tokensStaked = _tokensStaked;

    stakeToken.safeTransferFrom(presaleContract, address(this), tokensStaked);
    delete stakers;
  }

  function updateStakingRewards() external onlyOwner {
    lastRewardedBlock = block.number;
    accumulatedRewardsPerShare = 0;
  }

  /**
   * @dev Function to batch update staker data
   * @param _users Users to update
   * @param _amounts Amounts to update
   */
  function batchUpdateStakers(
    address[] calldata _users,
    uint256[] calldata _amounts
  ) external onlyOwner {
    require(
      _users.length == _amounts.length,
      "Length mismatch"
    );

    for (uint256 i = 0; i < _users.length; i++) {
      if (_amounts[i] > 0) {
        poolStakers[_users[i]] = PoolStaker({
          amount: _amounts[i],
          stakedTime: block.timestamp,
          rewardDebt: 0
        });

        if (!stakerExists[_users[i]]) {
          stakers.push(_users[i]);
          stakerExists[_users[i]] = true;
          totalStakers++;
        }
      }
    }
  }

  function renounceOwnership() public override onlyOwner {
  }  
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)

pragma solidity ^0.8.20;

import {ContextUpgradeable} from "../utils/ContextUpgradeable.sol";
import {Initializable} from "../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.
 *
 * The initial owner is set to the address provided by the deployer. 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 {
    /// @custom:storage-location erc7201:openzeppelin.storage.Ownable
    struct OwnableStorage {
        address _owner;
    }

    // keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.Ownable")) - 1)) & ~bytes32(uint256(0xff))
    bytes32 private constant OwnableStorageLocation = 0x9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c199300;

    function _getOwnableStorage() private pure returns (OwnableStorage storage $) {
        assembly {
            $.slot := OwnableStorageLocation
        }
    }

    /**
     * @dev The caller account is not authorized to perform an operation.
     */
    error OwnableUnauthorizedAccount(address account);

    /**
     * @dev The owner is not a valid owner account. (eg. `address(0)`)
     */
    error OwnableInvalidOwner(address owner);

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

    /**
     * @dev Initializes the contract setting the address provided by the deployer as the initial owner.
     */
    function __Ownable_init(address initialOwner) internal onlyInitializing {
        __Ownable_init_unchained(initialOwner);
    }

    function __Ownable_init_unchained(address initialOwner) internal onlyInitializing {
        if (initialOwner == address(0)) {
            revert OwnableInvalidOwner(address(0));
        }
        _transferOwnership(initialOwner);
    }

    /**
     * @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) {
        OwnableStorage storage $ = _getOwnableStorage();
        return $._owner;
    }

    /**
     * @dev Throws if the sender is not the owner.
     */
    function _checkOwner() internal view virtual {
        if (owner() != _msgSender()) {
            revert OwnableUnauthorizedAccount(_msgSender());
        }
    }

    /**
     * @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 {
        if (newOwner == address(0)) {
            revert OwnableInvalidOwner(address(0));
        }
        _transferOwnership(newOwner);
    }

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

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (proxy/utils/Initializable.sol)

pragma solidity ^0.8.20;

/**
 * @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 Storage of the initializable contract.
     *
     * It's implemented on a custom ERC-7201 namespace to reduce the risk of storage collisions
     * when using with upgradeable contracts.
     *
     * @custom:storage-location erc7201:openzeppelin.storage.Initializable
     */
    struct InitializableStorage {
        /**
         * @dev Indicates that the contract has been initialized.
         */
        uint64 _initialized;
        /**
         * @dev Indicates that the contract is in the process of being initialized.
         */
        bool _initializing;
    }

    // keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.Initializable")) - 1)) & ~bytes32(uint256(0xff))
    bytes32 private constant INITIALIZABLE_STORAGE = 0xf0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00;

    /**
     * @dev The contract is already initialized.
     */
    error InvalidInitialization();

    /**
     * @dev The contract is not initializing.
     */
    error NotInitializing();

    /**
     * @dev Triggered when the contract has been initialized or reinitialized.
     */
    event Initialized(uint64 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 in the context of a constructor an `initializer` may be invoked any
     * number of times. This behavior in the constructor can be useful during testing and is not expected to be used in
     * production.
     *
     * Emits an {Initialized} event.
     */
    modifier initializer() {
        // solhint-disable-next-line var-name-mixedcase
        InitializableStorage storage $ = _getInitializableStorage();

        // Cache values to avoid duplicated sloads
        bool isTopLevelCall = !$._initializing;
        uint64 initialized = $._initialized;

        // Allowed calls:
        // - initialSetup: the contract is not in the initializing state and no previous version was
        //                 initialized
        // - construction: the contract is initialized at version 1 (no reininitialization) and the
        //                 current contract is just being deployed
        bool initialSetup = initialized == 0 && isTopLevelCall;
        bool construction = initialized == 1 && address(this).code.length == 0;

        if (!initialSetup && !construction) {
            revert InvalidInitialization();
        }
        $._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 2**64 - 1 will prevent any future reinitialization.
     *
     * Emits an {Initialized} event.
     */
    modifier reinitializer(uint64 version) {
        // solhint-disable-next-line var-name-mixedcase
        InitializableStorage storage $ = _getInitializableStorage();

        if ($._initializing || $._initialized >= version) {
            revert InvalidInitialization();
        }
        $._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() {
        _checkInitializing();
        _;
    }

    /**
     * @dev Reverts if the contract is not in an initializing state. See {onlyInitializing}.
     */
    function _checkInitializing() internal view virtual {
        if (!_isInitializing()) {
            revert NotInitializing();
        }
    }

    /**
     * @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 {
        // solhint-disable-next-line var-name-mixedcase
        InitializableStorage storage $ = _getInitializableStorage();

        if ($._initializing) {
            revert InvalidInitialization();
        }
        if ($._initialized != type(uint64).max) {
            $._initialized = type(uint64).max;
            emit Initialized(type(uint64).max);
        }
    }

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

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

    /**
     * @dev Returns a pointer to the storage namespace.
     */
    // solhint-disable-next-line var-name-mixedcase
    function _getInitializableStorage() private pure returns (InitializableStorage storage $) {
        assembly {
            $.slot := INITIALIZABLE_STORAGE
        }
    }
}

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

pragma solidity ^0.8.20;
import {Initializable} from "../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;
    }

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

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/ReentrancyGuard.sol)

pragma solidity ^0.8.20;
import {Initializable} from "../proxy/utils/Initializable.sol";

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

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

    /// @custom:storage-location erc7201:openzeppelin.storage.ReentrancyGuard
    struct ReentrancyGuardStorage {
        uint256 _status;
    }

    // keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.ReentrancyGuard")) - 1)) & ~bytes32(uint256(0xff))
    bytes32 private constant ReentrancyGuardStorageLocation = 0x9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f00;

    function _getReentrancyGuardStorage() private pure returns (ReentrancyGuardStorage storage $) {
        assembly {
            $.slot := ReentrancyGuardStorageLocation
        }
    }

    /**
     * @dev Unauthorized reentrant call.
     */
    error ReentrancyGuardReentrantCall();

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

    function __ReentrancyGuard_init_unchained() internal onlyInitializing {
        ReentrancyGuardStorage storage $ = _getReentrancyGuardStorage();
        $._status = NOT_ENTERED;
    }

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

    function _nonReentrantBefore() private {
        ReentrancyGuardStorage storage $ = _getReentrancyGuardStorage();
        // On the first call to nonReentrant, _status will be NOT_ENTERED
        if ($._status == ENTERED) {
            revert ReentrancyGuardReentrantCall();
        }

        // Any calls to nonReentrant after this point will fail
        $._status = ENTERED;
    }

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

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

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (interfaces/IERC1363.sol)

pragma solidity ^0.8.20;

import {IERC20} from "./IERC20.sol";
import {IERC165} from "./IERC165.sol";

/**
 * @title IERC1363
 * @dev Interface of the ERC-1363 standard as defined in the https://eips.ethereum.org/EIPS/eip-1363[ERC-1363].
 *
 * Defines an extension interface for ERC-20 tokens that supports executing code on a recipient contract
 * after `transfer` or `transferFrom`, or code on a spender contract after `approve`, in a single transaction.
 */
interface IERC1363 is IERC20, IERC165 {
    /*
     * Note: the ERC-165 identifier for this interface is 0xb0202a11.
     * 0xb0202a11 ===
     *   bytes4(keccak256('transferAndCall(address,uint256)')) ^
     *   bytes4(keccak256('transferAndCall(address,uint256,bytes)')) ^
     *   bytes4(keccak256('transferFromAndCall(address,address,uint256)')) ^
     *   bytes4(keccak256('transferFromAndCall(address,address,uint256,bytes)')) ^
     *   bytes4(keccak256('approveAndCall(address,uint256)')) ^
     *   bytes4(keccak256('approveAndCall(address,uint256,bytes)'))
     */

    /**
     * @dev Moves a `value` amount of tokens from the caller's account to `to`
     * and then calls {IERC1363Receiver-onTransferReceived} on `to`.
     * @param to The address which you want to transfer to.
     * @param value The amount of tokens to be transferred.
     * @return A boolean value indicating whether the operation succeeded unless throwing.
     */
    function transferAndCall(address to, uint256 value) external returns (bool);

    /**
     * @dev Moves a `value` amount of tokens from the caller's account to `to`
     * and then calls {IERC1363Receiver-onTransferReceived} on `to`.
     * @param to The address which you want to transfer to.
     * @param value The amount of tokens to be transferred.
     * @param data Additional data with no specified format, sent in call to `to`.
     * @return A boolean value indicating whether the operation succeeded unless throwing.
     */
    function transferAndCall(address to, uint256 value, bytes calldata data) external returns (bool);

    /**
     * @dev Moves a `value` amount of tokens from `from` to `to` using the allowance mechanism
     * and then calls {IERC1363Receiver-onTransferReceived} on `to`.
     * @param from The address which you want to send tokens from.
     * @param to The address which you want to transfer to.
     * @param value The amount of tokens to be transferred.
     * @return A boolean value indicating whether the operation succeeded unless throwing.
     */
    function transferFromAndCall(address from, address to, uint256 value) external returns (bool);

    /**
     * @dev Moves a `value` amount of tokens from `from` to `to` using the allowance mechanism
     * and then calls {IERC1363Receiver-onTransferReceived} on `to`.
     * @param from The address which you want to send tokens from.
     * @param to The address which you want to transfer to.
     * @param value The amount of tokens to be transferred.
     * @param data Additional data with no specified format, sent in call to `to`.
     * @return A boolean value indicating whether the operation succeeded unless throwing.
     */
    function transferFromAndCall(address from, address to, uint256 value, bytes calldata data) external returns (bool);

    /**
     * @dev Sets a `value` amount of tokens as the allowance of `spender` over the
     * caller's tokens and then calls {IERC1363Spender-onApprovalReceived} on `spender`.
     * @param spender The address which will spend the funds.
     * @param value The amount of tokens to be spent.
     * @return A boolean value indicating whether the operation succeeded unless throwing.
     */
    function approveAndCall(address spender, uint256 value) external returns (bool);

    /**
     * @dev Sets a `value` amount of tokens as the allowance of `spender` over the
     * caller's tokens and then calls {IERC1363Spender-onApprovalReceived} on `spender`.
     * @param spender The address which will spend the funds.
     * @param value The amount of tokens to be spent.
     * @param data Additional data with no specified format, sent in call to `spender`.
     * @return A boolean value indicating whether the operation succeeded unless throwing.
     */
    function approveAndCall(address spender, uint256 value, bytes calldata data) external returns (bool);
}

File 7 of 13 : IERC165.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC165.sol)

pragma solidity ^0.8.20;

import {IERC165} from "../utils/introspection/IERC165.sol";

File 8 of 13 : IERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC20.sol)

pragma solidity ^0.8.20;

import {IERC20} from "../token/ERC20/IERC20.sol";

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

pragma solidity ^0.8.20;

/**
 * @dev Interface of the ERC-20 standard as defined in the ERC.
 */
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 value of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

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

    /**
     * @dev Moves a `value` amount of 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 value) 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 a `value` amount of tokens 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 value) external returns (bool);

    /**
     * @dev Moves a `value` amount of tokens from `from` to `to` using the
     * allowance mechanism. `value` 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 value) external returns (bool);
}

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

pragma solidity ^0.8.20;

import {IERC20} from "../IERC20.sol";
import {IERC1363} from "../../../interfaces/IERC1363.sol";
import {Address} from "../../../utils/Address.sol";

/**
 * @title SafeERC20
 * @dev Wrappers around ERC-20 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 {
    /**
     * @dev An operation with an ERC-20 token failed.
     */
    error SafeERC20FailedOperation(address token);

    /**
     * @dev Indicates a failed `decreaseAllowance` request.
     */
    error SafeERC20FailedDecreaseAllowance(address spender, uint256 currentAllowance, uint256 requestedDecrease);

    /**
     * @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.encodeCall(token.transfer, (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.encodeCall(token.transferFrom, (from, to, 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.
     *
     * IMPORTANT: If the token implements ERC-7674 (ERC-20 with temporary allowance), and if the "client"
     * smart contract uses ERC-7674 to set temporary allowances, then the "client" smart contract should avoid using
     * this function. Performing a {safeIncreaseAllowance} or {safeDecreaseAllowance} operation on a token contract
     * that has a non-zero temporary allowance (for that particular owner-spender) will result in unexpected behavior.
     */
    function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
        uint256 oldAllowance = token.allowance(address(this), spender);
        forceApprove(token, spender, oldAllowance + value);
    }

    /**
     * @dev Decrease the calling contract's allowance toward `spender` by `requestedDecrease`. If `token` returns no
     * value, non-reverting calls are assumed to be successful.
     *
     * IMPORTANT: If the token implements ERC-7674 (ERC-20 with temporary allowance), and if the "client"
     * smart contract uses ERC-7674 to set temporary allowances, then the "client" smart contract should avoid using
     * this function. Performing a {safeIncreaseAllowance} or {safeDecreaseAllowance} operation on a token contract
     * that has a non-zero temporary allowance (for that particular owner-spender) will result in unexpected behavior.
     */
    function safeDecreaseAllowance(IERC20 token, address spender, uint256 requestedDecrease) internal {
        unchecked {
            uint256 currentAllowance = token.allowance(address(this), spender);
            if (currentAllowance < requestedDecrease) {
                revert SafeERC20FailedDecreaseAllowance(spender, currentAllowance, requestedDecrease);
            }
            forceApprove(token, spender, currentAllowance - requestedDecrease);
        }
    }

    /**
     * @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,
     * non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval
     * to be set to zero before setting it to a non-zero value, such as USDT.
     *
     * NOTE: If the token implements ERC-7674, this function will not modify any temporary allowance. This function
     * only sets the "standard" allowance. Any temporary allowance will remain active, in addition to the value being
     * set here.
     */
    function forceApprove(IERC20 token, address spender, uint256 value) internal {
        bytes memory approvalCall = abi.encodeCall(token.approve, (spender, value));

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

    /**
     * @dev Performs an {ERC1363} transferAndCall, with a fallback to the simple {ERC20} transfer if the target has no
     * code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when
     * targeting contracts.
     *
     * Reverts if the returned value is other than `true`.
     */
    function transferAndCallRelaxed(IERC1363 token, address to, uint256 value, bytes memory data) internal {
        if (to.code.length == 0) {
            safeTransfer(token, to, value);
        } else if (!token.transferAndCall(to, value, data)) {
            revert SafeERC20FailedOperation(address(token));
        }
    }

    /**
     * @dev Performs an {ERC1363} transferFromAndCall, with a fallback to the simple {ERC20} transferFrom if the target
     * has no code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when
     * targeting contracts.
     *
     * Reverts if the returned value is other than `true`.
     */
    function transferFromAndCallRelaxed(
        IERC1363 token,
        address from,
        address to,
        uint256 value,
        bytes memory data
    ) internal {
        if (to.code.length == 0) {
            safeTransferFrom(token, from, to, value);
        } else if (!token.transferFromAndCall(from, to, value, data)) {
            revert SafeERC20FailedOperation(address(token));
        }
    }

    /**
     * @dev Performs an {ERC1363} approveAndCall, with a fallback to the simple {ERC20} approve if the target has no
     * code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when
     * targeting contracts.
     *
     * NOTE: When the recipient address (`to`) has no code (i.e. is an EOA), this function behaves as {forceApprove}.
     * Opposedly, when the recipient address (`to`) has code, this function only attempts to call {ERC1363-approveAndCall}
     * once without retrying, and relies on the returned value to be true.
     *
     * Reverts if the returned value is other than `true`.
     */
    function approveAndCallRelaxed(IERC1363 token, address to, uint256 value, bytes memory data) internal {
        if (to.code.length == 0) {
            forceApprove(token, to, value);
        } else if (!token.approveAndCall(to, value, data)) {
            revert SafeERC20FailedOperation(address(token));
        }
    }

    /**
     * @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 {_callOptionalReturnBool} that reverts if call fails to meet the requirements.
     */
    function _callOptionalReturn(IERC20 token, bytes memory data) private {
        uint256 returnSize;
        uint256 returnValue;
        assembly ("memory-safe") {
            let success := call(gas(), token, 0, add(data, 0x20), mload(data), 0, 0x20)
            // bubble errors
            if iszero(success) {
                let ptr := mload(0x40)
                returndatacopy(ptr, 0, returndatasize())
                revert(ptr, returndatasize())
            }
            returnSize := returndatasize()
            returnValue := mload(0)
        }

        if (returnSize == 0 ? address(token).code.length == 0 : returnValue != 1) {
            revert SafeERC20FailedOperation(address(token));
        }
    }

    /**
     * @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 silently catches all reverts and returns a bool instead.
     */
    function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
        bool success;
        uint256 returnSize;
        uint256 returnValue;
        assembly ("memory-safe") {
            success := call(gas(), token, 0, add(data, 0x20), mload(data), 0, 0x20)
            returnSize := returndatasize()
            returnValue := mload(0)
        }
        return success && (returnSize == 0 ? address(token).code.length > 0 : returnValue == 1);
    }
}

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

pragma solidity ^0.8.20;

import {Errors} from "./Errors.sol";

/**
 * @dev Collection of functions related to the address type
 */
library Address {
    /**
     * @dev There's no code at `target` (it is not a contract).
     */
    error AddressEmptyCode(address target);

    /**
     * @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.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
     */
    function sendValue(address payable recipient, uint256 amount) internal {
        if (address(this).balance < amount) {
            revert Errors.InsufficientBalance(address(this).balance, amount);
        }

        (bool success, ) = recipient.call{value: amount}("");
        if (!success) {
            revert Errors.FailedCall();
        }
    }

    /**
     * @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 or custom error, it is bubbled
     * up by this function (like regular Solidity function calls). However, if
     * the call reverted with no returned reason, this function reverts with a
     * {Errors.FailedCall} error.
     *
     * 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.
     */
    function functionCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionCallWithValue(target, data, 0);
    }

    /**
     * @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`.
     */
    function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
        if (address(this).balance < value) {
            revert Errors.InsufficientBalance(address(this).balance, value);
        }
        (bool success, bytes memory returndata) = target.call{value: value}(data);
        return verifyCallResultFromTarget(target, success, returndata);
    }

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

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

    /**
     * @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target
     * was not a contract or bubbling up the revert reason (falling back to {Errors.FailedCall}) in case
     * of an unsuccessful call.
     */
    function verifyCallResultFromTarget(
        address target,
        bool success,
        bytes memory returndata
    ) internal view returns (bytes memory) {
        if (!success) {
            _revert(returndata);
        } else {
            // only check if target is a contract if the call was successful and the return data is empty
            // otherwise we already know that it was a contract
            if (returndata.length == 0 && target.code.length == 0) {
                revert AddressEmptyCode(target);
            }
            return returndata;
        }
    }

    /**
     * @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the
     * revert reason or with a default {Errors.FailedCall} error.
     */
    function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) {
        if (!success) {
            _revert(returndata);
        } else {
            return returndata;
        }
    }

    /**
     * @dev Reverts with returndata if present. Otherwise reverts with {Errors.FailedCall}.
     */
    function _revert(bytes memory returndata) 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
            assembly ("memory-safe") {
                let returndata_size := mload(returndata)
                revert(add(32, returndata), returndata_size)
            }
        } else {
            revert Errors.FailedCall();
        }
    }
}

File 12 of 13 : Errors.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/Errors.sol)

pragma solidity ^0.8.20;

/**
 * @dev Collection of common custom errors used in multiple contracts
 *
 * IMPORTANT: Backwards compatibility is not guaranteed in future versions of the library.
 * It is recommended to avoid relying on the error API for critical functionality.
 *
 * _Available since v5.1._
 */
library Errors {
    /**
     * @dev The ETH balance of the account is not enough to perform the operation.
     */
    error InsufficientBalance(uint256 balance, uint256 needed);

    /**
     * @dev A call to an address target failed. The target may have reverted.
     */
    error FailedCall();

    /**
     * @dev The deployment failed.
     */
    error FailedDeployment();

    /**
     * @dev A necessary precompile is missing.
     */
    error MissingPrecompile(address);
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/introspection/IERC165.sol)

pragma solidity ^0.8.20;

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

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

Contract Security Audit

Contract ABI

API
[{"inputs":[],"name":"InvalidInitialization","type":"error"},{"inputs":[],"name":"NotInitializing","type":"error"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"OwnableInvalidOwner","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"OwnableUnauthorizedAccount","type":"error"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"SafeERC20FailedOperation","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint64","name":"version","type":"uint64"}],"name":"Initialized","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":false,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Staked","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Unstaked","type":"event"},{"inputs":[{"internalType":"address[]","name":"_users","type":"address[]"},{"internalType":"uint256[]","name":"_amounts","type":"uint256[]"}],"name":"batchUpdateStakers","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"_usersToBlacklist","type":"address[]"}],"name":"blacklistUsers","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"claimStart","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"endBlock","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getAccumulatedRewardsPerShare","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getLastRewardedBlock","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"}],"name":"getRewards","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getStakers","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getStakingState","outputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"harvestRewards","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_tokenAddress","type":"address"},{"internalType":"address","name":"_presaleContract","type":"address"},{"internalType":"uint256","name":"_rewardTokensPerBlock","type":"uint256"},{"internalType":"uint256","name":"_lockTime","type":"uint256"},{"internalType":"uint256","name":"_endBlock","type":"uint256"},{"internalType":"address","name":"_admin","type":"address"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"initializeUpgrade","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"isBlacklisted","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lockedTime","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"poolStakers","outputs":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"stakedTime","type":"uint256"},{"internalType":"uint256","name":"rewardDebt","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"presaleContract","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address[]","name":"_userToRemoveFromBlacklist","type":"address[]"}],"name":"removeFromBlacklist","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"rewardTokensPerBlock","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_claimStart","type":"uint256"}],"name":"setClaimStart","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_endBlock","type":"uint256"}],"name":"setEndBlock","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_time","type":"uint256"}],"name":"setLockedTime","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_presale","type":"address"}],"name":"setPresale","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_rewardTokensPerBlock","type":"uint256"}],"name":"setRewardTokensPerBlock","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_stakeToken","type":"address"}],"name":"setStakeToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"stake","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"stakeByPresale","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"stakeToken","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"stakerExists","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"stakers","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"tokensStaked","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalStakers","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"unstake","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"updateStakingRewards","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokensStaked","type":"uint256"}],"name":"updateStakingState","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"userLockedRewards","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"}]

6080604052348015600f57600080fd5b50611b9f8061001f6000396000f3fe608060405234801561001057600080fd5b50600436106102325760003560e01c806389daf79911610130578063c713aa94116100b8578063e12799b11161007c578063e12799b1146104ee578063f04d688f146104f6578063f2fde38b146104ff578063fd5e6dd114610512578063fe575a871461052557600080fd5b8063c713aa9414610438578063cddb3e7b1461044b578063cfa10ca014610495578063d5fcc7b6146104c8578063df1dcaa9146104db57600080fd5b8063a8b38205116100ff578063a8b38205146103ee578063b0aa1e04146103f7578063b1a5d12d1461040a578063b514b0a31461041d578063bb3d676a1461042557600080fd5b806389daf7991461038f5780638da5cb5b146103a257806399a03316146103d2578063a694fc3a146103db57600080fd5b806351ed6a30116101be5780637d7366aa116101825780637d7366aa146103435780637db4adfa146103635780637e6298e01461036b578063869890381461037357806388d2d0f31461037c57600080fd5b806351ed6a30146102d75780635f2c16a11461030257806363d9df8514610315578063715018a61461032857806379ee54f71461033057600080fd5b80632be11ae2116102055780632be11ae2146102845780632def66201461028c5780632e1878641461029457806338f059b9146102a757806343352d61146102c257600080fd5b80630397d45814610237578063083c63231461024c5780630fd3738a1461026857806329d0fa3e1461027b575b600080fd5b61024a61024536600461189a565b610548565b005b61025560075481565b6040519081526020015b60405180910390f35b61024a6102763660046118bc565b610572565b61025560055481565b61024a61057f565b61024a61058a565b61024a6102a2366004611921565b61083a565b6002546005546040805192835260208301919091520161025f565b6102ca610a63565b60405161025f9190611992565b6000546102ea906001600160a01b031681565b6040516001600160a01b03909116815260200161025f565b61024a6103103660046119de565b610ac5565b6001546102ea906001600160a01b031681565b61024a610d3b565b61025561033e36600461189a565b610d43565b61025561035136600461189a565b600b6020526000908152604090205481565b61024a610e50565b610255610e63565b610255600c5481565b61024a61038a3660046118bc565b610e74565b61024a61039d366004611a08565b610eae565b7f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c199300546001600160a01b03166102ea565b61025560025481565b61024a6103e93660046118bc565b610f1e565b61025560065481565b61024a6104053660046118bc565b611103565b61024a610418366004611a4a565b611110565b610255611264565b61024a610433366004611a08565b611275565b61024a6104463660046118bc565b6112e5565b61047a61045936600461189a565b60096020526000908152604090208054600182015460029092015490919083565b6040805193845260208401929092529082015260600161025f565b6104b86104a336600461189a565b600e6020526000908152604090205460ff1681565b604051901515815260200161025f565b61024a6104d636600461189a565b6112f2565b61024a6104e93660046118bc565b61131c565b61024a611329565b61025560085481565b61024a61050d36600461189a565b6113f3565b6102ea6105203660046118bc565b61142e565b6104b861053336600461189a565b600a6020526000908152604090205460ff1681565b610550611458565b600080546001600160a01b0319166001600160a01b0392909216919091179055565b61057a611458565b600555565b610588336114b3565b565b3360009081526009602090815260409182902082516060810184528154808252600183015493820184905260029092015493810193909352600654909142916105d291611abf565b111580156105ef5750426006546008546105ec9190611abf565b11155b61065a5760405162461bcd60e51b815260206004820152603160248201527f596f7520617265206e6f7420616c6c6f77656420746f20756e7374616b65206260448201527065666f7265206c6f636b65642074696d6560781b60648201526084015b60405180910390fd5b600081116106aa5760405162461bcd60e51b815260206004820152601c60248201527f556e7374616b6520616d6f756e742063616e2774206265207a65726f000000006044820152606401610651565b6106b3336114b3565b336000908152600960205260408120818155600181018290556002018190555b600d548110156107ce57336001600160a01b0316600d82815481106106fa576106fa611ad8565b6000918252602090912001546001600160a01b0316036107c657600d805461072490600190611aee565b8154811061073457610734611ad8565b600091825260209091200154600d80546001600160a01b03909216918390811061076057610760611ad8565b9060005260206000200160006101000a8154816001600160a01b0302191690836001600160a01b03160217905550600d80548061079f5761079f611b01565b600082815260209020810160001990810180546001600160a01b03191690550190556107ce565b6001016106d3565b5080600260008282546107e19190611aee565b909155505060408051338152602081018390527f0f5bb82176feb1b5e747e28471aa92156a04d9f3ab9f45f28e2d704232b93f75910160405180910390a1600054610836906001600160a01b031633836115d2565b5050565b610842611458565b8281146108835760405162461bcd60e51b815260206004820152600f60248201526e098cadccee8d040dad2e6dac2e8c6d608b1b6044820152606401610651565b60005b83811015610a5c5760008383838181106108a2576108a2611ad8565b905060200201351115610a545760405180606001604052808484848181106108cc576108cc611ad8565b9050602002013581526020014281526020016000815250600960008787858181106108f9576108f9611ad8565b905060200201602081019061090e919061189a565b6001600160a01b031681526020808201929092526040908101600090812084518155928401516001840155920151600290910155600e9086868481811061095757610957611ad8565b905060200201602081019061096c919061189a565b6001600160a01b0316815260208101919091526040016000205460ff16610a5457600d8585838181106109a1576109a1611ad8565b90506020020160208101906109b6919061189a565b81546001808201845560009384526020842090910180546001600160a01b0319166001600160a01b03939093169290921790915590600e90878785818110610a0057610a00611ad8565b9050602002016020810190610a15919061189a565b6001600160a01b0316815260208101919091526040016000908120805460ff191692151592909217909155600c805491610a4e83611b17565b91905055505b600101610886565b5050505050565b6060600d805480602002602001604051908101604052809291908181526020018280548015610abb57602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311610a9d575b5050505050905090565b6001546001600160a01b03163314610b305760405162461bcd60e51b815260206004820152602860248201527f54686973206d6574686f64206973206f6e6c7920666f722070726573616c652060448201526710dbdb9d1c9858dd60c21b6064820152608401610651565b6007544310610b7a5760405162461bcd60e51b815260206004820152601660248201527514dd185ada5b99c81a185cc81899595b88195b99195960521b6044820152606401610651565b60008111610bca5760405162461bcd60e51b815260206004820152601c60248201527f4465706f73697420616d6f756e742063616e2774206265207a65726f000000006044820152606401610651565b6001600160a01b0382166000908152600960209081526040808320600e9092529091205460ff16610c6d57600d805460018082019092557fd7b6990105719101dabeb77144f2a3385c8033acd3af97e9423a695e81ad1eb50180546001600160a01b0319166001600160a01b0386169081179091556000908152600e60205260408120805460ff1916909217909155600c805491610c6783611b17565b91905055505b610c76836114b3565b81816000016000828254610c8a9190611abf565b9091555050600454815464e8d4a5100091610ca491611b30565b610cae9190611b47565b81600201819055504281600101819055508160026000828254610cd19190611abf565b9091555050604080516001600160a01b0385168152602081018490527f9e71bc8eea02a63969f509818f2dafb9254532904319f9dbda79b67bd34a5f3d910160405180910390a1600154600054610d36916001600160a01b0391821691163085611631565b505050565b610588611458565b6000600254600003610d5757506000919050565b60006007544311610d7457600354610d6f9043611aee565b610d84565b600354600754610d849190611aee565b9050600060055482610d969190611b30565b9050600060025464e8d4a5100083610dae9190611b30565b610db89190611b47565b600454610dc59190611abf565b6001600160a01b0386166000818152600960209081526040808320815160608101835281548152600182015481850152600290910154818301908152948452600b9092529091205491518151939450909264e8d4a5100090610e28908690611b30565b610e329190611b47565b610e3c9190611aee565b610e469190611abf565b9695505050505050565b610e58611458565b436003556000600455565b6000610e6d611458565b5060045490565b610e7c611458565b6002819055600154600054610e9f916001600160a01b0391821691163084611631565b610eab600d600061184c565b50565b610eb6611458565b60005b81811015610d36576000600a6000858585818110610ed957610ed9611ad8565b9050602002016020810190610eee919061189a565b6001600160a01b031681526020810191909152604001600020805460ff1916911515919091179055600101610eb9565b6007544310610f685760405162461bcd60e51b815260206004820152601660248201527514dd185ada5b99c81a185cc81899595b88195b99195960521b6044820152606401610651565b60008111610fb85760405162461bcd60e51b815260206004820152601c60248201527f4465706f73697420616d6f756e742063616e2774206265207a65726f000000006044820152606401610651565b336000908152600960209081526040808320600e9092529091205460ff1661104957600d805460018181019092557fd7b6990105719101dabeb77144f2a3385c8033acd3af97e9423a695e81ad1eb50180546001600160a01b031916339081179091556000908152600e60205260408120805460ff1916909217909155600c80549161104383611b17565b91905055505b611052336114b3565b818160000160008282546110669190611abf565b9091555050600454815464e8d4a510009161108091611b30565b61108a9190611b47565b816002018190555042816001018190555081600260008282546110ad9190611abf565b909155505060408051338152602081018490527f9e71bc8eea02a63969f509818f2dafb9254532904319f9dbda79b67bd34a5f3d910160405180910390a1600054610836906001600160a01b0316333085611631565b61110b611458565b600855565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a008054600160401b810460ff16159067ffffffffffffffff166000811580156111565750825b905060008267ffffffffffffffff1660011480156111735750303b155b905081158015611181575080155b1561119f5760405163f92ee8a960e01b815260040160405180910390fd5b845467ffffffffffffffff1916600117855583156111c957845460ff60401b1916600160401b1785555b6111d286611670565b6005899055600080546001600160a01b03808e166001600160a01b03199283161790925560018054928d169290911691909117905560068890556007879055831561125757845460ff60401b19168555604051600181527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15b5050505050505050505050565b600061126e611458565b5060035490565b61127d611458565b60005b81811015610d36576001600a60008585858181106112a0576112a0611ad8565b90506020020160208101906112b5919061189a565b6001600160a01b031681526020810191909152604001600020805460ff1916911515919091179055600101611280565b6112ed611458565b600755565b6112fa611458565b600180546001600160a01b0319166001600160a01b0392909216919091179055565b611324611458565b600655565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00805460029190600160401b900460ff16806113735750805467ffffffffffffffff808416911610155b156113915760405163f92ee8a960e01b815260040160405180910390fd5b805468ffffffffffffffffff191667ffffffffffffffff8316908117600160401b1760ff60401b191682556040519081527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15050565b6113fb611458565b6001600160a01b03811661142557604051631e4fbdf760e01b815260006004820152602401610651565b610eab81611681565b600d818154811061143e57600080fd5b6000918252602090912001546001600160a01b0316905081565b3361148a7f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c199300546001600160a01b031690565b6001600160a01b0316146105885760405163118cdaa760e01b8152336004820152602401610651565b6001600160a01b0381166000908152600a602052604090205460ff161561151c5760405162461bcd60e51b815260206004820152601b60248201527f54686973206164647265737320697320626c61636b6c697374656400000000006044820152606401610651565b6115246116f2565b6001600160a01b03811660009081526009602052604081206002810154600454825492939264e8d4a510009161155991611b30565b6115639190611b47565b61156d9190611aee565b90508060000361157c57505050565b600454825464e8d4a510009161159191611b30565b61159b9190611b47565b60028301556001600160a01b0383166000908152600b6020526040812080548392906115c8908490611abf565b9091555050505050565b6040516001600160a01b03838116602483015260448201839052610d3691859182169063a9059cbb906064015b604051602081830303815290604052915060e01b6020820180516001600160e01b03838183161783525050505061178a565b6040516001600160a01b03848116602483015283811660448301526064820183905261166a9186918216906323b872dd906084016115ff565b50505050565b6116786117fb565b610eab81611844565b7f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c19930080546001600160a01b031981166001600160a01b03848116918217845560405192169182907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3505050565b6002546000036117025743600355565b6000600754431161171f5760035461171a9043611aee565b61172f565b60035460075461172f9190611aee565b90506000600554826117419190611b30565b60025490915061175664e8d4a5100083611b30565b6117609190611b47565b60045461176d9190611abf565b600455600754431161177f5743611783565b6007545b6003555050565b600080602060008451602086016000885af1806117ad576040513d6000823e3d81fd5b50506000513d915081156117c55780600114156117d2565b6001600160a01b0384163b155b1561166a57604051635274afe760e01b81526001600160a01b0385166004820152602401610651565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a0054600160401b900460ff1661058857604051631afcd79f60e31b815260040160405180910390fd5b6113fb6117fb565b5080546000825590600052602060002090810190610eab91905b8082111561187a5760008155600101611866565b5090565b80356001600160a01b038116811461189557600080fd5b919050565b6000602082840312156118ac57600080fd5b6118b58261187e565b9392505050565b6000602082840312156118ce57600080fd5b5035919050565b60008083601f8401126118e757600080fd5b50813567ffffffffffffffff8111156118ff57600080fd5b6020830191508360208260051b850101111561191a57600080fd5b9250929050565b6000806000806040858703121561193757600080fd5b843567ffffffffffffffff81111561194e57600080fd5b61195a878288016118d5565b909550935050602085013567ffffffffffffffff81111561197a57600080fd5b611986878288016118d5565b95989497509550505050565b602080825282518282018190526000918401906040840190835b818110156119d35783516001600160a01b03168352602093840193909201916001016119ac565b509095945050505050565b600080604083850312156119f157600080fd5b6119fa8361187e565b946020939093013593505050565b60008060208385031215611a1b57600080fd5b823567ffffffffffffffff811115611a3257600080fd5b611a3e858286016118d5565b90969095509350505050565b60008060008060008060c08789031215611a6357600080fd5b611a6c8761187e565b9550611a7a6020880161187e565b9450604087013593506060870135925060808701359150611a9d60a0880161187e565b90509295509295509295565b634e487b7160e01b600052601160045260246000fd5b80820180821115611ad257611ad2611aa9565b92915050565b634e487b7160e01b600052603260045260246000fd5b81810381811115611ad257611ad2611aa9565b634e487b7160e01b600052603160045260246000fd5b600060018201611b2957611b29611aa9565b5060010190565b8082028115828204841417611ad257611ad2611aa9565b600082611b6457634e487b7160e01b600052601260045260246000fd5b50049056fea2646970667358221220fb58dcecba6c50a9e05037eadf31c15ba3c223abe392291a0f427ae7a8745e8264736f6c634300081b0033

Deployed Bytecode

0x608060405234801561001057600080fd5b50600436106102325760003560e01c806389daf79911610130578063c713aa94116100b8578063e12799b11161007c578063e12799b1146104ee578063f04d688f146104f6578063f2fde38b146104ff578063fd5e6dd114610512578063fe575a871461052557600080fd5b8063c713aa9414610438578063cddb3e7b1461044b578063cfa10ca014610495578063d5fcc7b6146104c8578063df1dcaa9146104db57600080fd5b8063a8b38205116100ff578063a8b38205146103ee578063b0aa1e04146103f7578063b1a5d12d1461040a578063b514b0a31461041d578063bb3d676a1461042557600080fd5b806389daf7991461038f5780638da5cb5b146103a257806399a03316146103d2578063a694fc3a146103db57600080fd5b806351ed6a30116101be5780637d7366aa116101825780637d7366aa146103435780637db4adfa146103635780637e6298e01461036b578063869890381461037357806388d2d0f31461037c57600080fd5b806351ed6a30146102d75780635f2c16a11461030257806363d9df8514610315578063715018a61461032857806379ee54f71461033057600080fd5b80632be11ae2116102055780632be11ae2146102845780632def66201461028c5780632e1878641461029457806338f059b9146102a757806343352d61146102c257600080fd5b80630397d45814610237578063083c63231461024c5780630fd3738a1461026857806329d0fa3e1461027b575b600080fd5b61024a61024536600461189a565b610548565b005b61025560075481565b6040519081526020015b60405180910390f35b61024a6102763660046118bc565b610572565b61025560055481565b61024a61057f565b61024a61058a565b61024a6102a2366004611921565b61083a565b6002546005546040805192835260208301919091520161025f565b6102ca610a63565b60405161025f9190611992565b6000546102ea906001600160a01b031681565b6040516001600160a01b03909116815260200161025f565b61024a6103103660046119de565b610ac5565b6001546102ea906001600160a01b031681565b61024a610d3b565b61025561033e36600461189a565b610d43565b61025561035136600461189a565b600b6020526000908152604090205481565b61024a610e50565b610255610e63565b610255600c5481565b61024a61038a3660046118bc565b610e74565b61024a61039d366004611a08565b610eae565b7f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c199300546001600160a01b03166102ea565b61025560025481565b61024a6103e93660046118bc565b610f1e565b61025560065481565b61024a6104053660046118bc565b611103565b61024a610418366004611a4a565b611110565b610255611264565b61024a610433366004611a08565b611275565b61024a6104463660046118bc565b6112e5565b61047a61045936600461189a565b60096020526000908152604090208054600182015460029092015490919083565b6040805193845260208401929092529082015260600161025f565b6104b86104a336600461189a565b600e6020526000908152604090205460ff1681565b604051901515815260200161025f565b61024a6104d636600461189a565b6112f2565b61024a6104e93660046118bc565b61131c565b61024a611329565b61025560085481565b61024a61050d36600461189a565b6113f3565b6102ea6105203660046118bc565b61142e565b6104b861053336600461189a565b600a6020526000908152604090205460ff1681565b610550611458565b600080546001600160a01b0319166001600160a01b0392909216919091179055565b61057a611458565b600555565b610588336114b3565b565b3360009081526009602090815260409182902082516060810184528154808252600183015493820184905260029092015493810193909352600654909142916105d291611abf565b111580156105ef5750426006546008546105ec9190611abf565b11155b61065a5760405162461bcd60e51b815260206004820152603160248201527f596f7520617265206e6f7420616c6c6f77656420746f20756e7374616b65206260448201527065666f7265206c6f636b65642074696d6560781b60648201526084015b60405180910390fd5b600081116106aa5760405162461bcd60e51b815260206004820152601c60248201527f556e7374616b6520616d6f756e742063616e2774206265207a65726f000000006044820152606401610651565b6106b3336114b3565b336000908152600960205260408120818155600181018290556002018190555b600d548110156107ce57336001600160a01b0316600d82815481106106fa576106fa611ad8565b6000918252602090912001546001600160a01b0316036107c657600d805461072490600190611aee565b8154811061073457610734611ad8565b600091825260209091200154600d80546001600160a01b03909216918390811061076057610760611ad8565b9060005260206000200160006101000a8154816001600160a01b0302191690836001600160a01b03160217905550600d80548061079f5761079f611b01565b600082815260209020810160001990810180546001600160a01b03191690550190556107ce565b6001016106d3565b5080600260008282546107e19190611aee565b909155505060408051338152602081018390527f0f5bb82176feb1b5e747e28471aa92156a04d9f3ab9f45f28e2d704232b93f75910160405180910390a1600054610836906001600160a01b031633836115d2565b5050565b610842611458565b8281146108835760405162461bcd60e51b815260206004820152600f60248201526e098cadccee8d040dad2e6dac2e8c6d608b1b6044820152606401610651565b60005b83811015610a5c5760008383838181106108a2576108a2611ad8565b905060200201351115610a545760405180606001604052808484848181106108cc576108cc611ad8565b9050602002013581526020014281526020016000815250600960008787858181106108f9576108f9611ad8565b905060200201602081019061090e919061189a565b6001600160a01b031681526020808201929092526040908101600090812084518155928401516001840155920151600290910155600e9086868481811061095757610957611ad8565b905060200201602081019061096c919061189a565b6001600160a01b0316815260208101919091526040016000205460ff16610a5457600d8585838181106109a1576109a1611ad8565b90506020020160208101906109b6919061189a565b81546001808201845560009384526020842090910180546001600160a01b0319166001600160a01b03939093169290921790915590600e90878785818110610a0057610a00611ad8565b9050602002016020810190610a15919061189a565b6001600160a01b0316815260208101919091526040016000908120805460ff191692151592909217909155600c805491610a4e83611b17565b91905055505b600101610886565b5050505050565b6060600d805480602002602001604051908101604052809291908181526020018280548015610abb57602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311610a9d575b5050505050905090565b6001546001600160a01b03163314610b305760405162461bcd60e51b815260206004820152602860248201527f54686973206d6574686f64206973206f6e6c7920666f722070726573616c652060448201526710dbdb9d1c9858dd60c21b6064820152608401610651565b6007544310610b7a5760405162461bcd60e51b815260206004820152601660248201527514dd185ada5b99c81a185cc81899595b88195b99195960521b6044820152606401610651565b60008111610bca5760405162461bcd60e51b815260206004820152601c60248201527f4465706f73697420616d6f756e742063616e2774206265207a65726f000000006044820152606401610651565b6001600160a01b0382166000908152600960209081526040808320600e9092529091205460ff16610c6d57600d805460018082019092557fd7b6990105719101dabeb77144f2a3385c8033acd3af97e9423a695e81ad1eb50180546001600160a01b0319166001600160a01b0386169081179091556000908152600e60205260408120805460ff1916909217909155600c805491610c6783611b17565b91905055505b610c76836114b3565b81816000016000828254610c8a9190611abf565b9091555050600454815464e8d4a5100091610ca491611b30565b610cae9190611b47565b81600201819055504281600101819055508160026000828254610cd19190611abf565b9091555050604080516001600160a01b0385168152602081018490527f9e71bc8eea02a63969f509818f2dafb9254532904319f9dbda79b67bd34a5f3d910160405180910390a1600154600054610d36916001600160a01b0391821691163085611631565b505050565b610588611458565b6000600254600003610d5757506000919050565b60006007544311610d7457600354610d6f9043611aee565b610d84565b600354600754610d849190611aee565b9050600060055482610d969190611b30565b9050600060025464e8d4a5100083610dae9190611b30565b610db89190611b47565b600454610dc59190611abf565b6001600160a01b0386166000818152600960209081526040808320815160608101835281548152600182015481850152600290910154818301908152948452600b9092529091205491518151939450909264e8d4a5100090610e28908690611b30565b610e329190611b47565b610e3c9190611aee565b610e469190611abf565b9695505050505050565b610e58611458565b436003556000600455565b6000610e6d611458565b5060045490565b610e7c611458565b6002819055600154600054610e9f916001600160a01b0391821691163084611631565b610eab600d600061184c565b50565b610eb6611458565b60005b81811015610d36576000600a6000858585818110610ed957610ed9611ad8565b9050602002016020810190610eee919061189a565b6001600160a01b031681526020810191909152604001600020805460ff1916911515919091179055600101610eb9565b6007544310610f685760405162461bcd60e51b815260206004820152601660248201527514dd185ada5b99c81a185cc81899595b88195b99195960521b6044820152606401610651565b60008111610fb85760405162461bcd60e51b815260206004820152601c60248201527f4465706f73697420616d6f756e742063616e2774206265207a65726f000000006044820152606401610651565b336000908152600960209081526040808320600e9092529091205460ff1661104957600d805460018181019092557fd7b6990105719101dabeb77144f2a3385c8033acd3af97e9423a695e81ad1eb50180546001600160a01b031916339081179091556000908152600e60205260408120805460ff1916909217909155600c80549161104383611b17565b91905055505b611052336114b3565b818160000160008282546110669190611abf565b9091555050600454815464e8d4a510009161108091611b30565b61108a9190611b47565b816002018190555042816001018190555081600260008282546110ad9190611abf565b909155505060408051338152602081018490527f9e71bc8eea02a63969f509818f2dafb9254532904319f9dbda79b67bd34a5f3d910160405180910390a1600054610836906001600160a01b0316333085611631565b61110b611458565b600855565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a008054600160401b810460ff16159067ffffffffffffffff166000811580156111565750825b905060008267ffffffffffffffff1660011480156111735750303b155b905081158015611181575080155b1561119f5760405163f92ee8a960e01b815260040160405180910390fd5b845467ffffffffffffffff1916600117855583156111c957845460ff60401b1916600160401b1785555b6111d286611670565b6005899055600080546001600160a01b03808e166001600160a01b03199283161790925560018054928d169290911691909117905560068890556007879055831561125757845460ff60401b19168555604051600181527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15b5050505050505050505050565b600061126e611458565b5060035490565b61127d611458565b60005b81811015610d36576001600a60008585858181106112a0576112a0611ad8565b90506020020160208101906112b5919061189a565b6001600160a01b031681526020810191909152604001600020805460ff1916911515919091179055600101611280565b6112ed611458565b600755565b6112fa611458565b600180546001600160a01b0319166001600160a01b0392909216919091179055565b611324611458565b600655565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00805460029190600160401b900460ff16806113735750805467ffffffffffffffff808416911610155b156113915760405163f92ee8a960e01b815260040160405180910390fd5b805468ffffffffffffffffff191667ffffffffffffffff8316908117600160401b1760ff60401b191682556040519081527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15050565b6113fb611458565b6001600160a01b03811661142557604051631e4fbdf760e01b815260006004820152602401610651565b610eab81611681565b600d818154811061143e57600080fd5b6000918252602090912001546001600160a01b0316905081565b3361148a7f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c199300546001600160a01b031690565b6001600160a01b0316146105885760405163118cdaa760e01b8152336004820152602401610651565b6001600160a01b0381166000908152600a602052604090205460ff161561151c5760405162461bcd60e51b815260206004820152601b60248201527f54686973206164647265737320697320626c61636b6c697374656400000000006044820152606401610651565b6115246116f2565b6001600160a01b03811660009081526009602052604081206002810154600454825492939264e8d4a510009161155991611b30565b6115639190611b47565b61156d9190611aee565b90508060000361157c57505050565b600454825464e8d4a510009161159191611b30565b61159b9190611b47565b60028301556001600160a01b0383166000908152600b6020526040812080548392906115c8908490611abf565b9091555050505050565b6040516001600160a01b03838116602483015260448201839052610d3691859182169063a9059cbb906064015b604051602081830303815290604052915060e01b6020820180516001600160e01b03838183161783525050505061178a565b6040516001600160a01b03848116602483015283811660448301526064820183905261166a9186918216906323b872dd906084016115ff565b50505050565b6116786117fb565b610eab81611844565b7f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c19930080546001600160a01b031981166001600160a01b03848116918217845560405192169182907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3505050565b6002546000036117025743600355565b6000600754431161171f5760035461171a9043611aee565b61172f565b60035460075461172f9190611aee565b90506000600554826117419190611b30565b60025490915061175664e8d4a5100083611b30565b6117609190611b47565b60045461176d9190611abf565b600455600754431161177f5743611783565b6007545b6003555050565b600080602060008451602086016000885af1806117ad576040513d6000823e3d81fd5b50506000513d915081156117c55780600114156117d2565b6001600160a01b0384163b155b1561166a57604051635274afe760e01b81526001600160a01b0385166004820152602401610651565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a0054600160401b900460ff1661058857604051631afcd79f60e31b815260040160405180910390fd5b6113fb6117fb565b5080546000825590600052602060002090810190610eab91905b8082111561187a5760008155600101611866565b5090565b80356001600160a01b038116811461189557600080fd5b919050565b6000602082840312156118ac57600080fd5b6118b58261187e565b9392505050565b6000602082840312156118ce57600080fd5b5035919050565b60008083601f8401126118e757600080fd5b50813567ffffffffffffffff8111156118ff57600080fd5b6020830191508360208260051b850101111561191a57600080fd5b9250929050565b6000806000806040858703121561193757600080fd5b843567ffffffffffffffff81111561194e57600080fd5b61195a878288016118d5565b909550935050602085013567ffffffffffffffff81111561197a57600080fd5b611986878288016118d5565b95989497509550505050565b602080825282518282018190526000918401906040840190835b818110156119d35783516001600160a01b03168352602093840193909201916001016119ac565b509095945050505050565b600080604083850312156119f157600080fd5b6119fa8361187e565b946020939093013593505050565b60008060208385031215611a1b57600080fd5b823567ffffffffffffffff811115611a3257600080fd5b611a3e858286016118d5565b90969095509350505050565b60008060008060008060c08789031215611a6357600080fd5b611a6c8761187e565b9550611a7a6020880161187e565b9450604087013593506060870135925060808701359150611a9d60a0880161187e565b90509295509295509295565b634e487b7160e01b600052601160045260246000fd5b80820180821115611ad257611ad2611aa9565b92915050565b634e487b7160e01b600052603260045260246000fd5b81810381811115611ad257611ad2611aa9565b634e487b7160e01b600052603160045260246000fd5b600060018201611b2957611b29611aa9565b5060010190565b8082028115828204841417611ad257611ad2611aa9565b600082611b6457634e487b7160e01b600052601260045260246000fd5b50049056fea2646970667358221220fb58dcecba6c50a9e05037eadf31c15ba3c223abe392291a0f427ae7a8745e8264736f6c634300081b0033

Block Uncle Number Difficulty Gas Used Reward
View All Uncles
Loading...
Loading
Loading...
Loading
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.