ETH Price: $3,260.63 (-0.54%)
 

Overview

ETH Balance

0 ETH

Eth Value

$0.00

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To
Withdraw Extra T...149981142022-06-20 18:49:52947 days ago1655750992IN
0xF63345F2...A16E03169
0 ETH0.0010722528.06298102
Admin Withdraw R...147700002022-05-13 22:13:34985 days ago1652480014IN
0xF63345F2...A16E03169
0 ETH0.002286342.96676175
Withdraw Tokens146617722022-04-26 18:43:141002 days ago1650998594IN
0xF63345F2...A16E03169
0 ETH0.01296465150
Withdraw Tokens143463522022-03-08 13:02:271052 days ago1646744547IN
0xF63345F2...A16E03169
0 ETH0.01039965150
Withdraw Tokens142369512022-02-19 14:15:451069 days ago1645280145IN
0xF63345F2...A16E03169
0 ETH0.01296465150
Withdraw Tokens142021342022-02-14 4:44:221074 days ago1644813862IN
0xF63345F2...A16E03169
0 ETH0.0025098229.03849122
Withdraw Tokens141819142022-02-11 1:49:201077 days ago1644544160IN
0xF63345F2...A16E03169
0 ETH0.01296465150
Withdraw Tokens141668462022-02-08 17:51:121079 days ago1644342672IN
0xF63345F2...A16E03169
0 ETH0.01296465150
Withdraw Tokens140415122022-01-20 9:09:101099 days ago1642669750IN
0xF63345F2...A16E03169
0 ETH0.01296465150
Withdraw Tokens140393662022-01-20 0:58:041099 days ago1642640284IN
0xF63345F2...A16E03169
0 ETH0.0069063279.90565067
Withdraw Tokens140107212022-01-15 15:01:001104 days ago1642258860IN
0xF63345F2...A16E03169
0 ETH0.01039965150
Withdraw Tokens139798322022-01-10 20:13:271108 days ago1641845607IN
0xF63345F2...A16E03169
0 ETH0.01039965150
Withdraw Tokens139759882022-01-10 5:50:151109 days ago1641793815IN
0xF63345F2...A16E03169
0 ETH0.01296465150
Withdraw Tokens139759772022-01-10 5:47:561109 days ago1641793676IN
0xF63345F2...A16E03169
0 ETH0.01296465150
Withdraw Tokens139730082022-01-09 18:36:371109 days ago1641753397IN
0xF63345F2...A16E03169
0 ETH0.01296465150
Withdraw Tokens139715732022-01-09 13:18:531110 days ago1641734333IN
0xF63345F2...A16E03169
0 ETH0.01296465150
Withdraw Tokens139612582022-01-07 23:30:031111 days ago1641598203IN
0xF63345F2...A16E03169
0 ETH0.01296465150
Withdraw Tokens139570472022-01-07 7:42:271112 days ago1641541347IN
0xF63345F2...A16E03169
0 ETH0.00700524101.04058024
Withdraw Tokens139546352022-01-06 22:45:371112 days ago1641509137IN
0xF63345F2...A16E03169
0 ETH0.01039965150
Withdraw Tokens139531642022-01-06 17:15:471112 days ago1641489347IN
0xF63345F2...A16E03169
0 ETH0.01039965150
Withdraw Tokens139530432022-01-06 16:49:481112 days ago1641487788IN
0xF63345F2...A16E03169
0 ETH0.01039965150
Withdraw Tokens139529422022-01-06 16:29:061112 days ago1641486546IN
0xF63345F2...A16E03169
0 ETH0.01147303165.48210723
Withdraw Tokens139521162022-01-06 13:38:581113 days ago1641476338IN
0xF63345F2...A16E03169
0 ETH0.0064785593.44378686
Withdraw Tokens139516052022-01-06 11:36:071113 days ago1641468967IN
0xF63345F2...A16E03169
0 ETH0.01039965150
Withdraw Tokens139514672022-01-06 11:05:111113 days ago1641467111IN
0xF63345F2...A16E03169
0 ETH0.01039965150
View all transactions

View more zero value Internal Transactions in Advanced View mode

Advanced mode:
Loading...
Loading

Similar Match Source Code
This contract matches the deployed Bytecode of the Source Code for Contract 0xbD3e0af8...067E5c65D
The constructor portion of the code might be different and could alter the actual behaviour of the contract

Contract Name:
SplytStaking

Compiler Version
v0.8.0+commit.c7dfd78e

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion
File 1 of 8 : SplytStaking.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.0;

import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/utils/math/SafeMath.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "./ABDKMath64x64.sol";

/**
 * @title SplytStaking
 * @dev Enables a user to stake tokens into this smart contract
 */
