More Info
Private Name Tags
ContractCreator
Latest 25 from a total of 2,310 transactions
Transaction Hash |
Method
|
Block
|
From
|
To
|
|||||
---|---|---|---|---|---|---|---|---|---|
Stake | 65090545 | 5 hrs ago | IN | 0 POL | 0.00318933 | ||||
Stake | 65082338 | 9 hrs ago | IN | 0 POL | 0.00380527 | ||||
Stake | 65078561 | 12 hrs ago | IN | 0 POL | 0.02448006 | ||||
Stake | 65076592 | 13 hrs ago | IN | 0 POL | 0.02814164 | ||||
Withdraw | 65075855 | 13 hrs ago | IN | 0 POL | 0.01747353 | ||||
Stake | 65072977 | 15 hrs ago | IN | 0 POL | 0.0100764 | ||||
Claim Rewards | 65072919 | 15 hrs ago | IN | 0 POL | 0.00813088 | ||||
Withdraw | 65071927 | 16 hrs ago | IN | 0 POL | 0.0033202 | ||||
Stake | 65068366 | 18 hrs ago | IN | 0 POL | 0.01717601 | ||||
Claim Rewards | 65068054 | 18 hrs ago | IN | 0 POL | 0.00397006 | ||||
Withdraw | 65067885 | 18 hrs ago | IN | 0 POL | 0.00338678 | ||||
Withdraw | 65067710 | 18 hrs ago | IN | 0 POL | 0.00861275 | ||||
Claim Rewards | 65067662 | 18 hrs ago | IN | 0 POL | 0.00289646 | ||||
Stake | 65041753 | 34 hrs ago | IN | 0 POL | 0.00356379 | ||||
Claim Rewards | 65041232 | 34 hrs ago | IN | 0 POL | 0.00657293 | ||||
Withdraw | 65041221 | 34 hrs ago | IN | 0 POL | 0.0081372 | ||||
Withdraw | 65038068 | 36 hrs ago | IN | 0 POL | 0.01808977 | ||||
Claim Rewards | 65038052 | 36 hrs ago | IN | 0 POL | 0.01423573 | ||||
Withdraw | 65037897 | 36 hrs ago | IN | 0 POL | 0.01702582 | ||||
Claim Rewards | 65037875 | 36 hrs ago | IN | 0 POL | 0.01620013 | ||||
Stake | 65036301 | 37 hrs ago | IN | 0 POL | 0.07049305 | ||||
Withdraw | 65036018 | 37 hrs ago | IN | 0 POL | 0.14832292 | ||||
Claim Rewards | 65022532 | 45 hrs ago | IN | 0 POL | 0.00416405 | ||||
Stake | 65014045 | 2 days ago | IN | 0 POL | 0.01170009 | ||||
Stake | 65010417 | 2 days ago | IN | 0 POL | 0.002868 |
Loading...
Loading
Contract Source Code Verified (Exact Match)
Contract Name:
StakingFlex
Compiler Version
v0.8.23+commit.f704f362
Optimization Enabled:
Yes with 200 runs
Other Settings:
paris EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT pragma solidity 0.8.23; import "openzeppelin-contracts/contracts/token/ERC20/extensions/IERC20Metadata.sol"; import "openzeppelin-contracts/contracts/token/ERC20/IERC20.sol"; import "openzeppelin-contracts/contracts/token/ERC20/utils/SafeERC20.sol"; import "openzeppelin-contracts/contracts/access/Ownable.sol"; import "openzeppelin-contracts/contracts/utils/Pausable.sol"; import "openzeppelin-contracts/contracts/utils/ReentrancyGuard.sol"; import "openzeppelin-contracts/contracts/utils/math/Math.sol"; /// @title Flexible Staking contract contract StakingFlex is Ownable, Pausable, ReentrancyGuard { /// @dev Emitted when tokens are staked. event TokensStaked(address indexed staker, uint256 amount); /// @dev Emitted when a tokens are withdrawn. event TokensWithdrawn(address indexed staker, uint256 amount); /// @dev Emitted when a staker claims staking rewards. event RewardsClaimed(address indexed staker, uint256 rewardAmount); /// @dev Emitted when contract admin updates timeUnit. event UpdatedTimeUnit(uint256 oldTimeUnit, uint256 newTimeUnit); /// @dev Emergency event to force the withdrawals of found event TokensWithdrawnAdmin(address indexed staker, uint256 amount); /// @dev Emitted when contract admin updates rewardsPerUnitTime. event UpdatedRewardRatio( uint256 oldNumerator, uint256 newNumerator, uint256 oldDenominator, uint256 newDenominator ); /// @dev Represent a staking condition struct StakingCondition { uint256 timeUnit; uint256 startTimestamp; uint256 endTimestamp; uint256 rewardRatioNumerator; uint256 rewardRatioDenominator; } /// @dev Represent a staker position struct StakerStaking { uint256 conditionIdOflastUpdate; uint256 timeOfLastUpdate; uint256 amountStaked; uint256 unclaimedRewards; } /// @dev Mapping staker address to StakerStaking mapping(address => StakerStaking) public stakers; /// @dev Total reward collected per Wallet mapping(address => uint256) public stakersRewardClaimed; /// @dev Address of ERC20 contract of the stacked Tokens address public immutable stakingToken; /// @dev Decimals of staking token. uint256 public immutable stakingTokenDecimals; /// @dev Address of ERC20 contract of the reward Tokens address public immutable rewardToken; /// @dev Decimals of reward token. uint256 public immutable rewardTokenDecimals; /// @dev Total amount of tokens staked in the contract. uint256 public stakingTokenBalance; /// @dev Next staking condition Id. Tracks number of conditions updates so far. uint256 private nextConditionId; /// @dev Address of the wallet holdings the token rewards address public immutable rewardWallet; /// @dev Count the total number of unique stakers uint256 public totalStakers; /// @dev Count the total rewards claimed by all the users. uint256 public totalRewardClaimed; /// @dev Mapping from condition Id to staking condition. See {struct IStaking721.StakingCondition} mapping(uint256 => StakingCondition) private stakingConditions; /** * @notice Initializes a new StakingFlex contract with specific token addresses and staking conditions. * @dev Sets up the staking token, reward token, initial staking conditions, and the contract owner. * It fetches token decimals and initializes the first staking condition. * @param _stakingToken Address of the ERC20 token used for staking. * @param _rewardToken Address of the ERC20 token used for rewards. * @param _rewardWallet Address of the wallet holding the reward tokens. * @param _timeUnit The initial time unit for reward calculations. * @param _numerator The numerator part of the reward ratio for the first staking condition. * @param _denominator The denominator part of the reward ratio for the first staking condition, ensuring no division by zero. */ constructor( address _stakingToken, address _rewardToken, address _rewardWallet, uint80 _timeUnit, uint256 _numerator, uint256 _denominator ) Ownable(msg.sender) { require(_rewardWallet != address(this), "Reward wallet cannot be the contract itself"); require(_stakingToken != address(0) && _rewardToken != address(0) && _rewardWallet != address(0), "Staking/Reward token/wallet cannot be the zero address"); stakingToken = _stakingToken; stakingTokenDecimals = IERC20Metadata(_stakingToken).decimals(); rewardTokenDecimals = IERC20Metadata(_rewardToken).decimals(); rewardToken = _rewardToken; rewardWallet = _rewardWallet; _setStakingCondition(_timeUnit, _numerator, _denominator); } /** * @dev Returns the time unit from the latest staking condition. * @return _timeUnit The current time unit in seconds for reward calculations. */ function getTimeUnit() public view returns (uint256 _timeUnit) { _timeUnit = stakingConditions[nextConditionId - 1].timeUnit; } /** * @dev Returns the numerator and denominator of the reward ratio from the latest staking condition. * @return _numerator The numerator part of the current reward ratio. * @return _denominator The denominator part of the current reward ratio. */ function getRewardRatio() public view returns (uint256 _numerator, uint256 _denominator) { _numerator = stakingConditions[nextConditionId - 1].rewardRatioNumerator; _denominator = stakingConditions[nextConditionId - 1].rewardRatioDenominator; } /** * @notice Set time unit. Set as a number of seconds. * Could be specified as -- x * 1 hours, x * 1 days, etc. * @dev Can only be called by the contract owner. * @param _timeUnit New time unit. */ function setTimeUnit(uint256 _timeUnit) external virtual onlyOwner { StakingCondition memory condition = stakingConditions[nextConditionId - 1]; require(_timeUnit != condition.timeUnit, "Time-unit unchanged."); _setStakingCondition(_timeUnit, condition.rewardRatioNumerator, condition.rewardRatioDenominator); emit UpdatedTimeUnit(condition.timeUnit, _timeUnit); } /** * @notice Set rewards per unit of time. * Interpreted as (numerator/denominator) rewards per second/per day/etc based on time-unit. * * For e.g., ratio of 1/20 would mean 1 reward token for every 20 tokens staked. * @dev Can only be called by the contract owner. * @param _numerator Reward ratio numerator. * @param _denominator Reward ratio denominator. */ function setRewardRatio(uint256 _numerator, uint256 _denominator) external virtual onlyOwner { StakingCondition memory condition = stakingConditions[nextConditionId - 1]; require( _numerator != condition.rewardRatioNumerator || _denominator != condition.rewardRatioDenominator, "Reward ratio unchanged." ); _setStakingCondition(condition.timeUnit, _numerator, _denominator); emit UpdatedRewardRatio( condition.rewardRatioNumerator, _numerator, condition.rewardRatioDenominator, _denominator ); } /** * @dev Internal function to set a new staking condition with specified time unit and reward ratio. * This function creates a new staking condition and increments the condition ID. * It also manages the start and end timestamps for staking conditions. * This function is meant to be called internally from setRewardRatio or setTimeUnit * @param _timeUnit The time unit for the new staking condition. * @param _numerator The numerator part of the reward ratio for the new staking condition. * @param _denominator The denominator part of the reward ratio for the new staking condition. */ function _setStakingCondition(uint256 _timeUnit, uint256 _numerator, uint256 _denominator) internal virtual { require(_denominator != 0, "divide by 0"); require(_numerator != 0, "numerator can't be 0"); require(_numerator <= _denominator, "Reward ratio cannot be more than 100%"); require(_timeUnit != 0, "time unit can't be 0"); uint256 conditionId = nextConditionId; nextConditionId += 1; stakingConditions[conditionId] = StakingCondition({ timeUnit: _timeUnit, rewardRatioNumerator: _numerator, rewardRatioDenominator: _denominator, startTimestamp: block.timestamp, endTimestamp: 0 }); if (conditionId > 0) { stakingConditions[conditionId - 1].endTimestamp = block.timestamp; } } /** * @notice Pauses all staking activities. Withdrawals are still authorized. * @dev Can only be called by the contract owner. * @dev Emits the Paused event (inherited from Pausable contract). */ function pause() public onlyOwner { _pause(); } /** * @notice Resumes all staking activities. * @dev Can only be called by the contract owner. * @dev Emits the Unpaused event (inherited from Pausable contract). */ function unpause() public onlyOwner { _unpause(); } /** * @notice Allows the owner to forcibly withdraw staked tokens from a staker's position in case of an emergency. * @dev This function can be called only by the owner. * @dev Emits the TokensWithdrawnAdmin event * @param _staker The address of the staker from whom tokens are being withdrawn. */ function forceWithdraw(address _staker) public onlyOwner { uint256 _amountStaked = stakers[_staker].amountStaked; require(_amountStaked != 0, "Withdrawing 0 tokens"); stakingTokenBalance -= _amountStaked; _updateUnclaimedRewardsForStaker(_staker); stakers[_staker].amountStaked -= _amountStaked; if (stakers[_staker].amountStaked == 0) { totalStakers --; } _safeTransferERC20( stakingToken, address(this), _staker, _amountStaked ); emit TokensWithdrawnAdmin(_stakeMsgSender(), _amountStaked); } /** * @dev Internal function to handle the logic of staking tokens. * Updates the staking balance and, if necessary, the unclaimed rewards for a staker. * Emits a TokensStaked event upon successful staking. * @param _amount The amount of tokens to be staked. * @notice This function does not directly interact with users and is intended to be called by the stake function. */ function _stake(uint256 _amount) internal virtual { require(_amount != 0, "Staking 0 tokens"); address _stakingToken = stakingToken; if (stakers[_stakeMsgSender()].amountStaked > 0) { _updateUnclaimedRewardsForStaker(_stakeMsgSender()); } else { stakers[_stakeMsgSender()].timeOfLastUpdate = block.timestamp; stakers[_stakeMsgSender()].conditionIdOflastUpdate = nextConditionId - 1; totalStakers++; } uint256 balanceBefore = IERC20(_stakingToken).balanceOf(address(this)); _safeTransferERC20( stakingToken, _stakeMsgSender(), address(this), _amount ); uint256 actualAmount = IERC20(_stakingToken).balanceOf(address(this)) - balanceBefore; stakers[_stakeMsgSender()].amountStaked += actualAmount; stakingTokenBalance += actualAmount; emit TokensStaked(_stakeMsgSender(), actualAmount); } /** * @dev Internal function to update the unclaimed rewards for a specific staking position. * Calculates the new rewards based on the current staking condition and adds them * to the staker's unclaimed rewards. * @param _staker The address of the staker whose rewards are being updated. */ function _updateUnclaimedRewardsForStaker(address _staker) internal virtual { uint256 rewards = _calculateRewards(_staker); stakers[_staker].unclaimedRewards += rewards; stakers[_staker].timeOfLastUpdate = block.timestamp; stakers[_staker].conditionIdOflastUpdate = nextConditionId - 1; } /** * @dev Internal view function to calculate the rewards for a staker's position. * The calculation takes into account the staker's amount staked, the time elapsed, * the reward ratio of the current staking condition and the previous staking conditions if they applies. * @param _staker The address of the staker whose rewards are being calculated. * @return _rewards The total calculated reward amount for the staker. */ function _calculateRewards(address _staker) internal view virtual returns (uint256 _rewards) { StakerStaking memory staker = stakers[_staker]; uint256 _stakerConditionId = staker.conditionIdOflastUpdate; uint256 _nextConditionId = nextConditionId; for (uint256 i = _stakerConditionId; i < _nextConditionId; i += 1) { StakingCondition memory condition = stakingConditions[i]; uint256 startTime = i != _stakerConditionId ? condition.startTimestamp : staker.timeOfLastUpdate; uint256 endTime = condition.endTimestamp != 0 ? condition.endTimestamp : block.timestamp; (bool noOverflowProduct, uint256 rewardsProduct) = Math.tryMul( (endTime - startTime) * staker.amountStaked, condition.rewardRatioNumerator ); (bool noOverflowSum, uint256 rewardsSum) = Math.tryAdd( _rewards, (rewardsProduct / condition.timeUnit) / condition.rewardRatioDenominator ); _rewards = noOverflowProduct && noOverflowSum ? rewardsSum : _rewards; } (, _rewards) = Math.tryMul(_rewards, 10 ** rewardTokenDecimals); _rewards /= (10 ** stakingTokenDecimals); } /// @dev Exposes the ability to override the msg sender -- support ERC2771. function _stakeMsgSender() internal virtual returns (address) { return msg.sender; } /** * @dev Internal function to safely transfer ERC20 tokens. * It handles transfers between any two addresses, including the contract itself. * @param _currency The address of the ERC20 token to be transferred. * @param _from The address from which the tokens are transferred. * @param _to The address to which the tokens are transferred. * @param _amount The amount of tokens to be transferred. */ function _safeTransferERC20(address _currency, address _from, address _to, uint256 _amount) internal { if (_from == _to) { return; } if (_from == address(this)) { SafeERC20.safeTransfer(IERC20(_currency), _to, _amount); } else { SafeERC20.safeTransferFrom(IERC20(_currency), _from, _to, _amount); } } /** * @dev Internal function to handle the logic of withdrawing staked tokens. * This function updates the staker's balance, update the unclaimed rewards, * and emits a TokensWithdrawn event upon successful withdrawal. * @param _amount The amount of tokens to be withdrawn. */ function _withdraw(uint256 _amount) internal virtual { uint256 _amountStaked = stakers[_stakeMsgSender()].amountStaked; require(_amount != 0, "Withdrawing 0 tokens"); require(_amountStaked >= _amount, "Withdrawing more than staked"); _updateUnclaimedRewardsForStaker(_stakeMsgSender()); stakers[_stakeMsgSender()].amountStaked -= _amount; stakingTokenBalance -= _amount; if (stakers[_stakeMsgSender()].amountStaked == 0) { totalStakers --; } _safeTransferERC20( stakingToken, address(this), _stakeMsgSender(), _amount ); emit TokensWithdrawn(_stakeMsgSender(), _amount); } /** * @dev Internal function to handle the logic of claiming rewards for a staker. * It calculates the total rewards, transfers them from the reward wallet to the staker, * and updates relevant state variables. * Emit the RewardsClaimed event */ function _claimRewards() internal virtual { uint256 rewards = stakers[_stakeMsgSender()].unclaimedRewards + _calculateRewards(_stakeMsgSender()); require(rewards != 0, "No rewards"); stakers[_stakeMsgSender()].timeOfLastUpdate = block.timestamp; stakers[_stakeMsgSender()].unclaimedRewards = 0; stakers[_stakeMsgSender()].conditionIdOflastUpdate = nextConditionId - 1; stakersRewardClaimed[_stakeMsgSender()] += rewards; totalRewardClaimed += rewards; // @dev Transfer the reward to the user _safeTransferERC20( rewardToken, rewardWallet, _stakeMsgSender(), rewards ); emit RewardsClaimed(_stakeMsgSender(), rewards); } /// @dev Return the information about a specific staker /// @param _staker Address of the staker. /// @return stackInfo The data for the staking position. function getStakingInfo(address _staker) external view returns (StakerStaking memory stackInfo) { require(stakers[_staker].timeOfLastUpdate > 0, "Staker not found"); stackInfo = stakers[_staker]; stackInfo.unclaimedRewards = stackInfo.unclaimedRewards + _calculateRewards(_staker); } /** * @notice Allows a user to stake a specified amount of tokens. * This will create an new position for the user or increase an existing one. * @dev This function calls the internal _stake function and applies checks for pausing and reentrancy. * @param _amount The amount of tokens to be staked by the user. */ function stake(uint256 _amount) external whenNotPaused nonReentrant { _stake(_amount); } /** * @notice Allows a user to withdraw tokens from their staking position. * @dev This function calls the internal _withdraw function for the specified amount. * @param amount The amount of tokens to withdraw.. */ function withdraw(uint256 amount) external nonReentrant { _withdraw(amount); } /** * @notice Allows a staker to claim their accumulated rewards. * @dev This function calls the internal _claimRewards function to handle the reward claiming logic. * Emits a RewardsClaimed event upon successful claiming of rewards. */ function claimRewards() external nonReentrant { _claimRewards(); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/IERC20Metadata.sol) pragma solidity ^0.8.20; import {IERC20} from "../IERC20.sol"; /** * @dev Interface for the optional metadata functions from the ERC20 standard. */ interface IERC20Metadata is IERC20 { /** * @dev Returns the name of the token. */ function name() external view returns (string memory); /** * @dev Returns the symbol of the token. */ function symbol() external view returns (string memory); /** * @dev Returns the decimals places of the token. */ function decimals() external view returns (uint8); }
// SPDX-License-Identifier: MIT // 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); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/utils/SafeERC20.sol) pragma solidity ^0.8.20; import {IERC20} from "../IERC20.sol"; import {IERC20Permit} from "../extensions/IERC20Permit.sol"; import {Address} from "../../../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; /** * @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; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol) pragma solidity ^0.8.20; import {Context} from "../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. * * 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); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/Pausable.sol) pragma solidity ^0.8.20; import {Context} from "../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 { bool private _paused; /** * @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); /** * @dev The operation failed because the contract is paused. */ error EnforcedPause(); /** * @dev The operation failed because the contract is not paused. */ error ExpectedPause(); /** * @dev Initializes the contract in unpaused state. */ constructor() { _paused = false; } /** * @dev Modifier to make a function callable only when the contract is not paused. * * Requirements: * * - The contract must not be paused. */ modifier whenNotPaused() { _requireNotPaused(); _; } /** * @dev Modifier to make a function callable only when the contract is paused. * * Requirements: * * - The contract must be paused. */ modifier whenPaused() { _requirePaused(); _; } /** * @dev Returns true if the contract is paused, and false otherwise. */ function paused() public view virtual returns (bool) { return _paused; } /** * @dev Throws if the contract is paused. */ function _requireNotPaused() internal view virtual { if (paused()) { revert EnforcedPause(); } } /** * @dev Throws if the contract is not paused. */ function _requirePaused() internal view virtual { if (!paused()) { revert ExpectedPause(); } } /** * @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 // OpenZeppelin Contracts (last updated v5.0.0) (utils/ReentrancyGuard.sol) pragma solidity ^0.8.20; /** * @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; /** * @dev Unauthorized reentrant call. */ error ReentrancyGuardReentrantCall(); constructor() { _status = NOT_ENTERED; } /** * @dev Prevents a contract from calling itself, directly or indirectly. * Calling a `nonReentrant` function from another `nonReentrant` * function is not supported. It is possible to prevent this from happening * by making the `nonReentrant` function external, and making it call a * `private` function that does the actual work. */ modifier nonReentrant() { _nonReentrantBefore(); _; _nonReentrantAfter(); } function _nonReentrantBefore() private { // On the first call to nonReentrant, _status will be NOT_ENTERED if (_status == ENTERED) { revert ReentrancyGuardReentrantCall(); } // Any calls to nonReentrant after this point will fail _status = ENTERED; } function _nonReentrantAfter() private { // By storing the original value once again, a refund is triggered (see // https://eips.ethereum.org/EIPS/eip-2200) _status = NOT_ENTERED; } /** * @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a * `nonReentrant` function in the call stack. */ function _reentrancyGuardEntered() internal view returns (bool) { return _status == ENTERED; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/math/Math.sol) pragma solidity ^0.8.20; /** * @dev Standard math utilities missing in the Solidity language. */ library Math { /** * @dev Muldiv operation overflow. */ error MathOverflowedMulDiv(); enum Rounding { Floor, // Toward negative infinity Ceil, // Toward positive infinity Trunc, // Toward zero Expand // Away from zero } /** * @dev Returns the addition of two unsigned integers, with an overflow flag. */ function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); } } /** * @dev Returns the subtraction of two unsigned integers, with an overflow flag. */ function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b > a) return (false, 0); return (true, a - b); } } /** * @dev Returns the multiplication of two unsigned integers, with an overflow flag. */ function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) return (true, 0); uint256 c = a * b; if (c / a != b) return (false, 0); return (true, c); } } /** * @dev Returns the division of two unsigned integers, with a division by zero flag. */ function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a / b); } } /** * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag. */ function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a % b); } } /** * @dev Returns the largest of two numbers. */ function max(uint256 a, uint256 b) internal pure returns (uint256) { return a > b ? a : b; } /** * @dev Returns the smallest of two numbers. */ function min(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; } /** * @dev Returns the average of two numbers. The result is rounded towards * zero. */ function average(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b) / 2 can overflow. return (a & b) + (a ^ b) / 2; } /** * @dev Returns the ceiling of the division of two numbers. * * This differs from standard division with `/` in that it rounds towards infinity instead * of rounding towards zero. */ function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) { if (b == 0) { // Guarantee the same behavior as in a regular Solidity division. return a / b; } // (a + b - 1) / b can overflow on addition, so we distribute. return a == 0 ? 0 : (a - 1) / b + 1; } /** * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or * denominator == 0. * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) with further edits by * Uniswap Labs also under MIT license. */ function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) { unchecked { // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256 // variables such that product = prod1 * 2^256 + prod0. uint256 prod0 = x * y; // Least significant 256 bits of the product uint256 prod1; // Most significant 256 bits of the product assembly { let mm := mulmod(x, y, not(0)) prod1 := sub(sub(mm, prod0), lt(mm, prod0)) } // Handle non-overflow cases, 256 by 256 division. if (prod1 == 0) { // Solidity will revert if denominator == 0, unlike the div opcode on its own. // The surrounding unchecked block does not change this fact. // See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic. return prod0 / denominator; } // Make sure the result is less than 2^256. Also prevents denominator == 0. if (denominator <= prod1) { revert MathOverflowedMulDiv(); } /////////////////////////////////////////////// // 512 by 256 division. /////////////////////////////////////////////// // Make division exact by subtracting the remainder from [prod1 prod0]. uint256 remainder; assembly { // Compute remainder using mulmod. remainder := mulmod(x, y, denominator) // Subtract 256 bit number from 512 bit number. prod1 := sub(prod1, gt(remainder, prod0)) prod0 := sub(prod0, remainder) } // Factor powers of two out of denominator and compute largest power of two divisor of denominator. // Always >= 1. See https://cs.stackexchange.com/q/138556/92363. uint256 twos = denominator & (0 - denominator); assembly { // Divide denominator by twos. denominator := div(denominator, twos) // Divide [prod1 prod0] by twos. prod0 := div(prod0, twos) // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one. twos := add(div(sub(0, twos), twos), 1) } // Shift in bits from prod1 into prod0. prod0 |= prod1 * twos; // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for // four bits. That is, denominator * inv = 1 mod 2^4. uint256 inverse = (3 * denominator) ^ 2; // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also // works in modular arithmetic, doubling the correct bits in each step. inverse *= 2 - denominator * inverse; // inverse mod 2^8 inverse *= 2 - denominator * inverse; // inverse mod 2^16 inverse *= 2 - denominator * inverse; // inverse mod 2^32 inverse *= 2 - denominator * inverse; // inverse mod 2^64 inverse *= 2 - denominator * inverse; // inverse mod 2^128 inverse *= 2 - denominator * inverse; // inverse mod 2^256 // Because the division is now exact we can divide by multiplying with the modular inverse of denominator. // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1 // is no longer required. result = prod0 * inverse; return result; } } /** * @notice Calculates x * y / denominator with full precision, following the selected rounding direction. */ function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) { uint256 result = mulDiv(x, y, denominator); if (unsignedRoundsUp(rounding) && mulmod(x, y, denominator) > 0) { result += 1; } return result; } /** * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded * towards zero. * * Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11). */ function sqrt(uint256 a) internal pure returns (uint256) { if (a == 0) { return 0; } // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target. // // We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`. // // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)` // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))` // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)` // // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit. uint256 result = 1 << (log2(a) >> 1); // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128, // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision // into the expected uint128 result. unchecked { result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; return min(result, a / result); } } /** * @notice Calculates sqrt(a), following the selected rounding direction. */ function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = sqrt(a); return result + (unsignedRoundsUp(rounding) && result * result < a ? 1 : 0); } } /** * @dev Return the log in base 2 of a positive value rounded towards zero. * Returns 0 if given 0. */ function log2(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >> 128 > 0) { value >>= 128; result += 128; } if (value >> 64 > 0) { value >>= 64; result += 64; } if (value >> 32 > 0) { value >>= 32; result += 32; } if (value >> 16 > 0) { value >>= 16; result += 16; } if (value >> 8 > 0) { value >>= 8; result += 8; } if (value >> 4 > 0) { value >>= 4; result += 4; } if (value >> 2 > 0) { value >>= 2; result += 2; } if (value >> 1 > 0) { result += 1; } } return result; } /** * @dev Return the log in base 2, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log2(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log2(value); return result + (unsignedRoundsUp(rounding) && 1 << result < value ? 1 : 0); } } /** * @dev Return the log in base 10 of a positive value rounded towards zero. * Returns 0 if given 0. */ function log10(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >= 10 ** 64) { value /= 10 ** 64; result += 64; } if (value >= 10 ** 32) { value /= 10 ** 32; result += 32; } if (value >= 10 ** 16) { value /= 10 ** 16; result += 16; } if (value >= 10 ** 8) { value /= 10 ** 8; result += 8; } if (value >= 10 ** 4) { value /= 10 ** 4; result += 4; } if (value >= 10 ** 2) { value /= 10 ** 2; result += 2; } if (value >= 10 ** 1) { result += 1; } } return result; } /** * @dev Return the log in base 10, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log10(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log10(value); return result + (unsignedRoundsUp(rounding) && 10 ** result < value ? 1 : 0); } } /** * @dev Return the log in base 256 of a positive value rounded towards zero. * Returns 0 if given 0. * * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string. */ function log256(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >> 128 > 0) { value >>= 128; result += 16; } if (value >> 64 > 0) { value >>= 64; result += 8; } if (value >> 32 > 0) { value >>= 32; result += 4; } if (value >> 16 > 0) { value >>= 16; result += 2; } if (value >> 8 > 0) { result += 1; } } return result; } /** * @dev Return the log in base 256, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log256(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log256(value); return result + (unsignedRoundsUp(rounding) && 1 << (result << 3) < value ? 1 : 0); } } /** * @dev Returns whether a provided rounding mode is considered rounding up for unsigned integers. */ function unsignedRoundsUp(Rounding rounding) internal pure returns (bool) { return uint8(rounding) % 2 == 1; } }
// SPDX-License-Identifier: MIT // 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); }
// SPDX-License-Identifier: MIT // 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(); } } }
// SPDX-License-Identifier: MIT // 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; } }
{ "remappings": [ "@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/", "ds-test/=lib/forge-std/lib/ds-test/src/", "erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/", "forge-std/=lib/forge-std/src/", "openzeppelin-contracts/=lib/openzeppelin-contracts/" ], "optimizer": { "enabled": true, "runs": 200 }, "metadata": { "useLiteralContent": false, "bytecodeHash": "ipfs", "appendCBOR": true }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "evmVersion": "paris", "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[{"internalType":"address","name":"_stakingToken","type":"address"},{"internalType":"address","name":"_rewardToken","type":"address"},{"internalType":"address","name":"_rewardWallet","type":"address"},{"internalType":"uint80","name":"_timeUnit","type":"uint80"},{"internalType":"uint256","name":"_numerator","type":"uint256"},{"internalType":"uint256","name":"_denominator","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":"EnforcedPause","type":"error"},{"inputs":[],"name":"ExpectedPause","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":[],"name":"ReentrancyGuardReentrantCall","type":"error"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"SafeERC20FailedOperation","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"staker","type":"address"},{"indexed":false,"internalType":"uint256","name":"rewardAmount","type":"uint256"}],"name":"RewardsClaimed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"staker","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"TokensStaked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"staker","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"TokensWithdrawn","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"staker","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"TokensWithdrawnAdmin","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"oldNumerator","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newNumerator","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"oldDenominator","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newDenominator","type":"uint256"}],"name":"UpdatedRewardRatio","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"oldTimeUnit","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newTimeUnit","type":"uint256"}],"name":"UpdatedTimeUnit","type":"event"},{"inputs":[],"name":"claimRewards","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_staker","type":"address"}],"name":"forceWithdraw","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getRewardRatio","outputs":[{"internalType":"uint256","name":"_numerator","type":"uint256"},{"internalType":"uint256","name":"_denominator","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_staker","type":"address"}],"name":"getStakingInfo","outputs":[{"components":[{"internalType":"uint256","name":"conditionIdOflastUpdate","type":"uint256"},{"internalType":"uint256","name":"timeOfLastUpdate","type":"uint256"},{"internalType":"uint256","name":"amountStaked","type":"uint256"},{"internalType":"uint256","name":"unclaimedRewards","type":"uint256"}],"internalType":"struct StakingFlex.StakerStaking","name":"stackInfo","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getTimeUnit","outputs":[{"internalType":"uint256","name":"_timeUnit","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":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"rewardToken","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"rewardTokenDecimals","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"rewardWallet","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_numerator","type":"uint256"},{"internalType":"uint256","name":"_denominator","type":"uint256"}],"name":"setRewardRatio","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_timeUnit","type":"uint256"}],"name":"setTimeUnit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"stake","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"stakers","outputs":[{"internalType":"uint256","name":"conditionIdOflastUpdate","type":"uint256"},{"internalType":"uint256","name":"timeOfLastUpdate","type":"uint256"},{"internalType":"uint256","name":"amountStaked","type":"uint256"},{"internalType":"uint256","name":"unclaimedRewards","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"stakersRewardClaimed","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"stakingToken","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"stakingTokenBalance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"stakingTokenDecimals","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalRewardClaimed","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalStakers","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":"amount","type":"uint256"}],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"}]
Contract Creation Code
6101206040523480156200001257600080fd5b506040516200210738038062002107833981016040819052620000359162000507565b33806200005d57604051631e4fbdf760e01b8152600060048201526024015b60405180910390fd5b6200006881620002ae565b506000805460ff60a01b1916905560018055306001600160a01b03851603620000e85760405162461bcd60e51b815260206004820152602b60248201527f5265776172642077616c6c65742063616e6e6f742062652074686520636f6e7460448201526a3930b1ba1034ba39b2b63360a91b606482015260840162000054565b6001600160a01b038616158015906200010957506001600160a01b03851615155b80156200011e57506001600160a01b03841615155b620001925760405162461bcd60e51b815260206004820152603660248201527f5374616b696e672f52657761726420746f6b656e2f77616c6c65742063616e6e60448201527f6f7420626520746865207a65726f206164647265737300000000000000000000606482015260840162000054565b6001600160a01b03861660808190526040805163313ce56760e01b8152905163313ce567916004808201926020929091908290030181865afa158015620001dd573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000203919062000586565b60ff1660a08181525050846001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa1580156200024c573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000272919062000586565b60ff1660e0526001600160a01b0380861660c052841661010052620002a26001600160501b0384168383620002fe565b505050505050620005fa565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b806000036200033e5760405162461bcd60e51b815260206004820152600b60248201526a064697669646520627920360ac1b604482015260640162000054565b81600003620003905760405162461bcd60e51b815260206004820152601460248201527f6e756d657261746f722063616e27742062652030000000000000000000000000604482015260640162000054565b80821115620003f05760405162461bcd60e51b815260206004820152602560248201527f52657761726420726174696f2063616e6e6f74206265206d6f7265207468616e604482015264203130302560d81b606482015260840162000054565b82600003620004425760405162461bcd60e51b815260206004820152601460248201527f74696d6520756e69742063616e27742062652030000000000000000000000000604482015260640162000054565b60058054906001906000620004588385620005c8565b90915550506040805160a081018252858152426020808301918252600083850181815260608501898152608086018981528884526008909452959091209351845591516001840155905160028301559151600382015590516004909101558015620004e4574260086000620004cf600185620005e4565b81526020810191909152604001600020600201555b50505050565b80516001600160a01b03811681146200050257600080fd5b919050565b60008060008060008060c087890312156200052157600080fd5b6200052c87620004ea565b95506200053c60208801620004ea565b94506200054c60408801620004ea565b60608801519094506001600160501b03811681146200056a57600080fd5b809350506080870151915060a087015190509295509295509295565b6000602082840312156200059957600080fd5b815160ff81168114620005ab57600080fd5b9392505050565b634e487b7160e01b600052601160045260246000fd5b80820180821115620005de57620005de620005b2565b92915050565b81810381811115620005de57620005de620005b2565b60805160a05160c05160e05161010051611a9062000677600039600081816104020152610e9201526000818161031901526114a90152600081816103db0152610e7101526000818161039901526114dd015260008181610228015281816107bf01528181610d310152818161112e015261121d0152611a906000f3fe608060405234801561001057600080fd5b50600436106101725760003560e01c8063882f3e16116100de578063a694fc3a11610097578063d68124c711610071578063d68124c7146103bb578063f2fde38b146103c3578063f7c618c1146103d6578063fb75b2c7146103fd57600080fd5b8063a694fc3a1461033b578063aa4704f31461034e578063b9f7a7b51461039457600080fd5b8063882f3e16146102735780638caaa271146102865780638da5cb5b1461028f5780639168ae72146102a057806397e1b4bc146102f75780639bdcecd11461031457600080fd5b80636360106f116101305780636360106f146101ff5780636f83f6a214610212578063715018a61461021b57806372f702f3146102235780638456cb5914610262578063869890381461026a57600080fd5b80621b7934146101775780632e1a7d4d1461018c578063372500ab1461019f578063385e381d146101a75780633f4ba83a146101da5780635c975abb146101e2575b600080fd5b61018a6101853660046117e1565b610424565b005b61018a61019a366004611803565b610556565b61018a610573565b6101c76101b536600461181c565b60036020526000908152604090205481565b6040519081526020015b60405180910390f35b61018a61058e565b600054600160a01b900460ff1660405190151581526020016101d1565b61018a61020d366004611803565b61059e565b6101c760075481565b61018a6106a4565b61024a7f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b0390911681526020016101d1565b61018a6106b6565b6101c760065481565b61018a61028136600461181c565b6106c6565b6101c760045481565b6000546001600160a01b031661024a565b6102d76102ae36600461181c565b600260208190526000918252604090912080546001820154928201546003909201549092919084565b6040805194855260208501939093529183015260608201526080016101d1565b6102ff610820565b604080519283526020830191909152016101d1565b6101c77f000000000000000000000000000000000000000000000000000000000000000081565b61018a610349366004611803565b610875565b61036161035c36600461181c565b61088e565b6040516101d191908151815260208083015190820152604080830151908201526060918201519181019190915260800190565b6101c77f000000000000000000000000000000000000000000000000000000000000000081565b6101c761097f565b61018a6103d136600461181c565b6109ab565b61024a7f000000000000000000000000000000000000000000000000000000000000000081565b61024a7f000000000000000000000000000000000000000000000000000000000000000081565b61042c6109e6565b6000600860006001600554610441919061185b565b81526020019081526020016000206040518060a00160405290816000820154815260200160018201548152602001600282015481526020016003820154815260200160048201548152505090508060600151831415806104a5575080608001518214155b6104f65760405162461bcd60e51b815260206004820152601760248201527f52657761726420726174696f20756e6368616e6765642e00000000000000000060448201526064015b60405180910390fd5b8051610503908484610a13565b60608082015160808084015160408051938452602084018890528301529181018490527feb6684a1e7c9bd2adc792fb253558f022bcbef39fb6ad31dc58cdfefdd5b5190910160405180910390a1505050565b61055e610be0565b61056781610c0a565b61057060018055565b50565b61057b610be0565b610583610d8a565b61058c60018055565b565b6105966109e6565b61058c610ef0565b6105a66109e6565b60006008600060016005546105bb919061185b565b81526020019081526020016000206040518060a0016040529081600082015481526020016001820154815260200160028201548152602001600382015481526020016004820154815250509050806000015182036106525760405162461bcd60e51b81526020600482015260146024820152732a34b6b296bab734ba103ab731b430b733b2b21760611b60448201526064016104ed565b6106658282606001518360800151610a13565b805160408051918252602082018490527fd968de290ed68f978b9e4816f7d4be9ef46189fe8eeb3eeb86199e7229cf2de0910160405180910390a15050565b6106ac6109e6565b61058c6000610f45565b6106be6109e6565b61058c610f95565b6106ce6109e6565b6001600160a01b038116600090815260026020819052604082200154908190036107315760405162461bcd60e51b81526020600482015260146024820152735769746864726177696e67203020746f6b656e7360601b60448201526064016104ed565b8060046000828254610743919061185b565b90915550610752905082610fd8565b6001600160a01b0382166000908152600260208190526040822001805483929061077d90849061185b565b90915550506001600160a01b03821660009081526002602081905260408220015490036107ba57600680549060006107b48361186e565b91905055505b6107e67f0000000000000000000000000000000000000000000000000000000000000000308484611064565b60405181815233907f61b39c63d13e99e6b90cafd8c3c2f2ebfbbff983bd8504fc7389da5f3702f9e8906020015b60405180910390a25050565b600080600860006001600554610836919061185b565b815260200190815260200160002060030154915060086000600160055461085d919061185b565b81526020019081526020016000206004015490509091565b61087d6110aa565b610885610be0565b610567816110d5565b6108b96040518060800160405280600081526020016000815260200160008152602001600081525090565b6001600160a01b0382166000908152600260205260409020600101546109145760405162461bcd60e51b815260206004820152601060248201526f14dd185ad95c881b9bdd08199bdd5b9960821b60448201526064016104ed565b506001600160a01b03811660009081526002602081815260409283902083516080810185528154815260018201549281019290925291820154928101929092526003015460608201526109668261133b565b81606001516109759190611885565b6060820152919050565b6000600860006001600554610994919061185b565b815260200190815260200160002060000154905090565b6109b36109e6565b6001600160a01b0381166109dd57604051631e4fbdf760e01b8152600060048201526024016104ed565b61057081610f45565b6000546001600160a01b0316331461058c5760405163118cdaa760e01b81523360048201526024016104ed565b80600003610a515760405162461bcd60e51b815260206004820152600b60248201526a064697669646520627920360ac1b60448201526064016104ed565b81600003610a985760405162461bcd60e51b815260206004820152601460248201527306e756d657261746f722063616e277420626520360641b60448201526064016104ed565b80821115610af65760405162461bcd60e51b815260206004820152602560248201527f52657761726420726174696f2063616e6e6f74206265206d6f7265207468616e604482015264203130302560d81b60648201526084016104ed565b82600003610b3d5760405162461bcd60e51b8152602060048201526014602482015273074696d6520756e69742063616e277420626520360641b60448201526064016104ed565b60058054906001906000610b518385611885565b90915550506040805160a081018252858152426020808301918252600083850181815260608501898152608086018981528884526008909452959091209351845591516001840155905160028301559151600382015590516004909101558015610bda574260086000610bc560018561185b565b81526020810191909152604001600020600201555b50505050565b600260015403610c0357604051633ee5aeb560e01b815260040160405180910390fd5b6002600155565b3360009081526002602081905260408220015490829003610c645760405162461bcd60e51b81526020600482015260146024820152735769746864726177696e67203020746f6b656e7360601b60448201526064016104ed565b81811015610cb45760405162461bcd60e51b815260206004820152601c60248201527f5769746864726177696e67206d6f7265207468616e207374616b65640000000060448201526064016104ed565b610cbd33610fd8565b3360009081526002602081905260408220018054849290610cdf90849061185b565b925050819055508160046000828254610cf8919061185b565b9091555050336000908152600260208190526040822001549003610d2c5760068054906000610d268361186e565b91905055505b610d587f0000000000000000000000000000000000000000000000000000000000000000303385611064565b60405182815233907f6352c5382c4a4578e712449ca65e83cdb392d045dfcf1cad9615189db2da244b90602001610814565b6000610d953361133b565b33600090815260026020526040902060030154610db29190611885565b905080600003610df15760405162461bcd60e51b815260206004820152600a6024820152694e6f207265776172647360b01b60448201526064016104ed565b33600090815260026020526040812042600180830191909155600390910191909155600554610e20919061185b565b33600090815260026020908152604080832093909355600390529081208054839290610e4d908490611885565b925050819055508060076000828254610e669190611885565b90915550610eb890507f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000003384611064565b60405181815233907ffc30cddea38e2bf4d6ea7d3f9ed3b6ad7f176419f4963bd81318067a4aee73fe9060200160405180910390a250565b610ef8611516565b6000805460ff60a01b191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b610f9d6110aa565b6000805460ff60a01b1916600160a01b1790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258610f283390565b6000610fe38261133b565b6001600160a01b038316600090815260026020526040812060030180549293508392909190611013908490611885565b90915550506001600160a01b038216600090815260026020526040902042600191820155600554611044919061185b565b6001600160a01b0390921660009081526002602052604090209190915550565b816001600160a01b0316836001600160a01b03160315610bda57306001600160a01b0384160361109e57611099848383611540565b610bda565b610bda848484846115a4565b600054600160a01b900460ff161561058c5760405163d93c066560e01b815260040160405180910390fd5b806000036111185760405162461bcd60e51b815260206004820152601060248201526f5374616b696e67203020746f6b656e7360801b60448201526064016104ed565b33600090815260026020819052604090912001547f000000000000000000000000000000000000000000000000000000000000000090156111615761115c33610fd8565b6111ab565b33600090815260026020526040902042600191820155600554611184919061185b565b3360009081526002602052604081209190915560068054916111a583611898565b91905055505b6040516370a0823160e01b81523060048201526000906001600160a01b038316906370a0823190602401602060405180830381865afa1580156111f2573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061121691906118b1565b90506112447f0000000000000000000000000000000000000000000000000000000000000000333086611064565b6040516370a0823160e01b815230600482015260009082906001600160a01b038516906370a0823190602401602060405180830381865afa15801561128d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112b191906118b1565b6112bb919061185b565b336000908152600260208190526040822001805492935083929091906112e2908490611885565b9250508190555080600460008282546112fb9190611885565b909155505060405181815233907fb539ca1e5c8d398ddf1c41c30166f33404941683be4683319b57669a93dad4ef9060200160405180910390a250505050565b6001600160a01b0381166000908152600260208181526040808420815160808101835281548082526001830154948201949094529381015491840191909152600301546060830152600554815b8181101561149f576000818152600860209081526040808320815160a0810183528154815260018201549381019390935260028101549183019190915260038101546060830152600401546080820152908483036113ea5785602001516113f0565b81602001515b905060008260400151600003611406574261140c565b82604001515b905060008061143989604001518585611425919061185b565b61142f91906118ca565b86606001516115dd565b915091506000806114688c886080015189600001518661145991906118f7565b61146391906118f7565b611628565b915091508380156114765750815b611480578b611482565b805b9b50505050505050506001816114989190611885565b9050611388565b506114d4846114cf7f0000000000000000000000000000000000000000000000000000000000000000600a6119fd565b6115dd565b945061150390507f0000000000000000000000000000000000000000000000000000000000000000600a6119fd565b61150d90856118f7565b95945050505050565b600054600160a01b900460ff1661058c57604051638dfc202b60e01b815260040160405180910390fd5b6040516001600160a01b0383811660248301526044820183905261159f91859182169063a9059cbb906064015b604051602081830303815290604052915060e01b6020820180516001600160e01b038381831617835250505050611643565b505050565b6040516001600160a01b038481166024830152838116604483015260648201839052610bda9186918216906323b872dd9060840161156d565b600080836000036115f45750600190506000611621565b83830283858281611607576116076118e1565b041461161a576000809250925050611621565b6001925090505b9250929050565b6000808383018481101561161a576000809250925050611621565b60006116586001600160a01b038416836116a6565b9050805160001415801561167d57508080602001905181019061167b9190611a09565b155b1561159f57604051635274afe760e01b81526001600160a01b03841660048201526024016104ed565b60606116b4838360006116bd565b90505b92915050565b6060814710156116e25760405163cd78605960e01b81523060048201526024016104ed565b600080856001600160a01b031684866040516116fe9190611a2b565b60006040518083038185875af1925050503d806000811461173b576040519150601f19603f3d011682016040523d82523d6000602084013e611740565b606091505b509150915061175086838361175c565b925050505b9392505050565b6060826117715761176c826117b8565b611755565b815115801561178857506001600160a01b0384163b155b156117b157604051639996b31560e01b81526001600160a01b03851660048201526024016104ed565b5080611755565b8051156117c85780518082602001fd5b604051630a12f52160e11b815260040160405180910390fd5b600080604083850312156117f457600080fd5b50508035926020909101359150565b60006020828403121561181557600080fd5b5035919050565b60006020828403121561182e57600080fd5b81356001600160a01b038116811461175557600080fd5b634e487b7160e01b600052601160045260246000fd5b818103818111156116b7576116b7611845565b60008161187d5761187d611845565b506000190190565b808201808211156116b7576116b7611845565b6000600182016118aa576118aa611845565b5060010190565b6000602082840312156118c357600080fd5b5051919050565b80820281158282048414176116b7576116b7611845565b634e487b7160e01b600052601260045260246000fd5b60008261191457634e487b7160e01b600052601260045260246000fd5b500490565b600181815b8085111561195457816000190482111561193a5761193a611845565b8085161561194757918102915b93841c939080029061191e565b509250929050565b60008261196b575060016116b7565b81611978575060006116b7565b816001811461198e5760028114611998576119b4565b60019150506116b7565b60ff8411156119a9576119a9611845565b50506001821b6116b7565b5060208310610133831016604e8410600b84101617156119d7575081810a6116b7565b6119e18383611919565b80600019048211156119f5576119f5611845565b029392505050565b60006116b4838361195c565b600060208284031215611a1b57600080fd5b8151801515811461175557600080fd5b6000825160005b81811015611a4c5760208186018101518583015201611a32565b50600092019182525091905056fea26469706673582212201cdc1367ee5ee0e8c2955af5cce141005ce58938dded8a92d2abe37976bffc3e64736f6c634300081700330000000000000000000000002f3e306d9f02ee8e8850f9040404918d0b3452070000000000000000000000002f3e306d9f02ee8e8850f9040404918d0b345207000000000000000000000000ccc388e27e0da13db9f2f22c8035bd1df211036e0000000000000000000000000000000000000000000000000000000001e1338000000000000000000000000000000000000000000000000000000000000000050000000000000000000000000000000000000000000000000000000000000064
Deployed Bytecode
0x608060405234801561001057600080fd5b50600436106101725760003560e01c8063882f3e16116100de578063a694fc3a11610097578063d68124c711610071578063d68124c7146103bb578063f2fde38b146103c3578063f7c618c1146103d6578063fb75b2c7146103fd57600080fd5b8063a694fc3a1461033b578063aa4704f31461034e578063b9f7a7b51461039457600080fd5b8063882f3e16146102735780638caaa271146102865780638da5cb5b1461028f5780639168ae72146102a057806397e1b4bc146102f75780639bdcecd11461031457600080fd5b80636360106f116101305780636360106f146101ff5780636f83f6a214610212578063715018a61461021b57806372f702f3146102235780638456cb5914610262578063869890381461026a57600080fd5b80621b7934146101775780632e1a7d4d1461018c578063372500ab1461019f578063385e381d146101a75780633f4ba83a146101da5780635c975abb146101e2575b600080fd5b61018a6101853660046117e1565b610424565b005b61018a61019a366004611803565b610556565b61018a610573565b6101c76101b536600461181c565b60036020526000908152604090205481565b6040519081526020015b60405180910390f35b61018a61058e565b600054600160a01b900460ff1660405190151581526020016101d1565b61018a61020d366004611803565b61059e565b6101c760075481565b61018a6106a4565b61024a7f0000000000000000000000002f3e306d9f02ee8e8850f9040404918d0b34520781565b6040516001600160a01b0390911681526020016101d1565b61018a6106b6565b6101c760065481565b61018a61028136600461181c565b6106c6565b6101c760045481565b6000546001600160a01b031661024a565b6102d76102ae36600461181c565b600260208190526000918252604090912080546001820154928201546003909201549092919084565b6040805194855260208501939093529183015260608201526080016101d1565b6102ff610820565b604080519283526020830191909152016101d1565b6101c77f000000000000000000000000000000000000000000000000000000000000000581565b61018a610349366004611803565b610875565b61036161035c36600461181c565b61088e565b6040516101d191908151815260208083015190820152604080830151908201526060918201519181019190915260800190565b6101c77f000000000000000000000000000000000000000000000000000000000000000581565b6101c761097f565b61018a6103d136600461181c565b6109ab565b61024a7f0000000000000000000000002f3e306d9f02ee8e8850f9040404918d0b34520781565b61024a7f000000000000000000000000ccc388e27e0da13db9f2f22c8035bd1df211036e81565b61042c6109e6565b6000600860006001600554610441919061185b565b81526020019081526020016000206040518060a00160405290816000820154815260200160018201548152602001600282015481526020016003820154815260200160048201548152505090508060600151831415806104a5575080608001518214155b6104f65760405162461bcd60e51b815260206004820152601760248201527f52657761726420726174696f20756e6368616e6765642e00000000000000000060448201526064015b60405180910390fd5b8051610503908484610a13565b60608082015160808084015160408051938452602084018890528301529181018490527feb6684a1e7c9bd2adc792fb253558f022bcbef39fb6ad31dc58cdfefdd5b5190910160405180910390a1505050565b61055e610be0565b61056781610c0a565b61057060018055565b50565b61057b610be0565b610583610d8a565b61058c60018055565b565b6105966109e6565b61058c610ef0565b6105a66109e6565b60006008600060016005546105bb919061185b565b81526020019081526020016000206040518060a0016040529081600082015481526020016001820154815260200160028201548152602001600382015481526020016004820154815250509050806000015182036106525760405162461bcd60e51b81526020600482015260146024820152732a34b6b296bab734ba103ab731b430b733b2b21760611b60448201526064016104ed565b6106658282606001518360800151610a13565b805160408051918252602082018490527fd968de290ed68f978b9e4816f7d4be9ef46189fe8eeb3eeb86199e7229cf2de0910160405180910390a15050565b6106ac6109e6565b61058c6000610f45565b6106be6109e6565b61058c610f95565b6106ce6109e6565b6001600160a01b038116600090815260026020819052604082200154908190036107315760405162461bcd60e51b81526020600482015260146024820152735769746864726177696e67203020746f6b656e7360601b60448201526064016104ed565b8060046000828254610743919061185b565b90915550610752905082610fd8565b6001600160a01b0382166000908152600260208190526040822001805483929061077d90849061185b565b90915550506001600160a01b03821660009081526002602081905260408220015490036107ba57600680549060006107b48361186e565b91905055505b6107e67f0000000000000000000000002f3e306d9f02ee8e8850f9040404918d0b345207308484611064565b60405181815233907f61b39c63d13e99e6b90cafd8c3c2f2ebfbbff983bd8504fc7389da5f3702f9e8906020015b60405180910390a25050565b600080600860006001600554610836919061185b565b815260200190815260200160002060030154915060086000600160055461085d919061185b565b81526020019081526020016000206004015490509091565b61087d6110aa565b610885610be0565b610567816110d5565b6108b96040518060800160405280600081526020016000815260200160008152602001600081525090565b6001600160a01b0382166000908152600260205260409020600101546109145760405162461bcd60e51b815260206004820152601060248201526f14dd185ad95c881b9bdd08199bdd5b9960821b60448201526064016104ed565b506001600160a01b03811660009081526002602081815260409283902083516080810185528154815260018201549281019290925291820154928101929092526003015460608201526109668261133b565b81606001516109759190611885565b6060820152919050565b6000600860006001600554610994919061185b565b815260200190815260200160002060000154905090565b6109b36109e6565b6001600160a01b0381166109dd57604051631e4fbdf760e01b8152600060048201526024016104ed565b61057081610f45565b6000546001600160a01b0316331461058c5760405163118cdaa760e01b81523360048201526024016104ed565b80600003610a515760405162461bcd60e51b815260206004820152600b60248201526a064697669646520627920360ac1b60448201526064016104ed565b81600003610a985760405162461bcd60e51b815260206004820152601460248201527306e756d657261746f722063616e277420626520360641b60448201526064016104ed565b80821115610af65760405162461bcd60e51b815260206004820152602560248201527f52657761726420726174696f2063616e6e6f74206265206d6f7265207468616e604482015264203130302560d81b60648201526084016104ed565b82600003610b3d5760405162461bcd60e51b8152602060048201526014602482015273074696d6520756e69742063616e277420626520360641b60448201526064016104ed565b60058054906001906000610b518385611885565b90915550506040805160a081018252858152426020808301918252600083850181815260608501898152608086018981528884526008909452959091209351845591516001840155905160028301559151600382015590516004909101558015610bda574260086000610bc560018561185b565b81526020810191909152604001600020600201555b50505050565b600260015403610c0357604051633ee5aeb560e01b815260040160405180910390fd5b6002600155565b3360009081526002602081905260408220015490829003610c645760405162461bcd60e51b81526020600482015260146024820152735769746864726177696e67203020746f6b656e7360601b60448201526064016104ed565b81811015610cb45760405162461bcd60e51b815260206004820152601c60248201527f5769746864726177696e67206d6f7265207468616e207374616b65640000000060448201526064016104ed565b610cbd33610fd8565b3360009081526002602081905260408220018054849290610cdf90849061185b565b925050819055508160046000828254610cf8919061185b565b9091555050336000908152600260208190526040822001549003610d2c5760068054906000610d268361186e565b91905055505b610d587f0000000000000000000000002f3e306d9f02ee8e8850f9040404918d0b345207303385611064565b60405182815233907f6352c5382c4a4578e712449ca65e83cdb392d045dfcf1cad9615189db2da244b90602001610814565b6000610d953361133b565b33600090815260026020526040902060030154610db29190611885565b905080600003610df15760405162461bcd60e51b815260206004820152600a6024820152694e6f207265776172647360b01b60448201526064016104ed565b33600090815260026020526040812042600180830191909155600390910191909155600554610e20919061185b565b33600090815260026020908152604080832093909355600390529081208054839290610e4d908490611885565b925050819055508060076000828254610e669190611885565b90915550610eb890507f0000000000000000000000002f3e306d9f02ee8e8850f9040404918d0b3452077f000000000000000000000000ccc388e27e0da13db9f2f22c8035bd1df211036e3384611064565b60405181815233907ffc30cddea38e2bf4d6ea7d3f9ed3b6ad7f176419f4963bd81318067a4aee73fe9060200160405180910390a250565b610ef8611516565b6000805460ff60a01b191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b610f9d6110aa565b6000805460ff60a01b1916600160a01b1790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258610f283390565b6000610fe38261133b565b6001600160a01b038316600090815260026020526040812060030180549293508392909190611013908490611885565b90915550506001600160a01b038216600090815260026020526040902042600191820155600554611044919061185b565b6001600160a01b0390921660009081526002602052604090209190915550565b816001600160a01b0316836001600160a01b03160315610bda57306001600160a01b0384160361109e57611099848383611540565b610bda565b610bda848484846115a4565b600054600160a01b900460ff161561058c5760405163d93c066560e01b815260040160405180910390fd5b806000036111185760405162461bcd60e51b815260206004820152601060248201526f5374616b696e67203020746f6b656e7360801b60448201526064016104ed565b33600090815260026020819052604090912001547f0000000000000000000000002f3e306d9f02ee8e8850f9040404918d0b34520790156111615761115c33610fd8565b6111ab565b33600090815260026020526040902042600191820155600554611184919061185b565b3360009081526002602052604081209190915560068054916111a583611898565b91905055505b6040516370a0823160e01b81523060048201526000906001600160a01b038316906370a0823190602401602060405180830381865afa1580156111f2573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061121691906118b1565b90506112447f0000000000000000000000002f3e306d9f02ee8e8850f9040404918d0b345207333086611064565b6040516370a0823160e01b815230600482015260009082906001600160a01b038516906370a0823190602401602060405180830381865afa15801561128d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112b191906118b1565b6112bb919061185b565b336000908152600260208190526040822001805492935083929091906112e2908490611885565b9250508190555080600460008282546112fb9190611885565b909155505060405181815233907fb539ca1e5c8d398ddf1c41c30166f33404941683be4683319b57669a93dad4ef9060200160405180910390a250505050565b6001600160a01b0381166000908152600260208181526040808420815160808101835281548082526001830154948201949094529381015491840191909152600301546060830152600554815b8181101561149f576000818152600860209081526040808320815160a0810183528154815260018201549381019390935260028101549183019190915260038101546060830152600401546080820152908483036113ea5785602001516113f0565b81602001515b905060008260400151600003611406574261140c565b82604001515b905060008061143989604001518585611425919061185b565b61142f91906118ca565b86606001516115dd565b915091506000806114688c886080015189600001518661145991906118f7565b61146391906118f7565b611628565b915091508380156114765750815b611480578b611482565b805b9b50505050505050506001816114989190611885565b9050611388565b506114d4846114cf7f0000000000000000000000000000000000000000000000000000000000000005600a6119fd565b6115dd565b945061150390507f0000000000000000000000000000000000000000000000000000000000000005600a6119fd565b61150d90856118f7565b95945050505050565b600054600160a01b900460ff1661058c57604051638dfc202b60e01b815260040160405180910390fd5b6040516001600160a01b0383811660248301526044820183905261159f91859182169063a9059cbb906064015b604051602081830303815290604052915060e01b6020820180516001600160e01b038381831617835250505050611643565b505050565b6040516001600160a01b038481166024830152838116604483015260648201839052610bda9186918216906323b872dd9060840161156d565b600080836000036115f45750600190506000611621565b83830283858281611607576116076118e1565b041461161a576000809250925050611621565b6001925090505b9250929050565b6000808383018481101561161a576000809250925050611621565b60006116586001600160a01b038416836116a6565b9050805160001415801561167d57508080602001905181019061167b9190611a09565b155b1561159f57604051635274afe760e01b81526001600160a01b03841660048201526024016104ed565b60606116b4838360006116bd565b90505b92915050565b6060814710156116e25760405163cd78605960e01b81523060048201526024016104ed565b600080856001600160a01b031684866040516116fe9190611a2b565b60006040518083038185875af1925050503d806000811461173b576040519150601f19603f3d011682016040523d82523d6000602084013e611740565b606091505b509150915061175086838361175c565b925050505b9392505050565b6060826117715761176c826117b8565b611755565b815115801561178857506001600160a01b0384163b155b156117b157604051639996b31560e01b81526001600160a01b03851660048201526024016104ed565b5080611755565b8051156117c85780518082602001fd5b604051630a12f52160e11b815260040160405180910390fd5b600080604083850312156117f457600080fd5b50508035926020909101359150565b60006020828403121561181557600080fd5b5035919050565b60006020828403121561182e57600080fd5b81356001600160a01b038116811461175557600080fd5b634e487b7160e01b600052601160045260246000fd5b818103818111156116b7576116b7611845565b60008161187d5761187d611845565b506000190190565b808201808211156116b7576116b7611845565b6000600182016118aa576118aa611845565b5060010190565b6000602082840312156118c357600080fd5b5051919050565b80820281158282048414176116b7576116b7611845565b634e487b7160e01b600052601260045260246000fd5b60008261191457634e487b7160e01b600052601260045260246000fd5b500490565b600181815b8085111561195457816000190482111561193a5761193a611845565b8085161561194757918102915b93841c939080029061191e565b509250929050565b60008261196b575060016116b7565b81611978575060006116b7565b816001811461198e5760028114611998576119b4565b60019150506116b7565b60ff8411156119a9576119a9611845565b50506001821b6116b7565b5060208310610133831016604e8410600b84101617156119d7575081810a6116b7565b6119e18383611919565b80600019048211156119f5576119f5611845565b029392505050565b60006116b4838361195c565b600060208284031215611a1b57600080fd5b8151801515811461175557600080fd5b6000825160005b81811015611a4c5760208186018101518583015201611a32565b50600092019182525091905056fea26469706673582212201cdc1367ee5ee0e8c2955af5cce141005ce58938dded8a92d2abe37976bffc3e64736f6c63430008170033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
0000000000000000000000002f3e306d9f02ee8e8850f9040404918d0b3452070000000000000000000000002f3e306d9f02ee8e8850f9040404918d0b345207000000000000000000000000ccc388e27e0da13db9f2f22c8035bd1df211036e0000000000000000000000000000000000000000000000000000000001e1338000000000000000000000000000000000000000000000000000000000000000050000000000000000000000000000000000000000000000000000000000000064
-----Decoded View---------------
Arg [0] : _stakingToken (address): 0x2F3E306d9F02ee8e8850F9040404918d0b345207
Arg [1] : _rewardToken (address): 0x2F3E306d9F02ee8e8850F9040404918d0b345207
Arg [2] : _rewardWallet (address): 0xCCc388e27e0DA13db9F2f22c8035bd1df211036E
Arg [3] : _timeUnit (uint80): 31536000
Arg [4] : _numerator (uint256): 5
Arg [5] : _denominator (uint256): 100
-----Encoded View---------------
6 Constructor Arguments found :
Arg [0] : 0000000000000000000000002f3e306d9f02ee8e8850f9040404918d0b345207
Arg [1] : 0000000000000000000000002f3e306d9f02ee8e8850f9040404918d0b345207
Arg [2] : 000000000000000000000000ccc388e27e0da13db9f2f22c8035bd1df211036e
Arg [3] : 0000000000000000000000000000000000000000000000000000000001e13380
Arg [4] : 0000000000000000000000000000000000000000000000000000000000000005
Arg [5] : 0000000000000000000000000000000000000000000000000000000000000064
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 30 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|---|---|---|---|---|
POL | 100.00% | $0.008315 | 15,740,767 | $130,886.27 |
[ 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.