More Info
Private Name Tags
ContractCreator
TokenTracker
Latest 25 from a total of 23,758 transactions
| Transaction Hash |
|
Block
|
From
|
To
|
|||||
|---|---|---|---|---|---|---|---|---|---|
| Approve | 28328735 | 5 hrs ago | IN | 0 ETH | 0.0000011 | ||||
| Exercise Ve | 28327183 | 6 hrs ago | IN | 0 ETH | 0.00003429 | ||||
| Exercise Ve | 28264847 | 46 hrs ago | IN | 0 ETH | 0.00003784 | ||||
| Exercise Ve | 28261971 | 2 days ago | IN | 0 ETH | 0.0000346 | ||||
| Exercise Ve | 28246292 | 2 days ago | IN | 0 ETH | 0.00003576 | ||||
| Exercise Ve | 28225780 | 2 days ago | IN | 0 ETH | 0.00003599 | ||||
| Exercise Ve | 28217880 | 3 days ago | IN | 0 ETH | 0.00003298 | ||||
| Exercise Ve | 28197755 | 3 days ago | IN | 0 ETH | 0.00005632 | ||||
| Exercise Ve | 28191786 | 3 days ago | IN | 0 ETH | 0.0000353 | ||||
| Approve | 28170012 | 4 days ago | IN | 0 ETH | 0.00000202 | ||||
| Exercise Ve | 28160674 | 4 days ago | IN | 0 ETH | 0.0000362 | ||||
| Exercise Ve | 28156973 | 4 days ago | IN | 0 ETH | 0.00003323 | ||||
| Exercise Ve | 28154846 | 4 days ago | IN | 0 ETH | 0.00003106 | ||||
| Exercise Ve | 28152920 | 4 days ago | IN | 0 ETH | 0.00003289 | ||||
| Transfer | 28050719 | 7 days ago | IN | 0 ETH | 0.00000126 | ||||
| Transfer | 28042848 | 7 days ago | IN | 0 ETH | 0.00000126 | ||||
| Transfer | 28042764 | 7 days ago | IN | 0 ETH | 0.00000126 | ||||
| Exercise Ve | 28034213 | 7 days ago | IN | 0 ETH | 0.00002694 | ||||
| Exercise Ve | 28018513 | 7 days ago | IN | 0 ETH | 0.00003254 | ||||
| Exercise Ve | 28005048 | 8 days ago | IN | 0 ETH | 0.00002948 | ||||
| Exercise Ve | 28001345 | 8 days ago | IN | 0 ETH | 0.00003201 | ||||
| Exercise Ve | 27982137 | 8 days ago | IN | 0 ETH | 0.00002772 | ||||
| Exercise Ve | 27928990 | 9 days ago | IN | 0 ETH | 0.00002996 | ||||
| Exercise Ve | 27924123 | 10 days ago | IN | 0 ETH | 0.00003076 | ||||
| Transfer | 27913536 | 10 days ago | IN | 0 ETH | 0.00000189 |
Latest 25 internal transactions (View All)
Advanced mode:
| Parent Transaction Hash | Block | From | To | |||
|---|---|---|---|---|---|---|
| 28327183 | 6 hrs ago | 0 ETH | ||||
| 28307782 | 19 hrs ago | 0 ETH | ||||
| 28264847 | 46 hrs ago | 0 ETH | ||||
| 28261971 | 2 days ago | 0 ETH | ||||
| 28248035 | 2 days ago | 0 ETH | ||||
| 28247655 | 2 days ago | 0 ETH | ||||
| 28247628 | 2 days ago | 0 ETH | ||||
| 28246292 | 2 days ago | 0 ETH | ||||
| 28225780 | 2 days ago | 0 ETH | ||||
| 28217880 | 3 days ago | 0 ETH | ||||
| 28211305 | 3 days ago | 0 ETH | ||||
| 28211305 | 3 days ago | 0 ETH | ||||
| 28211300 | 3 days ago | 0 ETH | ||||
| 28211300 | 3 days ago | 0 ETH | ||||
| 28211300 | 3 days ago | 0 ETH | ||||
| 28197755 | 3 days ago | 0 ETH | ||||
| 28191786 | 3 days ago | 0 ETH | ||||
| 28191550 | 3 days ago | 0 ETH | ||||
| 28191543 | 3 days ago | 0 ETH | ||||
| 28191537 | 3 days ago | 0 ETH | ||||
| 28191537 | 3 days ago | 0 ETH | ||||
| 28191530 | 3 days ago | 0 ETH | ||||
| 28191512 | 3 days ago | 0 ETH | ||||
| 28191485 | 3 days ago | 0 ETH | ||||
| 28191463 | 3 days ago | 0 ETH |
Cross-Chain Transactions
Loading...
Loading
Contract Name:
BribeOptionToken
Compiler Version
v0.8.13+commit.abaa5c0e
Optimization Enabled:
Yes with 1000 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: AGPL-3.0
pragma solidity 0.8.13;
import {AccessControl} from "@openzeppelin/contracts/access/AccessControl.sol";
import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import {OptionTokenV3} from "./OptionTokenV3.sol";
contract BribeOptionToken is ERC20, AccessControl {
/// -----------------------------------------------------------------------
/// Roles
/// -----------------------------------------------------------------------
/// @dev The identifier of the role which maintains other roles and settings
bytes32 public constant ADMIN_ROLE = keccak256("ADMIN");
/// @dev The identifier of the role which is allowed to mint options token
bytes32 public constant MINTER_ROLE = keccak256("MINTER");
/// @dev The identifier of the role which allows accounts to pause execrcising options
/// in case of emergency
bytes32 public constant PAUSER_ROLE = keccak256("PAUSER");
/// @notice Is minting new tokens currently permissioned
bool public permissionedMint = false;
/// -----------------------------------------------------------------------
/// Errors
/// -----------------------------------------------------------------------
error OptionToken_PastDeadline();
error OptionToken_NoAdminRole();
error OptionToken_NoMinterRole();
error OptionToken_NoPauserRole();
error OptionToken_Paused();
/// -----------------------------------------------------------------------
/// Events
/// -----------------------------------------------------------------------
event ExerciseVe(
address indexed sender,
address indexed recipient,
uint256 amount,
uint256 nftId
);
event PauseStateChanged(bool isPaused);
/// -----------------------------------------------------------------------
/// Modifiers
/// -----------------------------------------------------------------------
/// @dev A modifier which checks that the caller has the admin role.
modifier onlyAdmin() {
if (!hasRole(ADMIN_ROLE, msg.sender)) revert OptionToken_NoAdminRole();
_;
}
/// @dev A modifier which checks that the caller has the admin role.
modifier onlyMinter() {
if (
permissionedMint &&
!hasRole(ADMIN_ROLE, msg.sender) &&
!hasRole(MINTER_ROLE, msg.sender)
) revert OptionToken_NoMinterRole();
_;
}
/// @dev A modifier which checks that the caller has the pause role.
modifier onlyPauser() {
if (!hasRole(PAUSER_ROLE, msg.sender))
revert OptionToken_NoPauserRole();
_;
}
/// @notice The underlying token purchased during redemption
OptionTokenV3 public immutable optionToken;
/// @notice Is excersizing options currently paused
bool public isPaused;
constructor(
string memory _name,
string memory _symbol,
OptionTokenV3 _optionToken,
address _admin
) ERC20(_name, _symbol) {
_grantRole(ADMIN_ROLE, _admin);
_grantRole(PAUSER_ROLE, _admin);
_setRoleAdmin(ADMIN_ROLE, ADMIN_ROLE);
_setRoleAdmin(MINTER_ROLE, ADMIN_ROLE);
_setRoleAdmin(PAUSER_ROLE, ADMIN_ROLE);
optionToken = _optionToken;
}
/// @notice Called by the admin to mint options tokens. Admin must grant token approval.
/// @param _to The address that will receive the minted options tokens
/// @param _amount The amount of options tokens that will be minted
function mint(address _to, uint256 _amount) external onlyMinter {
// transfer underlying tokens from the caller
optionToken.transferFrom(msg.sender, address(this), _amount); // BLOTR reverts on failure
// mint options tokens
_mint(_to, _amount);
}
/// @notice Exercises options tokens to purchase the underlying tokens.
/// @param _amount The amount of options tokens to exercise
/// @param _maxPaymentAmount The maximum payment in principal
/// @param _recipient The recipient of the purchased underlying tokens
/// @param _deadline The Unix timestamp (in seconds) after which the call will revert
/// @return nftId
function exerciseVe(
uint256 _amount,
uint256 _maxPaymentAmount,
address _recipient,
uint256 _deadline
) external returns (uint256 nftId) {
if (block.timestamp > _deadline) revert OptionToken_PastDeadline();
if (isPaused) revert OptionToken_Paused();
// burn callers tokens
_burn(msg.sender, _amount);
(, nftId) = optionToken.exerciseVe(_amount, _maxPaymentAmount, _recipient, 0, _deadline);
emit ExerciseVe(msg.sender, _recipient, _amount, nftId);
}
/// @notice called by the admin to toggle the permissioned mint state.
function togglePermissionedMint() external onlyAdmin {
permissionedMint = !permissionedMint;
}
/// @notice called by the admin to re-enable option exercising from a paused state.
function unPause() external onlyAdmin {
if (!isPaused) return;
isPaused = false;
emit PauseStateChanged(false);
}
/// -----------------------------------------------------------------------
/// Pauser functions
/// -----------------------------------------------------------------------
function pause() external onlyPauser {
if (isPaused) return;
isPaused = true;
emit PauseStateChanged(true);
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (access/AccessControl.sol)
pragma solidity ^0.8.0;
import "./IAccessControl.sol";
import "../utils/Context.sol";
import "../utils/Strings.sol";
import "../utils/introspection/ERC165.sol";
/**
* @dev Contract module that allows children to implement role-based access
* control mechanisms. This is a lightweight version that doesn't allow enumerating role
* members except through off-chain means by accessing the contract event logs. Some
* applications may benefit from on-chain enumerability, for those cases see
* {AccessControlEnumerable}.
*
* Roles are referred to by their `bytes32` identifier. These should be exposed
* in the external API and be unique. The best way to achieve this is by
* using `public constant` hash digests:
*
* ```solidity
* bytes32 public constant MY_ROLE = keccak256("MY_ROLE");
* ```
*
* Roles can be used to represent a set of permissions. To restrict access to a
* function call, use {hasRole}:
*
* ```solidity
* function foo() public {
* require(hasRole(MY_ROLE, msg.sender));
* ...
* }
* ```
*
* Roles can be granted and revoked dynamically via the {grantRole} and
* {revokeRole} functions. Each role has an associated admin role, and only
* accounts that have a role's admin role can call {grantRole} and {revokeRole}.
*
* By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means
* that only accounts with this role will be able to grant or revoke other
* roles. More complex role relationships can be created by using
* {_setRoleAdmin}.
*
* WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to
* grant and revoke this role. Extra precautions should be taken to secure
* accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules}
* to enforce additional security measures for this role.
*/
abstract contract AccessControl is Context, IAccessControl, ERC165 {
struct RoleData {
mapping(address => bool) members;
bytes32 adminRole;
}
mapping(bytes32 => RoleData) private _roles;
bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;
/**
* @dev Modifier that checks that an account has a specific role. Reverts
* with a standardized message including the required role.
*
* The format of the revert reason is given by the following regular expression:
*
* /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/
*
* _Available since v4.1._
*/
modifier onlyRole(bytes32 role) {
_checkRole(role);
_;
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);
}
/**
* @dev Returns `true` if `account` has been granted `role`.
*/
function hasRole(bytes32 role, address account) public view virtual override returns (bool) {
return _roles[role].members[account];
}
/**
* @dev Revert with a standard message if `_msgSender()` is missing `role`.
* Overriding this function changes the behavior of the {onlyRole} modifier.
*
* Format of the revert message is described in {_checkRole}.
*
* _Available since v4.6._
*/
function _checkRole(bytes32 role) internal view virtual {
_checkRole(role, _msgSender());
}
/**
* @dev Revert with a standard message if `account` is missing `role`.
*
* The format of the revert reason is given by the following regular expression:
*
* /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/
*/
function _checkRole(bytes32 role, address account) internal view virtual {
if (!hasRole(role, account)) {
revert(
string(
abi.encodePacked(
"AccessControl: account ",
Strings.toHexString(account),
" is missing role ",
Strings.toHexString(uint256(role), 32)
)
)
);
}
}
/**
* @dev Returns the admin role that controls `role`. See {grantRole} and
* {revokeRole}.
*
* To change a role's admin, use {_setRoleAdmin}.
*/
function getRoleAdmin(bytes32 role) public view virtual override returns (bytes32) {
return _roles[role].adminRole;
}
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*
* May emit a {RoleGranted} event.
*/
function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {
_grantRole(role, account);
}
/**
* @dev Revokes `role` from `account`.
*
* If `account` had been granted `role`, emits a {RoleRevoked} event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*
* May emit a {RoleRevoked} event.
*/
function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {
_revokeRole(role, account);
}
/**
* @dev Revokes `role` from the calling account.
*
* Roles are often managed via {grantRole} and {revokeRole}: this function's
* purpose is to provide a mechanism for accounts to lose their privileges
* if they are compromised (such as when a trusted device is misplaced).
*
* If the calling account had been revoked `role`, emits a {RoleRevoked}
* event.
*
* Requirements:
*
* - the caller must be `account`.
*
* May emit a {RoleRevoked} event.
*/
function renounceRole(bytes32 role, address account) public virtual override {
require(account == _msgSender(), "AccessControl: can only renounce roles for self");
_revokeRole(role, account);
}
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event. Note that unlike {grantRole}, this function doesn't perform any
* checks on the calling account.
*
* May emit a {RoleGranted} event.
*
* [WARNING]
* ====
* This function should only be called from the constructor when setting
* up the initial roles for the system.
*
* Using this function in any other way is effectively circumventing the admin
* system imposed by {AccessControl}.
* ====
*
* NOTE: This function is deprecated in favor of {_grantRole}.
*/
function _setupRole(bytes32 role, address account) internal virtual {
_grantRole(role, account);
}
/**
* @dev Sets `adminRole` as ``role``'s admin role.
*
* Emits a {RoleAdminChanged} event.
*/
function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {
bytes32 previousAdminRole = getRoleAdmin(role);
_roles[role].adminRole = adminRole;
emit RoleAdminChanged(role, previousAdminRole, adminRole);
}
/**
* @dev Grants `role` to `account`.
*
* Internal function without access restriction.
*
* May emit a {RoleGranted} event.
*/
function _grantRole(bytes32 role, address account) internal virtual {
if (!hasRole(role, account)) {
_roles[role].members[account] = true;
emit RoleGranted(role, account, _msgSender());
}
}
/**
* @dev Revokes `role` from `account`.
*
* Internal function without access restriction.
*
* May emit a {RoleRevoked} event.
*/
function _revokeRole(bytes32 role, address account) internal virtual {
if (hasRole(role, account)) {
_roles[role].members[account] = false;
emit RoleRevoked(role, account, _msgSender());
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (access/AccessControlEnumerable.sol)
pragma solidity ^0.8.0;
import "./IAccessControlEnumerable.sol";
import "./AccessControl.sol";
import "../utils/structs/EnumerableSet.sol";
/**
* @dev Extension of {AccessControl} that allows enumerating the members of each role.
*/
abstract contract AccessControlEnumerable is IAccessControlEnumerable, AccessControl {
using EnumerableSet for EnumerableSet.AddressSet;
mapping(bytes32 => EnumerableSet.AddressSet) private _roleMembers;
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IAccessControlEnumerable).interfaceId || super.supportsInterface(interfaceId);
}
/**
* @dev Returns one of the accounts that have `role`. `index` must be a
* value between 0 and {getRoleMemberCount}, non-inclusive.
*
* Role bearers are not sorted in any particular way, and their ordering may
* change at any point.
*
* WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure
* you perform all queries on the same block. See the following
* https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]
* for more information.
*/
function getRoleMember(bytes32 role, uint256 index) public view virtual override returns (address) {
return _roleMembers[role].at(index);
}
/**
* @dev Returns the number of accounts that have `role`. Can be used
* together with {getRoleMember} to enumerate all bearers of a role.
*/
function getRoleMemberCount(bytes32 role) public view virtual override returns (uint256) {
return _roleMembers[role].length();
}
/**
* @dev Overload {_grantRole} to track enumerable memberships
*/
function _grantRole(bytes32 role, address account) internal virtual override {
super._grantRole(role, account);
_roleMembers[role].add(account);
}
/**
* @dev Overload {_revokeRole} to track enumerable memberships
*/
function _revokeRole(bytes32 role, address account) internal virtual override {
super._revokeRole(role, account);
_roleMembers[role].remove(account);
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol)
pragma solidity ^0.8.0;
/**
* @dev External interface of AccessControl declared to support ERC165 detection.
*/
interface IAccessControl {
/**
* @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`
*
* `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite
* {RoleAdminChanged} not being emitted signaling this.
*
* _Available since v3.1._
*/
event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);
/**
* @dev Emitted when `account` is granted `role`.
*
* `sender` is the account that originated the contract call, an admin role
* bearer except when using {AccessControl-_setupRole}.
*/
event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);
/**
* @dev Emitted when `account` is revoked `role`.
*
* `sender` is the account that originated the contract call:
* - if using `revokeRole`, it is the admin role bearer
* - if using `renounceRole`, it is the role bearer (i.e. `account`)
*/
event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);
/**
* @dev Returns `true` if `account` has been granted `role`.
*/
function hasRole(bytes32 role, address account) external view returns (bool);
/**
* @dev Returns the admin role that controls `role`. See {grantRole} and
* {revokeRole}.
*
* To change a role's admin, use {AccessControl-_setRoleAdmin}.
*/
function getRoleAdmin(bytes32 role) external view returns (bytes32);
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/
function grantRole(bytes32 role, address account) external;
/**
* @dev Revokes `role` from `account`.
*
* If `account` had been granted `role`, emits a {RoleRevoked} event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/
function revokeRole(bytes32 role, address account) external;
/**
* @dev Revokes `role` from the calling account.
*
* Roles are often managed via {grantRole} and {revokeRole}: this function's
* purpose is to provide a mechanism for accounts to lose their privileges
* if they are compromised (such as when a trusted device is misplaced).
*
* If the calling account had been granted `role`, emits a {RoleRevoked}
* event.
*
* Requirements:
*
* - the caller must be `account`.
*/
function renounceRole(bytes32 role, address account) external;
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (access/IAccessControlEnumerable.sol)
pragma solidity ^0.8.0;
import "./IAccessControl.sol";
/**
* @dev External interface of AccessControlEnumerable declared to support ERC165 detection.
*/
interface IAccessControlEnumerable is IAccessControl {
/**
* @dev Returns one of the accounts that have `role`. `index` must be a
* value between 0 and {getRoleMemberCount}, non-inclusive.
*
* Role bearers are not sorted in any particular way, and their ordering may
* change at any point.
*
* WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure
* you perform all queries on the same block. See the following
* https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]
* for more information.
*/
function getRoleMember(bytes32 role, uint256 index) external view returns (address);
/**
* @dev Returns the number of accounts that have `role`. Can be used
* together with {getRoleMember} to enumerate all bearers of a role.
*/
function getRoleMemberCount(bytes32 role) external view returns (uint256);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (governance/utils/IVotes.sol)
pragma solidity ^0.8.0;
/**
* @dev Common interface for {ERC20Votes}, {ERC721Votes}, and other {Votes}-enabled contracts.
*
* _Available since v4.5._
*/
interface IVotes {
/**
* @dev Emitted when an account changes their delegate.
*/
event DelegateChanged(address indexed delegator, address indexed fromDelegate, address indexed toDelegate);
/**
* @dev Emitted when a token transfer or delegate change results in changes to a delegate's number of votes.
*/
event DelegateVotesChanged(address indexed delegate, uint256 previousBalance, uint256 newBalance);
/**
* @dev Returns the current amount of votes that `account` has.
*/
function getVotes(address account) external view returns (uint256);
/**
* @dev Returns the amount of votes that `account` had at a specific moment in the past. If the `clock()` is
* configured to use block numbers, this will return the value at the end of the corresponding block.
*/
function getPastVotes(address account, uint256 timepoint) external view returns (uint256);
/**
* @dev Returns the total supply of votes available at a specific moment in the past. If the `clock()` is
* configured to use block numbers, this will return the value at the end of the corresponding block.
*
* NOTE: This value is the sum of all available votes, which is not necessarily the sum of all delegated votes.
* Votes that have not been delegated are still part of total supply, even though they would not participate in a
* vote.
*/
function getPastTotalSupply(uint256 timepoint) external view returns (uint256);
/**
* @dev Returns the delegate that `account` has chosen.
*/
function delegates(address account) external view returns (address);
/**
* @dev Delegates votes from the sender to `delegatee`.
*/
function delegate(address delegatee) external;
/**
* @dev Delegates votes from signer to `delegatee`.
*/
function delegateBySig(address delegatee, uint256 nonce, uint256 expiry, uint8 v, bytes32 r, bytes32 s) external;
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (interfaces/IERC5805.sol)
pragma solidity ^0.8.0;
import "../governance/utils/IVotes.sol";
import "./IERC6372.sol";
interface IERC5805 is IERC6372, IVotes {}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (interfaces/IERC6372.sol)
pragma solidity ^0.8.0;
interface IERC6372 {
/**
* @dev Clock used for flagging checkpoints. Can be overridden to implement timestamp based checkpoints (and voting).
*/
function clock() external view returns (uint48);
/**
* @dev Description of the clock
*/
// solhint-disable-next-line func-name-mixedcase
function CLOCK_MODE() external view returns (string memory);
}// 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.4) (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.
*
* ==== Security Considerations
*
* There are two important considerations concerning the use of `permit`. The first is that a valid permit signature
* expresses an allowance, and it should not be assumed to convey additional meaning. In particular, it should not be
* considered as an intention to spend the allowance in any specific way. The second is that because permits have
* built-in replay protection and can be submitted by anyone, they can be frontrun. A protocol that uses permits should
* take this into consideration and allow a `permit` call to fail. Combining these two aspects, a pattern that may be
* generally recommended is:
*
* ```solidity
* function doThingWithPermit(..., uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public {
* try token.permit(msg.sender, address(this), value, deadline, v, r, s) {} catch {}
* doThing(..., value);
* }
*
* function doThing(..., uint256 value) public {
* token.safeTransferFrom(msg.sender, address(this), value);
* ...
* }
* ```
*
* Observe that: 1) `msg.sender` is used as the owner, leaving no ambiguity as to the signer intent, and 2) the use of
* `try/catch` allows the permit to fail and makes the code tolerant to frontrunning. (See also
* {SafeERC20-safeTransferFrom}).
*
* Additionally, note that smart contract wallets (such as Argent or Safe) are not able to produce permit signatures, so
* contracts should have entry points that don't rely on permit.
*/
interface IERC20Permit {
/**
* @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,
* given ``owner``'s signed approval.
*
* IMPORTANT: The same issues {IERC20-approve} has related to transaction
* ordering also apply here.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `deadline` must be a timestamp in the future.
* - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`
* over the EIP712-formatted function arguments.
* - the signature must use ``owner``'s current nonce (see {nonces}).
*
* For more information on the signature format, see the
* https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP
* section].
*
* CAUTION: See Security Considerations above.
*/
function permit(
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) external;
/**
* @dev Returns the current nonce for `owner`. This value must be
* included whenever a signature is generated for {permit}.
*
* Every successful call to {permit} increases ``owner``'s nonce by one. This
* prevents a signature from being used multiple times.
*/
function nonces(address owner) external view returns (uint256);
/**
* @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.
*/
// solhint-disable-next-line func-name-mixedcase
function DOMAIN_SEPARATOR() external view returns (bytes32);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated 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.5.0) (token/ERC721/extensions/IERC721Enumerable.sol)
pragma solidity ^0.8.0;
import "../IERC721.sol";
/**
* @title ERC-721 Non-Fungible Token Standard, optional enumeration extension
* @dev See https://eips.ethereum.org/EIPS/eip-721
*/
interface IERC721Enumerable is IERC721 {
/**
* @dev Returns the total amount of tokens stored by the contract.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns a token ID owned by `owner` at a given `index` of its token list.
* Use along with {balanceOf} to enumerate all of ``owner``'s tokens.
*/
function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256);
/**
* @dev Returns a token ID at a given `index` of all the tokens stored by the contract.
* Use along with {totalSupply} to enumerate all tokens.
*/
function tokenByIndex(uint256 index) external view returns (uint256);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC721/IERC721.sol)
pragma solidity ^0.8.0;
import "../../utils/introspection/IERC165.sol";
/**
* @dev Required interface of an ERC721 compliant contract.
*/
interface IERC721 is IERC165 {
/**
* @dev Emitted when `tokenId` token is transferred from `from` to `to`.
*/
event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.
*/
event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
*/
event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
/**
* @dev Returns the number of tokens in ``owner``'s account.
*/
function balanceOf(address owner) external view returns (uint256 balance);
/**
* @dev Returns the owner of the `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function ownerOf(uint256 tokenId) external view returns (address owner);
/**
* @dev Safely transfers `tokenId` token from `from` to `to`.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external;
/**
* @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
* are aware of the ERC721 protocol to prevent tokens from being forever locked.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must have been allowed to move this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(address from, address to, uint256 tokenId) external;
/**
* @dev Transfers `tokenId` token from `from` to `to`.
*
* WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721
* or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must
* understand this adds an external call which potentially creates a reentrancy vulnerability.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
*
* Emits a {Transfer} event.
*/
function transferFrom(address from, address to, uint256 tokenId) external;
/**
* @dev Gives permission to `to` to transfer `tokenId` token to another account.
* The approval is cleared when the token is transferred.
*
* Only a single account can be approved at a time, so approving the zero address clears previous approvals.
*
* Requirements:
*
* - The caller must own the token or be an approved operator.
* - `tokenId` must exist.
*
* Emits an {Approval} event.
*/
function approve(address to, uint256 tokenId) external;
/**
* @dev Approve or remove `operator` as an operator for the caller.
* Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
*
* Requirements:
*
* - The `operator` cannot be the caller.
*
* Emits an {ApprovalForAll} event.
*/
function setApprovalForAll(address operator, bool approved) external;
/**
* @dev Returns the account approved for `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function getApproved(uint256 tokenId) external view returns (address operator);
/**
* @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
*
* See {setApprovalForAll}
*/
function isApprovedForAll(address owner, address operator) external view returns (bool);
}// 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 (last updated v4.9.4) (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;
}
function _contextSuffixLength() internal view virtual returns (uint256) {
return 0;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)
pragma solidity ^0.8.0;
import "./IERC165.sol";
/**
* @dev Implementation of the {IERC165} interface.
*
* Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check
* for the additional interface id that will be supported. For example:
*
* ```solidity
* function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
* return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
* }
* ```
*
* Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.
*/
abstract contract ERC165 is IERC165 {
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IERC165).interfaceId;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[EIP].
*
* Implementers can declare support of contract interfaces, which can then be
* queried by others ({ERC165Checker}).
*
* For an implementation, see {ERC165}.
*/
interface IERC165 {
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
* to learn more about how these ids are created.
*
* This function call must use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}// 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
// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SignedMath.sol)
pragma solidity ^0.8.0;
/**
* @dev Standard signed math utilities missing in the Solidity language.
*/
library SignedMath {
/**
* @dev Returns the largest of two signed numbers.
*/
function max(int256 a, int256 b) internal pure returns (int256) {
return a > b ? a : b;
}
/**
* @dev Returns the smallest of two signed numbers.
*/
function min(int256 a, int256 b) internal pure returns (int256) {
return a < b ? a : b;
}
/**
* @dev Returns the average of two signed numbers without overflow.
* The result is rounded towards zero.
*/
function average(int256 a, int256 b) internal pure returns (int256) {
// Formula from the book "Hacker's Delight"
int256 x = (a & b) + ((a ^ b) >> 1);
return x + (int256(uint256(x) >> 255) & (a ^ b));
}
/**
* @dev Returns the absolute unsigned value of a signed value.
*/
function abs(int256 n) internal pure returns (uint256) {
unchecked {
// must be unchecked in order to support `n = type(int256).min`
return uint256(n >= 0 ? n : -n);
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/Strings.sol)
pragma solidity ^0.8.0;
import "./math/Math.sol";
import "./math/SignedMath.sol";
/**
* @dev String operations.
*/
library Strings {
bytes16 private constant _SYMBOLS = "0123456789abcdef";
uint8 private constant _ADDRESS_LENGTH = 20;
/**
* @dev Converts a `uint256` to its ASCII `string` decimal representation.
*/
function toString(uint256 value) internal pure returns (string memory) {
unchecked {
uint256 length = Math.log10(value) + 1;
string memory buffer = new string(length);
uint256 ptr;
/// @solidity memory-safe-assembly
assembly {
ptr := add(buffer, add(32, length))
}
while (true) {
ptr--;
/// @solidity memory-safe-assembly
assembly {
mstore8(ptr, byte(mod(value, 10), _SYMBOLS))
}
value /= 10;
if (value == 0) break;
}
return buffer;
}
}
/**
* @dev Converts a `int256` to its ASCII `string` decimal representation.
*/
function toString(int256 value) internal pure returns (string memory) {
return string(abi.encodePacked(value < 0 ? "-" : "", toString(SignedMath.abs(value))));
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
*/
function toHexString(uint256 value) internal pure returns (string memory) {
unchecked {
return toHexString(value, Math.log256(value) + 1);
}
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
*/
function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
bytes memory buffer = new bytes(2 * length + 2);
buffer[0] = "0";
buffer[1] = "x";
for (uint256 i = 2 * length + 1; i > 1; --i) {
buffer[i] = _SYMBOLS[value & 0xf];
value >>= 4;
}
require(value == 0, "Strings: hex length insufficient");
return string(buffer);
}
/**
* @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.
*/
function toHexString(address addr) internal pure returns (string memory) {
return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);
}
/**
* @dev Returns true if the two strings are equal.
*/
function equal(string memory a, string memory b) internal pure returns (bool) {
return keccak256(bytes(a)) == keccak256(bytes(b));
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/structs/EnumerableSet.sol)
// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.
pragma solidity ^0.8.0;
/**
* @dev Library for managing
* https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive
* types.
*
* Sets have the following properties:
*
* - Elements are added, removed, and checked for existence in constant time
* (O(1)).
* - Elements are enumerated in O(n). No guarantees are made on the ordering.
*
* ```solidity
* contract Example {
* // Add the library methods
* using EnumerableSet for EnumerableSet.AddressSet;
*
* // Declare a set state variable
* EnumerableSet.AddressSet private mySet;
* }
* ```
*
* As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)
* and `uint256` (`UintSet`) are supported.
*
* [WARNING]
* ====
* Trying to delete such a structure from storage will likely result in data corruption, rendering the structure
* unusable.
* See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.
*
* In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an
* array of EnumerableSet.
* ====
*/
library EnumerableSet {
// To implement this library for multiple types with as little code
// repetition as possible, we write it in terms of a generic Set type with
// bytes32 values.
// The Set implementation uses private functions, and user-facing
// implementations (such as AddressSet) are just wrappers around the
// underlying Set.
// This means that we can only create new EnumerableSets for types that fit
// in bytes32.
struct Set {
// Storage of set values
bytes32[] _values;
// Position of the value in the `values` array, plus 1 because index 0
// means a value is not in the set.
mapping(bytes32 => uint256) _indexes;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function _add(Set storage set, bytes32 value) private returns (bool) {
if (!_contains(set, value)) {
set._values.push(value);
// The value is stored at length-1, but we add 1 to all indexes
// and use 0 as a sentinel value
set._indexes[value] = set._values.length;
return true;
} else {
return false;
}
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function _remove(Set storage set, bytes32 value) private returns (bool) {
// We read and store the value's index to prevent multiple reads from the same storage slot
uint256 valueIndex = set._indexes[value];
if (valueIndex != 0) {
// Equivalent to contains(set, value)
// To delete an element from the _values array in O(1), we swap the element to delete with the last one in
// the array, and then remove the last element (sometimes called as 'swap and pop').
// This modifies the order of the array, as noted in {at}.
uint256 toDeleteIndex = valueIndex - 1;
uint256 lastIndex = set._values.length - 1;
if (lastIndex != toDeleteIndex) {
bytes32 lastValue = set._values[lastIndex];
// Move the last value to the index where the value to delete is
set._values[toDeleteIndex] = lastValue;
// Update the index for the moved value
set._indexes[lastValue] = valueIndex; // Replace lastValue's index to valueIndex
}
// Delete the slot where the moved value was stored
set._values.pop();
// Delete the index for the deleted slot
delete set._indexes[value];
return true;
} else {
return false;
}
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function _contains(Set storage set, bytes32 value) private view returns (bool) {
return set._indexes[value] != 0;
}
/**
* @dev Returns the number of values on the set. O(1).
*/
function _length(Set storage set) private view returns (uint256) {
return set._values.length;
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function _at(Set storage set, uint256 index) private view returns (bytes32) {
return set._values[index];
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function _values(Set storage set) private view returns (bytes32[] memory) {
return set._values;
}
// Bytes32Set
struct Bytes32Set {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {
return _add(set._inner, value);
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {
return _remove(set._inner, value);
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {
return _contains(set._inner, value);
}
/**
* @dev Returns the number of values in the set. O(1).
*/
function length(Bytes32Set storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {
return _at(set._inner, index);
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {
bytes32[] memory store = _values(set._inner);
bytes32[] memory result;
/// @solidity memory-safe-assembly
assembly {
result := store
}
return result;
}
// AddressSet
struct AddressSet {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(AddressSet storage set, address value) internal returns (bool) {
return _add(set._inner, bytes32(uint256(uint160(value))));
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(AddressSet storage set, address value) internal returns (bool) {
return _remove(set._inner, bytes32(uint256(uint160(value))));
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(AddressSet storage set, address value) internal view returns (bool) {
return _contains(set._inner, bytes32(uint256(uint160(value))));
}
/**
* @dev Returns the number of values in the set. O(1).
*/
function length(AddressSet storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(AddressSet storage set, uint256 index) internal view returns (address) {
return address(uint160(uint256(_at(set._inner, index))));
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function values(AddressSet storage set) internal view returns (address[] memory) {
bytes32[] memory store = _values(set._inner);
address[] memory result;
/// @solidity memory-safe-assembly
assembly {
result := store
}
return result;
}
// UintSet
struct UintSet {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(UintSet storage set, uint256 value) internal returns (bool) {
return _add(set._inner, bytes32(value));
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(UintSet storage set, uint256 value) internal returns (bool) {
return _remove(set._inner, bytes32(value));
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(UintSet storage set, uint256 value) internal view returns (bool) {
return _contains(set._inner, bytes32(value));
}
/**
* @dev Returns the number of values in the set. O(1).
*/
function length(UintSet storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(UintSet storage set, uint256 index) internal view returns (uint256) {
return uint256(_at(set._inner, index));
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function values(UintSet storage set) internal view returns (uint256[] memory) {
bytes32[] memory store = _values(set._inner);
uint256[] memory result;
/// @solidity memory-safe-assembly
assembly {
result := store
}
return result;
}
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.13;
interface IGauge {
function notifyRewardAmount(address token, uint amount) external;
function getReward(address account, address[] memory tokens) external;
function getReward(address account) external;
function claimFees() external returns (uint claimed0, uint claimed1);
function rewardRate(address _pair) external view returns (uint);
function balanceOf(address _account) external view returns (uint);
function isForPair() external view returns (bool);
function totalSupply() external view returns (uint);
function earned(address token, address account) external view returns (uint);
function stakeToken() external view returns (address);
function setDistribution(address _distro) external;
function addRewardToken(address _rewardToken) external;
function updateRewardToken() external;
function activateEmergencyMode() external;
function stopEmergencyMode() external;
function setInternalBribe(address intbribe) external;
function setGaugeRewarder(address _gr) external;
function setFeeVault(address _feeVault) external;
function depositWithLock(address account, uint256 amount, uint256 _lockDuration) external;
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.13;
interface IPair {
function metadata() external view returns (uint dec0, uint dec1, uint r0, uint r1, bool st, address t0, address t1);
function claimFees() external returns (uint, uint);
function tokens() external view returns (address, address);
function token0() external view returns (address);
function token1() external view returns (address);
function transferFrom(address src, address dst, uint amount) external returns (bool);
function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external;
function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external;
function burn(address to) external returns (uint amount0, uint amount1);
function mint(address to) external returns (uint liquidity);
function getReserves() external view returns (uint _reserve0, uint _reserve1, uint _blockTimestampLast);
function getAmountOut(uint, address) external view returns (uint);
function name() external view returns(string memory);
function symbol() external view returns(string memory);
function totalSupply() external view returns (uint);
function decimals() external view returns (uint8);
function claimable0(address _user) external view returns (uint);
function claimable1(address _user) external view returns (uint);
function isStable() external view returns(bool);
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.13;
interface IRouter {
function pairFor(address tokenA, address tokenB, bool stable) external view returns (address pair);
function addLiquidity(address tokenA,address tokenB,bool stable,uint amountADesired,uint amountBDesired,uint amountAMin,uint amountBMin,address to,uint deadline) external returns (uint amountA, uint amountB, uint liquidity);
function getReserves(address tokenA, address tokenB, bool stable) external view returns (uint reserveA, uint reserveB);
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.13;
interface IVoter {
function ve() external view returns (address);
function gauges(address _pair) external view returns (address);
function isGauge(address _gauge) external view returns (bool);
function poolForGauge(address _gauge) external view returns (address);
function factory() external view returns (address);
function minter() external view returns(address);
function isWhitelisted(address token) external view returns (bool);
function notifyRewardAmount(uint amount) external;
function distributeAll() external;
function distributeFees(address[] memory _gauges) external;
function internal_bribes(address _gauge) external view returns (address);
function external_bribes(address _gauge) external view returns (address);
function usedWeights(uint id) external view returns(uint);
function lastVoted(uint id) external view returns(uint);
function poolVote(uint id, uint _index) external view returns(address _pair);
function votes(uint id, address _pool) external view returns(uint votes);
function poolVoteLength(uint tokenId) external view returns(uint);
function attachTokenToGauge(uint _tokenId, address account) external;
function detachTokenFromGauge(uint _tokenId, address account) external;
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.13;
library Math {
function max(uint a, uint b) internal pure returns (uint) {
return a >= b ? a : b;
}
function min(uint a, uint b) internal pure returns (uint) {
return a < b ? a : b;
}
function sqrt(uint y) internal pure returns (uint z) {
if (y > 3) {
z = y;
uint x = y / 2 + 1;
while (x < z) {
z = x;
x = (y / x + x) / 2;
}
} else if (y != 0) {
z = 1;
}
}
function cbrt(uint256 n) internal pure returns (uint256) { unchecked {
uint256 x = 0;
for (uint256 y = 1 << 255; y > 0; y >>= 3) {
x <<= 1;
uint256 z = 3 * x * (x + 1) + 1;
if (n / y >= z) {
n -= y * z;
x += 1;
}
}
return x;
}}
function sub(uint x, uint y) internal pure returns (uint z) {
require((z = x - y) <= x, 'Math: Sub-underflow');
}
function abs(int256 n) internal pure returns (uint256) {
unchecked {
// must be unchecked in order to support `n = type(int256).min`
return uint256(n >= 0 ? n : -n);
}
}
}// SPDX-License-Identifier: GPL-3.0-only
pragma solidity >=0.7.0;
interface IDynamicTwapOracle {
/**
* @notice Get the address of the pool
* @return The address of the pool
*/
function pool() external view returns (address);
/**
* @notice Get the address of the first token in the pool
* @return The address of the first token
*/
function token0() external view returns (address);
/**
* @notice Get the address of the second token in the pool
* @return The address of the second token
*/
function token1() external view returns (address);
/**
* @notice Estimate the output amount of a trade
* @param tokenIn The address of the input token
* @param amountIn The amount of the input token
* @param secondsAgo The number of seconds ago to start the TWAP
* @return amountOut The estimated output amount
*/
function estimateAmountOut(
address tokenIn,
uint128 amountIn,
uint32 secondsAgo
) external view returns (uint amountOut);
}// SPDX-License-Identifier: GPL-3.0-only
pragma solidity 0.8.13;
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {IAccessControl} from "@openzeppelin/contracts/access/IAccessControl.sol";
interface IOption is IAccessControl {
function paymentToken() external view returns (IERC20);
function getPaymentAmount(uint256 _amount, bytes calldata _data) external view returns (uint256);
function exercise(uint256 _amount, address sender, bytes calldata _data) external returns (uint256);
}// SPDX-License-Identifier: GPL-3.0-only
pragma solidity 0.8.13;
interface IOptionFeeDistributor {
function distribute(address token, uint256 amount) external;
}// SPDX-License-Identifier: GPL-3.0-only
pragma solidity 0.8.13;
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {IAccessControl} from "@openzeppelin/contracts/access/IAccessControl.sol";
import {IDynamicTwapOracle} from "./DynamicTwapOracle/IDynamicTwapOracle.sol";
import {IOptionFeeDistributor} from "./IOptionFeeDistributor.sol";
import {IPair} from "../interfaces/IPair.sol";
interface IOptionTokenV3 is IERC20, IAccessControl {
function ADMIN_ROLE() external view returns (bytes32);
function MINTER_ROLE() external view returns (bytes32);
function PAUSER_ROLE() external view returns (bytes32);
function paymentToken() external view returns (IERC20);
function UNDERLYING_TOKEN() external view returns (IERC20);
function voter() external view returns (address);
function mint(address _to, uint256 _amount) external;
function getDiscountedPrice(uint256 _amount) external view returns (uint256);
function getDiscountedPrice(uint256 _amount, uint256 _discount) external view returns (uint256);
function getLockDurationForLpDiscount(uint256 _amount) external view returns (uint256);
function getPaymentTokenAmountForExerciseLp(
uint256 _amount,
uint256 _discount
) external view returns (uint256, uint256);
function getSlopeInterceptForLpDiscount() external view returns (int256, int256);
function getTimeWeightedAveragePrice(uint256 _amount) external view returns (uint256);
function setTwapOracleAndPaymentToken(IDynamicTwapOracle _twapOracle, address _paymentToken) external;
function setPairAndPaymentToken(IPair _pair, address _paymentToken) external;
function setFeeDistributor(IOptionFeeDistributor _feeDistributor) external;
function setDiscount(uint256 _discount) external;
function setVeDiscount(uint256 _veDiscount) external;
function setMinLPDiscount(uint256 _lpMinDiscount) external;
function setMaxLPDiscount(uint256 _lpMaxDiscount) external;
function setLockDurationForMaxLpDiscount(uint256 _duration) external;
function setLockDurationForMinLpDiscount(uint256 _duration) external;
function setTwapSeconds(uint32 _twapSeconds) external;
function burn(uint256 _amount) external;
function updateGauge() external;
function setGauge(address _gauge) external;
function setRouter(address _router) external;
function unPause() external;
function pause() external;
}// SPDX-License-Identifier: AGPL-3.0
pragma solidity 0.8.13;
import {AccessControlEnumerable} from "@openzeppelin/contracts/access/AccessControlEnumerable.sol";
import {ERC20, IERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import {Math} from "../libraries/Math.sol";
import {IVotingEscrowV2} from "../VoterV5/VotingEscrow/interfaces/IVotingEscrowV2.sol";
import {IVoter} from "../interfaces/IVoter.sol";
import {IPair} from "../interfaces/IPair.sol";
import {IGauge} from "../interfaces/IGauge.sol";
import {IRouter} from "../interfaces/IRouter.sol";
import {IDynamicTwapOracle} from "./DynamicTwapOracle/IDynamicTwapOracle.sol";
import {IOptionTokenV3} from "./IOptionTokenV3.sol";
import {IOptionFeeDistributor} from "./IOptionFeeDistributor.sol";
import {IOption} from "./IOption.sol";
/// @title Option Token
/// @notice Option token representing the right to purchase the underlying token
/// at TWAP reduced rate. Similar to call options but with a variable strike
/// price that's always at a certain discount to the market price.
/// Credit to Velocimeter for the original implementation
contract OptionTokenV3 is IOptionTokenV3, ERC20, AccessControlEnumerable {
using SafeERC20 for IERC20;
/// -----------------------------------------------------------------------
/// Constants
/// -----------------------------------------------------------------------
uint256 public constant MAX_DISCOUNT = 100; // 100%
uint256 public constant MIN_DISCOUNT = 0; // 0%
uint256 public constant MAX_TWAP_SECONDS = 86400; // 2 days
/// @dev Lock set to 2 years
uint256 public constant FULL_LOCK = 2 * 365 * 86400; // 2 years
/// -----------------------------------------------------------------------
/// Roles
/// -----------------------------------------------------------------------
/// @dev The identifier of the role which maintains other roles and settings
bytes32 public constant override ADMIN_ROLE = keccak256("ADMIN");
/// @dev The identifier of the role which is allowed to mint options token
bytes32 public constant override MINTER_ROLE = keccak256("MINTER");
/// @dev The identifier of the role which allows accounts to pause exercising options
/// in case of emergency
bytes32 public constant override PAUSER_ROLE = keccak256("PAUSER");
/// -----------------------------------------------------------------------
/// Immutable parameters
/// -----------------------------------------------------------------------
/// @notice The token paid by the options token holder during redemption
IERC20 public override paymentToken;
/// @notice The underlying token purchased during redemption
IERC20 public immutable UNDERLYING_TOKEN;
/// @notice The voter contract
address public voter;
/// -----------------------------------------------------------------------
/// Storage variables
/// -----------------------------------------------------------------------
/// @notice The router for adding liquidity
address public router; // this should not be immutable
/// @notice The pair contract used to deposit LP option
IPair public pair;
/// @notice The guage contract for the pair
address public gauge;
/// @notice The oracle contract that provides the current TWAP price to purchase
/// the underlying token while exercising options (the strike price)
IDynamicTwapOracle public twapOracle;
/// @notice The contract that receives the payment tokens when options are exercised
IOptionFeeDistributor public feeDistributor;
/// @notice the discount given during exercising with locking to the LP
uint256 public maxLPDiscount = 20; // User pays 20%
uint256 public minLPDiscount = 80; // User pays 80%
/// @notice the lock duration for max discount to create locked LP
uint256 public lockDurationForMaxLpDiscount = FULL_LOCK; // 52 weeks
// @notice the lock duration for max discount to create locked LP
uint256 public lockDurationForMinLpDiscount = 7 * 86400; // 1 week
// @notice the lock duration for min discount to create locked veToken
uint256 public lockDurationForMinVeDiscount = 2 weeks; // 2 weeks
/// @notice the discount given during exercising. 30 = user pays 30%
uint256 public discount = 40;
/// @notice the max discount for locking to vote escrow
uint256 public veMaxDiscount = 0; // User pays 0%
/// @notice controls the duration of the twap used to calculate the strike price
uint32 public twapSeconds = 60 * 30 * 4;
/// @notice Is exercising options currently paused
bool public isPaused;
/// @notice Is minting new options currently permissioned
bool public permissionedMint = false;
/// @notice allows to expand options with new contracts
mapping(address => bool) optionTokens;
/// -----------------------------------------------------------------------
/// Events
/// -----------------------------------------------------------------------
event Exercise(address indexed sender, address indexed recipient, uint256 amount, uint256 paymentAmount);
event ExerciseVe(
address indexed sender,
address indexed recipient,
uint256 amount,
uint256 paymentAmount,
uint256 nftId
);
event ExerciseLp(
address indexed sender,
address indexed recipient,
uint256 amount,
uint256 paymentAmount,
uint256 lpAmount
);
event SetPairAndPaymentToken(IPair indexed newPair, address indexed newPaymentToken);
event SetGauge(address indexed newGauge);
event SetRouter(address indexed router);
event SetTwapOracleAndPaymentToken(IDynamicTwapOracle indexed _twapOracle, address indexed _paymentToken);
event SetFeeDistributor(IOptionFeeDistributor indexed newFeeDistributor);
event SetDiscount(uint256 discount);
event SetVeDiscount(uint256 veDiscount);
event SetMinLPDiscount(uint256 lpMinDiscount);
event SetMaxLPDiscount(uint256 lpMaxDiscount);
event SetLockDurationForMaxLpDiscount(uint256 lockDurationForMaxLpDiscount);
event SetLockDurationForMinLpDiscount(uint256 lockDurationForMinLpDiscount);
event SetLockDurationForMinVeDiscount(uint256 lockDurationForMinVeDiscount);
event PauseStateChanged(bool isPaused);
event SetTwapSeconds(uint32 twapSeconds);
event ToggleOption(address option, bool enabled);
/// -----------------------------------------------------------------------
/// Errors
/// -----------------------------------------------------------------------
error OptionToken_PastDeadline();
error OptionToken_NoAdminRole();
error OptionToken_NoMinterRole();
error OptionToken_NoPauserRole();
error OptionToken_SlippageTooHigh();
error OptionToken_InvalidDiscount();
error OptionToken_Paused();
error OptionToken_InvalidTwapSeconds();
error OptionToken_IncorrectPairToken();
error OptionToken_InvalidLockDuration();
error OptionToken_InvalidOption();
/// -----------------------------------------------------------------------
/// Modifiers
/// -----------------------------------------------------------------------
/// @dev A modifier which checks that the caller has the admin role.
modifier onlyAdmin() {
if (!hasRole(ADMIN_ROLE, msg.sender)) revert OptionToken_NoAdminRole();
_;
}
/// @dev A modifier which checks that the caller has the admin or minter role.
modifier onlyMinter() {
if (permissionedMint && !hasRole(ADMIN_ROLE, msg.sender) && !hasRole(MINTER_ROLE, msg.sender))
revert OptionToken_NoMinterRole();
_;
}
/// @dev A modifier which checks that the caller has the pause role.
modifier onlyPauser() {
if (!hasRole(PAUSER_ROLE, msg.sender)) revert OptionToken_NoPauserRole();
_;
}
/// -----------------------------------------------------------------------
/// Constructor
/// -----------------------------------------------------------------------
constructor(
string memory _name,
string memory _symbol,
address _admin,
ERC20 _paymentToken,
ERC20 _underlyingToken,
IDynamicTwapOracle _twapOracle,
IOptionFeeDistributor _feeDistributor,
address _voter,
IPair _pair,
address _router
) ERC20(_name, _symbol) {
_grantRole(DEFAULT_ADMIN_ROLE, _admin);
_grantRole(ADMIN_ROLE, _admin);
_grantRole(PAUSER_ROLE, _admin);
_setRoleAdmin(ADMIN_ROLE, ADMIN_ROLE);
_setRoleAdmin(MINTER_ROLE, ADMIN_ROLE);
_setRoleAdmin(PAUSER_ROLE, ADMIN_ROLE);
paymentToken = _paymentToken;
UNDERLYING_TOKEN = _underlyingToken;
twapOracle = _twapOracle;
feeDistributor = _feeDistributor;
pair = _pair;
router = _router;
voter = _voter;
paymentToken.approve(address(_feeDistributor), type(uint256).max);
emit SetTwapOracleAndPaymentToken(_twapOracle, address(_paymentToken));
emit SetPairAndPaymentToken(_pair, address(paymentToken));
emit SetRouter(router);
emit SetFeeDistributor(_feeDistributor);
emit SetDiscount(discount);
emit SetVeDiscount(veMaxDiscount);
emit SetMinLPDiscount(minLPDiscount);
emit SetMaxLPDiscount(maxLPDiscount);
}
/// -----------------------------------------------------------------------
/// External functions
/// -----------------------------------------------------------------------
/// @notice Exercises options tokens to purchase the underlying tokens.
/// @dev The oracle may revert if it cannot give a secure result.
/// @param _amount The amount of options tokens to exercise
/// @param _maxPaymentAmount The maximum acceptable amount to pay. Used for slippage protection.
/// @param _recipient The recipient of the purchased underlying tokens
/// @return The amount paid to the fee distributor to purchase the underlying tokens
function exercise(uint256 _amount, uint256 _maxPaymentAmount, address _recipient) external returns (uint256) {
return _exercise(_amount, _maxPaymentAmount, _recipient);
}
/// @notice Exercises options tokens to purchase the underlying tokens.
/// @dev The oracle may revert if it cannot give a secure result.
/// @param _amount The amount of options tokens to exercise
/// @param _maxPaymentAmount The maximum acceptable amount to pay. Used for slippage protection.
/// @param _recipient The recipient of the purchased underlying tokens
/// @param _deadline The Unix timestamp (in seconds) after which the call will revert
/// @return The amount paid to the fee distributor to purchase the underlying tokens
function exercise(
uint256 _amount,
uint256 _maxPaymentAmount,
address _recipient,
uint256 _deadline
) external returns (uint256) {
if (block.timestamp > _deadline) revert OptionToken_PastDeadline();
return _exercise(_amount, _maxPaymentAmount, _recipient);
}
/// @notice Exercises options tokens to purchase the underlying tokens.
/// @dev The oracle may revert if it cannot give a secure result.
/// @param _amount The amount of options tokens to exercise
/// @param _maxPaymentAmount The maximum acceptable amount to pay. Used for slippage protection.
/// @param _recipient The recipient of the purchased underlying tokens
/// @param _deadline The Unix timestamp (in seconds) after which the call will revert
/// @return The amount paid to the fee distributor to purchase the underlying tokens
function exerciseVe(
uint256 _amount,
uint256 _maxPaymentAmount,
address _recipient,
uint256 _discount,
uint256 _deadline
) external returns (uint256, uint256) {
if (block.timestamp > _deadline) revert OptionToken_PastDeadline();
return _exerciseVe(_amount, _maxPaymentAmount, _discount, _recipient);
}
/// @notice Exercises options tokens to create LP and stake in gauges with lock.
/// @dev The oracle may revert if it cannot give a secure result.
/// @param _amount The amount of options tokens to exercise
/// @param _maxPaymentAmount The maximum acceptable amount to pay. Used for slippage protection.
/// @param _discount The desired discount
/// @param _deadline The Unix timestamp (in seconds) after which the call will revert
/// @return The amount paid to the treasury to purchase the underlying tokens
function exerciseLp(
uint256 _amount,
uint256 _maxPaymentAmount,
uint256 _maxLPAmount,
address _recipient,
uint256 _discount,
uint256 _deadline
) external returns (uint256, uint256) {
if (block.timestamp > _deadline) revert OptionToken_PastDeadline();
return _exerciseLp(_amount, _maxPaymentAmount, _maxLPAmount, _recipient, _discount);
}
function exerciseExternal(
IOption _option,
uint256 _amount,
uint256 _deadline,
bytes calldata _data
) external returns (uint256) {
if (!optionTokens[address(_option)]) revert OptionToken_InvalidOption();
if (block.timestamp > _deadline) revert OptionToken_PastDeadline();
uint256 paymentAmount = _option.getPaymentAmount(_amount, _data);
_burn(msg.sender, _amount);
_option.paymentToken().safeTransferFrom(msg.sender, address(_option), paymentAmount);
UNDERLYING_TOKEN.safeTransfer(address(_option), _amount);
return _option.exercise(_amount, msg.sender, _data);
}
/// -----------------------------------------------------------------------
/// Public functions
/// -----------------------------------------------------------------------
function getVotingEscrow() external view returns (address votingEscrow) {
votingEscrow = IVoter(voter).ve();
}
/// @notice Returns the discounted price in paymentTokens for a given amount of options tokens
/// @param _amount The amount of options tokens to exercise
/// @return The amount of payment tokens to pay to purchase the underlying tokens
function getDiscountedPrice(uint256 _amount) public view returns (uint256) {
return getDiscountedPrice(_amount, discount);
}
/// @notice Returns the discounted price in paymentTokens for a given amount of options tokens redeemed to veToken
/// @param _amount The amount of options tokens to exercise
/// @param _discount The discount amount
/// @return The amount of payment tokens to pay to purchase the underlying tokens
function getDiscountedPrice(uint256 _amount, uint256 _discount) public view returns (uint256) {
return (getTimeWeightedAveragePrice(_amount) * _discount) / 100;
}
/// @notice Returns the average price in payment tokens over period defined in twapSeconds for an amount of tokens
/// @param _amount The amount of underlying tokens to purchase
/// @return The amount of payment tokens
function getTimeWeightedAveragePrice(uint256 _amount) public view returns (uint256) {
return twapOracle.estimateAmountOut(address(UNDERLYING_TOKEN), uint128(_amount), twapSeconds);
}
/// @notice Returns the lock duration for a desired discount to create locked LP
function getLockDurationForLpDiscount(uint256 _discount) public view returns (uint256 duration) {
(int256 slope, int256 intercept) = getSlopeInterceptForLpDiscount();
duration = Math.abs(slope * int256(_discount) + intercept);
}
/// @notice Returns the lock duration for a desired discount to create locked VE
function getLockDurationForVeDiscount(uint256 _discount) public view returns (uint256 duration) {
(int256 slope, int256 intercept) = getSlopeInterceptForVeDiscount();
duration = Math.abs(slope * int256(_discount) + intercept);
}
/// @notice Returns the amount in paymentTokens for a given amount of options tokens required for the LP exercise lp
/// @param _amount The amount of options tokens to exercise
/// @param _discount The discount amount
function getPaymentTokenAmountForExerciseLp(
uint256 _amount,
uint256 _discount
) public view returns (uint256 paymentAmount, uint256 paymentAmountToAddLiquidity) {
paymentAmount = getDiscountedPrice(_amount, _discount);
(uint256 underlyingReserve, uint256 paymentReserve) = IRouter(router).getReserves(
address(UNDERLYING_TOKEN),
address(paymentToken),
false
);
paymentAmountToAddLiquidity = (_amount * paymentReserve) / underlyingReserve;
}
function getSlopeInterceptForLpDiscount() public view returns (int256 slope, int256 intercept) {
slope =
int256(lockDurationForMaxLpDiscount - lockDurationForMinLpDiscount) /
(int256(maxLPDiscount) - int256(minLPDiscount));
intercept = int256(lockDurationForMinLpDiscount) - (slope * int256(minLPDiscount));
}
function getSlopeInterceptForVeDiscount() public view returns (int256 slope, int256 intercept) {
slope = int256(FULL_LOCK - lockDurationForMinVeDiscount) / (int256(veMaxDiscount) - int256(discount));
intercept = int256(lockDurationForMinVeDiscount) - (slope * int256(discount));
}
/// -----------------------------------------------------------------------
/// Admin functions
/// -----------------------------------------------------------------------
/// @notice Sets the twap oracle contract address.
/// @param _twapOracle The new twap oracle contract address
function setTwapOracleAndPaymentToken(IDynamicTwapOracle _twapOracle, address _paymentToken) external onlyAdmin {
if (
!((_twapOracle.token0() == _paymentToken && _twapOracle.token1() == address(UNDERLYING_TOKEN)) ||
(_twapOracle.token0() == address(UNDERLYING_TOKEN) && _twapOracle.token1() == _paymentToken))
) revert OptionToken_IncorrectPairToken();
twapOracle = _twapOracle;
paymentToken = ERC20(_paymentToken);
paymentToken.approve(address(feeDistributor), type(uint256).max);
emit SetTwapOracleAndPaymentToken(_twapOracle, _paymentToken);
}
/// @notice Sets the fee distributor. Only callable by the admin.
/// @param _feeDistributor The new fee distributor.
function setFeeDistributor(IOptionFeeDistributor _feeDistributor) external onlyAdmin {
paymentToken.approve(address(feeDistributor), 0);
feeDistributor = _feeDistributor;
paymentToken.approve(address(_feeDistributor), type(uint256).max);
emit SetFeeDistributor(_feeDistributor);
}
/// @notice Sets the discount amount. Only callable by the admin.
/// @param _discount The new discount amount.
function setDiscount(uint256 _discount) external onlyAdmin {
if (_discount > MAX_DISCOUNT || _discount == MIN_DISCOUNT) revert OptionToken_InvalidDiscount();
discount = _discount;
emit SetDiscount(_discount);
}
/// @notice Sets the further discount amount for locking. Only callable by the admin.
/// @param _veDiscount The new discount amount.
function setVeDiscount(uint256 _veDiscount) external onlyAdmin {
if (_veDiscount > MAX_DISCOUNT || _veDiscount == MIN_DISCOUNT) revert OptionToken_InvalidDiscount();
veMaxDiscount = _veDiscount;
emit SetVeDiscount(_veDiscount);
}
/// @notice Sets the twap seconds to control the length of our twap
/// @param _twapSeconds The new twap points.
function setTwapSeconds(uint32 _twapSeconds) external onlyAdmin {
if (_twapSeconds > MAX_TWAP_SECONDS || _twapSeconds == 0) revert OptionToken_InvalidTwapSeconds();
twapSeconds = _twapSeconds;
emit SetTwapSeconds(_twapSeconds);
}
/// @notice Sets the pair contract. Only callable by the admin.
/// @param _pair The new pair contract
function setPairAndPaymentToken(IPair _pair, address _paymentToken) external onlyAdmin {
(address token0, address token1) = _pair.tokens();
if (
!((token0 == _paymentToken && token1 == address(UNDERLYING_TOKEN)) ||
(token0 == address(UNDERLYING_TOKEN) && token1 == _paymentToken))
) revert OptionToken_IncorrectPairToken();
pair = _pair;
gauge = IVoter(voter).gauges(address(_pair));
paymentToken = IERC20(_paymentToken);
emit SetPairAndPaymentToken(_pair, _paymentToken);
}
/// @notice Update gauge address to match with Voter contract
function updateGauge() external {
address newGauge = IVoter(voter).gauges(address(pair));
gauge = newGauge;
emit SetGauge(newGauge);
}
/// @notice Sets the gauge address when the gauge is not listed in Voter. Only callable by the admin.
/// @param _gauge The new treasury address
function setGauge(address _gauge) external onlyAdmin {
gauge = _gauge;
emit SetGauge(_gauge);
}
/// @notice Sets the router address. Only callable by the admin.
/// @param _router The new router address
function setRouter(address _router) external onlyAdmin {
router = _router;
emit SetRouter(_router);
}
/// @notice Sets the discount amount for lp. Only callable by the admin.
/// @param _lpMinDiscount The new discount amount.
function setMinLPDiscount(uint256 _lpMinDiscount) external onlyAdmin {
/// @dev Cannot be lower than MIN_DISCOUNT or gte maxLPDiscount
if (_lpMinDiscount > MAX_DISCOUNT || _lpMinDiscount == MIN_DISCOUNT || maxLPDiscount > _lpMinDiscount)
revert OptionToken_InvalidDiscount();
minLPDiscount = _lpMinDiscount;
emit SetMinLPDiscount(_lpMinDiscount);
}
/// @notice Sets the discount amount for lp. Only callable by the admin.
/// @param _lpMaxDiscount The new discount amount.
function setMaxLPDiscount(uint256 _lpMaxDiscount) external onlyAdmin {
/// @dev Cannot be higher than MAX_DISCOUNT or lte minLPDiscount
if (_lpMaxDiscount > MAX_DISCOUNT || _lpMaxDiscount == MIN_DISCOUNT || _lpMaxDiscount > minLPDiscount)
revert OptionToken_InvalidDiscount();
maxLPDiscount = _lpMaxDiscount;
emit SetMaxLPDiscount(_lpMaxDiscount);
}
/// @notice Sets the lock duration for max discount amount to create LP and stake in gauge.
/// @param _duration The new lock duration.
function setLockDurationForMaxLpDiscount(uint256 _duration) external onlyAdmin {
if (_duration <= lockDurationForMinLpDiscount) revert OptionToken_InvalidLockDuration();
lockDurationForMaxLpDiscount = _duration;
emit SetLockDurationForMaxLpDiscount(_duration);
}
/// @notice Sets the lock duration for min discount amount for locked veToken.
/// @param _duration The new lock duration.
function setLockDurationForMinVeDiscount(uint256 _duration) external onlyAdmin {
if (_duration > lockDurationForMinVeDiscount) revert OptionToken_InvalidLockDuration();
lockDurationForMinVeDiscount = _duration;
emit SetLockDurationForMaxLpDiscount(_duration);
}
// @notice Sets the lock duration for min discount amount to create LP and stake in gauge.
/// @param _duration The new lock duration.
function setLockDurationForMinLpDiscount(uint256 _duration) external onlyAdmin {
if (_duration > lockDurationForMaxLpDiscount) revert OptionToken_InvalidLockDuration();
lockDurationForMinLpDiscount = _duration;
emit SetLockDurationForMinLpDiscount(_duration);
}
/// @notice Called by the admin to burn options tokens and transfer underlying tokens to the caller.
/// @param _amount The amount of options tokens that will be burned and underlying tokens transferred to the caller
function burn(uint256 _amount) external onlyAdmin {
// transfer underlying tokens to the caller
UNDERLYING_TOKEN.safeTransfer(msg.sender, _amount);
// burn option tokens
_burn(msg.sender, _amount);
}
/// @notice called by the admin to re-enable option exercising from a paused state.
function unPause() external onlyAdmin {
if (!isPaused) return;
isPaused = false;
emit PauseStateChanged(false);
}
/// @notice called by the admin to re-enable option exercising from a paused state.
function togglePermissionedMint() external onlyAdmin {
permissionedMint = !permissionedMint;
}
function toggleOption(address option, bool enabled) external onlyAdmin {
optionTokens[option] = enabled;
emit ToggleOption(option, enabled);
}
/// -----------------------------------------------------------------------
/// Minter functions
/// -----------------------------------------------------------------------
/// @notice Called by the minter to mint options tokens. Admin must grant token approval.
/// @param _to The address that will receive the minted options tokens
/// @param _amount The amount of options tokens that will be minted
function mint(address _to, uint256 _amount) external onlyMinter {
// transfer underlying tokens from the caller
UNDERLYING_TOKEN.safeTransferFrom(msg.sender, address(this), _amount);
// mint options tokens
_mint(_to, _amount);
}
/// -----------------------------------------------------------------------
/// Pauser functions
/// -----------------------------------------------------------------------
function pause() external onlyPauser {
if (isPaused) return;
isPaused = true;
emit PauseStateChanged(true);
}
/// -----------------------------------------------------------------------
/// Internal functions
/// -----------------------------------------------------------------------
function _exercise(
uint256 _amount,
uint256 _maxPaymentAmount,
address _recipient
) internal returns (uint256 paymentAmount) {
if (isPaused) revert OptionToken_Paused();
// burn callers tokens
_burn(msg.sender, _amount);
paymentAmount = getDiscountedPrice(_amount);
if (paymentAmount > _maxPaymentAmount) revert OptionToken_SlippageTooHigh();
// transfer payment tokens from msg.sender to the fee distributor
paymentToken.safeTransferFrom(msg.sender, address(this), paymentAmount);
feeDistributor.distribute(address(paymentToken), paymentAmount);
// send underlying tokens to recipient
UNDERLYING_TOKEN.safeTransfer(_recipient, _amount); // will revert on failure
emit Exercise(msg.sender, _recipient, _amount, paymentAmount);
}
function _exerciseVe(
uint256 _amount,
uint256 _maxPaymentAmount,
uint256 _discount,
address _recipient
) internal returns (uint256 paymentAmount, uint256 nftId) {
if (isPaused) revert OptionToken_Paused();
if (_discount > discount || _discount < veMaxDiscount) revert OptionToken_InvalidDiscount();
// burn callers tokens
_burn(msg.sender, _amount);
paymentAmount = getDiscountedPrice(_amount, _discount);
if (paymentAmount > _maxPaymentAmount) revert OptionToken_SlippageTooHigh();
// transfer payment tokens from msg.sender to the fee distributor
paymentToken.safeTransferFrom(msg.sender, address(this), paymentAmount);
feeDistributor.distribute(address(paymentToken), paymentAmount);
address votingEscrow = IVoter(voter).ve();
// lock underlying tokens to vote escrow
UNDERLYING_TOKEN.approve(votingEscrow, _amount);
nftId = IVotingEscrowV2(votingEscrow).createLockFor(
_amount,
getLockDurationForVeDiscount(_discount),
_recipient,
false
);
emit ExerciseVe(msg.sender, _recipient, _amount, paymentAmount, nftId);
}
function _exerciseLp(
uint256 _amount, // the oTOKEN amount the user wants to redeem with
uint256 _maxPaymentAmount, // the
uint256 _maxLPAmount, // the
address _recipient,
uint256 _discount
) internal returns (uint256 paymentAmount, uint256 lpAmount) {
if (isPaused) revert OptionToken_Paused();
if (_discount > minLPDiscount || _discount < maxLPDiscount) revert OptionToken_InvalidDiscount();
// burn callers tokens
_burn(msg.sender, _amount);
(uint256 paymentAmounts, uint256 paymentAmountToAddLiquidity) = getPaymentTokenAmountForExerciseLp(
_amount,
_discount
);
paymentAmount = paymentAmounts;
if (paymentAmount > _maxPaymentAmount || paymentAmountToAddLiquidity > _maxLPAmount) revert OptionToken_SlippageTooHigh();
/// @notice user pays redeem amount + required payment for LP deposit
paymentToken.safeTransferFrom(msg.sender, address(this), paymentAmount + paymentAmountToAddLiquidity);
// transfer payment tokens to the fee distributor
feeDistributor.distribute(address(paymentToken), paymentAmount);
// Create Lp for users
UNDERLYING_TOKEN.approve(router, _amount);
paymentToken.approve(router, paymentAmountToAddLiquidity);
(, , lpAmount) = IRouter(router).addLiquidity(
address(UNDERLYING_TOKEN),
address(paymentToken),
false,
_amount,
paymentAmountToAddLiquidity,
1,
1,
address(this),
block.timestamp
);
IERC20(address(pair)).approve(gauge, lpAmount);
IGauge(gauge).depositWithLock(_recipient, lpAmount, getLockDurationForLpDiscount(_discount));
emit ExerciseLp(msg.sender, _recipient, _amount, paymentAmount, lpAmount);
}
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.13;
import {IERC5805} from "@openzeppelin/contracts/interfaces/IERC5805.sol";
import {Checkpoints} from "../libraries/Checkpoints.sol";
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {IERC721Enumerable} from "@openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.sol";
interface IVotingEscrowV2 is IERC5805, IERC721Enumerable {
struct LockDetails {
uint256 amount; /// @dev amount of tokens locked
uint256 startTime; /// @dev when locking started
uint256 endTime; /// @dev when locking ends
bool isPermanent; /// @dev if its a permanent lock
}
/// -----------------------------------------------------------------------
/// Events
/// -----------------------------------------------------------------------
event SupplyUpdated(uint256 oldSupply, uint256 newSupply);
/// @notice Lock events
event LockCreated(uint256 indexed tokenId, address indexed to, uint256 value, uint256 unlockTime, bool isPermanent);
event LockUpdated(uint256 indexed tokenId, uint256 value, uint256 unlockTime, bool isPermanent);
event LockMerged(
uint256 indexed fromTokenId,
uint256 indexed toTokenId,
uint256 totalValue,
uint256 unlockTime,
bool isPermanent
);
event LockSplit(uint256[] splitWeights, uint256 indexed _tokenId);
event LockDurationExtended(uint256 indexed tokenId, uint256 newUnlockTime, bool isPermanent);
event LockAmountIncreased(uint256 indexed tokenId, uint256 value);
event UnlockPermanent(uint256 indexed tokenId, address indexed sender, uint256 unlockTime);
/// @notice Delegate events
event LockDelegateChanged(
uint256 indexed tokenId,
address indexed delegator,
address fromDelegate,
address indexed toDelegate
);
/// -----------------------------------------------------------------------
/// Errors
/// -----------------------------------------------------------------------
error AlreadyVoted();
error InvalidNonce();
error InvalidDelegatee();
error InvalidSignature();
error InvalidSignatureS();
error LockDurationNotInFuture();
error LockDurationTooLong();
error LockExpired();
error LockNotExpired();
error NoLockFound();
error NotPermanentLock();
error PermanentLock();
error SameNFT();
error SignatureExpired();
error ZeroAmount();
function supply() external view returns (uint);
function token() external view returns (IERC20);
function balanceOfNFT(uint256 _tokenId) external view returns (uint256);
function balanceOfNFTAt(uint256 _tokenId, uint256 _timestamp) external view returns (uint256);
function delegates(uint256 tokenId, uint48 timestamp) external view returns (address);
function lockDetails(uint256 tokenId) external view returns (LockDetails calldata);
function isApprovedOrOwner(address user, uint tokenId) external view returns (bool);
function getPastEscrowPoint(
uint256 _tokenId,
uint256 _timePoint
) external view returns (Checkpoints.Point memory, uint48);
function getFirstEscrowPoint(uint256 _tokenId) external view returns (Checkpoints.Point memory, uint48);
function checkpoint() external;
function increaseAmount(uint256 _tokenId, uint256 _value) external;
function createLockFor(uint256 _value, uint256 _lockDuration, address _to, bool _permanent) external returns (uint256);
function decimals() external view returns(uint8);
}// SPDX-License-Identifier: MIT
// This file was derived from OpenZeppelin Contracts (last updated v5.0.0) (utils/structs/Checkpoints.sol)
pragma solidity 0.8.13;
import {Math} from "@openzeppelin/contracts/utils/math/Math.sol";
/**
* @dev This library defines the `Trace*` struct, for checkpointing values as they change at different points in
* time, and later looking up past values by block number. See {Votes} as an example.
*
* To create a history of checkpoints define a variable type `Checkpoints.Trace*` in your contract, and store a new
* checkpoint for the current transaction block using the {push} function.
*/
library Checkpoints {
struct Trace {
Checkpoint[] _checkpoints;
}
/**
* @dev Struct to keep track of the voting power over time.
*/
struct Point {
/// @dev The voting power at a specific time
/// - MUST never be negative.
int128 bias;
/// @dev The rate at which the voting power decreases over time.
int128 slope;
/// @dev The value of tokens which do not decrease over time, representing permanent voting power
/// - MUST never be negative.
int128 permanent;
}
struct Checkpoint {
uint48 _key;
Point _value;
}
/**
* @dev A value was attempted to be inserted on a past checkpoint.
*/
error CheckpointUnorderedInsertions();
/**
* @dev Pushes a (`key`, `value`) pair into a Trace so that it is stored as the checkpoint.
*
* Returns previous value and new value.
*
* IMPORTANT: Never accept `key` as a user input, since an arbitrary `type(uint48).max` key set will disable the
* library.
*/
function push(Trace storage self, uint48 key, Point memory value) internal returns (Point memory, Point memory) {
return _insert(self._checkpoints, key, value);
}
/**
* @dev Returns the value in the first (oldest) checkpoint with key greater or equal than the search key, or zero if
* there is none.
*/
function lowerLookup(Trace storage self, uint48 key) internal view returns (Point memory) {
uint256 len = self._checkpoints.length;
uint256 pos = _lowerBinaryLookup(self._checkpoints, key, 0, len);
return pos == len ? blankPoint() : _unsafeAccess(self._checkpoints, pos)._value;
}
/**
* @dev Returns the value in the last (most recent) checkpoint with key lower or equal than the search key, or zero
* if there is none.
*/
function upperLookup(
Trace storage self,
uint48 key
) internal view returns (bool exists, uint48 _key, Point memory _value) {
uint256 len = self._checkpoints.length;
uint256 pos = _upperBinaryLookup(self._checkpoints, key, 0, len);
exists = pos != 0;
_value = exists ? _unsafeAccess(self._checkpoints, pos - 1)._value : blankPoint();
_key = exists ? _unsafeAccess(self._checkpoints, pos - 1)._key : 0;
}
/**
* @dev Returns the value in the last (most recent) checkpoint with key lower or equal than the search key, or zero
* if there is none.
*
* NOTE: This is a variant of {upperLookup} that is optimised to find "recent" checkpoint (checkpoints with high
* keys).
*/
function upperLookupRecent(
Trace storage self,
uint48 key
) internal view returns (bool exists, uint48 _key, Point memory _value) {
uint256 len = self._checkpoints.length;
uint256 low = 0;
uint256 high = len;
if (len > 5) {
uint256 mid = len - Math.sqrt(len);
if (key < _unsafeAccess(self._checkpoints, mid)._key) {
high = mid;
} else {
low = mid + 1;
}
}
uint256 pos = _upperBinaryLookup(self._checkpoints, key, low, high);
exists = pos != 0;
_value = exists ? _unsafeAccess(self._checkpoints, pos - 1)._value : blankPoint();
_key = exists ? _unsafeAccess(self._checkpoints, pos - 1)._key : 0;
}
/**
* @dev Returns the value in the most recent checkpoint, or zero if there are no checkpoints.
*/
function latest(Trace storage self) internal view returns (Point memory) {
uint256 pos = self._checkpoints.length;
return pos == 0 ? blankPoint() : _unsafeAccess(self._checkpoints, pos - 1)._value;
}
/**
* @dev Returns whether there is a checkpoint in the structure (i.e. it is not empty), and if so the key and value
* in the most recent checkpoint.
*/
function latestCheckpoint(
Trace storage self
) internal view returns (bool exists, uint48 _key, Point memory _value) {
uint256 pos = self._checkpoints.length;
if (pos == 0) {
return (false, 0, blankPoint());
} else {
Checkpoint memory ckpt = _unsafeAccess(self._checkpoints, pos - 1);
return (true, ckpt._key, ckpt._value);
}
}
/**
* @dev Returns whether there is a checkpoint in the structure (i.e. it is not empty), and if so the key and value
* in the most recent checkpoint.
*/
function firstCheckpoint(
Trace storage self
) internal view returns (bool exists, uint48 _key, Point memory _value) {
uint256 pos = self._checkpoints.length;
if (pos == 0) {
return (false, 0, blankPoint());
} else {
Checkpoint memory ckpt = _unsafeAccess(self._checkpoints, 0);
return (true, ckpt._key, ckpt._value);
}
}
/**
* @dev Returns the number of checkpoint.
*/
function length(Trace storage self) internal view returns (uint256) {
return self._checkpoints.length;
}
/**
* @dev Returns checkpoint at given position.
*/
function at(Trace storage self, uint48 pos) internal view returns (Checkpoint memory) {
return self._checkpoints[pos];
}
/**
* @dev Pushes a (`key`, `value`) pair into an ordered list of checkpoints, either by inserting a new checkpoint,
* or by updating the last one.
*/
function _insert(
Checkpoint[] storage self,
uint48 key,
Point memory value
) private returns (Point memory, Point memory) {
uint256 pos = self.length;
if (pos > 0) {
// Copying to memory is important here.
Checkpoint memory last = _unsafeAccess(self, pos - 1);
// Checkpoint keys must be non-decreasing.
if (last._key > key) {
revert CheckpointUnorderedInsertions();
}
// Update or push new checkpoint
if (last._key == key) {
_unsafeAccess(self, pos - 1)._value = value;
} else {
self.push(Checkpoint({_key: key, _value: value}));
}
return (last._value, value);
} else {
self.push(Checkpoint({_key: key, _value: value}));
return (blankPoint(), value);
}
}
/**
* @dev Return the index of the last (most recent) checkpoint with key lower or equal than the search key, or `high`
* if there is none. `low` and `high` define a section where to do the search, with inclusive `low` and exclusive
* `high`.
*
* WARNING: `high` should not be greater than the array's length.
*/
function _upperBinaryLookup(
Checkpoint[] storage self,
uint48 key,
uint256 low,
uint256 high
) private view returns (uint256) {
while (low < high) {
uint256 mid = Math.average(low, high);
if (_unsafeAccess(self, mid)._key > key) {
high = mid;
} else {
low = mid + 1;
}
}
return high;
}
/**
* @dev Return the index of the first (oldest) checkpoint with key is greater or equal than the search key, or
* `high` if there is none. `low` and `high` define a section where to do the search, with inclusive `low` and
* exclusive `high`.
*
* WARNING: `high` should not be greater than the array's length.
*/
function _lowerBinaryLookup(
Checkpoint[] storage self,
uint48 key,
uint256 low,
uint256 high
) private view returns (uint256) {
while (low < high) {
uint256 mid = Math.average(low, high);
if (_unsafeAccess(self, mid)._key < key) {
low = mid + 1;
} else {
high = mid;
}
}
return high;
}
/**
* @dev Access an element of the array without performing bounds check. The position is assumed to be within bounds.
*/
function _unsafeAccess(Checkpoint[] storage self, uint256 pos) private view returns (Checkpoint storage result) {
return self[pos];
}
/**
* @dev Access an element of the array without performing bounds check. The position is assumed to be within bounds.
*/
function _realUnsafeAccess(
Checkpoint[] storage self,
uint256 pos
) private pure returns (Checkpoint storage result) {
assembly {
mstore(0, self.slot)
result.slot := add(keccak256(0, 0x20), pos)
}
}
function blankPoint() internal pure returns (Point memory) {
return Point({bias: 0, slope: 0, permanent: 0});
}
struct TraceAddress {
CheckpointAddress[] _checkpoints;
}
struct CheckpointAddress {
uint48 _key;
address _value;
}
/**
* @dev Pushes a (`key`, `value`) pair into a TraceAddress so that it is stored as the checkpoint.
*
* Returns previous value and new value.
*
* IMPORTANT: Never accept `key` as a user input, since an arbitrary `type(uint48).max` key set will disable the
* library.
*/
function push(TraceAddress storage self, uint48 key, address value) internal returns (address, address) {
return _insert(self._checkpoints, key, value);
}
/**
* @dev Returns the value in the first (oldest) checkpoint with key greater or equal than the search key, or zero if
* there is none.
*/
function lowerLookup(TraceAddress storage self, uint48 key) internal view returns (address) {
uint256 len = self._checkpoints.length;
uint256 pos = _lowerBinaryLookup(self._checkpoints, key, 0, len);
return pos == len ? address(0) : _unsafeAccess(self._checkpoints, pos)._value;
}
/**
* @dev Returns the value in the last (most recent) checkpoint with key lower or equal than the search key, or zero
* if there is none.
*/
function upperLookup(TraceAddress storage self, uint48 key) internal view returns (address) {
uint256 len = self._checkpoints.length;
uint256 pos = _upperBinaryLookup(self._checkpoints, key, 0, len);
return pos == 0 ? address(0) : _unsafeAccess(self._checkpoints, pos - 1)._value;
}
/**
* @dev Returns the value in the last (most recent) checkpoint with key lower or equal than the search key, or zero
* if there is none.
*
* NOTE: This is a variant of {upperLookup} that is optimised to find "recent" checkpoint (checkpoints with high
* keys).
*/
function upperLookupRecent(TraceAddress storage self, uint48 key) internal view returns (address) {
uint256 len = self._checkpoints.length;
uint256 low = 0;
uint256 high = len;
if (len > 5) {
uint256 mid = len - Math.sqrt(len);
if (key < _unsafeAccess(self._checkpoints, mid)._key) {
high = mid;
} else {
low = mid + 1;
}
}
uint256 pos = _upperBinaryLookup(self._checkpoints, key, low, high);
return pos == 0 ? address(0) : _unsafeAccess(self._checkpoints, pos - 1)._value;
}
/**
* @dev Returns the value in the most recent checkpoint, or zero if there are no checkpoints.
*/
function latest(TraceAddress storage self) internal view returns (address) {
uint256 pos = self._checkpoints.length;
return pos == 0 ? address(0) : _unsafeAccess(self._checkpoints, pos - 1)._value;
}
/**
* @dev Returns whether there is a checkpoint in the structure (i.e. it is not empty), and if so the key and value
* in the most recent checkpoint.
*/
function latestCheckpoint(
TraceAddress storage self
) internal view returns (bool exists, uint48 _key, address _value) {
uint256 pos = self._checkpoints.length;
if (pos == 0) {
return (false, 0, address(0));
} else {
CheckpointAddress memory ckpt = _unsafeAccess(self._checkpoints, pos - 1);
return (true, ckpt._key, ckpt._value);
}
}
/**
* @dev Returns the number of checkpoint.
*/
function length(TraceAddress storage self) internal view returns (uint256) {
return self._checkpoints.length;
}
/**
* @dev Returns checkpoint at given position.
*/
function at(TraceAddress storage self, uint48 pos) internal view returns (CheckpointAddress memory) {
return self._checkpoints[pos];
}
/**
* @dev Pushes a (`key`, `value`) pair into an ordered list of checkpoints, either by inserting a new checkpoint,
* or by updating the last one.
*/
function _insert(CheckpointAddress[] storage self, uint48 key, address value) private returns (address, address) {
uint256 pos = self.length;
if (pos > 0) {
// Copying to memory is important here.
CheckpointAddress memory last = _unsafeAccess(self, pos - 1);
// Checkpoint keys must be non-decreasing.
if (last._key > key) {
revert CheckpointUnorderedInsertions();
}
// Update or push new checkpoint
if (last._key == key) {
_unsafeAccess(self, pos - 1)._value = value;
} else {
self.push(CheckpointAddress({_key: key, _value: value}));
}
return (last._value, value);
} else {
self.push(CheckpointAddress({_key: key, _value: value}));
return (address(0), value);
}
}
/**
* @dev Return the index of the last (most recent) checkpoint with key lower or equal than the search key, or `high`
* if there is none. `low` and `high` define a section where to do the search, with inclusive `low` and exclusive
* `high`.
*
* WARNING: `high` should not be greater than the array's length.
*/
function _upperBinaryLookup(
CheckpointAddress[] storage self,
uint48 key,
uint256 low,
uint256 high
) private view returns (uint256) {
while (low < high) {
uint256 mid = Math.average(low, high);
if (_unsafeAccess(self, mid)._key > key) {
high = mid;
} else {
low = mid + 1;
}
}
return high;
}
/**
* @dev Return the index of the first (oldest) checkpoint with key is greater or equal than the search key, or
* `high` if there is none. `low` and `high` define a section where to do the search, with inclusive `low` and
* exclusive `high`.
*
* WARNING: `high` should not be greater than the array's length.
*/
function _lowerBinaryLookup(
CheckpointAddress[] storage self,
uint48 key,
uint256 low,
uint256 high
) private view returns (uint256) {
while (low < high) {
uint256 mid = Math.average(low, high);
if (_unsafeAccess(self, mid)._key < key) {
low = mid + 1;
} else {
high = mid;
}
}
return high;
}
/**
* @dev Access an element of the array without performing bounds check. The position is assumed to be within bounds.
*/
function _unsafeAccess(
CheckpointAddress[] storage self,
uint256 pos
) private pure returns (CheckpointAddress storage result) {
assembly {
mstore(0, self.slot)
result.slot := add(keccak256(0, 0x20), pos)
}
}
}{
"optimizer": {
"enabled": true,
"runs": 1000
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"libraries": {}
}Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[{"internalType":"string","name":"_name","type":"string"},{"internalType":"string","name":"_symbol","type":"string"},{"internalType":"contract OptionTokenV3","name":"_optionToken","type":"address"},{"internalType":"address","name":"_admin","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"OptionToken_NoAdminRole","type":"error"},{"inputs":[],"name":"OptionToken_NoMinterRole","type":"error"},{"inputs":[],"name":"OptionToken_NoPauserRole","type":"error"},{"inputs":[],"name":"OptionToken_PastDeadline","type":"error"},{"inputs":[],"name":"OptionToken_Paused","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"sender","type":"address"},{"indexed":true,"internalType":"address","name":"recipient","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"nftId","type":"uint256"}],"name":"ExerciseVe","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bool","name":"isPaused","type":"bool"}],"name":"PauseStateChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","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":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"inputs":[],"name":"ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MINTER_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"PAUSER_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"subtractedValue","type":"uint256"}],"name":"decreaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"uint256","name":"_maxPaymentAmount","type":"uint256"},{"internalType":"address","name":"_recipient","type":"address"},{"internalType":"uint256","name":"_deadline","type":"uint256"}],"name":"exerciseVe","outputs":[{"internalType":"uint256","name":"nftId","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"addedValue","type":"uint256"}],"name":"increaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"isPaused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"mint","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"optionToken","outputs":[{"internalType":"contract OptionTokenV3","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"permissionedMint","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"togglePermissionedMint","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"unPause","outputs":[],"stateMutability":"nonpayable","type":"function"}]Contract Creation Code
60a06040526006805460ff191690553480156200001b57600080fd5b5060405162001f0638038062001f068339810160408190526200003e91620003e0565b8351849084906200005790600390602085019062000254565b5080516200006d90600490602084019062000254565b5050506200009160008051602062001ee6833981519152826200016460201b60201c565b620000bd7f539440820030c4994db4e31b6b800deafd503688728f932addfe7a410515c14c8262000164565b620000d860008051602062001ee68339815191528062000209565b620001137ff0887ba65ee2024ea881d91b74c2450ef19e1557f03bed3ea9f16b037cbe2dc960008051602062001ee683398151915262000209565b6200014e7f539440820030c4994db4e31b6b800deafd503688728f932addfe7a410515c14c60008051602062001ee683398151915262000209565b506001600160a01b031660805250620004b09050565b60008281526005602090815260408083206001600160a01b038516845290915290205460ff16620002055760008281526005602090815260408083206001600160a01b03851684529091529020805460ff19166001179055620001c43390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45b5050565b600082815260056020526040808220600101805490849055905190918391839186917fbd79b86ffe0ab8e8776151514217cd7cacd52c909f66475c3af44e129f0b00ff9190a4505050565b828054620002629062000474565b90600052602060002090601f016020900481019282620002865760008555620002d1565b82601f10620002a157805160ff1916838001178555620002d1565b82800160010185558215620002d1579182015b82811115620002d1578251825591602001919060010190620002b4565b50620002df929150620002e3565b5090565b5b80821115620002df5760008155600101620002e4565b634e487b7160e01b600052604160045260246000fd5b600082601f8301126200032257600080fd5b81516001600160401b03808211156200033f576200033f620002fa565b604051601f8301601f19908116603f011681019082821181831017156200036a576200036a620002fa565b816040528381526020925086838588010111156200038757600080fd5b600091505b83821015620003ab57858201830151818301840152908201906200038c565b83821115620003bd5760008385830101525b9695505050505050565b6001600160a01b0381168114620003dd57600080fd5b50565b60008060008060808587031215620003f757600080fd5b84516001600160401b03808211156200040f57600080fd5b6200041d8883890162000310565b955060208701519150808211156200043457600080fd5b50620004438782880162000310565b93505060408501516200045681620003c7565b60608601519092506200046981620003c7565b939692955090935050565b600181811c908216806200048957607f821691505b602082108103620004aa57634e487b7160e01b600052602260045260246000fd5b50919050565b608051611a0c620004da60003960008181610271015281816107fa01526109550152611a0c6000f3fe608060405234801561001057600080fd5b50600436106101cf5760003560e01c806375b238fc11610104578063a7f32719116100a2578063d547741f11610071578063d547741f14610430578063dd62ed3e14610443578063e63ab1e91461047c578063f7b188a5146104a357600080fd5b8063a7f32719146103dc578063a9059cbb146103e4578063b187bd26146103f7578063d53913931461040957600080fd5b806391d14854116100de57806391d148541461038057806395d89b41146103b9578063a217fddf146103c1578063a457c2d7146103c957600080fd5b806375b238fc146103445780638456cb591461036b5780638d6d8b091461037357600080fd5b80632f2ff15d11610171578063395093511161014b57806339509351146102e257806340c10f19146102f557806362994c051461030857806370a082311461031b57600080fd5b80632f2ff15d146102ab578063313ce567146102c057806336568abe146102cf57600080fd5b806318160ddd116101ad57806318160ddd1461022457806323b872dd14610236578063248a9ca3146102495780632bab754b1461026c57600080fd5b806301ffc9a7146101d457806306fdde03146101fc578063095ea7b314610211575b600080fd5b6101e76101e236600461165b565b6104ab565b60405190151581526020015b60405180910390f35b610204610544565b6040516101f391906116c9565b6101e761021f366004611718565b6105d6565b6002545b6040519081526020016101f3565b6101e7610244366004611742565b6105ee565b61022861025736600461177e565b60009081526005602052604090206001015490565b6102937f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b0390911681526020016101f3565b6102be6102b9366004611797565b610612565b005b604051601281526020016101f3565b6102be6102dd366004611797565b61063c565b6101e76102f0366004611718565b6106cd565b6102be610303366004611718565b61070c565b6102286103163660046117c3565b61087a565b610228610329366004611800565b6001600160a01b031660009081526020819052604090205490565b6102287fdf8b4c520ffe197c5343c6f5aec59570151ef9a492f2c624fd45ddde6135ec4281565b6102be610a13565b6006546101e79060ff1681565b6101e761038e366004611797565b60009182526005602090815260408084206001600160a01b0393909316845291905290205460ff1690565b610204610ad1565b610228600081565b6101e76103d7366004611718565b610ae0565b6102be610b8a565b6101e76103f2366004611718565b610bed565b6006546101e790610100900460ff1681565b6102287ff0887ba65ee2024ea881d91b74c2450ef19e1557f03bed3ea9f16b037cbe2dc981565b6102be61043e366004611797565b610bfb565b61022861045136600461181b565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b6102287f539440820030c4994db4e31b6b800deafd503688728f932addfe7a410515c14c81565b6102be610c20565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f7965db0b00000000000000000000000000000000000000000000000000000000148061053e57507f01ffc9a7000000000000000000000000000000000000000000000000000000007fffffffff000000000000000000000000000000000000000000000000000000008316145b92915050565b60606003805461055390611845565b80601f016020809104026020016040519081016040528092919081815260200182805461057f90611845565b80156105cc5780601f106105a1576101008083540402835291602001916105cc565b820191906000526020600020905b8154815290600101906020018083116105af57829003601f168201915b5050505050905090565b6000336105e4818585610cbb565b5060019392505050565b6000336105fc858285610e13565b610607858585610ea5565b506001949350505050565b60008281526005602052604090206001015461062d81611092565b610637838361109f565b505050565b6001600160a01b03811633146106bf5760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201527f20726f6c657320666f722073656c66000000000000000000000000000000000060648201526084015b60405180910390fd5b6106c98282611141565b5050565b3360008181526001602090815260408083206001600160a01b03871684529091528120549091906105e49082908690610707908790611895565b610cbb565b60065460ff16801561074d57503360009081527f09f04f5809d5be59813a33617d16f069caae874a6b34f03139f63d934daddae6602052604090205460ff16155b801561078857503360009081527fca0a2f641ec05ca23127d994cf03ffc453db616acae0b86cb56bb95304d06854602052604090205460ff16155b156107bf576040517f4fcb6d0100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040517f23b872dd000000000000000000000000000000000000000000000000000000008152336004820152306024820152604481018290527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906323b872dd906064016020604051808303816000875af115801561084b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061086f91906118ad565b506106c982826111c4565b6000814211156108b6576040517f5aac626200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600654610100900460ff16156108f7576040517eb4aa3700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6109013386611283565b6040517fa9f6ee3300000000000000000000000000000000000000000000000000000000815260048101869052602481018590526001600160a01b03848116604483015260006064830152608482018490527f0000000000000000000000000000000000000000000000000000000000000000169063a9f6ee339060a40160408051808303816000875af115801561099d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109c191906118cf565b60408051888152602081018390529193506001600160a01b038616925033917fb8828f93d133aa6adcb920a5139bd3549f1ece7d8e208e36b8b27bc7d86bedfa910160405180910390a3949350505050565b3360009081527f6d1313f54c6e85b8122281b762369ceaab354256c60189434b7be71b5b32a70f602052604090205460ff16610a7b576040517fb1c851f800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600654610100900460ff16610acf576006805461ff001916610100179055604051600181527f4543baa938cb97f5073ec206ad35638cdb1f4db8f677d31579b2f6fe7d18c14a906020015b60405180910390a15b565b60606004805461055390611845565b3360008181526001602090815260408083206001600160a01b038716845290915281205490919083811015610b7d5760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f7760448201527f207a65726f00000000000000000000000000000000000000000000000000000060648201526084016106b6565b6106078286868403610cbb565b3360009081527f09f04f5809d5be59813a33617d16f069caae874a6b34f03139f63d934daddae6602052604090205460ff16610bd95760405163f982dd0f60e01b815260040160405180910390fd5b6006805460ff19811660ff90911615179055565b6000336105e4818585610ea5565b600082815260056020526040902060010154610c1681611092565b6106378383611141565b3360009081527f09f04f5809d5be59813a33617d16f069caae874a6b34f03139f63d934daddae6602052604090205460ff16610c6f5760405163f982dd0f60e01b815260040160405180910390fd5b600654610100900460ff1615610acf576006805461ff0019169055604051600081527f4543baa938cb97f5073ec206ad35638cdb1f4db8f677d31579b2f6fe7d18c14a90602001610ac6565b6001600160a01b038316610d365760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460448201527f726573730000000000000000000000000000000000000000000000000000000060648201526084016106b6565b6001600160a01b038216610db25760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f20616464726560448201527f737300000000000000000000000000000000000000000000000000000000000060648201526084016106b6565b6001600160a01b0383811660008181526001602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b6001600160a01b038381166000908152600160209081526040808320938616835292905220546000198114610e9f5781811015610e925760405162461bcd60e51b815260206004820152601d60248201527f45524332303a20696e73756666696369656e7420616c6c6f77616e636500000060448201526064016106b6565b610e9f8484848403610cbb565b50505050565b6001600160a01b038316610f215760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f20616460448201527f647265737300000000000000000000000000000000000000000000000000000060648201526084016106b6565b6001600160a01b038216610f9d5760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201527f657373000000000000000000000000000000000000000000000000000000000060648201526084016106b6565b6001600160a01b0383166000908152602081905260409020548181101561102c5760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e742065786365656473206260448201527f616c616e6365000000000000000000000000000000000000000000000000000060648201526084016106b6565b6001600160a01b03848116600081815260208181526040808320878703905593871680835291849020805487019055925185815290927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a3610e9f565b61109c81336113ec565b50565b60008281526005602090815260408083206001600160a01b038516845290915290205460ff166106c95760008281526005602090815260408083206001600160a01b03851684529091529020805460ff191660011790556110fd3390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b60008281526005602090815260408083206001600160a01b038516845290915290205460ff16156106c95760008281526005602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b6001600160a01b03821661121a5760405162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f20616464726573730060448201526064016106b6565b806002600082825461122c9190611895565b90915550506001600160a01b038216600081815260208181526040808320805486019055518481527fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a35050565b6001600160a01b0382166112ff5760405162461bcd60e51b815260206004820152602160248201527f45524332303a206275726e2066726f6d20746865207a65726f2061646472657360448201527f730000000000000000000000000000000000000000000000000000000000000060648201526084016106b6565b6001600160a01b0382166000908152602081905260409020548181101561138e5760405162461bcd60e51b815260206004820152602260248201527f45524332303a206275726e20616d6f756e7420657863656564732062616c616e60448201527f636500000000000000000000000000000000000000000000000000000000000060648201526084016106b6565b6001600160a01b0383166000818152602081815260408083208686039055600280548790039055518581529192917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a3505050565b60008281526005602090815260408083206001600160a01b038516845290915290205460ff166106c95761141f81611461565b61142a836020611473565b60405160200161143b9291906118f3565b60408051601f198184030181529082905262461bcd60e51b82526106b6916004016116c9565b606061053e6001600160a01b03831660145b60606000611482836002611974565b61148d906002611895565b67ffffffffffffffff8111156114a5576114a5611993565b6040519080825280601f01601f1916602001820160405280156114cf576020820181803683370190505b5090507f300000000000000000000000000000000000000000000000000000000000000081600081518110611506576115066119a9565b60200101906001600160f81b031916908160001a9053507f780000000000000000000000000000000000000000000000000000000000000081600181518110611551576115516119a9565b60200101906001600160f81b031916908160001a9053506000611575846002611974565b611580906001611895565b90505b6001811115611605577f303132333435363738396162636465660000000000000000000000000000000085600f16601081106115c1576115c16119a9565b1a60f81b8282815181106115d7576115d76119a9565b60200101906001600160f81b031916908160001a90535060049490941c936115fe816119bf565b9050611583565b5083156116545760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e7460448201526064016106b6565b9392505050565b60006020828403121561166d57600080fd5b81357fffffffff000000000000000000000000000000000000000000000000000000008116811461165457600080fd5b60005b838110156116b85781810151838201526020016116a0565b83811115610e9f5750506000910152565b60208152600082518060208401526116e881604085016020870161169d565b601f01601f19169190910160400192915050565b80356001600160a01b038116811461171357600080fd5b919050565b6000806040838503121561172b57600080fd5b611734836116fc565b946020939093013593505050565b60008060006060848603121561175757600080fd5b611760846116fc565b925061176e602085016116fc565b9150604084013590509250925092565b60006020828403121561179057600080fd5b5035919050565b600080604083850312156117aa57600080fd5b823591506117ba602084016116fc565b90509250929050565b600080600080608085870312156117d957600080fd5b84359350602085013592506117f0604086016116fc565b9396929550929360600135925050565b60006020828403121561181257600080fd5b611654826116fc565b6000806040838503121561182e57600080fd5b611837836116fc565b91506117ba602084016116fc565b600181811c9082168061185957607f821691505b60208210810361187957634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052601160045260246000fd5b600082198211156118a8576118a861187f565b500190565b6000602082840312156118bf57600080fd5b8151801515811461165457600080fd5b600080604083850312156118e257600080fd5b505080516020909101519092909150565b7f416363657373436f6e74726f6c3a206163636f756e742000000000000000000081526000835161192b81601785016020880161169d565b7f206973206d697373696e6720726f6c6520000000000000000000000000000000601791840191820152835161196881602884016020880161169d565b01602801949350505050565b600081600019048311821515161561198e5761198e61187f565b500290565b634e487b7160e01b600052604160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b6000816119ce576119ce61187f565b50600019019056fea2646970667358221220377dc29c7758d279029b7843bb37ede1d47b477a9dc267012e34976bd6e853ed64736f6c634300080d0033df8b4c520ffe197c5343c6f5aec59570151ef9a492f2c624fd45ddde6135ec42000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000c000000000000000000000000063349ba5e1f71252ecd56e8f950d1a518b400b600000000000000000000000009db42d3bda1525963db3b2372c4daabaf0491a53000000000000000000000000000000000000000000000000000000000000000c42726962652076654c594e58000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000076276654c594e5800000000000000000000000000000000000000000000000000
Deployed Bytecode
0x608060405234801561001057600080fd5b50600436106101cf5760003560e01c806375b238fc11610104578063a7f32719116100a2578063d547741f11610071578063d547741f14610430578063dd62ed3e14610443578063e63ab1e91461047c578063f7b188a5146104a357600080fd5b8063a7f32719146103dc578063a9059cbb146103e4578063b187bd26146103f7578063d53913931461040957600080fd5b806391d14854116100de57806391d148541461038057806395d89b41146103b9578063a217fddf146103c1578063a457c2d7146103c957600080fd5b806375b238fc146103445780638456cb591461036b5780638d6d8b091461037357600080fd5b80632f2ff15d11610171578063395093511161014b57806339509351146102e257806340c10f19146102f557806362994c051461030857806370a082311461031b57600080fd5b80632f2ff15d146102ab578063313ce567146102c057806336568abe146102cf57600080fd5b806318160ddd116101ad57806318160ddd1461022457806323b872dd14610236578063248a9ca3146102495780632bab754b1461026c57600080fd5b806301ffc9a7146101d457806306fdde03146101fc578063095ea7b314610211575b600080fd5b6101e76101e236600461165b565b6104ab565b60405190151581526020015b60405180910390f35b610204610544565b6040516101f391906116c9565b6101e761021f366004611718565b6105d6565b6002545b6040519081526020016101f3565b6101e7610244366004611742565b6105ee565b61022861025736600461177e565b60009081526005602052604090206001015490565b6102937f00000000000000000000000063349ba5e1f71252ecd56e8f950d1a518b400b6081565b6040516001600160a01b0390911681526020016101f3565b6102be6102b9366004611797565b610612565b005b604051601281526020016101f3565b6102be6102dd366004611797565b61063c565b6101e76102f0366004611718565b6106cd565b6102be610303366004611718565b61070c565b6102286103163660046117c3565b61087a565b610228610329366004611800565b6001600160a01b031660009081526020819052604090205490565b6102287fdf8b4c520ffe197c5343c6f5aec59570151ef9a492f2c624fd45ddde6135ec4281565b6102be610a13565b6006546101e79060ff1681565b6101e761038e366004611797565b60009182526005602090815260408084206001600160a01b0393909316845291905290205460ff1690565b610204610ad1565b610228600081565b6101e76103d7366004611718565b610ae0565b6102be610b8a565b6101e76103f2366004611718565b610bed565b6006546101e790610100900460ff1681565b6102287ff0887ba65ee2024ea881d91b74c2450ef19e1557f03bed3ea9f16b037cbe2dc981565b6102be61043e366004611797565b610bfb565b61022861045136600461181b565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b6102287f539440820030c4994db4e31b6b800deafd503688728f932addfe7a410515c14c81565b6102be610c20565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f7965db0b00000000000000000000000000000000000000000000000000000000148061053e57507f01ffc9a7000000000000000000000000000000000000000000000000000000007fffffffff000000000000000000000000000000000000000000000000000000008316145b92915050565b60606003805461055390611845565b80601f016020809104026020016040519081016040528092919081815260200182805461057f90611845565b80156105cc5780601f106105a1576101008083540402835291602001916105cc565b820191906000526020600020905b8154815290600101906020018083116105af57829003601f168201915b5050505050905090565b6000336105e4818585610cbb565b5060019392505050565b6000336105fc858285610e13565b610607858585610ea5565b506001949350505050565b60008281526005602052604090206001015461062d81611092565b610637838361109f565b505050565b6001600160a01b03811633146106bf5760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201527f20726f6c657320666f722073656c66000000000000000000000000000000000060648201526084015b60405180910390fd5b6106c98282611141565b5050565b3360008181526001602090815260408083206001600160a01b03871684529091528120549091906105e49082908690610707908790611895565b610cbb565b60065460ff16801561074d57503360009081527f09f04f5809d5be59813a33617d16f069caae874a6b34f03139f63d934daddae6602052604090205460ff16155b801561078857503360009081527fca0a2f641ec05ca23127d994cf03ffc453db616acae0b86cb56bb95304d06854602052604090205460ff16155b156107bf576040517f4fcb6d0100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040517f23b872dd000000000000000000000000000000000000000000000000000000008152336004820152306024820152604481018290527f00000000000000000000000063349ba5e1f71252ecd56e8f950d1a518b400b606001600160a01b0316906323b872dd906064016020604051808303816000875af115801561084b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061086f91906118ad565b506106c982826111c4565b6000814211156108b6576040517f5aac626200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600654610100900460ff16156108f7576040517eb4aa3700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6109013386611283565b6040517fa9f6ee3300000000000000000000000000000000000000000000000000000000815260048101869052602481018590526001600160a01b03848116604483015260006064830152608482018490527f00000000000000000000000063349ba5e1f71252ecd56e8f950d1a518b400b60169063a9f6ee339060a40160408051808303816000875af115801561099d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109c191906118cf565b60408051888152602081018390529193506001600160a01b038616925033917fb8828f93d133aa6adcb920a5139bd3549f1ece7d8e208e36b8b27bc7d86bedfa910160405180910390a3949350505050565b3360009081527f6d1313f54c6e85b8122281b762369ceaab354256c60189434b7be71b5b32a70f602052604090205460ff16610a7b576040517fb1c851f800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600654610100900460ff16610acf576006805461ff001916610100179055604051600181527f4543baa938cb97f5073ec206ad35638cdb1f4db8f677d31579b2f6fe7d18c14a906020015b60405180910390a15b565b60606004805461055390611845565b3360008181526001602090815260408083206001600160a01b038716845290915281205490919083811015610b7d5760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f7760448201527f207a65726f00000000000000000000000000000000000000000000000000000060648201526084016106b6565b6106078286868403610cbb565b3360009081527f09f04f5809d5be59813a33617d16f069caae874a6b34f03139f63d934daddae6602052604090205460ff16610bd95760405163f982dd0f60e01b815260040160405180910390fd5b6006805460ff19811660ff90911615179055565b6000336105e4818585610ea5565b600082815260056020526040902060010154610c1681611092565b6106378383611141565b3360009081527f09f04f5809d5be59813a33617d16f069caae874a6b34f03139f63d934daddae6602052604090205460ff16610c6f5760405163f982dd0f60e01b815260040160405180910390fd5b600654610100900460ff1615610acf576006805461ff0019169055604051600081527f4543baa938cb97f5073ec206ad35638cdb1f4db8f677d31579b2f6fe7d18c14a90602001610ac6565b6001600160a01b038316610d365760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460448201527f726573730000000000000000000000000000000000000000000000000000000060648201526084016106b6565b6001600160a01b038216610db25760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f20616464726560448201527f737300000000000000000000000000000000000000000000000000000000000060648201526084016106b6565b6001600160a01b0383811660008181526001602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b6001600160a01b038381166000908152600160209081526040808320938616835292905220546000198114610e9f5781811015610e925760405162461bcd60e51b815260206004820152601d60248201527f45524332303a20696e73756666696369656e7420616c6c6f77616e636500000060448201526064016106b6565b610e9f8484848403610cbb565b50505050565b6001600160a01b038316610f215760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f20616460448201527f647265737300000000000000000000000000000000000000000000000000000060648201526084016106b6565b6001600160a01b038216610f9d5760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201527f657373000000000000000000000000000000000000000000000000000000000060648201526084016106b6565b6001600160a01b0383166000908152602081905260409020548181101561102c5760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e742065786365656473206260448201527f616c616e6365000000000000000000000000000000000000000000000000000060648201526084016106b6565b6001600160a01b03848116600081815260208181526040808320878703905593871680835291849020805487019055925185815290927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a3610e9f565b61109c81336113ec565b50565b60008281526005602090815260408083206001600160a01b038516845290915290205460ff166106c95760008281526005602090815260408083206001600160a01b03851684529091529020805460ff191660011790556110fd3390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b60008281526005602090815260408083206001600160a01b038516845290915290205460ff16156106c95760008281526005602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b6001600160a01b03821661121a5760405162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f20616464726573730060448201526064016106b6565b806002600082825461122c9190611895565b90915550506001600160a01b038216600081815260208181526040808320805486019055518481527fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a35050565b6001600160a01b0382166112ff5760405162461bcd60e51b815260206004820152602160248201527f45524332303a206275726e2066726f6d20746865207a65726f2061646472657360448201527f730000000000000000000000000000000000000000000000000000000000000060648201526084016106b6565b6001600160a01b0382166000908152602081905260409020548181101561138e5760405162461bcd60e51b815260206004820152602260248201527f45524332303a206275726e20616d6f756e7420657863656564732062616c616e60448201527f636500000000000000000000000000000000000000000000000000000000000060648201526084016106b6565b6001600160a01b0383166000818152602081815260408083208686039055600280548790039055518581529192917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a3505050565b60008281526005602090815260408083206001600160a01b038516845290915290205460ff166106c95761141f81611461565b61142a836020611473565b60405160200161143b9291906118f3565b60408051601f198184030181529082905262461bcd60e51b82526106b6916004016116c9565b606061053e6001600160a01b03831660145b60606000611482836002611974565b61148d906002611895565b67ffffffffffffffff8111156114a5576114a5611993565b6040519080825280601f01601f1916602001820160405280156114cf576020820181803683370190505b5090507f300000000000000000000000000000000000000000000000000000000000000081600081518110611506576115066119a9565b60200101906001600160f81b031916908160001a9053507f780000000000000000000000000000000000000000000000000000000000000081600181518110611551576115516119a9565b60200101906001600160f81b031916908160001a9053506000611575846002611974565b611580906001611895565b90505b6001811115611605577f303132333435363738396162636465660000000000000000000000000000000085600f16601081106115c1576115c16119a9565b1a60f81b8282815181106115d7576115d76119a9565b60200101906001600160f81b031916908160001a90535060049490941c936115fe816119bf565b9050611583565b5083156116545760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e7460448201526064016106b6565b9392505050565b60006020828403121561166d57600080fd5b81357fffffffff000000000000000000000000000000000000000000000000000000008116811461165457600080fd5b60005b838110156116b85781810151838201526020016116a0565b83811115610e9f5750506000910152565b60208152600082518060208401526116e881604085016020870161169d565b601f01601f19169190910160400192915050565b80356001600160a01b038116811461171357600080fd5b919050565b6000806040838503121561172b57600080fd5b611734836116fc565b946020939093013593505050565b60008060006060848603121561175757600080fd5b611760846116fc565b925061176e602085016116fc565b9150604084013590509250925092565b60006020828403121561179057600080fd5b5035919050565b600080604083850312156117aa57600080fd5b823591506117ba602084016116fc565b90509250929050565b600080600080608085870312156117d957600080fd5b84359350602085013592506117f0604086016116fc565b9396929550929360600135925050565b60006020828403121561181257600080fd5b611654826116fc565b6000806040838503121561182e57600080fd5b611837836116fc565b91506117ba602084016116fc565b600181811c9082168061185957607f821691505b60208210810361187957634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052601160045260246000fd5b600082198211156118a8576118a861187f565b500190565b6000602082840312156118bf57600080fd5b8151801515811461165457600080fd5b600080604083850312156118e257600080fd5b505080516020909101519092909150565b7f416363657373436f6e74726f6c3a206163636f756e742000000000000000000081526000835161192b81601785016020880161169d565b7f206973206d697373696e6720726f6c6520000000000000000000000000000000601791840191820152835161196881602884016020880161169d565b01602801949350505050565b600081600019048311821515161561198e5761198e61187f565b500290565b634e487b7160e01b600052604160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b6000816119ce576119ce61187f565b50600019019056fea2646970667358221220377dc29c7758d279029b7843bb37ede1d47b477a9dc267012e34976bd6e853ed64736f6c634300080d0033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000c000000000000000000000000063349ba5e1f71252ecd56e8f950d1a518b400b600000000000000000000000009db42d3bda1525963db3b2372c4daabaf0491a53000000000000000000000000000000000000000000000000000000000000000c42726962652076654c594e58000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000076276654c594e5800000000000000000000000000000000000000000000000000
-----Decoded View---------------
Arg [0] : _name (string): Bribe veLYNX
Arg [1] : _symbol (string): bveLYNX
Arg [2] : _optionToken (address): 0x63349BA5E1F71252eCD56E8F950D1A518B400b60
Arg [3] : _admin (address): 0x9DB42D3BDA1525963db3B2372C4DAABaf0491A53
-----Encoded View---------------
8 Constructor Arguments found :
Arg [0] : 0000000000000000000000000000000000000000000000000000000000000080
Arg [1] : 00000000000000000000000000000000000000000000000000000000000000c0
Arg [2] : 00000000000000000000000063349ba5e1f71252ecd56e8f950d1a518b400b60
Arg [3] : 0000000000000000000000009db42d3bda1525963db3b2372c4daabaf0491a53
Arg [4] : 000000000000000000000000000000000000000000000000000000000000000c
Arg [5] : 42726962652076654c594e580000000000000000000000000000000000000000
Arg [6] : 0000000000000000000000000000000000000000000000000000000000000007
Arg [7] : 6276654c594e5800000000000000000000000000000000000000000000000000
Loading...
Loading
Loading...
Loading
Loading...
Loading
Net Worth in USD
$0.00
Net Worth in ETH
Multichain Portfolio | 35 Chains
| Chain | Token | Portfolio % | Price | Amount | Value |
|---|
Loading...
Loading
Loading...
Loading
Loading...
Loading
[ Download: CSV Export ]
[ 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.