contract SplytStaking is Ownable {
  using SafeMath for uint256;
  using SafeERC20 for IERC20;

  IERC20 private _token; // The token to be used in this smart contract

  struct Compound {
    uint depositStartBlock;  // Block where users are allowed to start deposits
    uint depositEndBlock;    // Block where deposits are no longer allowed
    uint interestStartBlock; // Block that starts yield gaining
    uint interestEndBlock;   // Block that ends yield gained
    uint startTime;          // Time to start computing compound yield
    uint endTime;            // Time to stop computing compound yield
    uint apyPerSec;          // Interval at which yield compounds, e.g., 31556952 seconds/year, 8600 hours/year
    uint apyPerBlock;        // Reward per block. We assume 15s per block
  }

  struct activeStaker {
    address addr; // Address of active staker
    uint balance; // Balance of the staker
  }

  Compound private compound;                // Struct to hold compound information
  uint constant secondsPerYear = 31556952;  // Seconds in a year
  uint constant blocksPerMonth = 175200;    // Blocks per month
  uint poolDurationByBlock;                 // How long to yield interest aka max amount of blocks allowed for reward
  uint constant secondPerBlock = 15;        // Number of seconds between blocks mined
  uint feeDivisor = 10**3;                  // Withdrawal fee (0.1%)

  uint totalPrincipal;                     // Total amount of token principal deposited into this smart contract
  uint numUsersWithDeposits;               // Total number of users who have deposited tokens into this smart contract
  uint numUniqueUsers;                     // Total number of unique users who have called stakeTokens() so far

  uint secretBonusLimit;                   // If secretBonusLimit reached, provide bonus to long term holders
  uint secretBonusPool;                    // Pool amount to be distributed

  mapping (address => uint256) public _balances;       // Balance of tokens by user
  mapping (uint256 => address) public addressByIndex;  // Address by index

  /**
   * @dev Emitted when `_amount` tokens are staked by `_userAddress`
   */
  event TokenStaked(address _userAddress, uint256 _amount);

  /**
   * @dev Emitted when `_amount` tokens are withdrawn by `_userAddress`
   */
  event TokenWithdrawn(address _userAddress, uint256 _amount);

  /**
   * @dev Creates the SplytStaking smart contract
   * @param token address of the token to be vested
   * @param _apyPerSec APY gained per second ratio
   * @param _depositStartBlock Block where deposits start
   * @param _depositEndBlock Block where deposits end
   */
  constructor (
    address token,
    uint _apyPerSec,
    uint _depositStartBlock,
    uint _depositEndBlock,
    uint _poolDurationByBlock,
    uint _secretBonusLimit,
    uint _secretBonusPool
  ) public {
    _token = IERC20(token);

    // Set how long the pool will yield interest
    poolDurationByBlock = _poolDurationByBlock;

    // set bonus pool params
    secretBonusLimit = _secretBonusLimit;
    secretBonusPool = _secretBonusPool;

    // Compute start and end blocks for yield compounding
    uint interestStartBlock = _depositEndBlock.add(1);
    uint interestEndBlock = interestStartBlock.add(poolDurationByBlock);

    // Compute start and end times for the same time period
    uint blocksUntilInterestStarts = interestStartBlock.sub(block.number);
    uint interestStartTime = block.timestamp.add(blocksUntilInterestStarts.mul(secondPerBlock));
    uint blocksUntilInterestEnd = interestEndBlock.sub(interestStartBlock);
    uint interestEndTime = block.timestamp.add(blocksUntilInterestEnd.mul(secondPerBlock));

    compound = Compound({
      depositStartBlock: _depositStartBlock,
      depositEndBlock: _depositEndBlock,
      interestStartBlock: interestStartBlock,
      interestEndBlock: interestEndBlock,
      startTime: interestStartTime,
      endTime: interestEndTime,
      apyPerSec: _apyPerSec,
      apyPerBlock: _apyPerSec.mul(secondPerBlock)
    });

    numUsersWithDeposits = 0;
    totalPrincipal = 0;
    numUniqueUsers = 0;
    _balances[address(this)] = 0;
  }

  // -----------------------------------------------------------------------
  // Modifiers
  // -----------------------------------------------------------------------

  /**
   * @dev Modifier that only lets the function continue if it is within the deposit window (depositStartBlock, depositEndBlock)
   */
  modifier depositWindow() {
    require (block.number > compound.depositStartBlock && block.number <= compound.depositEndBlock, "DepositWindow: Can be called only during deposit window");
    _;
  }

  /**
   * @dev Modifier that only lets the function continue if the current block is before compound.interestStartBlock
   */
  modifier hasNotStartedYielding() {
    require (block.number < compound.interestStartBlock, "HasNotStartedYielding: Can be called only before interest start block");
    _;
  }

  // -----------------------------------------------------------------------
  // Helpers
  // -----------------------------------------------------------------------

  /**
   * @dev Check that the amount of blocks staked does not exceed limit: poolBlockDuration=maxBlock.
   * @dev If a user keeps their tokens longer than maxBlock, they only get yield up to maxBlock.
   * @param numBlocksPassed Amount of blocks passed
   * @param maxBlock Highest amount of blocks allowed to pass (limit)
   */
  function _blocksStaked(uint numBlocksPassed, uint maxBlock) public pure returns (uint) {
    if(numBlocksPassed >= maxBlock) {
      return maxBlock;
    } else {
      return numBlocksPassed;
    }
  }

  // -----------------------------------------------------------------------
  // COMPUTATIONS
  // -----------------------------------------------------------------------

  /**
   * @dev Estimates the power computation
   * @param x base
   * @param n duration
   */
  function pow (int128 x, uint n) public pure returns (int128 r) {
    r = ABDKMath64x64.fromUInt (1);  while (n > 0) {
    if (n % 2 == 1) {
      r = ABDKMath64x64.mul (r, x);
      n -= 1;
    } else {
      x = ABDKMath64x64.mul (x, x);
      n /= 2;
    }
  }
  }

  /**
   * @dev Method to compute APY gained. Note: this is only used for comparison, not actually used to compute real gain
   * @param principal Principal provided
   * @param ratio Amount of APY gained per second
   * @param n Duration
   */
  function compoundInterestByTime(uint principal, uint ratio, uint n) public pure returns (uint) {
    return ABDKMath64x64.mulu (
      pow (
        ABDKMath64x64.add (ABDKMath64x64.fromUInt (1), ABDKMath64x64.divu (ratio, 10**18)),
        n),
      principal);
  }

  /**
   * @dev Wrapper method that is bound to the smart contract apyPerSec variable
   * @dev Enables durations to be set manually
   * @dev Not used to compute real gain
   * @param principal Principal provided
   * @param duration Duration
   * @return the amount gained: principal + yield
   */
  function compoundWithPrincipalAndTime(uint principal, uint duration) external view returns (uint) {
    return compoundInterestByTime(principal, compound.apyPerSec, duration);
  }

  /**
   * @dev Wrapper method that is bound to the smart contract apyPerSec and computes duration against live blockchain data
   * @dev Not used to compute real gain
   * @param principal Principal provided
   * @return the amount gained: principal + yield
   */
  function compoundWithPrincipal(uint principal) public view returns (uint) {
    uint duration = block.timestamp - compound.startTime;
    return compoundInterestByTime(principal, compound.apyPerSec, duration);
  }

  /**
   * @dev Wrapper method that computes gain using the callers information
   * @dev Uses all predefined variables in the smart contract and blockchain state
   * @dev Not used to compute real gain
   * @return the amount gained: principal + yield
   */
  function compoundWithPrincipalByUser() external view returns (uint) {
    return compoundWithPrincipal(_balances[msg.sender]);
  }

  /**
   * @dev Raw method that computes gain using blocks instead of time
   * @param principal Principal provided
   * @param blocksStaked Number of blocks with which to compute gain
   * @return the amount gained: principal + yield
   */
  function _compoundInterestByBlock(uint principal, uint blocksStaked) public view returns (uint) {
    uint reward = SafeMath.div(compound.apyPerBlock.mul(principal).mul(blocksStaked), 10**18);
    return reward.add(principal);
  }

  /**
   * @dev Computes yield gained using block raw function
   * @dev Makes sure that a user cannot gain more yield than poolBlockDuration as defined in the smart contract
   * @param principal Principal
   * @return the amount gained: principal + yield
   */
  function compoundInterestByBlock(uint principal) public view returns (uint) {
    uint numBlocksPassed = block.number.sub(compound.interestStartBlock);
    uint blocksStaked = _blocksStaked(numBlocksPassed, poolDurationByBlock);
    return _compoundInterestByBlock(principal, blocksStaked);
  }

  // -----------------------------------------------------------------------
  // GETTERS
  // -----------------------------------------------------------------------

  /**
   * @dev Gets block and time information out of the smart contract
   * @return _currentBlock Current block on the blockchain
   * @return _depositStartBlock Block where deposits are allowed
   * @return _depositEndBlock Block where deposits are no longer allowed
   * @return _interestStartBlock Block where yield starts growing
   * @return _interestEndBlock Block where yield stops growing
   * @return _interestStartTime Estimated yield start time (for comparison only)
   * @return _interestEndTime Estimated yield end time (for comparison only)
   * @return _interestApyPerSec APY per second rate defined in the smart contract
   * @return _interestApyPerBlock APY per block defined in the smart contract
   */
  function getCompoundInfo() external view returns (
    uint _currentBlock,
    uint _depositStartBlock,
    uint _depositEndBlock,
    uint _interestStartBlock,
    uint _interestEndBlock,
    uint _interestStartTime,
    uint _interestEndTime,
    uint _interestApyPerSec,
    uint _interestApyPerBlock
  ) {
    return (
    block.number,
    compound.depositStartBlock,
    compound.depositEndBlock,
    compound.interestStartBlock,
    compound.interestEndBlock,
    compound.startTime,
    compound.endTime,
    compound.apyPerSec,
    compound.apyPerBlock
    );
  }

  /**
 * @dev Gets info about secret pool. :P
 * @return _secretBonusLimit Number of wallets who need to stake to unlock the secretBonusPool
 * @return _secretBonusPool Total pool that will be divided by all users who stay for the entire duration (see withdrawTokens fn)
 * @return _bonusUnlockable Bool is true if number of users who stake is over  _secretBonusLimit
 * @return _bonusUnlocked Bool controls if the bonus is going to be applied (see withdrawTokens fn)
 */
  function getSecretPoolInfo() public view returns (uint _secretBonusLimit, uint _secretBonusPool, bool _bonusUnlockable, bool _bonusUnlocked) {
    return (
      secretBonusLimit,
      secretBonusPool,
      numUniqueUsers > secretBonusLimit,
      block.number >= compound.interestEndBlock && numUniqueUsers > secretBonusLimit
    );
  }

  /**
   * @dev Gets staking data from this smart contract
   * @return _totalPrincipal Total amount of tokens deposited as principal
   * @return _numUsersWithDeposits Number of users who have staked into this smart contract
   */
  function getAdminStakingInfo() public view returns (uint _totalPrincipal, uint _numUsersWithDeposits) {
    return (totalPrincipal, numUsersWithDeposits);
  }

  /**
   * @dev Gets user balance data
   * @dev If this is called before any yield is gained, we manually display 0 reward
   * @param userAddress Address of a given user
   * @return _principal Principal that a user has staked
   * @return _reward Current estimated reward earned
   * @return _balance Total balance (_principal + _reward)
   */
  function getUserBalances(address userAddress) external view returns (uint _principal, uint _reward, uint _balance) {
    if(block.number <= compound.interestStartBlock) {
      return (
      _balances[userAddress],
      0,
      _balances[userAddress]);
    } else {
      uint totalBalance = compoundInterestByBlock(_balances[userAddress]);
      uint reward = totalBalance.sub(_balances[userAddress]);
      return (
      _balances[userAddress],
      reward,
      totalBalance
      );
    }
  }

  /**
   * @dev Get list of active stakers and balances
   * @return {{addr, balance},...} as an array
   */
//  function getActiveStakers() public view returns (activeStaker[] memory) {
//    // Array of structs for active stakers
//    activeStaker[] memory activeStakers = new activeStaker[](numUsersWithDeposits);
//    uint i = 0; // index for activeStakers[]
//    uint j = 0; // index for addressByIndex[]
//    for (; i < numUsersWithDeposits ; j++) {
//      // If balances is zero, consider the address as an inactive staker
//      if (_balances[addressByIndex[j]] != 0) {
//        activeStakers[i].addr = addressByIndex[j];
//        activeStakers[i].balance = _balances[addressByIndex[j]];
//        i++;
//      }
//    }
//    return (activeStakers);
//  }

  /**
   * @dev Reads the APY defined in the smart contract as a percentage
   * @return _apy APY in percentage form
   */
  function apy() external view returns (uint _apy) {
    return secondsPerYear * compound.apyPerSec * 100;
  }

  // -----------------------------------------------------------------------
  // SETTERS
  // -----------------------------------------------------------------------

  /**
   * @dev Enables the deposit window to be changed. Only the smart contract owner is allowed to do this
   * @dev Because blocks are not always found at the same rate, we may need to change the deposit window so events start on time
   * @dev We will only call this so the start time is as accurate as possible
   * @dev We have to recompute the yield start block and yield end block times as well
   * @param _depositStartBlock New deposit start block
   * @param _depositEndBlock New deposit end block
   */
  function changeDepositWindow(uint _depositStartBlock, uint _depositEndBlock) external onlyOwner {
    compound.depositStartBlock = _depositStartBlock;
    compound.depositEndBlock = _depositEndBlock;
    compound.interestStartBlock = _depositEndBlock.add(1);
    compound.interestEndBlock = compound.interestStartBlock.add(poolDurationByBlock);

    uint blocksUntilInterestStarts = compound.interestStartBlock.sub(block.number);
    compound.startTime = block.timestamp.add(blocksUntilInterestStarts.mul(secondPerBlock));

    uint blocksUntilInterestEnd = compound.interestEndBlock.sub(compound.interestStartBlock);
    compound.endTime = block.timestamp.add(blocksUntilInterestEnd.mul(secondPerBlock));
  }

    /**
   * @dev Change the APY of the contract. Only the smart contract owner is allowed to do this
   * @dev The method should only be callable by the owner AND only if the current block is before compound.interestStartBlock
   * @param _newApyRate New APY 
   */

  function changeAPY(uint _newApyRate) external onlyOwner hasNotStartedYielding {    
    compound.apyPerSec = _newApyRate;
    compound.apyPerBlock = _newApyRate.mul(secondPerBlock);
  }

  /**
   * @dev Enables a user to deposit their stake into this smart contract. A user must call approve tokens before calling this method
   * @dev This can only be called during the deposit window. Calling this before or after will fail
   * @dev We also make sure to track the state of [totalPrincipal, numUsersWithDeposits]
   * @param _amount The amount of tokens to stake into this smart contract
   */
  function stakeTokens(uint _amount) external depositWindow {
    require(_token.allowance(msg.sender, address(this)) >= _amount, "TokenBalance: User has not allowed tokens to be used");
    require(_token.balanceOf(msg.sender) >= _amount, "TokenBalance: msg.sender can not stake more than they have");

    if(_balances[msg.sender] == 0) {
      numUsersWithDeposits++;
      numUniqueUsers++;
//      addressByIndex[numUniqueUsers++] = msg.sender;
    }

    _balances[msg.sender] += _amount;
    totalPrincipal += _amount;

    require(_token.transferFrom(msg.sender, address(this), _amount), "TokenTransfer: failed to transfer tokens from msg.sender here");
    emit TokenStaked(msg.sender, _amount);
  }


  /**
   * @dev Lets a user withdraw all their tokens from this smart contract
   * @dev A fee is charged on all withdrawals
   * @dev We make sure to track the state of [totalPrincipal, numUsersWithDeposits]
   */
  function withdrawTokens() external {
    require(_balances[msg.sender] > 0, "TokenBalance: no tokens available to be withdrawn");

    uint totalBalance = 0;

    if(block.number <= compound.depositEndBlock) {
      totalBalance = _balances[msg.sender];
    } else {
      totalBalance = compoundInterestByBlock(_balances[msg.sender]);
    }
    uint fee = totalBalance.div(feeDivisor);
    totalBalance = totalBalance.sub(fee);

    if(block.number >= compound.interestEndBlock && numUniqueUsers > secretBonusLimit) {
      totalBalance += secretBonusPool.div(numUniqueUsers);
    }

    totalPrincipal -= _balances[msg.sender];
    _balances[msg.sender] = 0;
    numUsersWithDeposits -= 1;

    require(_token.transfer(msg.sender, totalBalance));
    emit TokenWithdrawn(msg.sender, totalBalance);
  }

  /**
   * @dev Computes the amount of tokens the owner is allowed to withdraw
   * @dev Assumes owner deposited tokens at the end of the deposit window, and not all users stay for the full 30 days
   * @dev There will be a remainder because users leave before the 30 days is over. Owner withdraws the balance
   */
  function adminWithdrawRemaining() external onlyOwner {
    uint totalBalanceNeeded = compoundInterestByBlock(totalPrincipal);
    uint contractBalance = _token.balanceOf(address(this));

    // We deposit tokens and assume everyone gains yield for the full 30 days
    // There is a difference because some users will withdraw tokens before the 30 days is over
    if(contractBalance > totalBalanceNeeded) {
      uint extraTokenBalance = contractBalance.sub(totalBalanceNeeded);
      require(_token.transfer(msg.sender, extraTokenBalance));
      emit TokenWithdrawn(msg.sender, extraTokenBalance);
    }
  }

  /**
   * @dev Lets owner, and only the owner, withdraw any amount of tokens
   * @dev ONLY TO BE CALLED IN A CATASTROPHIC SCENARIO!!!
   * @param _amount Number of tokens to withdraw
   */
  function withdrawExtraTokens(uint _amount) external onlyOwner {
    require(_token.transfer(msg.sender, _amount));
    emit TokenWithdrawn(msg.sender, _amount);
  }
}

