More Info
Private Name Tags
ContractCreator
Latest 1 from a total of 1 transactions
Transaction Hash |
Method
|
Block
|
From
|
To
|
|||||
---|---|---|---|---|---|---|---|---|---|
Claim Rewards | 20363752 | 162 days ago | IN | 0 ETH | 0.00045953 |
View more zero value Internal Transactions in Advanced View mode
Advanced mode:
Loading...
Loading
Contract Name:
TokenStakingPool
Compiler Version
v0.8.20+commit.a1b79de6
Optimization Enabled:
Yes with 200 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: No-License // File: interfaces/IPoolExtension.sol pragma solidity ^0.8.20; interface IPoolExtension { function setShare( address wallet, uint256 balanceChange, bool isRemoving ) external; } // File: interfaces/ITokenStakingPool.sol pragma solidity ^0.8.20; /// @author RetreebInc /// @title Interface Staking Platform with fixed APY and lockup interface ITokenStakingPool { /** * @notice function that returns the amount of total Staked tokens * for a specific user * @param stakeHolder, address of the user to check * @return uint amount of the total deposited Tokens by the caller */ function amountStaked(address stakeHolder) external view returns (uint); /** * @notice function that returns the amount of total Staked tokens * on the smart contract * @return uint amount of the total deposited Tokens */ function totalDeposited() external view returns (uint); /** * @notice function that returns the amount of pending rewards * that can be claimed by the user * @param stakeHolder, address of the user to be checked * @return uint amount of claimable rewards */ function rewardOf(address stakeHolder) external view returns (uint); /** * @notice function that claims pending rewards * @dev transfer the pending rewards to the `msg.sender` */ function claimRewards() external; /** * @dev Emitted when `amount` tokens are deposited into * staking platform */ event Deposit(address indexed owner, uint amount); /** * @dev Emitted when user withdraw deposited `amount` */ event Withdraw(address indexed owner, uint amount); /** * @dev Emitted when `stakeHolder` claim rewards */ event Claim(address indexed stakeHolder, uint amount); /** * @dev Emitted when staking has started */ event StartStaking(uint startPeriod, uint endingPeriod); } // File: @openzeppelin/contracts/utils/Address.sol // OpenZeppelin Contracts (last updated v5.0.0) (utils/Address.sol) pragma solidity ^0.8.20; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev The ETH balance of the account is not enough to perform the operation. */ error AddressInsufficientBalance(address account); /** * @dev There's no code at `target` (it is not a contract). */ error AddressEmptyCode(address target); /** * @dev A call to an address target failed. The target may have reverted. */ error FailedInnerCall(); /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { if (address(this).balance < amount) { revert AddressInsufficientBalance(address(this)); } (bool success, ) = recipient.call{value: amount}(""); if (!success) { revert FailedInnerCall(); } } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason or custom error, it is bubbled * up by this function (like regular Solidity function calls). However, if * the call reverted with no returned reason, this function reverts with a * {FailedInnerCall} error. * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCallWithValue(target, data, 0); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { if (address(this).balance < value) { revert AddressInsufficientBalance(address(this)); } (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResultFromTarget(target, success, returndata); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResultFromTarget(target, success, returndata); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResultFromTarget(target, success, returndata); } /** * @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target * was not a contract or bubbling up the revert reason (falling back to {FailedInnerCall}) in case of an * unsuccessful call. */ function verifyCallResultFromTarget( address target, bool success, bytes memory returndata ) internal view returns (bytes memory) { if (!success) { _revert(returndata); } else { // only check if target is a contract if the call was successful and the return data is empty // otherwise we already know that it was a contract if (returndata.length == 0 && target.code.length == 0) { revert AddressEmptyCode(target); } return returndata; } } /** * @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the * revert reason or with a default {FailedInnerCall} error. */ function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) { if (!success) { _revert(returndata); } else { return returndata; } } /** * @dev Reverts with returndata if present. Otherwise reverts with {FailedInnerCall}. */ function _revert(bytes memory returndata) private pure { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly /// @solidity memory-safe-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert FailedInnerCall(); } } } // File: @openzeppelin/contracts/token/ERC20/extensions/IERC20Permit.sol // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/IERC20Permit.sol) pragma solidity ^0.8.20; /** * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612]. * * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't * need to send a transaction, and thus is not required to hold Ether at all. * * ==== Security Considerations * * There are two important considerations concerning the use of `permit`. The first is that a valid permit signature * expresses an allowance, and it should not be assumed to convey additional meaning. In particular, it should not be * considered as an intention to spend the allowance in any specific way. The second is that because permits have * built-in replay protection and can be submitted by anyone, they can be frontrun. A protocol that uses permits should * take this into consideration and allow a `permit` call to fail. Combining these two aspects, a pattern that may be * generally recommended is: * * ```solidity * function doThingWithPermit(..., uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public { * try token.permit(msg.sender, address(this), value, deadline, v, r, s) {} catch {} * doThing(..., value); * } * * function doThing(..., uint256 value) public { * token.safeTransferFrom(msg.sender, address(this), value); * ... * } * ``` * * Observe that: 1) `msg.sender` is used as the owner, leaving no ambiguity as to the signer intent, and 2) the use of * `try/catch` allows the permit to fail and makes the code tolerant to frontrunning. (See also * {SafeERC20-safeTransferFrom}). * * Additionally, note that smart contract wallets (such as Argent or Safe) are not able to produce permit signatures, so * contracts should have entry points that don't rely on permit. */ interface IERC20Permit { /** * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens, * given ``owner``'s signed approval. * * IMPORTANT: The same issues {IERC20-approve} has related to transaction * ordering also apply here. * * Emits an {Approval} event. * * Requirements: * * - `spender` cannot be the zero address. * - `deadline` must be a timestamp in the future. * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner` * over the EIP712-formatted function arguments. * - the signature must use ``owner``'s current nonce (see {nonces}). * * For more information on the signature format, see the * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP * section]. * * CAUTION: See Security Considerations above. */ function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external; /** * @dev Returns the current nonce for `owner`. This value must be * included whenever a signature is generated for {permit}. * * Every successful call to {permit} increases ``owner``'s nonce by one. This * prevents a signature from being used multiple times. */ function nonces(address owner) external view returns (uint256); /** * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}. */ // solhint-disable-next-line func-name-mixedcase function DOMAIN_SEPARATOR() external view returns (bytes32); } // File: @openzeppelin/contracts/token/ERC20/IERC20.sol // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/IERC20.sol) pragma solidity ^0.8.20; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); /** * @dev Returns the value of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the value of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves a `value` amount of tokens from the caller's account to `to`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address to, uint256 value) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets a `value` amount of tokens as the allowance of `spender` over the * caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 value) external returns (bool); /** * @dev Moves a `value` amount of tokens from `from` to `to` using the * allowance mechanism. `value` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address from, address to, uint256 value) external returns (bool); } // File: @openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/utils/SafeERC20.sol) pragma solidity ^0.8.20; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20 { using Address for address; /** * @dev An operation with an ERC20 token failed. */ error SafeERC20FailedOperation(address token); /** * @dev Indicates a failed `decreaseAllowance` request. */ error SafeERC20FailedDecreaseAllowance(address spender, uint256 currentAllowance, uint256 requestedDecrease); /** * @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value, * non-reverting calls are assumed to be successful. */ function safeTransfer(IERC20 token, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeCall(token.transfer, (to, value))); } /** * @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the * calling contract. If `token` returns no value, non-reverting calls are assumed to be successful. */ function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeCall(token.transferFrom, (from, to, value))); } /** * @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value, * non-reverting calls are assumed to be successful. */ function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 oldAllowance = token.allowance(address(this), spender); forceApprove(token, spender, oldAllowance + value); } /** * @dev Decrease the calling contract's allowance toward `spender` by `requestedDecrease`. If `token` returns no * value, non-reverting calls are assumed to be successful. */ function safeDecreaseAllowance(IERC20 token, address spender, uint256 requestedDecrease) internal { unchecked { uint256 currentAllowance = token.allowance(address(this), spender); if (currentAllowance < requestedDecrease) { revert SafeERC20FailedDecreaseAllowance(spender, currentAllowance, requestedDecrease); } forceApprove(token, spender, currentAllowance - requestedDecrease); } } /** * @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value, * non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval * to be set to zero before setting it to a non-zero value, such as USDT. */ function forceApprove(IERC20 token, address spender, uint256 value) internal { bytes memory approvalCall = abi.encodeCall(token.approve, (spender, value)); if (!_callOptionalReturnBool(token, approvalCall)) { _callOptionalReturn(token, abi.encodeCall(token.approve, (spender, 0))); _callOptionalReturn(token, approvalCall); } } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function _callOptionalReturn(IERC20 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data); if (returndata.length != 0 && !abi.decode(returndata, (bool))) { revert SafeERC20FailedOperation(address(token)); } } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). * * This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead. */ function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We cannot use {Address-functionCall} here since this should return false // and not revert is the subcall reverts. (bool success, bytes memory returndata) = address(token).call(data); return success && (returndata.length == 0 || abi.decode(returndata, (bool))) && address(token).code.length > 0; } } // File: @openzeppelin/contracts/utils/Context.sol // OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol) pragma solidity ^0.8.20; /** * @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; } function _contextSuffixLength() internal view virtual returns (uint256) { return 0; } } // File: @openzeppelin/contracts/access/Ownable.sol // OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol) pragma solidity ^0.8.20; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * The initial owner is set to the address provided by the deployer. This can * later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; /** * @dev The caller account is not authorized to perform an operation. */ error OwnableUnauthorizedAccount(address account); /** * @dev The owner is not a valid owner account. (eg. `address(0)`) */ error OwnableInvalidOwner(address owner); event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the address provided by the deployer as the initial owner. */ constructor(address initialOwner) { if (initialOwner == address(0)) { revert OwnableInvalidOwner(address(0)); } _transferOwnership(initialOwner); } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { _checkOwner(); _; } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if the sender is not the owner. */ function _checkOwner() internal view virtual { if (owner() != _msgSender()) { revert OwnableUnauthorizedAccount(_msgSender()); } } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby disabling any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _transferOwnership(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { if (newOwner == address(0)) { revert OwnableInvalidOwner(address(0)); } _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } } // File: TokenStakingPool.sol pragma solidity ^0.8.20; /// @author Juan Snaider Cruickshank /// Github: jscrui | Telegram: jscrui /// @title Token Staking Pool for UNREKT PROTOCOL /// @dev This contract is an extension from StakingPool.sol contract TokenStakingPool is IPoolExtension, ITokenStakingPool, Ownable { using SafeERC20 for IERC20; address public immutable mainPool; IERC20 public immutable token; uint public fixedAPR; uint private _totalStaked; mapping(address => uint) public staked; mapping(address => uint) private _rewardsToClaim; mapping(address => uint) public _userStartTime; modifier onlyPool() { require(_msgSender() == mainPool, 'Unauthorized'); _; } /** * @notice constructor contains all the parameters of the staking platform * @dev all parameters are immutable * @param _token, address of the token to be staked * @param _fixedAPR, the fixed APY (in %) 10 = 10%, 50 = 50% */ constructor(address _mainPool, IERC20 _token, uint _fixedAPR) Ownable(msg.sender) { mainPool = _mainPool; token = _token; fixedAPR = _fixedAPR; } function setShare( address wallet, uint256 balanceChange, bool isRemoving ) external override onlyPool { if (isRemoving) { _withdraw(wallet, balanceChange); } else { _deposit(wallet, balanceChange); } } /** * @notice function that allows a user to deposit tokens * @dev user must first approve the amount to deposit before calling this function, * cannot exceed the `maxAmountStaked` * @param amount, the amount to be deposited * @dev that the amount deposited should greater than 0 */ function _deposit(address wallet, uint amount) internal { require(amount > 0, 'Amount must be greater than 0'); if (_userStartTime[wallet] == 0) { _userStartTime[wallet] = block.timestamp; } _updateRewards(wallet); staked[wallet] += amount; _totalStaked += amount; emit Deposit(wallet, amount); } /** * @notice function that allows a user to withdraw its initial deposit * @param amount, amount to withdraw * @dev `amount` must be higher than `0` * @dev `amount` must be lower or equal to the amount staked * withdraw reset all states variable for the `msg.sender` to 0, and claim rewards * if rewards to claim */ function _withdraw(address wallet, uint amount) internal { require(amount > 0, 'Amount must be greater than 0'); require(amount <= staked[wallet], 'Amount higher than stakedAmount'); _updateRewards(wallet); if (_rewardsToClaim[wallet] > 0) { _claimRewards(wallet); } _totalStaked -= amount; staked[wallet] -= amount; emit Withdraw(wallet, amount); } /** * @notice claim all remaining balance on the contract * Residual balance is all the remaining tokens that have not been distributed * (e.g, in case the number of stakeholders is not sufficient) * @dev Can only be called after the end of the staking period * Cannot claim initial stakeholders deposit */ function withdrawResidualBalance() external onlyOwner { uint residualBalance = token.balanceOf(address(this)) - _totalStaked; require(residualBalance > 0, 'No residual Balance to withdraw'); token.safeTransfer(_msgSender(), residualBalance); } /** * @notice function that allows the owner to set the APY * @param _newAPR, the new APY to be set (in %) 10 = 10%, 50 = 50 */ function setAPR(uint8 _newAPR) external onlyOwner { fixedAPR = _newAPR; } /** * @notice function that returns the amount of total Staked tokens * for a specific user * @param stakeHolder, address of the user to check * @return uint amount of the total deposited Tokens by the caller */ function amountStaked( address stakeHolder ) external view override returns (uint) { return staked[stakeHolder]; } /** * @notice function that returns the amount of total Staked tokens * on the smart contract * @return uint amount of the total deposited Tokens */ function totalDeposited() external view override returns (uint) { return _totalStaked; } /** * @notice function that returns the amount of pending rewards * that can be claimed by the user * @param stakeHolder, address of the user to be checked * @return uint amount of claimable rewards */ function rewardOf(address stakeHolder) external view override returns (uint) { return _calculateRewards(stakeHolder); } /** * @notice function that claims pending rewards * @dev transfer the pending rewards to the `msg.sender` */ function claimRewards() external override { _claimRewards(_msgSender()); } /** * @notice calculate rewards based on the `fixedAPR` * @param stakeHolder, address of the user to be checked * @return uint amount of claimable tokens of the specified address */ function _calculateRewards(address stakeHolder) internal view returns (uint) { uint _timeStaked = block.timestamp - _userStartTime[stakeHolder]; return ((staked[stakeHolder] * fixedAPR * _timeStaked) / 365 days / 100) + _rewardsToClaim[stakeHolder]; } /** * @notice internal function that claims pending rewards * @dev transfer the pending rewards to the user address */ function _claimRewards(address stakeHolder) private { _updateRewards(stakeHolder); uint rewardsToClaim = _rewardsToClaim[stakeHolder]; require(rewardsToClaim > 0, 'Nothing to claim'); _rewardsToClaim[stakeHolder] = 0; token.safeTransfer(stakeHolder, rewardsToClaim); emit Claim(stakeHolder, rewardsToClaim); } /** * @notice function that update pending rewards * and shift them to rewardsToClaim * @dev update rewards claimable * and check the time spent since deposit for the `msg.sender` */ function _updateRewards(address stakeHolder) private { _rewardsToClaim[stakeHolder] = _calculateRewards(stakeHolder); _userStartTime[stakeHolder] = block.timestamp; } /** * @notice this function allows to withdraw all the * tokens of the contract in case of an emergency. * @dev Its only callable by the Owner. */ function withdrawTokens(uint256 _amount) external onlyOwner { IERC20 _token = IERC20(token); _token.safeTransfer( _msgSender(), _amount == 0 ? _token.balanceOf(address(this)) : _amount ); } }
{ "optimizer": { "enabled": true, "runs": 200 }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } } }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[{"internalType":"address","name":"_mainPool","type":"address"},{"internalType":"contract IERC20","name":"_token","type":"address"},{"internalType":"uint256","name":"_fixedAPR","type":"uint256"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"address","name":"target","type":"address"}],"name":"AddressEmptyCode","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"AddressInsufficientBalance","type":"error"},{"inputs":[],"name":"FailedInnerCall","type":"error"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"OwnableInvalidOwner","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"OwnableUnauthorizedAccount","type":"error"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"SafeERC20FailedOperation","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"stakeHolder","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Claim","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Deposit","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"startPeriod","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"endingPeriod","type":"uint256"}],"name":"StartStaking","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Withdraw","type":"event"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"_userStartTime","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"stakeHolder","type":"address"}],"name":"amountStaked","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"claimRewards","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"fixedAPR","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"mainPool","outputs":[{"internalType":"address","name":"","type":"address"}],"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":[{"internalType":"address","name":"stakeHolder","type":"address"}],"name":"rewardOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint8","name":"_newAPR","type":"uint8"}],"name":"setAPR","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"wallet","type":"address"},{"internalType":"uint256","name":"balanceChange","type":"uint256"},{"internalType":"bool","name":"isRemoving","type":"bool"}],"name":"setShare","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"staked","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"token","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalDeposited","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":"withdrawResidualBalance","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"withdrawTokens","outputs":[],"stateMutability":"nonpayable","type":"function"}]
Contract Creation Code
60c060405234801561000f575f80fd5b50604051610eba380380610eba83398101604081905261002e916100de565b338061005357604051631e4fbdf760e01b81525f600482015260240160405180910390fd5b61005c81610078565b506001600160a01b03928316608052911660a05260015561011e565b5f80546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6001600160a01b03811681146100db575f80fd5b50565b5f805f606084860312156100f0575f80fd5b83516100fb816100c7565b602085015190935061010c816100c7565b80925050604084015190509250925092565b60805160a051610d586101625f395f818161024a015281816103190152818161045701528181610520015261095901525f81816101cd01526102870152610d585ff3fe608060405234801561000f575f80fd5b50600436106100fb575f3560e01c806398807d8411610093578063f2fde38b11610063578063f2fde38b1461022a578063fb468ac31461023d578063fc0c546a14610245578063ff50abdc1461026c575f80fd5b806398807d84146101a9578063a5a302d3146101c8578063bd8d99f4146101ef578063ef40a67014610202575f80fd5b8063315a095d116100ce578063315a095d14610162578063372500ab14610175578063715018a61461017d5780638da5cb5b14610185575f80fd5b8063118ab4e1146100ff5780631d62ebd91461011b578063238a6d9e1461012e57806329cc05cf1461014d575b5f80fd5b61010860015481565b6040519081526020015b60405180910390f35b610108610129366004610bba565b610274565b61010861013c366004610bba565b60056020525f908152604090205481565b61016061015b366004610be0565b610284565b005b610160610170366004610c1d565b61030f565b6101606103c3565b6101606103ce565b5f546001600160a01b03165b6040516001600160a01b039091168152602001610112565b6101086101b7366004610bba565b60036020525f908152604090205481565b6101917f000000000000000000000000000000000000000000000000000000000000000081565b6101606101fd366004610c34565b6103df565b610108610210366004610bba565b6001600160a01b03165f9081526003602052604090205490565b610160610238366004610bba565b6103ef565b61016061042c565b6101917f000000000000000000000000000000000000000000000000000000000000000081565b600254610108565b5f61027e8261054f565b92915050565b337f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316146102f05760405162461bcd60e51b815260206004820152600c60248201526b155b985d5d1a1bdc9a5e995960a21b60448201526064015b60405180910390fd5b80156103055761030083836105e1565b505050565b610300838361074b565b61031761085b565b7f00000000000000000000000000000000000000000000000000000000000000006103bf33831561034857836103ae565b6040516370a0823160e01b81523060048201526001600160a01b038416906370a0823190602401602060405180830381865afa15801561038a573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906103ae9190610c54565b6001600160a01b0384169190610887565b5050565b6103cc336108d9565b565b6103d661085b565b6103cc5f6109bb565b6103e761085b565b60ff16600155565b6103f761085b565b6001600160a01b03811661042057604051631e4fbdf760e01b81525f60048201526024016102e7565b610429816109bb565b50565b61043461085b565b6002546040516370a0823160e01b81523060048201525f91906001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016906370a0823190602401602060405180830381865afa15801561049c573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906104c09190610c54565b6104ca9190610c7f565b90505f811161051b5760405162461bcd60e51b815260206004820152601f60248201527f4e6f20726573696475616c2042616c616e636520746f2077697468647261770060448201526064016102e7565b6104297f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03163383610887565b6001600160a01b0381165f9081526005602052604081205481906105739042610c7f565b6001600160a01b0384165f90815260046020908152604080832054600154600390935292205492935090916064916301e133809185916105b291610c92565b6105bc9190610c92565b6105c69190610ca9565b6105d09190610ca9565b6105da9190610cc8565b9392505050565b5f81116106305760405162461bcd60e51b815260206004820152601d60248201527f416d6f756e74206d7573742062652067726561746572207468616e203000000060448201526064016102e7565b6001600160a01b0382165f908152600360205260409020548111156106975760405162461bcd60e51b815260206004820152601f60248201527f416d6f756e7420686967686572207468616e207374616b6564416d6f756e740060448201526064016102e7565b6106a082610a0a565b6001600160a01b0382165f90815260046020526040902054156106c6576106c6826108d9565b8060025f8282546106d79190610c7f565b90915550506001600160a01b0382165f9081526003602052604081208054839290610703908490610c7f565b90915550506040518181526001600160a01b038316907f884edad9ce6fa2440d8a54cc123490eb96d2768479d49ff9c7366125a9424364906020015b60405180910390a25050565b5f811161079a5760405162461bcd60e51b815260206004820152601d60248201527f416d6f756e74206d7573742062652067726561746572207468616e203000000060448201526064016102e7565b6001600160a01b0382165f9081526005602052604081205490036107d3576001600160a01b0382165f9081526005602052604090204290555b6107dc82610a0a565b6001600160a01b0382165f9081526003602052604081208054839290610803908490610cc8565b925050819055508060025f82825461081b9190610cc8565b90915550506040518181526001600160a01b038316907fe1fffcc4923d04b559f4d29a8bfc6cda04eb5b0d3c460751c2402c5c5cc9109c9060200161073f565b5f546001600160a01b031633146103cc5760405163118cdaa760e01b81523360048201526024016102e7565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b179052610300908490610a3c565b6108e281610a0a565b6001600160a01b0381165f908152600460205260409020548061093a5760405162461bcd60e51b815260206004820152601060248201526f4e6f7468696e6720746f20636c61696d60801b60448201526064016102e7565b6001600160a01b038083165f90815260046020526040812055610980907f0000000000000000000000000000000000000000000000000000000000000000168383610887565b816001600160a01b03167f47cee97cb7acd717b3c0aa1435d004cd5b3c8c57d70dbceb4e4458bbd60e39d48260405161073f91815260200190565b5f80546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b610a138161054f565b6001600160a01b039091165f908152600460209081526040808320939093556005905220429055565b5f610a506001600160a01b03841683610a9d565b905080515f14158015610a74575080806020019051810190610a729190610cdb565b155b1561030057604051635274afe760e01b81526001600160a01b03841660048201526024016102e7565b60606105da83835f845f80856001600160a01b03168486604051610ac19190610cf6565b5f6040518083038185875af1925050503d805f8114610afb576040519150601f19603f3d011682016040523d82523d5f602084013e610b00565b606091505b5091509150610b10868383610b1a565b9695505050505050565b606082610b2f57610b2a82610b76565b6105da565b8151158015610b4657506001600160a01b0384163b155b15610b6f57604051639996b31560e01b81526001600160a01b03851660048201526024016102e7565b50806105da565b805115610b865780518082602001fd5b604051630a12f52160e11b815260040160405180910390fd5b80356001600160a01b0381168114610bb5575f80fd5b919050565b5f60208284031215610bca575f80fd5b6105da82610b9f565b8015158114610429575f80fd5b5f805f60608486031215610bf2575f80fd5b610bfb84610b9f565b9250602084013591506040840135610c1281610bd3565b809150509250925092565b5f60208284031215610c2d575f80fd5b5035919050565b5f60208284031215610c44575f80fd5b813560ff811681146105da575f80fd5b5f60208284031215610c64575f80fd5b5051919050565b634e487b7160e01b5f52601160045260245ffd5b8181038181111561027e5761027e610c6b565b808202811582820484141761027e5761027e610c6b565b5f82610cc357634e487b7160e01b5f52601260045260245ffd5b500490565b8082018082111561027e5761027e610c6b565b5f60208284031215610ceb575f80fd5b81516105da81610bd3565b5f82515f5b81811015610d155760208186018101518583015201610cfb565b505f92019182525091905056fea264697066735822122042da4fb1fdb7edb1231387e629e2dc0aebf6d229290c619cf59570d2853d332064736f6c63430008140033000000000000000000000000db47e4ed1beedb2c04fd74ff7a606fccdabd63d200000000000000000000000088a4e88d3e5ad70b5c78f9009eddb5816f3cd6210000000000000000000000000000000000000000000000000000000000000005
Deployed Bytecode
0x608060405234801561000f575f80fd5b50600436106100fb575f3560e01c806398807d8411610093578063f2fde38b11610063578063f2fde38b1461022a578063fb468ac31461023d578063fc0c546a14610245578063ff50abdc1461026c575f80fd5b806398807d84146101a9578063a5a302d3146101c8578063bd8d99f4146101ef578063ef40a67014610202575f80fd5b8063315a095d116100ce578063315a095d14610162578063372500ab14610175578063715018a61461017d5780638da5cb5b14610185575f80fd5b8063118ab4e1146100ff5780631d62ebd91461011b578063238a6d9e1461012e57806329cc05cf1461014d575b5f80fd5b61010860015481565b6040519081526020015b60405180910390f35b610108610129366004610bba565b610274565b61010861013c366004610bba565b60056020525f908152604090205481565b61016061015b366004610be0565b610284565b005b610160610170366004610c1d565b61030f565b6101606103c3565b6101606103ce565b5f546001600160a01b03165b6040516001600160a01b039091168152602001610112565b6101086101b7366004610bba565b60036020525f908152604090205481565b6101917f000000000000000000000000db47e4ed1beedb2c04fd74ff7a606fccdabd63d281565b6101606101fd366004610c34565b6103df565b610108610210366004610bba565b6001600160a01b03165f9081526003602052604090205490565b610160610238366004610bba565b6103ef565b61016061042c565b6101917f00000000000000000000000088a4e88d3e5ad70b5c78f9009eddb5816f3cd62181565b600254610108565b5f61027e8261054f565b92915050565b337f000000000000000000000000db47e4ed1beedb2c04fd74ff7a606fccdabd63d26001600160a01b0316146102f05760405162461bcd60e51b815260206004820152600c60248201526b155b985d5d1a1bdc9a5e995960a21b60448201526064015b60405180910390fd5b80156103055761030083836105e1565b505050565b610300838361074b565b61031761085b565b7f00000000000000000000000088a4e88d3e5ad70b5c78f9009eddb5816f3cd6216103bf33831561034857836103ae565b6040516370a0823160e01b81523060048201526001600160a01b038416906370a0823190602401602060405180830381865afa15801561038a573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906103ae9190610c54565b6001600160a01b0384169190610887565b5050565b6103cc336108d9565b565b6103d661085b565b6103cc5f6109bb565b6103e761085b565b60ff16600155565b6103f761085b565b6001600160a01b03811661042057604051631e4fbdf760e01b81525f60048201526024016102e7565b610429816109bb565b50565b61043461085b565b6002546040516370a0823160e01b81523060048201525f91906001600160a01b037f00000000000000000000000088a4e88d3e5ad70b5c78f9009eddb5816f3cd62116906370a0823190602401602060405180830381865afa15801561049c573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906104c09190610c54565b6104ca9190610c7f565b90505f811161051b5760405162461bcd60e51b815260206004820152601f60248201527f4e6f20726573696475616c2042616c616e636520746f2077697468647261770060448201526064016102e7565b6104297f00000000000000000000000088a4e88d3e5ad70b5c78f9009eddb5816f3cd6216001600160a01b03163383610887565b6001600160a01b0381165f9081526005602052604081205481906105739042610c7f565b6001600160a01b0384165f90815260046020908152604080832054600154600390935292205492935090916064916301e133809185916105b291610c92565b6105bc9190610c92565b6105c69190610ca9565b6105d09190610ca9565b6105da9190610cc8565b9392505050565b5f81116106305760405162461bcd60e51b815260206004820152601d60248201527f416d6f756e74206d7573742062652067726561746572207468616e203000000060448201526064016102e7565b6001600160a01b0382165f908152600360205260409020548111156106975760405162461bcd60e51b815260206004820152601f60248201527f416d6f756e7420686967686572207468616e207374616b6564416d6f756e740060448201526064016102e7565b6106a082610a0a565b6001600160a01b0382165f90815260046020526040902054156106c6576106c6826108d9565b8060025f8282546106d79190610c7f565b90915550506001600160a01b0382165f9081526003602052604081208054839290610703908490610c7f565b90915550506040518181526001600160a01b038316907f884edad9ce6fa2440d8a54cc123490eb96d2768479d49ff9c7366125a9424364906020015b60405180910390a25050565b5f811161079a5760405162461bcd60e51b815260206004820152601d60248201527f416d6f756e74206d7573742062652067726561746572207468616e203000000060448201526064016102e7565b6001600160a01b0382165f9081526005602052604081205490036107d3576001600160a01b0382165f9081526005602052604090204290555b6107dc82610a0a565b6001600160a01b0382165f9081526003602052604081208054839290610803908490610cc8565b925050819055508060025f82825461081b9190610cc8565b90915550506040518181526001600160a01b038316907fe1fffcc4923d04b559f4d29a8bfc6cda04eb5b0d3c460751c2402c5c5cc9109c9060200161073f565b5f546001600160a01b031633146103cc5760405163118cdaa760e01b81523360048201526024016102e7565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b179052610300908490610a3c565b6108e281610a0a565b6001600160a01b0381165f908152600460205260409020548061093a5760405162461bcd60e51b815260206004820152601060248201526f4e6f7468696e6720746f20636c61696d60801b60448201526064016102e7565b6001600160a01b038083165f90815260046020526040812055610980907f00000000000000000000000088a4e88d3e5ad70b5c78f9009eddb5816f3cd621168383610887565b816001600160a01b03167f47cee97cb7acd717b3c0aa1435d004cd5b3c8c57d70dbceb4e4458bbd60e39d48260405161073f91815260200190565b5f80546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b610a138161054f565b6001600160a01b039091165f908152600460209081526040808320939093556005905220429055565b5f610a506001600160a01b03841683610a9d565b905080515f14158015610a74575080806020019051810190610a729190610cdb565b155b1561030057604051635274afe760e01b81526001600160a01b03841660048201526024016102e7565b60606105da83835f845f80856001600160a01b03168486604051610ac19190610cf6565b5f6040518083038185875af1925050503d805f8114610afb576040519150601f19603f3d011682016040523d82523d5f602084013e610b00565b606091505b5091509150610b10868383610b1a565b9695505050505050565b606082610b2f57610b2a82610b76565b6105da565b8151158015610b4657506001600160a01b0384163b155b15610b6f57604051639996b31560e01b81526001600160a01b03851660048201526024016102e7565b50806105da565b805115610b865780518082602001fd5b604051630a12f52160e11b815260040160405180910390fd5b80356001600160a01b0381168114610bb5575f80fd5b919050565b5f60208284031215610bca575f80fd5b6105da82610b9f565b8015158114610429575f80fd5b5f805f60608486031215610bf2575f80fd5b610bfb84610b9f565b9250602084013591506040840135610c1281610bd3565b809150509250925092565b5f60208284031215610c2d575f80fd5b5035919050565b5f60208284031215610c44575f80fd5b813560ff811681146105da575f80fd5b5f60208284031215610c64575f80fd5b5051919050565b634e487b7160e01b5f52601160045260245ffd5b8181038181111561027e5761027e610c6b565b808202811582820484141761027e5761027e610c6b565b5f82610cc357634e487b7160e01b5f52601260045260245ffd5b500490565b8082018082111561027e5761027e610c6b565b5f60208284031215610ceb575f80fd5b81516105da81610bd3565b5f82515f5b81811015610d155760208186018101518583015201610cfb565b505f92019182525091905056fea264697066735822122042da4fb1fdb7edb1231387e629e2dc0aebf6d229290c619cf59570d2853d332064736f6c63430008140033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
000000000000000000000000db47e4ed1beedb2c04fd74ff7a606fccdabd63d200000000000000000000000088a4e88d3e5ad70b5c78f9009eddb5816f3cd6210000000000000000000000000000000000000000000000000000000000000005
-----Decoded View---------------
Arg [0] : _mainPool (address): 0xDB47e4eD1BeedB2C04fd74fF7A606fcCdaBd63D2
Arg [1] : _token (address): 0x88a4E88D3e5aD70b5c78F9009EDdb5816F3CD621
Arg [2] : _fixedAPR (uint256): 5
-----Encoded View---------------
3 Constructor Arguments found :
Arg [0] : 000000000000000000000000db47e4ed1beedb2c04fd74ff7a606fccdabd63d2
Arg [1] : 00000000000000000000000088a4e88d3e5ad70b5c78f9009eddb5816f3cd621
Arg [2] : 0000000000000000000000000000000000000000000000000000000000000005
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 30 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|
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.