More Info
Private Name Tags
ContractCreator
TokenTracker
Latest 25 from a total of 108 transactions
Transaction Hash |
Method
|
Block
|
From
|
To
|
|||||
---|---|---|---|---|---|---|---|---|---|
Stake | 21579361 | 10 days ago | IN | 0 ETH | 0.00025698 | ||||
Stake | 21571837 | 11 days ago | IN | 0 ETH | 0.00078058 | ||||
Stake | 21559072 | 13 days ago | IN | 0 ETH | 0.00093724 | ||||
Stake | 21553355 | 14 days ago | IN | 0 ETH | 0.00043573 | ||||
Stake | 21550905 | 14 days ago | IN | 0 ETH | 0.0009277 | ||||
Stake | 21513060 | 19 days ago | IN | 0 ETH | 0.00040035 | ||||
Unstake | 21495378 | 22 days ago | IN | 0 ETH | 0.00094391 | ||||
Stake | 21482446 | 24 days ago | IN | 0 ETH | 0.00022564 | ||||
Stake | 21364619 | 40 days ago | IN | 0 ETH | 0.00107368 | ||||
Stake | 21342554 | 43 days ago | IN | 0 ETH | 0.00128386 | ||||
Stake | 21337691 | 44 days ago | IN | 0 ETH | 0.00302758 | ||||
Stake | 21304437 | 48 days ago | IN | 0 ETH | 0.00124013 | ||||
Stake | 21298288 | 49 days ago | IN | 0 ETH | 0.00043013 | ||||
Unstake | 21288471 | 51 days ago | IN | 0 ETH | 0.00080794 | ||||
Stake | 21286566 | 51 days ago | IN | 0 ETH | 0.00080877 | ||||
Stake | 21279802 | 52 days ago | IN | 0 ETH | 0.00126827 | ||||
Unstake | 21273677 | 53 days ago | IN | 0 ETH | 0.00150988 | ||||
Stake | 21272791 | 53 days ago | IN | 0 ETH | 0.00125234 | ||||
Unstake | 21229266 | 59 days ago | IN | 0 ETH | 0.00123335 | ||||
Stake | 21227011 | 59 days ago | IN | 0 ETH | 0.00101335 | ||||
Unstake | 21223783 | 60 days ago | IN | 0 ETH | 0.00141632 | ||||
Stake | 21214757 | 61 days ago | IN | 0 ETH | 0.00130738 | ||||
Unstake | 21206595 | 62 days ago | IN | 0 ETH | 0.00073949 | ||||
Stake | 21200951 | 63 days ago | IN | 0 ETH | 0.00180683 | ||||
Stake | 21179994 | 66 days ago | IN | 0 ETH | 0.01095474 |
View more zero value Internal Transactions in Advanced View mode
Advanced mode:
Loading...
Loading
Contract Source Code Verified (Exact Match)
Contract Name:
Staking
Compiler Version
v0.8.23+commit.f704f362
Optimization Enabled:
Yes with 999999 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/token/ERC20/ERC20.sol"; import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/utils/math/Math.sol"; import "./interfaces/IStaking.sol"; /** * @title AirSwap: Stake Tokens * @notice https://www.airswap.io/ */ contract Staking is IStaking, Ownable { using SafeERC20 for ERC20; // ERC20 token properties string public name; string public symbol; // Token to be staked ERC20 public immutable stakingToken; // Current stake duration uint256 public stakeDuration; // Proposed stake duration (subject to timelock) uint256 private proposedStakeDuration; // Minimum timelock for change to stake duration uint256 private immutable minimumTimelock; // Time after which change to stake duration can be completed uint256 private activeTimelock; // Mapping of staker to proposed delegate mapping(address staker => address delegate) public proposedDelegates; // Mapping of staker to delegate mapping(address staker => address delegate) public stakerDelegates; // Mapping of delegate to staker mapping(address delegate => address staker) public delegateStakers; // Mapping of staker to stake mapping(address staker => Stake stake) public stakes; // Whether stakes are unlocked bool private unlocked; /** * @notice Staking constructor * @param _name string Token name for this contract * @param _symbol string Token symbol for this contract * @param _stakingToken address Token used for staking * @param _stakeDuration uint256 Required duration for each new stake * @param _minimumTimelock uint256 Time delay for a duration change */ constructor( string memory _name, string memory _symbol, ERC20 _stakingToken, uint256 _stakeDuration, uint256 _minimumTimelock ) { stakingToken = _stakingToken; stakeDuration = _stakeDuration; minimumTimelock = _minimumTimelock; name = _name; symbol = _symbol; } /** * @notice Stake tokens for msg.sender * @param _amount uint256 */ function stake(uint256 _amount) external override { stakeFor(msg.sender, _amount); } /** * @notice Stake tokens * @param _staker address * @param _amount uint256 */ function stakeFor(address _staker, uint256 _amount) public override { // Ensure _amount to stake is non-zero if (_amount == 0) revert AmountInvalid(0); // Stake as delegate if set if (delegateStakers[_staker] != address(0)) { _staker = delegateStakers[_staker]; } // Either create or update the stake if (stakes[_staker].balance == 0) { stakes[_staker].start = block.timestamp; stakes[_staker].balance = _amount; } else { // Update start according to progress and stake _amount // Calc: Now - (Duration * (Available / New Stake Balance)) stakes[_staker].start = block.timestamp - (stakeDuration * available(_staker)) / (stakes[_staker].balance + _amount); // Add _amount to stake balance stakes[_staker].balance = stakes[_staker].balance + _amount; } // Update finish with new start plus duration stakes[_staker].finish = stakes[_staker].start + stakeDuration; // Transfer from msg.sender to this contract stakingToken.safeTransferFrom(msg.sender, address(this), _amount); // Mint staked tokens for the _staker emit Transfer(address(0), _staker, _amount); } /** * @notice Unstake tokens * @param _amount uint256 */ function unstake(uint256 _amount) external override { // Ensure _amount to unstake is non-zero if (_amount == 0) revert AmountInvalid(0); // Unstake as delegate if set address _staker = msg.sender; if (delegateStakers[msg.sender] != address(0)) { _staker = delegateStakers[msg.sender]; } // Select stake and currently available Stake storage _selected = stakes[_staker]; uint256 currentlyAvailable = available(_staker); // Ensure _amount does not exceed available if (_amount > currentlyAvailable) revert AmountInvalid(_amount); // Update start according to progress and unstake _amount // Calc: Now - ((Now - Start) * ((Available - Unstake Amount) / Available)) _selected.start = block.timestamp - (((block.timestamp - _selected.start) * (currentlyAvailable - _amount)) / currentlyAvailable); // Subtract _amount from stake balance _selected.balance = _selected.balance - _amount; // Delete the stake if it is now zero if (_selected.balance == 0) delete stakes[_staker]; // Transfer from this contract to the _staker stakingToken.safeTransfer(_staker, _amount); // Burn staked tokens for the _staker emit Transfer(_staker, address(0), _amount); } /** * @notice Amount available to unstake * @dev Linear from start to finish (0 to 100%) * @param _staker uint256 */ function available(address _staker) public view override returns (uint256) { Stake storage _selected = stakes[_staker]; if (unlocked || block.timestamp >= _selected.finish) { return _selected.balance; } // Calc: (Balance * (Now - Start)) / (Finish - Start) return (_selected.balance * (block.timestamp - _selected.start)) / (_selected.finish - _selected.start); } /** * @notice Get balance of a staker * @param _staker address */ function balanceOf(address _staker) external view override returns (uint256) { return stakes[_staker].balance; } /** * @notice Get total of all staked balances */ function totalSupply() external view override returns (uint256) { return stakingToken.balanceOf(address(this)); } /** * @notice Get decimals of underlying token */ function decimals() external view override returns (uint8) { return stakingToken.decimals(); } /** * @notice Propose delegate * @param _to address */ function proposeDelegate(address _to) external { if (stakerDelegates[msg.sender] != address(0)) revert SenderHasDelegate(msg.sender, _to); if (delegateStakers[_to] != address(0)) revert DelegateTaken(_to); if (stakes[_to].balance != 0) revert DelegateStaked(_to); proposedDelegates[msg.sender] = _to; emit ProposeDelegate(msg.sender, _to); } /** * @notice Accept delegate proposal * @param _from address */ function acceptDelegateProposal(address _from) external { if (proposedDelegates[_from] != msg.sender) revert DelegateNotProposed(_from); if (delegateStakers[msg.sender] != address(0)) revert DelegateTaken(_from); if (stakes[msg.sender].balance != 0) revert DelegateStaked(_from); stakerDelegates[_from] = msg.sender; delegateStakers[msg.sender] = _from; delete proposedDelegates[_from]; emit SetDelegate(_from, msg.sender); } /** * @notice Unset delegate * @param _delegate address */ function unsetDelegate(address _delegate) external { if (stakerDelegates[msg.sender] != _delegate) revert DelegateNotSet(_delegate); stakerDelegates[msg.sender] = address(0); delegateStakers[_delegate] = address(0); emit UnsetDelegate(msg.sender, _delegate); } /** * @notice Set timelock for duration change * @param _proposedStakeDuration uint256 * @param _durationChangeDelay uint256 */ function scheduleDurationChange( uint256 _proposedStakeDuration, uint256 _durationChangeDelay ) external onlyOwner { if (activeTimelock != 0) revert TimelockActive(); if (_durationChangeDelay < minimumTimelock) revert DelayInvalid(_durationChangeDelay); if (_proposedStakeDuration == 0) revert DurationInvalid(_proposedStakeDuration); activeTimelock = block.timestamp + _durationChangeDelay; proposedStakeDuration = _proposedStakeDuration; emit ScheduleDurationChange(proposedStakeDuration, activeTimelock); } /** * @notice Cancel timelock for duration change */ function cancelDurationChange() external onlyOwner { if (activeTimelock == 0) revert TimelockInactive(); delete activeTimelock; delete proposedStakeDuration; emit CancelDurationChange(); } /** * @notice Unlock (or re-lock) stakes * @param _unlocked bool Either locked or unlocked */ function setUnlocked(bool _unlocked) external onlyOwner { unlocked = _unlocked; emit SetUnlocked(_unlocked); } /** * @notice Complete timelocked duration change */ function completeDurationChange() external onlyOwner { if (activeTimelock == 0) revert TimelockInactive(); if (block.timestamp < activeTimelock) revert Timelocked(); stakeDuration = proposedStakeDuration; delete activeTimelock; delete proposedStakeDuration; emit CompleteDurationChange(stakeDuration); } /** * @notice Set token metadata for this contract * @param _name string Token name for this contract * @param _symbol string Token symbol for this contract */ function setMetaData( string memory _name, string memory _symbol ) external onlyOwner { name = _name; symbol = _symbol; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable.sol) pragma solidity ^0.8.0; import "../utils/Context.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _transferOwnership(_msgSender()); } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { _checkOwner(); _; } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if the sender is not the owner. */ function _checkOwner() internal view virtual { require(owner() == _msgSender(), "Ownable: caller is not the owner"); } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby disabling any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _transferOwnership(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/ERC20.sol) pragma solidity ^0.8.0; import "./IERC20.sol"; import "./extensions/IERC20Metadata.sol"; import "../../utils/Context.sol"; /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * The default value of {decimals} is 18. To change this, you should override * this function so it returns a different value. * * We have followed general OpenZeppelin Contracts guidelines: functions revert * instead returning `false` on failure. This behavior is nonetheless * conventional and does not conflict with the expectations of ERC20 * applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */ contract ERC20 is Context, IERC20, IERC20Metadata { mapping(address => uint256) private _balances; mapping(address => mapping(address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; /** * @dev Sets the values for {name} and {symbol}. * * All two of these values are immutable: they can only be set once during * construction. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev Returns the name of the token. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5.05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the default value returned by this function, unless * it's overridden. * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual override returns (uint8) { return 18; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `to` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address to, uint256 amount) public virtual override returns (bool) { address owner = _msgSender(); _transfer(owner, to, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on * `transferFrom`. This is semantically equivalent to an infinite approval. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { address owner = _msgSender(); _approve(owner, spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * NOTE: Does not update the allowance if the current allowance * is the maximum `uint256`. * * Requirements: * * - `from` and `to` cannot be the zero address. * - `from` must have a balance of at least `amount`. * - the caller must have allowance for ``from``'s tokens of at least * `amount`. */ function transferFrom(address from, address to, uint256 amount) public virtual override returns (bool) { address spender = _msgSender(); _spendAllowance(from, spender, amount); _transfer(from, to, amount); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { address owner = _msgSender(); _approve(owner, spender, allowance(owner, spender) + addedValue); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { address owner = _msgSender(); uint256 currentAllowance = allowance(owner, spender); require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); unchecked { _approve(owner, spender, currentAllowance - subtractedValue); } return true; } /** * @dev Moves `amount` of tokens from `from` to `to`. * * This internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `from` must have a balance of at least `amount`. */ function _transfer(address from, address to, uint256 amount) internal virtual { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(from, to, amount); uint256 fromBalance = _balances[from]; require(fromBalance >= amount, "ERC20: transfer amount exceeds balance"); unchecked { _balances[from] = fromBalance - amount; // Overflow not possible: the sum of all balances is capped by totalSupply, and the sum is preserved by // decrementing then incrementing. _balances[to] += amount; } emit Transfer(from, to, amount); _afterTokenTransfer(from, to, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply += amount; unchecked { // Overflow not possible: balance + amount is at most totalSupply + amount, which is checked above. _balances[account] += amount; } emit Transfer(address(0), account, amount); _afterTokenTransfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); uint256 accountBalance = _balances[account]; require(accountBalance >= amount, "ERC20: burn amount exceeds balance"); unchecked { _balances[account] = accountBalance - amount; // Overflow not possible: amount <= accountBalance <= totalSupply. _totalSupply -= amount; } emit Transfer(account, address(0), amount); _afterTokenTransfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Updates `owner` s allowance for `spender` based on spent `amount`. * * Does not update the allowance amount in case of infinite allowance. * Revert if not enough allowance is available. * * Might emit an {Approval} event. */ function _spendAllowance(address owner, address spender, uint256 amount) internal virtual { uint256 currentAllowance = allowance(owner, spender); if (currentAllowance != type(uint256).max) { require(currentAllowance >= amount, "ERC20: insufficient allowance"); unchecked { _approve(owner, spender, currentAllowance - amount); } } } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual {} /** * @dev Hook that is called after any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * has been transferred to `to`. * - when `from` is zero, `amount` tokens have been minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens have been burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _afterTokenTransfer(address from, address to, uint256 amount) internal virtual {} }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol) pragma solidity ^0.8.0; import "../IERC20.sol"; /** * @dev Interface for the optional metadata functions from the ERC20 standard. * * _Available since v4.1._ */ interface IERC20Metadata is IERC20 { /** * @dev Returns the name of the token. */ function name() external view returns (string memory); /** * @dev Returns the symbol of the token. */ function symbol() external view returns (string memory); /** * @dev Returns the decimals places of the token. */ function decimals() external view returns (uint8); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/extensions/IERC20Permit.sol) pragma solidity ^0.8.0; /** * @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. */ 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]. */ 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 v4.9.0) (token/ERC20/IERC20.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `to`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address to, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `from` to `to` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address from, address to, uint256 amount) external returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.3) (token/ERC20/utils/SafeERC20.sol) pragma solidity ^0.8.0; import "../IERC20.sol"; import "../extensions/IERC20Permit.sol"; import "../../../utils/Address.sol"; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20 { using Address for address; /** * @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.encodeWithSelector(token.transfer.selector, 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.encodeWithSelector(token.transferFrom.selector, from, to, value)); } /** * @dev Deprecated. This function has issues similar to the ones found in * {IERC20-approve}, and its usage is discouraged. * * Whenever possible, use {safeIncreaseAllowance} and * {safeDecreaseAllowance} instead. */ function safeApprove(IERC20 token, address spender, uint256 value) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' require( (value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } /** * @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); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance + value)); } /** * @dev Decrease the calling contract's allowance toward `spender` by `value`. If `token` returns no value, * non-reverting calls are assumed to be successful. */ function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal { unchecked { uint256 oldAllowance = token.allowance(address(this), spender); require(oldAllowance >= value, "SafeERC20: decreased allowance below zero"); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance - value)); } } /** * @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.encodeWithSelector(token.approve.selector, spender, value); if (!_callOptionalReturnBool(token, approvalCall)) { _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, 0)); _callOptionalReturn(token, approvalCall); } } /** * @dev Use a ERC-2612 signature to set the `owner` approval toward `spender` on `token`. * Revert on invalid signature. */ function safePermit( IERC20Permit token, address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) internal { uint256 nonceBefore = token.nonces(owner); token.permit(owner, spender, value, deadline, v, r, s); uint256 nonceAfter = token.nonces(owner); require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed"); } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function _callOptionalReturn(IERC20 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed"); require(returndata.length == 0 || abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } /** * @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.isContract(address(token)); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * * Furthermore, `isContract` will also return true if the target contract within * the same transaction is already scheduled for destruction by `SELFDESTRUCT`, * which only has an effect at the end of a transaction. * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://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.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract. * * _Available since v4.8._ */ function verifyCallResultFromTarget( address target, bool success, bytes memory returndata, string memory errorMessage ) internal view returns (bytes memory) { if (success) { if (returndata.length == 0) { // only check isContract if the call was successful and the return data is empty // otherwise we already know that it was a contract require(isContract(target), "Address: call to non-contract"); } return returndata; } else { _revert(returndata, errorMessage); } } /** * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason or using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { _revert(returndata, errorMessage); } } function _revert(bytes memory returndata, string memory errorMessage) 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(errorMessage); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (utils/math/Math.sol) pragma solidity ^0.8.0; /** * @dev Standard math utilities missing in the Solidity language. */ library Math { enum Rounding { Down, // Toward negative infinity Up, // Toward infinity Zero // Toward zero } /** * @dev Returns the largest of two numbers. */ function max(uint256 a, uint256 b) internal pure returns (uint256) { return a > b ? a : b; } /** * @dev Returns the smallest of two numbers. */ function min(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; } /** * @dev Returns the average of two numbers. The result is rounded towards * zero. */ function average(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b) / 2 can overflow. return (a & b) + (a ^ b) / 2; } /** * @dev Returns the ceiling of the division of two numbers. * * This differs from standard division with `/` in that it rounds up instead * of rounding down. */ function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b - 1) / b can overflow on addition, so we distribute. return a == 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; // Least significant 256 bits of the product uint256 prod1; // Most significant 256 bits of the product assembly { let mm := mulmod(x, y, not(0)) prod0 := mul(x, y) 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. require(denominator > prod1, "Math: mulDiv overflow"); /////////////////////////////////////////////// // 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. // Does not overflow because the denominator cannot be zero at this stage in the function. uint256 twos = denominator & (~denominator + 1); 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 (rounding == Rounding.Up && 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 down. * * 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 + (rounding == Rounding.Up && result * result < a ? 1 : 0); } } /** * @dev Return the log in base 2, rounded down, of a positive value. * 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 + (rounding == Rounding.Up && 1 << result < value ? 1 : 0); } } /** * @dev Return the log in base 10, rounded down, of a positive value. * 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 + (rounding == Rounding.Up && 10 ** result < value ? 1 : 0); } } /** * @dev Return the log in base 256, rounded down, of a positive value. * 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 + (rounding == Rounding.Up && 1 << (result << 3) < value ? 1 : 0); } } }
// SPDX-License-Identifier: MIT pragma solidity 0.8.23; interface IStaking { error AmountInvalid(uint256); error DelayInvalid(uint256); error DelegateInvalid(address); error DelegateNotProposed(address); error DelegateNotSet(address); error DelegateStaked(address); error DelegateTaken(address); error DurationInvalid(uint256); error SenderHasDelegate(address sender, address delegate); error TimelockActive(); error Timelocked(); error TimelockInactive(); struct Stake { uint256 start; uint256 finish; uint256 balance; } event CancelDurationChange(); event CompleteDurationChange(uint256 indexed newDuration); event ProposeDelegate(address indexed from, address indexed to); event Transfer(address indexed from, address indexed to, uint256 tokens); event ScheduleDurationChange( uint256 proposedStakeDuration, uint256 indexed unlockTimestamp ); event SetDelegate(address indexed staker, address indexed delegate); event SetUnlocked(bool unlock); event UnsetDelegate(address indexed staker, address indexed delegate); function stake(uint256 amount) external; function stakeFor(address account, uint256 amount) external; function unstake(uint256 amount) external; function available(address staker) external view returns (uint256); function balanceOf(address account) external view returns (uint256); function totalSupply() external view returns (uint256); function decimals() external view returns (uint8); function proposeDelegate(address to) external; function acceptDelegateProposal(address from) external; function unsetDelegate(address delegate) external; function scheduleDurationChange( uint256 proposedStakingDuration, uint256 durationChangeDelay ) external; function cancelDurationChange() external; function completeDurationChange() external; function setMetaData(string memory name, string memory symbol) external; }
{ "optimizer": { "enabled": true, "runs": 999999 }, "evmVersion": "paris", "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[{"internalType":"string","name":"_name","type":"string"},{"internalType":"string","name":"_symbol","type":"string"},{"internalType":"contract ERC20","name":"_stakingToken","type":"address"},{"internalType":"uint256","name":"_stakeDuration","type":"uint256"},{"internalType":"uint256","name":"_minimumTimelock","type":"uint256"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"AmountInvalid","type":"error"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"DelayInvalid","type":"error"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"DelegateInvalid","type":"error"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"DelegateNotProposed","type":"error"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"DelegateNotSet","type":"error"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"DelegateStaked","type":"error"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"DelegateTaken","type":"error"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"DurationInvalid","type":"error"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"address","name":"delegate","type":"address"}],"name":"SenderHasDelegate","type":"error"},{"inputs":[],"name":"TimelockActive","type":"error"},{"inputs":[],"name":"TimelockInactive","type":"error"},{"inputs":[],"name":"Timelocked","type":"error"},{"anonymous":false,"inputs":[],"name":"CancelDurationChange","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"newDuration","type":"uint256"}],"name":"CompleteDurationChange","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"}],"name":"ProposeDelegate","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"proposedStakeDuration","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"unlockTimestamp","type":"uint256"}],"name":"ScheduleDurationChange","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"staker","type":"address"},{"indexed":true,"internalType":"address","name":"delegate","type":"address"}],"name":"SetDelegate","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bool","name":"unlock","type":"bool"}],"name":"SetUnlocked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"tokens","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"staker","type":"address"},{"indexed":true,"internalType":"address","name":"delegate","type":"address"}],"name":"UnsetDelegate","type":"event"},{"inputs":[{"internalType":"address","name":"_from","type":"address"}],"name":"acceptDelegateProposal","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_staker","type":"address"}],"name":"available","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_staker","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"cancelDurationChange","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"completeDurationChange","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"delegate","type":"address"}],"name":"delegateStakers","outputs":[{"internalType":"address","name":"staker","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"}],"name":"proposeDelegate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"staker","type":"address"}],"name":"proposedDelegates","outputs":[{"internalType":"address","name":"delegate","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_proposedStakeDuration","type":"uint256"},{"internalType":"uint256","name":"_durationChangeDelay","type":"uint256"}],"name":"scheduleDurationChange","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"_name","type":"string"},{"internalType":"string","name":"_symbol","type":"string"}],"name":"setMetaData","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"_unlocked","type":"bool"}],"name":"setUnlocked","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"stake","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"stakeDuration","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_staker","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"stakeFor","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"staker","type":"address"}],"name":"stakerDelegates","outputs":[{"internalType":"address","name":"delegate","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"staker","type":"address"}],"name":"stakes","outputs":[{"internalType":"uint256","name":"start","type":"uint256"},{"internalType":"uint256","name":"finish","type":"uint256"},{"internalType":"uint256","name":"balance","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"stakingToken","outputs":[{"internalType":"contract ERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","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":[{"internalType":"address","name":"_delegate","type":"address"}],"name":"unsetDelegate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"unstake","outputs":[],"stateMutability":"nonpayable","type":"function"}]
Contract Creation Code
60c06040523480156200001157600080fd5b506040516200230d3803806200230d833981016040819052620000349162000197565b6200003f336200007f565b6001600160a01b038316608052600382905560a08190526001620000648682620002c6565b506002620000738582620002c6565b50505050505062000392565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b634e487b7160e01b600052604160045260246000fd5b600082601f830112620000f757600080fd5b81516001600160401b0380821115620001145762000114620000cf565b604051601f8301601f19908116603f011681019082821181831017156200013f576200013f620000cf565b81604052838152602092508660208588010111156200015d57600080fd5b600091505b8382101562000181578582018301518183018401529082019062000162565b6000602085830101528094505050505092915050565b600080600080600060a08688031215620001b057600080fd5b85516001600160401b0380821115620001c857600080fd5b620001d689838a01620000e5565b96506020880151915080821115620001ed57600080fd5b50620001fc88828901620000e5565b604088015190955090506001600160a01b03811681146200021c57600080fd5b6060870151608090970151959894975095949392505050565b600181811c908216806200024a57607f821691505b6020821081036200026b57634e487b7160e01b600052602260045260246000fd5b50919050565b601f821115620002c1576000816000526020600020601f850160051c810160208610156200029c5750805b601f850160051c820191505b81811015620002bd57828155600101620002a8565b5050505b505050565b81516001600160401b03811115620002e257620002e2620000cf565b620002fa81620002f3845462000235565b8462000271565b602080601f831160018114620003325760008415620003195750858301515b600019600386901b1c1916600185901b178555620002bd565b600085815260208120601f198616915b82811015620003635788860151825594840194600190910190840162000342565b5085821015620003825787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b60805160a051611f39620003d46000396000610d0e015260008181610371015281816106fc0152818161092701528181610bbf0152610c3d0152611f396000f3fe608060405234801561001057600080fd5b50600436106101ae5760003560e01c806370a08231116100ee57806395d89b4111610097578063a694fc3a11610071578063a694fc3a1461041d578063bb2c410014610430578063e71e7d0a14610443578063f2fde38b1461047957600080fd5b806395d89b41146103fa57806396dcfbe1146104025780639ef682d21461041557600080fd5b80637acc8577116100c85780637acc857714610393578063826b971e146103c95780638da5cb5b146103dc57600080fd5b806370a082311461032b578063715018a61461036457806372f702f31461036c57600080fd5b806318160ddd1161015b578063313ce56711610135578063313ce567146102e257806333aaef7d146102fc57806340f02ab61461030f5780636618a06c1461031857600080fd5b806318160ddd146102b45780632e17de78146102bc5780632ee40908146102cf57600080fd5b806310098ad51161018c57806310098ad514610236578063142164c41461025757806316934fc41461026a57600080fd5b806304d0b02c146101b357806306fdde03146101bd5780630b608fcb146101db575b600080fd5b6101bb61048c565b005b6101c561054a565b6040516101d291906119c1565b60405180910390f35b6102116101e9366004611a3b565b60066020526000908152604090205473ffffffffffffffffffffffffffffffffffffffff1681565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020016101d2565b610249610244366004611a3b565b6105d8565b6040519081526020016101d2565b6101bb610265366004611a64565b61065e565b610299610278366004611a3b565b60096020526000908152604090208054600182015460029092015490919083565b604080519384526020840192909252908201526060016101d2565b6102496106cb565b6101bb6102ca366004611a81565b610781565b6101bb6102dd366004611a9a565b6109a2565b6102ea610c39565b60405160ff90911681526020016101d2565b6101bb61030a366004611ac4565b610cca565b61024960035481565b6101bb610326366004611a3b565b610df1565b610249610339366004611a3b565b73ffffffffffffffffffffffffffffffffffffffff1660009081526009602052604090206002015490565b6101bb610fe3565b6102117f000000000000000000000000000000000000000000000000000000000000000081565b6102116103a1366004611a3b565b60086020526000908152604090205473ffffffffffffffffffffffffffffffffffffffff1681565b6101bb6103d7366004611a3b565b610ff7565b60005473ffffffffffffffffffffffffffffffffffffffff16610211565b6101c56110fe565b6101bb610410366004611a3b565b61110b565b6101bb6112f1565b6101bb61042b366004611a81565b61136a565b6101bb61043e366004611bc0565b611377565b610211610451366004611a3b565b60076020526000908152604090205473ffffffffffffffffffffffffffffffffffffffff1681565b6101bb610487366004611a3b565b61139d565b610494611451565b6005546000036104d0576040517fdde0198900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60055442101561050c576040517f774ae17d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600480546003819055600060058190559182905560405190917fa04d5e1ae3fd486b4c476203b016b4b63ba9743beaa99775851ed2f588c955bb91a2565b6001805461055790611c24565b80601f016020809104026020016040519081016040528092919081815260200182805461058390611c24565b80156105d05780601f106105a5576101008083540402835291602001916105d0565b820191906000526020600020905b8154815290600101906020018083116105b357829003601f168201915b505050505081565b73ffffffffffffffffffffffffffffffffffffffff81166000908152600960205260408120600a5460ff1680610612575080600101544210155b15610621576002015492915050565b805460018201546106329190611ca6565b815461063e9042611ca6565b826002015461064d9190611cbf565b6106579190611cd6565b9392505050565b610666611451565b600a80547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00168215159081179091556040519081527fee778e2a0f410018efe7786516deeb731836c21893fe3e5c3760427f5b88655b9060200160405180910390a150565b6040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201526000907f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16906370a0823190602401602060405180830381865afa158015610758573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061077c9190611d11565b905090565b806000036107c3576040517f2ff54bde000000000000000000000000000000000000000000000000000000008152600060048201526024015b60405180910390fd5b3360008181526008602052604090205473ffffffffffffffffffffffffffffffffffffffff161561081657503360009081526008602052604090205473ffffffffffffffffffffffffffffffffffffffff165b73ffffffffffffffffffffffffffffffffffffffff8116600090815260096020526040812090610845836105d8565b905080841115610884576040517f2ff54bde000000000000000000000000000000000000000000000000000000008152600481018590526024016107ba565b8061088f8582611ca6565b835461089b9042611ca6565b6108a59190611cbf565b6108af9190611cd6565b6108b99042611ca6565b825560028201546108cb908590611ca6565b6002830181905560000361090d5773ffffffffffffffffffffffffffffffffffffffff8316600090815260096020526040812081815560018101829055600201555b61094e73ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001684866114d2565b60405184815260009073ffffffffffffffffffffffffffffffffffffffff8516907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9060200160405180910390a350505050565b806000036109df576040517f2ff54bde000000000000000000000000000000000000000000000000000000008152600060048201526024016107ba565b73ffffffffffffffffffffffffffffffffffffffff8281166000908152600860205260409020541615610a385773ffffffffffffffffffffffffffffffffffffffff918216600090815260086020526040902054909116905b73ffffffffffffffffffffffffffffffffffffffff82166000908152600960205260408120600201549003610a9a5773ffffffffffffffffffffffffffffffffffffffff82166000908152600960205260409020428155600201819055610b59565b73ffffffffffffffffffffffffffffffffffffffff8216600090815260096020526040902060020154610ace908290611d2a565b610ad7836105d8565b600354610ae49190611cbf565b610aee9190611cd6565b610af89042611ca6565b73ffffffffffffffffffffffffffffffffffffffff8316600090815260096020526040902090815560020154610b2f908290611d2a565b73ffffffffffffffffffffffffffffffffffffffff83166000908152600960205260409020600201555b60035473ffffffffffffffffffffffffffffffffffffffff8316600090815260096020526040902054610b8c9190611d2a565b73ffffffffffffffffffffffffffffffffffffffff808416600090815260096020526040902060010191909155610be7907f0000000000000000000000000000000000000000000000000000000000000000163330846115a6565b60405181815273ffffffffffffffffffffffffffffffffffffffff8316906000907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9060200160405180910390a35050565b60007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015610ca6573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061077c9190611d3d565b610cd2611451565b60055415610d0c576040517f7d857b6700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b7f0000000000000000000000000000000000000000000000000000000000000000811015610d69576040517ff0bd1e54000000000000000000000000000000000000000000000000000000008152600481018290526024016107ba565b81600003610da6576040517fe71d86b5000000000000000000000000000000000000000000000000000000008152600481018390526024016107ba565b610db08142611d2a565b600581905560048390556040518381527f7b50adeb912ffc741db5be50cc1e5124df0edbd800869a27165243e15f7f3f529060200160405180910390a25050565b73ffffffffffffffffffffffffffffffffffffffff818116600090815260066020526040902054163314610e69576040517f9630109700000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff821660048201526024016107ba565b3360009081526008602052604090205473ffffffffffffffffffffffffffffffffffffffff1615610ede576040517fe50ad76400000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff821660048201526024016107ba565b3360009081526009602052604090206002015415610f40576040517fcefb11d400000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff821660048201526024016107ba565b73ffffffffffffffffffffffffffffffffffffffff811660008181526007602090815260408083208054337fffffffffffffffffffffffff0000000000000000000000000000000000000000918216811790925581855260088452828520805482168717905585855260069093528184208054909316909255519092917fbeebfeebc9d1af8057ca45af36b2171fea34cb5b251e394f0bc5fcabde119d7f91a350565b610feb611451565b610ff5600061160a565b565b3360009081526007602052604090205473ffffffffffffffffffffffffffffffffffffffff828116911614611070576040517fd5a271a000000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff821660048201526024016107ba565b33600081815260076020908152604080832080547fffffffffffffffffffffffff000000000000000000000000000000000000000090811690915573ffffffffffffffffffffffffffffffffffffffff8616808552600890935281842080549091169055519092917fd2f1a7fe15afaaa060b4cae76e37bdc95f2c02be91eecc6e7f4291d27af3191791a350565b6002805461055790611c24565b3360009081526007602052604090205473ffffffffffffffffffffffffffffffffffffffff1615611186576040517f539b163500000000000000000000000000000000000000000000000000000000815233600482015273ffffffffffffffffffffffffffffffffffffffff821660248201526044016107ba565b73ffffffffffffffffffffffffffffffffffffffff81811660009081526008602052604090205416156111fd576040517fe50ad76400000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff821660048201526024016107ba565b73ffffffffffffffffffffffffffffffffffffffff811660009081526009602052604090206002015415611275576040517fcefb11d400000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff821660048201526024016107ba565b3360008181526006602052604080822080547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff861690811790915590519092917fd5388fcc11aaa0f0c97ea8ce8d23d27b5513ec37f3c925cb9cb7d3a23e7efd4991a350565b6112f9611451565b600554600003611335576040517fdde0198900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000600581905560048190556040517fad9f24488dd2d4f821fcb2c503fa6446ff04bb2036760f06261fdb4cf6bd07e99190a1565b61137433826109a2565b50565b61137f611451565b600161138b8382611db0565b5060026113988282611db0565b505050565b6113a5611451565b73ffffffffffffffffffffffffffffffffffffffff8116611448576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084016107ba565b6113748161160a565b60005473ffffffffffffffffffffffffffffffffffffffff163314610ff5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016107ba565b60405173ffffffffffffffffffffffffffffffffffffffff83166024820152604481018290526113989084907fa9059cbb00000000000000000000000000000000000000000000000000000000906064015b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff000000000000000000000000000000000000000000000000000000009093169290921790915261167f565b60405173ffffffffffffffffffffffffffffffffffffffff808516602483015283166044820152606481018290526116049085907f23b872dd0000000000000000000000000000000000000000000000000000000090608401611524565b50505050565b6000805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60006116e1826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff1661178e9092919063ffffffff16565b90508051600014806117025750808060200190518101906117029190611eca565b611398576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f7420737563636565640000000000000000000000000000000000000000000060648201526084016107ba565b606061179d84846000856117a5565b949350505050565b606082471015611837576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c000000000000000000000000000000000000000000000000000060648201526084016107ba565b6000808673ffffffffffffffffffffffffffffffffffffffff1685876040516118609190611ee7565b60006040518083038185875af1925050503d806000811461189d576040519150601f19603f3d011682016040523d82523d6000602084013e6118a2565b606091505b50915091506118b3878383876118be565b979650505050505050565b6060831561195457825160000361194d5773ffffffffffffffffffffffffffffffffffffffff85163b61194d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016107ba565b508161179d565b61179d83838151156119695781518083602001fd5b806040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016107ba91906119c1565b60005b838110156119b85781810151838201526020016119a0565b50506000910152565b60208152600082518060208401526119e081604085016020870161199d565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169190910160400192915050565b803573ffffffffffffffffffffffffffffffffffffffff81168114611a3657600080fd5b919050565b600060208284031215611a4d57600080fd5b61065782611a12565b801515811461137457600080fd5b600060208284031215611a7657600080fd5b813561065781611a56565b600060208284031215611a9357600080fd5b5035919050565b60008060408385031215611aad57600080fd5b611ab683611a12565b946020939093013593505050565b60008060408385031215611ad757600080fd5b50508035926020909101359150565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600082601f830112611b2657600080fd5b813567ffffffffffffffff80821115611b4157611b41611ae6565b604051601f83017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f01168101908282118183101715611b8757611b87611ae6565b81604052838152866020858801011115611ba057600080fd5b836020870160208301376000602085830101528094505050505092915050565b60008060408385031215611bd357600080fd5b823567ffffffffffffffff80821115611beb57600080fd5b611bf786838701611b15565b93506020850135915080821115611c0d57600080fd5b50611c1a85828601611b15565b9150509250929050565b600181811c90821680611c3857607f821691505b602082108103611c71577f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b50919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b81810381811115611cb957611cb9611c77565b92915050565b8082028115828204841417611cb957611cb9611c77565b600082611d0c577f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b500490565b600060208284031215611d2357600080fd5b5051919050565b80820180821115611cb957611cb9611c77565b600060208284031215611d4f57600080fd5b815160ff8116811461065757600080fd5b601f821115611398576000816000526020600020601f850160051c81016020861015611d895750805b601f850160051c820191505b81811015611da857828155600101611d95565b505050505050565b815167ffffffffffffffff811115611dca57611dca611ae6565b611dde81611dd88454611c24565b84611d60565b602080601f831160018114611e315760008415611dfb5750858301515b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff600386901b1c1916600185901b178555611da8565b6000858152602081207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08616915b82811015611e7e57888601518255948401946001909101908401611e5f565b5085821015611eba57878501517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff600388901b60f8161c191681555b5050505050600190811b01905550565b600060208284031215611edc57600080fd5b815161065781611a56565b60008251611ef981846020870161199d565b919091019291505056fea2646970667358221220b743a753d117506cae6f5cd9262cdaa3660e929dcbc41b6c54bc275a3b73432464736f6c6343000817003300000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000e000000000000000000000000027054b13b1b798b345b591a4d22e6562d47ea75a0000000000000000000000000000000000000000000000000000000000b892000000000000000000000000000000000000000000000000000000000000093a80000000000000000000000000000000000000000000000000000000000000000a5374616b6564204153540000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000047341535400000000000000000000000000000000000000000000000000000000
Deployed Bytecode
0x608060405234801561001057600080fd5b50600436106101ae5760003560e01c806370a08231116100ee57806395d89b4111610097578063a694fc3a11610071578063a694fc3a1461041d578063bb2c410014610430578063e71e7d0a14610443578063f2fde38b1461047957600080fd5b806395d89b41146103fa57806396dcfbe1146104025780639ef682d21461041557600080fd5b80637acc8577116100c85780637acc857714610393578063826b971e146103c95780638da5cb5b146103dc57600080fd5b806370a082311461032b578063715018a61461036457806372f702f31461036c57600080fd5b806318160ddd1161015b578063313ce56711610135578063313ce567146102e257806333aaef7d146102fc57806340f02ab61461030f5780636618a06c1461031857600080fd5b806318160ddd146102b45780632e17de78146102bc5780632ee40908146102cf57600080fd5b806310098ad51161018c57806310098ad514610236578063142164c41461025757806316934fc41461026a57600080fd5b806304d0b02c146101b357806306fdde03146101bd5780630b608fcb146101db575b600080fd5b6101bb61048c565b005b6101c561054a565b6040516101d291906119c1565b60405180910390f35b6102116101e9366004611a3b565b60066020526000908152604090205473ffffffffffffffffffffffffffffffffffffffff1681565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020016101d2565b610249610244366004611a3b565b6105d8565b6040519081526020016101d2565b6101bb610265366004611a64565b61065e565b610299610278366004611a3b565b60096020526000908152604090208054600182015460029092015490919083565b604080519384526020840192909252908201526060016101d2565b6102496106cb565b6101bb6102ca366004611a81565b610781565b6101bb6102dd366004611a9a565b6109a2565b6102ea610c39565b60405160ff90911681526020016101d2565b6101bb61030a366004611ac4565b610cca565b61024960035481565b6101bb610326366004611a3b565b610df1565b610249610339366004611a3b565b73ffffffffffffffffffffffffffffffffffffffff1660009081526009602052604090206002015490565b6101bb610fe3565b6102117f00000000000000000000000027054b13b1b798b345b591a4d22e6562d47ea75a81565b6102116103a1366004611a3b565b60086020526000908152604090205473ffffffffffffffffffffffffffffffffffffffff1681565b6101bb6103d7366004611a3b565b610ff7565b60005473ffffffffffffffffffffffffffffffffffffffff16610211565b6101c56110fe565b6101bb610410366004611a3b565b61110b565b6101bb6112f1565b6101bb61042b366004611a81565b61136a565b6101bb61043e366004611bc0565b611377565b610211610451366004611a3b565b60076020526000908152604090205473ffffffffffffffffffffffffffffffffffffffff1681565b6101bb610487366004611a3b565b61139d565b610494611451565b6005546000036104d0576040517fdde0198900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60055442101561050c576040517f774ae17d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600480546003819055600060058190559182905560405190917fa04d5e1ae3fd486b4c476203b016b4b63ba9743beaa99775851ed2f588c955bb91a2565b6001805461055790611c24565b80601f016020809104026020016040519081016040528092919081815260200182805461058390611c24565b80156105d05780601f106105a5576101008083540402835291602001916105d0565b820191906000526020600020905b8154815290600101906020018083116105b357829003601f168201915b505050505081565b73ffffffffffffffffffffffffffffffffffffffff81166000908152600960205260408120600a5460ff1680610612575080600101544210155b15610621576002015492915050565b805460018201546106329190611ca6565b815461063e9042611ca6565b826002015461064d9190611cbf565b6106579190611cd6565b9392505050565b610666611451565b600a80547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00168215159081179091556040519081527fee778e2a0f410018efe7786516deeb731836c21893fe3e5c3760427f5b88655b9060200160405180910390a150565b6040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201526000907f00000000000000000000000027054b13b1b798b345b591a4d22e6562d47ea75a73ffffffffffffffffffffffffffffffffffffffff16906370a0823190602401602060405180830381865afa158015610758573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061077c9190611d11565b905090565b806000036107c3576040517f2ff54bde000000000000000000000000000000000000000000000000000000008152600060048201526024015b60405180910390fd5b3360008181526008602052604090205473ffffffffffffffffffffffffffffffffffffffff161561081657503360009081526008602052604090205473ffffffffffffffffffffffffffffffffffffffff165b73ffffffffffffffffffffffffffffffffffffffff8116600090815260096020526040812090610845836105d8565b905080841115610884576040517f2ff54bde000000000000000000000000000000000000000000000000000000008152600481018590526024016107ba565b8061088f8582611ca6565b835461089b9042611ca6565b6108a59190611cbf565b6108af9190611cd6565b6108b99042611ca6565b825560028201546108cb908590611ca6565b6002830181905560000361090d5773ffffffffffffffffffffffffffffffffffffffff8316600090815260096020526040812081815560018101829055600201555b61094e73ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000027054b13b1b798b345b591a4d22e6562d47ea75a1684866114d2565b60405184815260009073ffffffffffffffffffffffffffffffffffffffff8516907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9060200160405180910390a350505050565b806000036109df576040517f2ff54bde000000000000000000000000000000000000000000000000000000008152600060048201526024016107ba565b73ffffffffffffffffffffffffffffffffffffffff8281166000908152600860205260409020541615610a385773ffffffffffffffffffffffffffffffffffffffff918216600090815260086020526040902054909116905b73ffffffffffffffffffffffffffffffffffffffff82166000908152600960205260408120600201549003610a9a5773ffffffffffffffffffffffffffffffffffffffff82166000908152600960205260409020428155600201819055610b59565b73ffffffffffffffffffffffffffffffffffffffff8216600090815260096020526040902060020154610ace908290611d2a565b610ad7836105d8565b600354610ae49190611cbf565b610aee9190611cd6565b610af89042611ca6565b73ffffffffffffffffffffffffffffffffffffffff8316600090815260096020526040902090815560020154610b2f908290611d2a565b73ffffffffffffffffffffffffffffffffffffffff83166000908152600960205260409020600201555b60035473ffffffffffffffffffffffffffffffffffffffff8316600090815260096020526040902054610b8c9190611d2a565b73ffffffffffffffffffffffffffffffffffffffff808416600090815260096020526040902060010191909155610be7907f00000000000000000000000027054b13b1b798b345b591a4d22e6562d47ea75a163330846115a6565b60405181815273ffffffffffffffffffffffffffffffffffffffff8316906000907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9060200160405180910390a35050565b60007f00000000000000000000000027054b13b1b798b345b591a4d22e6562d47ea75a73ffffffffffffffffffffffffffffffffffffffff1663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015610ca6573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061077c9190611d3d565b610cd2611451565b60055415610d0c576040517f7d857b6700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b7f0000000000000000000000000000000000000000000000000000000000093a80811015610d69576040517ff0bd1e54000000000000000000000000000000000000000000000000000000008152600481018290526024016107ba565b81600003610da6576040517fe71d86b5000000000000000000000000000000000000000000000000000000008152600481018390526024016107ba565b610db08142611d2a565b600581905560048390556040518381527f7b50adeb912ffc741db5be50cc1e5124df0edbd800869a27165243e15f7f3f529060200160405180910390a25050565b73ffffffffffffffffffffffffffffffffffffffff818116600090815260066020526040902054163314610e69576040517f9630109700000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff821660048201526024016107ba565b3360009081526008602052604090205473ffffffffffffffffffffffffffffffffffffffff1615610ede576040517fe50ad76400000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff821660048201526024016107ba565b3360009081526009602052604090206002015415610f40576040517fcefb11d400000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff821660048201526024016107ba565b73ffffffffffffffffffffffffffffffffffffffff811660008181526007602090815260408083208054337fffffffffffffffffffffffff0000000000000000000000000000000000000000918216811790925581855260088452828520805482168717905585855260069093528184208054909316909255519092917fbeebfeebc9d1af8057ca45af36b2171fea34cb5b251e394f0bc5fcabde119d7f91a350565b610feb611451565b610ff5600061160a565b565b3360009081526007602052604090205473ffffffffffffffffffffffffffffffffffffffff828116911614611070576040517fd5a271a000000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff821660048201526024016107ba565b33600081815260076020908152604080832080547fffffffffffffffffffffffff000000000000000000000000000000000000000090811690915573ffffffffffffffffffffffffffffffffffffffff8616808552600890935281842080549091169055519092917fd2f1a7fe15afaaa060b4cae76e37bdc95f2c02be91eecc6e7f4291d27af3191791a350565b6002805461055790611c24565b3360009081526007602052604090205473ffffffffffffffffffffffffffffffffffffffff1615611186576040517f539b163500000000000000000000000000000000000000000000000000000000815233600482015273ffffffffffffffffffffffffffffffffffffffff821660248201526044016107ba565b73ffffffffffffffffffffffffffffffffffffffff81811660009081526008602052604090205416156111fd576040517fe50ad76400000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff821660048201526024016107ba565b73ffffffffffffffffffffffffffffffffffffffff811660009081526009602052604090206002015415611275576040517fcefb11d400000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff821660048201526024016107ba565b3360008181526006602052604080822080547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff861690811790915590519092917fd5388fcc11aaa0f0c97ea8ce8d23d27b5513ec37f3c925cb9cb7d3a23e7efd4991a350565b6112f9611451565b600554600003611335576040517fdde0198900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000600581905560048190556040517fad9f24488dd2d4f821fcb2c503fa6446ff04bb2036760f06261fdb4cf6bd07e99190a1565b61137433826109a2565b50565b61137f611451565b600161138b8382611db0565b5060026113988282611db0565b505050565b6113a5611451565b73ffffffffffffffffffffffffffffffffffffffff8116611448576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084016107ba565b6113748161160a565b60005473ffffffffffffffffffffffffffffffffffffffff163314610ff5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016107ba565b60405173ffffffffffffffffffffffffffffffffffffffff83166024820152604481018290526113989084907fa9059cbb00000000000000000000000000000000000000000000000000000000906064015b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff000000000000000000000000000000000000000000000000000000009093169290921790915261167f565b60405173ffffffffffffffffffffffffffffffffffffffff808516602483015283166044820152606481018290526116049085907f23b872dd0000000000000000000000000000000000000000000000000000000090608401611524565b50505050565b6000805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60006116e1826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff1661178e9092919063ffffffff16565b90508051600014806117025750808060200190518101906117029190611eca565b611398576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f7420737563636565640000000000000000000000000000000000000000000060648201526084016107ba565b606061179d84846000856117a5565b949350505050565b606082471015611837576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c000000000000000000000000000000000000000000000000000060648201526084016107ba565b6000808673ffffffffffffffffffffffffffffffffffffffff1685876040516118609190611ee7565b60006040518083038185875af1925050503d806000811461189d576040519150601f19603f3d011682016040523d82523d6000602084013e6118a2565b606091505b50915091506118b3878383876118be565b979650505050505050565b6060831561195457825160000361194d5773ffffffffffffffffffffffffffffffffffffffff85163b61194d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016107ba565b508161179d565b61179d83838151156119695781518083602001fd5b806040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016107ba91906119c1565b60005b838110156119b85781810151838201526020016119a0565b50506000910152565b60208152600082518060208401526119e081604085016020870161199d565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169190910160400192915050565b803573ffffffffffffffffffffffffffffffffffffffff81168114611a3657600080fd5b919050565b600060208284031215611a4d57600080fd5b61065782611a12565b801515811461137457600080fd5b600060208284031215611a7657600080fd5b813561065781611a56565b600060208284031215611a9357600080fd5b5035919050565b60008060408385031215611aad57600080fd5b611ab683611a12565b946020939093013593505050565b60008060408385031215611ad757600080fd5b50508035926020909101359150565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600082601f830112611b2657600080fd5b813567ffffffffffffffff80821115611b4157611b41611ae6565b604051601f83017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f01168101908282118183101715611b8757611b87611ae6565b81604052838152866020858801011115611ba057600080fd5b836020870160208301376000602085830101528094505050505092915050565b60008060408385031215611bd357600080fd5b823567ffffffffffffffff80821115611beb57600080fd5b611bf786838701611b15565b93506020850135915080821115611c0d57600080fd5b50611c1a85828601611b15565b9150509250929050565b600181811c90821680611c3857607f821691505b602082108103611c71577f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b50919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b81810381811115611cb957611cb9611c77565b92915050565b8082028115828204841417611cb957611cb9611c77565b600082611d0c577f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b500490565b600060208284031215611d2357600080fd5b5051919050565b80820180821115611cb957611cb9611c77565b600060208284031215611d4f57600080fd5b815160ff8116811461065757600080fd5b601f821115611398576000816000526020600020601f850160051c81016020861015611d895750805b601f850160051c820191505b81811015611da857828155600101611d95565b505050505050565b815167ffffffffffffffff811115611dca57611dca611ae6565b611dde81611dd88454611c24565b84611d60565b602080601f831160018114611e315760008415611dfb5750858301515b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff600386901b1c1916600185901b178555611da8565b6000858152602081207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08616915b82811015611e7e57888601518255948401946001909101908401611e5f565b5085821015611eba57878501517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff600388901b60f8161c191681555b5050505050600190811b01905550565b600060208284031215611edc57600080fd5b815161065781611a56565b60008251611ef981846020870161199d565b919091019291505056fea2646970667358221220b743a753d117506cae6f5cd9262cdaa3660e929dcbc41b6c54bc275a3b73432464736f6c63430008170033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
00000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000e000000000000000000000000027054b13b1b798b345b591a4d22e6562d47ea75a0000000000000000000000000000000000000000000000000000000000b892000000000000000000000000000000000000000000000000000000000000093a80000000000000000000000000000000000000000000000000000000000000000a5374616b6564204153540000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000047341535400000000000000000000000000000000000000000000000000000000
-----Decoded View---------------
Arg [0] : _name (string): Staked AST
Arg [1] : _symbol (string): sAST
Arg [2] : _stakingToken (address): 0x27054b13b1B798B345b591a4d22e6562d47eA75a
Arg [3] : _stakeDuration (uint256): 12096000
Arg [4] : _minimumTimelock (uint256): 604800
-----Encoded View---------------
9 Constructor Arguments found :
Arg [0] : 00000000000000000000000000000000000000000000000000000000000000a0
Arg [1] : 00000000000000000000000000000000000000000000000000000000000000e0
Arg [2] : 00000000000000000000000027054b13b1b798b345b591a4d22e6562d47ea75a
Arg [3] : 0000000000000000000000000000000000000000000000000000000000b89200
Arg [4] : 0000000000000000000000000000000000000000000000000000000000093a80
Arg [5] : 000000000000000000000000000000000000000000000000000000000000000a
Arg [6] : 5374616b65642041535400000000000000000000000000000000000000000000
Arg [7] : 0000000000000000000000000000000000000000000000000000000000000004
Arg [8] : 7341535400000000000000000000000000000000000000000000000000000000
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 30 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|---|---|---|---|---|
ETH | 100.00% | $0.096903 | 7,099,894.9619 | $688,001.12 |
Loading...
Loading
[ Download: CSV Export ]
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.