ETH Price: $3,337.74 (+0.27%)
 

Overview

ETH Balance

0 ETH

Eth Value

$0.00

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To

There are no matching entries

1 Internal Transaction found.

Latest 1 internal transaction

Advanced mode:
Parent Transaction Hash Block
From
To
204148302024-07-29 21:11:59155 days ago1722287519  Contract Creation0 ETH
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
Staking

Compiler Version
v0.8.23+commit.f704f362

Optimization Enabled:
Yes with 1000000 runs

Other Settings:
paris EvmVersion
File 1 of 19 : Staking.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.23;

/*
.____                             ________
|    |   _____  ___.__. __________\_____  \
|    |   \__  \<   |  |/ __ \_  __ \_(__  <
|    |___ / __ \\___  \  ___/|  | \/       \
|_______ (____  / ____|\___  >__| /______  /
        \/    \/\/         \/            \/

https://layer3.xyz

Made with ♥ by Wonderland (https://defi.sucks)

*/

import {IDistributor} from 'interfaces/IDistributor.sol';
import {IStaking} from 'interfaces/IStaking.sol';
import {Ownable2StepUpgradeable} from 'openzeppelin-upgradeable/access/Ownable2StepUpgradeable.sol';

import {UUPSUpgradeable} from 'openzeppelin-upgradeable/proxy/utils/UUPSUpgradeable.sol';
import {PausableUpgradeable} from 'openzeppelin-upgradeable/utils/PausableUpgradeable.sol';
import {IERC20, SafeERC20} from 'openzeppelin/token/ERC20/utils/SafeERC20.sol';

import {Math} from 'openzeppelin/utils/math/Math.sol';
import {SafeCast} from 'openzeppelin/utils/math/SafeCast.sol';

contract Staking is IStaking, Ownable2StepUpgradeable, UUPSUpgradeable, PausableUpgradeable {
  using SafeERC20 for IERC20;
  using SafeCast for uint256;
  using Math for uint256;

  /// @notice The lockup periods
  uint256 internal constant _12_MONTHS = 12 * 30 days;
  uint256 internal constant _18_MONTHS = 18 * 30 days;
  uint256 internal constant _24_MONTHS = 24 * 30 days;
  uint256 internal constant _36_MONTHS = 36 * 30 days;

  /// @notice The base value for calculations
  uint256 internal constant _BASE = 1e18;

  /// @inheritdoc IStaking
  IERC20 public token;

  /// @inheritdoc IStaking
  IDistributor public distributor;

  /// @inheritdoc IStaking
  uint256 public rewardsDuration;

  /// @inheritdoc IStaking
  uint256 public periodFinish;

  /// @inheritdoc IStaking
  uint256 public lastUpdateTime;

  /// @inheritdoc IStaking
  uint256 public rewardPerSecond;

  /// @inheritdoc IStaking
  uint256 public rewardPerShare;

  /// @inheritdoc IStaking
  uint256 public totalRewards;

  /// @inheritdoc IStaking
  uint256 public totalDeposits;

  /// @inheritdoc IStaking
  uint256 public totalWeights;

  /// @inheritdoc IStaking
  uint256 public withdrawalPeriod;

  /// @inheritdoc IStaking
  mapping(address _user => Staker _staker) public stakers;

  /// @inheritdoc IStaking
  mapping(address _user => mapping(uint256 _index => Deposit _deposit)) public deposits;

  /// @custom:oz-upgrades-unsafe-allow constructor
  constructor() {
    _disableInitializers();
  }

  function initialize(IERC20 _token, IDistributor _distributor, address _owner) public initializer {
    token = _token;
    distributor = _distributor;
    rewardsDuration = 5 * 12 * 30 days;
    withdrawalPeriod = 7 days;

    __Ownable_init(_owner);
    __Ownable2Step_init();
    __UUPSUpgradeable_init();
    __Pausable_init();

    _pause();
  }

  /// @inheritdoc IStaking
  function stake(uint256 _amount, uint256 _lockupPeriod) external {
    Deposit memory _deposit = _stake(_amount, _lockupPeriod, msg.sender);
    emit Staked(msg.sender, _deposit.index, _deposit.amount, _deposit.lockupPeriod, _deposit.unlockAt);

    // Transfer the tokens to the contract
    token.safeTransferFrom(msg.sender, address(this), _amount);
  }

  /// @inheritdoc IStaking
  function stake(uint256 _amount, uint256 _lockupPeriod, address _user) external {
    if (msg.sender != address(distributor)) revert OnlyDistributor();
    // The distributor will transfer the tokens after calling this function
    Deposit memory _deposit = _stake(_amount, _lockupPeriod, _user);
    emit Staked(_user, _deposit.index, _deposit.amount, _deposit.lockupPeriod, _deposit.unlockAt);
  }

  /// @inheritdoc IStaking
  function increaseStake(uint256 _index, uint256 _amount) external {
    _increaseStake(_index, _amount, msg.sender);
    emit StakeIncreased(msg.sender, _index, _amount);

    // Transfer the tokens to the contract
    token.safeTransferFrom(msg.sender, address(this), _amount);
  }

  /// @inheritdoc IStaking
  function getReward() external {
    Staker storage _staker = _updateReward(msg.sender);
    uint256 _reward = _staker.pendingRewards;
    if (_reward > 0) {
      _staker.pendingRewards = 0;
      totalRewards -= _reward;
      token.safeTransfer(msg.sender, _reward);
      emit RewardPaid(msg.sender, _reward);
    }
  }

  /// @inheritdoc IStaking
  function getRewardAndStake(uint256 _lockupPeriod) external {
    Staker storage _staker = _updateReward(msg.sender);
    uint256 _reward = _staker.pendingRewards;
    if (_reward > 0) {
      _staker.pendingRewards = 0;
      Deposit memory _deposit = _stake(_reward, _lockupPeriod, msg.sender);
      totalRewards -= _reward;
      emit ClaimRewardAndStake(msg.sender, _deposit.index, _reward, _lockupPeriod);
    }
  }

  /// @inheritdoc IStaking
  function getRewardAndIncreaseStake(uint256 _index) external {
    Staker storage _staker = _updateReward(msg.sender);
    uint256 _reward = _staker.pendingRewards;
    if (_reward > 0) {
      _staker.pendingRewards = 0;
      _increaseStake(_index, _reward, msg.sender);
      totalRewards -= _reward;
      emit ClaimRewardAndIncreaseStake(msg.sender, _index, _reward);
    }
  }

  /// @inheritdoc IStaking
  function initiateWithdrawal(uint256 _index) external {
    // Get the Deposit struct
    Deposit storage _deposit = deposits[msg.sender][_index];

    if (_deposit.amount == 0) revert InvalidDepositIndex();
    if (_deposit.lockupPeriod > 0) revert DepositLocked();
    if (_deposit.withdrawAt > 0) revert WithdrawalAlreadyInitiated();

    _decreaseStake(_deposit);

    // Update the withdrawal timestamp
    _deposit.withdrawAt = (block.timestamp + withdrawalPeriod).toUint40();

    emit WithdrawalInitiated(msg.sender, _index, _deposit.withdrawAt);
  }

  /// @inheritdoc IStaking
  function cancelWithdrawal(uint256 _index) external {
    // Get the Deposit struct
    Deposit storage _deposit = deposits[msg.sender][_index];
    uint256 _amount = _deposit.amount;

    if (_deposit.amount == 0) revert InvalidDepositIndex();
    if (_deposit.withdrawAt == 0) revert WithdrawalNotInitiated();

    Staker storage _staker = _updateReward(msg.sender);

    // Because the deposit is unlocked, we're calculating the weight with a lockup period of 0
    uint256 _weight = _calculateWeight(0, _amount);

    // Update the total weights and user weight and reset the withdrawal timestamp
    totalWeights += _weight;
    _staker.weight += _weight.toUint128();
    _deposit.withdrawAt = 0;

    emit WithdrawalCancelled(msg.sender, _index);
  }

  /// @inheritdoc IStaking
  function withdraw(uint256 _index) external {
    // Get the Deposit struct
    Deposit memory _deposit = deposits[msg.sender][_index];

    if (_deposit.amount == 0) revert InvalidDepositIndex();

    if (_deposit.lockupPeriod > 0) {
      if (_deposit.unlockAt > block.timestamp) revert DepositLocked();
      _decreaseStake(_deposit);
    } else if (withdrawalPeriod == 0 && _deposit.withdrawAt == 0) {
      _decreaseStake(_deposit);
    } else {
      // Non-lockup deposits can be withdrawn only after a withdrawal period
      if (_deposit.withdrawAt > block.timestamp) revert DepositNotWithdrawable();
      if (_deposit.withdrawAt == 0) revert WithdrawalNotInitiated();
      // Not updating weights because the deposit was already removed from the total in `initiateWithdrawal`
    }

    // Update the total deposits
    totalDeposits -= _deposit.amount;

    // Delete the deposit
    delete deposits[msg.sender][_index];

    // Transfer the tokens to the user
    token.safeTransfer(msg.sender, _deposit.amount);
    emit Withdrawn(msg.sender, _index, _deposit.amount);
  }

  /// @inheritdoc IStaking
  function emergencyWithdraw(uint256 _amount) external onlyOwner {
    if (_amount == 0) revert ZeroAmount();

    // Withdraw either the requested amount or the remaining balance
    uint256 _remainingBalance = token.balanceOf(address(this));
    uint256 _withdrawalAmount = _amount > _remainingBalance ? _remainingBalance : _amount;

    token.safeTransfer(owner(), _withdrawalAmount);
    emit EmergencyWithdrawn(owner(), _withdrawalAmount);
  }

  /// @inheritdoc IStaking
  function setRewardAmount(uint256 _reward) external onlyOwner {
    uint256 _currentBalance = token.balanceOf(address(this));
    if (_reward > _currentBalance - totalDeposits - totalRewards) revert InsufficientBalance();

    _updateReward(address(0));

    if (block.timestamp >= periodFinish) {
      rewardPerSecond = _reward / rewardsDuration;
    } else {
      uint256 _remaining = periodFinish - block.timestamp;
      uint256 _leftover = _remaining * rewardPerSecond;
      rewardPerSecond = (_reward + _leftover) / rewardsDuration;
    }

    lastUpdateTime = block.timestamp;
    periodFinish = block.timestamp + rewardsDuration;
    totalRewards += _reward;
    emit RewardAdded(_reward);
  }

  /// @inheritdoc IStaking
  function setRewardsDuration(uint256 _rewardsDuration) external onlyOwner {
    if (periodFinish > block.timestamp) revert PeriodNotFinished();

    uint256 _oldRewardsDuration = rewardsDuration;
    rewardsDuration = _rewardsDuration;
    emit RewardsDurationUpdated(_oldRewardsDuration, _rewardsDuration);
  }

  /// @inheritdoc IStaking
  function setWithdrawalPeriod(uint256 _withdrawalPeriod) external onlyOwner {
    uint256 _oldWithdrawalPeriod = withdrawalPeriod;

    withdrawalPeriod = _withdrawalPeriod;
    emit WithdrawalPeriodUpdated(_oldWithdrawalPeriod, _withdrawalPeriod);
  }

  /// @inheritdoc IStaking
  function pause() external onlyOwner {
    _pause();
  }

  /// @inheritdoc IStaking
  function unpause() external onlyOwner {
    _unpause();
  }

  /// @inheritdoc IStaking
  function setDistributorAddress(IDistributor _distributor) external onlyOwner {
    IDistributor _oldDistributor = distributor;

    distributor = _distributor;
    emit DistributorUpdated(_oldDistributor, _distributor);
  }

  /// @inheritdoc IStaking
  function collectDust(IERC20 _token, uint256 _amount) external onlyOwner {
    if (_token == token || address(_token) == address(0)) revert InvalidToken();
    if (_amount == 0) revert ZeroAmount();

    address _owner = owner();

    _token.safeTransfer(_owner, _amount);

    emit DustCollected(_owner, _token, _amount);
  }

  /// @inheritdoc IStaking
  function calculateAPY(uint256 _amount, uint256 _lockupPeriod) external view returns (uint256 _apy) {
    uint256 _weight = _calculateWeight(_lockupPeriod, _amount);
    uint256 _rewardPerYear = rewardPerSecond * _12_MONTHS * _BASE * 100;

    _apy = Math.mulDiv(_weight, _rewardPerYear, (totalWeights + _weight) * _amount);
  }

  /// @inheritdoc IStaking
  function calculateAPY(address _user, uint256 _index) external view returns (uint256 _apy) {
    Deposit memory _deposit = deposits[_user][_index];
    uint256 _weight = _calculateWeight(_deposit.lockupPeriod, _deposit.amount);
    uint256 _rewardPerYear = rewardPerSecond * _12_MONTHS * _BASE * 100;

    _apy = Math.mulDiv(_weight, _rewardPerYear, _deposit.amount * totalWeights);
  }

  /// @inheritdoc IStaking
  function listDeposits(
    address _user,
    uint256 _startFrom,
    uint256 _batchSize
  ) external view returns (Deposit[] memory _list) {
    uint256 _totalDeposits = stakers[_user].depositCount;

    // Return an empty array if non-existent user or no deposits
    if (_startFrom > _totalDeposits) {
      return _list;
    }

    if (_batchSize > _totalDeposits - _startFrom) {
      _batchSize = _totalDeposits - _startFrom;
    }

    _list = new Deposit[](_batchSize);

    uint256 _index;
    while (_index < _batchSize) {
      _list[_index] = deposits[_user][_startFrom + _index];
      ++_index;
    }
  }

  /// @inheritdoc IStaking
  function pendingRewards(address _user) public view returns (uint256 _pendingRewards) {
    Staker storage _staker = stakers[_user];

    // Staker's pendingRewards already accounts for rewards calculated prior to the last snapshot
    // We take the difference between the current rate and the one pendingRewards was calculated at
    // And work out the amount of rewards accumulated after the snapshot
    uint256 _rateDifferenceSinceSnapshot = _calculatedRewardPerShare() - _staker.rewardPerShareSnapshot;
    uint256 _rewardsSinceSnapshot = _staker.weight * _rateDifferenceSinceSnapshot / _BASE;
    _pendingRewards = _staker.pendingRewards + _rewardsSinceSnapshot;
  }

  /**
   * @notice Stakes the provided amount of tokens and increases the total weight
   * @param _amount The amount of tokens
   * @param _lockupPeriod The lockup period
   * @param _user The address of the user
   */
  function _stake(uint256 _amount, uint256 _lockupPeriod, address _user) internal returns (Deposit memory _deposit) {
    if (_amount == 0) revert ZeroAmount();
    Staker storage _staker = _updateReward(_user);

    // Calculate the user weight, taking into account the lockup period multiplier
    uint256 _weight = _calculateWeight(_lockupPeriod, _amount);

    // Update the total weights and user weight
    totalWeights += _weight;
    totalDeposits += _amount;
    _staker.weight += _weight.toUint128();

    // Get the last index and increment it
    uint256 _lastIndex = _staker.depositCount++;
    uint256 _unlockAt = block.timestamp + _lockupPeriod;

    _deposit = Deposit({
      amount: _amount.toUint128(),
      unlockAt: _unlockAt.toUint40(),
      lockupPeriod: _lockupPeriod.toUint32(),
      index: _lastIndex.toUint16(),
      withdrawAt: 0
    });

    // Create a new Deposit struct
    deposits[_user][_lastIndex] = _deposit;
  }

  /**
   * @notice Updates the reward rate and the staker's info
   * @param _user The address of the user
   * @return _staker The staker struct
   */
  function _updateReward(address _user) internal whenNotPaused returns (Staker storage _staker) {
    rewardPerShare = _calculatedRewardPerShare();
    lastUpdateTime = _lastTimeRewardApplicable();
    _staker = stakers[_user];
    if (_user != address(0)) {
      _staker.pendingRewards = pendingRewards(_user).toUint128();
      _staker.rewardPerShareSnapshot = rewardPerShare.toUint128();
    }
  }

  /**
   * @notice Adds the specified amount of tokens the specified deposit
   * @param _index The index of the deposit
   * @param _amount The amount of tokens
   * @param _user The address of the user
   * @dev Only unlocked deposits can be increased
   */
  function _increaseStake(uint256 _index, uint256 _amount, address _user) internal {
    Deposit storage _deposit = deposits[_user][_index];

    if (_deposit.amount == 0) revert InvalidDepositIndex();
    if (_deposit.lockupPeriod > 0) revert CannotIncreaseLockedStake();
    if (_deposit.withdrawAt > 0) revert WithdrawalAlreadyInitiated();

    // Because the deposit is unlocked, we're calculating the weight with a lockup period of 0
    uint256 _weight = _calculateWeight(0, _amount);

    // Update the total weights and user weight
    Staker storage _staker = _updateReward(_user);
    totalWeights += _weight;
    totalDeposits += _amount;
    _staker.weight += _weight.toUint128();
    _deposit.amount += _amount.toUint128();
  }

  /**
   * @notice Decreases the stake of the specified deposit
   * @param _deposit The deposit to decrease
   */
  function _decreaseStake(Deposit memory _deposit) internal {
    Staker storage _staker = _updateReward(msg.sender);

    // Calculate the user weight
    uint256 _weight = _calculateWeight(_deposit.lockupPeriod, _deposit.amount);

    // Avoid rounding issues where `weight(a) + weight(b) <= weight(a+b)` that may cause underflows
    _weight = _weight <= _staker.weight ? _weight : _staker.weight;

    // Update the total weights and user weight
    totalWeights -= _weight;
    _staker.weight -= _weight.toUint128();
  }

  /**
   * @notice Returns either the current time or the end of the rewards period, whichever is earlier
   * @return _lastTimeReward The timestamp of the last time rewards were applicable
   */
  function _lastTimeRewardApplicable() internal view returns (uint256 _lastTimeReward) {
    _lastTimeReward = block.timestamp < periodFinish ? block.timestamp : periodFinish;
  }

  /**
   * @notice Calculates the reward per share
   * @return _rewardPerShare The reward per share
   */
  function _calculatedRewardPerShare() internal view returns (uint256 _rewardPerShare) {
    if (totalWeights == 0) {
      return rewardPerShare;
    }

    uint256 _timeSinceLastUpdate = _lastTimeRewardApplicable() - lastUpdateTime;

    _rewardPerShare = rewardPerShare + _timeSinceLastUpdate * rewardPerSecond * _BASE / totalWeights;
  }

  /**
   * @notice Applies the lockup period multiplier to get the deposit's weight
   * @param _lockupPeriod The lockup period
   * @param _amount The amount of tokens
   * @return _weight The weight of the deposit
   */
  function _calculateWeight(uint256 _lockupPeriod, uint256 _amount) internal pure returns (uint256 _weight) {
    if (_lockupPeriod == 0) {
      _weight = _amount * 250 / 1000;
    } else if (_lockupPeriod == _12_MONTHS) {
      _weight = _amount * 500 / 1000;
    } else if (_lockupPeriod == _18_MONTHS) {
      _weight = _amount * 625 / 1000;
    } else if (_lockupPeriod == _24_MONTHS) {
      _weight = _amount * 750 / 1000;
    } else if (_lockupPeriod == _36_MONTHS) {
      _weight = _amount;
    } else {
      revert InvalidLockupPeriod();
    }
  }

  /**
   * @notice Checks if the contract upgrade is authorized
   * @param _newImplementation The address of the new implementation
   * @dev Only owner should be allowed to perform upgrades
   */
  function _authorizeUpgrade(address _newImplementation) internal override onlyOwner {}
}

File 2 of 19 : IDistributor.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.23;

