Contract Overview
My Name Tag:
Not Available, login to update
[ Download CSV Export ]
Contract Name:
Staking
Compiler Version
v0.8.2+commit.661d1103
Optimization Enabled:
Yes with 800 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/security/ReentrancyGuard.sol"; import "@openzeppelin/contracts/security/Pausable.sol"; import "../interfaces/staking/IStaking.sol"; import "../interfaces/staking/IStakingRoot.sol"; import "../interfaces/staking/ITokenLocker.sol"; /** @title Staking * @notice General staking contract for staking ACRE */ contract Staking is Ownable, ReentrancyGuard, IStaking, Pausable { using SafeERC20 for IERC20; struct UserInfo { uint256 amount; // amount of tokens staked by the user uint256 rewardDebt; // amount to be cut off in rewards calculation - updated when deposit, withdraw or claim uint256 pendingRewards; // pending rewards for the user } struct PoolInfo { uint256 accTokenPerShare; // accumulative rewards per deposited token uint256 depositAmount; uint256 rewardsAmount; uint256 lockupDuration; } IStakingRoot public stakingRoot; IERC20 public token; uint256 public totalDistributed; uint256 public totalReleased; PoolInfo public poolInfo; mapping(address => UserInfo) public userInfo; uint256 public constant SHARE_MULTIPLIER = 1e12; event Deposit(address indexed user, uint256 amount); event RequestWithdraw(address indexed user, uint256 amount); event Claim(address indexed user, uint256 amount); event TokenAddressSet(address token); event PoolLockDurationChanged(uint256 lockupDuration); event Pause(); event Unpause(); constructor(IStakingRoot _root) { require(address(_root) != address(0), "Invalid StakingRoot"); stakingRoot = _root; } modifier onlyRoot() { require(msg.sender == address(stakingRoot), "Not StakingRoot"); _; } function getTotalDepositAmount() public view override returns (uint256) { return poolInfo.depositAmount; } // staking token and reward token are same, reward amount is contract_token_balance - total_staked function getTotalDistributableRewards() public view returns (uint256) { return token.balanceOf(address(this)) + totalReleased - getTotalDepositAmount() - totalDistributed; } // accumulative rewards for staking amount function accumulativeRewards(uint256 amount, uint256 _accTokenPerShare) internal pure returns (uint256) { return (amount * _accTokenPerShare) / (SHARE_MULTIPLIER); } /** * @notice get Pending Rewards of a user * * @param _user: User Address */ function pendingRewards(address _user) external view override returns (uint256) { require(_user != address(0), "Invalid user address"); PoolInfo storage pool = poolInfo; UserInfo storage user = userInfo[_user]; uint256 accTokenPerShare = pool.accTokenPerShare; uint256 depositAmount = pool.depositAmount; if (depositAmount != 0) { uint256 tokenReward = getTotalDistributableRewards(); accTokenPerShare = accTokenPerShare + ((tokenReward * (SHARE_MULTIPLIER)) / (depositAmount)); } // last_accumulated_reward is expressed as rewardDebt // accumulated_rewards - last_accumulated_reward + last_pending_rewards return accumulativeRewards(user.amount, accTokenPerShare) - (user.rewardDebt) + (user.pendingRewards); } /** * @notice _updatePool distribute pending rewards * */ function _updatePool() internal { uint256 depositAmount = poolInfo.depositAmount; if (depositAmount == 0) { return; } uint256 tokenReward = getTotalDistributableRewards(); poolInfo.rewardsAmount += tokenReward; // accTokenPerShare is by definition accumulation of token rewards per staked token poolInfo.accTokenPerShare += (tokenReward * SHARE_MULTIPLIER) / depositAmount; totalDistributed = totalDistributed + tokenReward; } function _updateUserPendingRewards(address addr) internal { UserInfo storage user = userInfo[addr]; if (user.amount == 0) { return; } user.pendingRewards += accumulativeRewards(user.amount, poolInfo.accTokenPerShare) - user.rewardDebt; } /** * @notice deposit token to the contract * * @param amount: Amount of token to deposit */ function deposit(uint256 amount) external override whenNotPaused { require(amount > 0, "should deposit positive amount"); _updatePool(); _updateUserPendingRewards(msg.sender); UserInfo storage user = userInfo[msg.sender]; token.safeTransferFrom(address(msg.sender), address(this), amount); user.amount += amount; poolInfo.depositAmount += amount; // last_accumulated_reward is expressed as rewardDebt user.rewardDebt = accumulativeRewards(user.amount, poolInfo.accTokenPerShare); emit Deposit(msg.sender, amount); } /** * @notice request token to be back * * @param amount: Amount of token to withdraw * @param _withdrawRewards: flag to withdraw reward or not */ function requestWithdraw(uint256 amount, bool _withdrawRewards) external override nonReentrant whenNotPaused { require(amount > 0, "amount should be positive"); _updatePool(); _updateUserPendingRewards(msg.sender); UserInfo storage user = userInfo[msg.sender]; require(user.amount >= amount, "Withdrawing more than you have!"); if (_withdrawRewards) { uint256 claimedAmount = safeTokenTransfer(msg.sender, user.pendingRewards); emit Claim(msg.sender, claimedAmount); user.pendingRewards = user.pendingRewards - claimedAmount; totalReleased += claimedAmount; } address tokenLocker = (stakingRoot).tokenLocker(); token.approve(tokenLocker, amount); ITokenLocker(tokenLocker).lockToken( address(token), msg.sender, amount, block.timestamp + poolInfo.lockupDuration ); user.amount -= amount; poolInfo.depositAmount -= amount; // last_accumulated_reward is expressed as rewardDebt user.rewardDebt = accumulativeRewards(user.amount, poolInfo.accTokenPerShare); emit RequestWithdraw(msg.sender, amount); } /** * @notice claim rewards from a certain pool * */ function claim() external override nonReentrant whenNotPaused { _updatePool(); _updateUserPendingRewards(msg.sender); PoolInfo storage pool = poolInfo; UserInfo storage user = userInfo[msg.sender]; if (user.pendingRewards > 0) { uint256 claimedAmount = safeTokenTransfer(msg.sender, user.pendingRewards); emit Claim(msg.sender, claimedAmount); totalReleased += claimedAmount; user.pendingRewards -= claimedAmount; pool.rewardsAmount -= claimedAmount; } // last_accumulated_reward is expressed as rewardDebt user.rewardDebt = accumulativeRewards(user.amount, poolInfo.accTokenPerShare); } function safeTokenTransfer(address to, uint256 amount) internal returns (uint256) { PoolInfo memory pool = poolInfo; if (amount > pool.rewardsAmount) { token.safeTransfer(to, pool.rewardsAmount); return pool.rewardsAmount; } else { token.safeTransfer(to, amount); return amount; } } function getDepositAmount(address user) external view override returns (uint256) { return userInfo[user].amount; } function withdrawAnyToken( address _token, uint256 amount, address beneficiary ) external override onlyRoot { IERC20(_token).safeTransfer(beneficiary, amount); } function setToken(IERC20 _token) external onlyOwner { require(address(token) == address(0), "Token already set!"); require(address(_token) != address(0), "Invalid Token Address"); token = _token; emit TokenAddressSet(address(token)); poolInfo.lockupDuration = 14 days; emit PoolLockDurationChanged(poolInfo.lockupDuration); } function updatePoolDuration(uint256 _lockupDuration) external onlyOwner { poolInfo.lockupDuration = _lockupDuration; emit PoolLockDurationChanged(_lockupDuration); } // This function is called per epoch by bot function claimRewardsFromRoot() external { stakingRoot.claimRewards(); } /** * @notice Triggers stopped state * @dev Only possible when contract not paused. */ function pause() external onlyOwner whenNotPaused { _pause(); emit Pause(); } /** * @notice Returns to normal state * @dev Only possible when contract is paused. */ function unpause() external onlyOwner whenPaused { _unpause(); emit Unpause(); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (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 `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom( address sender, address recipient, uint256 amount ) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC20/utils/SafeERC20.sol) pragma solidity ^0.8.0; import "../IERC20.sol"; import "../../../utils/Address.sol"; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20 { using Address for address; function safeTransfer( IERC20 token, address to, uint256 value ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom( IERC20 token, address from, address to, uint256 value ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } /** * @dev Deprecated. This function has issues similar to the ones found in * {IERC20-approve}, and its usage is discouraged. * * Whenever possible, use {safeIncreaseAllowance} and * {safeDecreaseAllowance} instead. */ function safeApprove( IERC20 token, address spender, uint256 value ) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' require( (value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function safeIncreaseAllowance( IERC20 token, address spender, uint256 value ) internal { uint256 newAllowance = token.allowance(address(this), spender) + value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function safeDecreaseAllowance( IERC20 token, address spender, uint256 value ) internal { unchecked { uint256 oldAllowance = token.allowance(address(this), spender); require(oldAllowance >= value, "SafeERC20: decreased allowance below zero"); uint256 newAllowance = oldAllowance - value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function _callOptionalReturn(IERC20 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (access/Ownable.sol) pragma solidity ^0.8.0; import "../utils/Context.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _transferOwnership(_msgSender()); } /** * @dev 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); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (security/ReentrancyGuard.sol) pragma solidity ^0.8.0; /** * @dev Contract module that helps prevent reentrant calls to a function. * * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier * available, which can be applied to functions to make sure there are no nested * (reentrant) calls to them. * * Note that because there is a single `nonReentrant` guard, functions marked as * `nonReentrant` may not call one another. This can be worked around by making * those functions `private`, and then adding `external` `nonReentrant` entry * points to them. * * TIP: If you would like to learn more about reentrancy and alternative ways * to protect against it, check out our blog post * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul]. */ abstract contract ReentrancyGuard { // Booleans are more expensive than uint256 or any type that takes up a full // word because each write operation emits an extra SLOAD to first read the // slot's contents, replace the bits taken up by the boolean, and then write // back. This is the compiler's defense against contract upgrades and // pointer aliasing, and it cannot be disabled. // The values being non-zero value makes deployment a bit more expensive, // but in exchange the refund on every call to nonReentrant will be lower in // amount. Since refunds are capped to a percentage of the total // transaction's gas, it is best to keep them low in cases like this one, to // increase the likelihood of the full refund coming into effect. uint256 private constant _NOT_ENTERED = 1; uint256 private constant _ENTERED = 2; uint256 private _status; constructor() { _status = _NOT_ENTERED; } /** * @dev Prevents a contract from calling itself, directly or indirectly. * Calling a `nonReentrant` function from another `nonReentrant` * function is not supported. It is possible to prevent this from happening * by making the `nonReentrant` function external, and making it call a * `private` function that does the actual work. */ modifier nonReentrant() { // On the first call to nonReentrant, _notEntered will be true require(_status != _ENTERED, "ReentrancyGuard: reentrant call"); // Any calls to nonReentrant after this point will fail _status = _ENTERED; _; // By storing the original value once again, a refund is triggered (see // https://eips.ethereum.org/EIPS/eip-2200) _status = _NOT_ENTERED; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (security/Pausable.sol) pragma solidity ^0.8.0; import "../utils/Context.sol"; /** * @dev Contract module which allows children to implement an emergency stop * mechanism that can be triggered by an authorized account. * * This module is used through inheritance. It will make available the * modifiers `whenNotPaused` and `whenPaused`, which can be applied to * the functions of your contract. Note that they will not be pausable by * simply including this module, only once the modifiers are put in place. */ abstract contract Pausable is Context { /** * @dev Emitted when the pause is triggered by `account`. */ event Paused(address account); /** * @dev Emitted when the pause is lifted by `account`. */ event Unpaused(address account); bool private _paused; /** * @dev Initializes the contract in unpaused state. */ constructor() { _paused = false; } /** * @dev Returns true if the contract is paused, and false otherwise. */ function paused() public view virtual returns (bool) { return _paused; } /** * @dev Modifier to make a function callable only when the contract is not paused. * * Requirements: * * - The contract must not be paused. */ modifier whenNotPaused() { require(!paused(), "Pausable: paused"); _; } /** * @dev Modifier to make a function callable only when the contract is paused. * * Requirements: * * - The contract must be paused. */ modifier whenPaused() { require(paused(), "Pausable: not paused"); _; } /** * @dev Triggers stopped state. * * Requirements: * * - The contract must not be paused. */ function _pause() internal virtual whenNotPaused { _paused = true; emit Paused(_msgSender()); } /** * @dev Returns to normal state. * * Requirements: * * - The contract must be paused. */ function _unpause() internal virtual whenPaused { _paused = false; emit Unpaused(_msgSender()); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; interface IStaking { function getDepositAmount(address user) external view returns (uint256); function getTotalDepositAmount() external view returns (uint256); function withdrawAnyToken( address _token, uint256 amount, address beneficiary ) external; function claim() external; function requestWithdraw(uint256 amount, bool _withdrawRewards) external; function deposit(uint256 amount) external; function pendingRewards(address _user) external view returns (uint256); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; interface IStakingRoot { function dstakingOverview() external view returns (address); function tokenLocker() external view returns (address); function staking() external view returns (address); function redelegationAttemptPeriod() external view returns (uint256); function isRedelegationDisabled() external view returns (bool); function isDStaking(address) external view returns (bool); function isDStakingRemoved(address) external view returns (bool); function dStakingCreators(address) external view returns (address); function claimRewards() external; function minTokenAmountForDStaker() external view returns (uint256); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** @title ITokenLocker * @notice */ interface ITokenLocker { function lockToken( address token, address beneficiary, uint256 amount, uint256 unlockTime ) external; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Address.sol) pragma solidity ^0.8.0; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @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); } } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } }
{ "metadata": { "bytecodeHash": "none" }, "optimizer": { "enabled": true, "runs": 800 }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "libraries": {} }
[{"inputs":[{"internalType":"contract IStakingRoot","name":"_root","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Claim","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","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":[],"name":"Pause","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"lockupDuration","type":"uint256"}],"name":"PoolLockDurationChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"RequestWithdraw","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"token","type":"address"}],"name":"TokenAddressSet","type":"event"},{"anonymous":false,"inputs":[],"name":"Unpause","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"inputs":[],"name":"SHARE_MULTIPLIER","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"claim","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"claimRewardsFromRoot","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"deposit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"}],"name":"getDepositAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getTotalDepositAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getTotalDistributableRewards","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"}],"name":"pendingRewards","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"poolInfo","outputs":[{"internalType":"uint256","name":"accTokenPerShare","type":"uint256"},{"internalType":"uint256","name":"depositAmount","type":"uint256"},{"internalType":"uint256","name":"rewardsAmount","type":"uint256"},{"internalType":"uint256","name":"lockupDuration","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bool","name":"_withdrawRewards","type":"bool"}],"name":"requestWithdraw","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"_token","type":"address"}],"name":"setToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"stakingRoot","outputs":[{"internalType":"contract IStakingRoot","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"token","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalDistributed","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalReleased","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":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_lockupDuration","type":"uint256"}],"name":"updatePoolDuration","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"userInfo","outputs":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"rewardDebt","type":"uint256"},{"internalType":"uint256","name":"pendingRewards","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"address","name":"beneficiary","type":"address"}],"name":"withdrawAnyToken","outputs":[],"stateMutability":"nonpayable","type":"function"}]
Contract Creation Code
60806040523480156200001157600080fd5b5060405162001c0038038062001c00833981016040819052620000349162000124565b6200003f33620000d4565b600180556002805460ff191690556001600160a01b038116620000a85760405162461bcd60e51b815260206004820152601360248201527f496e76616c6964205374616b696e67526f6f7400000000000000000000000000604482015260640160405180910390fd5b600280546001600160a01b0390921661010002610100600160a81b031990921691909117905562000154565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60006020828403121562000136578081fd5b81516001600160a01b03811681146200014d578182fd5b9392505050565b611a9c80620001646000396000f3fe608060405234801561001057600080fd5b50600436106101985760003560e01c8063715018a6116100e3578063b6b55f251161008c578063efca2eed11610066578063efca2eed14610371578063f2fde38b1461037a578063fc0c546a1461038d57610198565b8063b6b55f251461032c578063b8ba16fd1461033f578063e33b7de31461036857610198565b80638da5cb5b116100bd5780638da5cb5b146103005780639050beec146103115780639d99daad1461031957610198565b8063715018a6146102dd5780638456cb59146102e55780638a47f530146102ed57610198565b806342868c28116101455780635a2f3d091161011f5780635a2f3d091461027e5780635c975abb146102b457806360f5a7af146102ca57610198565b806342868c281461023e5780634e71d92d1461024657806351ba77311461024e57610198565b806331d7a2621161017657806331d7a2621461021b5780633c9b97fc1461022e5780633f4ba83a1461023657610198565b8063144fa6d71461019d5780631959a002146101b2578063291c3f7914610201575b600080fd5b6101b06101ab366004611879565b6103a0565b005b6101e16101c0366004611879565b600a6020526000908152604090208054600182015460029092015490919083565b604080519384526020840192909252908201526060015b60405180910390f35b61020d64e8d4a5100081565b6040519081526020016101f8565b61020d610229366004611879565b610550565b60075461020d565b6101b0610638565b61020d610717565b6101b06107c6565b6002546102669061010090046001600160a01b031681565b6040516001600160a01b0390911681526020016101f8565b6006546007546008546009546102949392919084565b6040805194855260208501939093529183015260608201526080016101f8565b60025460ff1660405190151581526020016101f8565b6101b06102d836600461193e565b610949565b6101b0610d71565b6101b0610dd7565b6101b06102fb36600461190e565b610eaa565b6000546001600160a01b0316610266565b6101b0610f39565b6101b06103273660046118b1565b610fa3565b6101b061033a36600461190e565b61101b565b61020d61034d366004611879565b6001600160a01b03166000908152600a602052604090205490565b61020d60055481565b61020d60045481565b6101b0610388366004611879565b61116b565b600354610266906001600160a01b031681565b6000546001600160a01b031633146103ff5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064015b60405180910390fd5b6003546001600160a01b0316156104585760405162461bcd60e51b815260206004820152601260248201527f546f6b656e20616c72656164792073657421000000000000000000000000000060448201526064016103f6565b6001600160a01b0381166104ae5760405162461bcd60e51b815260206004820152601560248201527f496e76616c696420546f6b656e2041646472657373000000000000000000000060448201526064016103f6565b6003805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b038381169190911791829055604051911681527fd82cad5fdc98633445b90f806f2e1a61a5409f92187ee9cd87f1da18c90692669060200160405180910390a16212750060098190556040519081527fd21facc366489554e16d5f98cebc66efc21bb8e17afc4eed925a11a3081d4ddf906020015b60405180910390a150565b60006001600160a01b0382166105a85760405162461bcd60e51b815260206004820152601460248201527f496e76616c69642075736572206164647265737300000000000000000000000060448201526064016103f6565b6001600160a01b0382166000908152600a602052604090206006805460075491929180156106045760006105da610717565b9050816105ec64e8d4a51000836119f4565b6105f691906119d4565b61060090846119bc565b9250505b60028301546001840154845461061a908561124d565b6106249190611a13565b61062e91906119bc565b9695505050505050565b6000546001600160a01b031633146106925760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016103f6565b60025460ff166106e45760405162461bcd60e51b815260206004820152601460248201527f5061757361626c653a206e6f742070617573656400000000000000000000000060448201526064016103f6565b6106ec611272565b6040517f7805862f689e2f13df9f062ff482ad3ad112aca9e0847911ed832e158c525b3390600090a1565b600060045461072560075490565b6005546003546040516370a0823160e01b81523060048201526001600160a01b03909116906370a082319060240160206040518083038186803b15801561076b57600080fd5b505afa15801561077f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107a39190611926565b6107ad91906119bc565b6107b79190611a13565b6107c19190611a13565b905090565b600260015414156108195760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016103f6565b600260015561082a60025460ff1690565b1561086a5760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b60448201526064016103f6565b61087261130e565b61087b33611389565b336000908152600a602052604090206002810154600691901561092f5760006108a83383600201546113e7565b60405181815290915033907f47cee97cb7acd717b3c0aa1435d004cd5b3c8c57d70dbceb4e4458bbd60e39d49060200160405180910390a280600560008282546108f291906119bc565b925050819055508082600201600082825461090d9190611a13565b92505081905550808360020160008282546109289190611a13565b9091555050505b805460065461093e919061124d565b600191820155805550565b6002600154141561099c5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016103f6565b60026001556109ad60025460ff1690565b156109ed5760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b60448201526064016103f6565b60008211610a3d5760405162461bcd60e51b815260206004820152601960248201527f616d6f756e742073686f756c6420626520706f7369746976650000000000000060448201526064016103f6565b610a4561130e565b610a4e33611389565b336000908152600a602052604090208054831115610aae5760405162461bcd60e51b815260206004820152601f60248201527f5769746864726177696e67206d6f7265207468616e20796f752068617665210060448201526064016103f6565b8115610b2d576000610ac43383600201546113e7565b60405181815290915033907f47cee97cb7acd717b3c0aa1435d004cd5b3c8c57d70dbceb4e4458bbd60e39d49060200160405180910390a2808260020154610b0c9190611a13565b82600201819055508060056000828254610b2691906119bc565b9091555050505b6000600260019054906101000a90046001600160a01b03166001600160a01b031663a80bf3e66040518163ffffffff1660e01b815260040160206040518083038186803b158015610b7d57600080fd5b505afa158015610b91573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bb59190611895565b60035460405163095ea7b360e01b81526001600160a01b0380841660048301526024820188905292935091169063095ea7b390604401602060405180830381600087803b158015610c0557600080fd5b505af1158015610c19573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c3d91906118f2565b506003546009546001600160a01b038084169263e4ddc77c9291169033908890610c6790426119bc565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e087901b1681526001600160a01b03948516600482015293909216602484015260448301526064820152608401600060405180830381600087803b158015610cd357600080fd5b505af1158015610ce7573d6000803e3d6000fd5b5050505083826000016000828254610cff9190611a13565b909155505060078054859190600090610d19908490611a13565b90915550508154600654610d2d919061124d565b600183015560405184815233907f0afd74a2a0a78f6c15e41029f44995ee023fe49276f44a4b2b2cf674829362e69060200160405180910390a25050600180555050565b6000546001600160a01b03163314610dcb5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016103f6565b610dd56000611463565b565b6000546001600160a01b03163314610e315760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016103f6565b60025460ff1615610e775760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b60448201526064016103f6565b610e7f6114c0565b6040517f6985a02210a168e66602d3235cb6db0e70f92b3ba4d376a33c0f3d9434bff62590600090a1565b6000546001600160a01b03163314610f045760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016103f6565b60098190556040518181527fd21facc366489554e16d5f98cebc66efc21bb8e17afc4eed925a11a3081d4ddf90602001610545565b600260019054906101000a90046001600160a01b03166001600160a01b031663372500ab6040518163ffffffff1660e01b8152600401600060405180830381600087803b158015610f8957600080fd5b505af1158015610f9d573d6000803e3d6000fd5b50505050565b60025461010090046001600160a01b031633146110025760405162461bcd60e51b815260206004820152600f60248201527f4e6f74205374616b696e67526f6f74000000000000000000000000000000000060448201526064016103f6565b6110166001600160a01b038416828461153b565b505050565b60025460ff16156110615760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b60448201526064016103f6565b600081116110b15760405162461bcd60e51b815260206004820152601e60248201527f73686f756c64206465706f73697420706f73697469766520616d6f756e74000060448201526064016103f6565b6110b961130e565b6110c233611389565b336000818152600a6020526040902060035490916110eb916001600160a01b03169030856115cb565b818160000160008282546110ff91906119bc565b9091555050600780548391906000906111199084906119bc565b9091555050805460065461112d919061124d565b600182015560405182815233907fe1fffcc4923d04b559f4d29a8bfc6cda04eb5b0d3c460751c2402c5c5cc9109c9060200160405180910390a25050565b6000546001600160a01b031633146111c55760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016103f6565b6001600160a01b0381166112415760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084016103f6565b61124a81611463565b50565b600064e8d4a5100061125f83856119f4565b61126991906119d4565b90505b92915050565b60025460ff166112c45760405162461bcd60e51b815260206004820152601460248201527f5061757361626c653a206e6f742070617573656400000000000000000000000060448201526064016103f6565b6002805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b6007548061131c5750610dd5565b6000611326610717565b9050806006600201600082825461133d91906119bc565b9091555082905061135364e8d4a51000836119f4565b61135d91906119d4565b6006805460009061136f9084906119bc565b90915550506004546113829082906119bc565b6004555050565b6001600160a01b0381166000908152600a6020526040902080546113ad575061124a565b600181015481546006546113c1919061124d565b6113cb9190611a13565b8160020160008282546113de91906119bc565b90915550505050565b60408051608081018252600654815260075460208201526008549181018290526009546060820152600091831115611443576040810151600354611438916001600160a01b0390911690869061153b565b60400151905061126c565b60035461145a906001600160a01b0316858561153b565b8291505061126c565b600080546001600160a01b0383811673ffffffffffffffffffffffffffffffffffffffff19831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60025460ff16156115065760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b60448201526064016103f6565b6002805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586112f13390565b6040516001600160a01b03831660248201526044810182905261101690849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff0000000000000000000000000000000000000000000000000000000090931692909217909152611603565b6040516001600160a01b0380851660248301528316604482015260648101829052610f9d9085906323b872dd60e01b90608401611567565b6000611658826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166116e89092919063ffffffff16565b805190915015611016578080602001905181019061167691906118f2565b6110165760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f7420737563636565640000000000000000000000000000000000000000000060648201526084016103f6565b60606116f78484600085611701565b90505b9392505050565b6060824710156117795760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c000000000000000000000000000000000000000000000000000060648201526084016103f6565b843b6117c75760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016103f6565b600080866001600160a01b031685876040516117e3919061196d565b60006040518083038185875af1925050503d8060008114611820576040519150601f19603f3d011682016040523d82523d6000602084013e611825565b606091505b5091509150611835828286611840565b979650505050505050565b6060831561184f5750816116fa565b82511561185f5782518084602001fd5b8160405162461bcd60e51b81526004016103f69190611989565b60006020828403121561188a578081fd5b81356116fa81611a6c565b6000602082840312156118a6578081fd5b81516116fa81611a6c565b6000806000606084860312156118c5578182fd5b83356118d081611a6c565b92506020840135915060408401356118e781611a6c565b809150509250925092565b600060208284031215611903578081fd5b81516116fa81611a81565b60006020828403121561191f578081fd5b5035919050565b600060208284031215611937578081fd5b5051919050565b60008060408385031215611950578182fd5b82359150602083013561196281611a81565b809150509250929050565b6000825161197f818460208701611a2a565b9190910192915050565b60006020825282518060208401526119a8816040850160208701611a2a565b601f01601f19169190910160400192915050565b600082198211156119cf576119cf611a56565b500190565b6000826119ef57634e487b7160e01b81526012600452602481fd5b500490565b6000816000190483118215151615611a0e57611a0e611a56565b500290565b600082821015611a2557611a25611a56565b500390565b60005b83811015611a45578181015183820152602001611a2d565b83811115610f9d5750506000910152565b634e487b7160e01b600052601160045260246000fd5b6001600160a01b038116811461124a57600080fd5b801515811461124a57600080fdfea164736f6c6343000802000a000000000000000000000000fbbd365bcb6ec0485036f3223717927d99eedfaf
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
000000000000000000000000fbbd365bcb6ec0485036f3223717927d99eedfaf
-----Decoded View---------------
Arg [0] : _root (address): 0xfbbd365bcb6ec0485036f3223717927d99eedfaf
-----Encoded View---------------
1 Constructor Arguments found :
Arg [0] : 000000000000000000000000fbbd365bcb6ec0485036f3223717927d99eedfaf
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.