File 2 of 8 : SafeERC20.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "../IERC20.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;

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

    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));
    }

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

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

    /**
     * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
     * on the return value: the return value is optional (but if data is returned, it must not be false).
     * @param token The token targeted by the call.
     * @param data The call data (encoded using abi.encode or one of its variants).
     */
    function _callOptionalReturn(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");
        if (returndata.length > 0) {
            // Return data is optional
            require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
        }
    }
}

File 3 of 8 : IERC20.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

File 4 of 8 : SafeMath.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

File 5 of 8 : Ownable.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "../utils/Context.sol";

/**
 * @dev Contract module which provides a basic access control mechanism, where
 * there is an account (an owner) that can be granted exclusive access to
 * specific functions.
 *
 * By default, the owner account will be the one that deploys the contract. This
 * can later be changed with {transferOwnership}.
 *
 * This module is used through inheritance. It will make available the modifier
 * `onlyOwner`, which can be applied to your functions to restrict their use to
 * the owner.
 */
abstract contract Ownable is Context {
    address private _owner;

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

    /**
     * @dev Initializes the contract setting the deployer as the initial owner.
     */
    constructor() {
        _setOwner(_msgSender());
    }

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

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

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

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

    function _setOwner(address newOwner) private {
        address oldOwner = _owner;
        _owner = newOwner;
        emit OwnershipTransferred(oldOwner, newOwner);
    }
}

File 6 of 8 : ABDKMath64x64.sol
// SPDX-License-Identifier: BSD-4-Clause
/*
 * ABDK Math 64.64 Smart Contract Library.  Copyright © 2019 by ABDK Consulting.
 * Author: Mikhail Vladimirov <[email protected]>
 */
pragma solidity ^0.8.0;

/**
 * Smart contract library of mathematical functions operating with signed
 * 64.64-bit fixed point numbers.  Signed 64.64-bit fixed point number is
 * basically a simple fraction whose numerator is signed 128-bit integer and
 * denominator is 2^64.  As long as denominator is always the same, there is no
 * need to store it, thus in Solidity signed 64.64-bit fixed point numbers are
 * represented by int128 type holding only the numerator.
 */