import {IStaking} from 'interfaces/IStaking.sol';
import {IERC20} from 'openzeppelin/token/ERC20/IERC20.sol';

/**
 * @title Distributor Contract
 * @author Wonderland (https://defi.sucks)
 * @notice Distributes tokens to users based on a merkle root and a signature
 */
interface IDistributor {
  /*///////////////////////////////////////////////////////////////
                            EVENTS
  ///////////////////////////////////////////////////////////////*/

  /**
   * @notice Emitted when a user claims their tokens
   * @param _account The account that claimed the tokens
   * @param _amount The amount of tokens claimed
   */
  event Claimed(address indexed _account, uint256 _amount);

  /**
   * @notice Emitted when a user claims and stakes their tokens
   * @param _account The account that claimed and staked the tokens
   * @param _amount The amount of tokens claimed and staked
   * @param _lockupPeriod The lockup period for the deposit
   * @param _timestamp The timestamp at which the tokens were claimed and staked
   */
  event ClaimedAndStaked(address indexed _account, uint256 _amount, uint256 _lockupPeriod, uint256 _timestamp);

  /**
   * @notice Emitted when the owner withdraws tokens from the contract
   * @param _owner The owner that withdrew the tokens
   * @param _amount The amount of tokens withdrawn
   */
  event EmergencyWithdrawn(address indexed _owner, uint256 _amount);

  /**
   * @notice Emitted when the signer is updated by the owner
   * @param _oldSigner The old signer address
   * @param _newSigner The new signer address
   */
  event SignerUpdated(address indexed _oldSigner, address indexed _newSigner);

  /**
   * @notice Emitted when the owner collects dust tokens from the contract
   * @param _owner The owner that collected the dust tokens
   * @param _token The token address
   * @param _amount The amount of tokens collected
   */
  event DustCollected(address indexed _owner, IERC20 indexed _token, uint256 _amount);

  /*///////////////////////////////////////////////////////////////
                            ERRORS
  ///////////////////////////////////////////////////////////////*/

  /**
   * @notice Throws if the input amount is zero
   */
  error ZeroAmount();

  /**
   * @notice Throws if the user has already claimed their tokens
   */
  error AlreadyClaimed();

  /**
   * @notice Throws if the recovered signer is different from the expected signer
   */
  error InvalidSigner();

  /**
   * @notice Throws if the merkle verification fails
   */
  error InvalidProof();

  /**
   * @notice Throws if the new signer address is invalid
   */
  error InvalidNewSigner();

  /**
   * @notice Throws if the input token is invalid
   */
  error InvalidToken();

  /*///////////////////////////////////////////////////////////////
                            LOGIC
  ///////////////////////////////////////////////////////////////*/

  /**
   * @notice Verifies eligibility and transfers the tokens to the caller
   * @param _amount The amount of tokens to claim
   * @param _merkleProof The merkle proof of the claim
   * @param _signature The signature provided by the UI
   */
  function claim(uint256 _amount, bytes32[] calldata _merkleProof, bytes calldata _signature) external;

  /**
   * @notice Verifies eligibility and stakes the claimed tokens in the contract
   * @param _amount The amount of tokens to claim
   * @param _merkleProof The merkle proof for the claim
   * @param _signature The signature for verification of the claim data
   * @param _lockupPeriod The period of time to lock the tokens for
   */
  function claimAndStake(
    uint256 _amount,
    bytes32[] calldata _merkleProof,
    bytes calldata _signature,
    uint32 _lockupPeriod
  ) external;

  /**
   * @notice Sends any remaining tokens to the owner
   * @dev Only callable by the owner
   * @dev If the specified amount exceeds the available balance, the entire balance is withdrawn
   * @param _amount The amount of tokens to withdraw
   */
  function emergencyWithdraw(uint256 _amount) external;

  /**
   * @notice Updates the signer address
   * @dev Only callable by the owner
   * @param _newSigner The new signer address
   */
  function updateSigner(address _newSigner) external;

  /**
   * @notice Collects dust tokens from the contract
   * @dev Only the owner can call this function
   * @param _token The token to collect
   * @param _amount The amount of tokens to collect
   */
  function collectDust(IERC20 _token, uint256 _amount) external;

  /*///////////////////////////////////////////////////////////////
                            VARIABLES
  ///////////////////////////////////////////////////////////////*/

  /**
   * @notice The root of the merkle tree
   * @return _merkleRoot The root of the merkle tree
   */
  // solhint-disable-next-line func-name-mixedcase
  function MERKLE_ROOT() external view returns (bytes32 _merkleRoot);

  /**
   * @notice The token being distributed
   * @return _token The address of the token
   */
  // solhint-disable-next-line func-name-mixedcase
  function TOKEN() external view returns (IERC20 _token);

  /**
   * @notice The address of the staking contract
   * @return _staking The staking contract
   */
  // solhint-disable-next-line func-name-mixedcase
  function STAKING() external view returns (IStaking _staking);

  /**
   * @notice The address of the signer
   * @return _signer The address of the signer
   */
  function signer() external view returns (address _signer);

  /**
   * @notice Returns whether the user has claimed their tokens
   * @param _user The address of the user
   * @return _claimed Whether the user has claimed their tokens
   */
  function hasClaimed(address _user) external view returns (bool _claimed);
}

File 3 of 19 : IStaking.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.23;

import {IDistributor} from './IDistributor.sol';
import {IERC20} from 'openzeppelin/token/ERC20/utils/SafeERC20.sol';

interface IStaking {
  /*///////////////////////////////////////////////////////////////
                            STRUCTS
  ///////////////////////////////////////////////////////////////*/

  /**
   * @notice Deposit struct
   * @param amount The amount of tokens deposited
   * @param unlockAt The timestamp when the tokens can be unlocked
   * @param lockupPeriod The period the tokens are locked for to get the bonus
   * @param index The index of the deposit
   * @param withdrawAt The timestamp when the tokens can be withdrawn (after withdrawal period is over)
   */
  struct Deposit {
    uint128 amount;
    uint40 unlockAt;
    uint32 lockupPeriod;
    uint16 index;
    uint40 withdrawAt;
  }

  /**
   * @notice Staker struct
   * @param weight The combined weight of the staker's deposits
   * @param depositCount The number of deposits the staker has
   * @param rewardPerShareSnapshot The amount of rewards per share as seen at the last update
   * @param pendingRewards The amount of rewards available to be claimed by the staker
   */
  struct Staker {
    uint128 weight;
    uint128 depositCount;
    uint128 rewardPerShareSnapshot;
    uint128 pendingRewards;
  }

  /*///////////////////////////////////////////////////////////////
                                EVENTS
  ///////////////////////////////////////////////////////////////*/

  /**
   * @notice Emitted when the user stakes tokens
   * @param _user The user that staked the tokens
   * @param _index The index of the deposit
   * @param _amount The amount of tokens staked
   * @param _lockupPeriod The lockup period
   * @param _unlockAt The timestamp when the tokens can be withdrawn
   */
  event Staked(
    address indexed _user, uint256 indexed _index, uint256 _amount, uint256 _lockupPeriod, uint256 _unlockAt
  );

  /**
   * @notice Emitted when the user adds tokens to an existing stake
   * @param _user The user that staked the tokens
   * @param _index The index of the deposit
   * @param _amount The amount of tokens added
   */
  event StakeIncreased(address indexed _user, uint256 indexed _index, uint256 _amount);

  /**
   * @notice Emitted when the user claims pending rewards and creates a new deposit
   * @param _user The user that staked the rewards
   * @param _index The index of the created stake
   * @param _amount The amount of tokens staked
   * @param _lockupPeriod The lockup period
   */
  event ClaimRewardAndStake(address indexed _user, uint256 indexed _index, uint256 _amount, uint256 _lockupPeriod);

  /**
   * @notice Emitted when the user claims pending rewards and adds the tokens to an existing stake
   * @param _user The user that staked the tokens
   * @param _index The index of the deposit
   * @param _amount The amount of tokens added
   */
  event ClaimRewardAndIncreaseStake(address indexed _user, uint256 indexed _index, uint256 _amount);

  /**
   * @notice Emitted when the user initiates a withdrawal
   * @param _user The user that initiated the withdrawal
   * @param _index The index of the deposit
   * @param _withdrawAt The end of the withdrawal period
   */
  event WithdrawalInitiated(address indexed _user, uint256 indexed _index, uint256 _withdrawAt);

  /**
   * @notice Emitted when the user cancels the withdrawal
   * @param _user The user that cancelled the withdrawal
   * @param _index The index of the deposit
   */
  event WithdrawalCancelled(address indexed _user, uint256 indexed _index);

  /**
   * @notice Emitted when the user withdraws tokens
   * @param _user The user that withdrew the tokens
   * @param _index The index of the deposit
   * @param _amount The amount of tokens withdrawn
   */
  event Withdrawn(address indexed _user, uint256 indexed _index, uint256 _amount);

  /**
   * @notice Emitted when the user claims their rewards
   * @param _user The user that claimed the rewards
   * @param _amount The amount of rewards claimed
   */
  event RewardPaid(address indexed _user, uint256 _amount);

  /**
   * @notice Emitted when the reward amount is added
   * @param _reward The new reward amount
   */
  event RewardAdded(uint256 _reward);

  /**
   * @notice Emitted when the rewards duration is updated
   * @param _oldRewardsDuration The previous rewards duration
   * @param _rewardsDuration The new rewards duration
   */
  event RewardsDurationUpdated(uint256 _oldRewardsDuration, uint256 _rewardsDuration);

  /**
   * @notice Emitted when the dust tokens are collected
   * @param _owner The owner that collected the dust tokens
   * @param _token The token address
   * @param _amount The amount of tokens collected
   */
  event DustCollected(address indexed _owner, IERC20 _token, uint256 _amount);

  /**
   * @notice Emitted when the staked deposits and the rewards are retracted by the owner
   * @param _owner The owner that withdrew the tokens
   * @param _amount The amount of tokens retracted
   */
  event EmergencyWithdrawn(address indexed _owner, uint256 _amount);

  /**
   * @notice Emitted when the withdrawal period is updated
   * @param _oldWithdrawalPeriod The previous withdrawal period
   * @param _withdrawalPeriod The new withdrawal period
   */
  event WithdrawalPeriodUpdated(uint256 _oldWithdrawalPeriod, uint256 _withdrawalPeriod);

  /**
   * @notice Emitted when the distributor address is updated
   * @param _oldDistributor The previous distributor
   * @param _distributor The new distributor
   */
  event DistributorUpdated(IDistributor _oldDistributor, IDistributor _distributor);

  /*///////////////////////////////////////////////////////////////
                                ERRORS
  ///////////////////////////////////////////////////////////////*/

  /**
   * @notice Throws if the provided amount is zero
   */
  error ZeroAmount();

  /**
   * @notice Throws if the deposit with the given index does not exist
   */
  error InvalidDepositIndex();

  /**
   * @notice Throws if trying to withdraw a locked deposit
   */
  error DepositLocked();

  /**
   * @notice Throws if the lockup period is invalid
   */
  error InvalidLockupPeriod();

  /**
   * @notice Throws if the staking contract has insufficient balance to pay the rewards at the given rate
   */
  error InsufficientBalance();

  /**
   * @notice Throws if the period is not finished
   */
  error PeriodNotFinished();

  /**
   * @notice Throws if the token is invalid
   */
  error InvalidToken();

  /**
   * @notice Throws if the caller is not the distributor
   */
  error OnlyDistributor();

  /**
   * @notice Throws if the caller is trying to add tokens to a locked deposit
   */
  error CannotIncreaseLockedStake();

  /**
   * @notice Throws if the withdrawal is not initiated while trying to withdraw
   */
  error WithdrawalNotInitiated();

  /**
   * @notice Throws if the caller is trying to initiate a withdrawal of a deposit that's already in the withdrawal process
   */
  error WithdrawalAlreadyInitiated();

  /**
   * @notice Throws if the withdrawal period is not over while trying to withdraw
   */
  error DepositNotWithdrawable();

  /*///////////////////////////////////////////////////////////////
                            VARIABLES
  ///////////////////////////////////////////////////////////////*/

  /**
   * @notice The address of the token contract
   * @return _token The token contract
   */
  function token() external view returns (IERC20 _token);

  /**
   * @notice The address of the distributor contract
   * @return _distributor The distributor contract
   */
  function distributor() external view returns (IDistributor _distributor);

  /**
   * @notice The time period in seconds over which rewards are distributed
   * @return _rewardsDuration The rewards duration
   */
  function rewardsDuration() external view returns (uint256 _rewardsDuration);

  /**
   * @notice Returns the timestamp of the last block at which the rewards will be distributed
   * @return _periodFinish The end of the rewards period
   */
  function periodFinish() external view returns (uint256 _periodFinish);

  /**
   * @notice The amount of rewards given to the stakers every second
   * @return _rewardPerSecond The amount of reward per second
   */
  function rewardPerSecond() external view returns (uint256 _rewardPerSecond);

  /**
   * @notice The time the reward per second was updated
   * @return _lastUpdateTime The last time the reward per second was updated
   */
  function lastUpdateTime() external view returns (uint256 _lastUpdateTime);

  /**
   * @notice The total weight of the deposits in the contract
   * @return _totalWeights The total weight of the deposits
   */
  function totalWeights() external view returns (uint256 _totalWeights);

  /**
   * @notice The total amount of tokens staked in the contract
   * @return _totalDeposits The amount of tokens staked in the contract
   */
  function totalDeposits() external view returns (uint256 _totalDeposits);

  /**
   * @notice The amount of tokens intended to be distributed as rewards
   * @return _totalRewards The total reward amount
   */
  function totalRewards() external view returns (uint256 _totalRewards);

  /**
   * @notice The reward generated per staker's share of the pool
   * @return _rewardPerShare The reward per share
   */
  function rewardPerShare() external view returns (uint256 _rewardPerShare);

  /**
   * @notice The time period in seconds after which the staker can withdraw their tokens
   * @dev This is only needed for non-lockup deposits
   * @return _withdrawalPeriod The withdrawal period
   */
  function withdrawalPeriod() external view returns (uint256 _withdrawalPeriod);

  /**
   * @notice Provides information about a given staker
   * @param _user The staker's address
   * @return _weight The total weight of the staker's deposits
   * @return _depositCount The number of deposits the staker has
   * @return _rewardPerShareSnapshot The amount of rewards per share as seen at the last update
   * @return _pendingRewards The amount of rewards pending to be claimed by the staker
   */
  function stakers(address _user)
    external
    view
    returns (uint128 _weight, uint128 _depositCount, uint128 _rewardPerShareSnapshot, uint128 _pendingRewards);

  /**
   * @notice Returns a user's deposit with the given index
   * @param _user The address of the user
   * @param _depositIndex The index of the deposit
   * @return _amount The amount of tokens deposited
   * @return _unlockAt The timestamp when the tokens can be withdrawn
   * @return _lockupPeriod The period the tokens are locked to get the bonus
   * @return _index The index of the deposit
   */
  function deposits(
    address _user,
    uint256 _depositIndex
  ) external view returns (uint128 _amount, uint40 _unlockAt, uint32 _lockupPeriod, uint16 _index, uint40 _withdrawAt);

  /*///////////////////////////////////////////////////////////////
                        EXTERNAL FUNCTIONS
  ///////////////////////////////////////////////////////////////*/

  /**
   * @notice The list of deposits of the user
   * @param _user The address of the user
   * @param _startFrom The index to start from
   * @param _batchSize The size of the batch
   * @return _list The list of deposits
   */
  function listDeposits(
    address _user,
    uint256 _startFrom,
    uint256 _batchSize
  ) external view returns (Deposit[] memory _list);

  /**
   * @notice Calculates APY based on the given amount and the lockup period
   * @param _amount The amount of tokens to stake
   * @param _lockupPeriod The lockup period
   * @return _apy The APY the staker would get
   */
  function calculateAPY(uint256 _amount, uint256 _lockupPeriod) external view returns (uint256 _apy);

  /**
   * @notice Returns the APY of an existing deposit
   * @param _user The staker address
   * @param _index The index of the deposit
   * @return _apy The APY the deposit is generating
   */
  function calculateAPY(address _user, uint256 _index) external view returns (uint256 _apy);

  /**
   * @notice The amount of pending rewards the staker has
   * @param _user The address of the user
   * @return _pendingRewards The amount of the rewards ready to be claimed
   */
  function pendingRewards(address _user) external view returns (uint256 _pendingRewards);

  /**
   * @notice The stake function
   * @param _amount The amount of tokens
   * @param _lockupPeriod The lockup period, must be either 0 or one of the allowed lockup periods
   */
  function stake(uint256 _amount, uint256 _lockupPeriod) external;

  /**
   * @notice The stake function for the distributor, allowing to stake on behalf of another address
   * @param _amount The amount of tokens
   * @param _lockupPeriod The lockup period, must be either 0 or one of the allowed lockup periods
   * @param _user The address of the user to stake for
   */
  function stake(uint256 _amount, uint256 _lockupPeriod, address _user) external;

  /**
   * @notice Add the provided amount of tokens to an existing stake
   * @param _amount The amount of tokens to add
   * @param _index The index of the deposit to increase
   */
  function increaseStake(uint256 _index, uint256 _amount) external;

  /**
   * @notice Claims pending rewards and adds them to an existing stake
   * @param _index The index of the deposit to increase
   */
  function getRewardAndIncreaseStake(uint256 _index) external;

  /**
   * @notice Initiates a withdrawal of the deposit
   * @dev The tokens will be locked for the withdrawal period
   * @dev Only needed for non-lockup deposits
   * @param _index The index of the deposit to withdraw
   */
  function initiateWithdrawal(uint256 _index) external;

  /**
   * @notice Cancels the withdrawal of the deposit
   * @param _index The index of the deposit to cancel the withdrawal
   */
  function cancelWithdrawal(uint256 _index) external;

  /**
   * @notice The withdraw function
   * @param _index The index of the deposit to withdraw
   */
  function withdraw(uint256 _index) external;

  /**
   * @notice Transfers pending rewards to the caller
   */
  function getReward() external;

  /**
   * @notice Claims the pending rewards and creates an unlocked deposit from them
   * @param _lockupPeriod The lockup period, must be either 0 or one of the allowed lockup periods
   */
  function getRewardAndStake(uint256 _lockupPeriod) external;

  /**
   * @notice Updates the total amount of rewards for the stakers
   * @param _reward The new reward amount
   */
  function setRewardAmount(uint256 _reward) external;

  /**
   * @notice Updates the rewards duration
   * @param _rewardsDuration The new rewards duration
   */
  function setRewardsDuration(uint256 _rewardsDuration) external;

  /**
   * @notice Updates the distributor address
   * @param _distributor The new distributor
   */
  function setDistributorAddress(IDistributor _distributor) external;

  /**
   * @notice Sends any dust tokens to the owner
   * @param _token The token address
   * @param _amount The amount of tokens to withdraw
   */
  function collectDust(IERC20 _token, uint256 _amount) external;

  /**
   * @notice An emergency function which sends the specified number of tokens to the owner
   * @param _amount The amount of tokens to withdraw
   */
  function emergencyWithdraw(uint256 _amount) external;

  /**
   * @notice Updates the withdrawal period
   * @param _withdrawalPeriod The new withdrawal period
   */
  function setWithdrawalPeriod(uint256 _withdrawalPeriod) external;

  /**
   * @notice Pauses the staking and withdrawals
   */
  function pause() external;

  /**
   * @notice Unpauses the staking and withdrawals
   */
  function unpause() external;
}

File 4 of 19 : Ownable2StepUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable2Step.sol)

pragma solidity ^0.8.20;

