Cryo Explorer Ethereum Mainnet

Address Contract Verified

Address 0x869657980da246Eb29be4b939ED0B0327a7C6398
Balance 0 ETH
Nonce 1
Code Size 8448 bytes
Indexed Transactions 0
External Etherscan · Sourcify

Contract Bytecode

8448 bytes
0x608060405234801561000f575f5ffd5b50600436106101c2575f3560e01c8063979f8d96116100f7578063cddb3e7b11610095578063df1dcaa91161006f578063df1dcaa914610482578063f04d688f1461049e578063f2fde38b146104bc578063fe575a87146104d8576101c2565b8063cddb3e7b14610414578063d0bad4b114610448578063d5fcc7b614610466576101c2565b8063b0aa1e04116100d1578063b0aa1e04146103a4578063b6b55f25146103c0578063bb3d676a146103dc578063c713aa94146103f8576101c2565b8063979f8d961461034c57806399a0331614610368578063a8b3820514610386576101c2565b8063715018a61161016457806389daf7991161013e57806389daf799146102d85780638a6876ad146102f45780638da5cb5b1461031257806391c6196614610330576101c2565b8063715018a61461026e57806379ee54f7146102785780637d7366aa146102a8576101c2565b80632be11ae2116101a05780632be11ae21461021e5780633ccfd60b1461022857806351ed6a301461023257806363d9df8514610250576101c2565b80630397d458146101c6578063083c6323146101e257806329d0fa3e14610200575b5f5ffd5b6101e060048036038101906101db91906117ff565b610508565b005b6101ea610553565b6040516101f79190611842565b60405180910390f35b610208610559565b6040516102159190611842565b60405180910390f35b61022661055f565b005b61023061056a565b005b61023a61080f565b60405161024791906118b6565b60405180910390f35b610258610834565b60405161026591906118de565b60405180910390f35b610276610859565b005b610292600480360381019061028d91906117ff565b61086c565b60405161029f9190611842565b60405180910390f35b6102c260048036038101906102bd91906117ff565b6109eb565b6040516102cf9190611842565b60405180910390f35b6102f260048036038101906102ed9190611958565b610a00565b005b6102fc610aa5565b6040516103099190611842565b60405180910390f35b61031a610aab565b60405161032791906118de565b60405180910390f35b61034a600480360381019061034591906119cd565b610ad3565b005b61036660048036038101906103619190611a40565b610dbf565b005b610370610de3565b60405161037d9190611842565b60405180910390f35b61038e610de9565b60405161039b9190611842565b60405180910390f35b6103be60048036038101906103b99190611a6b565b610def565b005b6103da60048036038101906103d59190611a6b565b610e01565b005b6103f660048036038101906103f19190611958565b61102c565b005b610412600480360381019061040d9190611a6b565b6110d2565b005b61042e600480360381019061042991906117ff565b6110e4565b60405161043f959493929190611a96565b60405180910390f35b610450611116565b60405161045d9190611af6565b60405180910390f35b610480600480360381019061047b91906117ff565b611128565b005b61049c60048036038101906104979190611a6b565b611173565b005b6104a6611185565b6040516104b39190611842565b60405180910390f35b6104d660048036038101906104d191906117ff565b61118b565b005b6104f260048036038101906104ed91906117ff565b61120d565b6040516104ff9190611af6565b60405180910390f35b61051061122a565b8060025f6101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b600b5481565b60085481565b610568336112a8565b565b5f600d5f3373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f206040518060a00160405290815f820154815260200160018201548152602001600282015481526020016003820154815260200160048201548152505090505f815f015190504260095483602001516106009190611b3c565b1115801561061d575042600954600c5461061a9190611b3c565b11155b61065c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161065390611bef565b60405180910390fd5b5f811161069e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161069590611c57565b60405180910390fd5b6106a661055f565b600d5f3373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f5f82015f9055600182015f9055600282015f9055600382015f9055600482015f905550508060055f8282546107199190611c75565b925050819055503373ffffffffffffffffffffffffffffffffffffffff167f884edad9ce6fa2440d8a54cc123490eb96d2768479d49ff9c7366125a9424364826040516107669190611842565b60405180910390a260025f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a9059cbb33836040518363ffffffff1660e01b81526004016107ca929190611ca8565b6020604051808303815f875af11580156107e6573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061080a9190611ce3565b505050565b60025f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60035f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b61086161122a565b61086a5f61162e565b565b5f5f6005540361087e575f90506109e6565b5f600b54431161089b57600654436108969190611c75565b6108ac565b600654600b546108ab9190611c75565b5b90505f600854826108bd9190611d0e565b90505f60055464e8d4a51000836108d49190611d0e565b6108de9190611d7c565b6007546108eb9190611b3c565b90505f600d5f8773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f206040518060a00160405290815f82015481526020016001820154815260200160028201548152602001600382015481526020016004820154815250509050600f5f8773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f2054816080015164e8d4a5100084845f01516109c19190611d0e565b6109cb9190611d7c565b6109d59190611c75565b6109df9190611b3c565b9450505050505b919050565b600f602052805f5260405f205f915090505481565b610a0861122a565b5f5f90505b82829050811015610aa0575f600e5f858585818110610a2f57610a2e611dac565b5b9050602002016020810190610a4491906117ff565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f6101000a81548160ff0219169083151502179055508080600101915050610a0d565b505050565b60045481565b5f60015f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b60035f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610b62576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b5990611e49565b60405180910390fd5b600b544310610ba6576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b9d90611eb1565b60405180910390fd5b5f8111610be8576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610bdf90611f19565b60405180910390fd5b5f600d5f8473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f209050610c31836112a8565b81815f015f828254610c439190611b3c565b9250508190555064e8d4a51000600754825f0154610c619190611d0e565b610c6b9190611d7c565b81600401819055504281600101819055508160055f828254610c8d9190611b3c565b925050819055508160045f828254610ca59190611b3c565b925050819055508273ffffffffffffffffffffffffffffffffffffffff167fe1fffcc4923d04b559f4d29a8bfc6cda04eb5b0d3c460751c2402c5c5cc9109c83604051610cf29190611842565b60405180910390a260025f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166323b872dd60035f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1630856040518463ffffffff1660e01b8152600401610d7993929190611f37565b6020604051808303815f875af1158015610d95573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610db99190611ce3565b50505050565b610dc761122a565b80600a5f6101000a81548160ff02191690831515021790555050565b60055481565b60095481565b610df761122a565b80600c8190555050565b600b544310610e45576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e3c90611eb1565b60405180910390fd5b5f8111610e87576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e7e90611f19565b60405180910390fd5b5f600d5f3373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f209050610ecf61055f565b81815f015f828254610ee19190611b3c565b9250508190555064e8d4a51000600754825f0154610eff9190611d0e565b610f099190611d7c565b81600401819055504281600101819055504381600201819055508160055f828254610f349190611b3c565b925050819055503373ffffffffffffffffffffffffffffffffffffffff167fe1fffcc4923d04b559f4d29a8bfc6cda04eb5b0d3c460751c2402c5c5cc9109c83604051610f819190611842565b60405180910390a260025f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166323b872dd3330856040518463ffffffff1660e01b8152600401610fe793929190611f37565b6020604051808303815f875af1158015611003573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906110279190611ce3565b505050565b61103461122a565b5f5f90505b828290508110156110cd576001600e5f85858581811061105c5761105b611dac565b5b905060200201602081019061107191906117ff565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f6101000a81548160ff0219169083151502179055508080600101915050611039565b505050565b6110da61122a565b80600b8190555050565b600d602052805f5260405f205f91509050805f0154908060010154908060020154908060030154908060040154905085565b600a5f9054906101000a900460ff1681565b61113061122a565b8060035f6101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b61117b61122a565b8060098190555050565b600c5481565b61119361122a565b5f73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1603611201576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016111f890611fdc565b60405180910390fd5b61120a8161162e565b50565b600e602052805f5260405f205f915054906101000a900460ff1681565b6112326116f1565b73ffffffffffffffffffffffffffffffffffffffff16611250610aab565b73ffffffffffffffffffffffffffffffffffffffff16146112a6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161129d90612044565b60405180910390fd5b565b600e5f8273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f9054906101000a900460ff1615611332576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611329906120ac565b60405180910390fd5b61133a6116f8565b5f600d5f8373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f2090505f816004015464e8d4a51000600754845f01546113979190611d0e565b6113a19190611d7c565b6113ab9190611c75565b90505f81036113bb57505061162b565b80826003015f8282546113ce9190611b3c565b9250508190555064e8d4a51000600754835f01546113ec9190611d0e565b6113f69190611d7c565b8260040181905550600a5f9054906101000a900460ff166115d4575f600f5f8573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205411156114e457600f5f8473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f20548161149f9190611b3c565b90505f600f5f8573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f20819055505b8273ffffffffffffffffffffffffffffffffffffffff167fdaaebb9609cb2f719c59c9d334be287bf4def107ad3dec4a6f90d8abaa94c73c8260405161152a9190611842565b60405180910390a260025f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a9059cbb84836040518363ffffffff1660e01b815260040161158e929190611ca8565b6020604051808303815f875af11580156115aa573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906115ce9190611ce3565b50611628565b80600f5f8573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f8282546116209190611b3c565b925050819055505b50505b50565b5f60015f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1690508160015f6101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b5f33905090565b5f6005540361170d574360068190555061179b565b5f600b54431161172a57600654436117259190611c75565b61173b565b600654600b5461173a9190611c75565b5b90505f6008548261174c9190611d0e565b905060055464e8d4a51000826117629190611d0e565b61176c9190611d7c565b6007546117799190611b3c565b600781905550600b54431161178e5743611792565b600b545b60068190555050505b565b5f5ffd5b5f5ffd5b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f6117ce826117a5565b9050919050565b6117de816117c4565b81146117e8575f5ffd5b50565b5f813590506117f9816117d5565b92915050565b5f602082840312156118145761181361179d565b5b5f611821848285016117eb565b91505092915050565b5f819050919050565b61183c8161182a565b82525050565b5f6020820190506118555f830184611833565b92915050565b5f819050919050565b5f61187e611879611874846117a5565b61185b565b6117a5565b9050919050565b5f61188f82611864565b9050919050565b5f6118a082611885565b9050919050565b6118b081611896565b82525050565b5f6020820190506118c95f8301846118a7565b92915050565b6118d8816117c4565b82525050565b5f6020820190506118f15f8301846118cf565b92915050565b5f5ffd5b5f5ffd5b5f5ffd5b5f5f83601f840112611918576119176118f7565b5b8235905067ffffffffffffffff811115611935576119346118fb565b5b602083019150836020820283011115611951576119506118ff565b5b9250929050565b5f5f6020838503121561196e5761196d61179d565b5b5f83013567ffffffffffffffff81111561198b5761198a6117a1565b5b61199785828601611903565b92509250509250929050565b6119ac8161182a565b81146119b6575f5ffd5b50565b5f813590506119c7816119a3565b92915050565b5f5f604083850312156119e3576119e261179d565b5b5f6119f0858286016117eb565b9250506020611a01858286016119b9565b9150509250929050565b5f8115159050919050565b611a1f81611a0b565b8114611a29575f5ffd5b50565b5f81359050611a3a81611a16565b92915050565b5f60208284031215611a5557611a5461179d565b5b5f611a6284828501611a2c565b91505092915050565b5f60208284031215611a8057611a7f61179d565b5b5f611a8d848285016119b9565b91505092915050565b5f60a082019050611aa95f830188611833565b611ab66020830187611833565b611ac36040830186611833565b611ad06060830185611833565b611add6080830184611833565b9695505050505050565b611af081611a0b565b82525050565b5f602082019050611b095f830184611ae7565b92915050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b5f611b468261182a565b9150611b518361182a565b9250828201905080821115611b6957611b68611b0f565b5b92915050565b5f82825260208201905092915050565b7f796f7520617265206e6f7420616c6c6f77656420746f207769746864726177205f8201527f6265666f7265206c6f636b65642054696d650000000000000000000000000000602082015250565b5f611bd9603283611b6f565b9150611be482611b7f565b604082019050919050565b5f6020820190508181035f830152611c0681611bcd565b9050919050565b7f576974686472617720616d6f756e742063616e2774206265207a65726f0000005f82015250565b5f611c41601d83611b6f565b9150611c4c82611c0d565b602082019050919050565b5f6020820190508181035f830152611c6e81611c35565b9050919050565b5f611c7f8261182a565b9150611c8a8361182a565b9250828203905081811115611ca257611ca1611b0f565b5b92915050565b5f604082019050611cbb5f8301856118cf565b611cc86020830184611833565b9392505050565b5f81519050611cdd81611a16565b92915050565b5f60208284031215611cf857611cf761179d565b5b5f611d0584828501611ccf565b91505092915050565b5f611d188261182a565b9150611d238361182a565b9250828202611d318161182a565b91508282048414831517611d4857611d47611b0f565b5b5092915050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601260045260245ffd5b5f611d868261182a565b9150611d918361182a565b925082611da157611da0611d4f565b5b828204905092915050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52603260045260245ffd5b7f54686973206d6574686f64206973206f6e6c7920666f722070726573616c65205f8201527f436f6e7472616374000000000000000000000000000000000000000000000000602082015250565b5f611e33602883611b6f565b9150611e3e82611dd9565b604082019050919050565b5f6020820190508181035f830152611e6081611e27565b9050919050565b7f7374616b696e6720686173206265656e20656e646564000000000000000000005f82015250565b5f611e9b601683611b6f565b9150611ea682611e67565b602082019050919050565b5f6020820190508181035f830152611ec881611e8f565b9050919050565b7f4465706f73697420616d6f756e742063616e2774206265207a65726f000000005f82015250565b5f611f03601c83611b6f565b9150611f0e82611ecf565b602082019050919050565b5f6020820190508181035f830152611f3081611ef7565b9050919050565b5f606082019050611f4a5f8301866118cf565b611f5760208301856118cf565b611f646040830184611833565b949350505050565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f20615f8201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b5f611fc6602683611b6f565b9150611fd182611f6c565b604082019050919050565b5f6020820190508181035f830152611ff381611fba565b9050919050565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65725f82015250565b5f61202e602083611b6f565b915061203982611ffa565b602082019050919050565b5f6020820190508181035f83015261205b81612022565b9050919050565b7f54686973204164647265737320697320426c61636b6c697374656400000000005f82015250565b5f612096601b83611b6f565b91506120a182612062565b602082019050919050565b5f6020820190508181035f8301526120c38161208a565b905091905056fea26469706673582212206cbf8fcecf6d08610db7e8bda385e5a7f546a3565dad0d64fb4fb0e7a4e80ae264736f6c634300081e0033

