Contract
0xDaF4FfB05bfCb2C328c19135E3e74e1182C88283
11
Contract Overview
My Name Tag:
Not Available
[ Download CSV Export ]
Latest 3 internal transactions
Parent Txn Hash | Block | From | To | Value | |||
---|---|---|---|---|---|---|---|
0x4076e7f493d2ace57bac7f7f52fd25d02cb153c79b3762f0e34e68aa83707499 | 73316041 | 180 days 9 hrs ago | 0xdaf4ffb05bfcb2c328c19135e3e74e1182c88283 | Contract Creation | 0 ETH | ||
0x4076e7f493d2ace57bac7f7f52fd25d02cb153c79b3762f0e34e68aa83707499 | 73316041 | 180 days 9 hrs ago | 0xdaf4ffb05bfcb2c328c19135e3e74e1182c88283 | Contract Creation | 0 ETH | ||
0x4076e7f493d2ace57bac7f7f52fd25d02cb153c79b3762f0e34e68aa83707499 | 73316041 | 180 days 9 hrs ago | 0xdaf4ffb05bfcb2c328c19135e3e74e1182c88283 | Contract Creation | 0 ETH |
[ Download CSV Export ]
Contract Name:
OptionScalp
Compiler Version
v0.8.9+commit.e5eed63a
Optimization Enabled:
Yes with 5000 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol) pragma solidity ^0.8.0; import "../utils/Context.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _transferOwnership(_msgSender()); } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { _checkOwner(); _; } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if the sender is not the owner. */ function _checkOwner() internal view virtual { require(owner() == _msgSender(), "Ownable: caller is not the owner"); } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _transferOwnership(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (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.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/extensions/ERC721Burnable.sol) pragma solidity ^0.8.0; import "../ERC721.sol"; import "../../../utils/Context.sol"; /** * @title ERC721 Burnable Token * @dev ERC721 Token that can be burned (destroyed). */ abstract contract ERC721Burnable is Context, ERC721 { /** * @dev Burns `tokenId`. See {ERC721-_burn}. * * Requirements: * * - The caller must own `tokenId` or be an approved operator. */ function burn(uint256 tokenId) public virtual { //solhint-disable-next-line max-line-length require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: caller is not token owner or approved"); _burn(tokenId); } }
// 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) (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) (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 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: MIT // OpenZeppelin Contracts (last updated v4.6.0) (utils/math/SafeMath.sol) pragma solidity ^0.8.0; // CAUTION // This version of SafeMath should only be used with Solidity 0.8 or later, // because it relies on the compiler's built in overflow checks. /** * @dev Wrappers over Solidity's arithmetic operations. * * NOTE: `SafeMath` is generally not needed starting with Solidity 0.8, since the compiler * now has built in overflow checking. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); } } /** * @dev Returns the subtraction of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b > a) return (false, 0); return (true, a - b); } } /** * @dev Returns the multiplication of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) return (true, 0); uint256 c = a * b; if (c / a != b) return (false, 0); return (true, c); } } /** * @dev Returns the division of two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a / b); } } /** * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a % b); } } /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { return a + b; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return a - b; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { return a * b; } /** * @dev Returns the integer division of two unsigned integers, reverting on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return a % b; } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {trySub}. * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { unchecked { require(b <= a, errorMessage); return a - b; } } /** * @dev Returns the integer division of two unsigned integers, reverting with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { unchecked { require(b > 0, errorMessage); return a / b; } } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting with custom message when dividing by zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryMod}. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { unchecked { require(b > 0, errorMessage); return a % b; } } }
// 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: 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.0; /// @title Lighter version of the Openzeppelin Pausable contract /// @author witherblock /// @notice Helps pause a contract to block the execution of selected functions /// @dev Difference from the Openzeppelin version is changing the modifiers to internal fns and requires to reverts abstract contract Pausable { /** * @dev Emitted when the pause is triggered by `account`. */ event Paused(address account); /** * @dev Emitted when the pause is lifted by `account`. */ event Unpaused(address account); bool private _paused; /** * @dev Initializes the contract in unpaused state. */ constructor() { _paused = false; } /** * @dev Returns true if the contract is paused, and false otherwise. */ function paused() public view virtual returns (bool) { return _paused; } /** * @dev Internal function to make a function callable only when the contract is not paused. * * Requirements: * * - The contract must not be paused. */ function _whenNotPaused() internal view { if (paused()) revert ContractPaused(); } /** * @dev Internal function to make a function callable only when the contract is paused. * * Requirements: * * - The contract must be paused. */ function _whenPaused() internal view { if (!paused()) revert ContractNotPaused(); } /** * @dev Triggers stopped state. * * Requirements: * * - The contract must not be paused. */ function _pause() internal virtual { _whenNotPaused(); _paused = true; emit Paused(msg.sender); } /** * @dev Returns to normal state. * * Requirements: * * - The contract must be paused. */ function _unpause() internal virtual { _whenPaused(); _paused = false; emit Unpaused(msg.sender); } error ContractPaused(); error ContractNotPaused(); }
// 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); function decimals() external view returns (uint8); function symbol() external view returns (string memory); }
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.0; interface IPriceOracle { function getCollateralPrice() external view returns (uint256); function getUnderlyingPrice() external view returns (uint256); }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.7.5; pragma abicoder v2; import './IUniswapV3SwapCallback.sol'; /// @title Router token swapping functionality /// @notice Functions for swapping tokens via Uniswap V3 interface IUniswapV3Router is IUniswapV3SwapCallback { struct ExactInputSingleParams { address tokenIn; address tokenOut; uint24 fee; address recipient; uint256 deadline; uint256 amountIn; uint256 amountOutMinimum; uint160 sqrtPriceLimitX96; } /// @notice Swaps `amountIn` of one token for as much as possible of another token /// @param params The parameters necessary for the swap, encoded as `ExactInputSingleParams` in calldata /// @return amountOut The amount of the received token function exactInputSingle(ExactInputSingleParams calldata params) external payable returns (uint256 amountOut); struct ExactInputParams { bytes path; address recipient; uint256 deadline; uint256 amountIn; uint256 amountOutMinimum; } /// @notice Swaps `amountIn` of one token for as much as possible of another along the specified path /// @param params The parameters necessary for the multi-hop swap, encoded as `ExactInputParams` in calldata /// @return amountOut The amount of the received token function exactInput(ExactInputParams calldata params) external payable returns (uint256 amountOut); struct ExactOutputSingleParams { address tokenIn; address tokenOut; uint24 fee; address recipient; uint256 deadline; uint256 amountOut; uint256 amountInMaximum; uint160 sqrtPriceLimitX96; } /// @notice Swaps as little as possible of one token for `amountOut` of another token /// @param params The parameters necessary for the swap, encoded as `ExactOutputSingleParams` in calldata /// @return amountIn The amount of the input token function exactOutputSingle(ExactOutputSingleParams calldata params) external payable returns (uint256 amountIn); struct ExactOutputParams { bytes path; address recipient; uint256 deadline; uint256 amountOut; uint256 amountInMaximum; } /// @notice Swaps as little as possible of one token for `amountOut` of another along the specified path (reversed) /// @param params The parameters necessary for the multi-hop swap, encoded as `ExactOutputParams` in calldata /// @return amountIn The amount of the input token function exactOutput(ExactOutputParams calldata params) external payable returns (uint256 amountIn); }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; /// @title Callback for IUniswapV3PoolActions#swap /// @notice Any contract that calls IUniswapV3PoolActions#swap must implement this interface interface IUniswapV3SwapCallback { /// @notice Called to `msg.sender` after executing a swap via IUniswapV3Pool#swap. /// @dev In the implementation you must pay the pool tokens owed for the swap. /// The caller of this method must be checked to be a UniswapV3Pool deployed by the canonical UniswapV3Factory. /// amount0Delta and amount1Delta can both be 0 if no tokens were swapped. /// @param amount0Delta The amount of token0 that was sent (negative) or must be received (positive) by the pool by /// the end of the swap. If positive, the callback must send that amount of token0 to the pool. /// @param amount1Delta The amount of token1 that was sent (negative) or must be received (positive) by the pool by /// the end of the swap. If positive, the callback must send that amount of token1 to the pool. /// @param data Any data passed through by the caller via the IUniswapV3PoolActions#swap call function uniswapV3SwapCallback( int256 amount0Delta, int256 amount1Delta, bytes calldata data ) external; }
//SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.0; interface IVolatilityOracle { function getVolatility(uint256) external view returns (uint256); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import {IERC20} from "../interface/IERC20.sol"; import {SafeMath} from "@openzeppelin/contracts/utils/math/SafeMath.sol"; import {Address} from "@openzeppelin/contracts/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 SafeMath for uint256; 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' // solhint-disable-next-line max-line-length 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).add( value ); _callOptionalReturn( token, abi.encodeWithSelector( token.approve.selector, spender, newAllowance ) ); } function safeDecreaseAllowance( IERC20 token, address spender, uint256 value ) internal { uint256 newAllowance = token.allowance(address(this), spender).sub( value, "SafeERC20: decreased allowance below zero" ); _callOptionalReturn( token, abi.encodeWithSelector( token.approve.selector, spender, newAllowance ) ); } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function _callOptionalReturn(IERC20 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall( data, "SafeERC20: low-level call failed" ); if (returndata.length > 0) { // Return data is optional // solhint-disable-next-line max-line-length require( abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed" ); } } }
// SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.9; import {IERC20} from "./interface/IERC20.sol"; import {SafeERC20} from "./libraries/SafeERC20.sol"; import {ContractWhitelist} from "./helpers/ContractWhitelist.sol"; import {ScalpLP} from "./token/ScalpLP.sol"; import {ReentrancyGuard} from "@openzeppelin/contracts/security/ReentrancyGuard.sol"; import {IERC721} from "@openzeppelin/contracts/token/ERC721/IERC721.sol"; import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol"; import {ScalpPositionMinter} from "./positions/ScalpPositionMinter.sol"; import {Pausable} from "./helpers/Pausable.sol"; import {IOptionPricing} from "./interface/IOptionPricing.sol"; import {IVolatilityOracle} from "./interface/IVolatilityOracle.sol"; import {IPriceOracle} from "./interface/IPriceOracle.sol"; import {IUniswapV3Router} from "./interface/IUniswapV3Router.sol"; contract OptionScalp is Ownable, Pausable, ReentrancyGuard, ContractWhitelist { using SafeERC20 for IERC20; // Base token IERC20 public base; // Quote token IERC20 public quote; // Base decimals uint256 public baseDecimals; // Quote decimals uint256 public quoteDecimals; // Scalp Base LP token ScalpLP public baseLp; // Scalp Quote LP token ScalpLP public quoteLp; // Option pricing IOptionPricing public optionPricing; // Volatility oracle IVolatilityOracle public volatilityOracle; // Price oracle IPriceOracle public priceOracle; // Scalp position minter ScalpPositionMinter public scalpPositionMinter; // Uniswap V3 router IUniswapV3Router public uniswapV3Router; uint256[] public timeframes = [ 1 minutes, 5 minutes, 15 minutes, 30 minutes, 60 minutes ]; // Address of multisig which handles insurance fund address public insuranceFund; // Minimum margin to open a position (quoteDecimals) uint256 public minimumMargin; // Fees for opening position (divisor) uint256 public feeOpenPosition; // Minimum absolute threshold in quote asset above (entry - margin) when liquidate() is callable uint256 public minimumAbsoluteLiquidationThreshold; // Max size of a position (quoteDecimals) uint256 public maxSize; // Max open interest (quoteDecimals) uint256 public maxOpenInterest; // Used for percentages uint256 public constant divisor = 1e8; // Open interest (quoteDecimals) mapping(bool => uint256) public openInterest; // Cumulative pnl (quoteDecimals) mapping(address => int256) public cumulativePnl; // Cumulative volume (quoteDecimals) mapping(address => uint256) public cumulativeVolume; // Withdraw timeout uint256 public withdrawTimeout; // Scalp positions mapping(uint256 => ScalpPosition) public scalpPositions; struct Configuration { // quoteDecimals Max size of a position uint256 maxSize; // quoteDecimals Max open interest uint256 maxOpenInterest; IOptionPricing optionPricing; IVolatilityOracle volatilityOracle; IPriceOracle priceOracle; // Address receiving liquidation fees address insuranceFund; // quoteDecimals Minimum margin to open a position uint256 minimumMargin; // divisor Fees for opening position uint256 feeOpenPosition; // quoteDecimals Min. Abs. Thres. to liquidate uint256 minimumAbsoluteLiquidationThreshold; // seconds to wait before withdraw uint256 withdrawTimeout; } struct ScalpPosition { // Is position open bool isOpen; // Is short bool isShort; // Total size in quote asset uint256 size; // Open position count (in base asset) uint256 positions; // Amount borrowed uint256 amountBorrowed; // Amount received from swap uint256 amountOut; // Entry price uint256 entry; // Margin provided uint256 margin; // Premium for position uint256 premium; // Fees for position uint256 fees; // Final PNL of position int256 pnl; // Opened at timestamp uint256 openedAt; // How long position is to be kept open uint256 timeframe; } // Deposit event event Deposit(bool isQuote, uint256 amount, address indexed sender); // Withdraw event event Withdraw(bool isQuote, uint256 amount, address indexed sender); // Open position event event OpenPosition(uint256 id, uint256 size, address indexed user); // Close position event event ClosePosition(uint256 id, int256 pnl, address indexed user); // Shortfall event Shortfall(bool isQuote, uint256 amount); // AddProceeds event event AddProceeds(bool isQuote, uint256 amount); // Emergency withdraw event EmergencyWithdraw(address indexed receiver); constructor( address _base, address _quote, uint256 _baseDecimals, uint256 _quoteDecimals, address _uniswapV3Router, Configuration memory config ) { require(_base != address(0), "Invalid base token"); require(_quote != address(0), "Invalid quote token"); base = IERC20(_base); quote = IERC20(_quote); baseDecimals = _baseDecimals; quoteDecimals = _quoteDecimals; uniswapV3Router = IUniswapV3Router(_uniswapV3Router); maxSize = config.maxSize; maxOpenInterest = config.maxOpenInterest; optionPricing = config.optionPricing; volatilityOracle = config.volatilityOracle; priceOracle = config.priceOracle; insuranceFund = config.insuranceFund; minimumMargin = config.minimumMargin; feeOpenPosition = config.feeOpenPosition; minimumAbsoluteLiquidationThreshold = config .minimumAbsoluteLiquidationThreshold; withdrawTimeout = config.withdrawTimeout; scalpPositionMinter = new ScalpPositionMinter(); base.approve(address(uniswapV3Router), type(uint256).max); quote.approve(address(uniswapV3Router), type(uint256).max); quoteLp = new ScalpLP(address(this), address(quote), quote.symbol()); baseLp = new ScalpLP(address(this), address(base), base.symbol()); quote.approve(address(quoteLp), type(uint256).max); base.approve(address(baseLp), type(uint256).max); } /// @notice Internal function to handle swaps using Uniswap V3 exactOutput /// @param from Address of the token to sell /// @param to Address of the token to buy /// @param amountOut Target amount of to token we want to receive function _swapExactOut( address from, address to, uint256 amountOut ) internal returns (uint256 amountIn) { return uniswapV3Router.exactOutputSingle( IUniswapV3Router.ExactOutputSingleParams({ tokenIn: from, tokenOut: to, fee: 500, recipient: address(this), deadline: block.timestamp, amountOut: amountOut, amountInMaximum: type(uint256).max, sqrtPriceLimitX96: 0 }) ); } /// @notice Internal function to handle swaps using Uniswap V3 exactIn /// @param from Address of the token to sell /// @param to Address of the token to buy /// @param amountOut Target amount of to token we want to receive function _swapExactIn( address from, address to, uint256 amountIn ) internal returns (uint256 amountOut) { return uniswapV3Router.exactInputSingle( IUniswapV3Router.ExactInputSingleParams({ tokenIn: from, tokenOut: to, fee: 500, recipient: address(this), deadline: block.timestamp, amountIn: amountIn, amountOutMinimum: 0, sqrtPriceLimitX96: 0 }) ); } // Deposit assets // @param isQuote If true user deposits quote token (else base) // @param amount Amount of quote asset to deposit to LP function deposit( address receiver, bool isQuote, uint256 amount ) public nonReentrant returns (uint256 shares) { _isEligibleSender(); if (isQuote) { quote.safeTransferFrom(msg.sender, address(this), amount); shares = quoteLp.deposit(amount, receiver); } else { base.safeTransferFrom(msg.sender, address(this), amount); shares = baseLp.deposit(amount, receiver); } emit Deposit(isQuote, amount, msg.sender); } // Withdraw // @param isQuote If true user withdraws quote token (else base) // @param amount Amount of LP positions to withdraw function withdraw( bool isQuote, uint256 amount ) public returns (uint256 assets) { _isEligibleSender(); if (isQuote) { assets = quoteLp.redeem(amount, msg.sender, msg.sender); } else { assets = baseLp.redeem(amount, msg.sender, msg.sender); } emit Withdraw(isQuote, amount, msg.sender); return assets; } /// @notice Opens a position against/in favour of the base asset (if you short base is swapped to quote) /// @param size Size of position (quoteDecimals) /// @param timeframeIndex Position of the array /// @param margin Collateral posted by user /// @param entryLimit Minimum or maximum entry price (for short or long) function openPosition( bool isShort, uint256 size, uint256 timeframeIndex, uint256 margin, uint256 entryLimit ) public nonReentrant returns (uint256 id, uint256 entry) { _isEligibleSender(); require(timeframeIndex < timeframes.length, "Invalid timeframe"); require(margin >= minimumMargin, "Insufficient margin"); require(size <= maxSize, "Position exposure is too high"); require( size + openInterest[isShort] <= maxOpenInterest, "OI is too high" ); openInterest[isShort] += size; uint256 markPrice = getMarkPrice(); // Calculate premium for ATM option in quote uint256 premium = calcPremium( markPrice, size, timeframes[timeframeIndex] ); // Calculate opening fees in quote uint256 openingFees = calcFees(size); // We transfer margin + premium + fees from user quote.safeTransferFrom( msg.sender, address(this), margin + premium + openingFees ); uint256 swapped; if (isShort) { // base to quote swapped = _swapExactOut(address(base), address(quote), size); // size is quoteDecimals, swapped is baseDecimals // baseDecimals * quoteDecimals / (baseDecimals) = quoteDecimals entry = ((10 ** baseDecimals) * size) / swapped; require(entry >= entryLimit, "Slippage"); require( baseLp.totalAvailableAssets() >= swapped, "Insufficient liquidity" ); baseLp.lockLiquidity(swapped); } else { // quote to base require( quoteLp.totalAvailableAssets() >= size, "Insufficient liquidity" ); swapped = _swapExactIn(address(quote), address(base), size); // size is quoteDecimals, swapped is baseDecimals // baseDecimals * quoteDecimals / baseDecimals = quoteDecimals entry = ((10 ** baseDecimals) * size) / swapped; require(entry <= entryLimit, "Slippage"); quoteLp.lockLiquidity(size); } // Transfer fees to Insurance fund if (isShort) { uint256 baseOpeningFees = _swapExactIn( address(quote), address(base), openingFees ); baseLp.deposit(baseOpeningFees, insuranceFund); uint256 basePremium = _swapExactIn( address(quote), address(base), premium ); baseLp.addProceeds(basePremium); emit AddProceeds(false, basePremium); } else { quoteLp.deposit(openingFees, insuranceFund); quoteLp.addProceeds(premium); emit AddProceeds(true, premium); } // Generate scalp position NFT id = scalpPositionMinter.mint(msg.sender); scalpPositions[id] = ScalpPosition({ isOpen: true, isShort: isShort, size: size, positions: (size * (10 ** quoteDecimals)) / entry, amountBorrowed: isShort ? swapped : size, amountOut: isShort ? size : swapped, entry: entry, margin: margin, premium: premium, fees: openingFees, pnl: 0, openedAt: block.timestamp, timeframe: timeframes[timeframeIndex] }); emit OpenPosition(id, size, msg.sender); } /// @notice Closes an open position /// @param id ID of position function closePosition(uint256 id) public { _isEligibleSender(); require(scalpPositions[id].isOpen, "Invalid position ID"); require( scalpPositions[id].openedAt + 1 seconds <= block.timestamp, "Position must be open for at least 1 second" ); address owner = IERC721(scalpPositionMinter).ownerOf(id); if (!isLiquidatable(id) && msg.sender != owner) require( block.timestamp >= scalpPositions[id].openedAt + scalpPositions[id].timeframe, "Keeper can only close after expiry" ); uint256 swapped; uint256 traderWithdraw; scalpPositions[id].isOpen = false; scalpPositionMinter.burn(id); if (scalpPositions[id].isShort) { // quote to base swapped = _swapExactIn( address(quote), address(base), scalpPositions[id].amountOut + scalpPositions[id].margin ); if (swapped > scalpPositions[id].amountBorrowed) { baseLp.unlockLiquidity(scalpPositions[id].amountBorrowed); //convert remaining base to quote to pay for trader traderWithdraw = _swapExactIn( address(base), address(quote), swapped - scalpPositions[id].amountBorrowed ); quote.safeTransfer( isLiquidatable(id) ? insuranceFund : owner, traderWithdraw ); } else { baseLp.unlockLiquidity(swapped); emit Shortfall(false, scalpPositions[id].amountBorrowed - swapped); } } else { // base to quote swapped = _swapExactIn( address(base), address(quote), scalpPositions[id].amountOut ); if ( scalpPositions[id].margin + swapped > scalpPositions[id].amountBorrowed ) { quoteLp.unlockLiquidity(scalpPositions[id].amountBorrowed); traderWithdraw = scalpPositions[id].margin + swapped - scalpPositions[id].amountBorrowed; quote.safeTransfer( isLiquidatable(id) ? insuranceFund : owner, traderWithdraw ); } else { quoteLp.unlockLiquidity(scalpPositions[id].margin + swapped); emit Shortfall(true, scalpPositions[id].amountBorrowed - scalpPositions[id].margin + swapped); } } openInterest[scalpPositions[id].isShort] -= scalpPositions[id].size; int256 pnl = int256(traderWithdraw) - int256(scalpPositions[id].margin + scalpPositions[id].premium + scalpPositions[id].fees); scalpPositions[id].pnl = pnl; cumulativePnl[owner] += pnl; cumulativeVolume[owner] += scalpPositions[id].size; emit ClosePosition(id, pnl, msg.sender); } /// @notice Returns whether an open position is liquidatable function isLiquidatable(uint256 id) public view returns (bool) { return int256(scalpPositions[id].margin) + calcPnl(id) <= int256( minimumAbsoluteLiquidationThreshold * (scalpPositions[id].size / (10 ** quoteDecimals)) ); } /// @notice Get liquidation price /// @param id Identifier of the position function getLiquidationPrice( uint256 id ) public view returns (uint256 price) { if(!scalpPositions[id].isOpen) return 0; int256 threshold = int256(scalpPositions[id].margin) - int256( (minimumAbsoluteLiquidationThreshold * scalpPositions[id].size) / (10 ** quoteDecimals) ); if (scalpPositions[id].isShort) { price = scalpPositions[id].entry + (((10 ** quoteDecimals) * uint(threshold)) / scalpPositions[id].size); // (quoteDecimals) } else { price = scalpPositions[id].entry - (((10 ** quoteDecimals) * uint(threshold)) / scalpPositions[id].size); // (quoteDecimals) } } /// @notice Allow only scalp LP contract to claim collateral /// @param amount Amount of quote/base assets to transfer function claimCollateral(uint256 amount) public nonReentrant { require( msg.sender == address(quoteLp) || msg.sender == address(baseLp), "Only Scalp LP contract can claim collateral" ); if (msg.sender == address(quoteLp)) quote.safeTransfer(msg.sender, amount); else if (msg.sender == address(baseLp)) base.safeTransfer(msg.sender, amount); } /// @notice External function to return the volatility /// @param strike Strike of option function getVolatility( uint256 strike ) public view returns (uint256 volatility) { volatility = uint256(volatilityOracle.getVolatility(strike)); } /// @notice Internal function to calculate premium /// @param strike Strike of option /// @param size Amount of option function calcPremium( uint256 strike, uint256 size, uint256 timeToExpiry ) public view returns (uint256 premium) { uint256 expiry = block.timestamp + timeToExpiry; premium = ((uint256( optionPricing.getOptionPrice( false, expiry, strike, strike, getVolatility(strike) ) ) * size) / strike); // ATM options: does not matter if call or put } /// @notice Internal function to calculate fees /// @param amount Value of option in USD (ie6) function calcFees(uint256 amount) public view returns (uint256 fees) { fees = (amount * feeOpenPosition) / (100 * divisor); } /// @notice Internal function to calculate pnl /// @param id ID of position /// @dev positions is quoteDecimals, entry is quoteDecimals, markPrice is quoteDecimals, pnl is quoteDecimals function calcPnl(uint256 id) public view returns (int256 pnl) { uint256 markPrice = getMarkPrice(); if (scalpPositions[id].isShort) pnl = (int256(scalpPositions[id].positions) * (int256(scalpPositions[id].entry) - int256(markPrice))) / int256(10 ** quoteDecimals); else pnl = (int256(scalpPositions[id].positions) * (int256(markPrice) - int256(scalpPositions[id].entry))) / int256(10 ** quoteDecimals); } /// @notice Public function to retrieve price of base asset from oracle /// @param price Mark price (quoteDecimals) function getMarkPrice() public view returns (uint256 price) { price = uint256(priceOracle.getUnderlyingPrice()) / 10 ** 2; } /// @notice Returns the tokenIds owned by a wallet /// @param owner wallet owner function positionsOfOwner( address owner ) public view returns (uint256[] memory tokenIds) { uint256 ownerTokenCount = scalpPositionMinter.balanceOf(owner); tokenIds = new uint256[](ownerTokenCount); uint256 start; uint256 idx; while (start < ownerTokenCount) { uint256 tokenId = scalpPositionMinter.tokenOfOwnerByIndex( owner, idx ); tokenIds[start] = tokenId; ++start; ++idx; } } /// @notice Owner-only function to update config /// @param config Valid configuration struct function updateConfig(Configuration calldata config) public onlyOwner { maxSize = config.maxSize; maxOpenInterest = config.maxOpenInterest; optionPricing = config.optionPricing; volatilityOracle = config.volatilityOracle; priceOracle = config.priceOracle; insuranceFund = config.insuranceFund; minimumMargin = config.minimumMargin; feeOpenPosition = config.feeOpenPosition; minimumAbsoluteLiquidationThreshold = config .minimumAbsoluteLiquidationThreshold; withdrawTimeout = config.withdrawTimeout; } /// @notice Transfers all funds to msg.sender /// @dev Can only be called by the owner /// @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 onlyOwner { if (transferNative) payable(msg.sender).transfer(address(this).balance); IERC20 token; for (uint256 i; i < tokens.length; ) { token = IERC20(tokens[i]); token.safeTransfer(msg.sender, token.balanceOf(address(this))); unchecked { ++i; } } emit EmergencyWithdraw(msg.sender); } /** * @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 onlyOwner { _addToContractWhitelist(_contract); } /** * @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 removeFromContractWhitelist(address _contract) external onlyOwner { _removeFromContractWhitelist(_contract); } }
//SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.9; // Contracts import {ReentrancyGuard} from "@openzeppelin/contracts/security/ReentrancyGuard.sol"; import {ERC721} from "@openzeppelin/contracts/token/ERC721/ERC721.sol"; import {ERC721Enumerable} from "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol"; import {ERC721Burnable} from "@openzeppelin/contracts/token/ERC721/extensions/ERC721Burnable.sol"; import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol"; import {Counters} from "@openzeppelin/contracts/utils/Counters.sol"; contract ScalpPositionMinter is ReentrancyGuard, ERC721('OP-ScalpPosition', 'OPSP'), ERC721Enumerable, ERC721Burnable, Ownable { using Counters for Counters.Counter; /// @dev Token ID counter for straddle positions Counters.Counter private _tokenIdCounter; address public optionScalpContract; constructor() { optionScalpContract = msg.sender; _tokenIdCounter.increment(); } function setScalpContract(address _optionScalpContract) public onlyOwner { optionScalpContract = _optionScalpContract; } function mint(address to) public returns (uint tokenId) { require( msg.sender == optionScalpContract, "Only option scalp contract can mint an option scalp position token" ); tokenId = _tokenIdCounter.current(); _tokenIdCounter.increment(); _safeMint(to, tokenId); return tokenId; } function burn(uint256 id) public override { require( msg.sender == optionScalpContract, "Only option scalp contract can mint an option scalp position token" ); _burn(id); } // 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) returns (bool) { return super.supportsInterface(interfaceId); } }
// SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.9; // Contracts import {ERC20} from "solmate/src/tokens/ERC20.sol"; import {ERC4626} from "solmate/src/mixins/ERC4626.sol"; import {SafeTransferLib} from "solmate/src/utils/SafeTransferLib.sol"; // Libraries import {Strings} from "@openzeppelin/contracts/utils/Strings.sol"; import {OptionScalp} from '../OptionScalp.sol'; /** * @title Scalp LP Token */ contract ScalpLP is ERC4626 { using SafeTransferLib for ERC20; /// @dev The address of the scalp contract creating the lp token OptionScalp public scalp; /// @dev The address of the collateral contract for the scalp lp ERC20 public collateral; /// @dev The symbol reperesenting the underlying asset of the scalp lp string public underlyingSymbol; /// @dev The symbol representing the collateral token of the scalp lp string public collateralSymbol; // @dev Total collateral assets available uint public _totalAssets; // @dev Locked liquidity in active scalp positions uint public _lockedLiquidity; // @dev Transfer freezing after a new deposit (user -> time) mapping(address => uint256) public lockedUsers; /*==== CONSTRUCTOR ====*/ /** * @param _scalp The address of the scalp contract creating the lp token * @param _collateral The address of the collateral asset in the scalp contract * @param _collateralSymbol The symbol of the collateral asset token */ constructor( address _scalp, address _collateral, string memory _collateralSymbol ) ERC4626(ERC20(_collateral), "Scalp LP Token", "ScLP") { scalp = OptionScalp(_scalp); collateralSymbol = _collateralSymbol; symbol = concatenate(_collateralSymbol, "-LP"); } /*==== PURE FUNCTIONS ====*/ /** * @notice Returns a concatenated string of a and b * @param _a string a * @param _b string b */ function concatenate(string memory _a, string memory _b) internal pure returns (string memory) { return string(abi.encodePacked(_a, _b)); } function deposit(uint256 assets, address receiver) public virtual override returns (uint256 shares) { // Check for rounding error since we round down in previewDeposit. require((shares = previewDeposit(assets)) != 0, "ZERO_SHARES"); // Need to transfer before minting or ERC777s could reenter. asset.safeTransferFrom(msg.sender, address(this), assets); _mint(receiver, shares); lockedUsers[receiver] = block.timestamp + scalp.withdrawTimeout(); emit Deposit(msg.sender, receiver, assets, shares); afterDeposit(assets, shares); } function withdraw( uint256 assets, address receiver, address owner ) public virtual override returns (uint256 shares) { require(lockedUsers[owner] <= block.timestamp, "Cooling period"); shares = previewWithdraw(assets); // No need to check for rounding error, previewWithdraw rounds up. if (msg.sender != owner) { uint256 allowed = allowance[owner][msg.sender]; // Saves gas for limited approvals. if (allowed != type(uint256).max) allowance[owner][msg.sender] = allowed - shares; } beforeWithdraw(assets, shares); _burn(owner, shares); emit Withdraw(msg.sender, receiver, owner, assets, shares); asset.safeTransfer(receiver, assets); } function redeem( uint256 shares, address receiver, address owner ) public virtual override returns (uint256 assets) { require(lockedUsers[owner] <= block.timestamp, "Cooling period"); if (msg.sender != owner) { uint256 allowed = allowance[owner][msg.sender]; // Saves gas for limited approvals. if (allowed != type(uint256).max) allowance[owner][msg.sender] = allowed - shares; } // Check for rounding error since we round down in previewRedeem. require((assets = previewRedeem(shares)) != 0, "ZERO_ASSETS"); beforeWithdraw(assets, shares); _burn(owner, shares); emit Withdraw(msg.sender, receiver, owner, assets, shares); asset.safeTransfer(receiver, assets); } function _beforeTokenTransfer(address from, address, uint256) internal virtual { require(lockedUsers[from] <= block.timestamp, "Cooling period"); } function totalAssets() public view virtual override returns (uint) { return _totalAssets; } function totalAvailableAssets() public view returns (uint) { return _totalAssets - _lockedLiquidity; } function lockLiquidity(uint amount) public { require(msg.sender == address(scalp), "Only scalp can call this function"); _lockedLiquidity += amount; } function unlockLiquidity(uint amount) public { require(msg.sender == address(scalp), "Only scalp can call this function"); _lockedLiquidity -= amount; } // Adds premium and fees to total available assets function addProceeds(uint proceeds) public { require(msg.sender == address(scalp), "Only scalp can call this function"); _totalAssets += proceeds; } function beforeWithdraw(uint256 assets, uint256 /*shares*/ ) internal virtual override { require(assets <= totalAvailableAssets(), "Not enough available assets to satisfy withdrawal"); /// ----------------------------------------------------------------------- /// Withdraw assets from Scalp contract /// ----------------------------------------------------------------------- scalp.claimCollateral(assets); _totalAssets -= assets; } function afterDeposit(uint256 assets, uint256 /*shares*/ ) internal virtual override { /// ----------------------------------------------------------------------- /// Deposit assets into Scalp contract /// ----------------------------------------------------------------------- _totalAssets += assets; // approve to scalp asset.safeApprove(address(scalp), assets); // deposit into scalp asset.safeTransfer(address(scalp), assets); } }
// SPDX-License-Identifier: AGPL-3.0-only pragma solidity >=0.8.0; import {ERC20} from "../tokens/ERC20.sol"; import {SafeTransferLib} from "../utils/SafeTransferLib.sol"; import {FixedPointMathLib} from "../utils/FixedPointMathLib.sol"; /// @notice Minimal ERC4626 tokenized Vault implementation. /// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/mixins/ERC4626.sol) abstract contract ERC4626 is ERC20 { using SafeTransferLib for ERC20; using FixedPointMathLib for uint256; /*////////////////////////////////////////////////////////////// EVENTS //////////////////////////////////////////////////////////////*/ event Deposit(address indexed caller, address indexed owner, uint256 assets, uint256 shares); event Withdraw( address indexed caller, address indexed receiver, address indexed owner, uint256 assets, uint256 shares ); /*////////////////////////////////////////////////////////////// IMMUTABLES //////////////////////////////////////////////////////////////*/ ERC20 public immutable asset; constructor( ERC20 _asset, string memory _name, string memory _symbol ) ERC20(_name, _symbol, _asset.decimals()) { asset = _asset; } /*////////////////////////////////////////////////////////////// DEPOSIT/WITHDRAWAL LOGIC //////////////////////////////////////////////////////////////*/ function deposit(uint256 assets, address receiver) public virtual returns (uint256 shares) { // Check for rounding error since we round down in previewDeposit. require((shares = previewDeposit(assets)) != 0, "ZERO_SHARES"); // Need to transfer before minting or ERC777s could reenter. asset.safeTransferFrom(msg.sender, address(this), assets); _mint(receiver, shares); emit Deposit(msg.sender, receiver, assets, shares); afterDeposit(assets, shares); } function mint(uint256 shares, address receiver) public virtual returns (uint256 assets) { assets = previewMint(shares); // No need to check for rounding error, previewMint rounds up. // Need to transfer before minting or ERC777s could reenter. asset.safeTransferFrom(msg.sender, address(this), assets); _mint(receiver, shares); emit Deposit(msg.sender, receiver, assets, shares); afterDeposit(assets, shares); } function withdraw( uint256 assets, address receiver, address owner ) public virtual returns (uint256 shares) { shares = previewWithdraw(assets); // No need to check for rounding error, previewWithdraw rounds up. if (msg.sender != owner) { uint256 allowed = allowance[owner][msg.sender]; // Saves gas for limited approvals. if (allowed != type(uint256).max) allowance[owner][msg.sender] = allowed - shares; } beforeWithdraw(assets, shares); _burn(owner, shares); emit Withdraw(msg.sender, receiver, owner, assets, shares); asset.safeTransfer(receiver, assets); } function redeem( uint256 shares, address receiver, address owner ) public virtual returns (uint256 assets) { if (msg.sender != owner) { uint256 allowed = allowance[owner][msg.sender]; // Saves gas for limited approvals. if (allowed != type(uint256).max) allowance[owner][msg.sender] = allowed - shares; } // Check for rounding error since we round down in previewRedeem. require((assets = previewRedeem(shares)) != 0, "ZERO_ASSETS"); beforeWithdraw(assets, shares); _burn(owner, shares); emit Withdraw(msg.sender, receiver, owner, assets, shares); asset.safeTransfer(receiver, assets); } /*////////////////////////////////////////////////////////////// ACCOUNTING LOGIC //////////////////////////////////////////////////////////////*/ function totalAssets() public view virtual returns (uint256); function convertToShares(uint256 assets) public view virtual returns (uint256) { uint256 supply = totalSupply; // Saves an extra SLOAD if totalSupply is non-zero. return supply == 0 ? assets : assets.mulDivDown(supply, totalAssets()); } function convertToAssets(uint256 shares) public view virtual returns (uint256) { uint256 supply = totalSupply; // Saves an extra SLOAD if totalSupply is non-zero. return supply == 0 ? shares : shares.mulDivDown(totalAssets(), supply); } function previewDeposit(uint256 assets) public view virtual returns (uint256) { return convertToShares(assets); } function previewMint(uint256 shares) public view virtual returns (uint256) { uint256 supply = totalSupply; // Saves an extra SLOAD if totalSupply is non-zero. return supply == 0 ? shares : shares.mulDivUp(totalAssets(), supply); } function previewWithdraw(uint256 assets) public view virtual returns (uint256) { uint256 supply = totalSupply; // Saves an extra SLOAD if totalSupply is non-zero. return supply == 0 ? assets : assets.mulDivUp(supply, totalAssets()); } function previewRedeem(uint256 shares) public view virtual returns (uint256) { return convertToAssets(shares); } /*////////////////////////////////////////////////////////////// DEPOSIT/WITHDRAWAL LIMIT LOGIC //////////////////////////////////////////////////////////////*/ function maxDeposit(address) public view virtual returns (uint256) { return type(uint256).max; } function maxMint(address) public view virtual returns (uint256) { return type(uint256).max; } function maxWithdraw(address owner) public view virtual returns (uint256) { return convertToAssets(balanceOf[owner]); } function maxRedeem(address owner) public view virtual returns (uint256) { return balanceOf[owner]; } /*////////////////////////////////////////////////////////////// INTERNAL HOOKS LOGIC //////////////////////////////////////////////////////////////*/ function beforeWithdraw(uint256 assets, uint256 shares) internal virtual {} function afterDeposit(uint256 assets, uint256 shares) internal virtual {} }
// SPDX-License-Identifier: AGPL-3.0-only pragma solidity >=0.8.0; /// @notice Modern and gas efficient ERC20 + EIP-2612 implementation. /// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/tokens/ERC20.sol) /// @author Modified from Uniswap (https://github.com/Uniswap/uniswap-v2-core/blob/master/contracts/UniswapV2ERC20.sol) /// @dev Do not manually set balances without updating totalSupply, as the sum of all user balances must not exceed it. abstract contract ERC20 { /*////////////////////////////////////////////////////////////// EVENTS //////////////////////////////////////////////////////////////*/ event Transfer(address indexed from, address indexed to, uint256 amount); event Approval(address indexed owner, address indexed spender, uint256 amount); /*////////////////////////////////////////////////////////////// METADATA STORAGE //////////////////////////////////////////////////////////////*/ string public name; string public symbol; uint8 public immutable decimals; /*////////////////////////////////////////////////////////////// ERC20 STORAGE //////////////////////////////////////////////////////////////*/ uint256 public totalSupply; mapping(address => uint256) public balanceOf; mapping(address => mapping(address => uint256)) public allowance; /*////////////////////////////////////////////////////////////// EIP-2612 STORAGE //////////////////////////////////////////////////////////////*/ uint256 internal immutable INITIAL_CHAIN_ID; bytes32 internal immutable INITIAL_DOMAIN_SEPARATOR; mapping(address => uint256) public nonces; /*////////////////////////////////////////////////////////////// CONSTRUCTOR //////////////////////////////////////////////////////////////*/ constructor( string memory _name, string memory _symbol, uint8 _decimals ) { name = _name; symbol = _symbol; decimals = _decimals; INITIAL_CHAIN_ID = block.chainid; INITIAL_DOMAIN_SEPARATOR = computeDomainSeparator(); } /*////////////////////////////////////////////////////////////// ERC20 LOGIC //////////////////////////////////////////////////////////////*/ function approve(address spender, uint256 amount) public virtual returns (bool) { allowance[msg.sender][spender] = amount; emit Approval(msg.sender, spender, amount); return true; } function transfer(address to, uint256 amount) public virtual returns (bool) { balanceOf[msg.sender] -= amount; // Cannot overflow because the sum of all user // balances can't exceed the max uint256 value. unchecked { balanceOf[to] += amount; } emit Transfer(msg.sender, to, amount); return true; } function transferFrom( address from, address to, uint256 amount ) public virtual returns (bool) { uint256 allowed = allowance[from][msg.sender]; // Saves gas for limited approvals. if (allowed != type(uint256).max) allowance[from][msg.sender] = allowed - amount; balanceOf[from] -= amount; // Cannot overflow because the sum of all user // balances can't exceed the max uint256 value. unchecked { balanceOf[to] += amount; } emit Transfer(from, to, amount); return true; } /*////////////////////////////////////////////////////////////// EIP-2612 LOGIC //////////////////////////////////////////////////////////////*/ function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) public virtual { require(deadline >= block.timestamp, "PERMIT_DEADLINE_EXPIRED"); // Unchecked because the only math done is incrementing // the owner's nonce which cannot realistically overflow. unchecked { address recoveredAddress = ecrecover( keccak256( abi.encodePacked( "\x19\x01", DOMAIN_SEPARATOR(), keccak256( abi.encode( keccak256( "Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)" ), owner, spender, value, nonces[owner]++, deadline ) ) ) ), v, r, s ); require(recoveredAddress != address(0) && recoveredAddress == owner, "INVALID_SIGNER"); allowance[recoveredAddress][spender] = value; } emit Approval(owner, spender, value); } function DOMAIN_SEPARATOR() public view virtual returns (bytes32) { return block.chainid == INITIAL_CHAIN_ID ? INITIAL_DOMAIN_SEPARATOR : computeDomainSeparator(); } function computeDomainSeparator() internal view virtual returns (bytes32) { return keccak256( abi.encode( keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"), keccak256(bytes(name)), keccak256("1"), block.chainid, address(this) ) ); } /*////////////////////////////////////////////////////////////// INTERNAL MINT/BURN LOGIC //////////////////////////////////////////////////////////////*/ function _mint(address to, uint256 amount) internal virtual { totalSupply += amount; // Cannot overflow because the sum of all user // balances can't exceed the max uint256 value. unchecked { balanceOf[to] += amount; } emit Transfer(address(0), to, amount); } function _burn(address from, uint256 amount) internal virtual { balanceOf[from] -= amount; // Cannot underflow because a user's balance // will never be larger than the total supply. unchecked { totalSupply -= amount; } emit Transfer(from, address(0), amount); } }
// SPDX-License-Identifier: AGPL-3.0-only pragma solidity >=0.8.0; /// @notice Arithmetic library with operations for fixed-point numbers. /// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/utils/FixedPointMathLib.sol) /// @author Inspired by USM (https://github.com/usmfum/USM/blob/master/contracts/WadMath.sol) library FixedPointMathLib { /*////////////////////////////////////////////////////////////// SIMPLIFIED FIXED POINT OPERATIONS //////////////////////////////////////////////////////////////*/ uint256 internal constant WAD = 1e18; // The scalar of ETH and most ERC20s. function mulWadDown(uint256 x, uint256 y) internal pure returns (uint256) { return mulDivDown(x, y, WAD); // Equivalent to (x * y) / WAD rounded down. } function mulWadUp(uint256 x, uint256 y) internal pure returns (uint256) { return mulDivUp(x, y, WAD); // Equivalent to (x * y) / WAD rounded up. } function divWadDown(uint256 x, uint256 y) internal pure returns (uint256) { return mulDivDown(x, WAD, y); // Equivalent to (x * WAD) / y rounded down. } function divWadUp(uint256 x, uint256 y) internal pure returns (uint256) { return mulDivUp(x, WAD, y); // Equivalent to (x * WAD) / y rounded up. } /*////////////////////////////////////////////////////////////// LOW LEVEL FIXED POINT OPERATIONS //////////////////////////////////////////////////////////////*/ function mulDivDown( uint256 x, uint256 y, uint256 denominator ) internal pure returns (uint256 z) { assembly { // Store x * y in z for now. z := mul(x, y) // Equivalent to require(denominator != 0 && (x == 0 || (x * y) / x == y)) if iszero(and(iszero(iszero(denominator)), or(iszero(x), eq(div(z, x), y)))) { revert(0, 0) } // Divide z by the denominator. z := div(z, denominator) } } function mulDivUp( uint256 x, uint256 y, uint256 denominator ) internal pure returns (uint256 z) { assembly { // Store x * y in z for now. z := mul(x, y) // Equivalent to require(denominator != 0 && (x == 0 || (x * y) / x == y)) if iszero(and(iszero(iszero(denominator)), or(iszero(x), eq(div(z, x), y)))) { revert(0, 0) } // First, divide z - 1 by the denominator and add 1. // We allow z - 1 to underflow if z is 0, because we multiply the // end result by 0 if z is zero, ensuring we return 0 if z is zero. z := mul(iszero(iszero(z)), add(div(sub(z, 1), denominator), 1)) } } function rpow( uint256 x, uint256 n, uint256 scalar ) internal pure returns (uint256 z) { assembly { switch x case 0 { switch n case 0 { // 0 ** 0 = 1 z := scalar } default { // 0 ** n = 0 z := 0 } } default { switch mod(n, 2) case 0 { // If n is even, store scalar in z for now. z := scalar } default { // If n is odd, store x in z for now. z := x } // Shifting right by 1 is like dividing by 2. let half := shr(1, scalar) for { // Shift n right by 1 before looping to halve it. n := shr(1, n) } n { // Shift n right by 1 each iteration to halve it. n := shr(1, n) } { // Revert immediately if x ** 2 would overflow. // Equivalent to iszero(eq(div(xx, x), x)) here. if shr(128, x) { revert(0, 0) } // Store x squared. let xx := mul(x, x) // Round to the nearest number. let xxRound := add(xx, half) // Revert if xx + half overflowed. if lt(xxRound, xx) { revert(0, 0) } // Set x to scaled xxRound. x := div(xxRound, scalar) // If n is even: if mod(n, 2) { // Compute z * x. let zx := mul(z, x) // If z * x overflowed: if iszero(eq(div(zx, x), z)) { // Revert if x is non-zero. if iszero(iszero(x)) { revert(0, 0) } } // Round to the nearest number. let zxRound := add(zx, half) // Revert if zx + half overflowed. if lt(zxRound, zx) { revert(0, 0) } // Return properly scaled zxRound. z := div(zxRound, scalar) } } } } } /*////////////////////////////////////////////////////////////// GENERAL NUMBER UTILITIES //////////////////////////////////////////////////////////////*/ function sqrt(uint256 x) internal pure returns (uint256 z) { assembly { // Start off with z at 1. z := 1 // Used below to help find a nearby power of 2. let y := x // Find the lowest power of 2 that is at least sqrt(x). if iszero(lt(y, 0x100000000000000000000000000000000)) { y := shr(128, y) // Like dividing by 2 ** 128. z := shl(64, z) // Like multiplying by 2 ** 64. } if iszero(lt(y, 0x10000000000000000)) { y := shr(64, y) // Like dividing by 2 ** 64. z := shl(32, z) // Like multiplying by 2 ** 32. } if iszero(lt(y, 0x100000000)) { y := shr(32, y) // Like dividing by 2 ** 32. z := shl(16, z) // Like multiplying by 2 ** 16. } if iszero(lt(y, 0x10000)) { y := shr(16, y) // Like dividing by 2 ** 16. z := shl(8, z) // Like multiplying by 2 ** 8. } if iszero(lt(y, 0x100)) { y := shr(8, y) // Like dividing by 2 ** 8. z := shl(4, z) // Like multiplying by 2 ** 4. } if iszero(lt(y, 0x10)) { y := shr(4, y) // Like dividing by 2 ** 4. z := shl(2, z) // Like multiplying by 2 ** 2. } if iszero(lt(y, 0x8)) { // Equivalent to 2 ** z. z := shl(1, z) } // Shifting right by 1 is like dividing by 2. z := shr(1, add(z, div(x, z))) z := shr(1, add(z, div(x, z))) z := shr(1, add(z, div(x, z))) z := shr(1, add(z, div(x, z))) z := shr(1, add(z, div(x, z))) z := shr(1, add(z, div(x, z))) z := shr(1, add(z, div(x, z))) // Compute a rounded down version of z. let zRoundDown := div(x, z) // If zRoundDown is smaller, use it. if lt(zRoundDown, z) { z := zRoundDown } } } function unsafeMod(uint256 x, uint256 y) internal pure returns (uint256 z) { assembly { // Mod x by y. Note this will return // 0 instead of reverting if y is zero. z := mod(x, y) } } function unsafeDiv(uint256 x, uint256 y) internal pure returns (uint256 r) { assembly { // Divide x by y. Note this will return // 0 instead of reverting if y is zero. r := div(x, y) } } function unsafeDivUp(uint256 x, uint256 y) internal pure returns (uint256 z) { assembly { // Add 1 to x * y if x % y > 0. Note this will // return 0 instead of reverting if y is zero. z := add(gt(mod(x, y), 0), div(x, y)) } } }
// SPDX-License-Identifier: AGPL-3.0-only pragma solidity >=0.8.0; import {ERC20} from "../tokens/ERC20.sol"; /// @notice Safe ETH and ERC20 transfer library that gracefully handles missing return values. /// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/utils/SafeTransferLib.sol) /// @dev Use with caution! Some functions in this library knowingly create dirty bits at the destination of the free memory pointer. /// @dev Note that none of the functions in this library check that a token has code at all! That responsibility is delegated to the caller. library SafeTransferLib { /*////////////////////////////////////////////////////////////// ETH OPERATIONS //////////////////////////////////////////////////////////////*/ function safeTransferETH(address to, uint256 amount) internal { bool success; assembly { // Transfer the ETH and store if it succeeded or not. success := call(gas(), to, amount, 0, 0, 0, 0) } require(success, "ETH_TRANSFER_FAILED"); } /*////////////////////////////////////////////////////////////// ERC20 OPERATIONS //////////////////////////////////////////////////////////////*/ function safeTransferFrom( ERC20 token, address from, address to, uint256 amount ) internal { bool success; assembly { // Get a pointer to some free memory. let freeMemoryPointer := mload(0x40) // Write the abi-encoded calldata into memory, beginning with the function selector. mstore(freeMemoryPointer, 0x23b872dd00000000000000000000000000000000000000000000000000000000) mstore(add(freeMemoryPointer, 4), from) // Append the "from" argument. mstore(add(freeMemoryPointer, 36), to) // Append the "to" argument. mstore(add(freeMemoryPointer, 68), amount) // Append the "amount" argument. success := and( // Set success to whether the call reverted, if not we check it either // returned exactly 1 (can't just be non-zero data), or had no return data. or(and(eq(mload(0), 1), gt(returndatasize(), 31)), iszero(returndatasize())), // We use 100 because the length of our calldata totals up like so: 4 + 32 * 3. // We use 0 and 32 to copy up to 32 bytes of return data into the scratch space. // Counterintuitively, this call must be positioned second to the or() call in the // surrounding and() call or else returndatasize() will be zero during the computation. call(gas(), token, 0, freeMemoryPointer, 100, 0, 32) ) } require(success, "TRANSFER_FROM_FAILED"); } function safeTransfer( ERC20 token, address to, uint256 amount ) internal { bool success; assembly { // Get a pointer to some free memory. let freeMemoryPointer := mload(0x40) // Write the abi-encoded calldata into memory, beginning with the function selector. mstore(freeMemoryPointer, 0xa9059cbb00000000000000000000000000000000000000000000000000000000) mstore(add(freeMemoryPointer, 4), to) // Append the "to" argument. mstore(add(freeMemoryPointer, 36), amount) // Append the "amount" argument. success := and( // Set success to whether the call reverted, if not we check it either // returned exactly 1 (can't just be non-zero data), or had no return data. or(and(eq(mload(0), 1), gt(returndatasize(), 31)), iszero(returndatasize())), // We use 68 because the length of our calldata totals up like so: 4 + 32 * 2. // We use 0 and 32 to copy up to 32 bytes of return data into the scratch space. // Counterintuitively, this call must be positioned second to the or() call in the // surrounding and() call or else returndatasize() will be zero during the computation. call(gas(), token, 0, freeMemoryPointer, 68, 0, 32) ) } require(success, "TRANSFER_FAILED"); } function safeApprove( ERC20 token, address to, uint256 amount ) internal { bool success; assembly { // Get a pointer to some free memory. let freeMemoryPointer := mload(0x40) // Write the abi-encoded calldata into memory, beginning with the function selector. mstore(freeMemoryPointer, 0x095ea7b300000000000000000000000000000000000000000000000000000000) mstore(add(freeMemoryPointer, 4), to) // Append the "to" argument. mstore(add(freeMemoryPointer, 36), amount) // Append the "amount" argument. success := and( // Set success to whether the call reverted, if not we check it either // returned exactly 1 (can't just be non-zero data), or had no return data. or(and(eq(mload(0), 1), gt(returndatasize(), 31)), iszero(returndatasize())), // We use 68 because the length of our calldata totals up like so: 4 + 32 * 2. // We use 0 and 32 to copy up to 32 bytes of return data into the scratch space. // Counterintuitively, this call must be positioned second to the or() call in the // surrounding and() call or else returndatasize() will be zero during the computation. call(gas(), token, 0, freeMemoryPointer, 68, 0, 32) ) } require(success, "APPROVE_FAILED"); } }
{ "optimizer": { "enabled": true, "runs": 5000 }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "metadata": { "useLiteralContent": true }, "libraries": {} }
[{"inputs":[{"internalType":"address","name":"_base","type":"address"},{"internalType":"address","name":"_quote","type":"address"},{"internalType":"uint256","name":"_baseDecimals","type":"uint256"},{"internalType":"uint256","name":"_quoteDecimals","type":"uint256"},{"internalType":"address","name":"_uniswapV3Router","type":"address"},{"components":[{"internalType":"uint256","name":"maxSize","type":"uint256"},{"internalType":"uint256","name":"maxOpenInterest","type":"uint256"},{"internalType":"contract IOptionPricing","name":"optionPricing","type":"address"},{"internalType":"contract IVolatilityOracle","name":"volatilityOracle","type":"address"},{"internalType":"contract IPriceOracle","name":"priceOracle","type":"address"},{"internalType":"address","name":"insuranceFund","type":"address"},{"internalType":"uint256","name":"minimumMargin","type":"uint256"},{"internalType":"uint256","name":"feeOpenPosition","type":"uint256"},{"internalType":"uint256","name":"minimumAbsoluteLiquidationThreshold","type":"uint256"},{"internalType":"uint256","name":"withdrawTimeout","type":"uint256"}],"internalType":"struct OptionScalp.Configuration","name":"config","type":"tuple"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"ContractNotPaused","type":"error"},{"inputs":[],"name":"ContractPaused","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bool","name":"isQuote","type":"bool"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"AddProceeds","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_contract","type":"address"}],"name":"AddToContractWhitelist","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"id","type":"uint256"},{"indexed":false,"internalType":"int256","name":"pnl","type":"int256"},{"indexed":true,"internalType":"address","name":"user","type":"address"}],"name":"ClosePosition","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bool","name":"isQuote","type":"bool"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"Deposit","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"receiver","type":"address"}],"name":"EmergencyWithdraw","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"id","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"size","type":"uint256"},{"indexed":true,"internalType":"address","name":"user","type":"address"}],"name":"OpenPosition","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_contract","type":"address"}],"name":"RemoveFromContractWhitelist","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bool","name":"isQuote","type":"bool"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Shortfall","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bool","name":"isQuote","type":"bool"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"Withdraw","type":"event"},{"inputs":[{"internalType":"address","name":"_contract","type":"address"}],"name":"addToContractWhitelist","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"base","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"baseDecimals","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"baseLp","outputs":[{"internalType":"contract ScalpLP","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"calcFees","outputs":[{"internalType":"uint256","name":"fees","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"id","type":"uint256"}],"name":"calcPnl","outputs":[{"internalType":"int256","name":"pnl","type":"int256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"strike","type":"uint256"},{"internalType":"uint256","name":"size","type":"uint256"},{"internalType":"uint256","name":"timeToExpiry","type":"uint256"}],"name":"calcPremium","outputs":[{"internalType":"uint256","name":"premium","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"claimCollateral","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"id","type":"uint256"}],"name":"closePosition","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"cumulativePnl","outputs":[{"internalType":"int256","name":"","type":"int256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"cumulativeVolume","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"receiver","type":"address"},{"internalType":"bool","name":"isQuote","type":"bool"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"deposit","outputs":[{"internalType":"uint256","name":"shares","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"divisor","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address[]","name":"tokens","type":"address[]"},{"internalType":"bool","name":"transferNative","type":"bool"}],"name":"emergencyWithdraw","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"feeOpenPosition","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"id","type":"uint256"}],"name":"getLiquidationPrice","outputs":[{"internalType":"uint256","name":"price","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getMarkPrice","outputs":[{"internalType":"uint256","name":"price","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"strike","type":"uint256"}],"name":"getVolatility","outputs":[{"internalType":"uint256","name":"volatility","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"insuranceFund","outputs":[{"internalType":"address","name":"","type":"address"}],"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":"id","type":"uint256"}],"name":"isLiquidatable","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxOpenInterest","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxSize","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"minimumAbsoluteLiquidationThreshold","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"minimumMargin","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"","type":"bool"}],"name":"openInterest","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"isShort","type":"bool"},{"internalType":"uint256","name":"size","type":"uint256"},{"internalType":"uint256","name":"timeframeIndex","type":"uint256"},{"internalType":"uint256","name":"margin","type":"uint256"},{"internalType":"uint256","name":"entryLimit","type":"uint256"}],"name":"openPosition","outputs":[{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"uint256","name":"entry","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"optionPricing","outputs":[{"internalType":"contract IOptionPricing","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"positionsOfOwner","outputs":[{"internalType":"uint256[]","name":"tokenIds","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"priceOracle","outputs":[{"internalType":"contract IPriceOracle","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"quote","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"quoteDecimals","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"quoteLp","outputs":[{"internalType":"contract ScalpLP","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_contract","type":"address"}],"name":"removeFromContractWhitelist","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"scalpPositionMinter","outputs":[{"internalType":"contract ScalpPositionMinter","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"scalpPositions","outputs":[{"internalType":"bool","name":"isOpen","type":"bool"},{"internalType":"bool","name":"isShort","type":"bool"},{"internalType":"uint256","name":"size","type":"uint256"},{"internalType":"uint256","name":"positions","type":"uint256"},{"internalType":"uint256","name":"amountBorrowed","type":"uint256"},{"internalType":"uint256","name":"amountOut","type":"uint256"},{"internalType":"uint256","name":"entry","type":"uint256"},{"internalType":"uint256","name":"margin","type":"uint256"},{"internalType":"uint256","name":"premium","type":"uint256"},{"internalType":"uint256","name":"fees","type":"uint256"},{"internalType":"int256","name":"pnl","type":"int256"},{"internalType":"uint256","name":"openedAt","type":"uint256"},{"internalType":"uint256","name":"timeframe","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"timeframes","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"uniswapV3Router","outputs":[{"internalType":"contract IUniswapV3Router","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"maxSize","type":"uint256"},{"internalType":"uint256","name":"maxOpenInterest","type":"uint256"},{"internalType":"contract IOptionPricing","name":"optionPricing","type":"address"},{"internalType":"contract IVolatilityOracle","name":"volatilityOracle","type":"address"},{"internalType":"contract IPriceOracle","name":"priceOracle","type":"address"},{"internalType":"address","name":"insuranceFund","type":"address"},{"internalType":"uint256","name":"minimumMargin","type":"uint256"},{"internalType":"uint256","name":"feeOpenPosition","type":"uint256"},{"internalType":"uint256","name":"minimumAbsoluteLiquidationThreshold","type":"uint256"},{"internalType":"uint256","name":"withdrawTimeout","type":"uint256"}],"internalType":"struct OptionScalp.Configuration","name":"config","type":"tuple"}],"name":"updateConfig","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"volatilityOracle","outputs":[{"internalType":"contract IVolatilityOracle","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"whitelistedContracts","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"isQuote","type":"bool"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"withdraw","outputs":[{"internalType":"uint256","name":"assets","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"withdrawTimeout","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"}]
Contract Creation Code
610120604052603c608090815261012c60a05261038460c05261070860e052610e10610100526200003590600e90600562000671565b503480156200004357600080fd5b50604051620089fd380380620089fd833981016040819052620000669162000767565b620000713362000621565b6000805460ff60a01b19169055600180556001600160a01b038616620000d35760405162461bcd60e51b815260206004820152601260248201527124b73b30b634b2103130b9b2903a37b5b2b760711b60448201526064015b60405180910390fd5b6001600160a01b0385166200012b5760405162461bcd60e51b815260206004820152601360248201527f496e76616c69642071756f746520746f6b656e000000000000000000000000006044820152606401620000ca565b600380546001600160a01b03199081166001600160a01b038981169190911790925560048054821688841617905560058690556006859055600d80548216858416179055825160135560208301516014556040808401516009805484169185169190911790556060840151600a805484169185169190911790556080840151600b8054841691851691909117905560a0840151600f8054909316931692909217905560c082015160105560e082015160115561010082015160125561012082015160185551620001fb90620006c7565b604051809103906000f08015801562000218573d6000803e3d6000fd5b50600c80546001600160a01b0319166001600160a01b03928316179055600354600d5460405163095ea7b360e01b81529083166004820152600019602482015291169063095ea7b390604401602060405180830381600087803b1580156200027f57600080fd5b505af115801562000294573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620002ba919062000883565b5060048054600d5460405163095ea7b360e01b81526001600160a01b03918216938101939093526000196024840152169063095ea7b390604401602060405180830381600087803b1580156200030f57600080fd5b505af115801562000324573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200034a919062000883565b5060048054604080516395d89b4160e01b8152905130936001600160a01b039093169283926395d89b419281830192600092829003018186803b1580156200039157600080fd5b505afa158015620003a6573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052620003d09190810190620008e1565b604051620003de90620006d5565b620003ec9392919062000999565b604051809103906000f08015801562000409573d6000803e3d6000fd5b50600880546001600160a01b0319166001600160a01b03928316179055600354604080516395d89b4160e01b815290513093929092169182916395d89b41916004808301926000929190829003018186803b1580156200046857600080fd5b505afa1580156200047d573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052620004a79190810190620008e1565b604051620004b590620006d5565b620004c39392919062000999565b604051809103906000f080158015620004e0573d6000803e3d6000fd5b50600780546001600160a01b0319166001600160a01b039283161790556004805460085460405163095ea7b360e01b81529084169281019290925260001960248301529091169063095ea7b390604401602060405180830381600087803b1580156200054b57600080fd5b505af115801562000560573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000586919062000883565b5060035460075460405163095ea7b360e01b81526001600160a01b039182166004820152600019602482015291169063095ea7b390604401602060405180830381600087803b158015620005d957600080fd5b505af1158015620005ee573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000614919062000883565b50505050505050620009e8565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b828054828255906000526020600020908101928215620006b5579160200282015b82811115620006b5578251829061ffff1690559160200191906001019062000692565b50620006c3929150620006e3565b5090565b6123a780620043c183390190565b612295806200676883390190565b5b80821115620006c35760008155600101620006e4565b6001600160a01b03811681146200071057600080fd5b50565b80516200072081620006fa565b919050565b634e487b7160e01b600052604160045260246000fd5b60405161014081016001600160401b038111828210171562000761576200076162000725565b60405290565b6000806000806000808688036101e08112156200078357600080fd5b87516200079081620006fa565b6020890151909750620007a381620006fa565b8096505060408801519450606088015193506080880151620007c581620006fa565b9250610140609f198201811315620007dc57600080fd5b620007e66200073b565b915060a0890151825260c089015160208301526200080760e08a0162000713565b60408301526101006200081c818b0162000713565b606084015261012062000831818c0162000713565b608085015262000843838c0162000713565b60a08501526101608b015160c08501526101808b015160e08501526101a08b0151828501526101c08b015181850152505050809150509295509295509295565b6000602082840312156200089657600080fd5b81518015158114620008a757600080fd5b9392505050565b60005b83811015620008cb578181015183820152602001620008b1565b83811115620008db576000848401525b50505050565b600060208284031215620008f457600080fd5b81516001600160401b03808211156200090c57600080fd5b818401915084601f8301126200092157600080fd5b81518181111562000936576200093662000725565b604051601f8201601f19908116603f0116810190838211818310171562000961576200096162000725565b816040528281528760208487010111156200097b57600080fd5b6200098e836020830160208801620008ae565b979650505050505050565b600060018060a01b038086168352808516602084015250606060408301528251806060840152620009d2816080850160208701620008ae565b601f01601f191691909101608001949350505050565b6139c980620009f86000396000f3fe608060405234801561001057600080fd5b50600436106103155760003560e01c80637d38100f116101a7578063bfc0ecb9116100ee578063c9959ddb11610097578063dc6638f411610071578063dc6638f414610758578063f25f688814610761578063f2fde38b1461077457600080fd5b8063c9959ddb14610712578063cc813e4e14610725578063d81ce7451461073857600080fd5b8063c3d9ed39116100c8578063c3d9ed39146106c4578063c4845139146106d7578063c49785b4146106ff57600080fd5b8063bfc0ecb914610671578063c189c19b14610691578063c3211857146106a457600080fd5b806399b9056311610150578063acc3a0061161012a578063acc3a00614610638578063b40389be1461064b578063b79023031461065e57600080fd5b806399b90563146106095780639c15d1a21461061c578063a126d6011461062557600080fd5b806396213df71161018157806396213df7146105da578063984c0450146105e3578063999b93af146105f657600080fd5b80637d38100f146105965780638da5cb5b146105b65780638eecd7a2146105c757600080fd5b806333f761781161026b57806355b13a4f116102145780636239277c116101ee5780636239277c14610566578063715018a6146105795780637c4b52cb1461058357600080fd5b806355b13a4f146105285780635c975abb1461053b578063604096321461055e57600080fd5b80634380dd3b116102455780634380dd3b146104ef5780635001f3b5146105025780635099b78d1461051557600080fd5b806333f76178146104ba578063391feebb146104c35780633fd1e2bd146104e657600080fd5b80631f2dc5ef116102cd5780632630c12f116102a75780632630c12f146104815780632c76d7a6146104945780632c854f23146104a757600080fd5b80631f2dc5ef1461045a578063211a4443146104655780632565b1591461047857600080fd5b806316279055116102fe578063162790551461040257806318d8c30b146104265780631e3394fb1461042f57600080fd5b806305c0608c1461031a5780630f0189ce14610336575b600080fd5b61032360105481565b6040519081526020015b60405180910390f35b61039e6103443660046131f2565b601960205260009081526040902080546001820154600283015460038401546004850154600586015460068701546007880154600889015460098a0154600a8b0154600b909b015460ff808c169c610100909c04169a908d565b604080519d15158e529b151560208e01529a8c019990995260608b019790975260808a019590955260a089019390935260c088019190915260e08701526101008601526101208501526101408401526101608301526101808201526101a00161032d565b610416610410366004613220565b3b151590565b604051901515815260200161032d565b61032360125481565b600954610442906001600160a01b031681565b6040516001600160a01b03909116815260200161032d565b6103236305f5e10081565b6104166104733660046131f2565b610787565b61032360135481565b600b54610442906001600160a01b031681565b600d54610442906001600160a01b031681565b6103236104b53660046131f2565b6107ee565b61032360055481565b6104166104d1366004613220565b60026020526000908152604090205460ff1681565b61032360065481565b600754610442906001600160a01b031681565b600354610442906001600160a01b031681565b6103236105233660046131f2565b610935565b600a54610442906001600160a01b031681565b60005474010000000000000000000000000000000000000000900460ff16610416565b610323610956565b6103236105743660046131f2565b6109ef565b610581610a1d565b005b61058161059136600461324b565b610a31565b6103236105a43660046132d1565b60156020526000908152604090205481565b6000546001600160a01b0316610442565b600854610442906001600160a01b031681565b61032360115481565b6103236105f13660046132ee565b610b84565b600454610442906001600160a01b031681565b61032361061736600461331a565b610d29565b61032360185481565b6105816106333660046131f2565b610f06565b610581610646366004613220565b611786565b600c54610442906001600160a01b031681565b600f54610442906001600160a01b031681565b61032361067f366004613220565b60166020526000908152604090205481565b61032361069f3660046131f2565b61179a565b6103236106b2366004613220565b60176020526000908152604090205481565b6105816106d2366004613220565b611830565b6106ea6106e536600461335b565b611841565b6040805192835260208301919091520161032d565b61058161070d3660046131f2565b6123b9565b61032361072036600461339f565b6124b8565b6105816107333660046133cb565b6125a9565b61074b610746366004613220565b612701565b60405161032d91906133de565b61032360145481565b61032361076f3660046131f2565b6128d1565b610581610782366004613220565b61299c565b6000600654600a6107989190613535565b6000838152601960205260409020600101546107b49190613570565b6012546107c19190613584565b6107ca836128d1565b6000848152601960205260409020600601546107e691906135a3565b131592915050565b60008181526019602052604081205460ff1661080c57506000919050565b6000600654600a61081d9190613535565b60008481526019602052604090206001015460125461083c9190613584565b6108469190613570565b6000848152601960205260409020600601546108629190613617565b600084815260196020526040902054909150610100900460ff16156108da5760008381526019602052604090206001015460065482906108a390600a613535565b6108ad9190613584565b6108b79190613570565b6000848152601960205260409020600501546108d3919061368b565b915061092f565b60008381526019602052604090206001015460065482906108fc90600a613535565b6109069190613584565b6109109190613570565b60008481526019602052604090206005015461092c91906136a3565b91505b50919050565b600e818154811061094557600080fd5b600091825260209091200154905081565b60006064600b60009054906101000a90046001600160a01b03166001600160a01b031663468f02d26040518163ffffffff1660e01b815260040160206040518083038186803b1580156109a857600080fd5b505afa1580156109bc573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109e091906136ba565b6109ea9190613570565b905090565b6000610a006305f5e1006064613584565b601154610a0d9084613584565b610a179190613570565b92915050565b610a25612a29565b610a2f6000612a83565b565b610a39612a29565b8015610a6d5760405133904780156108fc02916000818181858888f19350505050158015610a6b573d6000803e3d6000fd5b505b6000805b83811015610b5257848482818110610a8b57610a8b6136d3565b9050602002016020810190610aa09190613220565b6040517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152909250610b4a9033906001600160a01b038516906370a082319060240160206040518083038186803b158015610b0157600080fd5b505afa158015610b15573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b3991906136ba565b6001600160a01b0385169190612aeb565b600101610a71565b5060405133907f5e7b34819cd91b239220bec92fcfd3c10da2214ba13e4e2b1f6c9cfdbd68a9a290600090a250505050565b6000610b8e612bb7565b8215610c3f576008546040517fba08765200000000000000000000000000000000000000000000000000000000815260048101849052336024820181905260448201526001600160a01b039091169063ba08765290606401602060405180830381600087803b158015610c0057600080fd5b505af1158015610c14573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c3891906136ba565b9050610ce6565b6007546040517fba08765200000000000000000000000000000000000000000000000000000000815260048101849052336024820181905260448201526001600160a01b039091169063ba08765290606401602060405180830381600087803b158015610cab57600080fd5b505af1158015610cbf573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ce391906136ba565b90505b6040805184151581526020810184905233917f765caf9273e50ef4656990358ed1c5eebbe82d7edd5025ef23cf3d74bc29f7c7910160405180910390a292915050565b6000610d33612c1d565b610d3b612bb7565b8215610dff57600454610d59906001600160a01b0316333085612c77565b6008546040517f6e553f65000000000000000000000000000000000000000000000000000000008152600481018490526001600160a01b03868116602483015290911690636e553f6590604401602060405180830381600087803b158015610dc057600080fd5b505af1158015610dd4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610df891906136ba565b9050610eb9565b600354610e17906001600160a01b0316333085612c77565b6007546040517f6e553f65000000000000000000000000000000000000000000000000000000008152600481018490526001600160a01b03868116602483015290911690636e553f6590604401602060405180830381600087803b158015610e7e57600080fd5b505af1158015610e92573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610eb691906136ba565b90505b6040805184151581526020810184905233917f2a6aa41c5fa940c6ac04515090277cdb487ed49e82fc5b9621052ce012f30724910160405180910390a2610eff60018055565b9392505050565b610f0e612bb7565b60008181526019602052604090205460ff16610f715760405162461bcd60e51b815260206004820152601360248201527f496e76616c696420706f736974696f6e2049440000000000000000000000000060448201526064015b60405180910390fd5b6000818152601960205260409020600a01544290610f9090600161368b565b11156110045760405162461bcd60e51b815260206004820152602b60248201527f506f736974696f6e206d757374206265206f70656e20666f72206174206c656160448201527f73742031207365636f6e640000000000000000000000000000000000000000006064820152608401610f68565b600c546040517f6352211e000000000000000000000000000000000000000000000000000000008152600481018390526000916001600160a01b031690636352211e9060240160206040518083038186803b15801561106257600080fd5b505afa158015611076573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061109a9190613702565b90506110a582610787565b1580156110bb5750336001600160a01b03821614155b15611158576000828152601960205260409020600b810154600a909101546110e3919061368b565b4210156111585760405162461bcd60e51b815260206004820152602260248201527f4b65657065722063616e206f6e6c7920636c6f7365206166746572206578706960448201527f72790000000000000000000000000000000000000000000000000000000000006064820152608401610f68565b600082815260196020526040808220805460ff19169055600c5490517f42966c680000000000000000000000000000000000000000000000000000000081526004810185905282916001600160a01b0316906342966c6890602401600060405180830381600087803b1580156111cd57600080fd5b505af11580156111e1573d6000803e3d6000fd5b505050600085815260196020526040902054610100900460ff16159050611435576004805460035460008781526019602052604090206006810154930154611241936001600160a01b03938416939092169161123c9161368b565b612cce565b60008581526019602052604090206003015490925082111561136057600754600085815260196020526040908190206003015490517f96e839240000000000000000000000000000000000000000000000000000000081526001600160a01b03909216916396e83924916112bb9160040190815260200190565b600060405180830381600087803b1580156112d557600080fd5b505af11580156112e9573d6000803e3d6000fd5b50506003805460045460008981526019602052604090209092015461132394506001600160a01b03918216935091169061123c90866136a3565b905061135b61133185610787565b61133b5783611348565b600f546001600160a01b03165b6004546001600160a01b03169083612aeb565b611644565b6007546040517f96e83924000000000000000000000000000000000000000000000000000000008152600481018490526001600160a01b03909116906396e8392490602401600060405180830381600087803b1580156113bf57600080fd5b505af11580156113d3573d6000803e3d6000fd5b5050506000858152601960205260408120600301547fa0d38f527aab11c688d247e1184f9681755e84f179a37eff124ceb632f565b2592506114169085906136a3565b60408051921515835260208301919091520160405180910390a1611644565b60035460048054600087815260196020526040902090910154611465926001600160a01b03908116921690612cce565b600085815260196020526040902060038101546006909101549193509061148d90849061368b565b111561155357600854600085815260196020526040908190206003015490517f96e839240000000000000000000000000000000000000000000000000000000081526001600160a01b03909216916396e83924916114f19160040190815260200190565b600060405180830381600087803b15801561150b57600080fd5b505af115801561151f573d6000803e3d6000fd5b5050506000858152601960205260409020600381015460069091015490915061154990849061368b565b61132391906136a3565b6008546000858152601960205260409020600601546001600160a01b03909116906396e839249061158590859061368b565b6040518263ffffffff1660e01b81526004016115a391815260200190565b600060405180830381600087803b1580156115bd57600080fd5b505af11580156115d1573d6000803e3d6000fd5b505050600085815260196020526040902060068101546003909101547fa0d38f527aab11c688d247e1184f9681755e84f179a37eff124ceb632f565b259250600191859161161f91906136a3565b611629919061368b565b60408051921515835260208301919091520160405180910390a15b600084815260196020908152604080832060018101549054610100900460ff1615158452601590925282208054919290916116809084906136a3565b909155505060008481526019602052604081206008810154600782015460069092015490916116ae9161368b565b6116b8919061368b565b6116c29083613617565b60008681526019602090815260408083206009018490556001600160a01b038816835260169091528120805492935083929091906117019084906135a3565b90915550506000858152601960209081526040808320600101546001600160a01b03881684526017909252822080549192909161173f90849061368b565b9091555050604080518681526020810183905233917fb6429e464581235b38c90edff598207cf01509af983ac41329ffb40ea8cd8e5a910160405180910390a25050505050565b61178e612a29565b61179781612db0565b50565b600a546040517fc189c19b000000000000000000000000000000000000000000000000000000008152600481018390526000916001600160a01b03169063c189c19b9060240160206040518083038186803b1580156117f857600080fd5b505afa15801561180c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a1791906136ba565b611838612a29565b61179781612eb3565b60008061184c612c1d565b611854612bb7565b600e5485106118a55760405162461bcd60e51b815260206004820152601160248201527f496e76616c69642074696d656672616d650000000000000000000000000000006044820152606401610f68565b6010548410156118f75760405162461bcd60e51b815260206004820152601360248201527f496e73756666696369656e74206d617267696e000000000000000000000000006044820152606401610f68565b6013548611156119495760405162461bcd60e51b815260206004820152601d60248201527f506f736974696f6e206578706f7375726520697320746f6f20686967680000006044820152606401610f68565b601454871515600090815260156020526040902054611968908861368b565b11156119b65760405162461bcd60e51b815260206004820152600e60248201527f4f4920697320746f6f20686967680000000000000000000000000000000000006044820152606401610f68565b861515600090815260156020526040812080548892906119d790849061368b565b90915550600090506119e7610956565b90506000611a138289600e8a81548110611a0357611a036136d3565b90600052602060002001546124b8565b90506000611a20896109ef565b9050611a50333083611a32868c61368b565b611a3c919061368b565b6004546001600160a01b0316929190612c77565b60008a15611c4d57600354600454611a75916001600160a01b0390811691168c612f64565b9050808a600554600a611a889190613535565b611a929190613584565b611a9c9190613570565b945086851015611aee5760405162461bcd60e51b815260206004820152600860248201527f536c6970706167650000000000000000000000000000000000000000000000006044820152606401610f68565b600754604080517f13b98c0f000000000000000000000000000000000000000000000000000000008152905183926001600160a01b0316916313b98c0f916004808301926020929190829003018186803b158015611b4b57600080fd5b505afa158015611b5f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b8391906136ba565b1015611bd15760405162461bcd60e51b815260206004820152601660248201527f496e73756666696369656e74206c6971756964697479000000000000000000006044820152606401610f68565b6007546040517f2bfbd9cf000000000000000000000000000000000000000000000000000000008152600481018390526001600160a01b0390911690632bfbd9cf90602401600060405180830381600087803b158015611c3057600080fd5b505af1158015611c44573d6000803e3d6000fd5b50505050611e3e565b600854604080517f13b98c0f00000000000000000000000000000000000000000000000000000000815290518c926001600160a01b0316916313b98c0f916004808301926020929190829003018186803b158015611caa57600080fd5b505afa158015611cbe573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ce291906136ba565b1015611d305760405162461bcd60e51b815260206004820152601660248201527f496e73756666696369656e74206c6971756964697479000000000000000000006044820152606401610f68565b600454600354611d4d916001600160a01b0390811691168c612cce565b9050808a600554600a611d609190613535565b611d6a9190613584565b611d749190613570565b945086851115611dc65760405162461bcd60e51b815260206004820152600860248201527f536c6970706167650000000000000000000000000000000000000000000000006044820152606401610f68565b6008546040517f2bfbd9cf000000000000000000000000000000000000000000000000000000008152600481018c90526001600160a01b0390911690632bfbd9cf90602401600060405180830381600087803b158015611e2557600080fd5b505af1158015611e39573d6000803e3d6000fd5b505050505b8a15611fe257600454600354600091611e64916001600160a01b03918216911685612cce565b600754600f546040517f6e553f65000000000000000000000000000000000000000000000000000000008152600481018490526001600160a01b0391821660248201529293501690636e553f6590604401602060405180830381600087803b158015611ecf57600080fd5b505af1158015611ee3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f0791906136ba565b50600454600354600091611f28916001600160a01b03918216911687612cce565b6007546040517f93949874000000000000000000000000000000000000000000000000000000008152600481018390529192506001600160a01b031690639394987490602401600060405180830381600087803b158015611f8857600080fd5b505af1158015611f9c573d6000803e3d6000fd5b50506040805160008152602081018590527ff1bc206c8d659bf05edd19865dbae82643062168ec3970d9d7c5468f900487d9935001905060405180910390a15050612137565b600854600f546040517f6e553f65000000000000000000000000000000000000000000000000000000008152600481018590526001600160a01b039182166024820152911690636e553f6590604401602060405180830381600087803b15801561204b57600080fd5b505af115801561205f573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061208391906136ba565b506008546040517f93949874000000000000000000000000000000000000000000000000000000008152600481018590526001600160a01b0390911690639394987490602401600060405180830381600087803b1580156120e357600080fd5b505af11580156120f7573d6000803e3d6000fd5b50506040805160018152602081018790527ff1bc206c8d659bf05edd19865dbae82643062168ec3970d9d7c5468f900487d9935001905060405180910390a15b600c546040517f6a6278420000000000000000000000000000000000000000000000000000000081523360048201526001600160a01b0390911690636a62784290602401602060405180830381600087803b15801561219557600080fd5b505af11580156121a9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121cd91906136ba565b9550604051806101a001604052806001151581526020018c151581526020018b815260200186600654600a6122029190613535565b61220c908e613584565b6122169190613570565b81526020018c612226578b612228565b825b81526020018c612238578261223a565b8b5b815260200186815260200189815260200184815260200183815260200160008152602001428152602001600e8b81548110612277576122776136d3565b6000918252602080832091909101549092528881526019825260409081902083518154858501517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00009091169115157fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff16919091176101009115158202178255848301516001830155606085015160028301556080850151600383015560a0850151600483015560c0850151600583015560e08501516006830155840151600782015561012084015160088201556101408401516009820155610160840151600a82015561018090930151600b9093019290925581518881529081018c905233917ff9f9d4d8dc8cd97a8c718d19386c88c7b89bf1e71f31a3218dca3dbd2b9ba165910160405180910390a2505050506123af60018055565b9550959350505050565b6123c1612c1d565b6008546001600160a01b03163314806123e457506007546001600160a01b031633145b6124565760405162461bcd60e51b815260206004820152602b60248201527f4f6e6c79205363616c70204c5020636f6e74726163742063616e20636c61696d60448201527f20636f6c6c61746572616c0000000000000000000000000000000000000000006064820152608401610f68565b6008546001600160a01b031633141561248557600454612480906001600160a01b03163383612aeb565b6124af565b6007546001600160a01b03163314156124af576003546124af906001600160a01b03163383612aeb565b61179760018055565b6000806124c5834261368b565b600954909150859085906001600160a01b0316635b7b6d8860008585806124eb8161179a565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e088901b1681529415156004860152602485019390935260448401919091526064830152608482015260a40160206040518083038186803b15801561255457600080fd5b505afa158015612568573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061258c91906136ba565b6125969190613584565b6125a09190613570565b95945050505050565b6125b1612a29565b803560135560208101356014556125ce6060820160408301613220565b600980547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b03929092169190911790556126166080820160608301613220565b600a80547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b039290921691909117905561265e60a0820160808301613220565b600b80547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b03929092169190911790556126a660c0820160a08301613220565b600f80547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b039290921691909117905560c081013560105560e08101356011556101008101356012556101200135601855565b600c546040517f70a082310000000000000000000000000000000000000000000000000000000081526001600160a01b0383811660048301526060926000929116906370a082319060240160206040518083038186803b15801561276457600080fd5b505afa158015612778573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061279c91906136ba565b90508067ffffffffffffffff8111156127b7576127b761371f565b6040519080825280602002602001820160405280156127e0578160200160208202803683370190505b5091506000805b828210156128c957600c546040517f2f745c590000000000000000000000000000000000000000000000000000000081526001600160a01b038781166004830152602482018490526000921690632f745c599060440160206040518083038186803b15801561285557600080fd5b505afa158015612869573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061288d91906136ba565b9050808584815181106128a2576128a26136d3565b60209081029190910101526128b68361374e565b92506128c18261374e565b9150506127e7565b505050919050565b6000806128dc610956565b600084815260196020526040902054909150610100900460ff161561294c5760065461290990600a613535565b600084815260196020526040902060050154612926908390613617565b6000858152601960205260409020600201546129429190613769565b6108d39190613825565b60065461295a90600a613535565b6000848152601960205260409020600501546129769083613617565b6000858152601960205260409020600201546129929190613769565b61092c9190613825565b6129a4612a29565b6001600160a01b038116612a205760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f64647265737300000000000000000000000000000000000000000000000000006064820152608401610f68565b61179781612a83565b6000546001600160a01b03163314610a2f5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610f68565b600080546001600160a01b038381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6040516001600160a01b038316602482015260448101829052612bb29084907fa9059cbb00000000000000000000000000000000000000000000000000000000906064015b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff0000000000000000000000000000000000000000000000000000000090931692909217909152612fed565b505050565b333214610a2f573360009081526002602052604090205460ff16610a2f5760405162461bcd60e51b815260206004820152601c60248201527f436f6e7472616374206d7573742062652077686974656c6973746564000000006044820152606401610f68565b60026001541415612c705760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610f68565b6002600155565b6040516001600160a01b0380851660248301528316604482015260648101829052612cc89085907f23b872dd0000000000000000000000000000000000000000000000000000000090608401612b30565b50505050565b600d5460408051610100810182526001600160a01b03868116825285811660208301526101f48284015230606083015242608083015260a08201859052600060c0830181905260e0830181905292517f414bf3890000000000000000000000000000000000000000000000000000000081529293169163414bf38991612d569160040161386f565b602060405180830381600087803b158015612d7057600080fd5b505af1158015612d84573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612da891906136ba565b949350505050565b803b612dfe5760405162461bcd60e51b815260206004820152601a60248201527f41646472657373206d757374206265206120636f6e74726163740000000000006044820152606401610f68565b6001600160a01b03811660009081526002602052604090205460ff1615612e675760405162461bcd60e51b815260206004820152601c60248201527f436f6e747261637420616c72656164792077686974656c6973746564000000006044820152606401610f68565b6001600160a01b038116600081815260026020526040808220805460ff19166001179055517ffbd3cde7ff522a917e485c8ed2a6e87590887ab399f5ac312307903f498543079190a250565b6001600160a01b03811660009081526002602052604090205460ff16612f1b5760405162461bcd60e51b815260206004820152601860248201527f436f6e7472616374206e6f742077686974656c697374656400000000000000006044820152606401610f68565b6001600160a01b038116600081815260026020526040808220805460ff19169055517f8e81447740597754af5db3e176253a36f7981a9549f48ace3f0cb233913f9d859190a250565b600d5460408051610100810182526001600160a01b03868116825285811660208301526101f48284015230606083015242608083015260a0820185905260001960c0830152600060e0830181905292517fdb3e21980000000000000000000000000000000000000000000000000000000081529293169163db3e219891612d569160040161386f565b6000613042826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166130d29092919063ffffffff16565b805190915015612bb2578080602001905181019061306091906138dd565b612bb25760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f742073756363656564000000000000000000000000000000000000000000006064820152608401610f68565b6060612da8848460008585600080866001600160a01b031685876040516130f99190613926565b60006040518083038185875af1925050503d8060008114613136576040519150601f19603f3d011682016040523d82523d6000602084013e61313b565b606091505b509150915061314c87838387613157565b979650505050505050565b606083156131c35782516131bc576001600160a01b0385163b6131bc5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610f68565b5081612da8565b612da883838151156131d85781518083602001fd5b8060405162461bcd60e51b8152600401610f689190613942565b60006020828403121561320457600080fd5b5035919050565b6001600160a01b038116811461179757600080fd5b60006020828403121561323257600080fd5b8135610eff8161320b565b801515811461179757600080fd5b60008060006040848603121561326057600080fd5b833567ffffffffffffffff8082111561327857600080fd5b818601915086601f83011261328c57600080fd5b81358181111561329b57600080fd5b8760208260051b85010111156132b057600080fd5b602092830195509350508401356132c68161323d565b809150509250925092565b6000602082840312156132e357600080fd5b8135610eff8161323d565b6000806040838503121561330157600080fd5b823561330c8161323d565b946020939093013593505050565b60008060006060848603121561332f57600080fd5b833561333a8161320b565b9250602084013561334a8161323d565b929592945050506040919091013590565b600080600080600060a0868803121561337357600080fd5b853561337e8161323d565b97602087013597506040870135966060810135965060800135945092505050565b6000806000606084860312156133b457600080fd5b505081359360208301359350604090920135919050565b6000610140828403121561092f57600080fd5b6020808252825182820181905260009190848201906040850190845b81811015613416578351835292840192918401916001016133fa565b50909695505050505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b600181815b8085111561348c57816000190482111561347257613472613422565b8085161561347f57918102915b93841c9390800290613456565b509250929050565b6000826134a357506001610a17565b816134b057506000610a17565b81600181146134c657600281146134d0576134ec565b6001915050610a17565b60ff8411156134e1576134e1613422565b50506001821b610a17565b5060208310610133831016604e8410600b841016171561350f575081810a610a17565b6135198383613451565b806000190482111561352d5761352d613422565b029392505050565b6000610eff8383613494565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b60008261357f5761357f613541565b500490565b600081600019048311821515161561359e5761359e613422565b500290565b6000808212827f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff038413811516156135dd576135dd613422565b827f800000000000000000000000000000000000000000000000000000000000000003841281161561361157613611613422565b50500190565b6000808312837f80000000000000000000000000000000000000000000000000000000000000000183128115161561365157613651613422565b837f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01831381161561368557613685613422565b50500390565b6000821982111561369e5761369e613422565b500190565b6000828210156136b5576136b5613422565b500390565b6000602082840312156136cc57600080fd5b5051919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60006020828403121561371457600080fd5b8151610eff8161320b565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600060001982141561376257613762613422565b5060010190565b60007f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6000841360008413858304851182821616156137aa576137aa613422565b7f800000000000000000000000000000000000000000000000000000000000000060008712868205881281841616156137e5576137e5613422565b6000871292508782058712848416161561380157613801613422565b8785058712818416161561381757613817613422565b505050929093029392505050565b60008261383457613834613541565b60001983147f80000000000000000000000000000000000000000000000000000000000000008314161561386a5761386a613422565b500590565b6101008101610a1782846001600160a01b0380825116835280602083015116602084015262ffffff60408301511660408401528060608301511660608401526080820151608084015260a082015160a084015260c082015160c08401528060e08301511660e0840152505050565b6000602082840312156138ef57600080fd5b8151610eff8161323d565b60005b838110156139155781810151838201526020016138fd565b83811115612cc85750506000910152565b600082516139388184602087016138fa565b9190910192915050565b60208152600082518060208401526139618160408501602087016138fa565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fea26469706673582212206f219747d92419011dae1ec8d2e45ae035c4ce8237d3db01bf22a5918382e9d864736f6c6343000809003360806040523480156200001157600080fd5b50604080518082018252601081526f27a816a9b1b0b6382837b9b4ba34b7b760811b60208083019182528351808501909452600484526304f5053560e41b908401526001600081905582519293926200006b92906200012f565b508051620000819060029060208401906200012f565b5050506200009e62000098620000d060201b60201c565b620000d4565b600d8054336001600160a01b0319909116179055620000ca600c62000126602090811b62000bef17901c565b62000212565b3390565b600b80546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b80546001019055565b8280546200013d90620001d5565b90600052602060002090601f016020900481019282620001615760008555620001ac565b82601f106200017c57805160ff1916838001178555620001ac565b82800160010185558215620001ac579182015b82811115620001ac5782518255916020019190600101906200018f565b50620001ba929150620001be565b5090565b5b80821115620001ba5760008155600101620001bf565b600181811c90821680620001ea57607f821691505b602082108114156200020c57634e487b7160e01b600052602260045260246000fd5b50919050565b61218580620002226000396000f3fe608060405234801561001057600080fd5b506004361061018d5760003560e01c80636352211e116100e3578063a22cb4651161008c578063c898912f11610066578063c898912f14610326578063e985e9c514610339578063f2fde38b1461037557600080fd5b8063a22cb465146102ed578063b88d4fde14610300578063c87b56dd1461031357600080fd5b8063715018a6116100bd578063715018a6146102cc5780638da5cb5b146102d457806395d89b41146102e557600080fd5b80636352211e146102935780636a627842146102a657806370a08231146102b957600080fd5b806323b872dd1161014557806342966c681161011f57806342966c681461025a5780634f6ccce71461026d5780635fd564281461028057600080fd5b806323b872dd146102215780632f745c591461023457806342842e0e1461024757600080fd5b8063081812fc11610176578063081812fc146101cf578063095ea7b3146101fa57806318160ddd1461020f57600080fd5b806301ffc9a71461019257806306fdde03146101ba575b600080fd5b6101a56101a0366004611d04565b610388565b60405190151581526020015b60405180910390f35b6101c2610399565b6040516101b19190611d79565b6101e26101dd366004611d8c565b61042b565b6040516001600160a01b0390911681526020016101b1565b61020d610208366004611dbc565b610452565b005b6009545b6040519081526020016101b1565b61020d61022f366004611de6565b610589565b610213610242366004611dbc565b610610565b61020d610255366004611de6565b6106b8565b61020d610268366004611d8c565b6106d3565b61021361027b366004611d8c565b610785565b600d546101e2906001600160a01b031681565b6101e26102a1366004611d8c565b610829565b6102136102b4366004611e22565b61088e565b6102136102c7366004611e22565b610952565b61020d6109ec565b600b546001600160a01b03166101e2565b6101c2610a00565b61020d6102fb366004611e3d565b610a0f565b61020d61030e366004611ea8565b610a1e565b6101c2610321366004611d8c565b610aac565b61020d610334366004611e22565b610b20565b6101a5610347366004611f84565b6001600160a01b03918216600090815260066020908152604080832093909416825291909152205460ff1690565b61020d610383366004611e22565b610b62565b600061039382610bf8565b92915050565b6060600180546103a890611fb7565b80601f01602080910402602001604051908101604052809291908181526020018280546103d490611fb7565b80156104215780601f106103f657610100808354040283529160200191610421565b820191906000526020600020905b81548152906001019060200180831161040457829003601f168201915b5050505050905090565b600061043682610c4e565b506000908152600560205260409020546001600160a01b031690565b600061045d82610829565b9050806001600160a01b0316836001600160a01b031614156104ec5760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e6560448201527f720000000000000000000000000000000000000000000000000000000000000060648201526084015b60405180910390fd5b336001600160a01b038216148061050857506105088133610347565b61057a5760405162461bcd60e51b815260206004820152603d60248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f7420746f60448201527f6b656e206f776e6572206f7220617070726f76656420666f7220616c6c00000060648201526084016104e3565b6105848383610cb2565b505050565b6105933382610d38565b6106055760405162461bcd60e51b815260206004820152602d60248201527f4552433732313a2063616c6c6572206973206e6f7420746f6b656e206f776e6560448201527f72206f7220617070726f7665640000000000000000000000000000000000000060648201526084016104e3565b610584838383610db7565b600061061b83610952565b821061068f5760405162461bcd60e51b815260206004820152602b60248201527f455243373231456e756d657261626c653a206f776e657220696e646578206f7560448201527f74206f6620626f756e647300000000000000000000000000000000000000000060648201526084016104e3565b506001600160a01b03919091166000908152600760209081526040808320938352929052205490565b61058483838360405180602001604052806000815250610a1e565b600d546001600160a01b031633146107795760405162461bcd60e51b815260206004820152604260248201527f4f6e6c79206f7074696f6e207363616c7020636f6e74726163742063616e206d60448201527f696e7420616e206f7074696f6e207363616c7020706f736974696f6e20746f6b60648201527f656e000000000000000000000000000000000000000000000000000000000000608482015260a4016104e3565b61078281611005565b50565b600061079060095490565b82106108045760405162461bcd60e51b815260206004820152602c60248201527f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60448201527f7574206f6620626f756e6473000000000000000000000000000000000000000060648201526084016104e3565b600982815481106108175761081761200b565b90600052602060002001549050919050565b6000818152600360205260408120546001600160a01b0316806103935760405162461bcd60e51b815260206004820152601860248201527f4552433732313a20696e76616c696420746f6b656e204944000000000000000060448201526064016104e3565b600d546000906001600160a01b031633146109375760405162461bcd60e51b815260206004820152604260248201527f4f6e6c79206f7074696f6e207363616c7020636f6e74726163742063616e206d60448201527f696e7420616e206f7074696f6e207363616c7020706f736974696f6e20746f6b60648201527f656e000000000000000000000000000000000000000000000000000000000000608482015260a4016104e3565b50600c80546001810190915561094d82826110c0565b919050565b60006001600160a01b0382166109d05760405162461bcd60e51b815260206004820152602960248201527f4552433732313a2061646472657373207a65726f206973206e6f74206120766160448201527f6c6964206f776e6572000000000000000000000000000000000000000000000060648201526084016104e3565b506001600160a01b031660009081526004602052604090205490565b6109f46110da565b6109fe6000611134565b565b6060600280546103a890611fb7565b610a1a33838361119e565b5050565b610a283383610d38565b610a9a5760405162461bcd60e51b815260206004820152602d60248201527f4552433732313a2063616c6c6572206973206e6f7420746f6b656e206f776e6560448201527f72206f7220617070726f7665640000000000000000000000000000000000000060648201526084016104e3565b610aa68484848461128b565b50505050565b6060610ab782610c4e565b6000610ace60408051602081019091526000815290565b90506000815111610aee5760405180602001604052806000815250610b19565b80610af884611314565b604051602001610b0992919061203a565b6040516020818303038152906040525b9392505050565b610b286110da565b600d80547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0392909216919091179055565b610b6a6110da565b6001600160a01b038116610be65760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084016104e3565b61078281611134565b80546001019055565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f780e9d630000000000000000000000000000000000000000000000000000000014806103935750610393826113be565b6000818152600360205260409020546001600160a01b03166107825760405162461bcd60e51b815260206004820152601860248201527f4552433732313a20696e76616c696420746f6b656e204944000000000000000060448201526064016104e3565b600081815260056020526040902080547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0384169081179091558190610cff82610829565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b600080610d4483610829565b9050806001600160a01b0316846001600160a01b03161480610d8b57506001600160a01b0380821660009081526006602090815260408083209388168352929052205460ff165b80610daf5750836001600160a01b0316610da48461042b565b6001600160a01b0316145b949350505050565b826001600160a01b0316610dca82610829565b6001600160a01b031614610e465760405162461bcd60e51b815260206004820152602560248201527f4552433732313a207472616e736665722066726f6d20696e636f72726563742060448201527f6f776e657200000000000000000000000000000000000000000000000000000060648201526084016104e3565b6001600160a01b038216610ec15760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f2061646460448201527f726573730000000000000000000000000000000000000000000000000000000060648201526084016104e3565b610ece83838360016114a1565b826001600160a01b0316610ee182610829565b6001600160a01b031614610f5d5760405162461bcd60e51b815260206004820152602560248201527f4552433732313a207472616e736665722066726f6d20696e636f72726563742060448201527f6f776e657200000000000000000000000000000000000000000000000000000060648201526084016104e3565b600081815260056020908152604080832080547fffffffffffffffffffffffff00000000000000000000000000000000000000009081169091556001600160a01b0387811680865260048552838620805460001901905590871680865283862080546001019055868652600390945282852080549092168417909155905184937fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b600061101082610829565b90506110208160008460016114a1565b61102982610829565b600083815260056020908152604080832080547fffffffffffffffffffffffff00000000000000000000000000000000000000009081169091556001600160a01b0385168085526004845282852080546000190190558785526003909352818420805490911690555192935084927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908390a45050565b610a1a8282604051806020016040528060008152506114ad565b600b546001600160a01b031633146109fe5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016104e3565b600b80546001600160a01b038381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b816001600160a01b0316836001600160a01b031614156112005760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c65720000000000000060448201526064016104e3565b6001600160a01b0383811660008181526006602090815260408083209487168084529482529182902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b611296848484610db7565b6112a284848484611536565b610aa65760405162461bcd60e51b815260206004820152603260248201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560448201527f63656976657220696d706c656d656e746572000000000000000000000000000060648201526084016104e3565b60606000611321836116e3565b600101905060008167ffffffffffffffff81111561134157611341611e79565b6040519080825280601f01601f19166020018201604052801561136b576020820181803683370190505b5090508181016020015b600019017f3031323334353637383961626364656600000000000000000000000000000000600a86061a8153600a85049450846113b1576113b6565b611375565b509392505050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f80ac58cd00000000000000000000000000000000000000000000000000000000148061145157507fffffffff0000000000000000000000000000000000000000000000000000000082167f5b5e139f00000000000000000000000000000000000000000000000000000000145b8061039357507f01ffc9a7000000000000000000000000000000000000000000000000000000007fffffffff00000000000000000000000000000000000000000000000000000000831614610393565b610aa6848484846117c5565b6114b7838361190d565b6114c46000848484611536565b6105845760405162461bcd60e51b815260206004820152603260248201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560448201527f63656976657220696d706c656d656e746572000000000000000000000000000060648201526084016104e3565b60006001600160a01b0384163b156116d8576040517f150b7a020000000000000000000000000000000000000000000000000000000081526001600160a01b0385169063150b7a0290611593903390899088908890600401612069565b602060405180830381600087803b1580156115ad57600080fd5b505af19250505080156115dd575060408051601f3d908101601f191682019092526115da918101906120a5565b60015b61168d573d80801561160b576040519150601f19603f3d011682016040523d82523d6000602084013e611610565b606091505b5080516116855760405162461bcd60e51b815260206004820152603260248201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560448201527f63656976657220696d706c656d656e746572000000000000000000000000000060648201526084016104e3565b805181602001fd5b7fffffffff00000000000000000000000000000000000000000000000000000000167f150b7a0200000000000000000000000000000000000000000000000000000000149050610daf565b506001949350505050565b6000807a184f03e93ff9f4daa797ed6e38ed64bf6a1f010000000000000000831061172c577a184f03e93ff9f4daa797ed6e38ed64bf6a1f010000000000000000830492506040015b6d04ee2d6d415b85acef81000000008310611758576d04ee2d6d415b85acef8100000000830492506020015b662386f26fc10000831061177657662386f26fc10000830492506010015b6305f5e100831061178e576305f5e100830492506008015b61271083106117a257612710830492506004015b606483106117b4576064830492506002015b600a83106103935760010192915050565b6117d184848484611abe565b60018111156118485760405162461bcd60e51b815260206004820152603560248201527f455243373231456e756d657261626c653a20636f6e736563757469766520747260448201527f616e7366657273206e6f7420737570706f72746564000000000000000000000060648201526084016104e3565b816001600160a01b0385166118a45761189f81600980546000838152600a60205260408120829055600182018355919091527f6e1540171b6c0c960b71a7020d9f60077f6af931a8bbf590da0223dacf75c7af0155565b6118c7565b836001600160a01b0316856001600160a01b0316146118c7576118c78582611b46565b6001600160a01b0384166118e3576118de81611be3565b611906565b846001600160a01b0316846001600160a01b031614611906576119068482611c92565b5050505050565b6001600160a01b0382166119635760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f206164647265737360448201526064016104e3565b6000818152600360205260409020546001600160a01b0316156119c85760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e7465640000000060448201526064016104e3565b6119d66000838360016114a1565b6000818152600360205260409020546001600160a01b031615611a3b5760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e7465640000000060448201526064016104e3565b6001600160a01b038216600081815260046020908152604080832080546001019055848352600390915280822080547fffffffffffffffffffffffff0000000000000000000000000000000000000000168417905551839291907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b6001811115610aa6576001600160a01b03841615611b04576001600160a01b03841660009081526004602052604081208054839290611afe9084906120f1565b90915550505b6001600160a01b03831615610aa6576001600160a01b03831660009081526004602052604081208054839290611b3b908490612108565b909155505050505050565b60006001611b5384610952565b611b5d91906120f1565b600083815260086020526040902054909150808214611bb0576001600160a01b03841660009081526007602090815260408083208584528252808320548484528184208190558352600890915290208190555b5060009182526008602090815260408084208490556001600160a01b039094168352600781528383209183525290812055565b600954600090611bf5906001906120f1565b6000838152600a602052604081205460098054939450909284908110611c1d57611c1d61200b565b906000526020600020015490508060098381548110611c3e57611c3e61200b565b6000918252602080832090910192909255828152600a90915260408082208490558582528120556009805480611c7657611c76612120565b6001900381819060005260206000200160009055905550505050565b6000611c9d83610952565b6001600160a01b039093166000908152600760209081526040808320868452825280832085905593825260089052919091209190915550565b7fffffffff000000000000000000000000000000000000000000000000000000008116811461078257600080fd5b600060208284031215611d1657600080fd5b8135610b1981611cd6565b60005b83811015611d3c578181015183820152602001611d24565b83811115610aa65750506000910152565b60008151808452611d65816020860160208601611d21565b601f01601f19169290920160200192915050565b602081526000610b196020830184611d4d565b600060208284031215611d9e57600080fd5b5035919050565b80356001600160a01b038116811461094d57600080fd5b60008060408385031215611dcf57600080fd5b611dd883611da5565b946020939093013593505050565b600080600060608486031215611dfb57600080fd5b611e0484611da5565b9250611e1260208501611da5565b9150604084013590509250925092565b600060208284031215611e3457600080fd5b610b1982611da5565b60008060408385031215611e5057600080fd5b611e5983611da5565b915060208301358015158114611e6e57600080fd5b809150509250929050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b60008060008060808587031215611ebe57600080fd5b611ec785611da5565b9350611ed560208601611da5565b925060408501359150606085013567ffffffffffffffff80821115611ef957600080fd5b818701915087601f830112611f0d57600080fd5b813581811115611f1f57611f1f611e79565b604051601f8201601f19908116603f01168101908382118183101715611f4757611f47611e79565b816040528281528a6020848701011115611f6057600080fd5b82602086016020830137600060208483010152809550505050505092959194509250565b60008060408385031215611f9757600080fd5b611fa083611da5565b9150611fae60208401611da5565b90509250929050565b600181811c90821680611fcb57607f821691505b60208210811415612005577f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b50919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b6000835161204c818460208801611d21565b835190830190612060818360208801611d21565b01949350505050565b60006001600160a01b0380871683528086166020840152508360408301526080606083015261209b6080830184611d4d565b9695505050505050565b6000602082840312156120b757600080fd5b8151610b1981611cd6565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b600082821015612103576121036120c2565b500390565b6000821982111561211b5761211b6120c2565b500190565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603160045260246000fdfea2646970667358221220a34dc6ff6ac3ed4970ed335624b7e917097f493ba725f209eb7e476b64d0ff9664736f6c634300080900336101006040523480156200001257600080fd5b506040516200229538038062002295833981016040819052620000359162000398565b816040518060400160405280600e81526020016d29b1b0b638102628102a37b5b2b760911b81525060405180604001604052806004815260200163053634c560e41b8152508181846001600160a01b031663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b158015620000b657600080fd5b505afa158015620000cb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620000f1919062000478565b8251620001069060009060208601906200028c565b5081516200011c9060019060208501906200028c565b5060ff81166080524660a05262000132620001c2565b60c052505050506001600160a01b0391821660e05250600680546001600160a01b0319169185169190911790558051620001749060099060208401906200028c565b50620001a2816040518060400160405280600381526020016202d4c560ec1b8152506200025e60201b60201c565b8051620001b8916001916020909101906200028c565b50505050620005b8565b60007f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f6000604051620001f69190620004e1565b6040805191829003822060208301939093528101919091527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc660608201524660808201523060a082015260c00160405160208183030381529060405280519060200120905090565b606082826040516020016200027592919062000585565b604051602081830303815290604052905092915050565b8280546200029a90620004a4565b90600052602060002090601f016020900481019282620002be576000855562000309565b82601f10620002d957805160ff191683800117855562000309565b8280016001018555821562000309579182015b8281111562000309578251825591602001919060010190620002ec565b50620003179291506200031b565b5090565b5b808211156200031757600081556001016200031c565b80516001600160a01b03811681146200034a57600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b60005b838110156200038257818101518382015260200162000368565b8381111562000392576000848401525b50505050565b600080600060608486031215620003ae57600080fd5b620003b98462000332565b9250620003c96020850162000332565b60408501519092506001600160401b0380821115620003e757600080fd5b818601915086601f830112620003fc57600080fd5b8151818111156200041157620004116200034f565b604051601f8201601f19908116603f011681019083821181831017156200043c576200043c6200034f565b816040528281528960208487010111156200045657600080fd5b6200046983602083016020880162000365565b80955050505050509250925092565b6000602082840312156200048b57600080fd5b815160ff811681146200049d57600080fd5b9392505050565b600181811c90821680620004b957607f821691505b60208210811415620004db57634e487b7160e01b600052602260045260246000fd5b50919050565b600080835481600182811c915080831680620004fe57607f831692505b60208084108214156200051f57634e487b7160e01b86526022600452602486fd5b818015620005365760018114620005485762000577565b60ff1986168952848901965062000577565b60008a81526020902060005b868110156200056f5781548b82015290850190830162000554565b505084890196505b509498975050505050505050565b600083516200059981846020880162000365565b835190830190620005af81836020880162000365565b01949350505050565b60805160a05160c05160e051611c796200061c600039600081816103a6015281816109aa01528181610b7c01528181610e82015281816110430152818161156701526115a101526000610916015260006108e6015260006103650152611c796000f3fe608060405234801561001057600080fd5b50600436106102ad5760003560e01c806394bf804d1161017b578063ce04bebb116100d8578063d90a730e1161008c578063e948d03011610071578063e948d030146105b4578063ea9143e0146105d4578063ef8b30f7146105dd57600080fd5b8063d90a730e14610581578063dd62ed3e1461058957600080fd5b8063d505accf116100bd578063d505accf14610532578063d8dfeb4514610545578063d905777e1461055857600080fd5b8063ce04bebb14610516578063ce96cb771461051f57600080fd5b8063b460af941161012f578063bf91179411610114578063bf911794146104fb578063c63d75b6146103e0578063c6e6f5921461050357600080fd5b8063b460af94146104d5578063ba087652146104e857600080fd5b806396e839241161016057806396e839241461049c578063a9059cbb146104af578063b3d7f6b9146104c257600080fd5b806394bf804d1461048157806395d89b411461049457600080fd5b8063313ce567116102295780636e553f65116101dd5780637ecebe00116101c25780637ecebe001461043b578063895e38a71461045b578063939498741461046e57600080fd5b80636e553f651461040857806370a082311461041b57600080fd5b806338d52e0f1161020e57806338d52e0f146103a1578063402d267d146103e05780634cdad506146103f557600080fd5b8063313ce567146103605780633644e5151461039957600080fd5b80630a28a4771161028057806318160ddd1161026557806318160ddd1461032f57806323b872dd146103385780632bfbd9cf1461034b57600080fd5b80630a28a4771461031457806313b98c0f1461032757600080fd5b806301e1d114146102b257806306fdde03146102c957806307a2d13a146102de578063095ea7b3146102f1575b600080fd5b600a545b6040519081526020015b60405180910390f35b6102d16105f0565b6040516102c09190611895565b6102b66102ec3660046118ea565b61067e565b6103046102ff36600461191f565b6106ac565b60405190151581526020016102c0565b6102b66103223660046118ea565b610719565b6102b661073a565b6102b660025481565b610304610346366004611949565b610751565b61035e6103593660046118ea565b610843565b005b6103877f000000000000000000000000000000000000000000000000000000000000000081565b60405160ff90911681526020016102c0565b6102b66108e2565b6103c87f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b0390911681526020016102c0565b6102b66103ee366004611985565b5060001990565b6102b66104033660046118ea565b610938565b6102b66104163660046119a0565b610943565b6102b6610429366004611985565b60036020526000908152604090205481565b6102b6610449366004611985565b60056020526000908152604090205481565b6006546103c8906001600160a01b031681565b61035e61047c3660046118ea565b610ad0565b6102b661048f3660046119a0565b610b62565b6102d1610bfe565b61035e6104aa3660046118ea565b610c0b565b6103046104bd36600461191f565b610c9d565b6102b66104d03660046118ea565b610d15565b6102b66104e33660046119cc565b610d35565b6102b66104f63660046119cc565b610ea9565b6102d161106a565b6102b66105113660046118ea565b611077565b6102b6600a5481565b6102b661052d366004611985565b611098565b61035e610540366004611a08565b6110ba565b6007546103c8906001600160a01b031681565b6102b6610566366004611985565b6001600160a01b031660009081526003602052604090205490565b6102d1611328565b6102b6610597366004611a7b565b600460209081526000928352604080842090915290825290205481565b6102b66105c2366004611985565b600c6020526000908152604090205481565b6102b6600b5481565b6102b66105eb3660046118ea565b611335565b600080546105fd90611aa5565b80601f016020809104026020016040519081016040528092919081815260200182805461062990611aa5565b80156106765780601f1061064b57610100808354040283529160200191610676565b820191906000526020600020905b81548152906001019060200180831161065957829003601f168201915b505050505081565b60025460009080156106a35761069e610696600a5490565b849083611340565b6106a5565b825b9392505050565b3360008181526004602090815260408083206001600160a01b038716808552925280832085905551919290917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925906107079086815260200190565b60405180910390a35060015b92915050565b60025460009080156106a35761069e81610732600a5490565b85919061135f565b6000600b54600a5461074c9190611b28565b905090565b6001600160a01b038316600090815260046020908152604080832033845290915281205460001981146107ad576107888382611b28565b6001600160a01b03861660009081526004602090815260408083203384529091529020555b6001600160a01b038516600090815260036020526040812080548592906107d5908490611b28565b90915550506001600160a01b03808516600081815260036020526040908190208054870190555190918716907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef906108309087815260200190565b60405180910390a3506001949350505050565b6006546001600160a01b031633146108c85760405162461bcd60e51b815260206004820152602160248201527f4f6e6c79207363616c702063616e2063616c6c20746869732066756e6374696f60448201527f6e0000000000000000000000000000000000000000000000000000000000000060648201526084015b60405180910390fd5b80600b60008282546108da9190611b3f565b909155505050565b60007f000000000000000000000000000000000000000000000000000000000000000046146109135761074c61138d565b507f000000000000000000000000000000000000000000000000000000000000000090565b60006107138261067e565b600061094e83611335565b90508061099d5760405162461bcd60e51b815260206004820152600b60248201527f5a45524f5f53484152455300000000000000000000000000000000000000000060448201526064016108bf565b6109d26001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016333086611427565b6109dc82826114d3565b600660009054906101000a90046001600160a01b03166001600160a01b0316639c15d1a26040518163ffffffff1660e01b815260040160206040518083038186803b158015610a2a57600080fd5b505afa158015610a3e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a629190611b57565b610a6c9042611b3f565b6001600160a01b0383166000818152600c6020908152604091829020939093558051868152928301849052909133917fdcbc1c05240f31ff3ad067ef1ee35ce4997762752e3a095284754544f4c709d7910160405180910390a3610713838261153f565b6006546001600160a01b03163314610b505760405162461bcd60e51b815260206004820152602160248201527f4f6e6c79207363616c702063616e2063616c6c20746869732066756e6374696f60448201527f6e0000000000000000000000000000000000000000000000000000000000000060648201526084016108bf565b80600a60008282546108da9190611b3f565b6000610b6d83610d15565b9050610ba46001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016333084611427565b610bae82846114d3565b60408051828152602081018590526001600160a01b0384169133917fdcbc1c05240f31ff3ad067ef1ee35ce4997762752e3a095284754544f4c709d7910160405180910390a3610713818461153f565b600180546105fd90611aa5565b6006546001600160a01b03163314610c8b5760405162461bcd60e51b815260206004820152602160248201527f4f6e6c79207363616c702063616e2063616c6c20746869732066756e6374696f60448201527f6e0000000000000000000000000000000000000000000000000000000000000060648201526084016108bf565b80600b60008282546108da9190611b28565b33600090815260036020526040812080548391908390610cbe908490611b28565b90915550506001600160a01b038316600081815260036020526040908190208054850190555133907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef906107079086815260200190565b60025460009080156106a35761069e610d2d600a5490565b84908361135f565b6001600160a01b0381166000908152600c6020526040812054421015610d9d5760405162461bcd60e51b815260206004820152600e60248201527f436f6f6c696e6720706572696f6400000000000000000000000000000000000060448201526064016108bf565b610da684610719565b9050336001600160a01b03831614610e16576001600160a01b03821660009081526004602090815260408083203384529091529020546000198114610e1457610def8282611b28565b6001600160a01b03841660009081526004602090815260408083203384529091529020555b505b610e2084826115ce565b610e2a82826116dd565b60408051858152602081018390526001600160a01b03808516929086169133917ffbde797d201c681b91056529119e0b02407c7bb96a4a2c75c01fc9667232c8db910160405180910390a46106a56001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000168486611751565b6001600160a01b0381166000908152600c6020526040812054421015610f115760405162461bcd60e51b815260206004820152600e60248201527f436f6f6c696e6720706572696f6400000000000000000000000000000000000060448201526064016108bf565b336001600160a01b03831614610f7f576001600160a01b03821660009081526004602090815260408083203384529091529020546000198114610f7d57610f588582611b28565b6001600160a01b03841660009081526004602090815260408083203384529091529020555b505b610f8884610938565b905080610fd75760405162461bcd60e51b815260206004820152600b60248201527f5a45524f5f41535345545300000000000000000000000000000000000000000060448201526064016108bf565b610fe181856115ce565b610feb82856116dd565b60408051828152602081018690526001600160a01b03808516929086169133917ffbde797d201c681b91056529119e0b02407c7bb96a4a2c75c01fc9667232c8db910160405180910390a46106a56001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000168483611751565b600980546105fd90611aa5565b60025460009080156106a35761069e81611090600a5490565b859190611340565b6001600160a01b0381166000908152600360205260408120546107139061067e565b4284101561110a5760405162461bcd60e51b815260206004820152601760248201527f5045524d49545f444541444c494e455f4558504952454400000000000000000060448201526064016108bf565b600060016111166108e2565b6001600160a01b038a811660008181526005602090815260409182902080546001810190915582517f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c98184015280840194909452938d166060840152608083018c905260a083019390935260c08083018b90528151808403909101815260e0830190915280519201919091207f19010000000000000000000000000000000000000000000000000000000000006101008301526101028201929092526101228101919091526101420160408051601f198184030181528282528051602091820120600084529083018083525260ff871690820152606081018590526080810184905260a0016020604051602081039080840390855afa15801561123d573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b038116158015906112735750876001600160a01b0316816001600160a01b0316145b6112bf5760405162461bcd60e51b815260206004820152600e60248201527f494e56414c49445f5349474e455200000000000000000000000000000000000060448201526064016108bf565b6001600160a01b0390811660009081526004602090815260408083208a8516808552908352928190208990555188815291928a16917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a350505050505050565b600880546105fd90611aa5565b600061071382611077565b82820281151584158583048514171661135857600080fd5b0492915050565b82820281151584158583048514171661137757600080fd5b6001826001830304018115150290509392505050565b60007f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f60006040516113bf9190611b70565b6040805191829003822060208301939093528101919091527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc660608201524660808201523060a082015260c00160405160208183030381529060405280519060200120905090565b60006040517f23b872dd0000000000000000000000000000000000000000000000000000000081528460048201528360248201528260448201526020600060648360008a5af13d15601f3d11600160005114161716915050806114cc5760405162461bcd60e51b815260206004820152601460248201527f5452414e534645525f46524f4d5f4641494c454400000000000000000000000060448201526064016108bf565b5050505050565b80600260008282546114e59190611b3f565b90915550506001600160a01b0382166000818152600360209081526040808320805486019055518481527fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91015b60405180910390a35050565b81600a60008282546115519190611b3f565b9091555050600654611590906001600160a01b037f000000000000000000000000000000000000000000000000000000000000000081169116846117f6565b6006546115ca906001600160a01b037f00000000000000000000000000000000000000000000000000000000000000008116911684611751565b5050565b6115d661073a565b82111561164b5760405162461bcd60e51b815260206004820152603160248201527f4e6f7420656e6f75676820617661696c61626c652061737365747320746f207360448201527f617469736679207769746864726177616c00000000000000000000000000000060648201526084016108bf565b6006546040517fc49785b4000000000000000000000000000000000000000000000000000000008152600481018490526001600160a01b039091169063c49785b490602401600060405180830381600087803b1580156116aa57600080fd5b505af11580156116be573d6000803e3d6000fd5b5050505081600a60008282546116d49190611b28565b90915550505050565b6001600160a01b03821660009081526003602052604081208054839290611705908490611b28565b90915550506002805482900390556040518181526000906001600160a01b038416907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef90602001611533565b60006040517fa9059cbb000000000000000000000000000000000000000000000000000000008152836004820152826024820152602060006044836000895af13d15601f3d11600160005114161716915050806117f05760405162461bcd60e51b815260206004820152600f60248201527f5452414e534645525f4641494c4544000000000000000000000000000000000060448201526064016108bf565b50505050565b60006040517f095ea7b3000000000000000000000000000000000000000000000000000000008152836004820152826024820152602060006044836000895af13d15601f3d11600160005114161716915050806117f05760405162461bcd60e51b815260206004820152600e60248201527f415050524f56455f4641494c454400000000000000000000000000000000000060448201526064016108bf565b600060208083528351808285015260005b818110156118c2578581018301518582016040015282016118a6565b818111156118d4576000604083870101525b50601f01601f1916929092016040019392505050565b6000602082840312156118fc57600080fd5b5035919050565b80356001600160a01b038116811461191a57600080fd5b919050565b6000806040838503121561193257600080fd5b61193b83611903565b946020939093013593505050565b60008060006060848603121561195e57600080fd5b61196784611903565b925061197560208501611903565b9150604084013590509250925092565b60006020828403121561199757600080fd5b6106a582611903565b600080604083850312156119b357600080fd5b823591506119c360208401611903565b90509250929050565b6000806000606084860312156119e157600080fd5b833592506119f160208501611903565b91506119ff60408501611903565b90509250925092565b600080600080600080600060e0888a031215611a2357600080fd5b611a2c88611903565b9650611a3a60208901611903565b95506040880135945060608801359350608088013560ff81168114611a5e57600080fd5b9699959850939692959460a0840135945060c09093013592915050565b60008060408385031215611a8e57600080fd5b611a9783611903565b91506119c360208401611903565b600181811c90821680611ab957607f821691505b60208210811415611af3577f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b50919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b600082821015611b3a57611b3a611af9565b500390565b60008219821115611b5257611b52611af9565b500190565b600060208284031215611b6957600080fd5b5051919050565b600080835481600182811c915080831680611b8c57607f831692505b6020808410821415611bc5577f4e487b710000000000000000000000000000000000000000000000000000000086526022600452602486fd5b818015611bd95760018114611c0857611c35565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00861689528489019650611c35565b60008a81526020902060005b86811015611c2d5781548b820152908501908301611c14565b505084890196505b50949897505050505050505056fea264697066735822122085722d249366f7c2468de952363152d3789a187b2dfb30d7582c1ab13a1f2e7f64736f6c63430008090033000000000000000000000000912ce59144191c1204e64559fe8253a0e49e6548000000000000000000000000ff970a61a04b1ca14834a43f5de4533ebddb5cc800000000000000000000000000000000000000000000000000000000000000120000000000000000000000000000000000000000000000000000000000000006000000000000000000000000e592427a0aece92de3edee1f18e0157c0586156400000000000000000000000000000000000000000000000000000002540be400000000000000000000000000000000000000000000000000000009184e72a00000000000000000000000000035cfa5ac5edb29769f92e16b6b68efa60b810a8e000000000000000000000000a03f6f7c2b7fe70fcaf05c98f4fb083087ba58fd000000000000000000000000bdb0f3330d4b32b3133738451c8237d0a8af308100000000000000000000000055594cce8cc0014ea08c49fd820d731308f204c1000000000000000000000000000000000000000000000000000000000098968000000000000000000000000000000000000000000000000000000000004c4b400000000000000000000000000000000000000000000000000000000000000fa00000000000000000000000000000000000000000000000000000000000000e10
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
000000000000000000000000912ce59144191c1204e64559fe8253a0e49e6548000000000000000000000000ff970a61a04b1ca14834a43f5de4533ebddb5cc800000000000000000000000000000000000000000000000000000000000000120000000000000000000000000000000000000000000000000000000000000006000000000000000000000000e592427a0aece92de3edee1f18e0157c0586156400000000000000000000000000000000000000000000000000000002540be400000000000000000000000000000000000000000000000000000009184e72a00000000000000000000000000035cfa5ac5edb29769f92e16b6b68efa60b810a8e000000000000000000000000a03f6f7c2b7fe70fcaf05c98f4fb083087ba58fd000000000000000000000000bdb0f3330d4b32b3133738451c8237d0a8af308100000000000000000000000055594cce8cc0014ea08c49fd820d731308f204c1000000000000000000000000000000000000000000000000000000000098968000000000000000000000000000000000000000000000000000000000004c4b400000000000000000000000000000000000000000000000000000000000000fa00000000000000000000000000000000000000000000000000000000000000e10
-----Decoded View---------------
Arg [0] : _base (address): 0x912ce59144191c1204e64559fe8253a0e49e6548
Arg [1] : _quote (address): 0xff970a61a04b1ca14834a43f5de4533ebddb5cc8
Arg [2] : _baseDecimals (uint256): 18
Arg [3] : _quoteDecimals (uint256): 6
Arg [4] : _uniswapV3Router (address): 0xe592427a0aece92de3edee1f18e0157c05861564
Arg [5] : config (tuple): System.Collections.Generic.List`1[Nethereum.ABI.FunctionEncoding.ParameterOutput]
-----Encoded View---------------
15 Constructor Arguments found :
Arg [0] : 000000000000000000000000912ce59144191c1204e64559fe8253a0e49e6548
Arg [1] : 000000000000000000000000ff970a61a04b1ca14834a43f5de4533ebddb5cc8
Arg [2] : 0000000000000000000000000000000000000000000000000000000000000012
Arg [3] : 0000000000000000000000000000000000000000000000000000000000000006
Arg [4] : 000000000000000000000000e592427a0aece92de3edee1f18e0157c05861564
Arg [5] : 00000000000000000000000000000000000000000000000000000002540be400
Arg [6] : 000000000000000000000000000000000000000000000000000009184e72a000
Arg [7] : 00000000000000000000000035cfa5ac5edb29769f92e16b6b68efa60b810a8e
Arg [8] : 000000000000000000000000a03f6f7c2b7fe70fcaf05c98f4fb083087ba58fd
Arg [9] : 000000000000000000000000bdb0f3330d4b32b3133738451c8237d0a8af3081
Arg [10] : 00000000000000000000000055594cce8cc0014ea08c49fd820d731308f204c1
Arg [11] : 0000000000000000000000000000000000000000000000000000000000989680
Arg [12] : 00000000000000000000000000000000000000000000000000000000004c4b40
Arg [13] : 0000000000000000000000000000000000000000000000000000000000000fa0
Arg [14] : 0000000000000000000000000000000000000000000000000000000000000e10
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.