import {OwnableUpgradeable} from "./OwnableUpgradeable.sol";
import {Initializable} from "../proxy/utils/Initializable.sol";

/**
 * @dev Contract module which provides access control mechanism, where
 * there is an account (an owner) that can be granted exclusive access to
 * specific functions.
 *
 * The initial owner is specified at deployment time in the constructor for `Ownable`. This
 * can later be changed with {transferOwnership} and {acceptOwnership}.
 *
 * This module is used through inheritance. It will make available all functions
 * from parent (Ownable).
 */
abstract contract Ownable2StepUpgradeable is Initializable, OwnableUpgradeable {
    /// @custom:storage-location erc7201:openzeppelin.storage.Ownable2Step
    struct Ownable2StepStorage {
        address _pendingOwner;
    }

    // keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.Ownable2Step")) - 1)) & ~bytes32(uint256(0xff))
    bytes32 private constant Ownable2StepStorageLocation = 0x237e158222e3e6968b72b9db0d8043aacf074ad9f650f0d1606b4d82ee432c00;

    function _getOwnable2StepStorage() private pure returns (Ownable2StepStorage storage $) {
        assembly {
            $.slot := Ownable2StepStorageLocation
        }
    }

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

    function __Ownable2Step_init() internal onlyInitializing {
    }

    function __Ownable2Step_init_unchained() internal onlyInitializing {
    }
    /**
     * @dev Returns the address of the pending owner.
     */
    function pendingOwner() public view virtual returns (address) {
        Ownable2StepStorage storage $ = _getOwnable2StepStorage();
        return $._pendingOwner;
    }

    /**
     * @dev Starts the ownership transfer of the contract to a new account. Replaces the pending transfer if there is one.
     * Can only be called by the current owner.
     */
    function transferOwnership(address newOwner) public virtual override onlyOwner {
        Ownable2StepStorage storage $ = _getOwnable2StepStorage();
        $._pendingOwner = newOwner;
        emit OwnershipTransferStarted(owner(), newOwner);
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`) and deletes any pending owner.
     * Internal function without access restriction.
     */
    function _transferOwnership(address newOwner) internal virtual override {
        Ownable2StepStorage storage $ = _getOwnable2StepStorage();
        delete $._pendingOwner;
        super._transferOwnership(newOwner);
    }

    /**
     * @dev The new owner accepts the ownership transfer.
     */
    function acceptOwnership() public virtual {
        address sender = _msgSender();
        if (pendingOwner() != sender) {
            revert OwnableUnauthorizedAccount(sender);
        }
        _transferOwnership(sender);
    }
}

File 5 of 19 : UUPSUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (proxy/utils/UUPSUpgradeable.sol)

pragma solidity ^0.8.20;

import {IERC1822Proxiable} from "@openzeppelin/contracts/interfaces/draft-IERC1822.sol";
import {ERC1967Utils} from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Utils.sol";
import {Initializable} from "./Initializable.sol";

/**
 * @dev An upgradeability mechanism designed for UUPS proxies. The functions included here can perform an upgrade of an
 * {ERC1967Proxy}, when this contract is set as the implementation behind such a proxy.
 *
 * A security mechanism ensures that an upgrade does not turn off upgradeability accidentally, although this risk is
 * reinstated if the upgrade retains upgradeability but removes the security mechanism, e.g. by replacing
 * `UUPSUpgradeable` with a custom implementation of upgrades.
 *
 * The {_authorizeUpgrade} function must be overridden to include access restriction to the upgrade mechanism.
 */
abstract contract UUPSUpgradeable is Initializable, IERC1822Proxiable {
    /// @custom:oz-upgrades-unsafe-allow state-variable-immutable
    address private immutable __self = address(this);

    /**
     * @dev The version of the upgrade interface of the contract. If this getter is missing, both `upgradeTo(address)`
     * and `upgradeToAndCall(address,bytes)` are present, and `upgradeTo` must be used if no function should be called,
     * while `upgradeToAndCall` will invoke the `receive` function if the second argument is the empty byte string.
     * If the getter returns `"5.0.0"`, only `upgradeToAndCall(address,bytes)` is present, and the second argument must
     * be the empty byte string if no function should be called, making it impossible to invoke the `receive` function
     * during an upgrade.
     */
    string public constant UPGRADE_INTERFACE_VERSION = "5.0.0";

    /**
     * @dev The call is from an unauthorized context.
     */
    error UUPSUnauthorizedCallContext();

    /**
     * @dev The storage `slot` is unsupported as a UUID.
     */
    error UUPSUnsupportedProxiableUUID(bytes32 slot);

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

    /**
     * @dev Check that the execution is not being performed through a delegate call. This allows a function to be
     * callable on the implementing contract but not through proxies.
     */
    modifier notDelegated() {
        _checkNotDelegated();
        _;
    }

    function __UUPSUpgradeable_init() internal onlyInitializing {
    }

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

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

    /**
     * @dev Reverts if the execution is not performed via delegatecall or the execution
     * context is not of a proxy with an ERC1967-compliant implementation pointing to self.
     * See {_onlyProxy}.
     */
    function _checkProxy() internal view virtual {
        if (
            address(this) == __self || // Must be called through delegatecall
            ERC1967Utils.getImplementation() != __self // Must be called through an active proxy
        ) {
            revert UUPSUnauthorizedCallContext();
        }
    }

    /**
     * @dev Reverts if the execution is performed via delegatecall.
     * See {notDelegated}.
     */
    function _checkNotDelegated() internal view virtual {
        if (address(this) != __self) {
            // Must not be called through delegatecall
            revert UUPSUnauthorizedCallContext();
        }
    }

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

    /**
     * @dev Performs an implementation upgrade with a security check for UUPS proxies, and additional setup call.
     *
     * As a security check, {proxiableUUID} is invoked in the new implementation, and the return value
     * is expected to be the implementation slot in ERC1967.
     *
     * Emits an {IERC1967-Upgraded} event.
     */
    function _upgradeToAndCallUUPS(address newImplementation, bytes memory data) private {
        try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) {
            if (slot != ERC1967Utils.IMPLEMENTATION_SLOT) {
                revert UUPSUnsupportedProxiableUUID(slot);
            }
            ERC1967Utils.upgradeToAndCall(newImplementation, data);
        } catch {
            // The implementation is not UUPS
            revert ERC1967Utils.ERC1967InvalidImplementation(newImplementation);
        }
    }
}

File 6 of 19 : PausableUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/Pausable.sol)

pragma solidity ^0.8.20;

import {ContextUpgradeable} from "../utils/ContextUpgradeable.sol";
import {Initializable} from "../proxy/utils/Initializable.sol";

/**
 * @dev Contract module which allows children to implement an emergency stop
 * mechanism that can be triggered by an authorized account.
 *
 * This module is used through inheritance. It will make available the
 * modifiers `whenNotPaused` and `whenPaused`, which can be applied to
 * the functions of your contract. Note that they will not be pausable by
 * simply including this module, only once the modifiers are put in place.
 */
abstract contract PausableUpgradeable is Initializable, ContextUpgradeable {
    /// @custom:storage-location erc7201:openzeppelin.storage.Pausable
    struct PausableStorage {
        bool _paused;
    }

    // keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.Pausable")) - 1)) & ~bytes32(uint256(0xff))
    bytes32 private constant PausableStorageLocation = 0xcd5ed15c6e187e77e9aee88184c21f4f2182ab5827cb3b7e07fbedcd63f03300;

    function _getPausableStorage() private pure returns (PausableStorage storage $) {
        assembly {
            $.slot := PausableStorageLocation
        }
    }

    /**
     * @dev Emitted when the pause is triggered by `account`.
     */
    event Paused(address account);

    /**
     * @dev Emitted when the pause is lifted by `account`.
     */
    event Unpaused(address account);

    /**
     * @dev The operation failed because the contract is paused.
     */
    error EnforcedPause();

    /**
     * @dev The operation failed because the contract is not paused.
     */
    error ExpectedPause();

    /**
     * @dev Initializes the contract in unpaused state.
     */
    function __Pausable_init() internal onlyInitializing {
        __Pausable_init_unchained();
    }

    function __Pausable_init_unchained() internal onlyInitializing {
        PausableStorage storage $ = _getPausableStorage();
        $._paused = false;
    }

    /**
     * @dev Modifier to make a function callable only when the contract is not paused.
     *
     * Requirements:
     *
     * - The contract must not be paused.
     */
    modifier whenNotPaused() {
        _requireNotPaused();
        _;
    }

    /**
     * @dev Modifier to make a function callable only when the contract is paused.
     *
     * Requirements:
     *
     * - The contract must be paused.
     */
    modifier whenPaused() {
        _requirePaused();
        _;
    }

    /**
     * @dev Returns true if the contract is paused, and false otherwise.
     */
    function paused() public view virtual returns (bool) {
        PausableStorage storage $ = _getPausableStorage();
        return $._paused;
    }

    /**
     * @dev Throws if the contract is paused.
     */
    function _requireNotPaused() internal view virtual {
        if (paused()) {
            revert EnforcedPause();
        }
    }

    /**
     * @dev Throws if the contract is not paused.
     */
    function _requirePaused() internal view virtual {
        if (!paused()) {
            revert ExpectedPause();
        }
    }

    /**
     * @dev Triggers stopped state.
     *
     * Requirements:
     *
     * - The contract must not be paused.
     */
    function _pause() internal virtual whenNotPaused {
        PausableStorage storage $ = _getPausableStorage();
        $._paused = true;
        emit Paused(_msgSender());
    }

    /**
     * @dev Returns to normal state.
     *
     * Requirements:
     *
     * - The contract must be paused.
     */
    function _unpause() internal virtual whenPaused {
        PausableStorage storage $ = _getPausableStorage();
        $._paused = false;
        emit Unpaused(_msgSender());
    }
}

File 7 of 19 : SafeERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/utils/SafeERC20.sol)

pragma solidity ^0.8.20;

import {IERC20} from "../IERC20.sol";
import {IERC20Permit} from "../extensions/IERC20Permit.sol";
import {Address} from "../../../utils/Address.sol";

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

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

        bytes memory returndata = address(token).functionCall(data);
        if (returndata.length != 0 && !abi.decode(returndata, (bool))) {
            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 silents catches all reverts and returns a bool instead.
     */
    function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
        // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
        // we're implementing it ourselves. We cannot use {Address-functionCall} here since this should return false
        // and not revert is the subcall reverts.

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

File 8 of 19 : Math.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/math/Math.sol)

pragma solidity ^0.8.20;

/**
 * @dev Standard math utilities missing in the Solidity language.
 */
library Math {
    /**
     * @dev Muldiv operation overflow.
     */
    error MathOverflowedMulDiv();

    enum Rounding {
        Floor, // Toward negative infinity
        Ceil, // Toward positive infinity
        Trunc, // Toward zero
        Expand // Away from zero
    }

    /**
     * @dev Returns the addition of two unsigned integers, with an overflow flag.
     */
    function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            uint256 c = a + b;
            if (c < a) return (false, 0);
            return (true, c);
        }
    }

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

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

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

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

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

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

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

    /**
     * @dev Returns the ceiling of the division of two numbers.
     *
     * This differs from standard division with `/` in that it rounds towards infinity instead
     * of rounding towards zero.
     */
    function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
        if (b == 0) {
            // Guarantee the same behavior as in a regular Solidity division.
            return a / b;
        }

        // (a + b - 1) / b can overflow on addition, so we distribute.
        return a == 0 ? 0 : (a - 1) / b + 1;
    }

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

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

            // Make sure the result is less than 2^256. Also prevents denominator == 0.
            if (denominator <= prod1) {
                revert MathOverflowedMulDiv();
            }

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

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

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

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

            uint256 twos = denominator & (0 - denominator);
            assembly {
                // Divide denominator by twos.
                denominator := div(denominator, twos)

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    /**
     * @dev Returns whether a provided rounding mode is considered rounding up for unsigned integers.
     */
    function unsignedRoundsUp(Rounding rounding) internal pure returns (bool) {
        return uint8(rounding) % 2 == 1;
    }
}

File 9 of 19 : SafeCast.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/math/SafeCast.sol)
// This file was procedurally generated from scripts/generate/templates/SafeCast.js.

pragma solidity ^0.8.20;

/**
 * @dev Wrappers over Solidity's uintXX/intXX casting operators with added overflow
 * checks.
 *
 * Downcasting from uint256/int256 in Solidity does not revert on overflow. This can
 * easily result in undesired exploitation or bugs, since developers usually
 * assume that overflows raise errors. `SafeCast` restores this intuition by
 * reverting the transaction when such an operation overflows.
 *
 * Using this library instead of the unchecked operations eliminates an entire
 * class of bugs, so it's recommended to use it always.
 */
library SafeCast {
    /**
     * @dev Value doesn't fit in an uint of `bits` size.
     */
    error SafeCastOverflowedUintDowncast(uint8 bits, uint256 value);

    /**
     * @dev An int value doesn't fit in an uint of `bits` size.
     */
    error SafeCastOverflowedIntToUint(int256 value);

    /**
     * @dev Value doesn't fit in an int of `bits` size.
     */
    error SafeCastOverflowedIntDowncast(uint8 bits, int256 value);

    /**
     * @dev An uint value doesn't fit in an int of `bits` size.
     */
    error SafeCastOverflowedUintToInt(uint256 value);

    /**
     * @dev Returns the downcasted uint248 from uint256, reverting on
     * overflow (when the input is greater than largest uint248).
     *
     * Counterpart to Solidity's `uint248` operator.
     *
     * Requirements:
     *
     * - input must fit into 248 bits
     */
    function toUint248(uint256 value) internal pure returns (uint248) {
        if (value > type(uint248).max) {
            revert SafeCastOverflowedUintDowncast(248, value);
        }
        return uint248(value);
    }

    /**
     * @dev Returns the downcasted uint240 from uint256, reverting on
     * overflow (when the input is greater than largest uint240).
     *
     * Counterpart to Solidity's `uint240` operator.
     *
     * Requirements:
     *
     * - input must fit into 240 bits
     */
    function toUint240(uint256 value) internal pure returns (uint240) {
        if (value > type(uint240).max) {
            revert SafeCastOverflowedUintDowncast(240, value);
        }
        return uint240(value);
    }

    /**
     * @dev Returns the downcasted uint232 from uint256, reverting on
     * overflow (when the input is greater than largest uint232).
     *
     * Counterpart to Solidity's `uint232` operator.
     *
     * Requirements:
     *
     * - input must fit into 232 bits
     */
    function toUint232(uint256 value) internal pure returns (uint232) {
        if (value > type(uint232).max) {
            revert SafeCastOverflowedUintDowncast(232, value);
        }
        return uint232(value);
    }

    /**
     * @dev Returns the downcasted uint224 from uint256, reverting on
     * overflow (when the input is greater than largest uint224).
     *
     * Counterpart to Solidity's `uint224` operator.
     *
     * Requirements:
     *
     * - input must fit into 224 bits
     */
    function toUint224(uint256 value) internal pure returns (uint224) {
        if (value > type(uint224).max) {
            revert SafeCastOverflowedUintDowncast(224, value);
        }
        return uint224(value);
    }

    /**
     * @dev Returns the downcasted uint216 from uint256, reverting on
     * overflow (when the input is greater than largest uint216).
     *
     * Counterpart to Solidity's `uint216` operator.
     *
     * Requirements:
     *
     * - input must fit into 216 bits
     */
    function toUint216(uint256 value) internal pure returns (uint216) {
        if (value > type(uint216).max) {
            revert SafeCastOverflowedUintDowncast(216, value);
        }
        return uint216(value);
    }

    /**
     * @dev Returns the downcasted uint208 from uint256, reverting on
     * overflow (when the input is greater than largest uint208).
     *
     * Counterpart to Solidity's `uint208` operator.
     *
     * Requirements:
     *
     * - input must fit into 208 bits
     */
    function toUint208(uint256 value) internal pure returns (uint208) {
        if (value > type(uint208).max) {
            revert SafeCastOverflowedUintDowncast(208, value);
        }
        return uint208(value);
    }

    /**
     * @dev Returns the downcasted uint200 from uint256, reverting on
     * overflow (when the input is greater than largest uint200).
     *
     * Counterpart to Solidity's `uint200` operator.
     *
     * Requirements:
     *
     * - input must fit into 200 bits
     */
    function toUint200(uint256 value) internal pure returns (uint200) {
        if (value > type(uint200).max) {
            revert SafeCastOverflowedUintDowncast(200, value);
        }
        return uint200(value);
    }

    /**
     * @dev Returns the downcasted uint192 from uint256, reverting on
     * overflow (when the input is greater than largest uint192).
     *
     * Counterpart to Solidity's `uint192` operator.
     *
     * Requirements:
     *
     * - input must fit into 192 bits
     */
    function toUint192(uint256 value) internal pure returns (uint192) {
        if (value > type(uint192).max) {
            revert SafeCastOverflowedUintDowncast(192, value);
        }
        return uint192(value);
    }

    /**
     * @dev Returns the downcasted uint184 from uint256, reverting on
     * overflow (when the input is greater than largest uint184).
     *
     * Counterpart to Solidity's `uint184` operator.
     *
     * Requirements:
     *
     * - input must fit into 184 bits
     */
    function toUint184(uint256 value) internal pure returns (uint184) {
        if (value > type(uint184).max) {
            revert SafeCastOverflowedUintDowncast(184, value);
        }
        return uint184(value);
    }

    /**
     * @dev Returns the downcasted uint176 from uint256, reverting on
     * overflow (when the input is greater than largest uint176).
     *
     * Counterpart to Solidity's `uint176` operator.
     *
     * Requirements:
     *
     * - input must fit into 176 bits
     */
    function toUint176(uint256 value) internal pure returns (uint176) {
        if (value > type(uint176).max) {
            revert SafeCastOverflowedUintDowncast(176, value);
        }
        return uint176(value);
    }

    /**
     * @dev Returns the downcasted uint168 from uint256, reverting on
     * overflow (when the input is greater than largest uint168).
     *
     * Counterpart to Solidity's `uint168` operator.
     *
     * Requirements:
     *
     * - input must fit into 168 bits
     */
    function toUint168(uint256 value) internal pure returns (uint168) {
        if (value > type(uint168).max) {
            revert SafeCastOverflowedUintDowncast(168, value);
        }
        return uint168(value);
    }

    /**
     * @dev Returns the downcasted uint160 from uint256, reverting on
     * overflow (when the input is greater than largest uint160).
     *
     * Counterpart to Solidity's `uint160` operator.
     *
     * Requirements:
     *
     * - input must fit into 160 bits
     */
    function toUint160(uint256 value) internal pure returns (uint160) {
        if (value > type(uint160).max) {
            revert SafeCastOverflowedUintDowncast(160, value);
        }
        return uint160(value);
    }

    /**
     * @dev Returns the downcasted uint152 from uint256, reverting on
     * overflow (when the input is greater than largest uint152).
     *
     * Counterpart to Solidity's `uint152` operator.
     *
     * Requirements:
     *
     * - input must fit into 152 bits
     */
    function toUint152(uint256 value) internal pure returns (uint152) {
        if (value > type(uint152).max) {
            revert SafeCastOverflowedUintDowncast(152, value);
        }
        return uint152(value);
    }

    /**
     * @dev Returns the downcasted uint144 from uint256, reverting on
     * overflow (when the input is greater than largest uint144).
     *
     * Counterpart to Solidity's `uint144` operator.
     *
     * Requirements:
     *
     * - input must fit into 144 bits
     */
    function toUint144(uint256 value) internal pure returns (uint144) {
        if (value > type(uint144).max) {
            revert SafeCastOverflowedUintDowncast(144, value);
        }
        return uint144(value);
    }

    /**
     * @dev Returns the downcasted uint136 from uint256, reverting on
     * overflow (when the input is greater than largest uint136).
     *
     * Counterpart to Solidity's `uint136` operator.
     *
     * Requirements:
     *
     * - input must fit into 136 bits
     */
    function toUint136(uint256 value) internal pure returns (uint136) {
        if (value > type(uint136).max) {
            revert SafeCastOverflowedUintDowncast(136, value);
        }
        return uint136(value);
    }

    /**
     * @dev Returns the downcasted uint128 from uint256, reverting on
     * overflow (when the input is greater than largest uint128).
     *
     * Counterpart to Solidity's `uint128` operator.
     *
     * Requirements:
     *
     * - input must fit into 128 bits
     */
    function toUint128(uint256 value) internal pure returns (uint128) {
        if (value > type(uint128).max) {
            revert SafeCastOverflowedUintDowncast(128, value);
        }
        return uint128(value);
    }

    /**
     * @dev Returns the downcasted uint120 from uint256, reverting on
     * overflow (when the input is greater than largest uint120).
     *
     * Counterpart to Solidity's `uint120` operator.
     *
     * Requirements:
     *
     * - input must fit into 120 bits
     */
    function toUint120(uint256 value) internal pure returns (uint120) {
        if (value > type(uint120).max) {
            revert SafeCastOverflowedUintDowncast(120, value);
        }
        return uint120(value);
    }

    /**
     * @dev Returns the downcasted uint112 from uint256, reverting on
     * overflow (when the input is greater than largest uint112).
     *
     * Counterpart to Solidity's `uint112` operator.
     *
     * Requirements:
     *
     * - input must fit into 112 bits
     */
    function toUint112(uint256 value) internal pure returns (uint112) {
        if (value > type(uint112).max) {
            revert SafeCastOverflowedUintDowncast(112, value);
        }
        return uint112(value);
    }

    /**
     * @dev Returns the downcasted uint104 from uint256, reverting on
     * overflow (when the input is greater than largest uint104).
     *
     * Counterpart to Solidity's `uint104` operator.
     *
     * Requirements:
     *
     * - input must fit into 104 bits
     */
    function toUint104(uint256 value) internal pure returns (uint104) {
        if (value > type(uint104).max) {
            revert SafeCastOverflowedUintDowncast(104, value);
        }
        return uint104(value);
    }

    /**
     * @dev Returns the downcasted uint96 from uint256, reverting on
     * overflow (when the input is greater than largest uint96).
     *
     * Counterpart to Solidity's `uint96` operator.
     *
     * Requirements:
     *
     * - input must fit into 96 bits
     */
    function toUint96(uint256 value) internal pure returns (uint96) {
        if (value > type(uint96).max) {
            revert SafeCastOverflowedUintDowncast(96, value);
        }
        return uint96(value);
    }

    /**
     * @dev Returns the downcasted uint88 from uint256, reverting on
     * overflow (when the input is greater than largest uint88).
     *
     * Counterpart to Solidity's `uint88` operator.
     *
     * Requirements:
     *
     * - input must fit into 88 bits
     */
    function toUint88(uint256 value) internal pure returns (uint88) {
        if (value > type(uint88).max) {
            revert SafeCastOverflowedUintDowncast(88, value);
        }
        return uint88(value);
    }

    /**
     * @dev Returns the downcasted uint80 from uint256, reverting on
     * overflow (when the input is greater than largest uint80).
     *
     * Counterpart to Solidity's `uint80` operator.
     *
     * Requirements:
     *
     * - input must fit into 80 bits
     */
    function toUint80(uint256 value) internal pure returns (uint80) {
        if (value > type(uint80).max) {
            revert SafeCastOverflowedUintDowncast(80, value);
        }
        return uint80(value);
    }

    /**
     * @dev Returns the downcasted uint72 from uint256, reverting on
     * overflow (when the input is greater than largest uint72).
     *
     * Counterpart to Solidity's `uint72` operator.
     *
     * Requirements:
     *
     * - input must fit into 72 bits
     */
    function toUint72(uint256 value) internal pure returns (uint72) {
        if (value > type(uint72).max) {
            revert SafeCastOverflowedUintDowncast(72, value);
        }
        return uint72(value);
    }

    /**
     * @dev Returns the downcasted uint64 from uint256, reverting on
     * overflow (when the input is greater than largest uint64).
     *
     * Counterpart to Solidity's `uint64` operator.
     *
     * Requirements:
     *
     * - input must fit into 64 bits
     */
    function toUint64(uint256 value) internal pure returns (uint64) {
        if (value > type(uint64).max) {
            revert SafeCastOverflowedUintDowncast(64, value);
        }
        return uint64(value);
    }

    /**
     * @dev Returns the downcasted uint56 from uint256, reverting on
     * overflow (when the input is greater than largest uint56).
     *
     * Counterpart to Solidity's `uint56` operator.
     *
     * Requirements:
     *
     * - input must fit into 56 bits
     */
    function toUint56(uint256 value) internal pure returns (uint56) {
        if (value > type(uint56).max) {
            revert SafeCastOverflowedUintDowncast(56, value);
        }
        return uint56(value);
    }

    /**
     * @dev Returns the downcasted uint48 from uint256, reverting on
     * overflow (when the input is greater than largest uint48).
     *
     * Counterpart to Solidity's `uint48` operator.
     *
     * Requirements:
     *
     * - input must fit into 48 bits
     */
    function toUint48(uint256 value) internal pure returns (uint48) {
        if (value > type(uint48).max) {
            revert SafeCastOverflowedUintDowncast(48, value);
        }
        return uint48(value);
    }

    /**
     * @dev Returns the downcasted uint40 from uint256, reverting on
     * overflow (when the input is greater than largest uint40).
     *
     * Counterpart to Solidity's `uint40` operator.
     *
     * Requirements:
     *
     * - input must fit into 40 bits
     */
    function toUint40(uint256 value) internal pure returns (uint40) {
        if (value > type(uint40).max) {
            revert SafeCastOverflowedUintDowncast(40, value);
        }
        return uint40(value);
    }

    /**
     * @dev Returns the downcasted uint32 from uint256, reverting on
     * overflow (when the input is greater than largest uint32).
     *
     * Counterpart to Solidity's `uint32` operator.
     *
     * Requirements:
     *
     * - input must fit into 32 bits
     */
    function toUint32(uint256 value) internal pure returns (uint32) {
        if (value > type(uint32).max) {
            revert SafeCastOverflowedUintDowncast(32, value);
        }
        return uint32(value);
    }

    /**
     * @dev Returns the downcasted uint24 from uint256, reverting on
     * overflow (when the input is greater than largest uint24).
     *
     * Counterpart to Solidity's `uint24` operator.
     *
     * Requirements:
     *
     * - input must fit into 24 bits
     */
    function toUint24(uint256 value) internal pure returns (uint24) {
        if (value > type(uint24).max) {
            revert SafeCastOverflowedUintDowncast(24, value);
        }
        return uint24(value);
    }

    /**
     * @dev Returns the downcasted uint16 from uint256, reverting on
     * overflow (when the input is greater than largest uint16).
     *
     * Counterpart to Solidity's `uint16` operator.
     *
     * Requirements:
     *
     * - input must fit into 16 bits
     */
    function toUint16(uint256 value) internal pure returns (uint16) {
        if (value > type(uint16).max) {
            revert SafeCastOverflowedUintDowncast(16, value);
        }
        return uint16(value);
    }

    /**
     * @dev Returns the downcasted uint8 from uint256, reverting on
     * overflow (when the input is greater than largest uint8).
     *
     * Counterpart to Solidity's `uint8` operator.
     *
     * Requirements:
     *
     * - input must fit into 8 bits
     */
    function toUint8(uint256 value) internal pure returns (uint8) {
        if (value > type(uint8).max) {
            revert SafeCastOverflowedUintDowncast(8, value);
        }
        return uint8(value);
    }

    /**
     * @dev Converts a signed int256 into an unsigned uint256.
     *
     * Requirements:
     *
     * - input must be greater than or equal to 0.
     */
    function toUint256(int256 value) internal pure returns (uint256) {
        if (value < 0) {
            revert SafeCastOverflowedIntToUint(value);
        }
        return uint256(value);
    }

    /**
     * @dev Returns the downcasted int248 from int256, reverting on
     * overflow (when the input is less than smallest int248 or
     * greater than largest int248).
     *
     * Counterpart to Solidity's `int248` operator.
     *
     * Requirements:
     *
     * - input must fit into 248 bits
     */
    function toInt248(int256 value) internal pure returns (int248 downcasted) {
        downcasted = int248(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(248, value);
        }
    }

    /**
     * @dev Returns the downcasted int240 from int256, reverting on
     * overflow (when the input is less than smallest int240 or
     * greater than largest int240).
     *
     * Counterpart to Solidity's `int240` operator.
     *
     * Requirements:
     *
     * - input must fit into 240 bits
     */
    function toInt240(int256 value) internal pure returns (int240 downcasted) {
        downcasted = int240(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(240, value);
        }
    }

    /**
     * @dev Returns the downcasted int232 from int256, reverting on
     * overflow (when the input is less than smallest int232 or
     * greater than largest int232).
     *
     * Counterpart to Solidity's `int232` operator.
     *
     * Requirements:
     *
     * - input must fit into 232 bits
     */
    function toInt232(int256 value) internal pure returns (int232 downcasted) {
        downcasted = int232(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(232, value);
        }
    }

    /**
     * @dev Returns the downcasted int224 from int256, reverting on
     * overflow (when the input is less than smallest int224 or
     * greater than largest int224).
     *
     * Counterpart to Solidity's `int224` operator.
     *
     * Requirements:
     *
     * - input must fit into 224 bits
     */
    function toInt224(int256 value) internal pure returns (int224 downcasted) {
        downcasted = int224(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(224, value);
        }
    }

    /**
     * @dev Returns the downcasted int216 from int256, reverting on
     * overflow (when the input is less than smallest int216 or
     * greater than largest int216).
     *
     * Counterpart to Solidity's `int216` operator.
     *
     * Requirements:
     *
     * - input must fit into 216 bits
     */
    function toInt216(int256 value) internal pure returns (int216 downcasted) {
        downcasted = int216(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(216, value);
        }
    }

    /**
     * @dev Returns the downcasted int208 from int256, reverting on
     * overflow (when the input is less than smallest int208 or
     * greater than largest int208).
     *
     * Counterpart to Solidity's `int208` operator.
     *
     * Requirements:
     *
     * - input must fit into 208 bits
     */
    function toInt208(int256 value) internal pure returns (int208 downcasted) {
        downcasted = int208(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(208, value);
        }
    }

    /**
     * @dev Returns the downcasted int200 from int256, reverting on
     * overflow (when the input is less than smallest int200 or
     * greater than largest int200).
     *
     * Counterpart to Solidity's `int200` operator.
     *
     * Requirements:
     *
     * - input must fit into 200 bits
     */
    function toInt200(int256 value) internal pure returns (int200 downcasted) {
        downcasted = int200(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(200, value);
        }
    }

    /**
     * @dev Returns the downcasted int192 from int256, reverting on
     * overflow (when the input is less than smallest int192 or
     * greater than largest int192).
     *
     * Counterpart to Solidity's `int192` operator.
     *
     * Requirements:
     *
     * - input must fit into 192 bits
     */
    function toInt192(int256 value) internal pure returns (int192 downcasted) {
        downcasted = int192(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(192, value);
        }
    }

    /**
     * @dev Returns the downcasted int184 from int256, reverting on
     * overflow (when the input is less than smallest int184 or
     * greater than largest int184).
     *
     * Counterpart to Solidity's `int184` operator.
     *
     * Requirements:
     *
     * - input must fit into 184 bits
     */
    function toInt184(int256 value) internal pure returns (int184 downcasted) {
        downcasted = int184(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(184, value);
        }
    }

    /**
     * @dev Returns the downcasted int176 from int256, reverting on
     * overflow (when the input is less than smallest int176 or
     * greater than largest int176).
     *
     * Counterpart to Solidity's `int176` operator.
     *
     * Requirements:
     *
     * - input must fit into 176 bits
     */
    function toInt176(int256 value) internal pure returns (int176 downcasted) {
        downcasted = int176(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(176, value);
        }
    }

    /**
     * @dev Returns the downcasted int168 from int256, reverting on
     * overflow (when the input is less than smallest int168 or
     * greater than largest int168).
     *
     * Counterpart to Solidity's `int168` operator.
     *
     * Requirements:
     *
     * - input must fit into 168 bits
     */
    function toInt168(int256 value) internal pure returns (int168 downcasted) {
        downcasted = int168(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(168, value);
        }
    }

    /**
     * @dev Returns the downcasted int160 from int256, reverting on
     * overflow (when the input is less than smallest int160 or
     * greater than largest int160).
     *
     * Counterpart to Solidity's `int160` operator.
     *
     * Requirements:
     *
     * - input must fit into 160 bits
     */
    function toInt160(int256 value) internal pure returns (int160 downcasted) {
        downcasted = int160(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(160, value);
        }
    }

    /**
     * @dev Returns the downcasted int152 from int256, reverting on
     * overflow (when the input is less than smallest int152 or
     * greater than largest int152).
     *
     * Counterpart to Solidity's `int152` operator.
     *
     * Requirements:
     *
     * - input must fit into 152 bits
     */
    function toInt152(int256 value) internal pure returns (int152 downcasted) {
        downcasted = int152(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(152, value);
        }
    }

    /**
     * @dev Returns the downcasted int144 from int256, reverting on
     * overflow (when the input is less than smallest int144 or
     * greater than largest int144).
     *
     * Counterpart to Solidity's `int144` operator.
     *
     * Requirements:
     *
     * - input must fit into 144 bits
     */
    function toInt144(int256 value) internal pure returns (int144 downcasted) {
        downcasted = int144(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(144, value);
        }
    }

    /**
     * @dev Returns the downcasted int136 from int256, reverting on
     * overflow (when the input is less than smallest int136 or
     * greater than largest int136).
     *
     * Counterpart to Solidity's `int136` operator.
     *
     * Requirements:
     *
     * - input must fit into 136 bits
     */
    function toInt136(int256 value) internal pure returns (int136 downcasted) {
        downcasted = int136(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(136, value);
        }
    }

    /**
     * @dev Returns the downcasted int128 from int256, reverting on
     * overflow (when the input is less than smallest int128 or
     * greater than largest int128).
     *
     * Counterpart to Solidity's `int128` operator.
     *
     * Requirements:
     *
     * - input must fit into 128 bits
     */
    function toInt128(int256 value) internal pure returns (int128 downcasted) {
        downcasted = int128(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(128, value);
        }
    }

    /**
     * @dev Returns the downcasted int120 from int256, reverting on
     * overflow (when the input is less than smallest int120 or
     * greater than largest int120).
     *
     * Counterpart to Solidity's `int120` operator.
     *
     * Requirements:
     *
     * - input must fit into 120 bits
     */
    function toInt120(int256 value) internal pure returns (int120 downcasted) {
        downcasted = int120(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(120, value);
        }
    }

    /**
     * @dev Returns the downcasted int112 from int256, reverting on
     * overflow (when the input is less than smallest int112 or
     * greater than largest int112).
     *
     * Counterpart to Solidity's `int112` operator.
     *
     * Requirements:
     *
     * - input must fit into 112 bits
     */
    function toInt112(int256 value) internal pure returns (int112 downcasted) {
        downcasted = int112(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(112, value);
        }
    }

    /**
     * @dev Returns the downcasted int104 from int256, reverting on
     * overflow (when the input is less than smallest int104 or
     * greater than largest int104).
     *
     * Counterpart to Solidity's `int104` operator.
     *
     * Requirements:
     *
     * - input must fit into 104 bits
     */
    function toInt104(int256 value) internal pure returns (int104 downcasted) {
        downcasted = int104(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(104, value);
        }
    }

    /**
     * @dev Returns the downcasted int96 from int256, reverting on
     * overflow (when the input is less than smallest int96 or
     * greater than largest int96).
     *
     * Counterpart to Solidity's `int96` operator.
     *
     * Requirements:
     *
     * - input must fit into 96 bits
     */
    function toInt96(int256 value) internal pure returns (int96 downcasted) {
        downcasted = int96(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(96, value);
        }
    }

    /**
     * @dev Returns the downcasted int88 from int256, reverting on
     * overflow (when the input is less than smallest int88 or
     * greater than largest int88).
     *
     * Counterpart to Solidity's `int88` operator.
     *
     * Requirements:
     *
     * - input must fit into 88 bits
     */
    function toInt88(int256 value) internal pure returns (int88 downcasted) {
        downcasted = int88(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(88, value);
        }
    }

    /**
     * @dev Returns the downcasted int80 from int256, reverting on
     * overflow (when the input is less than smallest int80 or
     * greater than largest int80).
     *
     * Counterpart to Solidity's `int80` operator.
     *
     * Requirements:
     *
     * - input must fit into 80 bits
     */
    function toInt80(int256 value) internal pure returns (int80 downcasted) {
        downcasted = int80(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(80, value);
        }
    }

    /**
     * @dev Returns the downcasted int72 from int256, reverting on
     * overflow (when the input is less than smallest int72 or
     * greater than largest int72).
     *
     * Counterpart to Solidity's `int72` operator.
     *
     * Requirements:
     *
     * - input must fit into 72 bits
     */
    function toInt72(int256 value) internal pure returns (int72 downcasted) {
        downcasted = int72(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(72, value);
        }
    }

    /**
     * @dev Returns the downcasted int64 from int256, reverting on
     * overflow (when the input is less than smallest int64 or
     * greater than largest int64).
     *
     * Counterpart to Solidity's `int64` operator.
     *
     * Requirements:
     *
     * - input must fit into 64 bits
     */
    function toInt64(int256 value) internal pure returns (int64 downcasted) {
        downcasted = int64(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(64, value);
        }
    }

    /**
     * @dev Returns the downcasted int56 from int256, reverting on
     * overflow (when the input is less than smallest int56 or
     * greater than largest int56).
     *
     * Counterpart to Solidity's `int56` operator.
     *
     * Requirements:
     *
     * - input must fit into 56 bits
     */
    function toInt56(int256 value) internal pure returns (int56 downcasted) {
        downcasted = int56(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(56, value);
        }
    }

    /**
     * @dev Returns the downcasted int48 from int256, reverting on
     * overflow (when the input is less than smallest int48 or
     * greater than largest int48).
     *
     * Counterpart to Solidity's `int48` operator.
     *
     * Requirements:
     *
     * - input must fit into 48 bits
     */
    function toInt48(int256 value) internal pure returns (int48 downcasted) {
        downcasted = int48(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(48, value);
        }
    }

    /**
     * @dev Returns the downcasted int40 from int256, reverting on
     * overflow (when the input is less than smallest int40 or
     * greater than largest int40).
     *
     * Counterpart to Solidity's `int40` operator.
     *
     * Requirements:
     *
     * - input must fit into 40 bits
     */
    function toInt40(int256 value) internal pure returns (int40 downcasted) {
        downcasted = int40(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(40, value);
        }
    }

    /**
     * @dev Returns the downcasted int32 from int256, reverting on
     * overflow (when the input is less than smallest int32 or
     * greater than largest int32).
     *
     * Counterpart to Solidity's `int32` operator.
     *
     * Requirements:
     *
     * - input must fit into 32 bits
     */
    function toInt32(int256 value) internal pure returns (int32 downcasted) {
        downcasted = int32(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(32, value);
        }
    }

    /**
     * @dev Returns the downcasted int24 from int256, reverting on
     * overflow (when the input is less than smallest int24 or
     * greater than largest int24).
     *
     * Counterpart to Solidity's `int24` operator.
     *
     * Requirements:
     *
     * - input must fit into 24 bits
     */
    function toInt24(int256 value) internal pure returns (int24 downcasted) {
        downcasted = int24(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(24, value);
        }
    }

    /**
     * @dev Returns the downcasted int16 from int256, reverting on
     * overflow (when the input is less than smallest int16 or
     * greater than largest int16).
     *
     * Counterpart to Solidity's `int16` operator.
     *
     * Requirements:
     *
     * - input must fit into 16 bits
     */
    function toInt16(int256 value) internal pure returns (int16 downcasted) {
        downcasted = int16(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(16, value);
        }
    }

    /**
     * @dev Returns the downcasted int8 from int256, reverting on
     * overflow (when the input is less than smallest int8 or
     * greater than largest int8).
     *
     * Counterpart to Solidity's `int8` operator.
     *
     * Requirements:
     *
     * - input must fit into 8 bits
     */
    function toInt8(int256 value) internal pure returns (int8 downcasted) {
        downcasted = int8(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(8, value);
        }
    }

    /**
     * @dev Converts an unsigned uint256 into a signed int256.
     *
     * Requirements:
     *
     * - input must be less than or equal to maxInt256.
     */
    function toInt256(uint256 value) internal pure returns (int256) {
        // Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive
        if (value > uint256(type(int256).max)) {
            revert SafeCastOverflowedUintToInt(value);
        }
        return int256(value);
    }
}

File 10 of 19 : IERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/IERC20.sol)

pragma solidity ^0.8.20;

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

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

    /**
     * @dev Returns the 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);
}

File 11 of 19 : OwnableUpgradeable.sol
// 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);
    }
}

File 12 of 19 : Initializable.sol
// 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
        }
    }
}

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

pragma solidity ^0.8.20;

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

File 14 of 19 : ERC1967Utils.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (proxy/ERC1967/ERC1967Utils.sol)

pragma solidity ^0.8.20;

import {IBeacon} from "../beacon/IBeacon.sol";
import {Address} from "../../utils/Address.sol";
import {StorageSlot} from "../../utils/StorageSlot.sol";

/**
 * @dev This abstract contract provides getters and event emitting update functions for
 * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.
 */
library ERC1967Utils {
    // We re-declare ERC-1967 events here because they can't be used directly from IERC1967.
    // This will be fixed in Solidity 0.8.21. At that point we should remove these events.
    /**
     * @dev Emitted when the implementation is upgraded.
     */
    event Upgraded(address indexed implementation);

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

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

    /**
     * @dev Storage slot with the address of the current implementation.
     * This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1.
     */
    // solhint-disable-next-line private-vars-leading-underscore
    bytes32 internal constant IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;

    /**
     * @dev The `implementation` of the proxy is invalid.
     */
    error ERC1967InvalidImplementation(address implementation);

    /**
     * @dev The `admin` of the proxy is invalid.
     */
    error ERC1967InvalidAdmin(address admin);

    /**
     * @dev The `beacon` of the proxy is invalid.
     */
    error ERC1967InvalidBeacon(address beacon);

    /**
     * @dev An upgrade function sees `msg.value > 0` that may be lost.
     */
    error ERC1967NonPayable();

    /**
     * @dev Returns the current implementation address.
     */
    function getImplementation() internal view returns (address) {
        return StorageSlot.getAddressSlot(IMPLEMENTATION_SLOT).value;
    }

    /**
     * @dev Stores a new address in the EIP1967 implementation slot.
     */
    function _setImplementation(address newImplementation) private {
        if (newImplementation.code.length == 0) {
            revert ERC1967InvalidImplementation(newImplementation);
        }
        StorageSlot.getAddressSlot(IMPLEMENTATION_SLOT).value = newImplementation;
    }

    /**
     * @dev Performs implementation upgrade with additional setup call if data is nonempty.
     * This function is payable only if the setup call is performed, otherwise `msg.value` is rejected
     * to avoid stuck value in the contract.
     *
     * Emits an {IERC1967-Upgraded} event.
     */
    function upgradeToAndCall(address newImplementation, bytes memory data) internal {
        _setImplementation(newImplementation);
        emit Upgraded(newImplementation);

        if (data.length > 0) {
            Address.functionDelegateCall(newImplementation, data);
        } else {
            _checkNonPayable();
        }
    }

    /**
     * @dev Storage slot with the admin of the contract.
     * This is the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1.
     */
    // solhint-disable-next-line private-vars-leading-underscore
    bytes32 internal constant ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;

    /**
     * @dev Returns the current admin.
     *
     * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using
     * the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.
     * `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`
     */
    function getAdmin() internal view returns (address) {
        return StorageSlot.getAddressSlot(ADMIN_SLOT).value;
    }

    /**
     * @dev Stores a new address in the EIP1967 admin slot.
     */
    function _setAdmin(address newAdmin) private {
        if (newAdmin == address(0)) {
            revert ERC1967InvalidAdmin(address(0));
        }
        StorageSlot.getAddressSlot(ADMIN_SLOT).value = newAdmin;
    }

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

    /**
     * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.
     * This is the keccak-256 hash of "eip1967.proxy.beacon" subtracted by 1.
     */
    // solhint-disable-next-line private-vars-leading-underscore
    bytes32 internal constant BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;

    /**
     * @dev Returns the current beacon.
     */
    function getBeacon() internal view returns (address) {
        return StorageSlot.getAddressSlot(BEACON_SLOT).value;
    }

    /**
     * @dev Stores a new beacon in the EIP1967 beacon slot.
     */
    function _setBeacon(address newBeacon) private {
        if (newBeacon.code.length == 0) {
            revert ERC1967InvalidBeacon(newBeacon);
        }

        StorageSlot.getAddressSlot(BEACON_SLOT).value = newBeacon;

        address beaconImplementation = IBeacon(newBeacon).implementation();
        if (beaconImplementation.code.length == 0) {
            revert ERC1967InvalidImplementation(beaconImplementation);
        }
    }

    /**
     * @dev Change the beacon and trigger a setup call if data is nonempty.
     * This function is payable only if the setup call is performed, otherwise `msg.value` is rejected
     * to avoid stuck value in the contract.
     *
     * Emits an {IERC1967-BeaconUpgraded} event.
     *
     * CAUTION: Invoking this function has no effect on an instance of {BeaconProxy} since v5, since
     * it uses an immutable beacon without looking at the value of the ERC-1967 beacon slot for
     * efficiency.
     */
    function upgradeBeaconToAndCall(address newBeacon, bytes memory data) internal {
        _setBeacon(newBeacon);
        emit BeaconUpgraded(newBeacon);

        if (data.length > 0) {
            Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);
        } else {
            _checkNonPayable();
        }
    }

    /**
     * @dev Reverts if `msg.value` is not zero. It can be used to avoid `msg.value` stuck in the contract
     * if an upgrade doesn't perform an initialization call.
     */
    function _checkNonPayable() private {
        if (msg.value > 0) {
            revert ERC1967NonPayable();
        }
    }
}

File 15 of 19 : ContextUpgradeable.sol
// 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;
    }
}

File 16 of 19 : IERC20Permit.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/IERC20Permit.sol)

pragma solidity ^0.8.20;

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

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

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

File 17 of 19 : Address.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/Address.sol)

pragma solidity ^0.8.20;

/**
 * @dev Collection of functions related to the address type
 */
library Address {
    /**
     * @dev The ETH balance of the account is not enough to perform the operation.
     */
    error AddressInsufficientBalance(address account);

    /**
     * @dev There's no code at `target` (it is not a contract).
     */
    error AddressEmptyCode(address target);

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

    /**
     * @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 AddressInsufficientBalance(address(this));
        }

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

    /**
     * @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
     * {FailedInnerCall} 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 AddressInsufficientBalance(address(this));
        }
        (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 {FailedInnerCall}) 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 {FailedInnerCall} 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 {FailedInnerCall}.
     */
    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
            /// @solidity memory-safe-assembly
            assembly {
                let returndata_size := mload(returndata)
                revert(add(32, returndata), returndata_size)
            }
        } else {
            revert FailedInnerCall();
        }
    }
}

File 18 of 19 : IBeacon.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (proxy/beacon/IBeacon.sol)

pragma solidity ^0.8.20;

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

File 19 of 19 : StorageSlot.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/StorageSlot.sol)
// This file was procedurally generated from scripts/generate/templates/StorageSlot.js.

pragma solidity ^0.8.20;

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

    struct BooleanSlot {
        bool value;
    }

    struct Bytes32Slot {
        bytes32 value;
    }

    struct Uint256Slot {
        uint256 value;
    }

    struct StringSlot {
        string value;
    }

    struct BytesSlot {
        bytes value;
    }

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

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

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

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

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

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

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

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

Settings
{
  "remappings": [
    "ds-test/=node_modules/ds-test/src/",
    "forge-std/=node_modules/forge-std/src/",
    "openzeppelin/=node_modules/@openzeppelin/contracts/",
    "openzeppelin-upgradeable/=node_modules/@openzeppelin/contracts-upgradeable/",
    "contracts/=src/contracts/",
    "interfaces/=src/interfaces/",
    "@openzeppelin/=node_modules/@openzeppelin/",
    "openzeppelin-foundry-upgrades/=lib/openzeppelin-foundry-upgrades/src/",
    "solhint/=node_modules/solhint/",
    "solidity-stringutils/=lib/openzeppelin-foundry-upgrades/lib/solidity-stringutils/"
  ],
  "optimizer": {
    "enabled": true,
    "runs": 1000000
  },
  "metadata": {
    "useLiteralContent": false,
    "bytecodeHash": "ipfs",
    "appendCBOR": true
  },
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  },
  "evmVersion": "paris",
  "viaIR": false,
  "libraries": {}
}

Contract Security Audit

Contract ABI

[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"address","name":"target","type":"address"}],"name":"AddressEmptyCode","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"AddressInsufficientBalance","type":"error"},{"inputs":[],"name":"CannotIncreaseLockedStake","type":"error"},{"inputs":[],"name":"DepositLocked","type":"error"},{"inputs":[],"name":"DepositNotWithdrawable","type":"error"},{"inputs":[{"internalType":"address","name":"implementation","type":"address"}],"name":"ERC1967InvalidImplementation","type":"error"},{"inputs":[],"name":"ERC1967NonPayable","type":"error"},{"inputs":[],"name":"EnforcedPause","type":"error"},{"inputs":[],"name":"ExpectedPause","type":"error"},{"inputs":[],"name":"FailedInnerCall","type":"error"},{"inputs":[],"name":"InsufficientBalance","type":"error"},{"inputs":[],"name":"InvalidDepositIndex","type":"error"},{"inputs":[],"name":"InvalidInitialization","type":"error"},{"inputs":[],"name":"InvalidLockupPeriod","type":"error"},{"inputs":[],"name":"InvalidToken","type":"error"},{"inputs":[],"name":"MathOverflowedMulDiv","type":"error"},{"inputs":[],"name":"NotInitializing","type":"error"},{"inputs":[],"name":"OnlyDistributor","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":[],"name":"PeriodNotFinished","type":"error"},{"inputs":[{"internalType":"uint8","name":"bits","type":"uint8"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"SafeCastOverflowedUintDowncast","type":"error"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"SafeERC20FailedOperation","type":"error"},{"inputs":[],"name":"UUPSUnauthorizedCallContext","type":"error"},{"inputs":[{"internalType":"bytes32","name":"slot","type":"bytes32"}],"name":"UUPSUnsupportedProxiableUUID","type":"error"},{"inputs":[],"name":"WithdrawalAlreadyInitiated","type":"error"},{"inputs":[],"name":"WithdrawalNotInitiated","type":"error"},{"inputs":[],"name":"ZeroAmount","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_user","type":"address"},{"indexed":true,"internalType":"uint256","name":"_index","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"ClaimRewardAndIncreaseStake","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_user","type":"address"},{"indexed":true,"internalType":"uint256","name":"_index","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_lockupPeriod","type":"uint256"}],"name":"ClaimRewardAndStake","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"contract IDistributor","name":"_oldDistributor","type":"address"},{"indexed":false,"internalType":"contract IDistributor","name":"_distributor","type":"address"}],"name":"DistributorUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_owner","type":"address"},{"indexed":false,"internalType":"contract IERC20","name":"_token","type":"address"},{"indexed":false,"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"DustCollected","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_owner","type":"address"},{"indexed":false,"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"EmergencyWithdrawn","type":"event"},{"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":"OwnershipTransferStarted","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":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"_reward","type":"uint256"}],"name":"RewardAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_user","type":"address"},{"indexed":false,"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"RewardPaid","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"_oldRewardsDuration","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_rewardsDuration","type":"uint256"}],"name":"RewardsDurationUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_user","type":"address"},{"indexed":true,"internalType":"uint256","name":"_index","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"StakeIncreased","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_user","type":"address"},{"indexed":true,"internalType":"uint256","name":"_index","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_lockupPeriod","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_unlockAt","type":"uint256"}],"name":"Staked","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"implementation","type":"address"}],"name":"Upgraded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_user","type":"address"},{"indexed":true,"internalType":"uint256","name":"_index","type":"uint256"}],"name":"WithdrawalCancelled","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_user","type":"address"},{"indexed":true,"internalType":"uint256","name":"_index","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_withdrawAt","type":"uint256"}],"name":"WithdrawalInitiated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"_oldWithdrawalPeriod","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_withdrawalPeriod","type":"uint256"}],"name":"WithdrawalPeriodUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_user","type":"address"},{"indexed":true,"internalType":"uint256","name":"_index","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"Withdrawn","type":"event"},{"inputs":[],"name":"UPGRADE_INTERFACE_VERSION","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"acceptOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint256","name":"_index","type":"uint256"}],"name":"calculateAPY","outputs":[{"internalType":"uint256","name":"_apy","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"uint256","name":"_lockupPeriod","type":"uint256"}],"name":"calculateAPY","outputs":[{"internalType":"uint256","name":"_apy","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_index","type":"uint256"}],"name":"cancelWithdrawal","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"_token","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"collectDust","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint256","name":"_index","type":"uint256"}],"name":"deposits","outputs":[{"internalType":"uint128","name":"amount","type":"uint128"},{"internalType":"uint40","name":"unlockAt","type":"uint40"},{"internalType":"uint32","name":"lockupPeriod","type":"uint32"},{"internalType":"uint16","name":"index","type":"uint16"},{"internalType":"uint40","name":"withdrawAt","type":"uint40"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"distributor","outputs":[{"internalType":"contract IDistributor","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"emergencyWithdraw","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getReward","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_index","type":"uint256"}],"name":"getRewardAndIncreaseStake","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_lockupPeriod","type":"uint256"}],"name":"getRewardAndStake","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_index","type":"uint256"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"increaseStake","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"_token","type":"address"},{"internalType":"contract IDistributor","name":"_distributor","type":"address"},{"internalType":"address","name":"_owner","type":"address"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_index","type":"uint256"}],"name":"initiateWithdrawal","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"lastUpdateTime","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint256","name":"_startFrom","type":"uint256"},{"internalType":"uint256","name":"_batchSize","type":"uint256"}],"name":"listDeposits","outputs":[{"components":[{"internalType":"uint128","name":"amount","type":"uint128"},{"internalType":"uint40","name":"unlockAt","type":"uint40"},{"internalType":"uint32","name":"lockupPeriod","type":"uint32"},{"internalType":"uint16","name":"index","type":"uint16"},{"internalType":"uint40","name":"withdrawAt","type":"uint40"}],"internalType":"struct IStaking.Deposit[]","name":"_list","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pendingOwner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"}],"name":"pendingRewards","outputs":[{"internalType":"uint256","name":"_pendingRewards","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"periodFinish","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"proxiableUUID","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"rewardPerSecond","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"rewardPerShare","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"rewardsDuration","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract IDistributor","name":"_distributor","type":"address"}],"name":"setDistributorAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_reward","type":"uint256"}],"name":"setRewardAmount","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_rewardsDuration","type":"uint256"}],"name":"setRewardsDuration","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_withdrawalPeriod","type":"uint256"}],"name":"setWithdrawalPeriod","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"uint256","name":"_lockupPeriod","type":"uint256"},{"internalType":"address","name":"_user","type":"address"}],"name":"stake","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"uint256","name":"_lockupPeriod","type":"uint256"}],"name":"stake","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"}],"name":"stakers","outputs":[{"internalType":"uint128","name":"weight","type":"uint128"},{"internalType":"uint128","name":"depositCount","type":"uint128"},{"internalType":"uint128","name":"rewardPerShareSnapshot","type":"uint128"},{"internalType":"uint128","name":"pendingRewards","type":"uint128"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"token","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalDeposits","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalRewards","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalWeights","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":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newImplementation","type":"address"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"upgradeToAndCall","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_index","type":"uint256"}],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"withdrawalPeriod","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"}]

60a0604052306080523480156200001557600080fd5b506200002062000026565b620000da565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00805468010000000000000000900460ff1615620000775760405163f92ee8a960e01b815260040160405180910390fd5b80546001600160401b0390811614620000d75780546001600160401b0319166001600160401b0390811782556040519081527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15b50565b6080516140b46200010460003960008181612a3f01528181612a680152612c8401526140b46000f3fe6080604052600436106102e75760003560e01c806387950f4911610184578063bec10cde116100d6578063d6d681771161008a578063ebe2b12b11610064578063ebe2b12b14610982578063f2fde38b14610998578063fc0c546a146109b857600080fd5b8063d6d6817714610834578063da10d9e21461094d578063e30c39781461096d57600080fd5b8063c0c53b8b116100bb578063c0c53b8b146107de578063c8f33c91146107fe578063cc1a378f1461081457600080fd5b8063bec10cde14610791578063bfe10928146107b157600080fd5b8063973b294f11610138578063b14b990f11610112578063b14b990f1461073b578063b873995a1461075b578063bca7093d1461077b57600080fd5b8063973b294f146106a5578063a8a65a78146106c5578063ad3cb1cc146106e557600080fd5b80638f10369a116101695780638f10369a146105d35780639168ae72146105e9578063926323d51461068f57600080fd5b806387950f49146105795780638da5cb5b1461059957600080fd5b80634f1ef2861161023d5780637628a37d116101f15780637b0472f0116101cb5780637b0472f01461052e5780637d8820971461054e5780638456cb591461056457600080fd5b80637628a37d146104d957806376c66d02146104f957806379ba50971461051957600080fd5b80635312ea8e116102225780635312ea8e146104625780635c975abb14610482578063715018a6146104c457600080fd5b80634f1ef2861461043a57806352d1902d1461044d57600080fd5b8063386a95251161029f5780633efcfda4116102795780633efcfda4146103ef5780633f4ba83a1461040f578063446a2ec81461042457600080fd5b8063386a95251461039757806339c35fae146103ad5780633d18b912146103da57600080fd5b806320a0b9ae116102d057806320a0b9ae146103375780632e1a7d4d1461035757806331d7a2621461037757600080fd5b80630e15561a146102ec57806312edde5e14610315575b600080fd5b3480156102f857600080fd5b5061030260075481565b6040519081526020015b60405180910390f35b34801561032157600080fd5b50610335610330366004613af4565b6109e5565b005b34801561034357600080fd5b50610302610352366004613b2f565b610c69565b34801561036357600080fd5b50610335610372366004613af4565b610dc9565b34801561038357600080fd5b50610302610392366004613b5b565b6110b1565b3480156103a357600080fd5b5061030260025481565b3480156103b957600080fd5b506103cd6103c8366004613b78565b61117c565b60405161030c9190613bad565b3480156103e657600080fd5b506103356113c8565b3480156103fb57600080fd5b5061033561040a366004613af4565b611499565b34801561041b57600080fd5b50610335611648565b34801561043057600080fd5b5061030260065481565b610335610448366004613c70565b61165a565b34801561045957600080fd5b50610302611675565b34801561046e57600080fd5b5061033561047d366004613af4565b6116a4565b34801561048e57600080fd5b507fcd5ed15c6e187e77e9aee88184c21f4f2182ab5827cb3b7e07fbedcd63f033005460ff16604051901515815260200161030c565b3480156104d057600080fd5b50610335611815565b3480156104e557600080fd5b506103356104f4366004613d52565b611827565b34801561050557600080fd5b50610335610514366004613af4565b61191a565b34801561052557600080fd5b506103356119e2565b34801561053a57600080fd5b50610335610549366004613d8b565b611a62565b34801561055a57600080fd5b5061030260085481565b34801561057057600080fd5b50610335611b0c565b34801561058557600080fd5b50610335610594366004613b5b565b611b1c565b3480156105a557600080fd5b506105ae611bab565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200161030c565b3480156105df57600080fd5b5061030260055481565b3480156105f557600080fd5b50610653610604366004613b5b565b600b60205260009081526040902080546001909101546fffffffffffffffffffffffffffffffff8083169270010000000000000000000000000000000090819004821692808316929190041684565b604080516fffffffffffffffffffffffffffffffff9586168152938516602085015291841691830191909152909116606082015260800161030c565b34801561069b57600080fd5b5061030260095481565b3480156106b157600080fd5b506103356106c0366004613af4565b611bed565b3480156106d157600080fd5b506103356106e0366004613af4565b611c33565b3480156106f157600080fd5b5061072e6040518060400160405280600581526020017f352e302e3000000000000000000000000000000000000000000000000000000081525081565b60405161030c9190613dd1565b34801561074757600080fd5b50610335610756366004613b2f565b611dee565b34801561076757600080fd5b50610302610776366004613d8b565b611f21565b34801561078757600080fd5b50610302600a5481565b34801561079d57600080fd5b506103356107ac366004613d8b565b611f82565b3480156107bd57600080fd5b506001546105ae9073ffffffffffffffffffffffffffffffffffffffff1681565b3480156107ea57600080fd5b506103356107f9366004613e22565b611fe9565b34801561080a57600080fd5b5061030260045481565b34801561082057600080fd5b5061033561082f366004613af4565b6121ef565b34801561084057600080fd5b506108ff61084f366004613b2f565b600c6020908152600092835260408084209091529082529020546fffffffffffffffffffffffffffffffff81169064ffffffffff700100000000000000000000000000000000820481169163ffffffff75010000000000000000000000000000000000000000008204169161ffff790100000000000000000000000000000000000000000000000000830416917b0100000000000000000000000000000000000000000000000000000090041685565b604080516fffffffffffffffffffffffffffffffff909616865264ffffffffff948516602087015263ffffffff9093169285019290925261ffff16606084015216608082015260a00161030c565b34801561095957600080fd5b50610335610968366004613af4565b612271565b34801561097957600080fd5b506105ae612328565b34801561098e57600080fd5b5061030260035481565b3480156109a457600080fd5b506103356109b3366004613b5b565b612351565b3480156109c457600080fd5b506000546105ae9073ffffffffffffffffffffffffffffffffffffffff1681565b336000908152600c602090815260408083208484529091528120805490916fffffffffffffffffffffffffffffffff9091169003610a4f576040517f6d97cdda00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b80547501000000000000000000000000000000000000000000900463ffffffff1615610aa7576040517ff38b9b5b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b80547b01000000000000000000000000000000000000000000000000000000900464ffffffffff1615610b06576040517f15499e2300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040805160a08101825282546fffffffffffffffffffffffffffffffff8116825264ffffffffff70010000000000000000000000000000000082048116602084015263ffffffff75010000000000000000000000000000000000000000008304169383019390935261ffff79010000000000000000000000000000000000000000000000000082041660608301527b0100000000000000000000000000000000000000000000000000000090049091166080820152610bc490612408565b610bda600a5442610bd59190613e91565b6124fc565b81547affffffffffffffffffffffffffffffffffffffffffffffffffffff167b0100000000000000000000000000000000000000000000000000000064ffffffffff9283168102919091178084556040519190049091168152829033907f31f69201fab7912e3ec9850e3ab705964bf46d9d4276bdcbb6d05e965e5f5401906020015b60405180910390a35050565b73ffffffffffffffffffffffffffffffffffffffff82166000908152600c602090815260408083208484528252808320815160a08101835290546fffffffffffffffffffffffffffffffff811680835264ffffffffff700100000000000000000000000000000000830481169584019590955263ffffffff750100000000000000000000000000000000000000000083041693830184905261ffff79010000000000000000000000000000000000000000000000000083041660608401527b010000000000000000000000000000000000000000000000000000009091049093166080820152918391610d5b9161254b565b90506000670de0b6b3a76400006301da9c00600554610d7a9190613ea4565b610d849190613ea4565b610d8f906064613ea4565b9050610dbf828260095486600001516fffffffffffffffffffffffffffffffff16610dba9190613ea4565b61260c565b9695505050505050565b336000908152600c602090815260408083208484528252808320815160a08101835290546fffffffffffffffffffffffffffffffff811680835264ffffffffff700100000000000000000000000000000000830481169584019590955263ffffffff75010000000000000000000000000000000000000000008304169383019390935261ffff79010000000000000000000000000000000000000000000000000082041660608301527b0100000000000000000000000000000000000000000000000000000090049092166080830152909103610ed2576040517f6d97cdda00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b604081015163ffffffff1615610f355742816020015164ffffffffff161115610f27576040517ff38b9b5b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610f3081612408565b610fe6565b600a54158015610f4e5750608081015164ffffffffff16155b15610f5c57610f3081612408565b42816080015164ffffffffff161115610fa1576040517f87fb75bb00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b806080015164ffffffffff16600003610fe6576040517f5bc0da6800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b80600001516fffffffffffffffffffffffffffffffff166008600082825461100e9190613ebb565b9091555050336000818152600c602090815260408083208684529091528120819055825190546110689273ffffffffffffffffffffffffffffffffffffffff909116916fffffffffffffffffffffffffffffffff16612707565b80516040516fffffffffffffffffffffffffffffffff9091168152829033907f92ccf450a286a957af52509bc1c9939d1a6a481783e142e41e2499f0bb66ebc690602001610c5d565b73ffffffffffffffffffffffffffffffffffffffff81166000908152600b60205260408120600181015482906fffffffffffffffffffffffffffffffff166110f7612788565b6111019190613ebb565b8254909150600090670de0b6b3a7640000906111309084906fffffffffffffffffffffffffffffffff16613ea4565b61113a9190613efd565b600184015490915061117390829070010000000000000000000000000000000090046fffffffffffffffffffffffffffffffff16613e91565b95945050505050565b73ffffffffffffffffffffffffffffffffffffffff83166000908152600b602052604090205460609070010000000000000000000000000000000090046fffffffffffffffffffffffffffffffff16808411156111d957506113c1565b6111e38482613ebb565b8311156111f7576111f48482613ebb565b92505b8267ffffffffffffffff81111561121057611210613c41565b60405190808252806020026020018201604052801561128757816020015b6040805160a0810182526000808252602080830182905292820181905260608201819052608082015282527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff90920191018161122e5790505b50915060005b838110156113be5773ffffffffffffffffffffffffffffffffffffffff86166000908152600c60205260408120906112c58388613e91565b81526020808201929092526040908101600020815160a08101835290546fffffffffffffffffffffffffffffffff8116825264ffffffffff700100000000000000000000000000000000820481169483019490945263ffffffff75010000000000000000000000000000000000000000008204169282019290925261ffff79010000000000000000000000000000000000000000000000000083041660608201527b01000000000000000000000000000000000000000000000000000000909104909116608082015283518490839081106113a2576113a2613f38565b6020026020010181905250806113b790613f67565b905061128d565b50505b9392505050565b60006113d3336127f5565b600181015490915070010000000000000000000000000000000090046fffffffffffffffffffffffffffffffff168015611495576001820180546fffffffffffffffffffffffffffffffff16905560078054829190600090611436908490613ebb565b909155505060005461145f9073ffffffffffffffffffffffffffffffffffffffff163383612707565b60405181815233907fe2403640ba68fed3a2f88b7557551d1993f84b99bb10ff833f0cf8db0c5e04869060200160405180910390a25b5050565b336000908152600c602090815260408083208484529091528120805490916fffffffffffffffffffffffffffffffff90911690819003611505576040517f6d97cdda00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b81547b01000000000000000000000000000000000000000000000000000000900464ffffffffff16600003611566576040517f5bc0da6800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000611571336127f5565b9050600061158060008461254b565b905080600960008282546115949190613e91565b909155506115a39050816128dc565b825483906000906115c79084906fffffffffffffffffffffffffffffffff16613f9f565b82546fffffffffffffffffffffffffffffffff9182166101009390930a92830291909202199091161790555083547affffffffffffffffffffffffffffffffffffffffffffffffffffff168455604051859033907f2eed97477f07c07ec48f8f678f4e84f7c0de55bf33f51c3dc989b1335308031990600090a35050505050565b611650612932565b61165861298a565b565b611662612a27565b61166b82612b2b565b6114958282612b33565b600061167f612c6c565b507f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc90565b6116ac612932565b806000036116e6576040517f1f2a200500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600080546040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff909116906370a0823190602401602060405180830381865afa158015611755573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117799190613fcf565b9050600081831161178a578261178c565b815b90506117b9611799611bab565b60005473ffffffffffffffffffffffffffffffffffffffff169083612707565b6117c1611bab565b73ffffffffffffffffffffffffffffffffffffffff167f2e39961a70a10f4d46383948095ac2752b3ee642a7c76aa827410aaff08c2e518260405161180891815260200190565b60405180910390a2505050565b61181d612932565b6116586000612cdb565b60015473ffffffffffffffffffffffffffffffffffffffff163314611878576040517f1b8f6df300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000611885848484612d2b565b606080820151825160408085015160208087015183516fffffffffffffffffffffffffffffffff909516855263ffffffff9092169084015264ffffffffff169082015292935061ffff169173ffffffffffffffffffffffffffffffffffffffff8516917f9cfd25589d1eb8ad71e342a86a8524e83522e3936c0803048c08f6d9ad974f4091015b60405180910390a350505050565b6000611925336127f5565b600181015490915070010000000000000000000000000000000090046fffffffffffffffffffffffffffffffff1680156119dd576001820180546fffffffffffffffffffffffffffffffff1690556000611980828533612d2b565b905081600760008282546119949190613ebb565b90915550506060810151604080518481526020810187905261ffff9092169133917f28a4391b81854dd0b9a033088421ef92664cbb2ce533b69baa569d4d1b81b383910161190c565b505050565b33806119ec612328565b73ffffffffffffffffffffffffffffffffffffffff1614611a56576040517f118cdaa700000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff821660048201526024015b60405180910390fd5b611a5f81612cdb565b50565b6000611a6f838333612d2b565b606080820151825160408085015160208087015183516fffffffffffffffffffffffffffffffff909516855263ffffffff9092169084015264ffffffffff169082015292935061ffff169133917f9cfd25589d1eb8ad71e342a86a8524e83522e3936c0803048c08f6d9ad974f40910160405180910390a36000546119dd9073ffffffffffffffffffffffffffffffffffffffff163330866130a1565b611b14612932565b6116586130ed565b611b24612932565b6001805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff000000000000000000000000000000000000000083168117909355604080519190921680825260208201939093527f111a961d91cf441fe07e7bfddc128b30ab56974d1a76851e969e0642fdb2dd5091015b60405180910390a15050565b6000807f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c1993005b5473ffffffffffffffffffffffffffffffffffffffff1692915050565b611bf5612932565b600a80549082905560408051828152602081018490527f759d29a964e1aa0e3273a781eec37e160daa40a40342ad659d83028dd14aacd19101611b9f565b611c3b612932565b600080546040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff909116906370a0823190602401602060405180830381865afa158015611caa573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611cce9190613fcf565b905060075460085482611ce19190613ebb565b611ceb9190613ebb565b821115611d24576040517ff4d678b800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b611d2e60006127f5565b506003544210611d4d57600254611d459083613efd565b600555611d8f565b600042600354611d5d9190613ebb565b9050600060055482611d6f9190613ea4565b600254909150611d7f8286613e91565b611d899190613efd565b60055550505b426004819055600254611da191613e91565b6003819055508160076000828254611db99190613e91565b90915550506040518281527fde88a922e0d3b88b24e9623efeb464919c6bf9f66857a65e2bfcf2ce87a9433d90602001611b9f565b611df6612932565b60005473ffffffffffffffffffffffffffffffffffffffff83811691161480611e33575073ffffffffffffffffffffffffffffffffffffffff8216155b15611e6a576040517fc1ab6dc100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b80600003611ea4576040517f1f2a200500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000611eae611bab565b9050611ed173ffffffffffffffffffffffffffffffffffffffff84168284612707565b6040805173ffffffffffffffffffffffffffffffffffffffff8581168252602082018590528316917f4b3832ed948bc80ab35e8cab3a5923e6e1a57696d02c846a8b6f54d39bf9acf09101611808565b600080611f2e838561254b565b90506000670de0b6b3a76400006301da9c00600554611f4d9190613ea4565b611f579190613ea4565b611f62906064613ea4565b905061117382828785600954611f789190613e91565b610dba9190613ea4565b611f8d828233613166565b604051818152829033907fe6afb5ca7cc84435baf09da39fcb42fc0fb8bdfef6c3ff2ce9fce2c70a18f8219060200160405180910390a36000546114959073ffffffffffffffffffffffffffffffffffffffff163330846130a1565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00805468010000000000000000810460ff16159067ffffffffffffffff166000811580156120345750825b905060008267ffffffffffffffff1660011480156120515750303b155b90508115801561205f575080155b15612096576040517ff92ee8a900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b84547fffffffffffffffffffffffffffffffffffffffffffffffff000000000000000016600117855583156120f75784547fffffffffffffffffffffffffffffffffffffffffffffff00ffffffffffffffff16680100000000000000001785555b6000805473ffffffffffffffffffffffffffffffffffffffff808b167fffffffffffffffffffffffff00000000000000000000000000000000000000009283161790925560018054928a16929091169190911790556309450c0060025562093a80600a55612164866133b7565b61216c6133c8565b6121746133c8565b61217c6133d0565b6121846130ed565b83156121e55784547fffffffffffffffffffffffffffffffffffffffffffffff00ffffffffffffffff168555604051600181527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15b5050505050505050565b6121f7612932565b426003541115612233576040517f449a6ba000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600280549082905560408051828152602081018490527fd20a04eb2807bde8cbdf16ef27a46d94a3162d81818f1781c0fe4ed9194ca3919101611b9f565b600061227c336127f5565b600181015490915070010000000000000000000000000000000090046fffffffffffffffffffffffffffffffff1680156119dd576001820180546fffffffffffffffffffffffffffffffff1690556122d5838233613166565b80600760008282546122e79190613ebb565b9091555050604051818152839033907fbcb84e4496de59b7cc314368190ec54380f616d6535422e388531cc05ba1b8829060200160405180910390a3505050565b6000807f237e158222e3e6968b72b9db0d8043aacf074ad9f650f0d1606b4d82ee432c00611bd0565b612359612932565b7f237e158222e3e6968b72b9db0d8043aacf074ad9f650f0d1606b4d82ee432c0080547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff831690811782556123c2611bab565b73ffffffffffffffffffffffffffffffffffffffff167f38d16b8cac22d99fc7c124b9cd0de2d3fa1faef420bfe791d8c362d765e2270060405160405180910390a35050565b6000612413336127f5565b90506000612441836040015163ffffffff1684600001516fffffffffffffffffffffffffffffffff1661254b565b82549091506fffffffffffffffffffffffffffffffff168111156124785781546fffffffffffffffffffffffffffffffff1661247a565b805b9050806009600082825461248e9190613ebb565b9091555061249d9050816128dc565b825483906000906124c19084906fffffffffffffffffffffffffffffffff16613fe8565b92506101000a8154816fffffffffffffffffffffffffffffffff02191690836fffffffffffffffffffffffffffffffff160217905550505050565b600064ffffffffff821115612547576040517f6dfcc6500000000000000000000000000000000000000000000000000000000081526028600482015260248101839052604401611a4d565b5090565b600082600003612574576103e86125638360fa613ea4565b61256d9190613efd565b9050612606565b6301da9c00830361258e576103e8612563836101f4613ea4565b6302c7ea0083036125a8576103e861256383610271613ea4565b6303b5380083036125c2576103e8612563836102ee613ea4565b63058fd40083036125d4575080612606565b6040517f1578094300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b92915050565b6000838302817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff85870982811083820303915050806000036126615783828161265757612657613ece565b04925050506113c1565b80841161269a576040517f227bc15300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000848688096000868103871696879004966002600389028118808a02820302808a02820302808a02820302808a02820302808a02820302808a02909103029181900381900460010186841190950394909402919094039290920491909117919091029150509392505050565b60405173ffffffffffffffffffffffffffffffffffffffff8381166024830152604482018390526119dd91859182169063a9059cbb906064015b604051602081830303815290604052915060e01b6020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506133e0565b600060095460000361279b575060065490565b60006004546127a8613476565b6127b29190613ebb565b9050600954670de0b6b3a7640000600554836127ce9190613ea4565b6127d89190613ea4565b6127e29190613efd565b6006546127ef9190613e91565b91505090565b60006127ff61348d565b612807612788565b600655612812613476565b6004555073ffffffffffffffffffffffffffffffffffffffff81166000818152600b6020526040902090156128d75761285261284d836110b1565b6128dc565b6001820180546fffffffffffffffffffffffffffffffff928316700100000000000000000000000000000000029216919091179055600654612893906128dc565b6001820180547fffffffffffffffffffffffffffffffff00000000000000000000000000000000166fffffffffffffffffffffffffffffffff929092169190911790555b919050565b60006fffffffffffffffffffffffffffffffff821115612547576040517f6dfcc6500000000000000000000000000000000000000000000000000000000081526080600482015260248101839052604401611a4d565b3361293b611bab565b73ffffffffffffffffffffffffffffffffffffffff1614611658576040517f118cdaa7000000000000000000000000000000000000000000000000000000008152336004820152602401611a4d565b6129926134e9565b7fcd5ed15c6e187e77e9aee88184c21f4f2182ab5827cb3b7e07fbedcd63f0330080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001681557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390a150565b3073ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000161480612af457507f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16612adb7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5473ffffffffffffffffffffffffffffffffffffffff1690565b73ffffffffffffffffffffffffffffffffffffffff1614155b15611658576040517fe07c8dba00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b611a5f612932565b8173ffffffffffffffffffffffffffffffffffffffff166352d1902d6040518163ffffffff1660e01b8152600401602060405180830381865afa925050508015612bb8575060408051601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0168201909252612bb591810190613fcf565b60015b612c06576040517f4c9c8ce300000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff83166004820152602401611a4d565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc8114612c62576040517faa1d49a400000000000000000000000000000000000000000000000000000000815260048101829052602401611a4d565b6119dd8383613544565b3073ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001614611658576040517fe07c8dba00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b7f237e158222e3e6968b72b9db0d8043aacf074ad9f650f0d1606b4d82ee432c0080547fffffffffffffffffffffffff0000000000000000000000000000000000000000168155611495826135a7565b6040805160a08101825260008082526020820181905291810182905260608101829052608081019190915283600003612d90576040517f1f2a200500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000612d9b836127f5565b90506000612da9858761254b565b90508060096000828254612dbd9190613e91565b925050819055508560086000828254612dd69190613e91565b90915550612de59050816128dc565b82548390600090612e099084906fffffffffffffffffffffffffffffffff16613f9f565b82546101009290920a6fffffffffffffffffffffffffffffffff818102199093169183160217909155835460009250700100000000000000000000000000000000900416836010612e5983614011565b91906101000a8154816fffffffffffffffffffffffffffffffff02191690836fffffffffffffffffffffffffffffffff1602179055506fffffffffffffffffffffffffffffffff16905060008642612eb19190613e91565b90506040518060a00160405280612ec78a6128dc565b6fffffffffffffffffffffffffffffffff168152602001612ee7836124fc565b64ffffffffff168152602001612efc8961363d565b63ffffffff168152602001612f1084613687565b61ffff90811682526000602092830181905273ffffffffffffffffffffffffffffffffffffffff9099168952600c82526040808a20958a52948252978490208251815492840151958401516060850151608086015164ffffffffff9081167b01000000000000000000000000000000000000000000000000000000027affffffffffffffffffffffffffffffffffffffffffffffffffffff92909d16790100000000000000000000000000000000000000000000000000027fffffffffff0000ffffffffffffffffffffffffffffffffffffffffffffffffff63ffffffff909416750100000000000000000000000000000000000000000002939093167fffffffffff000000000000ffffffffffffffffffffffffffffffffffffffffff99909116700100000000000000000000000000000000027fffffffffffffffffffffff0000000000000000000000000000000000000000009096166fffffffffffffffffffffffffffffffff90941693909317949094179690961617949094171696909617909155509295945050505050565b60405173ffffffffffffffffffffffffffffffffffffffff84811660248301528381166044830152606482018390526130e79186918216906323b872dd90608401612741565b50505050565b6130f561348d565b7fcd5ed15c6e187e77e9aee88184c21f4f2182ab5827cb3b7e07fbedcd63f0330080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660011781557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258336129fc565b73ffffffffffffffffffffffffffffffffffffffff81166000908152600c602090815260408083208684529091528120805490916fffffffffffffffffffffffffffffffff90911690036131e6576040517f6d97cdda00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b80547501000000000000000000000000000000000000000000900463ffffffff161561323d576040517ee24fbd00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b80547b01000000000000000000000000000000000000000000000000000000900464ffffffffff161561329c576040517f15499e2300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60006132a960008561254b565b905060006132b6846127f5565b905081600960008282546132ca9190613e91565b9250508190555084600860008282546132e39190613e91565b909155506132f29050826128dc565b815482906000906133169084906fffffffffffffffffffffffffffffffff16613f9f565b92506101000a8154816fffffffffffffffffffffffffffffffff02191690836fffffffffffffffffffffffffffffffff160217905550613355856128dc565b835484906000906133799084906fffffffffffffffffffffffffffffffff16613f9f565b92506101000a8154816fffffffffffffffffffffffffffffffff02191690836fffffffffffffffffffffffffffffffff160217905550505050505050565b6133bf6136cf565b611a5f81613736565b6116586136cf565b6133d86136cf565b61165861378e565b600061340273ffffffffffffffffffffffffffffffffffffffff8416836137df565b905080516000141580156134275750808060200190518101906134259190614040565b155b156119dd576040517f5274afe700000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff84166004820152602401611a4d565b60006003544210613488575060035490565b504290565b7fcd5ed15c6e187e77e9aee88184c21f4f2182ab5827cb3b7e07fbedcd63f033005460ff1615611658576040517fd93c066500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b7fcd5ed15c6e187e77e9aee88184c21f4f2182ab5827cb3b7e07fbedcd63f033005460ff16611658576040517f8dfc202b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61354d826137ed565b60405173ffffffffffffffffffffffffffffffffffffffff8316907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a280511561359f576119dd82826138bc565b611495613936565b7f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c19930080547fffffffffffffffffffffffff0000000000000000000000000000000000000000811673ffffffffffffffffffffffffffffffffffffffff848116918217845560405192169182907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3505050565b600063ffffffff821115612547576040517f6dfcc6500000000000000000000000000000000000000000000000000000000081526020600482015260248101839052604401611a4d565b600061ffff821115612547576040517f6dfcc6500000000000000000000000000000000000000000000000000000000081526010600482015260248101839052604401611a4d565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a005468010000000000000000900460ff16611658576040517fd7e6bcf800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61373e6136cf565b73ffffffffffffffffffffffffffffffffffffffff8116611a56576040517f1e4fbdf700000000000000000000000000000000000000000000000000000000815260006004820152602401611a4d565b6137966136cf565b7fcd5ed15c6e187e77e9aee88184c21f4f2182ab5827cb3b7e07fbedcd63f0330080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00169055565b60606113c18383600061396e565b8073ffffffffffffffffffffffffffffffffffffffff163b600003613856576040517f4c9c8ce300000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff82166004820152602401611a4d565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc80547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b60606000808473ffffffffffffffffffffffffffffffffffffffff16846040516138e69190614062565b600060405180830381855af49150503d8060008114613921576040519150601f19603f3d011682016040523d82523d6000602084013e613926565b606091505b5091509150611173858383613a23565b3415611658576040517fb398979f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6060814710156139ac576040517fcd786059000000000000000000000000000000000000000000000000000000008152306004820152602401611a4d565b6000808573ffffffffffffffffffffffffffffffffffffffff1684866040516139d59190614062565b60006040518083038185875af1925050503d8060008114613a12576040519150601f19603f3d011682016040523d82523d6000602084013e613a17565b606091505b5091509150610dbf8683835b606082613a3857613a3382613ab2565b6113c1565b8151158015613a5c575073ffffffffffffffffffffffffffffffffffffffff84163b155b15613aab576040517f9996b31500000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff85166004820152602401611a4d565b50806113c1565b805115613ac25780518082602001fd5b6040517f1425ea4200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600060208284031215613b0657600080fd5b5035919050565b73ffffffffffffffffffffffffffffffffffffffff81168114611a5f57600080fd5b60008060408385031215613b4257600080fd5b8235613b4d81613b0d565b946020939093013593505050565b600060208284031215613b6d57600080fd5b81356113c181613b0d565b600080600060608486031215613b8d57600080fd5b8335613b9881613b0d565b95602085013595506040909401359392505050565b602080825282518282018190526000919060409081850190868401855b82811015613c3457815180516fffffffffffffffffffffffffffffffff1685528681015164ffffffffff908116888701528682015163ffffffff168787015260608083015161ffff1690870152608091820151169085015260a09093019290850190600101613bca565b5091979650505050505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b60008060408385031215613c8357600080fd5b8235613c8e81613b0d565b9150602083013567ffffffffffffffff80821115613cab57600080fd5b818501915085601f830112613cbf57600080fd5b813581811115613cd157613cd1613c41565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f01168101908382118183101715613d1757613d17613c41565b81604052828152886020848701011115613d3057600080fd5b8260208601602083013760006020848301015280955050505050509250929050565b600080600060608486031215613d6757600080fd5b83359250602084013591506040840135613d8081613b0d565b809150509250925092565b60008060408385031215613d9e57600080fd5b50508035926020909101359150565b60005b83811015613dc8578181015183820152602001613db0565b50506000910152565b6020815260008251806020840152613df0816040850160208701613dad565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169190910160400192915050565b600080600060608486031215613e3757600080fd5b8335613e4281613b0d565b92506020840135613e5281613b0d565b91506040840135613d8081613b0d565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b8082018082111561260657612606613e62565b808202811582820484141761260657612606613e62565b8181038181111561260657612606613e62565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b600082613f33577f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b500490565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8203613f9857613f98613e62565b5060010190565b6fffffffffffffffffffffffffffffffff818116838216019080821115613fc857613fc8613e62565b5092915050565b600060208284031215613fe157600080fd5b5051919050565b6fffffffffffffffffffffffffffffffff828116828216039080821115613fc857613fc8613e62565b60006fffffffffffffffffffffffffffffffff80831681810361403657614036613e62565b6001019392505050565b60006020828403121561405257600080fd5b815180151581146113c157600080fd5b60008251614074818460208701613dad565b919091019291505056fea2646970667358221220b58cd54d7ff5068c1ddc25d5e476b2ca5299a62c494242fb5de9169476e750e964736f6c63430008170033

Deployed Bytecode

0x6080604052600436106102e75760003560e01c806387950f4911610184578063bec10cde116100d6578063d6d681771161008a578063ebe2b12b11610064578063ebe2b12b14610982578063f2fde38b14610998578063fc0c546a146109b857600080fd5b8063d6d6817714610834578063da10d9e21461094d578063e30c39781461096d57600080fd5b8063c0c53b8b116100bb578063c0c53b8b146107de578063c8f33c91146107fe578063cc1a378f1461081457600080fd5b8063bec10cde14610791578063bfe10928146107b157600080fd5b8063973b294f11610138578063b14b990f11610112578063b14b990f1461073b578063b873995a1461075b578063bca7093d1461077b57600080fd5b8063973b294f146106a5578063a8a65a78146106c5578063ad3cb1cc146106e557600080fd5b80638f10369a116101695780638f10369a146105d35780639168ae72146105e9578063926323d51461068f57600080fd5b806387950f49146105795780638da5cb5b1461059957600080fd5b80634f1ef2861161023d5780637628a37d116101f15780637b0472f0116101cb5780637b0472f01461052e5780637d8820971461054e5780638456cb591461056457600080fd5b80637628a37d146104d957806376c66d02146104f957806379ba50971461051957600080fd5b80635312ea8e116102225780635312ea8e146104625780635c975abb14610482578063715018a6146104c457600080fd5b80634f1ef2861461043a57806352d1902d1461044d57600080fd5b8063386a95251161029f5780633efcfda4116102795780633efcfda4146103ef5780633f4ba83a1461040f578063446a2ec81461042457600080fd5b8063386a95251461039757806339c35fae146103ad5780633d18b912146103da57600080fd5b806320a0b9ae116102d057806320a0b9ae146103375780632e1a7d4d1461035757806331d7a2621461037757600080fd5b80630e15561a146102ec57806312edde5e14610315575b600080fd5b3480156102f857600080fd5b5061030260075481565b6040519081526020015b60405180910390f35b34801561032157600080fd5b50610335610330366004613af4565b6109e5565b005b34801561034357600080fd5b50610302610352366004613b2f565b610c69565b34801561036357600080fd5b50610335610372366004613af4565b610dc9565b34801561038357600080fd5b50610302610392366004613b5b565b6110b1565b3480156103a357600080fd5b5061030260025481565b3480156103b957600080fd5b506103cd6103c8366004613b78565b61117c565b60405161030c9190613bad565b3480156103e657600080fd5b506103356113c8565b3480156103fb57600080fd5b5061033561040a366004613af4565b611499565b34801561041b57600080fd5b50610335611648565b34801561043057600080fd5b5061030260065481565b610335610448366004613c70565b61165a565b34801561045957600080fd5b50610302611675565b34801561046e57600080fd5b5061033561047d366004613af4565b6116a4565b34801561048e57600080fd5b507fcd5ed15c6e187e77e9aee88184c21f4f2182ab5827cb3b7e07fbedcd63f033005460ff16604051901515815260200161030c565b3480156104d057600080fd5b50610335611815565b3480156104e557600080fd5b506103356104f4366004613d52565b611827565b34801561050557600080fd5b50610335610514366004613af4565b61191a565b34801561052557600080fd5b506103356119e2565b34801561053a57600080fd5b50610335610549366004613d8b565b611a62565b34801561055a57600080fd5b5061030260085481565b34801561057057600080fd5b50610335611b0c565b34801561058557600080fd5b50610335610594366004613b5b565b611b1c565b3480156105a557600080fd5b506105ae611bab565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200161030c565b3480156105df57600080fd5b5061030260055481565b3480156105f557600080fd5b50610653610604366004613b5b565b600b60205260009081526040902080546001909101546fffffffffffffffffffffffffffffffff8083169270010000000000000000000000000000000090819004821692808316929190041684565b604080516fffffffffffffffffffffffffffffffff9586168152938516602085015291841691830191909152909116606082015260800161030c565b34801561069b57600080fd5b5061030260095481565b3480156106b157600080fd5b506103356106c0366004613af4565b611bed565b3480156106d157600080fd5b506103356106e0366004613af4565b611c33565b3480156106f157600080fd5b5061072e6040518060400160405280600581526020017f352e302e3000000000000000000000000000000000000000000000000000000081525081565b60405161030c9190613dd1565b34801561074757600080fd5b50610335610756366004613b2f565b611dee565b34801561076757600080fd5b50610302610776366004613d8b565b611f21565b34801561078757600080fd5b50610302600a5481565b34801561079d57600080fd5b506103356107ac366004613d8b565b611f82565b3480156107bd57600080fd5b506001546105ae9073ffffffffffffffffffffffffffffffffffffffff1681565b3480156107ea57600080fd5b506103356107f9366004613e22565b611fe9565b34801561080a57600080fd5b5061030260045481565b34801561082057600080fd5b5061033561082f366004613af4565b6121ef565b34801561084057600080fd5b506108ff61084f366004613b2f565b600c6020908152600092835260408084209091529082529020546fffffffffffffffffffffffffffffffff81169064ffffffffff700100000000000000000000000000000000820481169163ffffffff75010000000000000000000000000000000000000000008204169161ffff790100000000000000000000000000000000000000000000000000830416917b0100000000000000000000000000000000000000000000000000000090041685565b604080516fffffffffffffffffffffffffffffffff909616865264ffffffffff948516602087015263ffffffff9093169285019290925261ffff16606084015216608082015260a00161030c565b34801561095957600080fd5b50610335610968366004613af4565b612271565b34801561097957600080fd5b506105ae612328565b34801561098e57600080fd5b5061030260035481565b3480156109a457600080fd5b506103356109b3366004613b5b565b612351565b3480156109c457600080fd5b506000546105ae9073ffffffffffffffffffffffffffffffffffffffff1681565b336000908152600c602090815260408083208484529091528120805490916fffffffffffffffffffffffffffffffff9091169003610a4f576040517f6d97cdda00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b80547501000000000000000000000000000000000000000000900463ffffffff1615610aa7576040517ff38b9b5b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b80547b01000000000000000000000000000000000000000000000000000000900464ffffffffff1615610b06576040517f15499e2300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040805160a08101825282546fffffffffffffffffffffffffffffffff8116825264ffffffffff70010000000000000000000000000000000082048116602084015263ffffffff75010000000000000000000000000000000000000000008304169383019390935261ffff79010000000000000000000000000000000000000000000000000082041660608301527b0100000000000000000000000000000000000000000000000000000090049091166080820152610bc490612408565b610bda600a5442610bd59190613e91565b6124fc565b81547affffffffffffffffffffffffffffffffffffffffffffffffffffff167b0100000000000000000000000000000000000000000000000000000064ffffffffff9283168102919091178084556040519190049091168152829033907f31f69201fab7912e3ec9850e3ab705964bf46d9d4276bdcbb6d05e965e5f5401906020015b60405180910390a35050565b73ffffffffffffffffffffffffffffffffffffffff82166000908152600c602090815260408083208484528252808320815160a08101835290546fffffffffffffffffffffffffffffffff811680835264ffffffffff700100000000000000000000000000000000830481169584019590955263ffffffff750100000000000000000000000000000000000000000083041693830184905261ffff79010000000000000000000000000000000000000000000000000083041660608401527b010000000000000000000000000000000000000000000000000000009091049093166080820152918391610d5b9161254b565b90506000670de0b6b3a76400006301da9c00600554610d7a9190613ea4565b610d849190613ea4565b610d8f906064613ea4565b9050610dbf828260095486600001516fffffffffffffffffffffffffffffffff16610dba9190613ea4565b61260c565b9695505050505050565b336000908152600c602090815260408083208484528252808320815160a08101835290546fffffffffffffffffffffffffffffffff811680835264ffffffffff700100000000000000000000000000000000830481169584019590955263ffffffff75010000000000000000000000000000000000000000008304169383019390935261ffff79010000000000000000000000000000000000000000000000000082041660608301527b0100000000000000000000000000000000000000000000000000000090049092166080830152909103610ed2576040517f6d97cdda00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b604081015163ffffffff1615610f355742816020015164ffffffffff161115610f27576040517ff38b9b5b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610f3081612408565b610fe6565b600a54158015610f4e5750608081015164ffffffffff16155b15610f5c57610f3081612408565b42816080015164ffffffffff161115610fa1576040517f87fb75bb00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b806080015164ffffffffff16600003610fe6576040517f5bc0da6800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b80600001516fffffffffffffffffffffffffffffffff166008600082825461100e9190613ebb565b9091555050336000818152600c602090815260408083208684529091528120819055825190546110689273ffffffffffffffffffffffffffffffffffffffff909116916fffffffffffffffffffffffffffffffff16612707565b80516040516fffffffffffffffffffffffffffffffff9091168152829033907f92ccf450a286a957af52509bc1c9939d1a6a481783e142e41e2499f0bb66ebc690602001610c5d565b73ffffffffffffffffffffffffffffffffffffffff81166000908152600b60205260408120600181015482906fffffffffffffffffffffffffffffffff166110f7612788565b6111019190613ebb565b8254909150600090670de0b6b3a7640000906111309084906fffffffffffffffffffffffffffffffff16613ea4565b61113a9190613efd565b600184015490915061117390829070010000000000000000000000000000000090046fffffffffffffffffffffffffffffffff16613e91565b95945050505050565b73ffffffffffffffffffffffffffffffffffffffff83166000908152600b602052604090205460609070010000000000000000000000000000000090046fffffffffffffffffffffffffffffffff16808411156111d957506113c1565b6111e38482613ebb565b8311156111f7576111f48482613ebb565b92505b8267ffffffffffffffff81111561121057611210613c41565b60405190808252806020026020018201604052801561128757816020015b6040805160a0810182526000808252602080830182905292820181905260608201819052608082015282527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff90920191018161122e5790505b50915060005b838110156113be5773ffffffffffffffffffffffffffffffffffffffff86166000908152600c60205260408120906112c58388613e91565b81526020808201929092526040908101600020815160a08101835290546fffffffffffffffffffffffffffffffff8116825264ffffffffff700100000000000000000000000000000000820481169483019490945263ffffffff75010000000000000000000000000000000000000000008204169282019290925261ffff79010000000000000000000000000000000000000000000000000083041660608201527b01000000000000000000000000000000000000000000000000000000909104909116608082015283518490839081106113a2576113a2613f38565b6020026020010181905250806113b790613f67565b905061128d565b50505b9392505050565b60006113d3336127f5565b600181015490915070010000000000000000000000000000000090046fffffffffffffffffffffffffffffffff168015611495576001820180546fffffffffffffffffffffffffffffffff16905560078054829190600090611436908490613ebb565b909155505060005461145f9073ffffffffffffffffffffffffffffffffffffffff163383612707565b60405181815233907fe2403640ba68fed3a2f88b7557551d1993f84b99bb10ff833f0cf8db0c5e04869060200160405180910390a25b5050565b336000908152600c602090815260408083208484529091528120805490916fffffffffffffffffffffffffffffffff90911690819003611505576040517f6d97cdda00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b81547b01000000000000000000000000000000000000000000000000000000900464ffffffffff16600003611566576040517f5bc0da6800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000611571336127f5565b9050600061158060008461254b565b905080600960008282546115949190613e91565b909155506115a39050816128dc565b825483906000906115c79084906fffffffffffffffffffffffffffffffff16613f9f565b82546fffffffffffffffffffffffffffffffff9182166101009390930a92830291909202199091161790555083547affffffffffffffffffffffffffffffffffffffffffffffffffffff168455604051859033907f2eed97477f07c07ec48f8f678f4e84f7c0de55bf33f51c3dc989b1335308031990600090a35050505050565b611650612932565b61165861298a565b565b611662612a27565b61166b82612b2b565b6114958282612b33565b600061167f612c6c565b507f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc90565b6116ac612932565b806000036116e6576040517f1f2a200500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600080546040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff909116906370a0823190602401602060405180830381865afa158015611755573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117799190613fcf565b9050600081831161178a578261178c565b815b90506117b9611799611bab565b60005473ffffffffffffffffffffffffffffffffffffffff169083612707565b6117c1611bab565b73ffffffffffffffffffffffffffffffffffffffff167f2e39961a70a10f4d46383948095ac2752b3ee642a7c76aa827410aaff08c2e518260405161180891815260200190565b60405180910390a2505050565b61181d612932565b6116586000612cdb565b60015473ffffffffffffffffffffffffffffffffffffffff163314611878576040517f1b8f6df300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000611885848484612d2b565b606080820151825160408085015160208087015183516fffffffffffffffffffffffffffffffff909516855263ffffffff9092169084015264ffffffffff169082015292935061ffff169173ffffffffffffffffffffffffffffffffffffffff8516917f9cfd25589d1eb8ad71e342a86a8524e83522e3936c0803048c08f6d9ad974f4091015b60405180910390a350505050565b6000611925336127f5565b600181015490915070010000000000000000000000000000000090046fffffffffffffffffffffffffffffffff1680156119dd576001820180546fffffffffffffffffffffffffffffffff1690556000611980828533612d2b565b905081600760008282546119949190613ebb565b90915550506060810151604080518481526020810187905261ffff9092169133917f28a4391b81854dd0b9a033088421ef92664cbb2ce533b69baa569d4d1b81b383910161190c565b505050565b33806119ec612328565b73ffffffffffffffffffffffffffffffffffffffff1614611a56576040517f118cdaa700000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff821660048201526024015b60405180910390fd5b611a5f81612cdb565b50565b6000611a6f838333612d2b565b606080820151825160408085015160208087015183516fffffffffffffffffffffffffffffffff909516855263ffffffff9092169084015264ffffffffff169082015292935061ffff169133917f9cfd25589d1eb8ad71e342a86a8524e83522e3936c0803048c08f6d9ad974f40910160405180910390a36000546119dd9073ffffffffffffffffffffffffffffffffffffffff163330866130a1565b611b14612932565b6116586130ed565b611b24612932565b6001805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff000000000000000000000000000000000000000083168117909355604080519190921680825260208201939093527f111a961d91cf441fe07e7bfddc128b30ab56974d1a76851e969e0642fdb2dd5091015b60405180910390a15050565b6000807f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c1993005b5473ffffffffffffffffffffffffffffffffffffffff1692915050565b611bf5612932565b600a80549082905560408051828152602081018490527f759d29a964e1aa0e3273a781eec37e160daa40a40342ad659d83028dd14aacd19101611b9f565b611c3b612932565b600080546040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff909116906370a0823190602401602060405180830381865afa158015611caa573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611cce9190613fcf565b905060075460085482611ce19190613ebb565b611ceb9190613ebb565b821115611d24576040517ff4d678b800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b611d2e60006127f5565b506003544210611d4d57600254611d459083613efd565b600555611d8f565b600042600354611d5d9190613ebb565b9050600060055482611d6f9190613ea4565b600254909150611d7f8286613e91565b611d899190613efd565b60055550505b426004819055600254611da191613e91565b6003819055508160076000828254611db99190613e91565b90915550506040518281527fde88a922e0d3b88b24e9623efeb464919c6bf9f66857a65e2bfcf2ce87a9433d90602001611b9f565b611df6612932565b60005473ffffffffffffffffffffffffffffffffffffffff83811691161480611e33575073ffffffffffffffffffffffffffffffffffffffff8216155b15611e6a576040517fc1ab6dc100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b80600003611ea4576040517f1f2a200500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000611eae611bab565b9050611ed173ffffffffffffffffffffffffffffffffffffffff84168284612707565b6040805173ffffffffffffffffffffffffffffffffffffffff8581168252602082018590528316917f4b3832ed948bc80ab35e8cab3a5923e6e1a57696d02c846a8b6f54d39bf9acf09101611808565b600080611f2e838561254b565b90506000670de0b6b3a76400006301da9c00600554611f4d9190613ea4565b611f579190613ea4565b611f62906064613ea4565b905061117382828785600954611f789190613e91565b610dba9190613ea4565b611f8d828233613166565b604051818152829033907fe6afb5ca7cc84435baf09da39fcb42fc0fb8bdfef6c3ff2ce9fce2c70a18f8219060200160405180910390a36000546114959073ffffffffffffffffffffffffffffffffffffffff163330846130a1565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00805468010000000000000000810460ff16159067ffffffffffffffff166000811580156120345750825b905060008267ffffffffffffffff1660011480156120515750303b155b90508115801561205f575080155b15612096576040517ff92ee8a900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b84547fffffffffffffffffffffffffffffffffffffffffffffffff000000000000000016600117855583156120f75784547fffffffffffffffffffffffffffffffffffffffffffffff00ffffffffffffffff16680100000000000000001785555b6000805473ffffffffffffffffffffffffffffffffffffffff808b167fffffffffffffffffffffffff00000000000000000000000000000000000000009283161790925560018054928a16929091169190911790556309450c0060025562093a80600a55612164866133b7565b61216c6133c8565b6121746133c8565b61217c6133d0565b6121846130ed565b83156121e55784547fffffffffffffffffffffffffffffffffffffffffffffff00ffffffffffffffff168555604051600181527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15b5050505050505050565b6121f7612932565b426003541115612233576040517f449a6ba000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600280549082905560408051828152602081018490527fd20a04eb2807bde8cbdf16ef27a46d94a3162d81818f1781c0fe4ed9194ca3919101611b9f565b600061227c336127f5565b600181015490915070010000000000000000000000000000000090046fffffffffffffffffffffffffffffffff1680156119dd576001820180546fffffffffffffffffffffffffffffffff1690556122d5838233613166565b80600760008282546122e79190613ebb565b9091555050604051818152839033907fbcb84e4496de59b7cc314368190ec54380f616d6535422e388531cc05ba1b8829060200160405180910390a3505050565b6000807f237e158222e3e6968b72b9db0d8043aacf074ad9f650f0d1606b4d82ee432c00611bd0565b612359612932565b7f237e158222e3e6968b72b9db0d8043aacf074ad9f650f0d1606b4d82ee432c0080547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff831690811782556123c2611bab565b73ffffffffffffffffffffffffffffffffffffffff167f38d16b8cac22d99fc7c124b9cd0de2d3fa1faef420bfe791d8c362d765e2270060405160405180910390a35050565b6000612413336127f5565b90506000612441836040015163ffffffff1684600001516fffffffffffffffffffffffffffffffff1661254b565b82549091506fffffffffffffffffffffffffffffffff168111156124785781546fffffffffffffffffffffffffffffffff1661247a565b805b9050806009600082825461248e9190613ebb565b9091555061249d9050816128dc565b825483906000906124c19084906fffffffffffffffffffffffffffffffff16613fe8565b92506101000a8154816fffffffffffffffffffffffffffffffff02191690836fffffffffffffffffffffffffffffffff160217905550505050565b600064ffffffffff821115612547576040517f6dfcc6500000000000000000000000000000000000000000000000000000000081526028600482015260248101839052604401611a4d565b5090565b600082600003612574576103e86125638360fa613ea4565b61256d9190613efd565b9050612606565b6301da9c00830361258e576103e8612563836101f4613ea4565b6302c7ea0083036125a8576103e861256383610271613ea4565b6303b5380083036125c2576103e8612563836102ee613ea4565b63058fd40083036125d4575080612606565b6040517f1578094300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b92915050565b6000838302817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff85870982811083820303915050806000036126615783828161265757612657613ece565b04925050506113c1565b80841161269a576040517f227bc15300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000848688096000868103871696879004966002600389028118808a02820302808a02820302808a02820302808a02820302808a02820302808a02909103029181900381900460010186841190950394909402919094039290920491909117919091029150509392505050565b60405173ffffffffffffffffffffffffffffffffffffffff8381166024830152604482018390526119dd91859182169063a9059cbb906064015b604051602081830303815290604052915060e01b6020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506133e0565b600060095460000361279b575060065490565b60006004546127a8613476565b6127b29190613ebb565b9050600954670de0b6b3a7640000600554836127ce9190613ea4565b6127d89190613ea4565b6127e29190613efd565b6006546127ef9190613e91565b91505090565b60006127ff61348d565b612807612788565b600655612812613476565b6004555073ffffffffffffffffffffffffffffffffffffffff81166000818152600b6020526040902090156128d75761285261284d836110b1565b6128dc565b6001820180546fffffffffffffffffffffffffffffffff928316700100000000000000000000000000000000029216919091179055600654612893906128dc565b6001820180547fffffffffffffffffffffffffffffffff00000000000000000000000000000000166fffffffffffffffffffffffffffffffff929092169190911790555b919050565b60006fffffffffffffffffffffffffffffffff821115612547576040517f6dfcc6500000000000000000000000000000000000000000000000000000000081526080600482015260248101839052604401611a4d565b3361293b611bab565b73ffffffffffffffffffffffffffffffffffffffff1614611658576040517f118cdaa7000000000000000000000000000000000000000000000000000000008152336004820152602401611a4d565b6129926134e9565b7fcd5ed15c6e187e77e9aee88184c21f4f2182ab5827cb3b7e07fbedcd63f0330080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001681557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390a150565b3073ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000b32a3055f6c148d82d84f44b4d04c1f8a6e6a352161480612af457507f000000000000000000000000b32a3055f6c148d82d84f44b4d04c1f8a6e6a35273ffffffffffffffffffffffffffffffffffffffff16612adb7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5473ffffffffffffffffffffffffffffffffffffffff1690565b73ffffffffffffffffffffffffffffffffffffffff1614155b15611658576040517fe07c8dba00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b611a5f612932565b8173ffffffffffffffffffffffffffffffffffffffff166352d1902d6040518163ffffffff1660e01b8152600401602060405180830381865afa925050508015612bb8575060408051601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0168201909252612bb591810190613fcf565b60015b612c06576040517f4c9c8ce300000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff83166004820152602401611a4d565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc8114612c62576040517faa1d49a400000000000000000000000000000000000000000000000000000000815260048101829052602401611a4d565b6119dd8383613544565b3073ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000b32a3055f6c148d82d84f44b4d04c1f8a6e6a3521614611658576040517fe07c8dba00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b7f237e158222e3e6968b72b9db0d8043aacf074ad9f650f0d1606b4d82ee432c0080547fffffffffffffffffffffffff0000000000000000000000000000000000000000168155611495826135a7565b6040805160a08101825260008082526020820181905291810182905260608101829052608081019190915283600003612d90576040517f1f2a200500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000612d9b836127f5565b90506000612da9858761254b565b90508060096000828254612dbd9190613e91565b925050819055508560086000828254612dd69190613e91565b90915550612de59050816128dc565b82548390600090612e099084906fffffffffffffffffffffffffffffffff16613f9f565b82546101009290920a6fffffffffffffffffffffffffffffffff818102199093169183160217909155835460009250700100000000000000000000000000000000900416836010612e5983614011565b91906101000a8154816fffffffffffffffffffffffffffffffff02191690836fffffffffffffffffffffffffffffffff1602179055506fffffffffffffffffffffffffffffffff16905060008642612eb19190613e91565b90506040518060a00160405280612ec78a6128dc565b6fffffffffffffffffffffffffffffffff168152602001612ee7836124fc565b64ffffffffff168152602001612efc8961363d565b63ffffffff168152602001612f1084613687565b61ffff90811682526000602092830181905273ffffffffffffffffffffffffffffffffffffffff9099168952600c82526040808a20958a52948252978490208251815492840151958401516060850151608086015164ffffffffff9081167b01000000000000000000000000000000000000000000000000000000027affffffffffffffffffffffffffffffffffffffffffffffffffffff92909d16790100000000000000000000000000000000000000000000000000027fffffffffff0000ffffffffffffffffffffffffffffffffffffffffffffffffff63ffffffff909416750100000000000000000000000000000000000000000002939093167fffffffffff000000000000ffffffffffffffffffffffffffffffffffffffffff99909116700100000000000000000000000000000000027fffffffffffffffffffffff0000000000000000000000000000000000000000009096166fffffffffffffffffffffffffffffffff90941693909317949094179690961617949094171696909617909155509295945050505050565b60405173ffffffffffffffffffffffffffffffffffffffff84811660248301528381166044830152606482018390526130e79186918216906323b872dd90608401612741565b50505050565b6130f561348d565b7fcd5ed15c6e187e77e9aee88184c21f4f2182ab5827cb3b7e07fbedcd63f0330080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660011781557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258336129fc565b73ffffffffffffffffffffffffffffffffffffffff81166000908152600c602090815260408083208684529091528120805490916fffffffffffffffffffffffffffffffff90911690036131e6576040517f6d97cdda00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b80547501000000000000000000000000000000000000000000900463ffffffff161561323d576040517ee24fbd00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b80547b01000000000000000000000000000000000000000000000000000000900464ffffffffff161561329c576040517f15499e2300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60006132a960008561254b565b905060006132b6846127f5565b905081600960008282546132ca9190613e91565b9250508190555084600860008282546132e39190613e91565b909155506132f29050826128dc565b815482906000906133169084906fffffffffffffffffffffffffffffffff16613f9f565b92506101000a8154816fffffffffffffffffffffffffffffffff02191690836fffffffffffffffffffffffffffffffff160217905550613355856128dc565b835484906000906133799084906fffffffffffffffffffffffffffffffff16613f9f565b92506101000a8154816fffffffffffffffffffffffffffffffff02191690836fffffffffffffffffffffffffffffffff160217905550505050505050565b6133bf6136cf565b611a5f81613736565b6116586136cf565b6133d86136cf565b61165861378e565b600061340273ffffffffffffffffffffffffffffffffffffffff8416836137df565b905080516000141580156134275750808060200190518101906134259190614040565b155b156119dd576040517f5274afe700000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff84166004820152602401611a4d565b60006003544210613488575060035490565b504290565b7fcd5ed15c6e187e77e9aee88184c21f4f2182ab5827cb3b7e07fbedcd63f033005460ff1615611658576040517fd93c066500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b7fcd5ed15c6e187e77e9aee88184c21f4f2182ab5827cb3b7e07fbedcd63f033005460ff16611658576040517f8dfc202b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61354d826137ed565b60405173ffffffffffffffffffffffffffffffffffffffff8316907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a280511561359f576119dd82826138bc565b611495613936565b7f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c19930080547fffffffffffffffffffffffff0000000000000000000000000000000000000000811673ffffffffffffffffffffffffffffffffffffffff848116918217845560405192169182907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3505050565b600063ffffffff821115612547576040517f6dfcc6500000000000000000000000000000000000000000000000000000000081526020600482015260248101839052604401611a4d565b600061ffff821115612547576040517f6dfcc6500000000000000000000000000000000000000000000000000000000081526010600482015260248101839052604401611a4d565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a005468010000000000000000900460ff16611658576040517fd7e6bcf800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61373e6136cf565b73ffffffffffffffffffffffffffffffffffffffff8116611a56576040517f1e4fbdf700000000000000000000000000000000000000000000000000000000815260006004820152602401611a4d565b6137966136cf565b7fcd5ed15c6e187e77e9aee88184c21f4f2182ab5827cb3b7e07fbedcd63f0330080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00169055565b60606113c18383600061396e565b8073ffffffffffffffffffffffffffffffffffffffff163b600003613856576040517f4c9c8ce300000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff82166004820152602401611a4d565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc80547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b60606000808473ffffffffffffffffffffffffffffffffffffffff16846040516138e69190614062565b600060405180830381855af49150503d8060008114613921576040519150601f19603f3d011682016040523d82523d6000602084013e613926565b606091505b5091509150611173858383613a23565b3415611658576040517fb398979f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6060814710156139ac576040517fcd786059000000000000000000000000000000000000000000000000000000008152306004820152602401611a4d565b6000808573ffffffffffffffffffffffffffffffffffffffff1684866040516139d59190614062565b60006040518083038185875af1925050503d8060008114613a12576040519150601f19603f3d011682016040523d82523d6000602084013e613a17565b606091505b5091509150610dbf8683835b606082613a3857613a3382613ab2565b6113c1565b8151158015613a5c575073ffffffffffffffffffffffffffffffffffffffff84163b155b15613aab576040517f9996b31500000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff85166004820152602401611a4d565b50806113c1565b805115613ac25780518082602001fd5b6040517f1425ea4200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600060208284031215613b0657600080fd5b5035919050565b73ffffffffffffffffffffffffffffffffffffffff81168114611a5f57600080fd5b60008060408385031215613b4257600080fd5b8235613b4d81613b0d565b946020939093013593505050565b600060208284031215613b6d57600080fd5b81356113c181613b0d565b600080600060608486031215613b8d57600080fd5b8335613b9881613b0d565b95602085013595506040909401359392505050565b602080825282518282018190526000919060409081850190868401855b82811015613c3457815180516fffffffffffffffffffffffffffffffff1685528681015164ffffffffff908116888701528682015163ffffffff168787015260608083015161ffff1690870152608091820151169085015260a09093019290850190600101613bca565b5091979650505050505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b60008060408385031215613c8357600080fd5b8235613c8e81613b0d565b9150602083013567ffffffffffffffff80821115613cab57600080fd5b818501915085601f830112613cbf57600080fd5b813581811115613cd157613cd1613c41565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f01168101908382118183101715613d1757613d17613c41565b81604052828152886020848701011115613d3057600080fd5b8260208601602083013760006020848301015280955050505050509250929050565b600080600060608486031215613d6757600080fd5b83359250602084013591506040840135613d8081613b0d565b809150509250925092565b60008060408385031215613d9e57600080fd5b50508035926020909101359150565b60005b83811015613dc8578181015183820152602001613db0565b50506000910152565b6020815260008251806020840152613df0816040850160208701613dad565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169190910160400192915050565b600080600060608486031215613e3757600080fd5b8335613e4281613b0d565b92506020840135613e5281613b0d565b91506040840135613d8081613b0d565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b8082018082111561260657612606613e62565b808202811582820484141761260657612606613e62565b8181038181111561260657612606613e62565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b600082613f33577f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b500490565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8203613f9857613f98613e62565b5060010190565b6fffffffffffffffffffffffffffffffff818116838216019080821115613fc857613fc8613e62565b5092915050565b600060208284031215613fe157600080fd5b5051919050565b6fffffffffffffffffffffffffffffffff828116828216039080821115613fc857613fc8613e62565b60006fffffffffffffffffffffffffffffffff80831681810361403657614036613e62565b6001019392505050565b60006020828403121561405257600080fd5b815180151581146113c157600080fd5b60008251614074818460208701613dad565b919091019291505056fea2646970667358221220b58cd54d7ff5068c1ddc25d5e476b2ca5299a62c494242fb5de9169476e750e964736f6c63430008170033

Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

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

Validator Index Block Amount
View All Withdrawals

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

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.