false
true
0

Contract Address Details

0x39E2a049e7DBA9549F9E0ae6af5ebdf8D06C354b

Contract Name
Staking
Creator
0xb94333–acb7c0 at 0x3f866a–404cf7
Balance
0 tPLS
Tokens
Fetching tokens...
Transactions
Fetching transactions...
Transfers
Fetching transfers...
Gas Used
Fetching gas used...
Last Balance Update
25393873
Warning! Contract bytecode has been changed and doesn't match the verified one. Therefore, interaction with this smart contract may be risky.
Contract name:
Staking




Optimization enabled
true
Compiler version
v0.8.17+commit.8df45f5f




Optimization runs
200
EVM Version
default




Verified at
2025-04-30T20:24:24.886220Z

Constructor Arguments

0x000000000000000000000000d95b589ac4ddb36fa33399b4aa0834d22ce749e3

Arg [0] (address) : 0xd95b589ac4ddb36fa33399b4aa0834d22ce749e3

              

contracts/governance/Staking.sol

// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.7;
pragma abicoder v2;

// OpenZeppelin v4
import { Math } from "@openzeppelin/contracts/utils/math/Math.sol";
import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";

/**
 * @title Snapshot
 * @author Railgun Contributors
 * @notice Governance contract for railgun, handles staking, voting power, and snapshotting
 * @dev Snapshots cannot be taken during interval 0
 * wait till interval 1 before utilizing snapshots
 */