library ABDKMath64x64 {
    /*
     * Minimum value signed 64.64-bit fixed point number may have.
     */
    int128 private constant MIN_64x64 = -0x80000000000000000000000000000000;

    /*
     * Maximum value signed 64.64-bit fixed point number may have.
     */
    int128 private constant MAX_64x64 = 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF;

    /**
     * Convert signed 256-bit integer number into signed 64.64-bit fixed point
     * number.  Revert on overflow.
     *
     * @param x signed 256-bit integer number
     * @return signed 64.64-bit fixed point number
     */
    function fromInt (int256 x) internal pure returns (int128) {
    unchecked {
        require (x >= -0x8000000000000000 && x <= 0x7FFFFFFFFFFFFFFF);
        return int128 (x << 64);
    }
    }

    /**
     * Convert signed 64.64 fixed point number into signed 64-bit integer number
     * rounding down.
     *
     * @param x signed 64.64-bit fixed point number
     * @return signed 64-bit integer number
     */
    function toInt (int128 x) internal pure returns (int64) {
    unchecked {
        return int64 (x >> 64);
    }
    }

    /**
     * Convert unsigned 256-bit integer number into signed 64.64-bit fixed point
     * number.  Revert on overflow.
     *
     * @param x unsigned 256-bit integer number
     * @return signed 64.64-bit fixed point number
     */
    function fromUInt (uint256 x) internal pure returns (int128) {
    unchecked {
        require (x <= 0x7FFFFFFFFFFFFFFF);
        return int128 (int256 (x << 64));
    }
    }

    /**
     * Convert signed 64.64 fixed point number into unsigned 64-bit integer
     * number rounding down.  Revert on underflow.
     *
     * @param x signed 64.64-bit fixed point number
     * @return unsigned 64-bit integer number
     */
    function toUInt (int128 x) internal pure returns (uint64) {
    unchecked {
        require (x >= 0);
        return uint64 (uint128 (x >> 64));
    }
    }

    /**
     * Convert signed 128.128 fixed point number into signed 64.64-bit fixed point
     * number rounding down.  Revert on overflow.
     *
     * @param x signed 128.128-bin fixed point number
     * @return signed 64.64-bit fixed point number
     */
    function from128x128 (int256 x) internal pure returns (int128) {
    unchecked {
        int256 result = x >> 64;
        require (result >= MIN_64x64 && result <= MAX_64x64);
        return int128 (result);
    }
    }

    /**
     * Convert signed 64.64 fixed point number into signed 128.128 fixed point
     * number.
     *
     * @param x signed 64.64-bit fixed point number
     * @return signed 128.128 fixed point number
     */
    function to128x128 (int128 x) internal pure returns (int256) {
    unchecked {
        return int256 (x) << 64;
    }
    }

    /**
     * Calculate x + y.  Revert on overflow.
     *
     * @param x signed 64.64-bit fixed point number
     * @param y signed 64.64-bit fixed point number
     * @return signed 64.64-bit fixed point number
     */
    function add (int128 x, int128 y) internal pure returns (int128) {
    unchecked {
        int256 result = int256(x) + y;
        require (result >= MIN_64x64 && result <= MAX_64x64);
        return int128 (result);
    }
    }

    /**
     * Calculate x - y.  Revert on overflow.
     *
     * @param x signed 64.64-bit fixed point number
     * @param y signed 64.64-bit fixed point number
     * @return signed 64.64-bit fixed point number
     */
    function sub (int128 x, int128 y) internal pure returns (int128) {
    unchecked {
        int256 result = int256(x) - y;
        require (result >= MIN_64x64 && result <= MAX_64x64);
        return int128 (result);
    }
    }

    /**
     * Calculate x * y rounding down.  Revert on overflow.
     *
     * @param x signed 64.64-bit fixed point number
     * @param y signed 64.64-bit fixed point number
     * @return signed 64.64-bit fixed point number
     */
    function mul (int128 x, int128 y) internal pure returns (int128) {
    unchecked {
        int256 result = int256(x) * y >> 64;
        require (result >= MIN_64x64 && result <= MAX_64x64);
        return int128 (result);
    }
    }

    /**
     * Calculate x * y rounding towards zero, where x is signed 64.64 fixed point
     * number and y is signed 256-bit integer number.  Revert on overflow.
     *
     * @param x signed 64.64 fixed point number
     * @param y signed 256-bit integer number
     * @return signed 256-bit integer number
     */
    function muli (int128 x, int256 y) internal pure returns (int256) {
    unchecked {
        if (x == MIN_64x64) {
            require (y >= -0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF &&
            y <= 0x1000000000000000000000000000000000000000000000000);
            return -y << 63;
        } else {
            bool negativeResult = false;
            if (x < 0) {
                x = -x;
                negativeResult = true;
            }
            if (y < 0) {
                y = -y; // We rely on overflow behavior here
                negativeResult = !negativeResult;
            }
            uint256 absoluteResult = mulu (x, uint256 (y));
            if (negativeResult) {
                require (absoluteResult <=
                    0x8000000000000000000000000000000000000000000000000000000000000000);
                return -int256 (absoluteResult); // We rely on overflow behavior here
            } else {
                require (absoluteResult <=
                    0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);
                return int256 (absoluteResult);
            }
        }
    }
    }

    /**
     * Calculate x * y rounding down, where x is signed 64.64 fixed point number
     * and y is unsigned 256-bit integer number.  Revert on overflow.
     *
     * @param x signed 64.64 fixed point number
     * @param y unsigned 256-bit integer number
     * @return unsigned 256-bit integer number
     */
    function mulu (int128 x, uint256 y) internal pure returns (uint256) {
    unchecked {
        if (y == 0) return 0;

        require (x >= 0);

        uint256 lo = (uint256 (int256 (x)) * (y & 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF)) >> 64;
        uint256 hi = uint256 (int256 (x)) * (y >> 128);

        require (hi <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);
        hi <<= 64;

        require (hi <=
            0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF - lo);
        return hi + lo;
    }
    }

    /**
     * Calculate x / y rounding towards zero.  Revert on overflow or when y is
     * zero.
     *
     * @param x signed 64.64-bit fixed point number
     * @param y signed 64.64-bit fixed point number
     * @return signed 64.64-bit fixed point number
     */
    function div (int128 x, int128 y) internal pure returns (int128) {
    unchecked {
        require (y != 0);
        int256 result = (int256 (x) << 64) / y;
        require (result >= MIN_64x64 && result <= MAX_64x64);
        return int128 (result);
    }
    }

    /**
     * Calculate x / y rounding towards zero, where x and y are signed 256-bit
     * integer numbers.  Revert on overflow or when y is zero.
     *
     * @param x signed 256-bit integer number
     * @param y signed 256-bit integer number
     * @return signed 64.64-bit fixed point number
     */
    function divi (int256 x, int256 y) internal pure returns (int128) {
    unchecked {
        require (y != 0);

        bool negativeResult = false;
        if (x < 0) {
            x = -x; // We rely on overflow behavior here
            negativeResult = true;
        }
        if (y < 0) {
            y = -y; // We rely on overflow behavior here
            negativeResult = !negativeResult;
        }
        uint128 absoluteResult = divuu (uint256 (x), uint256 (y));
        if (negativeResult) {
            require (absoluteResult <= 0x80000000000000000000000000000000);
            return -int128 (absoluteResult); // We rely on overflow behavior here
        } else {
            require (absoluteResult <= 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);
            return int128 (absoluteResult); // We rely on overflow behavior here
        }
    }
    }

    /**
     * Calculate x / y rounding towards zero, where x and y are unsigned 256-bit
     * integer numbers.  Revert on overflow or when y is zero.
     *
     * @param x unsigned 256-bit integer number
     * @param y unsigned 256-bit integer number
     * @return signed 64.64-bit fixed point number
     */
    function divu (uint256 x, uint256 y) internal pure returns (int128) {
    unchecked {
        require (y != 0);
        uint128 result = divuu (x, y);
        require (result <= uint128 (MAX_64x64));
        return int128 (result);
    }
    }

    /**
     * Calculate -x.  Revert on overflow.
     *
     * @param x signed 64.64-bit fixed point number
     * @return signed 64.64-bit fixed point number
     */
    function neg (int128 x) internal pure returns (int128) {
    unchecked {
        require (x != MIN_64x64);
        return -x;
    }
    }

    /**
     * Calculate |x|.  Revert on overflow.
     *
     * @param x signed 64.64-bit fixed point number
     * @return signed 64.64-bit fixed point number
     */
    function abs (int128 x) internal pure returns (int128) {
    unchecked {
        require (x != MIN_64x64);
        return x < 0 ? -x : x;
    }
    }

    /**
     * Calculate 1 / x rounding towards zero.  Revert on overflow or when x is
     * zero.
     *
     * @param x signed 64.64-bit fixed point number
     * @return signed 64.64-bit fixed point number
     */
    function inv (int128 x) internal pure returns (int128) {
    unchecked {
        require (x != 0);
        int256 result = int256 (0x100000000000000000000000000000000) / x;
        require (result >= MIN_64x64 && result <= MAX_64x64);
        return int128 (result);
    }
    }

    /**
     * Calculate arithmetics average of x and y, i.e. (x + y) / 2 rounding down.
     *
     * @param x signed 64.64-bit fixed point number
     * @param y signed 64.64-bit fixed point number
     * @return signed 64.64-bit fixed point number
     */
    function avg (int128 x, int128 y) internal pure returns (int128) {
    unchecked {
        return int128 ((int256 (x) + int256 (y)) >> 1);
    }
    }

    /**
     * Calculate geometric average of x and y, i.e. sqrt (x * y) rounding down.
     * Revert on overflow or in case x * y is negative.
     *
     * @param x signed 64.64-bit fixed point number
     * @param y signed 64.64-bit fixed point number
     * @return signed 64.64-bit fixed point number
     */
    function gavg (int128 x, int128 y) internal pure returns (int128) {
    unchecked {
        int256 m = int256 (x) * int256 (y);
        require (m >= 0);
        require (m <
            0x4000000000000000000000000000000000000000000000000000000000000000);
        return int128 (sqrtu (uint256 (m)));
    }
    }

    /**
     * Calculate x^y assuming 0^0 is 1, where x is signed 64.64 fixed point number
     * and y is unsigned 256-bit integer number.  Revert on overflow.
     *
     * @param x signed 64.64-bit fixed point number
     * @param y uint256 value
     * @return signed 64.64-bit fixed point number
     */
    function pow (int128 x, uint256 y) internal pure returns (int128) {
    unchecked {
        bool negative = x < 0 && y & 1 == 1;

        uint256 absX = uint128 (x < 0 ? -x : x);
        uint256 absResult;
        absResult = 0x100000000000000000000000000000000;

        if (absX <= 0x10000000000000000) {
            absX <<= 63;
            while (y != 0) {
                if (y & 0x1 != 0) {
                    absResult = absResult * absX >> 127;
                }
                absX = absX * absX >> 127;

                if (y & 0x2 != 0) {
                    absResult = absResult * absX >> 127;
                }
                absX = absX * absX >> 127;

                if (y & 0x4 != 0) {
                    absResult = absResult * absX >> 127;
                }
                absX = absX * absX >> 127;

                if (y & 0x8 != 0) {
                    absResult = absResult * absX >> 127;
                }
                absX = absX * absX >> 127;

                y >>= 4;
            }

            absResult >>= 64;
        } else {
            uint256 absXShift = 63;
            if (absX < 0x1000000000000000000000000) { absX <<= 32; absXShift -= 32; }
            if (absX < 0x10000000000000000000000000000) { absX <<= 16; absXShift -= 16; }
            if (absX < 0x1000000000000000000000000000000) { absX <<= 8; absXShift -= 8; }
            if (absX < 0x10000000000000000000000000000000) { absX <<= 4; absXShift -= 4; }
            if (absX < 0x40000000000000000000000000000000) { absX <<= 2; absXShift -= 2; }
            if (absX < 0x80000000000000000000000000000000) { absX <<= 1; absXShift -= 1; }

            uint256 resultShift = 0;
            while (y != 0) {
                require (absXShift < 64);

                if (y & 0x1 != 0) {
                    absResult = absResult * absX >> 127;
                    resultShift += absXShift;
                    if (absResult > 0x100000000000000000000000000000000) {
                        absResult >>= 1;
                        resultShift += 1;
                    }
                }
                absX = absX * absX >> 127;
                absXShift <<= 1;
                if (absX >= 0x100000000000000000000000000000000) {
                    absX >>= 1;
                    absXShift += 1;
                }

                y >>= 1;
            }

            require (resultShift < 64);
            absResult >>= 64 - resultShift;
        }
        int256 result = negative ? -int256 (absResult) : int256 (absResult);
        require (result >= MIN_64x64 && result <= MAX_64x64);
        return int128 (result);
    }
    }

    /**
     * Calculate sqrt (x) rounding down.  Revert if x < 0.
     *
     * @param x signed 64.64-bit fixed point number
     * @return signed 64.64-bit fixed point number
     */
    function sqrt (int128 x) internal pure returns (int128) {
    unchecked {
        require (x >= 0);
        return int128 (sqrtu (uint256 (int256 (x)) << 64));
    }
    }

    /**
     * Calculate binary logarithm of x.  Revert if x <= 0.
     *
     * @param x signed 64.64-bit fixed point number
     * @return signed 64.64-bit fixed point number
     */
    function log_2 (int128 x) internal pure returns (int128) {
    unchecked {
        require (x > 0);

        int256 msb = 0;
        int256 xc = x;
        if (xc >= 0x10000000000000000) { xc >>= 64; msb += 64; }
        if (xc >= 0x100000000) { xc >>= 32; msb += 32; }
        if (xc >= 0x10000) { xc >>= 16; msb += 16; }
        if (xc >= 0x100) { xc >>= 8; msb += 8; }
        if (xc >= 0x10) { xc >>= 4; msb += 4; }
        if (xc >= 0x4) { xc >>= 2; msb += 2; }
        if (xc >= 0x2) msb += 1;  // No need to shift xc anymore

        int256 result = msb - 64 << 64;
        uint256 ux = uint256 (int256 (x)) << uint256 (127 - msb);
        for (int256 bit = 0x8000000000000000; bit > 0; bit >>= 1) {
            ux *= ux;
            uint256 b = ux >> 255;
            ux >>= 127 + b;
            result += bit * int256 (b);
        }

        return int128 (result);
    }
    }

    /**
     * Calculate natural logarithm of x.  Revert if x <= 0.
     *
     * @param x signed 64.64-bit fixed point number
     * @return signed 64.64-bit fixed point number
     */
    function ln (int128 x) internal pure returns (int128) {
    unchecked {
        require (x > 0);

        return int128 (int256 (
                uint256 (int256 (log_2 (x))) * 0xB17217F7D1CF79ABC9E3B39803F2F6AF >> 128));
    }
    }

    /**
     * Calculate binary exponent of x.  Revert on overflow.
     *
     * @param x signed 64.64-bit fixed point number
     * @return signed 64.64-bit fixed point number
     */
    function exp_2 (int128 x) internal pure returns (int128) {
    unchecked {
        require (x < 0x400000000000000000); // Overflow

        if (x < -0x400000000000000000) return 0; // Underflow

        uint256 result = 0x80000000000000000000000000000000;

        if (x & 0x8000000000000000 > 0)
            result = result * 0x16A09E667F3BCC908B2FB1366EA957D3E >> 128;
        if (x & 0x4000000000000000 > 0)
            result = result * 0x1306FE0A31B7152DE8D5A46305C85EDEC >> 128;
        if (x & 0x2000000000000000 > 0)
            result = result * 0x1172B83C7D517ADCDF7C8C50EB14A791F >> 128;
        if (x & 0x1000000000000000 > 0)
            result = result * 0x10B5586CF9890F6298B92B71842A98363 >> 128;
        if (x & 0x800000000000000 > 0)
            result = result * 0x1059B0D31585743AE7C548EB68CA417FD >> 128;
        if (x & 0x400000000000000 > 0)
            result = result * 0x102C9A3E778060EE6F7CACA4F7A29BDE8 >> 128;
        if (x & 0x200000000000000 > 0)
            result = result * 0x10163DA9FB33356D84A66AE336DCDFA3F >> 128;
        if (x & 0x100000000000000 > 0)
            result = result * 0x100B1AFA5ABCBED6129AB13EC11DC9543 >> 128;
        if (x & 0x80000000000000 > 0)
            result = result * 0x10058C86DA1C09EA1FF19D294CF2F679B >> 128;
        if (x & 0x40000000000000 > 0)
            result = result * 0x1002C605E2E8CEC506D21BFC89A23A00F >> 128;
        if (x & 0x20000000000000 > 0)
            result = result * 0x100162F3904051FA128BCA9C55C31E5DF >> 128;
        if (x & 0x10000000000000 > 0)
            result = result * 0x1000B175EFFDC76BA38E31671CA939725 >> 128;
        if (x & 0x8000000000000 > 0)
            result = result * 0x100058BA01FB9F96D6CACD4B180917C3D >> 128;
        if (x & 0x4000000000000 > 0)
            result = result * 0x10002C5CC37DA9491D0985C348C68E7B3 >> 128;
        if (x & 0x2000000000000 > 0)
            result = result * 0x1000162E525EE054754457D5995292026 >> 128;
        if (x & 0x1000000000000 > 0)
            result = result * 0x10000B17255775C040618BF4A4ADE83FC >> 128;
        if (x & 0x800000000000 > 0)
            result = result * 0x1000058B91B5BC9AE2EED81E9B7D4CFAB >> 128;
        if (x & 0x400000000000 > 0)
            result = result * 0x100002C5C89D5EC6CA4D7C8ACC017B7C9 >> 128;
        if (x & 0x200000000000 > 0)
            result = result * 0x10000162E43F4F831060E02D839A9D16D >> 128;
        if (x & 0x100000000000 > 0)
            result = result * 0x100000B1721BCFC99D9F890EA06911763 >> 128;
        if (x & 0x80000000000 > 0)
            result = result * 0x10000058B90CF1E6D97F9CA14DBCC1628 >> 128;
        if (x & 0x40000000000 > 0)
            result = result * 0x1000002C5C863B73F016468F6BAC5CA2B >> 128;
        if (x & 0x20000000000 > 0)
            result = result * 0x100000162E430E5A18F6119E3C02282A5 >> 128;
        if (x & 0x10000000000 > 0)
            result = result * 0x1000000B1721835514B86E6D96EFD1BFE >> 128;
        if (x & 0x8000000000 > 0)
            result = result * 0x100000058B90C0B48C6BE5DF846C5B2EF >> 128;
        if (x & 0x4000000000 > 0)
            result = result * 0x10000002C5C8601CC6B9E94213C72737A >> 128;
        if (x & 0x2000000000 > 0)
            result = result * 0x1000000162E42FFF037DF38AA2B219F06 >> 128;
        if (x & 0x1000000000 > 0)
            result = result * 0x10000000B17217FBA9C739AA5819F44F9 >> 128;
        if (x & 0x800000000 > 0)
            result = result * 0x1000000058B90BFCDEE5ACD3C1CEDC823 >> 128;
        if (x & 0x400000000 > 0)
            result = result * 0x100000002C5C85FE31F35A6A30DA1BE50 >> 128;
        if (x & 0x200000000 > 0)
            result = result * 0x10000000162E42FF0999CE3541B9FFFCF >> 128;
        if (x & 0x100000000 > 0)
            result = result * 0x100000000B17217F80F4EF5AADDA45554 >> 128;
        if (x & 0x80000000 > 0)
            result = result * 0x10000000058B90BFBF8479BD5A81B51AD >> 128;
        if (x & 0x40000000 > 0)
            result = result * 0x1000000002C5C85FDF84BD62AE30A74CC >> 128;
        if (x & 0x20000000 > 0)
            result = result * 0x100000000162E42FEFB2FED257559BDAA >> 128;
        if (x & 0x10000000 > 0)
            result = result * 0x1000000000B17217F7D5A7716BBA4A9AE >> 128;
        if (x & 0x8000000 > 0)
            result = result * 0x100000000058B90BFBE9DDBAC5E109CCE >> 128;
        if (x & 0x4000000 > 0)
            result = result * 0x10000000002C5C85FDF4B15DE6F17EB0D >> 128;
        if (x & 0x2000000 > 0)
            result = result * 0x1000000000162E42FEFA494F1478FDE05 >> 128;
        if (x & 0x1000000 > 0)
            result = result * 0x10000000000B17217F7D20CF927C8E94C >> 128;
        if (x & 0x800000 > 0)
            result = result * 0x1000000000058B90BFBE8F71CB4E4B33D >> 128;
        if (x & 0x400000 > 0)
            result = result * 0x100000000002C5C85FDF477B662B26945 >> 128;
        if (x & 0x200000 > 0)
            result = result * 0x10000000000162E42FEFA3AE53369388C >> 128;
        if (x & 0x100000 > 0)
            result = result * 0x100000000000B17217F7D1D351A389D40 >> 128;
        if (x & 0x80000 > 0)
            result = result * 0x10000000000058B90BFBE8E8B2D3D4EDE >> 128;
        if (x & 0x40000 > 0)
            result = result * 0x1000000000002C5C85FDF4741BEA6E77E >> 128;
        if (x & 0x20000 > 0)
            result = result * 0x100000000000162E42FEFA39FE95583C2 >> 128;
        if (x & 0x10000 > 0)
            result = result * 0x1000000000000B17217F7D1CFB72B45E1 >> 128;
        if (x & 0x8000 > 0)
            result = result * 0x100000000000058B90BFBE8E7CC35C3F0 >> 128;
        if (x & 0x4000 > 0)
            result = result * 0x10000000000002C5C85FDF473E242EA38 >> 128;
        if (x & 0x2000 > 0)
            result = result * 0x1000000000000162E42FEFA39F02B772C >> 128;
        if (x & 0x1000 > 0)
            result = result * 0x10000000000000B17217F7D1CF7D83C1A >> 128;
        if (x & 0x800 > 0)
            result = result * 0x1000000000000058B90BFBE8E7BDCBE2E >> 128;
        if (x & 0x400 > 0)
            result = result * 0x100000000000002C5C85FDF473DEA871F >> 128;
        if (x & 0x200 > 0)
            result = result * 0x10000000000000162E42FEFA39EF44D91 >> 128;
        if (x & 0x100 > 0)
            result = result * 0x100000000000000B17217F7D1CF79E949 >> 128;
        if (x & 0x80 > 0)
            result = result * 0x10000000000000058B90BFBE8E7BCE544 >> 128;
        if (x & 0x40 > 0)
            result = result * 0x1000000000000002C5C85FDF473DE6ECA >> 128;
        if (x & 0x20 > 0)
            result = result * 0x100000000000000162E42FEFA39EF366F >> 128;
        if (x & 0x10 > 0)
            result = result * 0x1000000000000000B17217F7D1CF79AFA >> 128;
        if (x & 0x8 > 0)
            result = result * 0x100000000000000058B90BFBE8E7BCD6D >> 128;
        if (x & 0x4 > 0)
            result = result * 0x10000000000000002C5C85FDF473DE6B2 >> 128;
        if (x & 0x2 > 0)
            result = result * 0x1000000000000000162E42FEFA39EF358 >> 128;
        if (x & 0x1 > 0)
            result = result * 0x10000000000000000B17217F7D1CF79AB >> 128;

        result >>= uint256 (int256 (63 - (x >> 64)));
        require (result <= uint256 (int256 (MAX_64x64)));

        return int128 (int256 (result));
    }
    }

    /**
     * Calculate natural exponent of x.  Revert on overflow.
     *
     * @param x signed 64.64-bit fixed point number
     * @return signed 64.64-bit fixed point number
     */
    function exp (int128 x) internal pure returns (int128) {
    unchecked {
        require (x < 0x400000000000000000); // Overflow

        if (x < -0x400000000000000000) return 0; // Underflow

        return exp_2 (
            int128 (int256 (x) * 0x171547652B82FE1777D0FFDA0D23A7D12 >> 128));
    }
    }

    /**
     * Calculate x / y rounding towards zero, where x and y are unsigned 256-bit
     * integer numbers.  Revert on overflow or when y is zero.
     *
     * @param x unsigned 256-bit integer number
     * @param y unsigned 256-bit integer number
     * @return unsigned 64.64-bit fixed point number
     */
    function divuu (uint256 x, uint256 y) private pure returns (uint128) {
    unchecked {
        require (y != 0);

        uint256 result;

        if (x <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF)
            result = (x << 64) / y;
        else {
            uint256 msb = 192;
            uint256 xc = x >> 192;
            if (xc >= 0x100000000) { xc >>= 32; msb += 32; }
            if (xc >= 0x10000) { xc >>= 16; msb += 16; }
            if (xc >= 0x100) { xc >>= 8; msb += 8; }
            if (xc >= 0x10) { xc >>= 4; msb += 4; }
            if (xc >= 0x4) { xc >>= 2; msb += 2; }
            if (xc >= 0x2) msb += 1;  // No need to shift xc anymore

            result = (x << 255 - msb) / ((y - 1 >> msb - 191) + 1);
            require (result <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);

            uint256 hi = result * (y >> 128);
            uint256 lo = result * (y & 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);

            uint256 xh = x >> 192;
            uint256 xl = x << 64;

            if (xl < lo) xh -= 1;
            xl -= lo; // We rely on overflow behavior here
            lo = hi << 128;
            if (xl < lo) xh -= 1;
            xl -= lo; // We rely on overflow behavior here

            assert (xh == hi >> 128);

            result += xl / y;
        }

        require (result <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);
        return uint128 (result);
    }
    }

    /**
     * Calculate sqrt (x) rounding down, where x is unsigned 256-bit integer
     * number.
     *
     * @param x unsigned 256-bit integer number
     * @return unsigned 128-bit integer number
     */
    function sqrtu (uint256 x) private pure returns (uint128) {
    unchecked {
        if (x == 0) return 0;
        else {
            uint256 xx = x;
            uint256 r = 1;
            if (xx >= 0x100000000000000000000000000000000) { xx >>= 128; r <<= 64; }
            if (xx >= 0x10000000000000000) { xx >>= 64; r <<= 32; }
            if (xx >= 0x100000000) { xx >>= 32; r <<= 16; }
            if (xx >= 0x10000) { xx >>= 16; r <<= 8; }
            if (xx >= 0x100) { xx >>= 8; r <<= 4; }
            if (xx >= 0x10) { xx >>= 4; r <<= 2; }
            if (xx >= 0x8) { r <<= 1; }
            r = (r + x / r) >> 1;
            r = (r + x / r) >> 1;
            r = (r + x / r) >> 1;
            r = (r + x / r) >> 1;
            r = (r + x / r) >> 1;
            r = (r + x / r) >> 1;
            r = (r + x / r) >> 1; // Seven iterations should be enough
            uint256 r1 = x / r;
            return uint128 (r < r1 ? r : r1);
        }
    }
    }
}

