Contract
0xfca313e2be55957AC628a6193A60D38aDC2da64E
12
Contract Overview
My Name Tag:
Not Available
TokenTracker:
[ Download CSV Export ]
Latest 25 internal transaction
[ Download CSV Export ]
Similar Match Source Code This contract matches the deployed ByteCode of the Source Code for Contract 0x0Dc96f38980144ebFfe745706DFeE92622dba829 The constructor portion of the code might be different and could alter the actual behaviour of the contract
Contract Name:
AtlanticStraddle
Compiler Version
v0.8.17+commit.8df45f5f
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.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: * * ``` * 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}: * * ``` * 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. */ 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 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 (last updated v4.7.0) (security/Pausable.sol) pragma solidity ^0.8.0; import "../utils/Context.sol"; /** * @dev Contract module which allows children to implement an emergency stop * mechanism that can be triggered by an authorized account. * * This module is used through inheritance. It will make available the * modifiers `whenNotPaused` and `whenPaused`, which can be applied to * the functions of your contract. Note that they will not be pausable by * simply including this module, only once the modifiers are put in place. */ abstract contract Pausable is Context { /** * @dev Emitted when the pause is triggered by `account`. */ event Paused(address account); /** * @dev Emitted when the pause is lifted by `account`. */ event Unpaused(address account); bool private _paused; /** * @dev Initializes the contract in unpaused state. */ constructor() { _paused = false; } /** * @dev Modifier to make a function callable only when the contract is not paused. * * Requirements: * * - The contract must not be paused. */ modifier whenNotPaused() { _requireNotPaused(); _; } /** * @dev Modifier to make a function callable only when the contract is paused. * * Requirements: * * - The contract must be paused. */ modifier whenPaused() { _requirePaused(); _; } /** * @dev Returns true if the contract is paused, and false otherwise. */ function paused() public view virtual returns (bool) { return _paused; } /** * @dev Throws if the contract is paused. */ function _requireNotPaused() internal view virtual { require(!paused(), "Pausable: paused"); } /** * @dev Throws if the contract is not paused. */ function _requirePaused() internal view virtual { require(paused(), "Pausable: not paused"); } /** * @dev Triggers stopped state. * * Requirements: * * - The contract must not be paused. */ function _pause() internal virtual whenNotPaused { _paused = true; emit Paused(_msgSender()); } /** * @dev Returns to normal state. * * Requirements: * * - The contract must be paused. */ function _unpause() internal virtual whenPaused { _paused = false; emit Unpaused(_msgSender()); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (security/ReentrancyGuard.sol) pragma solidity ^0.8.0; /** * @dev Contract module that helps prevent reentrant calls to a function. * * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier * available, which can be applied to functions to make sure there are no nested * (reentrant) calls to them. * * Note that because there is a single `nonReentrant` guard, functions marked as * `nonReentrant` may not call one another. This can be worked around by making * those functions `private`, and then adding `external` `nonReentrant` entry * points to them. * * TIP: If you would like to learn more about reentrancy and alternative ways * to protect against it, check out our blog post * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul]. */ abstract contract ReentrancyGuard { // Booleans are more expensive than uint256 or any type that takes up a full // word because each write operation emits an extra SLOAD to first read the // slot's contents, replace the bits taken up by the boolean, and then write // back. This is the compiler's defense against contract upgrades and // pointer aliasing, and it cannot be disabled. // The values being non-zero value makes deployment a bit more expensive, // but in exchange the refund on every call to nonReentrant will be lower in // amount. Since refunds are capped to a percentage of the total // transaction's gas, it is best to keep them low in cases like this one, to // increase the likelihood of the full refund coming into effect. uint256 private constant _NOT_ENTERED = 1; uint256 private constant _ENTERED = 2; uint256 private _status; constructor() { _status = _NOT_ENTERED; } /** * @dev Prevents a contract from calling itself, directly or indirectly. * Calling a `nonReentrant` function from another `nonReentrant` * function is not supported. It is possible to prevent this from happening * by making the `nonReentrant` function external, and making it call a * `private` function that does the actual work. */ modifier nonReentrant() { _nonReentrantBefore(); _; _nonReentrantAfter(); } function _nonReentrantBefore() private { // On the first call to nonReentrant, _status will be _NOT_ENTERED require(_status != _ENTERED, "ReentrancyGuard: reentrant call"); // Any calls to nonReentrant after this point will fail _status = _ENTERED; } function _nonReentrantAfter() private { // By storing the original value once again, a refund is triggered (see // https://eips.ethereum.org/EIPS/eip-2200) _status = _NOT_ENTERED; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.6.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 v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612]. * * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't * need to send a transaction, and thus is not required to hold Ether at all. */ interface IERC20Permit { /** * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens, * given ``owner``'s signed approval. * * IMPORTANT: The same issues {IERC20-approve} has related to transaction * ordering also apply here. * * Emits an {Approval} event. * * Requirements: * * - `spender` cannot be the zero address. * - `deadline` must be a timestamp in the future. * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner` * over the EIP712-formatted function arguments. * - the signature must use ``owner``'s current nonce (see {nonces}). * * For more information on the signature format, see the * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP * section]. */ function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external; /** * @dev Returns the current nonce for `owner`. This value must be * included whenever a signature is generated for {permit}. * * Every successful call to {permit} increases ``owner``'s nonce by one. This * prevents a signature from being used multiple times. */ function nonces(address owner) external view returns (uint256); /** * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}. */ // solhint-disable-next-line func-name-mixedcase function DOMAIN_SEPARATOR() external view returns (bytes32); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/utils/SafeERC20.sol) pragma solidity ^0.8.0; import "../IERC20.sol"; import "../extensions/draft-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; function safeTransfer( IERC20 token, address to, uint256 value ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom( IERC20 token, address from, address to, uint256 value ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } /** * @dev Deprecated. This function has issues similar to the ones found in * {IERC20-approve}, and its usage is discouraged. * * Whenever possible, use {safeIncreaseAllowance} and * {safeDecreaseAllowance} instead. */ function safeApprove( IERC20 token, address spender, uint256 value ) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' require( (value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function safeIncreaseAllowance( IERC20 token, address spender, uint256 value ) internal { uint256 newAllowance = token.allowance(address(this), spender) + value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function safeDecreaseAllowance( IERC20 token, address spender, uint256 value ) internal { unchecked { uint256 oldAllowance = token.allowance(address(this), spender); require(oldAllowance >= value, "SafeERC20: decreased allowance below zero"); uint256 newAllowance = oldAllowance - value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } } 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"); if (returndata.length > 0) { // Return data is optional require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (token/ERC721/ERC721.sol) pragma solidity ^0.8.0; import "./IERC721.sol"; import "./IERC721Receiver.sol"; import "./extensions/IERC721Metadata.sol"; import "../../utils/Address.sol"; import "../../utils/Context.sol"; import "../../utils/Strings.sol"; import "../../utils/introspection/ERC165.sol"; /** * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including * the Metadata extension, but not including the Enumerable extension, which is available separately as * {ERC721Enumerable}. */ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata { using Address for address; using Strings for uint256; // Token name string private _name; // Token symbol string private _symbol; // Mapping from token ID to owner address mapping(uint256 => address) private _owners; // Mapping owner address to token count mapping(address => uint256) private _balances; // Mapping from token ID to approved address mapping(uint256 => address) private _tokenApprovals; // Mapping from owner to operator approvals mapping(address => mapping(address => bool)) private _operatorApprovals; /** * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC721).interfaceId || interfaceId == type(IERC721Metadata).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721-balanceOf}. */ function balanceOf(address owner) public view virtual override returns (uint256) { require(owner != address(0), "ERC721: address zero is not a valid owner"); return _balances[owner]; } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view virtual override returns (address) { address owner = _ownerOf(tokenId); require(owner != address(0), "ERC721: invalid token ID"); return owner; } /** * @dev See {IERC721Metadata-name}. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev See {IERC721Metadata-symbol}. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { _requireMinted(tokenId); string memory baseURI = _baseURI(); return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : ""; } /** * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each * token will be the concatenation of the `baseURI` and the `tokenId`. Empty * by default, can be overridden in child contracts. */ function _baseURI() internal view virtual returns (string memory) { return ""; } /** * @dev See {IERC721-approve}. */ function approve(address to, uint256 tokenId) public virtual override { address owner = ERC721.ownerOf(tokenId); require(to != owner, "ERC721: approval to current owner"); require( _msgSender() == owner || isApprovedForAll(owner, _msgSender()), "ERC721: approve caller is not token owner or approved for all" ); _approve(to, tokenId); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view virtual override returns (address) { _requireMinted(tokenId); return _tokenApprovals[tokenId]; } /** * @dev See {IERC721-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual override { _setApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC721-isApprovedForAll}. */ function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { return _operatorApprovals[owner][operator]; } /** * @dev See {IERC721-transferFrom}. */ function transferFrom( address from, address to, uint256 tokenId ) public virtual override { //solhint-disable-next-line max-line-length require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: caller is not token owner or approved"); _transfer(from, to, tokenId); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId ) public virtual override { safeTransferFrom(from, to, tokenId, ""); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes memory data ) public virtual override { require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: caller is not token owner or approved"); _safeTransfer(from, to, tokenId, data); } /** * @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. * * `data` is additional data, it has no specified format and it is sent in call to `to`. * * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g. * implement alternative mechanisms to perform token transfer, such as signature-based. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeTransfer( address from, address to, uint256 tokenId, bytes memory data ) internal virtual { _transfer(from, to, tokenId); require(_checkOnERC721Received(from, to, tokenId, data), "ERC721: transfer to non ERC721Receiver implementer"); } /** * @dev Returns the owner of the `tokenId`. Does NOT revert if token doesn't exist */ function _ownerOf(uint256 tokenId) internal view virtual returns (address) { return _owners[tokenId]; } /** * @dev Returns whether `tokenId` exists. * * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}. * * Tokens start existing when they are minted (`_mint`), * and stop existing when they are burned (`_burn`). */ function _exists(uint256 tokenId) internal view virtual returns (bool) { return _ownerOf(tokenId) != address(0); } /** * @dev Returns whether `spender` is allowed to manage `tokenId`. * * Requirements: * * - `tokenId` must exist. */ function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) { address owner = ERC721.ownerOf(tokenId); return (spender == owner || isApprovedForAll(owner, spender) || getApproved(tokenId) == spender); } /** * @dev Safely mints `tokenId` and transfers it to `to`. * * Requirements: * * - `tokenId` must not exist. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeMint(address to, uint256 tokenId) internal virtual { _safeMint(to, tokenId, ""); } /** * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is * forwarded in {IERC721Receiver-onERC721Received} to contract recipients. */ function _safeMint( address to, uint256 tokenId, bytes memory data ) internal virtual { _mint(to, tokenId); require( _checkOnERC721Received(address(0), to, tokenId, data), "ERC721: transfer to non ERC721Receiver implementer" ); } /** * @dev Mints `tokenId` and transfers it to `to`. * * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible * * Requirements: * * - `tokenId` must not exist. * - `to` cannot be the zero address. * * Emits a {Transfer} event. */ function _mint(address to, uint256 tokenId) internal virtual { require(to != address(0), "ERC721: mint to the zero address"); require(!_exists(tokenId), "ERC721: token already minted"); _beforeTokenTransfer(address(0), to, tokenId, 1); // Check that tokenId was not minted by `_beforeTokenTransfer` hook require(!_exists(tokenId), "ERC721: token already minted"); unchecked { // Will not overflow unless all 2**256 token ids are minted to the same owner. // Given that tokens are minted one by one, it is impossible in practice that // this ever happens. Might change if we allow batch minting. // The ERC fails to describe this case. _balances[to] += 1; } _owners[tokenId] = to; emit Transfer(address(0), to, tokenId); _afterTokenTransfer(address(0), to, tokenId, 1); } /** * @dev Destroys `tokenId`. * The approval is cleared when the token is burned. * This is an internal function that does not check if the sender is authorized to operate on the token. * * Requirements: * * - `tokenId` must exist. * * Emits a {Transfer} event. */ function _burn(uint256 tokenId) internal virtual { address owner = ERC721.ownerOf(tokenId); _beforeTokenTransfer(owner, address(0), tokenId, 1); // Update ownership in case tokenId was transferred by `_beforeTokenTransfer` hook owner = ERC721.ownerOf(tokenId); // Clear approvals delete _tokenApprovals[tokenId]; unchecked { // Cannot overflow, as that would require more tokens to be burned/transferred // out than the owner initially received through minting and transferring in. _balances[owner] -= 1; } delete _owners[tokenId]; emit Transfer(owner, address(0), tokenId); _afterTokenTransfer(owner, address(0), tokenId, 1); } /** * @dev Transfers `tokenId` from `from` to `to`. * As opposed to {transferFrom}, this imposes no restrictions on msg.sender. * * Requirements: * * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * * Emits a {Transfer} event. */ function _transfer( address from, address to, uint256 tokenId ) internal virtual { require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer from incorrect owner"); require(to != address(0), "ERC721: transfer to the zero address"); _beforeTokenTransfer(from, to, tokenId, 1); // Check that tokenId was not transferred by `_beforeTokenTransfer` hook require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer from incorrect owner"); // Clear approvals from the previous owner delete _tokenApprovals[tokenId]; unchecked { // `_balances[from]` cannot overflow for the same reason as described in `_burn`: // `from`'s balance is the number of token held, which is at least one before the current // transfer. // `_balances[to]` could overflow in the conditions described in `_mint`. That would require // all 2**256 token ids to be minted, which in practice is impossible. _balances[from] -= 1; _balances[to] += 1; } _owners[tokenId] = to; emit Transfer(from, to, tokenId); _afterTokenTransfer(from, to, tokenId, 1); } /** * @dev Approve `to` to operate on `tokenId` * * Emits an {Approval} event. */ function _approve(address to, uint256 tokenId) internal virtual { _tokenApprovals[tokenId] = to; emit Approval(ERC721.ownerOf(tokenId), to, tokenId); } /** * @dev Approve `operator` to operate on all of `owner` tokens * * Emits an {ApprovalForAll} event. */ function _setApprovalForAll( address owner, address operator, bool approved ) internal virtual { require(owner != operator, "ERC721: approve to caller"); _operatorApprovals[owner][operator] = approved; emit ApprovalForAll(owner, operator, approved); } /** * @dev Reverts if the `tokenId` has not been minted yet. */ function _requireMinted(uint256 tokenId) internal view virtual { require(_exists(tokenId), "ERC721: invalid token ID"); } /** * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address. * The call is not executed if the target address is not a contract. * * @param from address representing the previous owner of the given token ID * @param to target address that will receive the tokens * @param tokenId uint256 ID of the token to be transferred * @param data bytes optional data to send along with the call * @return bool whether the call correctly returned the expected magic value */ function _checkOnERC721Received( address from, address to, uint256 tokenId, bytes memory data ) private returns (bool) { if (to.isContract()) { try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, data) returns (bytes4 retval) { return retval == IERC721Receiver.onERC721Received.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert("ERC721: transfer to non ERC721Receiver implementer"); } else { /// @solidity memory-safe-assembly assembly { revert(add(32, reason), mload(reason)) } } } } else { return true; } } /** * @dev Hook that is called before any token transfer. This includes minting and burning. If {ERC721Consecutive} is * used, the hook may be called as part of a consecutive (batch) mint, as indicated by `batchSize` greater than 1. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s tokens will be transferred to `to`. * - When `from` is zero, the tokens will be minted for `to`. * - When `to` is zero, ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * - `batchSize` is non-zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256, /* firstTokenId */ uint256 batchSize ) internal virtual { if (batchSize > 1) { if (from != address(0)) { _balances[from] -= batchSize; } if (to != address(0)) { _balances[to] += batchSize; } } } /** * @dev Hook that is called after any token transfer. This includes minting and burning. If {ERC721Consecutive} is * used, the hook may be called as part of a consecutive (batch) mint, as indicated by `batchSize` greater than 1. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s tokens were transferred to `to`. * - When `from` is zero, the tokens were minted for `to`. * - When `to` is zero, ``from``'s tokens were burned. * - `from` and `to` are never both zero. * - `batchSize` is non-zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _afterTokenTransfer( address from, address to, uint256 firstTokenId, uint256 batchSize ) internal virtual {} }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.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.6.0) (token/ERC721/IERC721Receiver.sol) pragma solidity ^0.8.0; /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ interface IERC721Receiver { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. * * The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`. */ function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (token/ERC721/extensions/ERC721Enumerable.sol) pragma solidity ^0.8.0; import "../ERC721.sol"; import "./IERC721Enumerable.sol"; /** * @dev This implements an optional extension of {ERC721} defined in the EIP that adds * enumerability of all the token ids in the contract as well as all token ids owned by each * account. */ abstract contract ERC721Enumerable is ERC721, IERC721Enumerable { // Mapping from owner to list of owned token IDs mapping(address => mapping(uint256 => uint256)) private _ownedTokens; // Mapping from token ID to index of the owner tokens list mapping(uint256 => uint256) private _ownedTokensIndex; // Array with all token ids, used for enumeration uint256[] private _allTokens; // Mapping from token id to position in the allTokens array mapping(uint256 => uint256) private _allTokensIndex; /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC721) returns (bool) { return interfaceId == type(IERC721Enumerable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}. */ function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256) { require(index < ERC721.balanceOf(owner), "ERC721Enumerable: owner index out of bounds"); return _ownedTokens[owner][index]; } /** * @dev See {IERC721Enumerable-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _allTokens.length; } /** * @dev See {IERC721Enumerable-tokenByIndex}. */ function tokenByIndex(uint256 index) public view virtual override returns (uint256) { require(index < ERC721Enumerable.totalSupply(), "ERC721Enumerable: global index out of bounds"); return _allTokens[index]; } /** * @dev See {ERC721-_beforeTokenTransfer}. */ function _beforeTokenTransfer( address from, address to, uint256 firstTokenId, uint256 batchSize ) internal virtual override { super._beforeTokenTransfer(from, to, firstTokenId, batchSize); if (batchSize > 1) { // Will only trigger during construction. Batch transferring (minting) is not available afterwards. revert("ERC721Enumerable: consecutive transfers not supported"); } uint256 tokenId = firstTokenId; if (from == address(0)) { _addTokenToAllTokensEnumeration(tokenId); } else if (from != to) { _removeTokenFromOwnerEnumeration(from, tokenId); } if (to == address(0)) { _removeTokenFromAllTokensEnumeration(tokenId); } else if (to != from) { _addTokenToOwnerEnumeration(to, tokenId); } } /** * @dev Private function to add a token to this extension's ownership-tracking data structures. * @param to address representing the new owner of the given token ID * @param tokenId uint256 ID of the token to be added to the tokens list of the given address */ function _addTokenToOwnerEnumeration(address to, uint256 tokenId) private { uint256 length = ERC721.balanceOf(to); _ownedTokens[to][length] = tokenId; _ownedTokensIndex[tokenId] = length; } /** * @dev Private function to add a token to this extension's token tracking data structures. * @param tokenId uint256 ID of the token to be added to the tokens list */ function _addTokenToAllTokensEnumeration(uint256 tokenId) private { _allTokensIndex[tokenId] = _allTokens.length; _allTokens.push(tokenId); } /** * @dev Private function to remove a token from this extension's ownership-tracking data structures. Note that * while the token is not assigned a new owner, the `_ownedTokensIndex` mapping is _not_ updated: this allows for * gas optimizations e.g. when performing a transfer operation (avoiding double writes). * This has O(1) time complexity, but alters the order of the _ownedTokens array. * @param from address representing the previous owner of the given token ID * @param tokenId uint256 ID of the token to be removed from the tokens list of the given address */ function _removeTokenFromOwnerEnumeration(address from, uint256 tokenId) private { // To prevent a gap in from's tokens array, we store the last token in the index of the token to delete, and // then delete the last slot (swap and pop). uint256 lastTokenIndex = ERC721.balanceOf(from) - 1; uint256 tokenIndex = _ownedTokensIndex[tokenId]; // When the token to delete is the last token, the swap operation is unnecessary if (tokenIndex != lastTokenIndex) { uint256 lastTokenId = _ownedTokens[from][lastTokenIndex]; _ownedTokens[from][tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token _ownedTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index } // This also deletes the contents at the last position of the array delete _ownedTokensIndex[tokenId]; delete _ownedTokens[from][lastTokenIndex]; } /** * @dev Private function to remove a token from this extension's token tracking data structures. * This has O(1) time complexity, but alters the order of the _allTokens array. * @param tokenId uint256 ID of the token to be removed from the tokens list */ function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private { // To prevent a gap in the tokens array, we store the last token in the index of the token to delete, and // then delete the last slot (swap and pop). uint256 lastTokenIndex = _allTokens.length - 1; uint256 tokenIndex = _allTokensIndex[tokenId]; // When the token to delete is the last token, the swap operation is unnecessary. However, since this occurs so // rarely (when the last minted token is burnt) that we still do the swap here to avoid the gas cost of adding // an 'if' statement (like in _removeTokenFromOwnerEnumeration) uint256 lastTokenId = _allTokens[lastTokenIndex]; _allTokens[tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token _allTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index // This also deletes the contents at the last position of the array delete _allTokensIndex[tokenId]; _allTokens.pop(); } }
// 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 v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol) pragma solidity ^0.8.0; import "../IERC721.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Metadata is IERC721 { /** * @dev Returns the token collection name. */ function name() external view returns (string memory); /** * @dev Returns the token collection symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) external view returns (string memory); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.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 * ==== * * [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://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract. * * _Available since v4.8._ */ function verifyCallResultFromTarget( address target, bool success, bytes memory returndata, string memory errorMessage ) internal view returns (bytes memory) { if (success) { if (returndata.length == 0) { // only check isContract if the call was successful and the return data is empty // otherwise we already know that it was a contract require(isContract(target), "Address: call to non-contract"); } return returndata; } else { _revert(returndata, errorMessage); } } /** * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason or using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { _revert(returndata, errorMessage); } } function _revert(bytes memory returndata, string memory errorMessage) private pure { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly /// @solidity memory-safe-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Counters.sol) pragma solidity ^0.8.0; /** * @title Counters * @author Matt Condon (@shrugs) * @dev Provides counters that can only be incremented, decremented or reset. This can be used e.g. to track the number * of elements in a mapping, issuing ERC721 ids, or counting request ids. * * Include with `using Counters for Counters.Counter;` */ library Counters { struct Counter { // This variable should never be directly accessed by users of the library: interactions must be restricted to // the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add // this feature: see https://github.com/ethereum/solidity/issues/4637 uint256 _value; // default: 0 } function current(Counter storage counter) internal view returns (uint256) { return counter._value; } function increment(Counter storage counter) internal { unchecked { counter._value += 1; } } function decrement(Counter storage counter) internal { uint256 value = counter._value; require(value > 0, "Counter: decrement overflow"); unchecked { counter._value = value - 1; } } function reset(Counter storage counter) internal { counter._value = 0; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/Strings.sol) pragma solidity ^0.8.0; import "./math/Math.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 `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); } }
// 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.8.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) { return prod0 / denominator; } // Make sure the result is less than 2^256. Also prevents denominator == 0. require(denominator > prod1); /////////////////////////////////////////////// // 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 10, 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 * 8) < value ? 1 : 0); } } }
//SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.7; // Libraries import {Counters} from "@openzeppelin/contracts/utils/Counters.sol"; import {ERC721} from "@openzeppelin/contracts/token/ERC721/ERC721.sol"; import {ERC721Enumerable} from "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol"; import {Math} from "@openzeppelin/contracts/utils/math/Math.sol"; import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; // Contracts import {AccessControl} from "@openzeppelin/contracts/access/AccessControl.sol"; import {ReentrancyGuard} from "@openzeppelin/contracts/security/ReentrancyGuard.sol"; import {Pausable} from "@openzeppelin/contracts/security/Pausable.sol"; import {ContractWhitelist} from "./helpers/ContractWhitelist.sol"; import {IAssetSwapper} from "./asset-swapper/IAssetSwapper.sol"; // Interfaces import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import {IOptionPricing} from "./interface/IOptionPricing.sol"; import {IPriceOracle} from "./interface/IPriceOracle.sol"; import {IVolatilityOracle} from "./interface/IVolatilityOracle.sol"; /// @title Atlantic Straddles /// @author Dopex /// @notice - Accept stable deposits /// - Deposits during an epoch will be for the next epoch /// - Stables are used as collateral to sell ATM put options for the underlying /// - n day epochs, deposits auto-rollover unless deactivated /// - Withdrawal considers performance of pool since deposit /// - On purchase of an Atlantic straddle, use 50% of the collateral locked in the PUT to purchase underlying asset /// - At expiry, settle by selling purchased underlying asset to return AP collateral contract AtlanticStraddle is ReentrancyGuard, ERC721, ERC721Enumerable, AccessControl, Pausable, ContractWhitelist { using SafeERC20 for IERC20; using Counters for Counters.Counter; /// @dev Token ID counter for write positions Counters.Counter private _tokenIdCounter; /// @dev Current epoch. 0-indexed uint256 public currentEpoch; /// @dev Managar Role bytes32 public constant MANAGER_ROLE = keccak256("MANAGER_ROLE"); /// @dev Contract addresses Addresses public addresses; /// @dev Total deposits for epoch (epoch => EpochData) mapping(uint256 => EpochData) public epochData; /// @dev Data for premium and funding collections for an epoch (epoch => EpochCollectionsData) mapping(uint256 => EpochCollectionsData) public epochCollectionsData; /// @dev Is vault ready for the epoch i.e can purchases begin (epoch => isVaultReady) mapping(uint256 => bool) public isVaultReady; /// @dev Toggled to true after an epoch has been marked pre-expired (epoch => isEpochPreExpired) mapping(uint256 => bool) public isEpochPreExpired; /// @dev Toggled to true after an epoch has been marked expired (epoch => isEpochExpired) mapping(uint256 => bool) public isEpochExpired; /// @dev Write positions (tokenId => WritePosition) mapping(uint256 => WritePosition) public writePositions; /// @dev Straddle positions (tokenId => StraddlePosition) mapping(uint256 => StraddlePosition) public straddlePositions; /// @dev Percentage precision uint256 public constant PERCENT_PRECISION = 1e6; /// @dev USDC decimals uint256 public constant USDC_DECIMALS = 1e6; /// @dev Min purchase 0.01 to prevent spam uint256 public constant MIN_PURCHASE_AMOUNT = 1e16; /// @dev Min deposit amount 1 usd to prevent spam uint256 public constant MIN_DEPOSIT_AMOUNT = USDC_DECIMALS; /// @dev Seconds a year uint256 internal constant SECONDS_A_YEAR = 365 days; /// @dev Purchase fee percent uint256 public purchaseFeePercent = 15e4; /// @dev Delegation fee uint256 public maxDelegationFee = USDC_DECIMALS; /// @dev Settlement fee percent uint256 public settlementFeePercent = 1e5; /// @dev AP funding percent uint256 public apFundingPercent = 36 * PERCENT_PRECISION; /// @dev Fee percent charged to owner, default to 0.1% uint256 public delegationFeePercent = PERCENT_PRECISION / 10; /// @dev Purchase time limit variable to prevent last min buyouts uint256 public blackoutPeriodBeforeExpiry = 4 hours; /// @dev PnL slippage percent uint256 public pnlSlippagePercent = 5e5; /// @dev The decimal precision for amount of options * strike price (or price) uint256 internal constant AMOUNT_PRICE_TO_USDC_DECIMALS = (1e18 * 1e8) / 1e6; struct Addresses { // USDC token (1e6 precision) address usd; // Underlying token address underlying; // Asset Swapper address assetSwapper; // Price Oracle address priceOracle; // Volatility Oracle address volatilityOracle; // Option Pricing address optionPricing; // Fee Distributor address feeDistributor; } struct EpochData { // Start time uint256 startTime; // Expiry time uint256 expiry; // Total USD deposits uint256 usdDeposits; // Active USD deposits (used for writing) uint256 activeUsdDeposits; // Settlement Price uint256 settlementPrice; // Percentage of total settlement executed uint256 settlementPercentage; // Amount of underlying assets purchased uint256 underlyingPurchased; } struct EpochCollectionsData { // Total premiums collected for USD deposits uint256 usdPremiums; // Total funding collected for USD deposits uint256 usdFunding; // Total amount of straddles sold uint256 totalSold; // Number of "live" straddles per epoch uint256 straddleCounter; // Final usd balance before withdraw uint256 finalUsdBalanceBeforeWithdaw; } struct WritePosition { // Epoch # uint256 epoch; // USD deposits uint256 usdDeposit; // Whether deposit should be rolled over to the next epoch bool rollover; } struct StraddlePosition { // Epoch # uint256 epoch; // Amount uint256 amount; // AP Strike uint256 apStrike; // Underlying purchased for this straddle uint256 underlyingPurchased; } event Bootstrap(uint256 epoch); event Deposit( uint256 epoch, uint256 amount, bool rollover, address user, address sender, uint256 tokenId ); event Purchase( uint256 epoch, address user, uint256 straddleId, uint256 cost ); event Settle( uint256 epoch, address indexed sender, address indexed owner, uint256 id, uint256 pnl ); event Withdraw( uint256 epoch, address indexed sender, uint256 id, uint256 pnl ); event ToggleRollover(uint256 id, bool rollover); event EpochExpired(address caller); event EpochPreExpired(address caller); event SetAddresses(Addresses addresses); event SetBlackoutPeriod(uint256 period); event SetApFunding(uint256 apFunding); event SetPnlSlippagePercent(uint256 pnlSlippagePercent); event SetFees( uint256 purchaseFeePercent, uint256 settlementFeePercent, uint256 delegationFeePercent, uint256 maxDelegationFee ); event SetAssetSwapperAllowance(address token, uint256 value, bool increase); /*==== CONSTRUCTOR ====*/ constructor( string memory _name, string memory _symbol, Addresses memory _addresses ) ERC721(_name, _symbol) { addresses = _addresses; _setupRole(DEFAULT_ADMIN_ROLE, msg.sender); _setupRole(MANAGER_ROLE, msg.sender); } /*==== USER METHODS ====*/ /// @dev Deposit for next epoch /// @param amount Amount to deposit /// @param shouldRollover Should the deposit be rolled over /// @param user User address /// @return tokenId Write position token ID function deposit( uint256 amount, bool shouldRollover, address user ) external whenNotPaused nonReentrant returns (uint256 tokenId) { _isEligibleSender(); require(amount > MIN_DEPOSIT_AMOUNT, "Invalid amount"); uint256 nextEpoch = currentEpoch + 1; epochData[nextEpoch].usdDeposits += amount; epochCollectionsData[nextEpoch].finalUsdBalanceBeforeWithdaw += amount; tokenId = _mintPositionToken(user); writePositions[tokenId] = WritePosition({ epoch: nextEpoch, usdDeposit: amount, rollover: shouldRollover }); IERC20(addresses.usd).safeTransferFrom( msg.sender, address(this), amount ); emit Deposit( nextEpoch, amount, shouldRollover, user, msg.sender, tokenId ); } /// @dev Rolls over a deposit to the next epoch. Anyone can call this for write positions with `rollover` enabled /// Call this prior to bootstrapping to a new epoch or it will roll over to epoch n + 2 /// @param id Write position token ID /// @return tokenId Rolled over write position token ID function rollover(uint256 id) public whenNotPaused nonReentrant returns (uint256 tokenId) { _isEligibleSender(); WritePosition memory writePos = writePositions[id]; require(writePos.rollover, "Rollover not authorized"); require(writePos.epoch != 0, "Invalid write position"); require(isEpochExpired[writePos.epoch], "Epoch has not expired"); uint256 depositPlusPnl = calculateWritePositionPnl(id); address user = ownerOf(id); _burn(id); require(depositPlusPnl != 0, "Write position pnl is 0"); uint256 delegationFee; // If the owner of the position is not the sender, collect rollover delegation fees if (user != msg.sender) { delegationFee = (depositPlusPnl * delegationFeePercent) / (PERCENT_PRECISION * 100); delegationFee = Math.min(delegationFee, maxDelegationFee); } depositPlusPnl -= delegationFee; emit Withdraw(writePos.epoch, user, id, depositPlusPnl); uint256 nextEpoch = currentEpoch + 1; epochData[nextEpoch].usdDeposits += depositPlusPnl; epochCollectionsData[nextEpoch] .finalUsdBalanceBeforeWithdaw += depositPlusPnl; tokenId = _mintPositionToken(user); writePositions[tokenId] = WritePosition({ epoch: nextEpoch, usdDeposit: depositPlusPnl, rollover: true }); IERC20(addresses.usd).safeTransfer(msg.sender, delegationFee); emit Deposit(nextEpoch, depositPlusPnl, true, user, user, tokenId); } /// @dev Rollover for multiple ids /// @param ids Write position token IDs /// @return tokenIds Rolled over write position token IDs function multirollover(uint256[] memory ids) external returns (uint256[] memory tokenIds) { uint256 idsLength = ids.length; tokenIds = new uint256[](idsLength); for (uint256 i; i < idsLength; ) { tokenIds[i] = rollover(ids[i]); unchecked { ++i; } } } /// @dev Toggle rollover for a write position /// @param id Write position token ID function toggleRollover(uint256 id) external whenNotPaused nonReentrant { _isEligibleSender(); require(ownerOf(id) == msg.sender, "Invalid owner"); require(writePositions[id].epoch != 0, "Invalid position"); writePositions[id].rollover = !writePositions[id].rollover; emit ToggleRollover(id, writePositions[id].rollover); } /// @dev Withdraw write positions after strikes are settled /// @param id ID of write position /// @return writePositionPnl of write position function withdraw(uint256 id) external whenNotPaused nonReentrant returns (uint256 writePositionPnl) { _isEligibleSender(); require(ownerOf(id) == msg.sender, "Invalid owner"); WritePosition memory writePos = writePositions[id]; require(writePos.epoch != 0, "Invalid write position"); require(isEpochExpired[writePos.epoch], "Settlements not done"); writePositionPnl = calculateWritePositionPnl(id); _burn(id); require(writePositionPnl != 0, "Write position pnl is 0"); IERC20(addresses.usd).safeTransfer(msg.sender, writePositionPnl); emit Withdraw(writePos.epoch, msg.sender, id, writePositionPnl); } /// @dev Purchase a straddle /// @param amount Approx. amount of straddles to purchase (10 ** 18) /// @param swapperId Swapper ID of the swap method to use /// @param minAmountOut Min amount out for the underlying purchased /// @param user Address to purchase straddles for /// @return tokenId Straddle position token ID function purchase( uint256 amount, uint256 minAmountOut, uint256 swapperId, address user ) external whenNotPaused nonReentrant returns ( uint256 tokenId, uint256 protocolFee, uint256 straddleCost ) { _isEligibleSender(); require(currentEpoch > 0, "Invalid epoch"); require(amount > MIN_PURCHASE_AMOUNT, "Invalid amount"); require( block.timestamp < epochData[currentEpoch].expiry - blackoutPeriodBeforeExpiry, "Cannot purchase during blackout period" ); uint256 currentPrice = getUnderlyingPrice(); uint256 timeToExpiry = epochData[currentEpoch].expiry - block.timestamp; require( epochData[currentEpoch].usdDeposits - (epochData[currentEpoch].activeUsdDeposits / AMOUNT_PRICE_TO_USDC_DECIMALS) >= (currentPrice * amount) / AMOUNT_PRICE_TO_USDC_DECIMALS, "Not enough AP liquidity available" ); // Swap half of AP to underlying uint256 underlyingPurchased = _swapToUnderlying( ((currentPrice * amount) / 2) / AMOUNT_PRICE_TO_USDC_DECIMALS, minAmountOut, swapperId ); epochCollectionsData[currentEpoch].finalUsdBalanceBeforeWithdaw -= ((currentPrice * amount) / 2) / AMOUNT_PRICE_TO_USDC_DECIMALS; uint256 swapPrice = (currentPrice * amount) / (underlyingPurchased * 2); epochData[currentEpoch].underlyingPurchased += underlyingPurchased; // Deposits epochData[currentEpoch].activeUsdDeposits += swapPrice * (underlyingPurchased * 2); uint256 apPremium = calculatePremium( true, swapPrice, swapPrice, underlyingPurchased * 2, epochData[currentEpoch].expiry ); uint256 apFunding = calculateApFunding( swapPrice, underlyingPurchased * 2, timeToExpiry ); // Collections epochCollectionsData[currentEpoch].usdPremiums += apPremium; epochCollectionsData[currentEpoch].usdFunding += apFunding; epochCollectionsData[currentEpoch].totalSold += underlyingPurchased * 2; epochCollectionsData[currentEpoch].straddleCounter += 1; // Mint straddle position token tokenId = _mintPositionToken(user); straddlePositions[tokenId] = StraddlePosition({ epoch: currentEpoch, amount: underlyingPurchased * 2, apStrike: swapPrice, underlyingPurchased: underlyingPurchased }); protocolFee = (amount * currentPrice * purchaseFeePercent) / (PERCENT_PRECISION * AMOUNT_PRICE_TO_USDC_DECIMALS * 100); straddleCost = ((apPremium + apFunding) / AMOUNT_PRICE_TO_USDC_DECIMALS); IERC20(addresses.usd).safeTransferFrom( msg.sender, address(this), straddleCost + protocolFee ); IERC20(addresses.usd).safeTransfer( addresses.feeDistributor, protocolFee ); epochCollectionsData[currentEpoch] .finalUsdBalanceBeforeWithdaw += ((apPremium + apFunding) / AMOUNT_PRICE_TO_USDC_DECIMALS); emit Purchase(currentEpoch, user, tokenId, apPremium + apFunding); } /// @dev Settles a purchased option /// @param id ID of straddle position function settle(uint256 id) public whenNotPaused nonReentrant returns (uint256) { _isEligibleSender(); StraddlePosition memory sp = straddlePositions[id]; require(sp.epoch != 0, "Invalid straddle position"); require(isEpochPreExpired[sp.epoch], "Epoch has not pre-expired"); uint256 buyerPnl = calculateStraddlePositionPnl(id); address owner = ownerOf(id); _burn(id); require(buyerPnl != 0, "buyerPnl cannot be 0"); uint256 protocolFee = (buyerPnl * settlementFeePercent) / (PERCENT_PRECISION * 100); uint256 delegationFee; // If owner did not settle, collect settlement fees if (owner != msg.sender) { delegationFee = (buyerPnl * delegationFeePercent) / (PERCENT_PRECISION * 100); delegationFee = Math.min(delegationFee, maxDelegationFee); } buyerPnl -= (protocolFee + delegationFee); epochCollectionsData[sp.epoch].straddleCounter -= 1; epochCollectionsData[sp.epoch] .finalUsdBalanceBeforeWithdaw -= (buyerPnl + protocolFee + delegationFee); IERC20(addresses.usd).safeTransfer( addresses.feeDistributor, protocolFee ); IERC20(addresses.usd).safeTransfer(owner, buyerPnl); IERC20(addresses.usd).safeTransfer(msg.sender, delegationFee); emit Settle(sp.epoch, msg.sender, owner, id, buyerPnl); return buyerPnl; } /// @dev Settle for multiple ids /// @param ids Straddle position token IDs /// @return pnls pnls function multisettle(uint256[] memory ids) external returns (uint256[] memory pnls) { uint256 idsLength = ids.length; pnls = new uint256[](idsLength); for (uint256 i; i < idsLength; ) { pnls[i] = settle(ids[i]); unchecked { ++i; } } } /*==== INTERNAL METHODS ====*/ /// @dev Internal function to mint a write position token /// @param to the address to mint the position to function _mintPositionToken(address to) private returns (uint256 tokenId) { tokenId = _tokenIdCounter.current(); _tokenIdCounter.increment(); _safeMint(to, tokenId); } /// @dev Internal function to swap USD to underlying tokens /// @param amount Amount of USD to swap /// @param minAmountOut The min amount out /// @param swapperId Swapper ID function _swapToUnderlying( uint256 amount, uint256 minAmountOut, uint256 swapperId ) internal returns (uint256 underlyingPurchased) { underlyingPurchased = IAssetSwapper(addresses.assetSwapper).swapAsset( addresses.usd, addresses.underlying, amount, minAmountOut, swapperId ); } /// @dev Internal function to swap underlying tokens to USD /// @param amount Amount of underlying tokens to swap /// @param minAmountOut The min amount out /// @param swapperId Swapper ID function _swapFromUnderlying( uint256 amount, uint256 minAmountOut, uint256 swapperId ) internal returns (uint256 usdObtained) { usdObtained = IAssetSwapper(addresses.assetSwapper).swapAsset( addresses.underlying, addresses.usd, amount, minAmountOut, swapperId ); } /*==== VIEWS ====*/ /// @notice Returns the price of the underlying in USD in 1e8 precision function getUnderlyingPrice() public view returns (uint256) { return IPriceOracle(addresses.priceOracle).getUnderlyingPrice(); } /// @notice Returns the volatility from the volatility oracle /// @param _strike Strike of the option function getVolatility(uint256 _strike) public view returns (uint256) { return IVolatilityOracle(addresses.volatilityOracle).getVolatility( _strike ); } /// @notice Calculate premium for an option /// @param _isPut Is put option /// @param _price Price of the underlying /// @param _strike Strike price of the option /// @param _amount Amount of options (1e18 precision) /// @param _expiry Expiry of the option /// @return premium in USD function calculatePremium( bool _isPut, uint256 _price, uint256 _strike, uint256 _amount, uint256 _expiry ) public view returns (uint256 premium) { premium = (IOptionPricing(addresses.optionPricing).getOptionPrice( _isPut, _expiry, _strike, _price, getVolatility(_strike) ) * _amount); } /// @notice Calculate premium for an option /// @param _price Price of the asset /// @param _amount Amount of options (1e18 precision) /// @param _timeToExpiry Time to expiry function calculateApFunding( uint256 _price, uint256 _amount, uint256 _timeToExpiry ) public view returns (uint256 funding) { funding = (((_price * apFundingPercent * _timeToExpiry * _amount) / (SECONDS_A_YEAR * PERCENT_PRECISION)) / 100) / 2; } /// @notice Calculates the writer position pnl /// @param id the id of the write position /// @return writePositionPnl function calculateWritePositionPnl(uint256 id) public view returns (uint256 writePositionPnl) { WritePosition memory writePos = writePositions[id]; require(writePos.epoch != 0, "Invalid write position"); writePositionPnl = (writePos.usdDeposit * epochCollectionsData[writePos.epoch] .finalUsdBalanceBeforeWithdaw) / epochData[writePos.epoch].usdDeposits; } /// @param id ID of straddle position /// @return buyerPnl positive pnl of buyer function calculateStraddlePositionPnl(uint256 id) public view returns (uint256 buyerPnl) { StraddlePosition memory sp = straddlePositions[id]; require(sp.epoch != 0, "Invalid straddle position"); uint256 settlementPrice = epochData[sp.epoch].settlementPrice; uint256 strikePrice = sp.apStrike; // straddle pnl = max(K - S, 0) + 0.5 * (S - K) // if K > S, get (K - S) - 0.5 * (K - S) if (strikePrice > settlementPrice) { buyerPnl = (strikePrice - settlementPrice) * sp.amount; buyerPnl -= (strikePrice - settlementPrice) * sp.underlyingPurchased; } else { // else get 0 + 0.5 * (S - K) buyerPnl += (settlementPrice - strikePrice) * sp.underlyingPurchased; } buyerPnl /= AMOUNT_PRICE_TO_USDC_DECIMALS; buyerPnl -= (buyerPnl * pnlSlippagePercent) / (100 * PERCENT_PRECISION); } /// @notice Returns the tokenIds owned by a wallet (writePositions) /// @param owner wallet owner function writePositionsOfOwner(address owner) public view returns (uint256[] memory tokenIds) { uint256 ownerTokenCount = balanceOf(owner); uint256 count; for (uint256 i; i < ownerTokenCount; ) { uint256 tokenId = tokenOfOwnerByIndex(owner, i); if (writePositions[tokenId].epoch != 0) { ++count; } unchecked { ++i; } } tokenIds = new uint256[](count); uint256 start; uint256 idx; while (start < count) { uint256 tokenId = tokenOfOwnerByIndex(owner, idx); if (writePositions[tokenId].epoch != 0) { tokenIds[start] = tokenId; ++start; } ++idx; } } /// @notice Returns the tokenIds owned by a wallet (straddlePositions) /// @param owner wallet owner function straddlePositionsOfOwner(address owner) public view returns (uint256[] memory tokenIds) { uint256 ownerTokenCount = balanceOf(owner); uint256 count; for (uint256 i; i < ownerTokenCount; ) { uint256 tokenId = tokenOfOwnerByIndex(owner, i); if (straddlePositions[tokenId].epoch != 0) { ++count; } unchecked { ++i; } } tokenIds = new uint256[](count); uint256 start; uint256 idx; while (start < count) { uint256 tokenId = tokenOfOwnerByIndex(owner, idx); if (straddlePositions[tokenId].epoch != 0) { tokenIds[start] = tokenId; ++start; } ++idx; } } /*==== MANAGER METHODS ====*/ /// @dev Bootstrap and start the next epoch for purchases /// @param expiry Expiry function bootstrap(uint256 expiry) external whenNotPaused onlyRole(MANAGER_ROLE) returns (bool) { uint256 nextEpoch = currentEpoch + 1; require( block.timestamp < expiry, "Expiry cannot be before current time" ); require( currentEpoch == 0 || !isVaultReady[nextEpoch], "Cannot bootstrap when vault is ready" ); if (currentEpoch > 0) { require( isEpochExpired[currentEpoch], "Cannot bootstrap before the current epoch was expired & settled" ); } // Set expiry in epoch data epochData[nextEpoch].startTime = block.timestamp; epochData[nextEpoch].expiry = expiry; // Mark vault as ready for epoch isVaultReady[nextEpoch] = true; // Increase the current epoch currentEpoch = nextEpoch; emit Bootstrap(nextEpoch); return true; } /// @dev Swap a certain percentage of total purchased underlying /// @param percentage percentage of underlying to swap in 1e6 /// @param minAmountOut the min amount out /// @param swapperId Swapper ID of the swap method to use with AssetSwapper function preExpireEpoch( uint256 percentage, uint256 minAmountOut, uint256 swapperId ) external whenNotPaused onlyRole(MANAGER_ROLE) returns (bool) { EpochData memory data = epochData[currentEpoch]; require(percentage > 0, "Percentage cannot be 0"); require( block.timestamp >= data.expiry, "Time is not past epoch expiry" ); require( !isEpochPreExpired[currentEpoch], "Epoch was already pre-expired" ); require(!isEpochExpired[currentEpoch], "Epoch was already expired"); require( data.settlementPercentage + percentage <= (100 * PERCENT_PRECISION), "You cannot swap more than 100%" ); // Swap all purchased underlying at current price uint256 underlyingToSwap = (data.underlyingPurchased * percentage) / (100 * PERCENT_PRECISION); uint256 normalizedSettlementPrice; if (underlyingToSwap > 0) { uint256 usdObtained = _swapFromUnderlying( underlyingToSwap, minAmountOut, swapperId ); epochCollectionsData[currentEpoch] .finalUsdBalanceBeforeWithdaw += usdObtained; uint256 settlementPrice = (usdObtained * AMOUNT_PRICE_TO_USDC_DECIMALS) / underlyingToSwap; normalizedSettlementPrice = ((data.settlementPrice * data.settlementPercentage) + (settlementPrice * percentage)) / (data.settlementPercentage + percentage); epochData[currentEpoch].settlementPercentage += percentage; } else { normalizedSettlementPrice = getUnderlyingPrice(); epochData[currentEpoch].settlementPercentage = 100 * PERCENT_PRECISION; } if (epochData[currentEpoch].settlementPrice == 0) { epochData[currentEpoch].settlementPrice = normalizedSettlementPrice; } else { epochData[currentEpoch].settlementPrice = Math.min( epochData[currentEpoch].settlementPrice, normalizedSettlementPrice ); } if ( epochData[currentEpoch].settlementPercentage > (99 * PERCENT_PRECISION) ) { isEpochPreExpired[currentEpoch] = true; } emit EpochPreExpired(msg.sender); return true; } /// @dev Expire epoch and set the settlement price function expireEpoch() external whenNotPaused onlyRole(MANAGER_ROLE) returns (bool expired) { require( block.timestamp >= epochData[currentEpoch].expiry, "Time is not past epoch expiry" ); require(isEpochPreExpired[currentEpoch], "Epoch has not pre-expired"); require(!isEpochExpired[currentEpoch], "Epoch was already expired"); if (epochCollectionsData[currentEpoch].straddleCounter == 0) { isEpochExpired[currentEpoch] = true; expired = true; } else { revert("All settlements have not been processed"); } emit EpochExpired(msg.sender); } /*==== ADMIN METHODS ====*/ /// @notice Sets the addresses used in the contract /// @dev Can only be called by admin /// @param _addresses Addresses function setAddresses(Addresses memory _addresses) external onlyRole(DEFAULT_ADMIN_ROLE) { addresses = _addresses; emit SetAddresses(_addresses); } /// @notice Change blackout period before expiry /// @dev Can only be called by governance function setBlackoutPeriodBeforeExpiry(uint256 period) external onlyRole(DEFAULT_ADMIN_ROLE) returns (bool) { require(period > 1 hours, "Blackout period must be more than 1 hour"); blackoutPeriodBeforeExpiry = period; emit SetBlackoutPeriod(period); return true; } /// @notice Sets the apFunding /// @dev Can only be called by admin /// @param _apFundingPercent funding percentage number between 1% and 100% function setApFunding(uint256 _apFundingPercent) external onlyRole(DEFAULT_ADMIN_ROLE) { require(_apFundingPercent > 0, "Funding rate must be greater than 0"); apFundingPercent = _apFundingPercent; emit SetApFunding(_apFundingPercent); } /// @notice Sets the pnlSlippagePercent /// @dev Can only be called by admin /// @param _pnlSlippagePercent The pnl slippage percent function setPnlSlippagePercent(uint256 _pnlSlippagePercent) external onlyRole(DEFAULT_ADMIN_ROLE) { require(_pnlSlippagePercent > 0, "Funding rate must be greater than 0"); pnlSlippagePercent = _pnlSlippagePercent; emit SetPnlSlippagePercent(_pnlSlippagePercent); } /// @notice Sets the purchase/settlement fee percent /// @dev Can only be called by admin /// @param _purchaseFeePercent Purchase fee percent /// @param _settlementFeePercent Settlement fee percent /// @param _delegationFeePercent Delegation fee percent /// @param _maxDelegationFee Max delegation fee for settlements and rollovers function setFees( uint256 _purchaseFeePercent, uint256 _settlementFeePercent, uint256 _delegationFeePercent, uint256 _maxDelegationFee ) external onlyRole(DEFAULT_ADMIN_ROLE) { require( _purchaseFeePercent > 0 && _settlementFeePercent > 0 && _delegationFeePercent > 0 && _maxDelegationFee > 0, "Values must be greater than 0" ); purchaseFeePercent = _purchaseFeePercent; settlementFeePercent = _settlementFeePercent; delegationFeePercent = _delegationFeePercent; maxDelegationFee = _maxDelegationFee; emit SetFees( _purchaseFeePercent, _settlementFeePercent, _delegationFeePercent, _maxDelegationFee ); } /// @notice Sets the allowance of the asset swapper /// @dev Can only be called by admin /// @param _token The token to set allowance for /// @param _value The amount of allowance /// @param _increase Whether to increase or decrease allowance function setAssetSwapperAllowance( address _token, uint256 _value, bool _increase ) external onlyRole(DEFAULT_ADMIN_ROLE) { if (_increase) { IERC20(_token).safeIncreaseAllowance( addresses.assetSwapper, _value ); } else { IERC20(_token).safeDecreaseAllowance( addresses.assetSwapper, _value ); } emit SetAssetSwapperAllowance(_token, _value, _increase); } /// @notice Pauses the vault for emergency cases /// @dev Can only be called by admin function pause() external onlyRole(DEFAULT_ADMIN_ROLE) { _pause(); } /// @notice Unpauses the vault /// @dev Can only be called by admin function unpause() external onlyRole(DEFAULT_ADMIN_ROLE) { _unpause(); } /// @notice Add a contract to the whitelist /// @dev Can only be called by the owner /// @param _contract Address of the contract that needs to be added to the whitelist function addToContractWhitelist(address _contract) external onlyRole(DEFAULT_ADMIN_ROLE) { _addToContractWhitelist(_contract); } /// @notice Remove a contract to the whitelist /// @dev Can only be called by the owner /// @param _contract Address of the contract that needs to be removed from the whitelist function removeFromContractWhitelist(address _contract) external onlyRole(DEFAULT_ADMIN_ROLE) { _removeFromContractWhitelist(_contract); } /// @notice Transfers all funds to msg.sender /// @dev Can only be called by admin /// @param tokens The list of erc20 tokens to withdraw /// @param transferNative Whether should transfer the native currency function emergencyWithdraw(address[] calldata tokens, bool transferNative) external onlyRole(DEFAULT_ADMIN_ROLE) whenPaused { if (transferNative) { payable(msg.sender).transfer(address(this).balance); } for (uint256 i; i < tokens.length; ) { IERC20 token = IERC20(tokens[i]); token.safeTransfer(msg.sender, token.balanceOf(address(this))); unchecked { ++i; } } } // The following functions are overrides required by Solidity. function _beforeTokenTransfer( address from, address to, uint256 tokenId, uint256 batchSize ) internal override(ERC721, ERC721Enumerable) { super._beforeTokenTransfer(from, to, tokenId, batchSize); } function supportsInterface(bytes4 interfaceId) public view override(ERC721, ERC721Enumerable, AccessControl) returns (bool) { return super.supportsInterface(interfaceId); } }
// SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.0; interface IAssetSwapper { function swapAsset( address from, address to, uint256 amount, uint256 minAmountOut, uint256 swapperId ) external returns (uint256); }
//SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.0; /// @title ContractWhitelist /// @author witherblock /// @notice A helper contract that lets you add a list of whitelisted contracts that should be able to interact with restricited functions abstract contract ContractWhitelist { /// @dev contract => whitelisted or not mapping(address => bool) public whitelistedContracts; /*==== SETTERS ====*/ /// @dev add to the contract whitelist /// @param _contract the address of the contract to add to the contract whitelist function _addToContractWhitelist(address _contract) internal { require(isContract(_contract), "Address must be a contract"); require( !whitelistedContracts[_contract], "Contract already whitelisted" ); whitelistedContracts[_contract] = true; emit AddToContractWhitelist(_contract); } /// @dev remove from the contract whitelist /// @param _contract the address of the contract to remove from the contract whitelist function _removeFromContractWhitelist(address _contract) internal { require(whitelistedContracts[_contract], "Contract not whitelisted"); whitelistedContracts[_contract] = false; emit RemoveFromContractWhitelist(_contract); } // modifier is eligible sender modifier function _isEligibleSender() internal view { // the below condition checks whether the caller is a contract or not if (msg.sender != tx.origin) require( whitelistedContracts[msg.sender], "Contract must be whitelisted" ); } /*==== VIEWS ====*/ /// @dev checks for contract or eoa addresses /// @param addr the address to check /// @return bool whether the passed address is a contract address function isContract(address addr) public view returns (bool) { uint256 size; assembly { size := extcodesize(addr) } return size > 0; } /*==== EVENTS ====*/ event AddToContractWhitelist(address indexed _contract); event RemoveFromContractWhitelist(address indexed _contract); }
//SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.7; interface IOptionPricing { function getOptionPrice( bool isPut, uint256 expiry, uint256 strike, uint256 lastPrice, uint256 baseIv ) external view returns (uint256); }
//SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.7; interface IPriceOracle { function getCollateralPrice() external view returns (uint256); function getUnderlyingPrice() external view returns (uint256); }
//SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.7; interface IVolatilityOracle { function getVolatility(uint256) external view returns (uint256); }
{ "evmVersion": "london", "libraries": {}, "metadata": { "bytecodeHash": "ipfs", "useLiteralContent": true }, "optimizer": { "enabled": true, "runs": 200 }, "remappings": [], "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } } }
[{"inputs":[{"internalType":"string","name":"_name","type":"string"},{"internalType":"string","name":"_symbol","type":"string"},{"components":[{"internalType":"address","name":"usd","type":"address"},{"internalType":"address","name":"underlying","type":"address"},{"internalType":"address","name":"assetSwapper","type":"address"},{"internalType":"address","name":"priceOracle","type":"address"},{"internalType":"address","name":"volatilityOracle","type":"address"},{"internalType":"address","name":"optionPricing","type":"address"},{"internalType":"address","name":"feeDistributor","type":"address"}],"internalType":"struct AtlanticStraddle.Addresses","name":"_addresses","type":"tuple"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_contract","type":"address"}],"name":"AddToContractWhitelist","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"approved","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":false,"internalType":"bool","name":"approved","type":"bool"}],"name":"ApprovalForAll","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"epoch","type":"uint256"}],"name":"Bootstrap","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"epoch","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"bool","name":"rollover","type":"bool"},{"indexed":false,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"address","name":"sender","type":"address"},{"indexed":false,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Deposit","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"caller","type":"address"}],"name":"EpochExpired","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"caller","type":"address"}],"name":"EpochPreExpired","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"epoch","type":"uint256"},{"indexed":false,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"straddleId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"cost","type":"uint256"}],"name":"Purchase","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_contract","type":"address"}],"name":"RemoveFromContractWhitelist","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":[{"components":[{"internalType":"address","name":"usd","type":"address"},{"internalType":"address","name":"underlying","type":"address"},{"internalType":"address","name":"assetSwapper","type":"address"},{"internalType":"address","name":"priceOracle","type":"address"},{"internalType":"address","name":"volatilityOracle","type":"address"},{"internalType":"address","name":"optionPricing","type":"address"},{"internalType":"address","name":"feeDistributor","type":"address"}],"indexed":false,"internalType":"struct AtlanticStraddle.Addresses","name":"addresses","type":"tuple"}],"name":"SetAddresses","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"apFunding","type":"uint256"}],"name":"SetApFunding","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"},{"indexed":false,"internalType":"bool","name":"increase","type":"bool"}],"name":"SetAssetSwapperAllowance","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"period","type":"uint256"}],"name":"SetBlackoutPeriod","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"purchaseFeePercent","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"settlementFeePercent","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"delegationFeePercent","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"maxDelegationFee","type":"uint256"}],"name":"SetFees","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"pnlSlippagePercent","type":"uint256"}],"name":"SetPnlSlippagePercent","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"epoch","type":"uint256"},{"indexed":true,"internalType":"address","name":"sender","type":"address"},{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":false,"internalType":"uint256","name":"id","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"pnl","type":"uint256"}],"name":"Settle","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"id","type":"uint256"},{"indexed":false,"internalType":"bool","name":"rollover","type":"bool"}],"name":"ToggleRollover","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"epoch","type":"uint256"},{"indexed":true,"internalType":"address","name":"sender","type":"address"},{"indexed":false,"internalType":"uint256","name":"id","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"pnl","type":"uint256"}],"name":"Withdraw","type":"event"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MANAGER_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MIN_DEPOSIT_AMOUNT","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MIN_PURCHASE_AMOUNT","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"PERCENT_PRECISION","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"USDC_DECIMALS","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_contract","type":"address"}],"name":"addToContractWhitelist","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"addresses","outputs":[{"internalType":"address","name":"usd","type":"address"},{"internalType":"address","name":"underlying","type":"address"},{"internalType":"address","name":"assetSwapper","type":"address"},{"internalType":"address","name":"priceOracle","type":"address"},{"internalType":"address","name":"volatilityOracle","type":"address"},{"internalType":"address","name":"optionPricing","type":"address"},{"internalType":"address","name":"feeDistributor","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"apFundingPercent","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"approve","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"blackoutPeriodBeforeExpiry","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"expiry","type":"uint256"}],"name":"bootstrap","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_price","type":"uint256"},{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"uint256","name":"_timeToExpiry","type":"uint256"}],"name":"calculateApFunding","outputs":[{"internalType":"uint256","name":"funding","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"_isPut","type":"bool"},{"internalType":"uint256","name":"_price","type":"uint256"},{"internalType":"uint256","name":"_strike","type":"uint256"},{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"uint256","name":"_expiry","type":"uint256"}],"name":"calculatePremium","outputs":[{"internalType":"uint256","name":"premium","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"id","type":"uint256"}],"name":"calculateStraddlePositionPnl","outputs":[{"internalType":"uint256","name":"buyerPnl","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"id","type":"uint256"}],"name":"calculateWritePositionPnl","outputs":[{"internalType":"uint256","name":"writePositionPnl","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"currentEpoch","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"delegationFeePercent","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bool","name":"shouldRollover","type":"bool"},{"internalType":"address","name":"user","type":"address"}],"name":"deposit","outputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"tokens","type":"address[]"},{"internalType":"bool","name":"transferNative","type":"bool"}],"name":"emergencyWithdraw","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"epochCollectionsData","outputs":[{"internalType":"uint256","name":"usdPremiums","type":"uint256"},{"internalType":"uint256","name":"usdFunding","type":"uint256"},{"internalType":"uint256","name":"totalSold","type":"uint256"},{"internalType":"uint256","name":"straddleCounter","type":"uint256"},{"internalType":"uint256","name":"finalUsdBalanceBeforeWithdaw","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"epochData","outputs":[{"internalType":"uint256","name":"startTime","type":"uint256"},{"internalType":"uint256","name":"expiry","type":"uint256"},{"internalType":"uint256","name":"usdDeposits","type":"uint256"},{"internalType":"uint256","name":"activeUsdDeposits","type":"uint256"},{"internalType":"uint256","name":"settlementPrice","type":"uint256"},{"internalType":"uint256","name":"settlementPercentage","type":"uint256"},{"internalType":"uint256","name":"underlyingPurchased","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"expireEpoch","outputs":[{"internalType":"bool","name":"expired","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getApproved","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getUnderlyingPrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_strike","type":"uint256"}],"name":"getVolatility","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"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":"owner","type":"address"},{"internalType":"address","name":"operator","type":"address"}],"name":"isApprovedForAll","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"addr","type":"address"}],"name":"isContract","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"isEpochExpired","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"isEpochPreExpired","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"isVaultReady","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxDelegationFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"ids","type":"uint256[]"}],"name":"multirollover","outputs":[{"internalType":"uint256[]","name":"tokenIds","type":"uint256[]"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"ids","type":"uint256[]"}],"name":"multisettle","outputs":[{"internalType":"uint256[]","name":"pnls","type":"uint256[]"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"ownerOf","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pnlSlippagePercent","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"percentage","type":"uint256"},{"internalType":"uint256","name":"minAmountOut","type":"uint256"},{"internalType":"uint256","name":"swapperId","type":"uint256"}],"name":"preExpireEpoch","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"minAmountOut","type":"uint256"},{"internalType":"uint256","name":"swapperId","type":"uint256"},{"internalType":"address","name":"user","type":"address"}],"name":"purchase","outputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"protocolFee","type":"uint256"},{"internalType":"uint256","name":"straddleCost","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"purchaseFeePercent","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_contract","type":"address"}],"name":"removeFromContractWhitelist","outputs":[],"stateMutability":"nonpayable","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":"uint256","name":"id","type":"uint256"}],"name":"rollover","outputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"usd","type":"address"},{"internalType":"address","name":"underlying","type":"address"},{"internalType":"address","name":"assetSwapper","type":"address"},{"internalType":"address","name":"priceOracle","type":"address"},{"internalType":"address","name":"volatilityOracle","type":"address"},{"internalType":"address","name":"optionPricing","type":"address"},{"internalType":"address","name":"feeDistributor","type":"address"}],"internalType":"struct AtlanticStraddle.Addresses","name":"_addresses","type":"tuple"}],"name":"setAddresses","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_apFundingPercent","type":"uint256"}],"name":"setApFunding","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"bool","name":"approved","type":"bool"}],"name":"setApprovalForAll","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"},{"internalType":"uint256","name":"_value","type":"uint256"},{"internalType":"bool","name":"_increase","type":"bool"}],"name":"setAssetSwapperAllowance","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"period","type":"uint256"}],"name":"setBlackoutPeriodBeforeExpiry","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_purchaseFeePercent","type":"uint256"},{"internalType":"uint256","name":"_settlementFeePercent","type":"uint256"},{"internalType":"uint256","name":"_delegationFeePercent","type":"uint256"},{"internalType":"uint256","name":"_maxDelegationFee","type":"uint256"}],"name":"setFees","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_pnlSlippagePercent","type":"uint256"}],"name":"setPnlSlippagePercent","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"id","type":"uint256"}],"name":"settle","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"settlementFeePercent","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"straddlePositions","outputs":[{"internalType":"uint256","name":"epoch","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"apStrike","type":"uint256"},{"internalType":"uint256","name":"underlyingPurchased","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"straddlePositionsOfOwner","outputs":[{"internalType":"uint256[]","name":"tokenIds","type":"uint256[]"}],"stateMutability":"view","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":[{"internalType":"uint256","name":"id","type":"uint256"}],"name":"toggleRollover","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"index","type":"uint256"}],"name":"tokenByIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"uint256","name":"index","type":"uint256"}],"name":"tokenOfOwnerByIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"tokenURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"transferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"whitelistedContracts","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"id","type":"uint256"}],"name":"withdraw","outputs":[{"internalType":"uint256","name":"writePositionPnl","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"writePositions","outputs":[{"internalType":"uint256","name":"epoch","type":"uint256"},{"internalType":"uint256","name":"usdDeposit","type":"uint256"},{"internalType":"bool","name":"rollover","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"writePositionsOfOwner","outputs":[{"internalType":"uint256[]","name":"tokenIds","type":"uint256[]"}],"stateMutability":"view","type":"function"}]
Contract Creation Code
6080604052620249f0601e55620f4240601f55620186a0602055620f424060246200002b919062000253565b6021556200003e600a620f424062000279565b6022556138406023556207a1206024553480156200005b57600080fd5b50604051620061ab380380620061ab8339810160408190526200007e91620003ba565b60016000819055839083906200009583826200055c565b506002620000a482826200055c565b5050600c805460ff19169055508051601080546001600160a01b03199081166001600160a01b0393841617909155602083015160118054831691841691909117905560408301516012805483169184169190911790556060830151601380548316918416919091179055608083015160148054831691841691909117905560a083015160158054831691841691909117905560c0830151601680549092169216919091179055620001576000336200018c565b620001837f241ecf16d79d0f8dbfb92cbc07fe17840425976cf0667f022fe9877caa831b08336200018c565b50505062000628565b6200019882826200019c565b5050565b620001a8828262000226565b62000198576000828152600b602090815260408083206001600160a01b03851684529091529020805460ff19166001179055620001e23390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b6000828152600b602090815260408083206001600160a01b038516845290915290205460ff165b92915050565b80820281158282048414176200024d57634e487b7160e01b600052601160045260246000fd5b6000826200029757634e487b7160e01b600052601260045260246000fd5b500490565b634e487b7160e01b600052604160045260246000fd5b60405160e081016001600160401b0381118282101715620002d757620002d76200029c565b60405290565b604051601f8201601f191681016001600160401b03811182821017156200030857620003086200029c565b604052919050565b600082601f8301126200032257600080fd5b81516001600160401b038111156200033e576200033e6200029c565b602062000354601f8301601f19168201620002dd565b82815285828487010111156200036957600080fd5b60005b83811015620003895785810183015182820184015282016200036c565b506000928101909101919091529392505050565b80516001600160a01b0381168114620003b557600080fd5b919050565b6000806000838503610120811215620003d257600080fd5b84516001600160401b0380821115620003ea57600080fd5b620003f88883890162000310565b955060208701519150808211156200040f57600080fd5b506200041e8782880162000310565b93505060e0603f19820112156200043457600080fd5b506200043f620002b2565b6200044d604086016200039d565b81526200045d606086016200039d565b602082015262000470608086016200039d565b60408201526200048360a086016200039d565b60608201526200049660c086016200039d565b6080820152620004a960e086016200039d565b60a0820152620004bd61010086016200039d565b60c0820152809150509250925092565b600181811c90821680620004e257607f821691505b6020821081036200050357634e487b7160e01b600052602260045260246000fd5b50919050565b601f8211156200055757600081815260208120601f850160051c81016020861015620005325750805b601f850160051c820191505b8181101562000553578281556001016200053e565b5050505b505050565b81516001600160401b038111156200057857620005786200029c565b6200059081620005898454620004cd565b8462000509565b602080601f831160018114620005c85760008415620005af5750858301515b600019600386901b1c1916600185901b17855562000553565b600085815260208120601f198616915b82811015620005f957888601518255948401946001909101908401620005d8565b5085821015620006185787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b615b7380620006386000396000f3fe608060405234801561001057600080fd5b50600436106104545760003560e01c80637927113011610241578063bfcb8d2b1161013b578063de40e873116100c3578063ef2bb7e211610087578063ef2bb7e214610b6c578063f55b5b1014610b7f578063f9bb30e214610b92578063fcec046814610ba5578063ffe8e3721461050f57600080fd5b8063de40e87314610aa6578063de8b007a14610ab9578063e985e9c514610acc578063ec87621c14610b08578063ee0d82c114610b1d57600080fd5b8063c87b56dd1161010a578063c87b56dd146109e3578063cddd3893146109f6578063cf4b6805146109ff578063d547741f14610a12578063da0321cd14610a2557600080fd5b8063bfcb8d2b146109b4578063c1419def1461050f578063c189c19b146109bd578063c3d9ed39146109d057600080fd5b806395d89b41116101c9578063a22cb4651161018d578063a22cb4651461095f578063acc3a00614610972578063b375d49214610985578063b88d4fde14610998578063bbdce168146109ab57600080fd5b806395d89b41146108a957806396e451b0146108b1578063998e59ae146108df5780639ce990ea14610944578063a217fddf1461095757600080fd5b80638df82800116102105780638df828001461080257806390bb58551461081557806391d148541461086a578063931efa961461087d57806393c82c751461088657600080fd5b806379271130146107c15780637c4b52cb146107d457806380ed71e4146107e75780638456cb59146107fa57600080fd5b80633f4ba83a116103525780635c975abb116102da5780636e821b2e1161029e5780636e821b2e146106ff5780636fcba3771461077f57806370a082311461079257806375153f3e146107a557806376671808146107b857600080fd5b80635c975abb146106b35780636352211e146106be5780636a9f3a8c146106d15780636c1085a1146106e45780636db29f6d146106f757600080fd5b80634a2a6070116103215780634a2a6070146106535780634e6d0268146106765780634f6ccce71461067f5780635387b84c1461069257806354545bfb146106a557600080fd5b80633f4ba83a1461060d5780633f83b8a51461061557806342842e0e14610638578063468f02d21461064b57600080fd5b8063248a9ca3116103e057806336568abe116103a457806336568abe146105915780633686a39e146105a4578063391feebb146105b75780633dbb196d146105da5780633ec21260146105fa57600080fd5b8063248a9ca31461052c57806326325a781461054f5780632e1a7d4d146105585780632f2ff15d1461056b5780632f745c591461057e57600080fd5b8063162790551161042757806316279055146104d657806318160ddd146104ea5780631d91ec30146104fc5780631ea30fef1461050f57806323b872dd1461051957600080fd5b806301ffc9a71461045957806306fdde0314610481578063081812fc14610496578063095ea7b3146104c1575b600080fd5b61046c610467366004615134565b610bae565b60405190151581526020015b60405180910390f35b610489610bbf565b60405161047891906151a1565b6104a96104a43660046151b4565b610c51565b6040516001600160a01b039091168152602001610478565b6104d46104cf3660046151e4565b610c78565b005b61046c6104e436600461520e565b3b151590565b6009545b604051908152602001610478565b61046c61050a366004615229565b610d92565b6104ee620f424081565b6104d4610527366004615255565b611209565b6104ee61053a3660046151b4565b6000908152600b602052604090206001015490565b6104ee60205481565b6104ee6105663660046151b4565b61123a565b6104d4610579366004615291565b61141e565b6104ee61058c3660046151e4565b611443565b6104d461059f366004615291565b6114d9565b61046c6105b23660046151b4565b611557565b61046c6105c536600461520e565b600d6020526000908152604090205460ff1681565b6105ed6105e8366004615304565b61175d565b60405161047891906153aa565b6105ed61060836600461520e565b611800565b6104d461190c565b61046c6106233660046151b4565b60196020526000908152604090205460ff1681565b6104d4610646366004615255565b611922565b6104ee61193d565b61046c6106613660046151b4565b601a6020526000908152604090205460ff1681565b6104ee60225481565b6104ee61068d3660046151b4565b6119b0565b6104ee6106a03660046151b4565b611a43565b6104ee662386f26fc1000081565b600c5460ff1661046c565b6104a96106cc3660046151b4565b611ba8565b6104d46106df3660046153fc565b611c08565b6104d46106f23660046151b4565b611ca2565b61046c611dc7565b61074a61070d3660046151b4565b6017602052600090815260409020805460018201546002830154600384015460048501546005860154600690960154949593949293919290919087565b604080519788526020880196909652948601939093526060850191909152608084015260a083015260c082015260e001610478565b6104d461078d36600461543c565b611fd8565b6104ee6107a036600461520e565b6120b8565b6104ee6107b33660046151b4565b61213e565b6104ee600f5481565b6105ed6107cf36600461520e565b6121dd565b6104d46107e236600461546e565b6122e0565b6104ee6107f53660046154e9565b6123ed565b6104d4612587565b6104ee6108103660046151b4565b61259a565b61084a6108233660046151b4565b601d6020526000908152604090208054600182015460028301546003909301549192909184565b604080519485526020850193909352918301526060820152608001610478565b61046c610878366004615291565b61289f565b6104ee60245481565b61046c6108943660046151b4565b601b6020526000908152604090205460ff1681565b6104896128ca565b6108c46108bf366004615527565b6128d9565b60408051938452602084019290925290820152606001610478565b61091c6108ed3660046151b4565b601860205260009081526040902080546001820154600283015460038401546004909401549293919290919085565b604080519586526020860194909452928401919091526060830152608082015260a001610478565b6104ee610952366004615229565b612ed1565b6104ee600081565b6104d461096d366004615566565b612f32565b6104d461098036600461520e565b612f3d565b6104d461099336600461559d565b612f51565b6104d46109a636600461564d565b613091565b6104ee60215481565b6104ee601f5481565b6104ee6109cb3660046151b4565b6130c9565b6104d46109de36600461520e565b613137565b6104896109f13660046151b4565b61314b565b6104ee60235481565b61046c610a0d3660046151b4565b6131be565b6104d4610a20366004615291565b61326d565b601054601154601254601354601454601554601654610a5d966001600160a01b03908116968116958116948116938116928116911687565b604080516001600160a01b039889168152968816602088015294871694860194909452918516606085015284166080840152831660a083015290911660c082015260e001610478565b6104ee610ab436600461570d565b613292565b6105ed610ac7366004615304565b613343565b61046c610ada366004615751565b6001600160a01b03918216600090815260066020908152604080832093909416825291909152205460ff1690565b6104ee600080516020615b1e83398151915281565b610b4f610b2b3660046151b4565b601c6020526000908152604090208054600182015460029092015490919060ff1683565b604080519384526020840192909252151590820152606001610478565b6104ee610b7a3660046151b4565b6133df565b6104d4610b8d3660046151b4565b613745565b6104d4610ba03660046151b4565b6137a5565b6104ee601e5481565b6000610bb982613805565b92915050565b606060018054610bce9061577b565b80601f0160208091040260200160405190810160405280929190818152602001828054610bfa9061577b565b8015610c475780601f10610c1c57610100808354040283529160200191610c47565b820191906000526020600020905b815481529060010190602001808311610c2a57829003601f168201915b5050505050905090565b6000610c5c8261382a565b506000908152600560205260409020546001600160a01b031690565b6000610c8382611ba8565b9050806001600160a01b0316836001600160a01b031603610cf55760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b60648201526084015b60405180910390fd5b336001600160a01b0382161480610d115750610d118133610ada565b610d835760405162461bcd60e51b815260206004820152603d60248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f7420746f60448201527f6b656e206f776e6572206f7220617070726f76656420666f7220616c6c0000006064820152608401610cec565b610d8d8383613889565b505050565b6000610d9c6138f7565b600080516020615b1e833981519152610db48161393f565b600f54600090815260176020908152604091829020825160e081018452815481526001820154928101929092526002810154928201929092526003820154606082015260048201546080820152600582015460a082015260069091015460c082015285610e5c5760405162461bcd60e51b8152602060048201526016602482015275050657263656e746167652063616e6e6f7420626520360541b6044820152606401610cec565b8060200151421015610eb05760405162461bcd60e51b815260206004820152601d60248201527f54696d65206973206e6f7420706173742065706f6368206578706972790000006044820152606401610cec565b600f546000908152601a602052604090205460ff1615610f125760405162461bcd60e51b815260206004820152601d60248201527f45706f63682077617320616c7265616479207072652d657870697265640000006044820152606401610cec565b600f546000908152601b602052604090205460ff1615610f705760405162461bcd60e51b8152602060048201526019602482015278115c1bd8da081dd85cc8185b1c9958591e48195e1c1a5c9959603a1b6044820152606401610cec565b610f7e620f424060646157c5565b868260a00151610f8e91906157dc565b1115610fdc5760405162461bcd60e51b815260206004820152601e60248201527f596f752063616e6e6f742073776170206d6f7265207468616e203130302500006044820152606401610cec565b6000610fec620f424060646157c5565b878360c00151610ffc91906157c5565b61100691906157ef565b9050600081156110e857600061101d838989613949565b90508060186000600f548152602001908152602001600020600401600082825461104791906157dc565b90915550600090508361106368056bc75e2d63100000846157c5565b61106d91906157ef565b9050898560a0015161107f91906157dc565b6110898b836157c5565b8660a00151876080015161109d91906157c5565b6110a791906157dc565b6110b191906157ef565b92508960176000600f54815260200190815260200160002060050160008282546110db91906157dc565b9091555061111692505050565b6110f061193d565b9050611100620f424060646157c5565b600f546000908152601760205260409020600501555b600f54600090815260176020526040812060040154900361114d57600f546000908152601760205260409020600401819055611182565b600f5460009081526017602052604090206004015461116c90826139e1565b600f546000908152601760205260409020600401555b611190620f424060636157c5565b600f5460009081526017602052604090206005015411156111c857600f546000908152601a60205260409020805460ff191660011790555b6040513381527fe299059e3adc918e4f4ab456527f6220987ed7fce29c2bc9a416f9336822bdd29060200160405180910390a1506001979650505050505050565b61121333826139f7565b61122f5760405162461bcd60e51b8152600401610cec90615811565b610d8d838383613a75565b60006112446138f7565b61124c613be6565b611254613c3f565b3361125e83611ba8565b6001600160a01b0316146112a45760405162461bcd60e51b815260206004820152600d60248201526c24b73b30b634b21037bbb732b960991b6044820152606401610cec565b6000828152601c602090815260408083208151606081018352815480825260018301549482019490945260029091015460ff1615159181019190915291036112fe5760405162461bcd60e51b8152600401610cec9061585e565b80516000908152601b602052604090205460ff166113555760405162461bcd60e51b8152602060048201526014602482015273536574746c656d656e7473206e6f7420646f6e6560601b6044820152606401610cec565b61135e8361213e565b915061136983613ca5565b816000036113b35760405162461bcd60e51b81526020600482015260176024820152760577269746520706f736974696f6e20706e6c206973203604c1b6044820152606401610cec565b6010546113ca906001600160a01b03163384613d48565b80516040805191825260208201859052810183905233907fb0ecf14e184effded5473bba77dcfab32b094b77ac1fbb36beec2aef555879709060600160405180910390a2506114196001600055565b919050565b6000828152600b60205260409020600101546114398161393f565b610d8d8383613dab565b600061144e836120b8565b82106114b05760405162461bcd60e51b815260206004820152602b60248201527f455243373231456e756d657261626c653a206f776e657220696e646578206f7560448201526a74206f6620626f756e647360a81b6064820152608401610cec565b506001600160a01b03919091166000908152600760209081526040808320938352929052205490565b6001600160a01b03811633146115495760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b6064820152608401610cec565b6115538282613e31565b5050565b60006115616138f7565b600080516020615b1e8339815191526115798161393f565b6000600f54600161158a91906157dc565b90508342106115e75760405162461bcd60e51b8152602060048201526024808201527f4578706972792063616e6e6f74206265206265666f72652063757272656e742060448201526374696d6560e01b6064820152608401610cec565b600f541580611605575060008181526019602052604090205460ff16155b61165d5760405162461bcd60e51b8152602060048201526024808201527f43616e6e6f7420626f6f747374726170207768656e207661756c7420697320726044820152636561647960e01b6064820152608401610cec565b600f54156116ec57600f546000908152601b602052604090205460ff166116ec5760405162461bcd60e51b815260206004820152603f60248201527f43616e6e6f7420626f6f747374726170206265666f726520746865206375727260448201527f656e742065706f6368207761732065787069726564202620736574746c6564006064820152608401610cec565b600081815260176020908152604080832042815560019081018890556019835292819020805460ff1916909317909255600f83905590518281527fb5ca1ca1b7b47549eb8af476f3ef702fc63bcd8b8c01dc163b009bb818f97997910160405180910390a160019250505b50919050565b80516060908067ffffffffffffffff81111561177b5761177b6152bd565b6040519080825280602002602001820160405280156117a4578160200160208202803683370190505b50915060005b818110156117f9576117d48482815181106117c7576117c761588e565b602002602001015161259a565b8382815181106117e6576117e661588e565b60209081029190910101526001016117aa565b5050919050565b6060600061180d836120b8565b90506000805b828110156118535760006118278683611443565b6000818152601d60205260409020549091501561184a57611847836158a4565b92505b50600101611813565b508067ffffffffffffffff81111561186d5761186d6152bd565b604051908082528060200260200182016040528015611896578160200160208202803683370190505b5092506000805b828210156119035760006118b18783611443565b6000818152601d6020526040902054909150156118f257808684815181106118db576118db61588e565b60209081029190910101526118ef836158a4565b92505b6118fb826158a4565b91505061189d565b50505050919050565b60006119178161393f565b61191f613e98565b50565b610d8d83838360405180602001604052806000815250613091565b60135460408051632347816960e11b815290516000926001600160a01b03169163468f02d29160048083019260209291908290030181865afa158015611987573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119ab91906158bd565b905090565b60006119bb60095490565b8210611a1e5760405162461bcd60e51b815260206004820152602c60248201527f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60448201526b7574206f6620626f756e647360a01b6064820152608401610cec565b60098281548110611a3157611a3161588e565b90600052602060002001549050919050565b6000818152601d6020908152604080832081516080810183528154808252600183015494820194909452600282015492810192909252600301546060820152908203611acd5760405162461bcd60e51b815260206004820152601960248201527824b73b30b634b21039ba3930b2323632903837b9b4ba34b7b760391b6044820152606401610cec565b805160009081526017602052604090819020600401549082015181811115611b35576020830151611afe83836158d6565b611b0891906157c5565b6060840151909450611b1a83836158d6565b611b2491906157c5565b611b2e90856158d6565b9350611b5b565b6060830151611b4482846158d6565b611b4e91906157c5565b611b5890856157dc565b93505b611b6e68056bc75e2d63100000856157ef565b9350611b7e620f424060646157c5565b602454611b8b90866157c5565b611b9591906157ef565b611b9f90856158d6565b95945050505050565b6000818152600360205260408120546001600160a01b031680610bb95760405162461bcd60e51b8152602060048201526018602482015277115490cdcc8c4e881a5b9d985b1a59081d1bdad95b88125160421b6044820152606401610cec565b6000611c138161393f565b8115611c3857601254611c33906001600160a01b03868116911685613eea565b611c52565b601254611c52906001600160a01b03868116911685613f9c565b604080516001600160a01b0386168152602081018590528315158183015290517f35d9c99316351d33a4edaa0cc300bc9e1ed88cdc7d677ec9f96016b1cd485d9a9181900360600190a150505050565b611caa6138f7565b611cb2613be6565b611cba613c3f565b33611cc482611ba8565b6001600160a01b031614611d0a5760405162461bcd60e51b815260206004820152600d60248201526c24b73b30b634b21037bbb732b960991b6044820152606401610cec565b6000818152601c60205260408120549003611d5a5760405162461bcd60e51b815260206004820152601060248201526f24b73b30b634b2103837b9b4ba34b7b760811b6044820152606401610cec565b6000818152601c6020908152604091829020600201805460ff8082161560ff199092168217909255835185815291161515918101919091527fb5e95d468eadd79446f495b23ddf06bb55ff5717a821eb2cc57154a31cd5ee22910160405180910390a161191f6001600055565b6000611dd16138f7565b600080516020615b1e833981519152611de98161393f565b600f54600090815260176020526040902060010154421015611e4d5760405162461bcd60e51b815260206004820152601d60248201527f54696d65206973206e6f7420706173742065706f6368206578706972790000006044820152606401610cec565b600f546000908152601a602052604090205460ff16611eaa5760405162461bcd60e51b8152602060048201526019602482015278115c1bd8da081a185cc81b9bdd081c1c994b595e1c1a5c9959603a1b6044820152606401610cec565b600f546000908152601b602052604090205460ff1615611f085760405162461bcd60e51b8152602060048201526019602482015278115c1bd8da081dd85cc8185b1c9958591e48195e1c1a5c9959603a1b6044820152606401610cec565b600f546000908152601860205260408120600301549003611f4957600f546000908152601b60205260409020805460ff191660019081179091559150611fa1565b60405162461bcd60e51b815260206004820152602760248201527f416c6c20736574746c656d656e74732068617665206e6f74206265656e2070726044820152661bd8d95cdcd95960ca1b6064820152608401610cec565b6040513381527f6a4de20bb9fa8fea199f1022f29eff6be1752c446674d16913f2afc2b3c5a8a59060200160405180910390a15090565b6000611fe38161393f565b600085118015611ff35750600084115b8015611fff5750600083115b801561200b5750600082115b6120575760405162461bcd60e51b815260206004820152601d60248201527f56616c756573206d7573742062652067726561746572207468616e20300000006044820152606401610cec565b601e85905560208481556022849055601f839055604080518781529182018690528101849052606081018390527f747eaccb30a9769474f1620ae0dd833b1ffb89520dcac6833b33df942b7c0c499060800160405180910390a15050505050565b60006001600160a01b0382166121225760405162461bcd60e51b815260206004820152602960248201527f4552433732313a2061646472657373207a65726f206973206e6f7420612076616044820152683634b21037bbb732b960b91b6064820152608401610cec565b506001600160a01b031660009081526004602052604090205490565b6000818152601c602090815260408083208151606081018352815480825260018301549482019490945260029091015460ff161515918101919091529082036121995760405162461bcd60e51b8152600401610cec9061585e565b80516000908152601760209081526040808320600201548451845260188352922060040154908301516121cc91906157c5565b6121d691906157ef565b9392505050565b606060006121ea836120b8565b90506000805b828110156122305760006122048683611443565b6000818152601c60205260409020549091501561222757612224836158a4565b92505b506001016121f0565b508067ffffffffffffffff81111561224a5761224a6152bd565b604051908082528060200260200182016040528015612273578160200160208202803683370190505b5092506000805b8282101561190357600061228e8783611443565b6000818152601c6020526040902054909150156122cf57808684815181106122b8576122b861588e565b60209081029190910101526122cc836158a4565b92505b6122d8826158a4565b91505061227a565b60006122eb8161393f565b6122f36140a8565b81156123275760405133904780156108fc02916000818181858888f19350505050158015612325573d6000803e3d6000fd5b505b60005b838110156123e65760008585838181106123465761234661588e565b905060200201602081019061235b919061520e565b6040516370a0823160e01b81523060048201529091506123dd9033906001600160a01b038416906370a0823190602401602060405180830381865afa1580156123a8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123cc91906158bd565b6001600160a01b0384169190613d48565b5060010161232a565b5050505050565b60006123f76138f7565b6123ff613be6565b612407613c3f565b620f4240841161244a5760405162461bcd60e51b815260206004820152600e60248201526d125b9d985b1a5908185b5bdd5b9d60921b6044820152606401610cec565b6000600f54600161245b91906157dc565b90508460176000838152602001908152602001600020600201600082825461248391906157dc565b9091555050600081815260186020526040812060040180548792906124a99084906157dc565b909155506124b89050836140f1565b6040805160608101825283815260208082018981528815158385019081526000868152601c909352939091209151825551600182015590516002909101805460ff191691151591909117905560105490925061251f906001600160a01b0316333088614116565b6040805182815260208101879052851515818301526001600160a01b038516606082015233608082015260a0810184905290517f14c0e56f4125d5707194bbf1beff49bb39b170a0f49574bcf25d8616f4df1cf69181900360c00190a1506121d66001600055565b60006125928161393f565b61191f61414e565b60006125a46138f7565b6125ac613be6565b6125b4613c3f565b6000828152601d6020908152604080832081516080810183528154808252600183015494820194909452600282015492810192909252600301546060820152910361263d5760405162461bcd60e51b815260206004820152601960248201527824b73b30b634b21039ba3930b2323632903837b9b4ba34b7b760391b6044820152606401610cec565b80516000908152601a602052604090205460ff166126995760405162461bcd60e51b8152602060048201526019602482015278115c1bd8da081a185cc81b9bdd081c1c994b595e1c1a5c9959603a1b6044820152606401610cec565b60006126a484611a43565b905060006126b185611ba8565b90506126bc85613ca5565b816000036127035760405162461bcd60e51b815260206004820152601460248201527306275796572506e6c2063616e6e6f7420626520360641b6044820152606401610cec565b6000612713620f424060646157c5565b60205461272090856157c5565b61272a91906157ef565b905060006001600160a01b03831633146127745761274c620f424060646157c5565b60225461275990866157c5565b61276391906157ef565b905061277181601f546139e1565b90505b61277e81836157dc565b61278890856158d6565b8551600090815260186020526040812060030180549296506001929091906127b19084906158d6565b909155508190506127c283866157dc565b6127cc91906157dc565b8551600090815260186020526040812060040180549091906127ef9084906158d6565b9091555050601654601054612811916001600160a01b03918216911684613d48565b601054612828906001600160a01b03168486613d48565b60105461283f906001600160a01b03163383613d48565b8451604080519182526020820189905281018590526001600160a01b0384169033907f5c6a917207417d39f68f90bcada5466a46efe20df97c2ac0046789b071b135ca9060600160405180910390a3509193505050506114196001600055565b6000918252600b602090815260408084206001600160a01b0393909316845291905290205460ff1690565b606060028054610bce9061577b565b60008060006128e66138f7565b6128ee613be6565b6128f6613c3f565b6000600f54116129385760405162461bcd60e51b815260206004820152600d60248201526c092dcecc2d8d2c840cae0dec6d609b1b6044820152606401610cec565b662386f26fc10000871161297f5760405162461bcd60e51b815260206004820152600e60248201526d125b9d985b1a5908185b5bdd5b9d60921b6044820152606401610cec565b602354600f546000908152601760205260409020600101546129a191906158d6565b42106129fe5760405162461bcd60e51b815260206004820152602660248201527f43616e6e6f7420707572636861736520647572696e6720626c61636b6f7574206044820152651c195c9a5bd960d21b6064820152608401610cec565b6000612a0861193d565b600f5460009081526017602052604081206001015491925090612a2c9042906158d6565b905068056bc75e2d63100000612a428a846157c5565b612a4c91906157ef565b600f54600090815260176020526040902060030154612a759068056bc75e2d63100000906157ef565b600f54600090815260176020526040902060020154612a9491906158d6565b1015612aec5760405162461bcd60e51b815260206004820152602160248201527f4e6f7420656e6f756768204150206c697175696469747920617661696c61626c6044820152606560f81b6064820152608401610cec565b6000612b2268056bc75e2d631000006002612b078d876157c5565b612b1191906157ef565b612b1b91906157ef565b8a8a61418b565b905068056bc75e2d631000006002612b3a8c866157c5565b612b4491906157ef565b612b4e91906157ef565b600f5460009081526018602052604081206004018054909190612b729084906158d6565b9091555060009050612b858260026157c5565b612b8f8c866157c5565b612b9991906157ef565b90508160176000600f5481526020019081526020016000206006016000828254612bc391906157dc565b90915550612bd490508260026157c5565b612bde90826157c5565b600f5460009081526017602052604081206003018054909190612c029084906157dc565b9091555060009050612c3660018380612c1c8760026157c5565b600f54600090815260176020526040902060010154613292565b90506000612c4f83612c498660026157c5565b87612ed1565b600f54600090815260186020526040812080549293508492909190612c759084906157dc565b9091555050600f5460009081526018602052604081206001018054839290612c9e9084906157dc565b90915550612caf90508460026157c5565b600f5460009081526018602052604081206002018054909190612cd39084906157dc565b9091555050600f546000908152601860205260408120600301805460019290612cfd9084906157dc565b90915550612d0c90508a6140f1565b98506040518060800160405280600f548152602001856002612d2e91906157c5565b81526020808201869052604091820187905260008c8152601d825282902083518155908301516001820155908201516002820155606090910151600390910155612d8468056bc75e2d63100000620f42406157c5565b612d8f9060646157c5565b601e54878f612d9e91906157c5565b612da891906157c5565b612db291906157ef565b975068056bc75e2d63100000612dc882846157dc565b612dd291906157ef565b9650612df73330612de38b8b6157dc565b6010546001600160a01b0316929190614116565b601654601054612e14916001600160a01b0391821691168a613d48565b68056bc75e2d63100000612e2882846157dc565b612e3291906157ef565b600f5460009081526018602052604081206004018054909190612e569084906157dc565b9091555050600f547f9d507133ca47d3afd7d870243115c9867ea2325ba4c3014950405d35dae67cd6908b8b612e8c85876157dc565b604080519485526001600160a01b03909316602085015291830152606082015260800160405180910390a1505050505050612ec76001600055565b9450945094915050565b600060026064612ee8620f42406301e133806157c5565b858560215489612ef891906157c5565b612f0291906157c5565b612f0c91906157c5565b612f1691906157ef565b612f2091906157ef565b612f2a91906157ef565b949350505050565b6115533383836141e4565b6000612f488161393f565b611553826142b2565b6000612f5c8161393f565b8151601080546001600160a01b039283166001600160a01b0319918216179091556020840151601180549184169183169190911790556040808501516012805491851691841691909117905560608501516013805491851691841691909117905560808501516014805491851691841691909117905560a08501516015805491851691841691909117905560c08501516016805491909416921691909117909155517f488865203db2c6efd677f2757b6433d6fd6f452390e796b6719252b8588fcdf99061308590849081516001600160a01b03908116825260208084015182169083015260408084015182169083015260608084015182169083015260808084015182169083015260a08381015182169083015260c092830151169181019190915260e00190565b60405180910390a15050565b61309b33836139f7565b6130b75760405162461bcd60e51b8152600401610cec90615811565b6130c3848484846143b5565b50505050565b60145460405163c189c19b60e01b8152600481018390526000916001600160a01b03169063c189c19b90602401602060405180830381865afa158015613113573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bb991906158bd565b60006131428161393f565b611553826143e8565b60606131568261382a565b600061316d60408051602081019091526000815290565b9050600081511161318d57604051806020016040528060008152506121d6565b8061319784614499565b6040516020016131a89291906158e9565b6040516020818303038152906040529392505050565b6000806131ca8161393f565b610e10831161322c5760405162461bcd60e51b815260206004820152602860248201527f426c61636b6f757420706572696f64206d757374206265206d6f726520746861604482015267371018903437bab960c11b6064820152608401610cec565b60238390556040518381527f32e6db6aab294383bb2b48c5adfb1100050e096a4ce0eed5b7568604fc09f10b9060200160405180910390a150600192915050565b6000828152600b60205260409020600101546132888161393f565b610d8d8383613e31565b60155460009083906001600160a01b0316635b7b6d888885888a6132b5826130c9565b6040516001600160e01b031960e088901b1681529415156004860152602485019390935260448401919091526064830152608482015260a401602060405180830381865afa15801561330b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061332f91906158bd565b61333991906157c5565b9695505050505050565b80516060908067ffffffffffffffff811115613361576133616152bd565b60405190808252806020026020018201604052801561338a578160200160208202803683370190505b50915060005b818110156117f9576133ba8482815181106133ad576133ad61588e565b60200260200101516133df565b8382815181106133cc576133cc61588e565b6020908102919091010152600101613390565b60006133e96138f7565b6133f1613be6565b6133f9613c3f565b6000828152601c60209081526040918290208251606081018452815481526001820154928101929092526002015460ff1615159181018290529061347f5760405162461bcd60e51b815260206004820152601760248201527f526f6c6c6f766572206e6f7420617574686f72697a65640000000000000000006044820152606401610cec565b80516000036134a05760405162461bcd60e51b8152600401610cec9061585e565b80516000908152601b602052604090205460ff166134f85760405162461bcd60e51b8152602060048201526015602482015274115c1bd8da081a185cc81b9bdd08195e1c1a5c9959605a1b6044820152606401610cec565b60006135038461213e565b9050600061351085611ba8565b905061351b85613ca5565b816000036135655760405162461bcd60e51b81526020600482015260176024820152760577269746520706f736974696f6e20706e6c206973203604c1b6044820152606401610cec565b60006001600160a01b03821633146135ad57613585620f424060646157c5565b60225461359290856157c5565b61359c91906157ef565b90506135aa81601f546139e1565b90505b6135b781846158d6565b8451604080519182526020820189905281018290529093506001600160a01b038316907fb0ecf14e184effded5473bba77dcfab32b094b77ac1fbb36beec2aef555879709060600160405180910390a26000600f54600161361891906157dc565b90508360176000838152602001908152602001600020600201600082825461364091906157dc565b9091555050600081815260186020526040812060040180548692906136669084906157dc565b909155506136759050836140f1565b60408051606081018252838152602080820188815260018385018181526000878152601c9094529490922092518355519082015590516002909101805460ff19169115159190911790556010549096506136d9906001600160a01b03163384613d48565b60408051828152602081018690526001818301526001600160a01b03851660608201819052608082015260a0810188905290517f14c0e56f4125d5707194bbf1beff49bb39b170a0f49574bcf25d8616f4df1cf69181900360c00190a150505050506114196001600055565b60006137508161393f565b600082116137705760405162461bcd60e51b8152600401610cec90615918565b60248290556040518281527fe4d44cc62a77ab305c1c324248b29e91f621d65b1c231ee984dd6800b2ff7b4690602001613085565b60006137b08161393f565b600082116137d05760405162461bcd60e51b8152600401610cec90615918565b60218290556040518281527fc5c758ec4001ae2dfceeb8a99ff59eacf17b62ca95bae713257b9dd494b9a84090602001613085565b60006001600160e01b03198216637965db0b60e01b1480610bb95750610bb98261452c565b6000818152600360205260409020546001600160a01b031661191f5760405162461bcd60e51b8152602060048201526018602482015277115490cdcc8c4e881a5b9d985b1a59081d1bdad95b88125160421b6044820152606401610cec565b600081815260056020526040902080546001600160a01b0319166001600160a01b03841690811790915581906138be82611ba8565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b600c5460ff161561393d5760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b6044820152606401610cec565b565b61191f8133614551565b60125460115460105460405163b91ac49560e01b81526001600160a01b0392831660048201529082166024820152604481018690526064810185905260848101849052600092919091169063b91ac4959060a4015b6020604051808303816000875af11580156139bd573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612f2a91906158bd565b60008183106139f057816121d6565b5090919050565b600080613a0383611ba8565b9050806001600160a01b0316846001600160a01b03161480613a4a57506001600160a01b0380821660009081526006602090815260408083209388168352929052205460ff165b80612f2a5750836001600160a01b0316613a6384610c51565b6001600160a01b031614949350505050565b826001600160a01b0316613a8882611ba8565b6001600160a01b031614613aae5760405162461bcd60e51b8152600401610cec9061595b565b6001600160a01b038216613b105760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b6064820152608401610cec565b613b1d83838360016145aa565b826001600160a01b0316613b3082611ba8565b6001600160a01b031614613b565760405162461bcd60e51b8152600401610cec9061595b565b600081815260056020908152604080832080546001600160a01b03199081169091556001600160a01b0387811680865260048552838620805460001901905590871680865283862080546001019055868652600390945282852080549092168417909155905184937fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b600260005403613c385760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610cec565b6002600055565b33321461393d57336000908152600d602052604090205460ff1661393d5760405162461bcd60e51b815260206004820152601c60248201527f436f6e7472616374206d7573742062652077686974656c6973746564000000006044820152606401610cec565b6000613cb082611ba8565b9050613cc08160008460016145aa565b613cc982611ba8565b600083815260056020908152604080832080546001600160a01b03199081169091556001600160a01b0385168085526004845282852080546000190190558785526003909352818420805490911690555192935084927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908390a45050565b6040516001600160a01b038316602482015260448101829052610d8d90849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b0319909316929092179091526145b6565b613db5828261289f565b611553576000828152600b602090815260408083206001600160a01b03851684529091529020805460ff19166001179055613ded3390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b613e3b828261289f565b15611553576000828152600b602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b613ea06140a8565b600c805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b604051636eb1769f60e11b81523060048201526001600160a01b038381166024830152600091839186169063dd62ed3e90604401602060405180830381865afa158015613f3b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613f5f91906158bd565b613f6991906157dc565b6040516001600160a01b0385166024820152604481018290529091506130c390859063095ea7b360e01b90606401613d74565b604051636eb1769f60e11b81523060048201526001600160a01b0383811660248301526000919085169063dd62ed3e90604401602060405180830381865afa158015613fec573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061401091906158bd565b9050818110156140745760405162461bcd60e51b815260206004820152602960248201527f5361666545524332303a2064656372656173656420616c6c6f77616e63652062604482015268656c6f77207a65726f60b81b6064820152608401610cec565b6040516001600160a01b038416602482015282820360448201819052906123e690869063095ea7b360e01b90606401613d74565b600c5460ff1661393d5760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b6044820152606401610cec565b60006140fc600e5490565b905061410c600e80546001019055565b6114198282614688565b6040516001600160a01b03808516602483015283166044820152606481018290526130c39085906323b872dd60e01b90608401613d74565b6141566138f7565b600c805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258613ecd3390565b60125460105460115460405163b91ac49560e01b81526001600160a01b0392831660048201529082166024820152604481018690526064810185905260848101849052600092919091169063b91ac4959060a40161399e565b816001600160a01b0316836001600160a01b0316036142455760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c6572000000000000006044820152606401610cec565b6001600160a01b03838116600081815260066020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b803b6143005760405162461bcd60e51b815260206004820152601a60248201527f41646472657373206d757374206265206120636f6e74726163740000000000006044820152606401610cec565b6001600160a01b0381166000908152600d602052604090205460ff16156143695760405162461bcd60e51b815260206004820152601c60248201527f436f6e747261637420616c72656164792077686974656c6973746564000000006044820152606401610cec565b6001600160a01b0381166000818152600d6020526040808220805460ff19166001179055517ffbd3cde7ff522a917e485c8ed2a6e87590887ab399f5ac312307903f498543079190a250565b6143c0848484613a75565b6143cc848484846146a2565b6130c35760405162461bcd60e51b8152600401610cec906159a0565b6001600160a01b0381166000908152600d602052604090205460ff166144505760405162461bcd60e51b815260206004820152601860248201527f436f6e7472616374206e6f742077686974656c697374656400000000000000006044820152606401610cec565b6001600160a01b0381166000818152600d6020526040808220805460ff19169055517f8e81447740597754af5db3e176253a36f7981a9549f48ace3f0cb233913f9d859190a250565b606060006144a6836147a3565b600101905060008167ffffffffffffffff8111156144c6576144c66152bd565b6040519080825280601f01601f1916602001820160405280156144f0576020820181803683370190505b5090508181016020015b600019016f181899199a1a9b1b9c1cb0b131b232b360811b600a86061a8153600a85049450846144fa57509392505050565b60006001600160e01b0319821663780e9d6360e01b1480610bb95750610bb98261487b565b61455b828261289f565b61155357614568816148cb565b6145738360206148dd565b6040516020016145849291906159f2565b60408051601f198184030181529082905262461bcd60e51b8252610cec916004016151a1565b6130c384848484614a79565b600061460b826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316614bb29092919063ffffffff16565b805190915015610d8d57808060200190518101906146299190615a67565b610d8d5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610cec565b611553828260405180602001604052806000815250614bc1565b60006001600160a01b0384163b1561479857604051630a85bd0160e11b81526001600160a01b0385169063150b7a02906146e6903390899088908890600401615a84565b6020604051808303816000875af1925050508015614721575060408051601f3d908101601f1916820190925261471e91810190615ab7565b60015b61477e573d80801561474f576040519150601f19603f3d011682016040523d82523d6000602084013e614754565b606091505b5080516000036147765760405162461bcd60e51b8152600401610cec906159a0565b805181602001fd5b6001600160e01b031916630a85bd0160e11b149050612f2a565b506001949350505050565b60008072184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b83106147e25772184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b830492506040015b6d04ee2d6d415b85acef8100000000831061480e576d04ee2d6d415b85acef8100000000830492506020015b662386f26fc10000831061482c57662386f26fc10000830492506010015b6305f5e1008310614844576305f5e100830492506008015b612710831061485857612710830492506004015b6064831061486a576064830492506002015b600a8310610bb95760010192915050565b60006001600160e01b031982166380ac58cd60e01b14806148ac57506001600160e01b03198216635b5e139f60e01b145b80610bb957506301ffc9a760e01b6001600160e01b0319831614610bb9565b6060610bb96001600160a01b03831660145b606060006148ec8360026157c5565b6148f79060026157dc565b67ffffffffffffffff81111561490f5761490f6152bd565b6040519080825280601f01601f191660200182016040528015614939576020820181803683370190505b509050600360fc1b816000815181106149545761495461588e565b60200101906001600160f81b031916908160001a905350600f60fb1b816001815181106149835761498361588e565b60200101906001600160f81b031916908160001a90535060006149a78460026157c5565b6149b29060016157dc565b90505b6001811115614a2a576f181899199a1a9b1b9c1cb0b131b232b360811b85600f16601081106149e6576149e661588e565b1a60f81b8282815181106149fc576149fc61588e565b60200101906001600160f81b031916908160001a90535060049490941c93614a2381615ad4565b90506149b5565b5083156121d65760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610cec565b614a8584848484614bf4565b6001811115614af45760405162461bcd60e51b815260206004820152603560248201527f455243373231456e756d657261626c653a20636f6e7365637574697665207472604482015274185b9cd9995c9cc81b9bdd081cdd5c1c1bdc9d1959605a1b6064820152608401610cec565b816001600160a01b038516614b5057614b4b81600980546000838152600a60205260408120829055600182018355919091527f6e1540171b6c0c960b71a7020d9f60077f6af931a8bbf590da0223dacf75c7af0155565b614b73565b836001600160a01b0316856001600160a01b031614614b7357614b738582614c7c565b6001600160a01b038416614b8f57614b8a81614d19565b6123e6565b846001600160a01b0316846001600160a01b0316146123e6576123e68482614dc8565b6060612f2a8484600085614e0c565b614bcb8383614ee7565b614bd860008484846146a2565b610d8d5760405162461bcd60e51b8152600401610cec906159a0565b60018111156130c3576001600160a01b03841615614c3a576001600160a01b03841660009081526004602052604081208054839290614c349084906158d6565b90915550505b6001600160a01b038316156130c3576001600160a01b03831660009081526004602052604081208054839290614c719084906157dc565b909155505050505050565b60006001614c89846120b8565b614c9391906158d6565b600083815260086020526040902054909150808214614ce6576001600160a01b03841660009081526007602090815260408083208584528252808320548484528184208190558352600890915290208190555b5060009182526008602090815260408084208490556001600160a01b039094168352600781528383209183525290812055565b600954600090614d2b906001906158d6565b6000838152600a602052604081205460098054939450909284908110614d5357614d5361588e565b906000526020600020015490508060098381548110614d7457614d7461588e565b6000918252602080832090910192909255828152600a90915260408082208490558582528120556009805480614dac57614dac615aeb565b6001900381819060005260206000200160009055905550505050565b6000614dd3836120b8565b6001600160a01b039093166000908152600760209081526040808320868452825280832085905593825260089052919091209190915550565b606082471015614e6d5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401610cec565b600080866001600160a01b03168587604051614e899190615b01565b60006040518083038185875af1925050503d8060008114614ec6576040519150601f19603f3d011682016040523d82523d6000602084013e614ecb565b606091505b5091509150614edc87838387615080565b979650505050505050565b6001600160a01b038216614f3d5760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f20616464726573736044820152606401610cec565b6000818152600360205260409020546001600160a01b031615614fa25760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e746564000000006044820152606401610cec565b614fb06000838360016145aa565b6000818152600360205260409020546001600160a01b0316156150155760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e746564000000006044820152606401610cec565b6001600160a01b038216600081815260046020908152604080832080546001019055848352600390915280822080546001600160a01b0319168417905551839291907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b606083156150ef5782516000036150e8576001600160a01b0385163b6150e85760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610cec565b5081612f2a565b612f2a83838151156151045781518083602001fd5b8060405162461bcd60e51b8152600401610cec91906151a1565b6001600160e01b03198116811461191f57600080fd5b60006020828403121561514657600080fd5b81356121d68161511e565b60005b8381101561516c578181015183820152602001615154565b50506000910152565b6000815180845261518d816020860160208601615151565b601f01601f19169290920160200192915050565b6020815260006121d66020830184615175565b6000602082840312156151c657600080fd5b5035919050565b80356001600160a01b038116811461141957600080fd5b600080604083850312156151f757600080fd5b615200836151cd565b946020939093013593505050565b60006020828403121561522057600080fd5b6121d6826151cd565b60008060006060848603121561523e57600080fd5b505081359360208301359350604090920135919050565b60008060006060848603121561526a57600080fd5b615273846151cd565b9250615281602085016151cd565b9150604084013590509250925092565b600080604083850312156152a457600080fd5b823591506152b4602084016151cd565b90509250929050565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff811182821017156152fc576152fc6152bd565b604052919050565b6000602080838503121561531757600080fd5b823567ffffffffffffffff8082111561532f57600080fd5b818501915085601f83011261534357600080fd5b813581811115615355576153556152bd565b8060051b91506153668483016152d3565b818152918301840191848101908884111561538057600080fd5b938501935b8385101561539e57843582529385019390850190615385565b98975050505050505050565b6020808252825182820181905260009190848201906040850190845b818110156153e2578351835292840192918401916001016153c6565b50909695505050505050565b801515811461191f57600080fd5b60008060006060848603121561541157600080fd5b61541a846151cd565b9250602084013591506040840135615431816153ee565b809150509250925092565b6000806000806080858703121561545257600080fd5b5050823594602084013594506040840135936060013592509050565b60008060006040848603121561548357600080fd5b833567ffffffffffffffff8082111561549b57600080fd5b818601915086601f8301126154af57600080fd5b8135818111156154be57600080fd5b8760208260051b85010111156154d357600080fd5b60209283019550935050840135615431816153ee565b6000806000606084860312156154fe57600080fd5b833592506020840135615510816153ee565b915061551e604085016151cd565b90509250925092565b6000806000806080858703121561553d57600080fd5b84359350602085013592506040850135915061555b606086016151cd565b905092959194509250565b6000806040838503121561557957600080fd5b615582836151cd565b91506020830135615592816153ee565b809150509250929050565b600060e082840312156155af57600080fd5b60405160e0810181811067ffffffffffffffff821117156155d2576155d26152bd565b6040526155de836151cd565b81526155ec602084016151cd565b60208201526155fd604084016151cd565b604082015261560e606084016151cd565b606082015261561f608084016151cd565b608082015261563060a084016151cd565b60a082015261564160c084016151cd565b60c08201529392505050565b6000806000806080858703121561566357600080fd5b61566c856151cd565b9350602061567b8187016151cd565b935060408601359250606086013567ffffffffffffffff8082111561569f57600080fd5b818801915088601f8301126156b357600080fd5b8135818111156156c5576156c56152bd565b6156d7601f8201601f191685016152d3565b915080825289848285010111156156ed57600080fd5b808484018584013760008482840101525080935050505092959194509250565b600080600080600060a0868803121561572557600080fd5b8535615730816153ee565b97602087013597506040870135966060810135965060800135945092505050565b6000806040838503121561576457600080fd5b61576d836151cd565b91506152b4602084016151cd565b600181811c9082168061578f57607f821691505b60208210810361175757634e487b7160e01b600052602260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b8082028115828204841417610bb957610bb96157af565b80820180821115610bb957610bb96157af565b60008261580c57634e487b7160e01b600052601260045260246000fd5b500490565b6020808252602d908201527f4552433732313a2063616c6c6572206973206e6f7420746f6b656e206f776e6560408201526c1c881bdc88185c1c1c9bdd9959609a1b606082015260800190565b60208082526016908201527524b73b30b634b2103bb934ba32903837b9b4ba34b7b760511b604082015260600190565b634e487b7160e01b600052603260045260246000fd5b6000600182016158b6576158b66157af565b5060010190565b6000602082840312156158cf57600080fd5b5051919050565b81810381811115610bb957610bb96157af565b600083516158fb818460208801615151565b83519083019061590f818360208801615151565b01949350505050565b60208082526023908201527f46756e64696e672072617465206d75737420626520677265617465722074686160408201526206e20360ec1b606082015260800190565b60208082526025908201527f4552433732313a207472616e736665722066726f6d20696e636f72726563742060408201526437bbb732b960d91b606082015260800190565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b7f416363657373436f6e74726f6c3a206163636f756e7420000000000000000000815260008351615a2a816017850160208801615151565b7001034b99036b4b9b9b4b733903937b6329607d1b6017918401918201528351615a5b816028840160208801615151565b01602801949350505050565b600060208284031215615a7957600080fd5b81516121d6816153ee565b6001600160a01b038581168252841660208201526040810183905260806060820181905260009061333990830184615175565b600060208284031215615ac957600080fd5b81516121d68161511e565b600081615ae357615ae36157af565b506000190190565b634e487b7160e01b600052603160045260246000fd5b60008251615b13818460208701615151565b919091019291505056fe241ecf16d79d0f8dbfb92cbc07fe17840425976cf0667f022fe9877caa831b08a2646970667358221220a1625cebcfd0d432897cbd7755e1a51f30bfcf2819b64633ed3b6b14e435434c64736f6c6343000811003300000000000000000000000000000000000000000000000000000000000001200000000000000000000000000000000000000000000000000000000000000160000000000000000000000000ff970a61a04b1ca14834a43f5de4533ebddb5cc80000000000000000000000006c2c06790b3e3e3c38e12ee22f8183b37a13ee55000000000000000000000000c7679e9e8198e6020d9b6854a066a368e4d2aa1a00000000000000000000000058bc6da61a00310ebc519fcf8c0d55493c529341000000000000000000000000b6645813567bb5beea8f62e793d075fe6d3be0b10000000000000000000000002b99e3d67dad973c1b9747da742b7e26c8bdd67b00000000000000000000000055594cce8cc0014ea08c49fd820d731308f204c100000000000000000000000000000000000000000000000000000000000000154450582041746c616e746963205374726164646c65000000000000000000000000000000000000000000000000000000000000000000000000000000000000174450582d41544c414e5449432d5354524144444c452d32000000000000000000
Age | Block | Fee Address | BC Fee Address | Voting Power | Jailed | Incoming |
---|
Make sure to use the "Vote Down" button for any spammy posts, and the "Vote Up" for interesting conversations.