Verified Source Code Full Match

Compiler: v0.8.30+commit.73712a01 EVM: prague Optimization: No
Layer_Staking.sol 239 lines
//SPDX-License-Identifier: Unlicense
pragma solidity ^0.8.20;

import "@openzeppelin/[email protected]/security/ReentrancyGuard.sol";
import "@openzeppelin/[email protected]/access/Ownable.sol";
import "@openzeppelin/[email protected]/interfaces/IERC20Metadata.sol";

contract LayerBrett_Staking is ReentrancyGuard, Ownable {
  IERC20Metadata public stakeToken; // Token to be staked and rewarded
  address public presaleContract; //presale contract address
  uint256 public tokensStakedByPresale; //total tokens staked by preSale
  uint256 public tokensStaked; // Total tokens staked

  uint256 private lastRewardedBlock; // Last block number the user had their rewards calculated
  uint256 private accumulatedRewardsPerShare; // Accumulated rewards per share times REWARDS_PRECISION
  uint256 public rewardTokensPerBlock; // Number of reward tokens minted per block
  uint256 private constant REWARDS_PRECISION = 1e12; // A big number to perform mul and div operations
  
  uint256 public lockedTime; //To lock the tokens in contract for definite time.
  bool public harvestLock; //To lock the harvest/claim.
  uint public endBlock; //At this block,the rewards generation will be stopped.
  uint256 public claimStart; //Users can claim after this time in epoch.

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

  //  staker address => PoolStaker
  mapping(address => PoolStaker) public poolStakers;
  mapping(address => bool) public isBlacklisted;
  mapping(address => uint) public userLockedRewards;

  // Events
  event Deposit(address indexed user, uint256 amount);
  event Withdraw(address indexed user, uint256 amount);
  event HarvestRewards(address indexed user, uint256 amount);

  constructor(
    address _rewardTokenAddress,
    uint256 _rewardTokensPerBlock,
    uint _lockTime
  ) {
    stakeToken = IERC20Metadata(_rewardTokenAddress);
    rewardTokensPerBlock = _rewardTokensPerBlock;
    lockedTime = _lockTime;
    harvestLock = true;
  }

  modifier onlyPresale() {
    require(msg.sender == presaleContract, 'This method is only for presale Contract');
    _;
  }

  /**
   * @dev Deposit tokens to the pool
   */
  function deposit(uint256 _amount) external {
    require(block.number < endBlock, 'staking has been ended');
    require(_amount > 0, "Deposit amount can't be zero");

    PoolStaker storage staker = poolStakers[msg.sender];

    // Update pool stakers
    harvestRewards();

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

    // Update pool
    tokensStaked += _amount;

    // Deposit tokens
    emit Deposit(msg.sender, _amount);
    stakeToken.transferFrom(msg.sender, address(this), _amount);
  }

  /**
   * @dev Deposit tokens to  pool by presale contract
   */
  function depositByPresale(address _user, uint256 _amount) external onlyPresale {
    require(block.number < endBlock, 'staking has been ended');
    require(_amount > 0, "Deposit amount can't be zero");

    PoolStaker storage staker = poolStakers[_user];

    // Update pool stakers
    _harvestRewards(_user);

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

    // Update pool
    tokensStaked += _amount;
    tokensStakedByPresale += _amount;

    // Deposit tokens
    emit Deposit(_user, _amount);
    stakeToken.transferFrom(presaleContract, address(this), _amount);
  }

  /**
   * @dev Withdraw all tokens from existing pool
   */
  function withdraw() external {
    PoolStaker memory staker = poolStakers[msg.sender];
    uint256 amount = staker.amount;
    require(staker.stakedTime + lockedTime <= block.timestamp && claimStart + lockedTime <= block.timestamp, 'you are not allowed to withdraw before locked Time');
    require(amount > 0, "Withdraw amount can't be zero");

    // Pay rewards
    harvestRewards();

    //delete staker
    delete poolStakers[msg.sender];

    // Update pool
    tokensStaked -= amount;

    // Withdraw tokens
    emit Withdraw(msg.sender, amount);
    stakeToken.transfer(msg.sender, amount);
  }

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

  /**
   * @dev Harvest user rewards
   */
  function _harvestRewards(address _user) private {
    require(!isBlacklisted[_user], 'This Address is Blacklisted');

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

    staker.Harvestedrewards += rewardsToHarvest;
    staker.rewardDebt = (staker.amount * accumulatedRewardsPerShare) / REWARDS_PRECISION;
    if (!harvestLock) {
      if (userLockedRewards[_user] > 0) {
        rewardsToHarvest += userLockedRewards[_user];
        userLockedRewards[_user] = 0;
      }
      emit HarvestRewards(_user, rewardsToHarvest);
      stakeToken.transfer(_user, rewardsToHarvest);
    } else {
      userLockedRewards[_user] += rewardsToHarvest;
    }
  }

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

  /**
   *@dev To get the number of rewards that user can get
   */
  function getRewards(address _user) public view returns (uint) {
    if (tokensStaked == 0) {
      return 0;
    }
    uint256 blocksSinceLastReward = block.number > endBlock ? endBlock - lastRewardedBlock : block.number - lastRewardedBlock;
    uint256 rewards = blocksSinceLastReward * rewardTokensPerBlock;
    uint256 accCalc = accumulatedRewardsPerShare + ((rewards * REWARDS_PRECISION) / tokensStaked);
    PoolStaker memory staker = poolStakers[_user];
    return ((staker.amount * accCalc) / REWARDS_PRECISION) - staker.rewardDebt + userLockedRewards[_user];
  }

  function setHarvestLock(bool _harvestlock) external onlyOwner {
    harvestLock = _harvestlock;
  }

  function setPresale(address _presale) external onlyOwner {
    presaleContract = _presale;
  }

  function setStakeToken(address _stakeToken) external onlyOwner {
    stakeToken = IERC20Metadata(_stakeToken);
  }

  function setLockedTime(uint _time) external onlyOwner {
    lockedTime = _time;
  }

  function setEndBlock(uint _endBlock) external onlyOwner {
    endBlock = _endBlock;
  }

  function setClaimStart(uint _claimStart) external onlyOwner {
    claimStart = _claimStart;
  }

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

  /**
   * @dev To remove users from blacklist which restricts blacklisted users from claiming
   * @param _userToRemoveFromBlacklist addresses of the users
   */
  function removeFromBlacklist(address[] calldata _userToRemoveFromBlacklist) external onlyOwner {
    for (uint256 i = 0; i < _userToRemoveFromBlacklist.length; i++) {
      isBlacklisted[_userToRemoveFromBlacklist[i]] = false;
    }
  }
}
IERC20Metadata.sol 6 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (interfaces/IERC20Metadata.sol)