File 7 of 8 : Address.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/**
 * @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
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // This method relies on extcodesize, which returns 0 for contracts in
        // construction, since the code is only stored at the end of the
        // constructor execution.

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

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

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

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

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

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

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

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

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

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

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

    /**
     * @dev 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) {
        require(isContract(target), "Address: delegate call to non-contract");

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

    function _verifyCallResult(
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) private pure returns (bytes memory) {
        if (success) {
            return returndata;
        } else {
            // Look for revert reason and bubble it up if present
            if (returndata.length > 0) {
                // The easiest way to bubble the revert reason is using memory via assembly

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

File 8 of 8 : Context.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/*
 * @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 Context {
    function _msgSender() internal view virtual returns (address) {
        return msg.sender;
    }

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

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

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"_apyPerSec","type":"uint256"},{"internalType":"uint256","name":"_depositStartBlock","type":"uint256"},{"internalType":"uint256","name":"_depositEndBlock","type":"uint256"},{"internalType":"uint256","name":"_poolDurationByBlock","type":"uint256"},{"internalType":"uint256","name":"_secretBonusLimit","type":"uint256"},{"internalType":"uint256","name":"_secretBonusPool","type":"uint256"}],"stateMutability":"nonpayable","type":"constructor"},{"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":"_userAddress","type":"address"},{"indexed":false,"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"TokenStaked","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_userAddress","type":"address"},{"indexed":false,"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"TokenWithdrawn","type":"event"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"_balances","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"numBlocksPassed","type":"uint256"},{"internalType":"uint256","name":"maxBlock","type":"uint256"}],"name":"_blocksStaked","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"principal","type":"uint256"},{"internalType":"uint256","name":"blocksStaked","type":"uint256"}],"name":"_compoundInterestByBlock","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"addressByIndex","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"adminWithdrawRemaining","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"apy","outputs":[{"internalType":"uint256","name":"_apy","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_newApyRate","type":"uint256"}],"name":"changeAPY","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_depositStartBlock","type":"uint256"},{"internalType":"uint256","name":"_depositEndBlock","type":"uint256"}],"name":"changeDepositWindow","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"principal","type":"uint256"}],"name":"compoundInterestByBlock","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"principal","type":"uint256"},{"internalType":"uint256","name":"ratio","type":"uint256"},{"internalType":"uint256","name":"n","type":"uint256"}],"name":"compoundInterestByTime","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"principal","type":"uint256"}],"name":"compoundWithPrincipal","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"principal","type":"uint256"},{"internalType":"uint256","name":"duration","type":"uint256"}],"name":"compoundWithPrincipalAndTime","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"compoundWithPrincipalByUser","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getAdminStakingInfo","outputs":[{"internalType":"uint256","name":"_totalPrincipal","type":"uint256"},{"internalType":"uint256","name":"_numUsersWithDeposits","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getCompoundInfo","outputs":[{"internalType":"uint256","name":"_currentBlock","type":"uint256"},{"internalType":"uint256","name":"_depositStartBlock","type":"uint256"},{"internalType":"uint256","name":"_depositEndBlock","type":"uint256"},{"internalType":"uint256","name":"_interestStartBlock","type":"uint256"},{"internalType":"uint256","name":"_interestEndBlock","type":"uint256"},{"internalType":"uint256","name":"_interestStartTime","type":"uint256"},{"internalType":"uint256","name":"_interestEndTime","type":"uint256"},{"internalType":"uint256","name":"_interestApyPerSec","type":"uint256"},{"internalType":"uint256","name":"_interestApyPerBlock","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getSecretPoolInfo","outputs":[{"internalType":"uint256","name":"_secretBonusLimit","type":"uint256"},{"internalType":"uint256","name":"_secretBonusPool","type":"uint256"},{"internalType":"bool","name":"_bonusUnlockable","type":"bool"},{"internalType":"bool","name":"_bonusUnlocked","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"userAddress","type":"address"}],"name":"getUserBalances","outputs":[{"internalType":"uint256","name":"_principal","type":"uint256"},{"internalType":"uint256","name":"_reward","type":"uint256"},{"internalType":"uint256","name":"_balance","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"int128","name":"x","type":"int128"},{"internalType":"uint256","name":"n","type":"uint256"}],"name":"pow","outputs":[{"internalType":"int128","name":"r","type":"int128"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"stakeTokens","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"withdrawExtraTokens","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"withdrawTokens","outputs":[],"stateMutability":"nonpayable","type":"function"}]

Deployed Bytecode

0x608060405234801561001057600080fd5b50600436106101585760003560e01c80638d8f2adb116100c3578063b01232ec1161007c578063b01232ec146102b7578063b5ed7391146102ca578063bf0c39d2146102e0578063c3497d5f146102f3578063d8ab920814610310578063f2fde38b1461032357610158565b80638d8f2adb146102325780638da5cb5b1461023a5780639ae651791461024f578063abd3f61214610262578063ae129e3114610284578063ae581bc21461029757610158565b806361ef6c7e1161011557806361ef6c7e146101d65780636ebcf607146101de578063715018a6146101f15780637547c7a3146101f957806376159b681461020c5780638c7857211461021f57610158565b806311f8ab201461015d57806331562946146101675780633bcfc4b8146101905780633ca3af13146101985780635574d4e5146101ab5780636036ddb8146101be575b600080fd5b610165610336565b005b61017a61017536600461136e565b6104f4565b60405161018791906116d5565b60405180910390f35b61017a610540565b6101656101a636600461136e565b610564565b61017a6101b936600461138f565b610623565b6101c6610663565b60405161018794939291906116ec565b61017a61069c565b61017a6101ec3660046112c7565b6106b5565b6101656106c7565b61016561020736600461133e565b610712565b61016561021a36600461133e565b6109d9565b61017a61022d36600461133e565b610a4f565b610165610a7a565b610242610c5c565b60405161018791906113ba565b61017a61025d36600461133e565b610c6b565b6102756102703660046112c7565b610c9a565b6040516101879392919061170b565b61017a61029236600461136e565b610d45565b6102aa6102a536600461130e565b610d5c565b6040516101879190611425565b6101656102c536600461133e565b610dc1565b6102d2610ebe565b6040516101879291906116de565b61017a6102ee36600461136e565b610ec8565b6102fb610eda565b60405161018799989796959493929190611721565b61024261031e36600461133e565b610ef6565b6101656103313660046112c7565b610f11565b61033e610fa6565b6001600160a01b031661034f610c5c565b6001600160a01b03161461037e5760405162461bcd60e51b815260040161037590611592565b60405180910390fd5b600061038b600c54610c6b565b6001546040516370a0823160e01b81529192506000916001600160a01b03909116906370a08231906103c19030906004016113ba565b60206040518083038186803b1580156103d957600080fd5b505afa1580156103ed573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104119190611356565b9050818111156104f05760006104278284610f8e565b60015460405163a9059cbb60e01b81529192506001600160a01b03169063a9059cbb9061045a903390859060040161140c565b602060405180830381600087803b15801561047457600080fd5b505af1158015610488573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104ac91906112ee565b6104b557600080fd5b7fa2bd9fcfcdba69f52bcd9a520846ad4bd685b187483f53efc42d035b2ddebff033826040516104e692919061140c565b60405180910390a1505b5050565b60008061052a61051c8461051687600260070154610f9a90919063ffffffff16565b90610f9a565b670de0b6b3a7640000610faa565b90506105368185610f82565b9150505b92915050565b600854600090610554906301e1855861178c565b61055f90606461178c565b905090565b61056c610fa6565b6001600160a01b031661057d610c5c565b6001600160a01b0316146105a35760405162461bcd60e51b815260040161037590611592565b600282905560038190556105b8816001610f82565b6004819055600a546105ca9190610f82565b6005556004546000906105dd9043610f8e565b90506105f46105ed82600f610f9a565b4290610f82565b60065560045460055460009161060a9190610f8e565b905061061a6105ed82600f610f9a565b60075550505050565b600061065b61065561064f6106386001610fb6565b61064a87670de0b6b3a7640000610fd4565b61100b565b84610d5c565b8561103f565b949350505050565b600080600080600f54601054600f54600e5411600260030154431015801561068e5750600f54600e54115b935093509350935090919293565b3360009081526011602052604081205461055f90610a4f565b60116020526000908152604090205481565b6106cf610fa6565b6001600160a01b03166106e0610c5c565b6001600160a01b0316146107065760405162461bcd60e51b815260040161037590611592565b61071060006110a7565b565b6002544311801561072557506003544311155b6107415760405162461bcd60e51b815260040161037590611678565b600154604051636eb1769f60e11b815282916001600160a01b03169063dd62ed3e9061077390339030906004016113ce565b60206040518083038186803b15801561078b57600080fd5b505afa15801561079f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107c39190611356565b10156107e15760405162461bcd60e51b815260040161037590611624565b6001546040516370a0823160e01b815282916001600160a01b0316906370a08231906108119033906004016113ba565b60206040518083038186803b15801561082957600080fd5b505afa15801561083d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108619190611356565b101561087f5760405162461bcd60e51b8152600401610375906114e4565b336000908152601160205260409020546108be57600d80549060006108a3836117c2565b9091555050600e80549060006108b8836117c2565b91905055505b33600090815260116020526040812080548392906108dd908490611760565b9250508190555080600c60008282546108f69190611760565b90915550506001546040516323b872dd60e01b81526001600160a01b03909116906323b872dd9061092f903390309086906004016113e8565b602060405180830381600087803b15801561094957600080fd5b505af115801561095d573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061098191906112ee565b61099d5760405162461bcd60e51b8152600401610375906115c7565b7f1fdab8a8457aaf782e4b6217d6ffa6f5006eda7e50922dd092b2e1524275d77433826040516109ce92919061140c565b60405180910390a150565b6109e1610fa6565b6001600160a01b03166109f2610c5c565b6001600160a01b031614610a185760405162461bcd60e51b815260040161037590611592565b6004544310610a395760405162461bcd60e51b815260040161037590611433565b6008819055610a4981600f610f9a565b60095550565b6006546000908190610a6190426117ab565b9050610a738360026006015483610623565b9392505050565b33600090815260116020526040902054610aa65760405162461bcd60e51b815260040161037590611541565b6003546000904311610ac8575033600090815260116020526040902054610ae4565b33600090815260116020526040902054610ae190610c6b565b90505b6000610afb600b5483610faa90919063ffffffff16565b9050610b078282610f8e565b6005549092504310801590610b1f5750600f54600e54115b15610b4057600e54601054610b3391610faa565b610b3d9083611760565b91505b33600090815260116020526040812054600c805491929091610b639084906117ab565b9091555050336000908152601160205260408120819055600d805460019290610b8d9084906117ab565b909155505060015460405163a9059cbb60e01b81526001600160a01b039091169063a9059cbb90610bc4903390869060040161140c565b602060405180830381600087803b158015610bde57600080fd5b505af1158015610bf2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c1691906112ee565b610c1f57600080fd5b7fa2bd9fcfcdba69f52bcd9a520846ad4bd685b187483f53efc42d035b2ddebff03383604051610c5092919061140c565b60405180910390a15050565b6000546001600160a01b031690565b6004546000908190610c7e904390610f8e565b90506000610c8e82600a54610d45565b905061065b84826104f4565b600080600060028001544311610ccd575050506001600160a01b0381166000908152601160205260408120549081610d3e565b6001600160a01b038416600090815260116020526040812054610cef90610c6b565b6001600160a01b03861660009081526011602052604081205491925090610d17908390610f8e565b6001600160a01b03871660009081526011602052604090205495509350909150610d3e9050565b9193909250565b6000818310610d5557508061053a565b508161053a565b6000610d686001610fb6565b90505b811561053a57610d7c6002836117dd565b60011415610da257610d8e81846110f7565b9050610d9b6001836117ab565b9150610dbc565b610dac83846110f7565b9250610db9600283611778565b91505b610d6b565b610dc9610fa6565b6001600160a01b0316610dda610c5c565b6001600160a01b031614610e005760405162461bcd60e51b815260040161037590611592565b60015460405163a9059cbb60e01b81526001600160a01b039091169063a9059cbb90610e32903390859060040161140c565b602060405180830381600087803b158015610e4c57600080fd5b505af1158015610e60573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e8491906112ee565b610e8d57600080fd5b7fa2bd9fcfcdba69f52bcd9a520846ad4bd685b187483f53efc42d035b2ddebff033826040516109ce92919061140c565b600c54600d549091565b6000610a738360026006015484610623565b6002546003546004546005546006546007546008546009544398565b6012602052600090815260409020546001600160a01b031681565b610f19610fa6565b6001600160a01b0316610f2a610c5c565b6001600160a01b031614610f505760405162461bcd60e51b815260040161037590611592565b6001600160a01b038116610f765760405162461bcd60e51b81526004016103759061149e565b610f7f816110a7565b50565b6000610a738284611760565b6000610a7382846117ab565b6000610a73828461178c565b3390565b6000610a738284611778565b6000677fffffffffffffff821115610fcd57600080fd5b5060401b90565b600081610fe057600080fd5b6000610fec848461112d565b905060016001607f1b036001600160801b0382161115610a7357600080fd5b6000600f83810b9083900b0160016001607f1b03198112801590611036575060016001607f1b038113155b610a7357600080fd5b60008161104e5750600061053a565b600083600f0b121561105f57600080fd5b600f83900b6001600160801b038316810260401c90608084901c026001600160c01b0381111561108e57600080fd5b60401b811981111561109f57600080fd5b019392505050565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6000600f83810b9083900b0260401d60016001607f1b03198112801590611036575060016001607f1b03811315610a7357600080fd5b60008161113957600080fd5b60006001600160c01b0384116111725782604085901b8161116a57634e487b7160e01b600052601260045260246000fd5b0490506112b3565b60c084811c640100000000811061118b576020918201911c5b62010000811061119d576010918201911c5b61010081106111ae576008918201911c5b601081106111be576004918201911c5b600481106111ce576002918201911c5b600281106111dd576001820191505b60bf820360018603901c6001018260ff0387901b8161120c57634e487b7160e01b600052601260045260246000fd5b0492506001600160801b0383111561122357600080fd5b608085901c83026001600160801b038616840260c088901c604089901b8281101561124f576001820391505b608084901b92900382811015611266576001820391505b829003608084901c821461128a57634e487b7160e01b600052600160045260246000fd5b8881816112a757634e487b7160e01b600052601260045260246000fd5b04870196505050505050505b6001600160801b03811115610a7357600080fd5b6000602082840312156112d8578081fd5b81356001600160a01b0381168114610a73578182fd5b6000602082840312156112ff578081fd5b81518015158114610a73578182fd5b60008060408385031215611320578081fd5b823580600f0b8114611330578182fd5b946020939093013593505050565b60006020828403121561134f578081fd5b5035919050565b600060208284031215611367578081fd5b5051919050565b60008060408385031215611380578182fd5b50508035926020909101359150565b6000806000606084860312156113a3578081fd5b505081359360208301359350604090920135919050565b6001600160a01b0391909116815260200190565b6001600160a01b0392831681529116602082015260400190565b6001600160a01b039384168152919092166020820152604081019190915260600190565b6001600160a01b03929092168252602082015260400190565b600f9190910b815260200190565b60208082526045908201527f4861734e6f74537461727465645969656c64696e673a2043616e20626520636160408201527f6c6c6564206f6e6c79206265666f726520696e74657265737420737461727420606082015264626c6f636b60d81b608082015260a00190565b60208082526026908201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160408201526564647265737360d01b606082015260800190565b6020808252603a908201527f546f6b656e42616c616e63653a206d73672e73656e6465722063616e206e6f7460408201527f207374616b65206d6f7265207468616e20746865792068617665000000000000606082015260800190565b60208082526031908201527f546f6b656e42616c616e63653a206e6f20746f6b656e7320617661696c61626c60408201527032903a37903132903bb4ba34323930bbb760791b606082015260800190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b6020808252603d908201527f546f6b656e5472616e736665723a206661696c656420746f207472616e73666560408201527f7220746f6b656e732066726f6d206d73672e73656e6465722068657265000000606082015260800190565b60208082526034908201527f546f6b656e42616c616e63653a205573657220686173206e6f7420616c6c6f776040820152731959081d1bdad95b9cc81d1bc81899481d5cd95960621b606082015260800190565b60208082526037908201527f4465706f73697457696e646f773a2043616e2062652063616c6c6564206f6e6c60408201527f7920647572696e67206465706f7369742077696e646f77000000000000000000606082015260800190565b90815260200190565b918252602082015260400190565b9384526020840192909252151560408301521515606082015260800190565b9283526020830191909152604082015260600190565b988952602089019790975260408801959095526060870193909352608086019190915260a085015260c084015260e08301526101008201526101200190565b60008219821115611773576117736117f1565b500190565b60008261178757611787611807565b500490565b60008160001904831182151516156117a6576117a66117f1565b500290565b6000828210156117bd576117bd6117f1565b500390565b60006000198214156117d6576117d66117f1565b5060010190565b6000826117ec576117ec611807565b500690565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fdfea2646970667358221220783381cc3f1cc6f3ac9fea7d9f7174a82a06e64909f7df9e4c7e927158d026f764736f6c63430008000033

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.