contract Staking {
  using SafeERC20 for IERC20;

  // Constants
  uint256 public constant STAKE_LOCKTIME = 30 days;
  uint256 public constant SNAPSHOT_INTERVAL = 1 days;

  // Staking token
  IERC20 public stakingToken;

  // Time of deployment
  // solhint-disable-next-line var-name-mixedcase
  uint256 public immutable DEPLOY_TIME = block.timestamp;

  // New stake created
  event Stake(address indexed account, uint256 indexed stakeID, uint256 amount);

  // Stake unlocked (coins removed from voting pool, 30 day delay before claiming is allowed)
  event Unlock(address indexed account, uint256 indexed stakeID);

  // Stake claimed
  event Claim(address indexed account, uint256 indexed stakeID);

  // Delegate claimed
  event Delegate(
    address indexed owner,
    address indexed _from,
    address indexed to,
    uint256 stakeID,
    uint256 amount
  );

  // Total staked
  uint256 public totalStaked = 0;

  // Snapshots for globals
  struct GlobalsSnapshot {
    uint256 interval;
    uint256 totalVotingPower;
    uint256 totalStaked;
  }
  GlobalsSnapshot[] private globalsSnapshots;

  // Stake
  struct StakeStruct {
    address delegate; // Address stake voting power is delegated to
    uint256 amount; // Amount of tokens on this stake
    uint256 staketime; // Time this stake was created
    uint256 locktime; // Time this stake can be claimed (if 0, unlock hasn't been initiated)
    uint256 claimedTime; // Time this stake was claimed (if 0, stake hasn't been claimed)
  }

  // Stake mapping
  // address => stakeID => stake
  mapping(address => StakeStruct[]) public stakes;

  // Voting power for each account
  mapping(address => uint256) public votingPower;

  // Snapshots for accounts
  struct AccountSnapshot {
    uint256 interval;
    uint256 votingPower;
  }
  mapping(address => AccountSnapshot[]) private accountSnapshots;

  /**
   * @notice Sets staking token
   * @param _stakingToken - time to get interval of
   */

  constructor(IERC20 _stakingToken) {
    stakingToken = _stakingToken;

    // Use address 0 to store inverted totalVotingPower
    votingPower[address(0)] = type(uint256).max;
  }

  /**
   * @notice Gets total voting power in system
   * @return totalVotingPower
   */

  function totalVotingPower() public view returns (uint256) {
    return ~votingPower[address(0)];
  }

  /**
   * @notice Gets length of stakes array for address
   * @param _account - address to retrieve stakes array of
   * @return length
   */

  function stakesLength(address _account) external view returns (uint256) {
    return stakes[_account].length;
  }

  /**
   * @notice Gets interval at time
   * @param _time - time to get interval of
   * @return interval
   */

  function intervalAtTime(uint256 _time) public view returns (uint256) {
    require(_time >= DEPLOY_TIME, "Staking: Requested time is before contract was deployed");
    return (_time - DEPLOY_TIME) / SNAPSHOT_INTERVAL;
  }

  /**
   * @notice Gets current interval
   * @return interval
   */

  function currentInterval() public view returns (uint256) {
    return intervalAtTime(block.timestamp);
  }

  /**
   * @notice Returns interval of latest global snapshot
   * @return Latest global snapshot interval
   */

  function latestGlobalsSnapshotInterval() public view returns (uint256) {
    if (globalsSnapshots.length > 0) {
      // If a snapshot exists return the interval it was taken
      return globalsSnapshots[globalsSnapshots.length - 1].interval;
    } else {
      // Else default to 0
      return 0;
    }
  }

  /**
   * @notice Returns interval of latest account snapshot
   * @param _account - account to get latest snapshot of
   * @return Latest account snapshot interval
   */

  function latestAccountSnapshotInterval(address _account) public view returns (uint256) {
    if (accountSnapshots[_account].length > 0) {
      // If a snapshot exists return the interval it was taken
      return accountSnapshots[_account][accountSnapshots[_account].length - 1].interval;
    } else {
      // Else default to 0
      return 0;
    }
  }

  /**
   * @notice Returns length of snapshot array
   * @param _account - account to get snapshot array length of
   * @return Snapshot array length
   */

  function accountSnapshotLength(address _account) external view returns (uint256) {
    return accountSnapshots[_account].length;
  }

  /**
   * @notice Returns length of snapshot array
   * @return Snapshot array length
   */

  function globalsSnapshotLength() external view returns (uint256) {
    return globalsSnapshots.length;
  }

  /**
   * @notice Returns global snapshot at index
   * @param _index - account to get latest snapshot of
   * @return Globals snapshot
   */

  function globalsSnapshot(uint256 _index) external view returns (GlobalsSnapshot memory) {
    return globalsSnapshots[_index];
  }

  /**
   * @notice Returns account snapshot at index
   * @param _account - account to get snapshot of
   * @param _index - index to get snapshot at
   * @return Account snapshot
   */
  function accountSnapshot(
    address _account,
    uint256 _index
  ) external view returns (AccountSnapshot memory) {
    return accountSnapshots[_account][_index];
  }

  /**
   * @notice Checks if account and globals snapshots need updating and updates
   * @param _account - Account to take snapshot for
   */
  function snapshot(address _account) internal {
    uint256 _currentInterval = currentInterval();

    // If latest global snapshot is less than current interval, push new snapshot
    if (latestGlobalsSnapshotInterval() < _currentInterval) {
      globalsSnapshots.push(GlobalsSnapshot(_currentInterval, totalVotingPower(), totalStaked));
    }

    // If latest account snapshot is less than current interval, push new snapshot
    // Skip if account is 0 address
    if (_account != address(0) && latestAccountSnapshotInterval(_account) < _currentInterval) {
      accountSnapshots[_account].push(AccountSnapshot(_currentInterval, votingPower[_account]));
    }
  }

  /**
   * @notice Moves voting power in response to delegation or stake/unstake
   * @param _from - account to move voting power fom
   * @param _to - account to move voting power to
   * @param _amount - amount of voting power to move
   */
  function moveVotingPower(address _from, address _to, uint256 _amount) internal {
    votingPower[_from] -= _amount;
    votingPower[_to] += _amount;
  }

  /**
   * @notice Updates vote delegation
   * @param _stakeID - stake to delegate
   * @param _to - address to delegate to
   */

  function delegate(uint256 _stakeID, address _to) public {
    StakeStruct storage _stake = stakes[msg.sender][_stakeID];

    require(_stake.locktime == 0, "Staking: Stake unlocked");

    require(_to != address(0), "Staking: Can't delegate to 0 address");

    if (_stake.delegate != _to) {
      // Check if snapshot needs to be taken
      snapshot(_stake.delegate); // From
      snapshot(_to); // To

      // Move voting power to delegatee
      moveVotingPower(_stake.delegate, _to, _stake.amount);

      // Emit event
      emit Delegate(msg.sender, _stake.delegate, _to, _stakeID, _stake.amount);

      // Update delegation
      _stake.delegate = _to;
    }
  }

  /**
   * @notice Delegates voting power of stake back to self
   * @param _stakeID - stake to delegate back to self
   */

  function undelegate(uint256 _stakeID) external {
    delegate(_stakeID, msg.sender);
  }

  /**
   * @notice Gets global state at interval
   * @param _interval - interval to get state at
   * @return state
   */

  function globalsSnapshotAtSearch(
    uint256 _interval
  ) internal view returns (GlobalsSnapshot memory) {
    // Index of element
    uint256 index;

    // High/low for binary search to find index
    // https://en.wikipedia.org/wiki/Binary_search_algorithm
    uint256 low = 0;
    uint256 high = globalsSnapshots.length;

    while (low < high) {
      uint256 mid = Math.average(low, high);

      // Note that mid will always be strictly less than high (i.e. it will be a valid array index)
      // because Math.average rounds down (it does integer division with truncation).
      if (globalsSnapshots[mid].interval > _interval) {
        high = mid;
      } else {
        low = mid + 1;
      }
    }

    // At this point `low` is the exclusive upper bound. Find the inclusive upper bounds and set to index
    if (low > 0 && globalsSnapshots[low - 1].interval == _interval) {
      return globalsSnapshots[low - 1];
    } else {
      index = low;
    }

    // If index is equal to snapshot array length, then no update was made after the requested
    // snapshot interval. This means the latest value is the right one.
    if (index == globalsSnapshots.length) {
      return GlobalsSnapshot(_interval, totalVotingPower(), totalStaked);
    } else {
      return globalsSnapshots[index];
    }
  }

  /**
   * @notice Gets global state at interval
   * @param _interval - interval to get state at
   * @param _hint - off-chain computed index of interval
   * @return state
   */

  function globalsSnapshotAt(
    uint256 _interval,
    uint256 _hint
  ) external view returns (GlobalsSnapshot memory) {
    require(_interval <= currentInterval(), "Staking: Interval out of bounds");

    // Check if hint is correct, else fall back to binary search
    if (
      _hint <= globalsSnapshots.length &&
      (_hint == 0 || globalsSnapshots[_hint - 1].interval < _interval) &&
      (_hint == globalsSnapshots.length || globalsSnapshots[_hint].interval >= _interval)
    ) {
      // The hint is correct
      if (_hint < globalsSnapshots.length) return globalsSnapshots[_hint];
      else return GlobalsSnapshot(_interval, totalVotingPower(), totalStaked);
    } else return globalsSnapshotAtSearch(_interval);
  }

  /**
   * @notice Gets account state at interval
   * @param _account - account to get state for
   * @param _interval - interval to get state at
   * @return state
   */
  function accountSnapshotAtSearch(
    address _account,
    uint256 _interval
  ) internal view returns (AccountSnapshot memory) {
    // Get account snapshots array
    AccountSnapshot[] storage snapshots = accountSnapshots[_account];

    // Index of element
    uint256 index;

    // High/low for binary search to find index
    // https://en.wikipedia.org/wiki/Binary_search_algorithm
    uint256 low = 0;
    uint256 high = snapshots.length;

    while (low < high) {
      uint256 mid = Math.average(low, high);

      // Note that mid will always be strictly less than high (i.e. it will be a valid array index)
      // because Math.average rounds down (it does integer division with truncation).
      if (snapshots[mid].interval > _interval) {
        high = mid;
      } else {
        low = mid + 1;
      }
    }

    // At this point `low` is the exclusive upper bound. Find the inclusive upper bounds and set to index
    if (low > 0 && snapshots[low - 1].interval == _interval) {
      return snapshots[low - 1];
    } else {
      index = low;
    }

    // If index is equal to snapshot array length, then no update was made after the requested
    // snapshot interval. This means the latest value is the right one.
    if (index == snapshots.length) {
      return AccountSnapshot(_interval, votingPower[_account]);
    } else {
      return snapshots[index];
    }
  }

  /**
   * @notice Gets account state at interval
   * @param _account - account to get state for
   * @param _interval - interval to get state at
   * @param _hint - off-chain computed index of interval
   * @return state
   */
  function accountSnapshotAt(
    address _account,
    uint256 _interval,
    uint256 _hint
  ) external view returns (AccountSnapshot memory) {
    require(_interval <= currentInterval(), "Staking: Interval out of bounds");

    // Get account snapshots array
    AccountSnapshot[] storage snapshots = accountSnapshots[_account];

    // Check if hint is correct, else fall back to binary search
    if (
      _hint <= snapshots.length &&
      (_hint == 0 || snapshots[_hint - 1].interval < _interval) &&
      (_hint == snapshots.length || snapshots[_hint].interval >= _interval)
    ) {
      // The hint is correct
      if (_hint < snapshots.length) return snapshots[_hint];
      else return AccountSnapshot(_interval, votingPower[_account]);
    } else return accountSnapshotAtSearch(_account, _interval);
  }

  /**
   * @notice Stake tokens
   * @dev This contract should be approve()'d for _amount
   * @param _amount - Amount to stake
   * @return stake ID
   */

  function stake(uint256 _amount) public returns (uint256) {
    // Check if amount is not 0
    require(_amount > 0, "Staking: Amount not set");

    // Check if snapshot needs to be taken
    snapshot(msg.sender);

    // Get stakeID
    uint256 stakeID = stakes[msg.sender].length;

    // Set stake values
    stakes[msg.sender].push(StakeStruct(msg.sender, _amount, block.timestamp, 0, 0));

    // Increment global staked
    totalStaked += _amount;

    // Add voting power
    moveVotingPower(address(0), msg.sender, _amount);

    // Transfer tokens
    stakingToken.safeTransferFrom(msg.sender, address(this), _amount);

    // Emit event
    emit Stake(msg.sender, stakeID, _amount);

    return stakeID;
  }

  /**
   * @notice Unlock stake tokens
   * @param _stakeID - Stake to unlock
   */

  function unlock(uint256 _stakeID) public {
    require(stakes[msg.sender][_stakeID].locktime == 0, "Staking: Stake already unlocked");

    // Check if snapshot needs to be taken
    snapshot(msg.sender);

    // Set stake locktime
    stakes[msg.sender][_stakeID].locktime = block.timestamp + STAKE_LOCKTIME;

    // Remove voting power
    moveVotingPower(
      stakes[msg.sender][_stakeID].delegate,
      address(0),
      stakes[msg.sender][_stakeID].amount
    );

    // Emit event
    emit Unlock(msg.sender, _stakeID);
  }

  /**
   * @notice Claim stake token
   * @param _stakeID - Stake to claim
   */

  function claim(uint256 _stakeID) public {
    require(
      stakes[msg.sender][_stakeID].locktime != 0 &&
        stakes[msg.sender][_stakeID].locktime < block.timestamp,
      "Staking: Stake not unlocked"
    );

    require(stakes[msg.sender][_stakeID].claimedTime == 0, "Staking: Stake already claimed");

    // Check if snapshot needs to be taken
    snapshot(msg.sender);

    // Set stake claimed time
    stakes[msg.sender][_stakeID].claimedTime = block.timestamp;

    // Decrement global staked
    totalStaked -= stakes[msg.sender][_stakeID].amount;

    // Transfer tokens
    stakingToken.safeTransfer(msg.sender, stakes[msg.sender][_stakeID].amount);

    // Emit event
    emit Claim(msg.sender, _stakeID);
  }
}
        