pragma solidity ^0.8.0;

import "../token/ERC20/extensions/IERC20Metadata.sol";
Ownable.sol 83 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable.sol)

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() {
        _transferOwnership(_msgSender());
    }

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

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

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

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

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

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Internal function without access restriction.
     */
    function _transferOwnership(address newOwner) internal virtual {
        address oldOwner = _owner;
        _owner = newOwner;
        emit OwnershipTransferred(oldOwner, newOwner);
    }
}
ReentrancyGuard.sol 77 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (security/ReentrancyGuard.sol)

pragma solidity ^0.8.0;

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

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

    uint256 private _status;

    constructor() {
        _status = _NOT_ENTERED;
    }

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

    function _nonReentrantBefore() private {
        // On the first call to nonReentrant, _status will be _NOT_ENTERED
        require(_status != _ENTERED, "ReentrancyGuard: reentrant call");

        // Any calls to nonReentrant after this point will fail
        _status = _ENTERED;
    }

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

    /**
     * @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a
     * `nonReentrant` function in the call stack.
     */
    function _reentrancyGuardEntered() internal view returns (bool) {
        return _status == _ENTERED;
    }
}
IERC20Metadata.sol 28 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)

pragma solidity ^0.8.0;

import "../IERC20.sol";

/**
 * @dev Interface for the optional metadata functions from the ERC20 standard.
 *
 * _Available since v4.1._
 */
