Contract Overview
Latest 25 from a total of 581 transactions
Contract Name:
Staking
Compiler Version
v0.8.10+commit.fc410830
// File @openzeppelin/contracts/token/ERC20/[email protected] // SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (token/ERC20/IERC20.sol) 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 `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); /** * @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 @openzeppelin/contracts/utils/[email protected] // OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://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); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // 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 @openzeppelin/contracts/token/ERC20/utils/[email protected] // OpenZeppelin Contracts v4.4.1 (token/ERC20/utils/SafeERC20.sol) pragma solidity ^0.8.0; /** * @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 @openzeppelin/contracts/utils/[email protected] // 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; } } // File @openzeppelin/contracts/access/[email protected] // OpenZeppelin Contracts v4.4.1 (access/Ownable.sol) pragma solidity ^0.8.0; /** * @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 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 { _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); } } // File @openzeppelin/contracts/utils/math/[email protected] // OpenZeppelin Contracts (last updated v4.5.0) (utils/math/Math.sol) pragma solidity ^0.8.0; /** * @dev Standard math utilities missing in the Solidity language. */ library Math { /** * @dev Returns the largest of two numbers. */ function max(uint256 a, uint256 b) internal pure returns (uint256) { return a >= b ? a : b; } /** * @dev Returns the smallest of two numbers. */ function min(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; } /** * @dev Returns the average of two numbers. The result is rounded towards * zero. */ function average(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b) / 2 can overflow. return (a & b) + (a ^ b) / 2; } /** * @dev Returns the ceiling of the division of two numbers. * * This differs from standard division with `/` in that it rounds up instead * of rounding down. */ function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b - 1) / b can overflow on addition, so we distribute. return a / b + (a % b == 0 ? 0 : 1); } } // File contracts/Staking.sol pragma solidity 0.8.10; /** * @dev Structs to store user staking data. */ struct Deposit { uint256 depositAmount; uint256 depositTime; uint256 endTime; uint32 rate; bool paid; } /** * @dev Structs to store staking contract basic information */ struct StakingContractInfo { string name; address addr; uint32 lockDuration; // in hours uint32 rate; uint8 withdrawFeePercent; } contract Staking is Ownable { using SafeERC20 for IERC20; error AllowanceTooLow(uint256 current, uint256 required); error InsufficientRewardsPleaseAddRewardsOrUseEmergencyExit( uint256 available, uint256 required ); error MustNotBeZero(string param); error NoStakeFoundForUser(address user); error NoZeroAddress(string param); error MaturityDateExpiredPleaseWithdraw(); error StakingIsPaused(); error MustBeLessOrEqual100(); mapping(address => Deposit) private deposits; mapping(address => bool) private hasStaked; StakingContractInfo internal contractInfo; IERC20 public tokenAddress; address public treasury; uint256 public stakedBalance; uint256 public rewardBalance; uint256 public totalParticipants; bool public isStopped; uint256 public constant INTEREST_RATE_CONVERTER = 100; uint256 public constant YEAR_IN_SECONDS = 31536000; /** * @notice Emitted when user stakes new value of tokens */ event Staked( address indexed token, address indexed staker, uint256 stakedAmount ); /** * @notice Emitted when user withdraws his deposit */ event PaidOut( address indexed token, address indexed staker, uint256 amount, uint256 reward ); /** * @notice Emitted when user withdraws his deposit */ event RateAndLockdurationChanged( uint32 newRate, uint32 lockDuration, uint256 time ); /** * @notice Emitted when new amount of rewards is added to contract */ event RewardsAdded(uint256 amount, uint256 time); /** * @notice Emitted when contract is paused/unpaused */ event StakingStatusChanged(bool status, uint256 time); /** * @notice Emitted when owner changes withdraw fee */ event WithdrawFeeChanged(uint8 newFee, uint256 time); modifier withdrawCheck(address from) { if (!hasStaked[from]) revert NoStakeFoundForUser(from); _; } modifier hasAllowance(address allower, uint256 amount) { // Make sure the allower has provided the right allowance. uint256 ourAllowance = tokenAddress.allowance(allower, address(this)); if (amount > ourAllowance) revert AllowanceTooLow(ourAllowance, amount); _; } /** * @param name name of the contract * @param tokenAddress_ contract address of the token * @param rate percentage * @param lockDuration duration in hours */ constructor( string memory name, IERC20 tokenAddress_, uint32 rate, uint32 lockDuration, uint8 withdrawFeePercent, address treasury_ ) { if (withdrawFeePercent > 100) revert MustBeLessOrEqual100(); if (address(tokenAddress_) == address(0)) { revert NoZeroAddress("tokenAddress_"); } if (address(treasury_) == address(0)) { revert NoZeroAddress("treasury_"); } contractInfo = StakingContractInfo( name, address(this), lockDuration, rate, withdrawFeePercent ); tokenAddress = tokenAddress_; treasury = treasury_; } /** * @notice owner can change current withdraw fee for stakers * @param percent withdraw fee percentage */ function setWithdrawFee(uint8 percent) external onlyOwner { if (percent > 100) revert MustBeLessOrEqual100(); contractInfo.withdrawFeePercent = percent; emit WithdrawFeeChanged(percent, block.timestamp); } /** * @notice to set new interest rates and lock duration * @param rate New effective interest rate * @param lockDuration Duration of lock for new deposits in hours * @dev lockduration is in hours */ function setRateAndLockduration(uint32 rate, uint32 lockDuration) external onlyOwner { contractInfo.rate = rate; contractInfo.lockDuration = lockDuration; emit RateAndLockdurationChanged(rate, lockDuration, block.timestamp); } /** * @dev if _status is false contract will be "stopped" and * no new deposits will be allowed */ function changeStakingStatus(bool _status) external onlyOwner { isStopped = _status; emit StakingStatusChanged(_status, block.timestamp); } /** * @param amount Amount to be staked * @dev to stake 'amount' value of tokens * once the user has given allowance to the staking contract */ function stake(uint256 amount) external hasAllowance(msg.sender, amount) { if (amount == 0) revert MustNotBeZero("amount"); if (isStopped) revert StakingIsPaused(); address from = msg.sender; if (hasStaked[from] && (block.timestamp >= deposits[from].endTime)) { revert MaturityDateExpiredPleaseWithdraw(); } uint256 newAmount; if (hasStaked[from]) { newAmount = amount + deposits[from].depositAmount + _calculate(from, block.timestamp); } else { hasStaked[from] = true; newAmount = amount; totalParticipants += 1; } deposits[from] = Deposit({ depositAmount: newAmount, depositTime: block.timestamp, endTime: block.timestamp + uint256(contractInfo.lockDuration) * 3600, rate: contractInfo.rate, paid: false }); stakedBalance = stakedBalance + amount; tokenAddress.safeTransferFrom(from, address(this), amount); emit Staked(address(tokenAddress), from, amount); } function getUserDeposit(address _userAddress) external view returns (Deposit memory) { return deposits[_userAddress]; } function getContractInfo() public view returns (StakingContractInfo memory) { return contractInfo; } /** * @notice Calcule withdraw penalty for user if deposit is withdrawn now * */ function calculateWithdrawFee(address user) public view returns (uint256) { Deposit storage userDeposit = deposits[user]; if (block.timestamp > userDeposit.endTime) { return 0; } return (userDeposit.depositAmount * contractInfo.withdrawFeePercent) / 100; } /** * @param rewardAmount rewards to be added to the staking contract * @dev to add rewards to the staking contract * once the allowance is given to this contract for 'rewardAmount' by the user */ function addReward(uint256 rewardAmount) external hasAllowance(msg.sender, rewardAmount) { if (rewardAmount == 0) revert MustNotBeZero("rewardAmount"); rewardBalance = rewardBalance + rewardAmount; tokenAddress.safeTransferFrom(msg.sender, address(this), rewardAmount); emit RewardsAdded(rewardAmount, block.timestamp); } function withdraw() external withdrawCheck(msg.sender) { address from = msg.sender; uint256 endTime = Math.min(block.timestamp, deposits[from].endTime); uint256 reward = _calculate(from, endTime); if (rewardBalance < reward) { revert InsufficientRewardsPleaseAddRewardsOrUseEmergencyExit( rewardBalance, reward ); } _withdraw(from, reward); } function _withdraw(address from, uint256 reward) private { uint256 penalty = calculateWithdrawFee(from); uint256 amount = deposits[from].depositAmount; uint256 amountAfterPenalty = amount - penalty; stakedBalance = stakedBalance - amount; rewardBalance = rewardBalance - reward; deposits[from].paid = true; hasStaked[from] = false; totalParticipants -= 1; // send user his deposit tokenAddress.safeTransfer(from, amountAfterPenalty + reward); if (penalty > 0) { // send any penalty to treasury wallet tokenAddress.safeTransfer(treasury, penalty); } emit PaidOut(address(tokenAddress), from, amountAfterPenalty, reward); } /** * @notice in case contract runs out of rewards and user is impatient */ function emergencyWithdraw() external withdrawCheck(msg.sender) { _withdraw(msg.sender, 0); } /** * @param user User wallet address * @return totalRewards Rewards from staking if user waits for maturity/end date * @return currentRewards Rewards from staking if user decide to withdraw right now */ function calculateRewards(address user) external view returns (uint256 totalRewards, uint256 currentRewards) { totalRewards = _calculate(user, deposits[user].endTime); currentRewards = _calculate( user, Math.min(block.timestamp, deposits[user].endTime) ); } function _calculate(address from, uint256 endTime) private view returns (uint256 interest) { if (!hasStaked[from]) return 0; Deposit memory deposit = deposits[from]; uint256 time = endTime - deposit.depositTime; interest = (deposit.depositAmount * deposit.rate * time) / (YEAR_IN_SECONDS * INTEREST_RATE_CONVERTER); return interest; } }
[{"inputs":[{"internalType":"string","name":"name","type":"string"},{"internalType":"contract IERC20","name":"tokenAddress_","type":"address"},{"internalType":"uint32","name":"rate","type":"uint32"},{"internalType":"uint32","name":"lockDuration","type":"uint32"},{"internalType":"uint8","name":"withdrawFeePercent","type":"uint8"},{"internalType":"address","name":"treasury_","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"uint256","name":"current","type":"uint256"},{"internalType":"uint256","name":"required","type":"uint256"}],"name":"AllowanceTooLow","type":"error"},{"inputs":[{"internalType":"uint256","name":"available","type":"uint256"},{"internalType":"uint256","name":"required","type":"uint256"}],"name":"InsufficientRewardsPleaseAddRewardsOrUseEmergencyExit","type":"error"},{"inputs":[],"name":"MaturityDateExpiredPleaseWithdraw","type":"error"},{"inputs":[],"name":"MustBeLessOrEqual100","type":"error"},{"inputs":[{"internalType":"string","name":"param","type":"string"}],"name":"MustNotBeZero","type":"error"},{"inputs":[{"internalType":"address","name":"user","type":"address"}],"name":"NoStakeFoundForUser","type":"error"},{"inputs":[{"internalType":"string","name":"param","type":"string"}],"name":"NoZeroAddress","type":"error"},{"inputs":[],"name":"StakingIsPaused","type":"error"},{"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":true,"internalType":"address","name":"token","type":"address"},{"indexed":true,"internalType":"address","name":"staker","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"reward","type":"uint256"}],"name":"PaidOut","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint32","name":"newRate","type":"uint32"},{"indexed":false,"internalType":"uint32","name":"lockDuration","type":"uint32"},{"indexed":false,"internalType":"uint256","name":"time","type":"uint256"}],"name":"RateAndLockdurationChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"time","type":"uint256"}],"name":"RewardsAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":true,"internalType":"address","name":"staker","type":"address"},{"indexed":false,"internalType":"uint256","name":"stakedAmount","type":"uint256"}],"name":"Staked","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bool","name":"status","type":"bool"},{"indexed":false,"internalType":"uint256","name":"time","type":"uint256"}],"name":"StakingStatusChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"newFee","type":"uint8"},{"indexed":false,"internalType":"uint256","name":"time","type":"uint256"}],"name":"WithdrawFeeChanged","type":"event"},{"inputs":[],"name":"INTEREST_RATE_CONVERTER","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"YEAR_IN_SECONDS","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"rewardAmount","type":"uint256"}],"name":"addReward","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"}],"name":"calculateRewards","outputs":[{"internalType":"uint256","name":"totalRewards","type":"uint256"},{"internalType":"uint256","name":"currentRewards","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"}],"name":"calculateWithdrawFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"_status","type":"bool"}],"name":"changeStakingStatus","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"emergencyWithdraw","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getContractInfo","outputs":[{"components":[{"internalType":"string","name":"name","type":"string"},{"internalType":"address","name":"addr","type":"address"},{"internalType":"uint32","name":"lockDuration","type":"uint32"},{"internalType":"uint32","name":"rate","type":"uint32"},{"internalType":"uint8","name":"withdrawFeePercent","type":"uint8"}],"internalType":"struct StakingContractInfo","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_userAddress","type":"address"}],"name":"getUserDeposit","outputs":[{"components":[{"internalType":"uint256","name":"depositAmount","type":"uint256"},{"internalType":"uint256","name":"depositTime","type":"uint256"},{"internalType":"uint256","name":"endTime","type":"uint256"},{"internalType":"uint32","name":"rate","type":"uint32"},{"internalType":"bool","name":"paid","type":"bool"}],"internalType":"struct Deposit","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"isStopped","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"rewardBalance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint32","name":"rate","type":"uint32"},{"internalType":"uint32","name":"lockDuration","type":"uint32"}],"name":"setRateAndLockduration","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint8","name":"percent","type":"uint8"}],"name":"setWithdrawFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"stake","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"stakedBalance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"tokenAddress","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalParticipants","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"treasury","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"}]
Contract Creation Code
608060405234801561001057600080fd5b50600436106101425760003560e01c80639946e341116100b8578063a694fc3a1161007c578063a694fc3a14610291578063aa5c3ab4146102a4578063b5517129146102ad578063c084b10b146102b5578063db2e21bc14610312578063f2fde38b1461031a57600080fd5b80639946e3411461023c5780639ac95d5f1461024f5780639d76ea5814610262578063a26dbf2614610275578063a356be351461027e57600080fd5b806364ab86751161010a57806364ab8675146101c8578063715018a6146101f057806374de4ec4146101f85780637847ea531461020b5780637cc1f867146102165780638da5cb5b1461022b57600080fd5b80631120b7ba146101475780633ccfd60b1461015c5780633f683b6a146101645780635b9f00161461018657806361d027b31461019d575b600080fd5b61015a61015536600461132f565b61032d565b005b61015a6103df565b600a546101719060ff1681565b60405190151581526020015b60405180910390f35b61018f60075481565b60405190815260200161017d565b6006546101b0906001600160a01b031681565b6040516001600160a01b03909116815260200161017d565b6101db6101d6366004611352565b610489565b6040805192835260208301919091520161017d565b61015a6104f6565b61015a61020636600461137b565b61052c565b61018f6301e1338081565b61021e610675565b60405161017d91906113ec565b6000546001600160a01b03166101b0565b61015a61024a366004611461565b61078a565b61018f61025d366004611352565b6107fa565b6005546101b0906001600160a01b031681565b61018f60095481565b61015a61028c366004611497565b610855565b61015a61029f36600461137b565b610903565b61018f60085481565b61018f606481565b6102c86102c3366004611352565b610c31565b60405161017d9190600060a08201905082518252602083015160208301526040830151604083015263ffffffff606084015116606083015260808301511515608083015292915050565b61015a610cd1565b61015a610328366004611352565b610d1a565b6000546001600160a01b031633146103605760405162461bcd60e51b8152600401610357906114ca565b60405180910390fd5b60648160ff1611156103855760405163c382105b60e01b815260040160405180910390fd5b6004805460ff60e01b1916600160e01b60ff841690810291909117909155604080519182524260208301527f8ad0368147aed0dcc0a368b4e9e6a41e213447d027c3a9c804cb833860da2e7891015b60405180910390a150565b3360008181526002602052604090205460ff1661041a57604051633eea258760e01b81526001600160a01b0382166004820152602401610357565b33600081815260016020526040812060020154610438904290610db2565b905060006104468383610dcc565b90508060085410156104795760085460405163334758e560e21b8152600481019190915260248101829052604401610357565b6104838382610ea9565b50505050565b6001600160a01b03811660009081526001602052604081206002015481906104b2908490610dcc565b91506104ef836104ea4260016000886001600160a01b03166001600160a01b0316815260200190815260200160002060020154610db2565b610dcc565b9050915091565b6000546001600160a01b031633146105205760405162461bcd60e51b8152600401610357906114ca565b61052a6000610fec565b565b600554604051636eb1769f60e11b815233600482018190523060248301529183916000916001600160a01b03169063dd62ed3e90604401602060405180830381865afa158015610580573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105a491906114ff565b9050808211156105d15760405163b7f077b960e01b81526004810182905260248101839052604401610357565b8361060e57604051633930c7a960e21b815260206004820152600c60248201526b1c995dd85c99105b5bdd5b9d60a21b6044820152606401610357565b8360085461061c919061152e565b600855600554610637906001600160a01b031633308761103c565b604080518581524260208201527f40df43107e8b4d467127964bd3c966687c0a6a39aaede970755397fd09535e98910160405180910390a150505050565b6040805160a08101825260608082526000602083018190529282018390528101829052608081019190915260036040518060a00160405290816000820180546106bd90611546565b80601f01602080910402602001604051908101604052809291908181526020018280546106e990611546565b80156107365780601f1061070b57610100808354040283529160200191610736565b820191906000526020600020905b81548152906001019060200180831161071957829003601f168201915b5050509183525050600191909101546001600160a01b038116602083015263ffffffff600160a01b820481166040840152600160c01b820416606083015260ff600160e01b90910416608090910152919050565b6000546001600160a01b031633146107b45760405162461bcd60e51b8152600401610357906114ca565b600a805460ff1916821515908117909155604080519182524260208301527fb7d83b7e094cfcfa7dd295e685a79a100995b6110e9708b6c36d9242b394545091016103d4565b6001600160a01b038116600090815260016020526040812060028101544211156108275750600092915050565b600454815460649161084491600160e01b90910460ff1690611581565b61084e91906115a0565b9392505050565b6000546001600160a01b0316331461087f5760405162461bcd60e51b8152600401610357906114ca565b6004805467ffffffffffffffff60a01b1916600160c01b63ffffffff85811691820263ffffffff60a01b191692909217600160a01b9285169283021790925560408051928352602083019190915242908201527f3546ce97c02e1ee7939717f17c835b6d6bd387a0e3b0410c5d6068aef18ceb409060600160405180910390a15050565b600554604051636eb1769f60e11b815233600482018190523060248301529183916000916001600160a01b03169063dd62ed3e90604401602060405180830381865afa158015610957573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061097b91906114ff565b9050808211156109a85760405163b7f077b960e01b81526004810182905260248101839052604401610357565b836109df57604051633930c7a960e21b8152602060048201526006602482015265185b5bdd5b9d60d21b6044820152606401610357565b600a5460ff1615610a0357604051636bea2ae560e01b815260040160405180910390fd5b3360008181526002602052604090205460ff168015610a3d57506001600160a01b0381166000908152600160205260409020600201544210155b15610a5b5760405163e54fd7b360e01b815260040160405180910390fd5b6001600160a01b03811660009081526002602052604081205460ff1615610aba57610a868242610dcc565b6001600160a01b038316600090815260016020526040902054610aa9908861152e565b610ab3919061152e565b9050610af9565b506001600160a01b0381166000908152600260205260408120805460ff1916600190811790915560098054889390610af390849061152e565b90915550505b6040805160a0810182528281524260208201526004549091820190610b2d90600160a01b900463ffffffff16610e10611581565b610b37904261152e565b815260045463ffffffff600160c01b9091048116602080840191909152600060409384018190526001600160a01b03871681526001808352908490208551815591850151908201559183015160028301556060830151600392909201805460809094015115156401000000000264ffffffffff199094169290911691909117919091179055600754610bca90879061152e565b600755600554610be5906001600160a01b031683308961103c565b6005546040518781526001600160a01b038481169216907f5dac0c1b1112564a045ba943c9d50270893e8e826c49be8e7073adc713ab7bd79060200160405180910390a3505050505050565b610c6b6040518060a00160405280600081526020016000815260200160008152602001600063ffffffff1681526020016000151581525090565b506001600160a01b0316600090815260016020818152604092839020835160a08101855281548152928101549183019190915260028101549282019290925260039091015463ffffffff81166060830152640100000000900460ff161515608082015290565b3360008181526002602052604090205460ff16610d0c57604051633eea258760e01b81526001600160a01b0382166004820152602401610357565b610d17336000610ea9565b50565b6000546001600160a01b03163314610d445760405162461bcd60e51b8152600401610357906114ca565b6001600160a01b038116610da95760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610357565b610d1781610fec565b6000818310610dc15781610dc3565b825b90505b92915050565b6001600160a01b03821660009081526002602052604081205460ff16610df457506000610dc6565b6001600160a01b0383166000908152600160208181526040808420815160a08101835281548152938101549284018390526002810154918401919091526003015463ffffffff81166060840152640100000000900460ff1615156080830152909190610e6090856115c2565b9050610e7160646301e13380611581565b81836060015163ffffffff168460000151610e8c9190611581565b610e969190611581565b610ea091906115a0565b95945050505050565b6000610eb4836107fa565b6001600160a01b038416600090815260016020526040812054919250610eda83836115c2565b905081600754610eea91906115c2565b600755600854610efb9085906115c2565b6008556001600160a01b0385166000908152600160208181526040808420600301805464ff00000000191664010000000017905560029091528220805460ff191690556009805491929091610f519084906115c2565b90915550610f78905085610f65868461152e565b6005546001600160a01b031691906110a7565b8215610f9b57600654600554610f9b916001600160a01b039182169116856110a7565b60055460408051838152602081018790526001600160a01b038881169316917f85ab59351da11b79336de7647172267c33bf533ee87d9d292441c2672177159b910160405180910390a35050505050565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6040516001600160a01b03808516602483015283166044820152606481018290526104839085906323b872dd60e01b906084015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b0319909316929092179091526110dc565b6040516001600160a01b0383166024820152604481018290526110d790849063a9059cbb60e01b90606401611070565b505050565b6000611131826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166111ae9092919063ffffffff16565b8051909150156110d7578080602001905181019061114f91906115d9565b6110d75760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610357565b60606111bd84846000856111c5565b949350505050565b6060824710156112265760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401610357565b6001600160a01b0385163b61127d5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610357565b600080866001600160a01b0316858760405161129991906115f6565b60006040518083038185875af1925050503d80600081146112d6576040519150601f19603f3d011682016040523d82523d6000602084013e6112db565b606091505b50915091506112eb8282866112f6565b979650505050505050565b6060831561130557508161084e565b8251156113155782518084602001fd5b8160405162461bcd60e51b81526004016103579190611612565b60006020828403121561134157600080fd5b813560ff8116811461084e57600080fd5b60006020828403121561136457600080fd5b81356001600160a01b038116811461084e57600080fd5b60006020828403121561138d57600080fd5b5035919050565b60005b838110156113af578181015183820152602001611397565b838111156104835750506000910152565b600081518084526113d8816020860160208601611394565b601f01601f19169290920160200192915050565b602081526000825160a0602084015261140860c08401826113c0565b905060018060a01b036020850151166040840152604084015163ffffffff8082166060860152806060870151166080860152505060ff60808501511660a08401528091505092915050565b8015158114610d1757600080fd5b60006020828403121561147357600080fd5b813561084e81611453565b803563ffffffff8116811461149257600080fd5b919050565b600080604083850312156114aa57600080fd5b6114b38361147e565b91506114c16020840161147e565b90509250929050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60006020828403121561151157600080fd5b5051919050565b634e487b7160e01b600052601160045260246000fd5b6000821982111561154157611541611518565b500190565b600181811c9082168061155a57607f821691505b6020821081141561157b57634e487b7160e01b600052602260045260246000fd5b50919050565b600081600019048311821515161561159b5761159b611518565b500290565b6000826115bd57634e487b7160e01b600052601260045260246000fd5b500490565b6000828210156115d4576115d4611518565b500390565b6000602082840312156115eb57600080fd5b815161084e81611453565b60008251611608818460208701611394565b9190910192915050565b602081526000610dc360208301846113c056fea2646970667358221220a5918a9d668ec46599bf0e86c6c665bf4d8f740c0cca4f62d0c3350b2bb0b61a64736f6c634300080a0033
Age | Block | Fee Address | BC Fee Address | Voting Power | Jailed | Incoming |
---|
Make sure to use the "Vote Down" button for any spammy posts, and the "Vote Up" for
interesting conversations.