@openzeppelin/contracts/token/ERC20/IERC20.sol

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

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

@openzeppelin/contracts/token/ERC20/extensions/IERC20Permit.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.4) (token/ERC20/extensions/IERC20Permit.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
 * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
 *
 * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
 * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't
 * need to send a transaction, and thus is not required to hold Ether at all.
 *
 * ==== 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);
}
          

@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol

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

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

@openzeppelin/contracts/utils/Address.sol

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

pragma solidity ^0.8.1;

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

        return account.code.length > 0;
    }

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

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

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

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

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

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

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

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

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

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

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

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

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

@openzeppelin/contracts/utils/math/Math.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/math/Math.sol)

pragma solidity ^0.8.0;

/**
 * @dev Standard math utilities missing in the Solidity language.
 */
library Math {
    enum Rounding {
        Down, // Toward negative infinity
        Up, // Toward infinity
        Zero // Toward zero
    }

    /**
     * @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 up instead
     * of rounding down.
     */
    function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
        // (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; // Least significant 256 bits of the product
            uint256 prod1; // Most significant 256 bits of the product
            assembly {
                let mm := mulmod(x, y, not(0))
                prod0 := mul(x, y)
                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.
            require(denominator > prod1, "Math: mulDiv overflow");

            ///////////////////////////////////////////////
            // 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.

            // Does not overflow because the denominator cannot be zero at this stage in the function.
            uint256 twos = denominator & (~denominator + 1);
            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 (rounding == Rounding.Up && 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 down.
     *
     * 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 + (rounding == Rounding.Up && result * result < a ? 1 : 0);
        }
    }

    /**
     * @dev Return the log in base 2, rounded down, of a positive value.
     * 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 + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);
        }
    }

    /**
     * @dev Return the log in base 10, rounded down, of a positive value.
     * 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 + (rounding == Rounding.Up && 10 ** result < value ? 1 : 0);
        }
    }

    /**
     * @dev Return the log in base 256, rounded down, of a positive value.
     * 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 + (rounding == Rounding.Up && 1 << (result << 3) < value ? 1 : 0);
        }
    }
}
          

Compiler Settings

{"outputSelection":{"*":{"*":["storageLayout","abi","evm.bytecode","evm.deployedBytecode","evm.methodIdentifiers","metadata"],"":["ast"]}},"optimizer":{"runs":200,"enabled":true},"libraries":{}}
              

Contract ABI

[{"type":"constructor","stateMutability":"nonpayable","inputs":[{"type":"address","name":"_stakingToken","internalType":"contract IERC20"}]},{"type":"event","name":"Claim","inputs":[{"type":"address","name":"account","internalType":"address","indexed":true},{"type":"uint256","name":"stakeID","internalType":"uint256","indexed":true}],"anonymous":false},{"type":"event","name":"Delegate","inputs":[{"type":"address","name":"owner","internalType":"address","indexed":true},{"type":"address","name":"_from","internalType":"address","indexed":true},{"type":"address","name":"to","internalType":"address","indexed":true},{"type":"uint256","name":"stakeID","internalType":"uint256","indexed":false},{"type":"uint256","name":"amount","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"Stake","inputs":[{"type":"address","name":"account","internalType":"address","indexed":true},{"type":"uint256","name":"stakeID","internalType":"uint256","indexed":true},{"type":"uint256","name":"amount","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"Unlock","inputs":[{"type":"address","name":"account","internalType":"address","indexed":true},{"type":"uint256","name":"stakeID","internalType":"uint256","indexed":true}],"anonymous":false},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"DEPLOY_TIME","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"SNAPSHOT_INTERVAL","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"STAKE_LOCKTIME","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"tuple","name":"","internalType":"struct Staking.AccountSnapshot","components":[{"type":"uint256","name":"interval","internalType":"uint256"},{"type":"uint256","name":"votingPower","internalType":"uint256"}]}],"name":"accountSnapshot","inputs":[{"type":"address","name":"_account","internalType":"address"},{"type":"uint256","name":"_index","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"tuple","name":"","internalType":"struct Staking.AccountSnapshot","components":[{"type":"uint256","name":"interval","internalType":"uint256"},{"type":"uint256","name":"votingPower","internalType":"uint256"}]}],"name":"accountSnapshotAt","inputs":[{"type":"address","name":"_account","internalType":"address"},{"type":"uint256","name":"_interval","internalType":"uint256"},{"type":"uint256","name":"_hint","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"accountSnapshotLength","inputs":[{"type":"address","name":"_account","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"claim","inputs":[{"type":"uint256","name":"_stakeID","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"currentInterval","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"delegate","inputs":[{"type":"uint256","name":"_stakeID","internalType":"uint256"},{"type":"address","name":"_to","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"tuple","name":"","internalType":"struct Staking.GlobalsSnapshot","components":[{"type":"uint256","name":"interval","internalType":"uint256"},{"type":"uint256","name":"totalVotingPower","internalType":"uint256"},{"type":"uint256","name":"totalStaked","internalType":"uint256"}]}],"name":"globalsSnapshot","inputs":[{"type":"uint256","name":"_index","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"tuple","name":"","internalType":"struct Staking.GlobalsSnapshot","components":[{"type":"uint256","name":"interval","internalType":"uint256"},{"type":"uint256","name":"totalVotingPower","internalType":"uint256"},{"type":"uint256","name":"totalStaked","internalType":"uint256"}]}],"name":"globalsSnapshotAt","inputs":[{"type":"uint256","name":"_interval","internalType":"uint256"},{"type":"uint256","name":"_hint","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"globalsSnapshotLength","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"intervalAtTime","inputs":[{"type":"uint256","name":"_time","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"latestAccountSnapshotInterval","inputs":[{"type":"address","name":"_account","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"latestGlobalsSnapshotInterval","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"stake","inputs":[{"type":"uint256","name":"_amount","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"delegate","internalType":"address"},{"type":"uint256","name":"amount","internalType":"uint256"},{"type":"uint256","name":"staketime","internalType":"uint256"},{"type":"uint256","name":"locktime","internalType":"uint256"},{"type":"uint256","name":"claimedTime","internalType":"uint256"}],"name":"stakes","inputs":[{"type":"address","name":"","internalType":"address"},{"type":"uint256","name":"","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"stakesLength","inputs":[{"type":"address","name":"_account","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"contract IERC20"}],"name":"stakingToken","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"totalStaked","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"totalVotingPower","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"undelegate","inputs":[{"type":"uint256","name":"_stakeID","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"unlock","inputs":[{"type":"uint256","name":"_stakeID","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"votingPower","inputs":[{"type":"address","name":"","internalType":"address"}]}]
              

Contract Creation Code

0x60a060405242608052600060015534801561001957600080fd5b50604051611b6d380380611b6d83398101604081905261003891610089565b600080546001600160a01b0319166001600160a01b0392909216919091178155805260046020526000197f17ef568e3e12ab5b9c7254a8d58478811de00f9e6eb34345acd53bf8fd09d3ec556100b9565b60006020828403121561009b57600080fd5b81516001600160a01b03811681146100b257600080fd5b9392505050565b608051611a8b6100e260003960008181610367015281816103ca015261046c0152611a8b6000f3fe608060405234801561001057600080fd5b50600436106101585760003560e01c8063681c637a116100c357806376992ec61161007c57806376992ec614610346578063817b1cd21461035957806390d92e7614610362578063a694fc3a14610389578063bed3b60c1461039c578063c07473f6146103a657600080fd5b8063681c637a146102d05780636c68c0e1146102e35780636ce0a99f146102f65780636d2beef1146103095780636d4361871461031357806372f702f31461031b57600080fd5b8063363487bc11610115578063363487bc1461022c578063379607f51461023457806349fc9df714610247578063584b62a1146102705780636198e339146102b5578063671b3793146102c857600080fd5b8063011de7aa1461015d578063074bc01d1461018357806308bbb8241461018b57806308d465e6146101a057806309fe7dd8146101ce57806324d63ba314610203575b600080fd5b61017061016b366004611856565b6103c6565b6040519081526020015b60405180910390f35b600254610170565b61019e610199366004611886565b6104a1565b005b6101b36101ae3660046118b2565b610645565b6040805182518152602092830151928101929092520161017a565b6101e16101dc366004611856565b6107e4565b604080518251815260208084015190820152918101519082015260600161017a565b6101706102113660046118e5565b6001600160a01b031660009081526005602052604090205490565b610170610859565b61019e610242366004611856565b610869565b6101706102553660046118e5565b6001600160a01b031660009081526003602052604090205490565b61028361027e366004611900565b610ab6565b604080516001600160a01b0390961686526020860194909452928401919091526060830152608082015260a00161017a565b61019e6102c3366004611856565b610b0e565b610170610c85565b6101e16102de36600461192a565b610cb4565b61019e6102f1366004611856565b610e45565b6101b3610304366004611900565b610e52565b6101706201518081565b610170610ec5565b60005461032e906001600160a01b031681565b6040516001600160a01b03909116815260200161017a565b6101706103543660046118e5565b610f0d565b61017060015481565b6101707f000000000000000000000000000000000000000000000000000000000000000081565b610170610397366004611856565b610f87565b61017062278d0081565b6101706103b43660046118e5565b60046020526000908152604090205481565b60007f00000000000000000000000000000000000000000000000000000000000000008210156104635760405162461bcd60e51b815260206004820152603760248201527f5374616b696e673a205265717565737465642074696d65206973206265666f7260448201527f6520636f6e747261637420776173206465706c6f79656400000000000000000060648201526084015b60405180910390fd5b620151806104917f000000000000000000000000000000000000000000000000000000000000000084611962565b61049b9190611975565b92915050565b3360009081526003602052604081208054849081106104c2576104c2611997565b9060005260206000209060050201905080600301546000146105265760405162461bcd60e51b815260206004820152601760248201527f5374616b696e673a205374616b6520756e6c6f636b6564000000000000000000604482015260640161045a565b6001600160a01b0382166105885760405162461bcd60e51b8152602060048201526024808201527f5374616b696e673a2043616e27742064656c656761746520746f2030206164646044820152637265737360e01b606482015260840161045a565b80546001600160a01b038381169116146106405780546105b0906001600160a01b03166110e6565b6105b9826110e6565b805460018201546105d5916001600160a01b03169084906111d7565b805460018201546040805186815260208101929092526001600160a01b0385811693169133917f086d57859b1d11780b2ef086bf84cef0e295c4cec8900b8e1620c6666b667542910160405180910390a480546001600160a01b0319166001600160a01b0383161781555b505050565b6040805180820190915260008082526020820152610661610859565b8311156106b05760405162461bcd60e51b815260206004820152601f60248201527f5374616b696e673a20496e74657276616c206f7574206f6620626f756e647300604482015260640161045a565b6001600160a01b03841660009081526005602052604090208054831180159061070d575082158061070d575083816106e9600186611962565b815481106106f9576106f9611997565b906000526020600020906002020160000154105b80156107465750805483148061074657508381848154811061073157610731611997565b90600052602060002090600202016000015410155b156107cf57805483101561079b5780838154811061076657610766611997565b9060005260206000209060020201604051806040016040529081600082015481526020016001820154815250509150506107dd565b50506040805180820182528381526001600160a01b03851660009081526004602090815292902054918101919091526107dd565b6107d98585611236565b9150505b9392505050565b61080860405180606001604052806000815260200160008152602001600081525090565b6002828154811061081b5761081b611997565b906000526020600020906003020160405180606001604052908160008201548152602001600182015481526020016002820154815250509050919050565b6000610864426103c6565b905090565b33600090815260036020526040902080548290811061088a5761088a611997565b9060005260206000209060050201600301546000141580156108df57503360009081526003602052604090208054429190839081106108cb576108cb611997565b906000526020600020906005020160030154105b61092b5760405162461bcd60e51b815260206004820152601b60248201527f5374616b696e673a205374616b65206e6f7420756e6c6f636b65640000000000604482015260640161045a565b33600090815260036020526040902080548290811061094c5761094c611997565b9060005260206000209060050201600401546000146109ad5760405162461bcd60e51b815260206004820152601e60248201527f5374616b696e673a205374616b6520616c726561647920636c61696d65640000604482015260640161045a565b6109b6336110e6565b3360009081526003602052604090208054429190839081106109da576109da611997565b6000918252602080832060046005909302019190910192909255338152600390915260409020805482908110610a1257610a12611997565b90600052602060002090600502016001015460016000828254610a359190611962565b90915550503360008181526003602052604090208054610a8692919084908110610a6157610a61611997565b6000918252602082206001600590920201015490546001600160a01b031691906113be565b604051819033907f47cee97cb7acd717b3c0aa1435d004cd5b3c8c57d70dbceb4e4458bbd60e39d490600090a350565b60036020528160005260406000208181548110610ad257600080fd5b6000918252602090912060059091020180546001820154600283015460038401546004909401546001600160a01b039093169550909350919085565b336000908152600360205260409020805482908110610b2f57610b2f611997565b906000526020600020906005020160030154600014610b905760405162461bcd60e51b815260206004820152601f60248201527f5374616b696e673a205374616b6520616c726561647920756e6c6f636b656400604482015260640161045a565b610b99336110e6565b610ba662278d00426119ad565b336000908152600360205260409020805483908110610bc757610bc7611997565b600091825260208083206003600590930201820193909355338252909152604090208054610c55919083908110610c0057610c00611997565b6000918252602080832060059092029091015433835260039091526040822080546001600160a01b03909216929185908110610c3e57610c3e611997565b9060005260206000209060050201600101546111d7565b604051819033907f6381d9813cabeb57471b5a7e05078e64845ccdb563146a6911d536f24ce960f190600090a350565b6000805260046020527f17ef568e3e12ab5b9c7254a8d58478811de00f9e6eb34345acd53bf8fd09d3ec541990565b610cd860405180606001604052806000815260200160008152602001600081525090565b610ce0610859565b831115610d2f5760405162461bcd60e51b815260206004820152601f60248201527f5374616b696e673a20496e74657276616c206f7574206f6620626f756e647300604482015260640161045a565b6002548211801590610d765750811580610d765750826002610d52600185611962565b81548110610d6257610d62611997565b906000526020600020906003020160000154105b8015610db15750600254821480610db157508260028381548110610d9c57610d9c611997565b90600052602060002090600302016000015410155b15610e3c57600254821015610e115760028281548110610dd357610dd3611997565b90600052602060002090600302016040518060600160405290816000820154815260200160018201548152602001600282015481525050905061049b565b6040518060600160405280848152602001610e2a610c85565b8152602001600154815250905061049b565b6107dd83611421565b610e4f81336104a1565b50565b60408051808201909152600080825260208201526001600160a01b0383166000908152600560205260409020805483908110610e9057610e90611997565b906000526020600020906002020160405180604001604052908160008201548152602001600182015481525050905092915050565b60025460009015610f075760028054610ee090600190611962565b81548110610ef057610ef0611997565b906000526020600020906003020160000154905090565b50600090565b6001600160a01b03811660009081526005602052604081205415610f7a576001600160a01b03821660009081526005602052604090208054610f5190600190611962565b81548110610f6157610f61611997565b9060005260206000209060020201600001549050919050565b506000919050565b919050565b6000808211610fd85760405162461bcd60e51b815260206004820152601760248201527f5374616b696e673a20416d6f756e74206e6f7420736574000000000000000000604482015260640161045a565b610fe1336110e6565b3360008181526003602081815260408084208054825160a0810184529687528684018981524293880193845260608801878152608089018881526001808501865594895295882098516005840290990180546001600160a01b0319166001600160a01b03909a16999099178955905188840155925160028801559151938601939093559051600490940193909355805485929061107f9084906119ad565b909155506110919050600033856111d7565b6000546110a9906001600160a01b0316333086611598565b604051838152819033907f5af417134f72a9d41143ace85b0a26dce6f550f894f2cbc1eeee8810603d91b69060200160405180910390a392915050565b60006110f0610859565b9050806110fb610ec5565b1015611156576002604051806060016040528083815260200161111c610c85565b8152600180546020928301528354808201855560009485529382902083516003909502019384559082015190830155604001516002909101555b6001600160a01b0382161580159061117557508061117383610f0d565b105b156111d3576001600160a01b0382166000818152600560209081526040808320815180830183528681529484526004835290832054848301908152815460018181018455928552929093209351600290920290930190815590519101555b5050565b6001600160a01b038316600090815260046020526040812080548392906111ff908490611962565b90915550506001600160a01b0382166000908152600460205260408120805483929061122c9084906119ad565b9091555050505050565b60408051808201909152600080825260208201526001600160a01b0383166000908152600560205260408120805490919081905b808210156112c757600061127e83836115d6565b90508685828154811061129357611293611997565b90600052602060002090600202016000015411156112b3578091506112c1565b6112be8160016119ad565b92505b5061126a565b600082118015611303575085846112df600185611962565b815481106112ef576112ef611997565b906000526020600020906002020160000154145b1561135c5783611314600184611962565b8154811061132457611324611997565b90600052602060002090600202016040518060400160405290816000820154815260200160018201548152505094505050505061049b565b819250835483036113ac576040518060400160405280878152602001600460008a6001600160a01b03166001600160a01b031681526020019081526020016000205481525094505050505061049b565b83838154811061132457611324611997565b6040516001600160a01b03831660248201526044810182905261064090849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b0319909316929092179091526115f1565b61144560405180606001604052806000815260200160008152602001600081525090565b60025460009081905b808210156114ac57600061146283836115d6565b9050856002828154811061147857611478611997565b9060005260206000209060030201600001541115611498578091506114a6565b6114a38160016119ad565b92505b5061144e565b6000821180156114e957508460026114c5600185611962565b815481106114d5576114d5611997565b906000526020600020906003020160000154145b1561154c5760026114fb600184611962565b8154811061150b5761150b611997565b906000526020600020906003020160405180606001604052908160008201548152602001600182015481526020016002820154815250509350505050919050565b8192506002548303611585576040518060600160405280868152602001611571610c85565b815260015460209091015295945050505050565b6002838154811061150b5761150b611997565b6040516001600160a01b03808516602483015283166044820152606481018290526115d09085906323b872dd60e01b906084016113ea565b50505050565b60006115e56002848418611975565b6107dd908484166119ad565b6000611646826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166116c69092919063ffffffff16565b905080516000148061166757508080602001905181019061166791906119c0565b6106405760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b606482015260840161045a565b60606116d584846000856116dd565b949350505050565b60608247101561173e5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b606482015260840161045a565b600080866001600160a01b0316858760405161175a9190611a06565b60006040518083038185875af1925050503d8060008114611797576040519150601f19603f3d011682016040523d82523d6000602084013e61179c565b606091505b50915091506117ad878383876117b8565b979650505050505050565b60608315611827578251600003611820576001600160a01b0385163b6118205760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015260640161045a565b50816116d5565b6116d5838381511561183c5781518083602001fd5b8060405162461bcd60e51b815260040161045a9190611a22565b60006020828403121561186857600080fd5b5035919050565b80356001600160a01b0381168114610f8257600080fd5b6000806040838503121561189957600080fd5b823591506118a96020840161186f565b90509250929050565b6000806000606084860312156118c757600080fd5b6118d08461186f565b95602085013595506040909401359392505050565b6000602082840312156118f757600080fd5b6107dd8261186f565b6000806040838503121561191357600080fd5b61191c8361186f565b946020939093013593505050565b6000806040838503121561193d57600080fd5b50508035926020909101359150565b634e487b7160e01b600052601160045260246000fd5b8181038181111561049b5761049b61194c565b60008261199257634e487b7160e01b600052601260045260246000fd5b500490565b634e487b7160e01b600052603260045260246000fd5b8082018082111561049b5761049b61194c565b6000602082840312156119d257600080fd5b815180151581146107dd57600080fd5b60005b838110156119fd5781810151838201526020016119e5565b50506000910152565b60008251611a188184602087016119e2565b9190910192915050565b6020815260008251806020840152611a418160408501602087016119e2565b601f01601f1916919091016040019291505056fea2646970667358221220f279833a32bdf91ebd93aa92f4af20ace3abcf7ecd2f5706ce11f04f66b8763164736f6c63430008110033000000000000000000000000d95b589ac4ddb36fa33399b4aa0834d22ce749e3

Deployed ByteCode

0x608060405234801561001057600080fd5b50600436106101585760003560e01c8063681c637a116100c357806376992ec61161007c57806376992ec614610346578063817b1cd21461035957806390d92e7614610362578063a694fc3a14610389578063bed3b60c1461039c578063c07473f6146103a657600080fd5b8063681c637a146102d05780636c68c0e1146102e35780636ce0a99f146102f65780636d2beef1146103095780636d4361871461031357806372f702f31461031b57600080fd5b8063363487bc11610115578063363487bc1461022c578063379607f51461023457806349fc9df714610247578063584b62a1146102705780636198e339146102b5578063671b3793146102c857600080fd5b8063011de7aa1461015d578063074bc01d1461018357806308bbb8241461018b57806308d465e6146101a057806309fe7dd8146101ce57806324d63ba314610203575b600080fd5b61017061016b366004611856565b6103c6565b6040519081526020015b60405180910390f35b600254610170565b61019e610199366004611886565b6104a1565b005b6101b36101ae3660046118b2565b610645565b6040805182518152602092830151928101929092520161017a565b6101e16101dc366004611856565b6107e4565b604080518251815260208084015190820152918101519082015260600161017a565b6101706102113660046118e5565b6001600160a01b031660009081526005602052604090205490565b610170610859565b61019e610242366004611856565b610869565b6101706102553660046118e5565b6001600160a01b031660009081526003602052604090205490565b61028361027e366004611900565b610ab6565b604080516001600160a01b0390961686526020860194909452928401919091526060830152608082015260a00161017a565b61019e6102c3366004611856565b610b0e565b610170610c85565b6101e16102de36600461192a565b610cb4565b61019e6102f1366004611856565b610e45565b6101b3610304366004611900565b610e52565b6101706201518081565b610170610ec5565b60005461032e906001600160a01b031681565b6040516001600160a01b03909116815260200161017a565b6101706103543660046118e5565b610f0d565b61017060015481565b6101707f00000000000000000000000000000000000000000000000000000000681286e981565b610170610397366004611856565b610f87565b61017062278d0081565b6101706103b43660046118e5565b60046020526000908152604090205481565b60007f00000000000000000000000000000000000000000000000000000000681286e98210156104635760405162461bcd60e51b815260206004820152603760248201527f5374616b696e673a205265717565737465642074696d65206973206265666f7260448201527f6520636f6e747261637420776173206465706c6f79656400000000000000000060648201526084015b60405180910390fd5b620151806104917f00000000000000000000000000000000000000000000000000000000681286e984611962565b61049b9190611975565b92915050565b3360009081526003602052604081208054849081106104c2576104c2611997565b9060005260206000209060050201905080600301546000146105265760405162461bcd60e51b815260206004820152601760248201527f5374616b696e673a205374616b6520756e6c6f636b6564000000000000000000604482015260640161045a565b6001600160a01b0382166105885760405162461bcd60e51b8152602060048201526024808201527f5374616b696e673a2043616e27742064656c656761746520746f2030206164646044820152637265737360e01b606482015260840161045a565b80546001600160a01b038381169116146106405780546105b0906001600160a01b03166110e6565b6105b9826110e6565b805460018201546105d5916001600160a01b03169084906111d7565b805460018201546040805186815260208101929092526001600160a01b0385811693169133917f086d57859b1d11780b2ef086bf84cef0e295c4cec8900b8e1620c6666b667542910160405180910390a480546001600160a01b0319166001600160a01b0383161781555b505050565b6040805180820190915260008082526020820152610661610859565b8311156106b05760405162461bcd60e51b815260206004820152601f60248201527f5374616b696e673a20496e74657276616c206f7574206f6620626f756e647300604482015260640161045a565b6001600160a01b03841660009081526005602052604090208054831180159061070d575082158061070d575083816106e9600186611962565b815481106106f9576106f9611997565b906000526020600020906002020160000154105b80156107465750805483148061074657508381848154811061073157610731611997565b90600052602060002090600202016000015410155b156107cf57805483101561079b5780838154811061076657610766611997565b9060005260206000209060020201604051806040016040529081600082015481526020016001820154815250509150506107dd565b50506040805180820182528381526001600160a01b03851660009081526004602090815292902054918101919091526107dd565b6107d98585611236565b9150505b9392505050565b61080860405180606001604052806000815260200160008152602001600081525090565b6002828154811061081b5761081b611997565b906000526020600020906003020160405180606001604052908160008201548152602001600182015481526020016002820154815250509050919050565b6000610864426103c6565b905090565b33600090815260036020526040902080548290811061088a5761088a611997565b9060005260206000209060050201600301546000141580156108df57503360009081526003602052604090208054429190839081106108cb576108cb611997565b906000526020600020906005020160030154105b61092b5760405162461bcd60e51b815260206004820152601b60248201527f5374616b696e673a205374616b65206e6f7420756e6c6f636b65640000000000604482015260640161045a565b33600090815260036020526040902080548290811061094c5761094c611997565b9060005260206000209060050201600401546000146109ad5760405162461bcd60e51b815260206004820152601e60248201527f5374616b696e673a205374616b6520616c726561647920636c61696d65640000604482015260640161045a565b6109b6336110e6565b3360009081526003602052604090208054429190839081106109da576109da611997565b6000918252602080832060046005909302019190910192909255338152600390915260409020805482908110610a1257610a12611997565b90600052602060002090600502016001015460016000828254610a359190611962565b90915550503360008181526003602052604090208054610a8692919084908110610a6157610a61611997565b6000918252602082206001600590920201015490546001600160a01b031691906113be565b604051819033907f47cee97cb7acd717b3c0aa1435d004cd5b3c8c57d70dbceb4e4458bbd60e39d490600090a350565b60036020528160005260406000208181548110610ad257600080fd5b6000918252602090912060059091020180546001820154600283015460038401546004909401546001600160a01b039093169550909350919085565b336000908152600360205260409020805482908110610b2f57610b2f611997565b906000526020600020906005020160030154600014610b905760405162461bcd60e51b815260206004820152601f60248201527f5374616b696e673a205374616b6520616c726561647920756e6c6f636b656400604482015260640161045a565b610b99336110e6565b610ba662278d00426119ad565b336000908152600360205260409020805483908110610bc757610bc7611997565b600091825260208083206003600590930201820193909355338252909152604090208054610c55919083908110610c0057610c00611997565b6000918252602080832060059092029091015433835260039091526040822080546001600160a01b03909216929185908110610c3e57610c3e611997565b9060005260206000209060050201600101546111d7565b604051819033907f6381d9813cabeb57471b5a7e05078e64845ccdb563146a6911d536f24ce960f190600090a350565b6000805260046020527f17ef568e3e12ab5b9c7254a8d58478811de00f9e6eb34345acd53bf8fd09d3ec541990565b610cd860405180606001604052806000815260200160008152602001600081525090565b610ce0610859565b831115610d2f5760405162461bcd60e51b815260206004820152601f60248201527f5374616b696e673a20496e74657276616c206f7574206f6620626f756e647300604482015260640161045a565b6002548211801590610d765750811580610d765750826002610d52600185611962565b81548110610d6257610d62611997565b906000526020600020906003020160000154105b8015610db15750600254821480610db157508260028381548110610d9c57610d9c611997565b90600052602060002090600302016000015410155b15610e3c57600254821015610e115760028281548110610dd357610dd3611997565b90600052602060002090600302016040518060600160405290816000820154815260200160018201548152602001600282015481525050905061049b565b6040518060600160405280848152602001610e2a610c85565b8152602001600154815250905061049b565b6107dd83611421565b610e4f81336104a1565b50565b60408051808201909152600080825260208201526001600160a01b0383166000908152600560205260409020805483908110610e9057610e90611997565b906000526020600020906002020160405180604001604052908160008201548152602001600182015481525050905092915050565b60025460009015610f075760028054610ee090600190611962565b81548110610ef057610ef0611997565b906000526020600020906003020160000154905090565b50600090565b6001600160a01b03811660009081526005602052604081205415610f7a576001600160a01b03821660009081526005602052604090208054610f5190600190611962565b81548110610f6157610f61611997565b9060005260206000209060020201600001549050919050565b506000919050565b919050565b6000808211610fd85760405162461bcd60e51b815260206004820152601760248201527f5374616b696e673a20416d6f756e74206e6f7420736574000000000000000000604482015260640161045a565b610fe1336110e6565b3360008181526003602081815260408084208054825160a0810184529687528684018981524293880193845260608801878152608089018881526001808501865594895295882098516005840290990180546001600160a01b0319166001600160a01b03909a16999099178955905188840155925160028801559151938601939093559051600490940193909355805485929061107f9084906119ad565b909155506110919050600033856111d7565b6000546110a9906001600160a01b0316333086611598565b604051838152819033907f5af417134f72a9d41143ace85b0a26dce6f550f894f2cbc1eeee8810603d91b69060200160405180910390a392915050565b60006110f0610859565b9050806110fb610ec5565b1015611156576002604051806060016040528083815260200161111c610c85565b8152600180546020928301528354808201855560009485529382902083516003909502019384559082015190830155604001516002909101555b6001600160a01b0382161580159061117557508061117383610f0d565b105b156111d3576001600160a01b0382166000818152600560209081526040808320815180830183528681529484526004835290832054848301908152815460018181018455928552929093209351600290920290930190815590519101555b5050565b6001600160a01b038316600090815260046020526040812080548392906111ff908490611962565b90915550506001600160a01b0382166000908152600460205260408120805483929061122c9084906119ad565b9091555050505050565b60408051808201909152600080825260208201526001600160a01b0383166000908152600560205260408120805490919081905b808210156112c757600061127e83836115d6565b90508685828154811061129357611293611997565b90600052602060002090600202016000015411156112b3578091506112c1565b6112be8160016119ad565b92505b5061126a565b600082118015611303575085846112df600185611962565b815481106112ef576112ef611997565b906000526020600020906002020160000154145b1561135c5783611314600184611962565b8154811061132457611324611997565b90600052602060002090600202016040518060400160405290816000820154815260200160018201548152505094505050505061049b565b819250835483036113ac576040518060400160405280878152602001600460008a6001600160a01b03166001600160a01b031681526020019081526020016000205481525094505050505061049b565b83838154811061132457611324611997565b6040516001600160a01b03831660248201526044810182905261064090849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b0319909316929092179091526115f1565b61144560405180606001604052806000815260200160008152602001600081525090565b60025460009081905b808210156114ac57600061146283836115d6565b9050856002828154811061147857611478611997565b9060005260206000209060030201600001541115611498578091506114a6565b6114a38160016119ad565b92505b5061144e565b6000821180156114e957508460026114c5600185611962565b815481106114d5576114d5611997565b906000526020600020906003020160000154145b1561154c5760026114fb600184611962565b8154811061150b5761150b611997565b906000526020600020906003020160405180606001604052908160008201548152602001600182015481526020016002820154815250509350505050919050565b8192506002548303611585576040518060600160405280868152602001611571610c85565b815260015460209091015295945050505050565b6002838154811061150b5761150b611997565b6040516001600160a01b03808516602483015283166044820152606481018290526115d09085906323b872dd60e01b906084016113ea565b50505050565b60006115e56002848418611975565b6107dd908484166119ad565b6000611646826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166116c69092919063ffffffff16565b905080516000148061166757508080602001905181019061166791906119c0565b6106405760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b606482015260840161045a565b60606116d584846000856116dd565b949350505050565b60608247101561173e5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b606482015260840161045a565b600080866001600160a01b0316858760405161175a9190611a06565b60006040518083038185875af1925050503d8060008114611797576040519150601f19603f3d011682016040523d82523d6000602084013e61179c565b606091505b50915091506117ad878383876117b8565b979650505050505050565b60608315611827578251600003611820576001600160a01b0385163b6118205760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015260640161045a565b50816116d5565b6116d5838381511561183c5781518083602001fd5b8060405162461bcd60e51b815260040161045a9190611a22565b60006020828403121561186857600080fd5b5035919050565b80356001600160a01b0381168114610f8257600080fd5b6000806040838503121561189957600080fd5b823591506118a96020840161186f565b90509250929050565b6000806000606084860312156118c757600080fd5b6118d08461186f565b95602085013595506040909401359392505050565b6000602082840312156118f757600080fd5b6107dd8261186f565b6000806040838503121561191357600080fd5b61191c8361186f565b946020939093013593505050565b6000806040838503121561193d57600080fd5b50508035926020909101359150565b634e487b7160e01b600052601160045260246000fd5b8181038181111561049b5761049b61194c565b60008261199257634e487b7160e01b600052601260045260246000fd5b500490565b634e487b7160e01b600052603260045260246000fd5b8082018082111561049b5761049b61194c565b6000602082840312156119d257600080fd5b815180151581146107dd57600080fd5b60005b838110156119fd5781810151838201526020016119e5565b50506000910152565b60008251611a188184602087016119e2565b9190910192915050565b6020815260008251806020840152611a418160408501602087016119e2565b601f01601f1916919091016040019291505056fea2646970667358221220f279833a32bdf91ebd93aa92f4af20ace3abcf7ecd2f5706ce11f04f66b8763164736f6c63430008110033