interface IERC20Metadata is IERC20 {
    /**
     * @dev Returns the name of the token.
     */
    function name() external view returns (string memory);

    /**
     * @dev Returns the symbol of the token.
     */
    function symbol() external view returns (string memory);

    /**
     * @dev Returns the decimals places of the token.
     */
    function decimals() external view returns (uint8);
}
Context.sol 24 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)

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;
    }
}
IERC20.sol 78 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/IERC20.sol)

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

Read Contract

claimStart 0xf04d688f → uint256
endBlock 0x083c6323 → uint256
getRewards 0x79ee54f7 → uint256
harvestLock 0xd0bad4b1 → bool
isBlacklisted 0xfe575a87 → bool
lockedTime 0xa8b38205 → uint256
owner 0x8da5cb5b → address
poolStakers 0xcddb3e7b → uint256, uint256, uint256, uint256, uint256
presaleContract 0x63d9df85 → address
rewardTokensPerBlock 0x29d0fa3e → uint256
stakeToken 0x51ed6a30 → address
tokensStaked 0x99a03316 → uint256
tokensStakedByPresale 0x8a6876ad → uint256
userLockedRewards 0x7d7366aa → uint256

Write Contract 14 functions

These functions modify contract state and require a wallet transaction to execute.

blacklistUsers 0xbb3d676a
address[] _usersToBlacklist
deposit 0xb6b55f25
uint256 _amount
depositByPresale 0x91c61966
address _user
uint256 _amount
harvestRewards 0x2be11ae2
No parameters
removeFromBlacklist 0x89daf799
address[] _userToRemoveFromBlacklist
renounceOwnership 0x715018a6
No parameters
setClaimStart 0xb0aa1e04
uint256 _claimStart
setEndBlock 0xc713aa94
uint256 _endBlock
setHarvestLock 0x979f8d96
bool _harvestlock
setLockedTime 0xdf1dcaa9
uint256 _time
setPresale 0xd5fcc7b6
address _presale
setStakeToken 0x0397d458
address _stakeToken
transferOwnership 0xf2fde38b
address newOwner
withdraw 0x3ccfd60b
No parameters

Recent Transactions

No transactions found for this address