Contract Overview
Balance:
0 ETH
ETH Value:
$0.00
My Name Tag:
Not Available
[ Download CSV Export ]
Latest 25 internal transaction
[ Download CSV Export ]
Contract Name:
BufferRouter
Compiler Version
v0.8.4+commit.c7e474f2
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.8.4; import "ReentrancyGuard.sol"; import "AccessControl.sol"; import "ECDSA.sol"; import "SafeERC20.sol"; import "Interfaces.sol"; /** * @author Heisenberg * @notice Buffer Options Router Contract */ contract BufferRouter is AccessControl, IBufferRouter { using SafeERC20 for ERC20; uint16 MAX_WAIT_TIME = 1 minutes; uint256 public nextQueueId = 0; address public publisher; bool public isInPrivateKeeperMode = true; mapping(address => uint256[]) public userQueuedIds; mapping(address => uint256[]) public userCancelledQueuedIds; mapping(uint256 => QueuedTrade) public queuedTrades; mapping(address => bool) public contractRegistry; mapping(address => bool) public isKeeper; constructor(address _publisher) { publisher = _publisher; _setupRole(DEFAULT_ADMIN_ROLE, msg.sender); } /************************************************ * ADMIN ONLY FUNCTIONS ***********************************************/ function setContractRegistry(address targetContract, bool register) external onlyRole(DEFAULT_ADMIN_ROLE) { contractRegistry[targetContract] = register; } function setKeeper(address _keeper, bool _isActive) external onlyRole(DEFAULT_ADMIN_ROLE) { isKeeper[_keeper] = _isActive; } function setInPrivateKeeperMode() external onlyRole(DEFAULT_ADMIN_ROLE) { isInPrivateKeeperMode = !isInPrivateKeeperMode; } /************************************************ * USER WRITE FUNCTIONS ***********************************************/ /** * @notice Adds an option creation request in the queue */ function initiateTrade( uint256 totalFee, uint256 period, bool isAbove, address targetContract, uint256 expectedStrike, uint256 slippage, bool allowPartialFill, string memory referralCode, uint256 traderNFTId ) external returns (uint256 queueId) { // Checks if the target contract has been registered require( contractRegistry[targetContract], "Router: Unauthorized contract" ); IBufferBinaryOptions optionsContract = IBufferBinaryOptions( targetContract ); optionsContract.runInitialChecks(slippage, period, totalFee); // Transfer the fee specified from the user to this contract. // User has to approve first inorder to execute this function ERC20(optionsContract.tokenX()).safeTransferFrom( msg.sender, address(this), totalFee ); queueId = nextQueueId; nextQueueId++; QueuedTrade memory queuedTrade = QueuedTrade( queueId, userQueueCount(msg.sender), msg.sender, totalFee, period, isAbove, targetContract, expectedStrike, slippage, allowPartialFill, block.timestamp, true, referralCode, traderNFTId ); queuedTrades[queueId] = queuedTrade; userQueuedIds[msg.sender].push(queueId); emit InitiateTrade(msg.sender, queueId, block.timestamp); } /** * @notice Cancels a queued traded. Can only be called by the trade owner */ function cancelQueuedTrade(uint256 queueId) external { QueuedTrade memory queuedTrade = queuedTrades[queueId]; require(msg.sender == queuedTrade.user, "Router: Forbidden"); require(queuedTrade.isQueued, "Router: Trade has already been opened"); _cancelQueuedTrade(queueId); emit CancelTrade(queuedTrade.user, queueId, "User Cancelled"); } /************************************************ * KEEPER ONLY FUNCTIONS ***********************************************/ /** * @notice Verifies the trade parameter via the signature and resolves all the valid queued trades */ function resolveQueuedTrades(OpenTradeParams[] calldata params) external { _validateKeeper(); for (uint32 index = 0; index < params.length; index++) { OpenTradeParams memory currentParams = params[index]; QueuedTrade memory queuedTrade = queuedTrades[ currentParams.queueId ]; IBufferBinaryOptions optionsContract = IBufferBinaryOptions( queuedTrade.targetContract ); bool isSignerVerifed = _validateSigner( currentParams.timestamp, optionsContract.assetPair(), currentParams.price, currentParams.signature ); // Silently fail if the signature doesn't match if (!isSignerVerifed) { emit FailResolve( currentParams.queueId, "Router: Signature didn't match" ); continue; } if ( !queuedTrade.isQueued || currentParams.timestamp != queuedTrade.queuedTime ) { // Trade has already been opened or cancelled or the timestamp is wrong. // So ignore this trade. continue; } // If the opening time is much greater than the queue time then cancel the trade if (block.timestamp - queuedTrade.queuedTime <= MAX_WAIT_TIME) { _openQueuedTrade(currentParams.queueId, currentParams.price); } else { _cancelQueuedTrade(currentParams.queueId); emit CancelTrade( queuedTrade.user, currentParams.queueId, "Wait time too high" ); } } } /** * @notice Verifies the option parameter via the signature and unlocks an array of options */ function unlockOptions(CloseTradeParams[] calldata optionData) external { _validateKeeper(); uint32 arrayLength = uint32(optionData.length); for (uint32 i = 0; i < arrayLength; i++) { CloseTradeParams memory params = optionData[i]; IBufferBinaryOptions optionsContract = IBufferBinaryOptions( params.targetContract ); (, , , , , uint256 expiration, , , ) = optionsContract.options( params.optionId ); bool isSignerVerifed = _validateSigner( params.expiryTimestamp, optionsContract.assetPair(), params.priceAtExpiry, params.signature ); // Silently fail if the timestamp of the signature is wrong if (expiration != params.expiryTimestamp) { emit FailUnlock(params.optionId, "Router: Wrong price"); continue; } // Silently fail if the signature doesn't match if (!isSignerVerifed) { emit FailUnlock( params.optionId, "Router: Signature didn't match" ); continue; } try optionsContract.unlock(params.optionId, params.priceAtExpiry) {} catch Error(string memory reason) { emit FailUnlock(params.optionId, reason); continue; } } } /************************************************ * READ ONLY FUNCTIONS ***********************************************/ function userQueueCount(address user) public view returns (uint256) { return userQueuedIds[user].length; } function userCancelledQueueCount(address user) external view returns (uint256) { return userCancelledQueuedIds[user].length; } /************************************************ * INTERNAL FUNCTIONS ***********************************************/ function _validateKeeper() private view { require( !isInPrivateKeeperMode || isKeeper[msg.sender], "Keeper: forbidden" ); } function _validateSigner( uint256 timestamp, string memory assetPair, uint256 price, bytes memory signature ) internal view returns (bool) { bytes32 digest = ECDSA.toEthSignedMessageHash( keccak256(abi.encodePacked(assetPair, timestamp, price)) ); (address recoveredSigner, ECDSA.RecoverError error) = ECDSA.tryRecover( digest, signature ); if (error == ECDSA.RecoverError.NoError) { return recoveredSigner == publisher; } else { return false; } } function _openQueuedTrade(uint256 queueId, uint256 price) internal { QueuedTrade storage queuedTrade = queuedTrades[queueId]; IBufferBinaryOptions optionsContract = IBufferBinaryOptions( queuedTrade.targetContract ); // Check if slippage lies within the bounds bool isSlippageWithinRange = optionsContract.isStrikeValid( queuedTrade.slippage, price, queuedTrade.expectedStrike ); if (!isSlippageWithinRange) { _cancelQueuedTrade(queueId); emit CancelTrade( queuedTrade.user, queueId, "Slippage limit exceeds" ); return; } // Check all the parameters and compute the amount and revised fee uint256 amount; uint256 revisedFee; bool isReferralValid; IBufferBinaryOptions.OptionParams memory optionParams = IBufferBinaryOptions.OptionParams( queuedTrade.expectedStrike, 0, queuedTrade.period, queuedTrade.isAbove, queuedTrade.allowPartialFill, queuedTrade.totalFee, queuedTrade.user, queuedTrade.referralCode, queuedTrade.traderNFTId ); try optionsContract.checkParams(optionParams) returns ( uint256 _amount, uint256 _revisedFee, bool _isReferralValid ) { (amount, revisedFee, isReferralValid) = ( _amount, _revisedFee, _isReferralValid ); } catch Error(string memory reason) { _cancelQueuedTrade(queueId); emit CancelTrade(queuedTrade.user, queueId, reason); return; } queuedTrade.isQueued = false; // Transfer the fee to the target options contract ERC20 tokenX = ERC20(optionsContract.tokenX()); tokenX.safeTransfer(queuedTrade.targetContract, revisedFee); // Refund the user in case the trade amount was lesser if (revisedFee < queuedTrade.totalFee) { tokenX.safeTransfer( queuedTrade.user, queuedTrade.totalFee - revisedFee ); } optionParams.totalFee = revisedFee; optionParams.strike = price; optionParams.amount = amount; uint256 optionId = optionsContract.createFromRouter( optionParams, isReferralValid, queuedTrade.queuedTime ); emit OpenTrade(queuedTrade.user, queueId, optionId); } function _cancelQueuedTrade(uint256 queueId) internal { QueuedTrade storage queuedTrade = queuedTrades[queueId]; IBufferBinaryOptions optionsContract = IBufferBinaryOptions( queuedTrade.targetContract ); queuedTrade.isQueued = false; ERC20(optionsContract.tokenX()).safeTransfer( queuedTrade.user, queuedTrade.totalFee ); userCancelledQueuedIds[queuedTrade.user].push(queueId); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (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() { // On the first call to nonReentrant, _notEntered will be true require(_status != _ENTERED, "ReentrancyGuard: reentrant call"); // Any calls to nonReentrant after this point will fail _status = _ENTERED; _; // 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.7.0) (access/AccessControl.sol) pragma solidity ^0.8.0; import "IAccessControl.sol"; import "Context.sol"; import "Strings.sol"; import "ERC165.sol"; /** * @dev Contract module that allows children to implement role-based access * control mechanisms. This is a lightweight version that doesn't allow enumerating role * members except through off-chain means by accessing the contract event logs. Some * applications may benefit from on-chain enumerability, for those cases see * {AccessControlEnumerable}. * * Roles are referred to by their `bytes32` identifier. These should be exposed * in the external API and be unique. The best way to achieve this is by * using `public constant` hash digests: * * ``` * bytes32 public constant MY_ROLE = keccak256("MY_ROLE"); * ``` * * Roles can be used to represent a set of permissions. To restrict access to a * function call, use {hasRole}: * * ``` * function foo() public { * require(hasRole(MY_ROLE, msg.sender)); * ... * } * ``` * * Roles can be granted and revoked dynamically via the {grantRole} and * {revokeRole} functions. Each role has an associated admin role, and only * accounts that have a role's admin role can call {grantRole} and {revokeRole}. * * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means * that only accounts with this role will be able to grant or revoke other * roles. More complex role relationships can be created by using * {_setRoleAdmin}. * * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to * grant and revoke this role. Extra precautions should be taken to secure * accounts that have been granted it. */ abstract contract AccessControl is Context, IAccessControl, ERC165 { struct RoleData { mapping(address => bool) members; bytes32 adminRole; } mapping(bytes32 => RoleData) private _roles; bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00; /** * @dev Modifier that checks that an account has a specific role. Reverts * with a standardized message including the required role. * * The format of the revert reason is given by the following regular expression: * * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/ * * _Available since v4.1._ */ modifier onlyRole(bytes32 role) { _checkRole(role); _; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId); } /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) public view virtual override returns (bool) { return _roles[role].members[account]; } /** * @dev Revert with a standard message if `_msgSender()` is missing `role`. * Overriding this function changes the behavior of the {onlyRole} modifier. * * Format of the revert message is described in {_checkRole}. * * _Available since v4.6._ */ function _checkRole(bytes32 role) internal view virtual { _checkRole(role, _msgSender()); } /** * @dev Revert with a standard message if `account` is missing `role`. * * The format of the revert reason is given by the following regular expression: * * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/ */ function _checkRole(bytes32 role, address account) internal view virtual { if (!hasRole(role, account)) { revert( string( abi.encodePacked( "AccessControl: account ", Strings.toHexString(uint160(account), 20), " is missing role ", Strings.toHexString(uint256(role), 32) ) ) ); } } /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) public view virtual override returns (bytes32) { return _roles[role].adminRole; } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. * * May emit a {RoleGranted} event. */ function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) { _grantRole(role, account); } /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. * * May emit a {RoleRevoked} event. */ function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) { _revokeRole(role, account); } /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been revoked `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `account`. * * May emit a {RoleRevoked} event. */ function renounceRole(bytes32 role, address account) public virtual override { require(account == _msgSender(), "AccessControl: can only renounce roles for self"); _revokeRole(role, account); } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. Note that unlike {grantRole}, this function doesn't perform any * checks on the calling account. * * May emit a {RoleGranted} event. * * [WARNING] * ==== * This function should only be called from the constructor when setting * up the initial roles for the system. * * Using this function in any other way is effectively circumventing the admin * system imposed by {AccessControl}. * ==== * * NOTE: This function is deprecated in favor of {_grantRole}. */ function _setupRole(bytes32 role, address account) internal virtual { _grantRole(role, account); } /** * @dev Sets `adminRole` as ``role``'s admin role. * * Emits a {RoleAdminChanged} event. */ function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual { bytes32 previousAdminRole = getRoleAdmin(role); _roles[role].adminRole = adminRole; emit RoleAdminChanged(role, previousAdminRole, adminRole); } /** * @dev Grants `role` to `account`. * * Internal function without access restriction. * * May emit a {RoleGranted} event. */ function _grantRole(bytes32 role, address account) internal virtual { if (!hasRole(role, account)) { _roles[role].members[account] = true; emit RoleGranted(role, account, _msgSender()); } } /** * @dev Revokes `role` from `account`. * * Internal function without access restriction. * * May emit a {RoleRevoked} event. */ function _revokeRole(bytes32 role, address account) internal virtual { if (hasRole(role, account)) { _roles[role].members[account] = false; emit RoleRevoked(role, account, _msgSender()); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol) pragma solidity ^0.8.0; /** * @dev External interface of AccessControl declared to support ERC165 detection. */ interface IAccessControl { /** * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole` * * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite * {RoleAdminChanged} not being emitted signaling this. * * _Available since v3.1._ */ event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole); /** * @dev Emitted when `account` is granted `role`. * * `sender` is the account that originated the contract call, an admin role * bearer except when using {AccessControl-_setupRole}. */ event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Emitted when `account` is revoked `role`. * * `sender` is the account that originated the contract call: * - if using `revokeRole`, it is the admin role bearer * - if using `renounceRole`, it is the role bearer (i.e. `account`) */ event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) external view returns (bool); /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {AccessControl-_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) external view returns (bytes32); /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function grantRole(bytes32 role, address account) external; /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function revokeRole(bytes32 role, address account) external; /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been granted `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `account`. */ function renounceRole(bytes32 role, address account) external; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (utils/Strings.sol) pragma solidity ^0.8.0; /** * @dev String operations. */ library Strings { bytes16 private constant _HEX_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) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @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] = _HEX_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } /** * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation. */ function toHexString(address addr) internal pure returns (string memory) { return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol) pragma solidity ^0.8.0; import "IERC165.sol"; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165).interfaceId; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.3) (utils/cryptography/ECDSA.sol) pragma solidity ^0.8.0; import "Strings.sol"; /** * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations. * * These functions can be used to verify that a message was signed by the holder * of the private keys of a given address. */ library ECDSA { enum RecoverError { NoError, InvalidSignature, InvalidSignatureLength, InvalidSignatureS, InvalidSignatureV } function _throwError(RecoverError error) private pure { if (error == RecoverError.NoError) { return; // no error: do nothing } else if (error == RecoverError.InvalidSignature) { revert("ECDSA: invalid signature"); } else if (error == RecoverError.InvalidSignatureLength) { revert("ECDSA: invalid signature length"); } else if (error == RecoverError.InvalidSignatureS) { revert("ECDSA: invalid signature 's' value"); } else if (error == RecoverError.InvalidSignatureV) { revert("ECDSA: invalid signature 'v' value"); } } /** * @dev Returns the address that signed a hashed message (`hash`) with * `signature` or error string. This address can then be used for verification purposes. * * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures: * this function rejects them by requiring the `s` value to be in the lower * half order, and the `v` value to be either 27 or 28. * * IMPORTANT: `hash` _must_ be the result of a hash operation for the * verification to be secure: it is possible to craft signatures that * recover to arbitrary addresses for non-hashed data. A safe way to ensure * this is by receiving a hash of the original message (which may otherwise * be too long), and then calling {toEthSignedMessageHash} on it. * * Documentation for signature generation: * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js] * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers] * * _Available since v4.3._ */ function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) { if (signature.length == 65) { bytes32 r; bytes32 s; uint8 v; // ecrecover takes the signature parameters, and the only way to get them // currently is to use assembly. /// @solidity memory-safe-assembly assembly { r := mload(add(signature, 0x20)) s := mload(add(signature, 0x40)) v := byte(0, mload(add(signature, 0x60))) } return tryRecover(hash, v, r, s); } else { return (address(0), RecoverError.InvalidSignatureLength); } } /** * @dev Returns the address that signed a hashed message (`hash`) with * `signature`. This address can then be used for verification purposes. * * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures: * this function rejects them by requiring the `s` value to be in the lower * half order, and the `v` value to be either 27 or 28. * * IMPORTANT: `hash` _must_ be the result of a hash operation for the * verification to be secure: it is possible to craft signatures that * recover to arbitrary addresses for non-hashed data. A safe way to ensure * this is by receiving a hash of the original message (which may otherwise * be too long), and then calling {toEthSignedMessageHash} on it. */ function recover(bytes32 hash, bytes memory signature) internal pure returns (address) { (address recovered, RecoverError error) = tryRecover(hash, signature); _throwError(error); return recovered; } /** * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately. * * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures] * * _Available since v4.3._ */ function tryRecover( bytes32 hash, bytes32 r, bytes32 vs ) internal pure returns (address, RecoverError) { bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff); uint8 v = uint8((uint256(vs) >> 255) + 27); return tryRecover(hash, v, r, s); } /** * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately. * * _Available since v4.2._ */ function recover( bytes32 hash, bytes32 r, bytes32 vs ) internal pure returns (address) { (address recovered, RecoverError error) = tryRecover(hash, r, vs); _throwError(error); return recovered; } /** * @dev Overload of {ECDSA-tryRecover} that receives the `v`, * `r` and `s` signature fields separately. * * _Available since v4.3._ */ function tryRecover( bytes32 hash, uint8 v, bytes32 r, bytes32 s ) internal pure returns (address, RecoverError) { // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most // signatures from current libraries generate a unique signature with an s-value in the lower half order. // // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept // these malleable signatures as well. if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) { return (address(0), RecoverError.InvalidSignatureS); } if (v != 27 && v != 28) { return (address(0), RecoverError.InvalidSignatureV); } // If the signature is valid (and not malleable), return the signer address address signer = ecrecover(hash, v, r, s); if (signer == address(0)) { return (address(0), RecoverError.InvalidSignature); } return (signer, RecoverError.NoError); } /** * @dev Overload of {ECDSA-recover} that receives the `v`, * `r` and `s` signature fields separately. */ function recover( bytes32 hash, uint8 v, bytes32 r, bytes32 s ) internal pure returns (address) { (address recovered, RecoverError error) = tryRecover(hash, v, r, s); _throwError(error); return recovered; } /** * @dev Returns an Ethereum Signed Message, created from a `hash`. This * produces hash corresponding to the one signed with the * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] * JSON-RPC method as part of EIP-191. * * See {recover}. */ function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) { // 32 is the length in bytes of hash, // enforced by the type signature above return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", hash)); } /** * @dev Returns an Ethereum Signed Message, created from `s`. This * produces hash corresponding to the one signed with the * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] * JSON-RPC method as part of EIP-191. * * See {recover}. */ function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) { return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n", Strings.toString(s.length), s)); } /** * @dev Returns an Ethereum Signed Typed Data, created from a * `domainSeparator` and a `structHash`. This produces hash corresponding * to the one signed with the * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`] * JSON-RPC method as part of EIP-712. * * See {recover}. */ function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) { return keccak256(abi.encodePacked("\x19\x01", domainSeparator, structHash)); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (token/ERC20/utils/SafeERC20.sol) pragma solidity ^0.8.0; import "IERC20.sol"; import "draft-IERC20Permit.sol"; import "Address.sol"; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20 { using Address for address; function safeTransfer( IERC20 token, address to, uint256 value ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom( IERC20 token, address from, address to, uint256 value ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } /** * @dev Deprecated. This function has issues similar to the ones found in * {IERC20-approve}, and its usage is discouraged. * * Whenever possible, use {safeIncreaseAllowance} and * {safeDecreaseAllowance} instead. */ function safeApprove( IERC20 token, address spender, uint256 value ) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' require( (value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function safeIncreaseAllowance( IERC20 token, address spender, uint256 value ) internal { uint256 newAllowance = token.allowance(address(this), spender) + value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function safeDecreaseAllowance( IERC20 token, address spender, uint256 value ) internal { unchecked { uint256 oldAllowance = token.allowance(address(this), spender); require(oldAllowance >= value, "SafeERC20: decreased allowance below zero"); uint256 newAllowance = oldAllowance - value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } } function safePermit( IERC20Permit token, address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) internal { uint256 nonceBefore = token.nonces(owner); token.permit(owner, spender, value, deadline, v, r, s); uint256 nonceAfter = token.nonces(owner); require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed"); } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function _callOptionalReturn(IERC20 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `to`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address to, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `from` to `to` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 amount ) external returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612]. * * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't * need to send a transaction, and thus is not required to hold Ether at all. */ interface IERC20Permit { /** * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens, * given ``owner``'s signed approval. * * IMPORTANT: The same issues {IERC20-approve} has related to transaction * ordering also apply here. * * Emits an {Approval} event. * * Requirements: * * - `spender` cannot be the zero address. * - `deadline` must be a timestamp in the future. * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner` * over the EIP712-formatted function arguments. * - the signature must use ``owner``'s current nonce (see {nonces}). * * For more information on the signature format, see the * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP * section]. */ function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external; /** * @dev Returns the current nonce for `owner`. This value must be * included whenever a signature is generated for {permit}. * * Every successful call to {permit} increases ``owner``'s nonce by one. This * prevents a signature from being used multiple times. */ function nonces(address owner) external view returns (uint256); /** * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}. */ // solhint-disable-next-line func-name-mixedcase function DOMAIN_SEPARATOR() external view returns (bytes32); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.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 functionCall(target, data, "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"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(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) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(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) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason 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 { // 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: BUSL-1.1 import "ERC20.sol"; pragma solidity 0.8.4; interface IKeeperPayment { function distributeForOpen( uint256 queueId, uint256 size, address keeper ) external; function distributeForClose( uint256 optionId, uint256 size, address keeper ) external; event DistriuteRewardForOpen(uint256 queueId, uint256 size, address keeper); event DistriuteRewardForClose( uint256 optionId, uint256 size, address keeper ); event UpdateOpenRewardPercent(uint32 value); event UpdateReward(uint32 value); } interface IBufferRouter { struct QueuedTrade { uint256 queueId; uint256 userQueueIndex; address user; uint256 totalFee; uint256 period; bool isAbove; address targetContract; uint256 expectedStrike; uint256 slippage; bool allowPartialFill; uint256 queuedTime; bool isQueued; string referralCode; uint256 traderNFTId; } struct Trade { uint256 queueId; uint256 price; } struct OpenTradeParams { uint256 queueId; uint256 timestamp; uint256 price; bytes signature; } struct CloseTradeParams { uint256 optionId; address targetContract; uint256 expiryTimestamp; uint256 priceAtExpiry; bytes signature; } event OpenTrade(address indexed account, uint256 queueId, uint256 optionId); event CancelTrade(address indexed account, uint256 queueId, string reason); event FailUnlock(uint256 optionId, string reason); event FailResolve(uint256 queueId, string reason); event InitiateTrade( address indexed account, uint256 queueId, uint256 queuedTime ); } interface IBufferBinaryOptions { event Create( address indexed account, uint256 indexed id, uint256 settlementFee, uint256 totalFee ); event Exercise( address indexed account, uint256 indexed id, uint256 profit, uint256 priceAtExpiration ); event Expire( uint256 indexed id, uint256 premium, uint256 priceAtExpiration ); event Pause(bool isPaused); event UpdateReferral( address user, address referrer, bool isReferralValid, uint256 totalFee, uint256 referrerFee, uint256 rebate, string referralCode ); function createFromRouter( OptionParams calldata optionParams, bool isReferralValid, uint256 queuedTime ) external returns (uint256 optionID); function checkParams(OptionParams calldata optionParams) external returns ( uint256 amount, uint256 revisedFee, bool isReferralValid ); function runInitialChecks( uint256 slippage, uint256 period, uint256 totalFee ) external view; function isStrikeValid( uint256 slippage, uint256 strike, uint256 expectedStrike ) external view returns (bool); function tokenX() external view returns (ERC20); function pool() external view returns (ILiquidityPool); function config() external view returns (IOptionsConfig); function assetPair() external view returns (string calldata); function fees( uint256 amount, address user, bool isAbove, string calldata referralCode, uint256 traderNFTId ) external view returns ( uint256 total, uint256 settlementFee, uint256 premium ); function getMaxUtilization() external view returns (uint256 maxAmount); enum State { Inactive, Active, Exercised, Expired } enum AssetCategory { Forex, Crypto, Commodities } struct OptionExpiryData { uint256 optionId; uint256 priceAtExpiration; } struct Option { State state; uint256 strike; uint256 amount; uint256 lockedAmount; uint256 premium; uint256 expiration; bool isAbove; uint256 totalFee; uint256 createdAt; } struct OptionParams { uint256 strike; uint256 amount; uint256 period; bool isAbove; bool allowPartialFill; uint256 totalFee; address user; string referralCode; uint256 traderNFTId; } function options(uint256 optionId) external view returns ( State state, uint256 strike, uint256 amount, uint256 lockedAmount, uint256 premium, uint256 expiration, bool isAbove, uint256 totalFee, uint256 createdAt ); function unlock(uint256 optionID, uint256 priceAtExpiration) external; } interface ILiquidityPool { struct LockedAmount { uint256 timestamp; uint256 amount; } struct ProvidedLiquidity { uint256 unlockedAmount; LockedAmount[] lockedAmounts; uint256 nextIndexForUnlock; } struct LockedLiquidity { uint256 amount; uint256 premium; bool locked; } event Profit(uint256 indexed id, uint256 amount); event Loss(uint256 indexed id, uint256 amount); event Provide(address indexed account, uint256 amount, uint256 writeAmount); event UpdateMaxLiquidity(uint256 indexed maxLiquidity); event Withdraw( address indexed account, uint256 amount, uint256 writeAmount ); function unlock(uint256 id) external; function totalTokenXBalance() external view returns (uint256 amount); function availableBalance() external view returns (uint256 balance); function send( uint256 id, address account, uint256 amount ) external; function lock( uint256 id, uint256 tokenXAmount, uint256 premium ) external; } interface IOptionsConfig { struct Window { uint8 startHour; uint8 startMinute; uint8 endHour; uint8 endMinute; } event UpdateMarketTime(); event UpdateMaxPeriod(uint32 value); event UpdateMinPeriod(uint32 value); event UpdateOptionFeePerTxnLimitPercent(uint16 value); event UpdateOverallPoolUtilizationLimit(uint16 value); event UpdateSettlementFeeDisbursalContract(address value); event UpdatetraderNFTContract(address value); event UpdateAssetUtilizationLimit(uint16 value); event UpdateMinFee(uint256 value); function traderNFTContract() external view returns (address); function settlementFeeDisbursalContract() external view returns (address); function marketTimes(uint8) external view returns ( uint8, uint8, uint8, uint8 ); function assetUtilizationLimit() external view returns (uint16); function overallPoolUtilizationLimit() external view returns (uint16); function maxPeriod() external view returns (uint32); function minPeriod() external view returns (uint32); function minFee() external view returns (uint256); function optionFeePerTxnLimitPercent() external view returns (uint16); } interface ITraderNFT { function tokenOwner(uint256 id) external view returns (address user); function tokenTierMappings(uint256 id) external view returns (uint8 tier); event UpdateTiers(uint256[] tokenIds, uint8[] tiers, uint256[] batchIds); } interface IReferralStorage { function codeOwner(string memory _code) external view returns (address); function traderReferralCodes(address) external view returns (string memory); function getTraderReferralInfo(address user) external view returns (string memory, address); function setTraderReferralCode(address user, string memory _code) external; function setReferrerTier(address, uint8) external; function referrerTierStep(uint8 referralTier) external view returns (uint8 step); function referrerTierDiscount(uint8 referralTier) external view returns (uint32 discount); function referrerTier(address referrer) external view returns (uint8 tier); struct ReferrerData { uint256 tradeVolume; uint256 rebate; uint256 trades; } struct ReferreeData { uint256 tradeVolume; uint256 rebate; } struct ReferralData { ReferrerData referrerData; ReferreeData referreeData; } struct Tier { uint256 totalRebate; // e.g. 2400 for 24% uint256 discountShare; // 5000 for 50%/50%, 7000 for 30% rebates/70% discount } event UpdateTraderReferralCode(address indexed account, string code); event UpdateReferrerTier(address referrer, uint8 tierId); event RegisterCode(address indexed account, string code); event SetCodeOwner( address indexed account, address newAccount, string code ); } interface IBufferOptionsForReader is IBufferBinaryOptions { function baseSettlementFeePercentageForAbove() external view returns (uint16); function baseSettlementFeePercentageForBelow() external view returns (uint16); function referral() external view returns (IReferralStorage); function stepSize() external view returns (uint16); function _getSettlementFeeDiscount( address referrer, address user, uint256 traderNFTId ) external view returns (bool isReferralValid, uint8 maxStep); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (token/ERC20/ERC20.sol) pragma solidity ^0.8.0; import "IERC20.sol"; import "IERC20Metadata.sol"; import "Context.sol"; /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin Contracts guidelines: functions revert * instead returning `false` on failure. This behavior is nonetheless * conventional and does not conflict with the expectations of ERC20 * applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */ contract ERC20 is Context, IERC20, IERC20Metadata { mapping(address => uint256) private _balances; mapping(address => mapping(address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; /** * @dev Sets the values for {name} and {symbol}. * * The default value of {decimals} is 18. To select a different value for * {decimals} you should overload it. * * All two of these values are immutable: they can only be set once during * construction. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev Returns the name of the token. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5.05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless this function is * overridden; * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual override returns (uint8) { return 18; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `to` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address to, uint256 amount) public virtual override returns (bool) { address owner = _msgSender(); _transfer(owner, to, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on * `transferFrom`. This is semantically equivalent to an infinite approval. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { address owner = _msgSender(); _approve(owner, spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * NOTE: Does not update the allowance if the current allowance * is the maximum `uint256`. * * Requirements: * * - `from` and `to` cannot be the zero address. * - `from` must have a balance of at least `amount`. * - the caller must have allowance for ``from``'s tokens of at least * `amount`. */ function transferFrom( address from, address to, uint256 amount ) public virtual override returns (bool) { address spender = _msgSender(); _spendAllowance(from, spender, amount); _transfer(from, to, amount); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { address owner = _msgSender(); _approve(owner, spender, allowance(owner, spender) + addedValue); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { address owner = _msgSender(); uint256 currentAllowance = allowance(owner, spender); require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); unchecked { _approve(owner, spender, currentAllowance - subtractedValue); } return true; } /** * @dev Moves `amount` of tokens from `from` to `to`. * * This internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `from` must have a balance of at least `amount`. */ function _transfer( address from, address to, uint256 amount ) internal virtual { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(from, to, amount); uint256 fromBalance = _balances[from]; require(fromBalance >= amount, "ERC20: transfer amount exceeds balance"); unchecked { _balances[from] = fromBalance - amount; } _balances[to] += amount; emit Transfer(from, to, amount); _afterTokenTransfer(from, to, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply += amount; _balances[account] += amount; emit Transfer(address(0), account, amount); _afterTokenTransfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); uint256 accountBalance = _balances[account]; require(accountBalance >= amount, "ERC20: burn amount exceeds balance"); unchecked { _balances[account] = accountBalance - amount; } _totalSupply -= amount; emit Transfer(account, address(0), amount); _afterTokenTransfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve( address owner, address spender, uint256 amount ) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Updates `owner` s allowance for `spender` based on spent `amount`. * * Does not update the allowance amount in case of infinite allowance. * Revert if not enough allowance is available. * * Might emit an {Approval} event. */ function _spendAllowance( address owner, address spender, uint256 amount ) internal virtual { uint256 currentAllowance = allowance(owner, spender); if (currentAllowance != type(uint256).max) { require(currentAllowance >= amount, "ERC20: insufficient allowance"); unchecked { _approve(owner, spender, currentAllowance - amount); } } } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 amount ) internal virtual {} /** * @dev Hook that is called after any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * has been transferred to `to`. * - when `from` is zero, `amount` tokens have been minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens have been burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _afterTokenTransfer( address from, address to, uint256 amount ) internal virtual {} }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol) pragma solidity ^0.8.0; import "IERC20.sol"; /** * @dev Interface for the optional metadata functions from the ERC20 standard. * * _Available since v4.1._ */ interface IERC20Metadata is IERC20 { /** * @dev Returns the name of the token. */ function name() external view returns (string memory); /** * @dev Returns the symbol of the token. */ function symbol() external view returns (string memory); /** * @dev Returns the decimals places of the token. */ function decimals() external view returns (uint8); }
{ "evmVersion": "istanbul", "optimizer": { "enabled": true, "runs": 1 }, "libraries": { "BufferRouter.sol": {} }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } } }
[{"inputs":[{"internalType":"address","name":"_publisher","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"uint256","name":"queueId","type":"uint256"},{"indexed":false,"internalType":"string","name":"reason","type":"string"}],"name":"CancelTrade","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"queueId","type":"uint256"},{"indexed":false,"internalType":"string","name":"reason","type":"string"}],"name":"FailResolve","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"optionId","type":"uint256"},{"indexed":false,"internalType":"string","name":"reason","type":"string"}],"name":"FailUnlock","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"uint256","name":"queueId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"queuedTime","type":"uint256"}],"name":"InitiateTrade","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"uint256","name":"queueId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"optionId","type":"uint256"}],"name":"OpenTrade","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"queueId","type":"uint256"}],"name":"cancelQueuedTrade","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"contractRegistry","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"totalFee","type":"uint256"},{"internalType":"uint256","name":"period","type":"uint256"},{"internalType":"bool","name":"isAbove","type":"bool"},{"internalType":"address","name":"targetContract","type":"address"},{"internalType":"uint256","name":"expectedStrike","type":"uint256"},{"internalType":"uint256","name":"slippage","type":"uint256"},{"internalType":"bool","name":"allowPartialFill","type":"bool"},{"internalType":"string","name":"referralCode","type":"string"},{"internalType":"uint256","name":"traderNFTId","type":"uint256"}],"name":"initiateTrade","outputs":[{"internalType":"uint256","name":"queueId","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"isInPrivateKeeperMode","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"isKeeper","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"nextQueueId","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"publisher","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"queuedTrades","outputs":[{"internalType":"uint256","name":"queueId","type":"uint256"},{"internalType":"uint256","name":"userQueueIndex","type":"uint256"},{"internalType":"address","name":"user","type":"address"},{"internalType":"uint256","name":"totalFee","type":"uint256"},{"internalType":"uint256","name":"period","type":"uint256"},{"internalType":"bool","name":"isAbove","type":"bool"},{"internalType":"address","name":"targetContract","type":"address"},{"internalType":"uint256","name":"expectedStrike","type":"uint256"},{"internalType":"uint256","name":"slippage","type":"uint256"},{"internalType":"bool","name":"allowPartialFill","type":"bool"},{"internalType":"uint256","name":"queuedTime","type":"uint256"},{"internalType":"bool","name":"isQueued","type":"bool"},{"internalType":"string","name":"referralCode","type":"string"},{"internalType":"uint256","name":"traderNFTId","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"queueId","type":"uint256"},{"internalType":"uint256","name":"timestamp","type":"uint256"},{"internalType":"uint256","name":"price","type":"uint256"},{"internalType":"bytes","name":"signature","type":"bytes"}],"internalType":"struct IBufferRouter.OpenTradeParams[]","name":"params","type":"tuple[]"}],"name":"resolveQueuedTrades","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"targetContract","type":"address"},{"internalType":"bool","name":"register","type":"bool"}],"name":"setContractRegistry","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"setInPrivateKeeperMode","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_keeper","type":"address"},{"internalType":"bool","name":"_isActive","type":"bool"}],"name":"setKeeper","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"optionId","type":"uint256"},{"internalType":"address","name":"targetContract","type":"address"},{"internalType":"uint256","name":"expiryTimestamp","type":"uint256"},{"internalType":"uint256","name":"priceAtExpiry","type":"uint256"},{"internalType":"bytes","name":"signature","type":"bytes"}],"internalType":"struct IBufferRouter.CloseTradeParams[]","name":"optionData","type":"tuple[]"}],"name":"unlockOptions","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"}],"name":"userCancelledQueueCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"userCancelledQueuedIds","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"}],"name":"userQueueCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"userQueuedIds","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"}]
Contract Creation Code
60806040526001805461ffff1916603c17905560006002556003805460ff60a01b1916600160a01b1790553480156200003757600080fd5b5060405162002e2c38038062002e2c8339810160408190526200005a9162000139565b600380546001600160a01b0319166001600160a01b0383161790556200008260003362000089565b5062000169565b62000095828262000099565b5050565b6000828152602081815260408083206001600160a01b038516845290915290205460ff1662000095576000828152602081815260408083206001600160a01b03851684529091529020805460ff19166001179055620000f53390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b6000602082840312156200014b578081fd5b81516001600160a01b038116811462000162578182fd5b9392505050565b612cb380620001796000396000f3fe608060405234801561001057600080fd5b50600436106101285760003560e01c806301ffc9a71461012d5780630aadf8fc146101555780631ea09eae14610176578063248a9ca31461017f5780632661ffb6146101925780632f2ff15d146101a757806336390f65146101ba57806336568abe146101cd578063412374fb146101e057806356e1783e146101f357806358f8025c1461021c57806362beffcc146102245780636ba42aaa146102375780637078956e1461025a5780638c72c54e1461026d57806391d1485414610298578063a217fddf146102ab578063aa8c7608146102b3578063ae56c6cd146102c6578063c02d4b83146102f3578063c92b4bf814610307578063d1b9e8531461031a578063d547741f1461032d578063ed111b0614610340575b600080fd5b61014061013b3660046123b4565b610363565b60405190151581526020015b60405180910390f35b61016861016336600461229e565b61039a565b60405190815260200161014c565b61016860025481565b61016861018d366004612378565b6103b5565b6101a56101a03660046122ba565b6103ca565b005b6101a56101b5366004612390565b610401565b6101a56101c8366004612378565b610422565b6101a56101db366004612390565b6106a1565b6101a56101ee36600461231d565b61071f565b61016861020136600461229e565b6001600160a01b031660009081526005602052604090205490565b6101a5610a9d565b610168610232366004612546565b610aca565b61014061024536600461229e565b60086020526000908152604090205460ff1681565b6101686102683660046122f2565b610e73565b600354610280906001600160a01b031681565b6040516001600160a01b03909116815260200161014c565b6101406102a6366004612390565b610ea4565b610168600081565b6101686102c13660046122f2565b610ecd565b6102d96102d4366004612378565b610ee9565b60405161014c9e9d9c9b9a999897969594939291906127fe565b60035461014090600160a01b900460ff1681565b6101a561031536600461231d565b610ff3565b6101a56103283660046122ba565b6112e9565b6101a561033b366004612390565b611320565b61014061034e36600461229e565b60076020526000908152604090205460ff1681565b60006001600160e01b03198216637965db0b60e01b148061039457506301ffc9a760e01b6001600160e01b03198316145b92915050565b6001600160a01b031660009081526004602052604090205490565b60009081526020819052604090206001015490565b60006103d58161133c565b506001600160a01b03919091166000908152600760205260409020805460ff1916911515919091179055565b61040a826103b5565b6104138161133c565b61041d8383611349565b505050565b600081815260066020818152604080842081516101c0810183528154815260018201549381019390935260028101546001600160a01b03908116928401929092526003810154606084015260048101546080840152600581015460ff808216151560a08601526101009182900490931660c08501529381015460e08401526007810154938301939093526008830154811615156101208301526009830154610140830152600a830154161515610160820152600b82018054919291610180840191906104ed90612aa7565b80601f016020809104026020016040519081016040528092919081815260200182805461051990612aa7565b80156105665780601f1061053b57610100808354040283529160200191610566565b820191906000526020600020905b81548152906001019060200180831161054957829003601f168201915b50505050508152602001600c82015481525050905080604001516001600160a01b0316336001600160a01b0316146105d95760405162461bcd60e51b81526020600482015260116024820152702937baba32b91d102337b93134b23232b760791b60448201526064015b60405180910390fd5b8061016001516106395760405162461bcd60e51b815260206004820152602560248201527f526f757465723a2054726164652068617320616c7265616479206265656e206f6044820152641c195b995960da1b60648201526084016105d0565b610642826113cd565b80604001516001600160a01b0316600080516020612c3e83398151915283604051610695918152604060208201819052600e908201526d155cd95c8810d85b98d95b1b195960921b606082015260800190565b60405180910390a25050565b6001600160a01b03811633146107115760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b60648201526084016105d0565b61071b82826114c0565b5050565b610727611525565b60005b63ffffffff811682111561041d57600083838363ffffffff1681811061076057634e487b7160e01b600052603260045260246000fd5b905060200281019061077291906128cc565b61077b906129e8565b8051600090815260066020818152604080842081516101c0810183528154815260018201549381019390935260028101546001600160a01b03908116928401929092526003810154606084015260048101546080840152600581015460ff808216151560a08601526101009182900490931660c08501529381015460e08401526007810154938301939093526008830154811615156101208301526009830154610140830152600a830154161515610160820152600b820180549495509293909261018084019161084b90612aa7565b80601f016020809104026020016040519081016040528092919081815260200182805461087790612aa7565b80156108c45780601f10610899576101008083540402835291602001916108c4565b820191906000526020600020905b8154815290600101906020018083116108a757829003601f168201915b50505050508152602001600c82015481525050905060008160c00151905060006109708460200151836001600160a01b03166310082c756040518163ffffffff1660e01b815260040160006040518083038186803b15801561092557600080fd5b505afa158015610939573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526109619190810190612479565b8660400151876060015161158f565b9050806109b85783516040517f540144f033b0c98241d6b8c9481755c9fdca47ee01d3ab4e4b14c6aeda805be5916109a7916127c0565b60405180910390a150505050610a8b565b82610160015115806109d35750826101400151846020015114155b156109e15750505050610a8b565b60015461014084015161ffff909116906109fb904261293f565b11610a1757610a1284600001518560400151611670565b610a86565b8351610a22906113cd565b82604001516001600160a01b0316600080516020612c3e8339815191528560000151604051610a7d918152604060208201819052601290820152710aec2d2e840e8d2daca40e8dede40d0d2ced60731b606082015260800190565b60405180910390a25b505050505b80610a9581612b29565b91505061072a565b6000610aa88161133c565b506003805460ff60a01b198116600160a01b9182900460ff1615909102179055565b6001600160a01b03861660009081526007602052604081205460ff16610b325760405162461bcd60e51b815260206004820152601d60248201527f526f757465723a20556e617574686f72697a656420636f6e747261637400000060448201526064016105d0565b6000879050806001600160a01b031663b916aa85878c8e6040518463ffffffff1660e01b8152600401610b67939291906128a1565b60006040518083038186803b158015610b7f57600080fd5b505afa158015610b93573d6000803e3d6000fd5b50505050610c1f33308d846001600160a01b03166316dc165b6040518163ffffffff1660e01b815260040160206040518083038186803b158015610bd657600080fd5b505afa158015610bea573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c0e91906123dc565b6001600160a01b0316929190611b76565b60028054925082906000610c3283612b0e565b91905055506000604051806101c00160405280848152602001610c543361039a565b8152602001336001600160a01b031681526020018d81526020018c81526020018b151581526020018a6001600160a01b0316815260200189815260200188815260200187151581526020014281526020016001151581526020018681526020018581525090508060066000858152602001908152602001600020600082015181600001556020820151816001015560408201518160020160006101000a8154816001600160a01b0302191690836001600160a01b03160217905550606082015181600301556080820151816004015560a08201518160050160006101000a81548160ff02191690831515021790555060c08201518160050160016101000a8154816001600160a01b0302191690836001600160a01b0316021790555060e0820151816006015561010082015181600701556101208201518160080160006101000a81548160ff021916908315150217905550610140820151816009015561016082015181600a0160006101000a81548160ff02191690831515021790555061018082015181600b019080519060200190610def92919061216c565b506101a09190910151600c9091015533600081815260046020908152604080832080546001810182559084529190922001859055517fa058ea17deb3dad493dcf014f030710e90240e4bf900bace442ac371365ac3ec90610e5c9086904290918252602082015260400190565b60405180910390a250509998505050505050505050565b60056020528160005260406000208181548110610e8f57600080fd5b90600052602060002001600091509150505481565b6000918252602082815260408084206001600160a01b0393909316845291905290205460ff1690565b60046020528160005260406000208181548110610e8f57600080fd5b600660208190526000918252604090912080546001820154600283015460038401546004850154600586015496860154600787015460088801546009890154600a8a0154600b8b0180549a9c999b6001600160a01b03998a169b989a979960ff808a169a610100909a049091169895811695931692909190610f6a90612aa7565b80601f0160208091040260200160405190810160405280929190818152602001828054610f9690612aa7565b8015610fe35780601f10610fb857610100808354040283529160200191610fe3565b820191906000526020600020905b815481529060010190602001808311610fc657829003601f168201915b50505050509080600c015490508e565b610ffb611525565b8060005b8163ffffffff168163ffffffff1610156112e357600084848363ffffffff1681811061103b57634e487b7160e01b600052603260045260246000fd5b905060200281019061104d91906128b7565b61105690612956565b6020810151815160405163409e220560e01b81526004810191909152919250906000906001600160a01b0383169063409e2205906024016101206040518083038186803b1580156110a657600080fd5b505afa1580156110ba573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110de91906123f8565b5050509550505050505060006111768460400151846001600160a01b03166310082c756040518163ffffffff1660e01b815260040160006040518083038186803b15801561112b57600080fd5b505afa15801561113f573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526111679190810190612479565b8660600151876080015161158f565b9050836040015182146111da578351604080519182526020820181905260139082015272526f757465723a2057726f6e6720707269636560681b6060820152600080516020612c5e833981519152906080015b60405180910390a1505050506112d1565b806111fd578351604051600080516020612c5e833981519152916111c9916127c0565b835160608501516040516316feb6c960e21b81526001600160a01b03861692635bfadb249261123792600401918252602082015260400190565b600060405180830381600087803b15801561125157600080fd5b505af1925050508015611262575060015b6112cc5761126e612b79565b806308c379a014156112c05750611283612b91565b8061128e57506112c2565b8451604051600080516020612c5e833981519152916112ae9184906127a7565b60405180910390a150505050506112d1565b505b3d6000803e3d6000fd5b505050505b806112db81612b29565b915050610fff565b50505050565b60006112f48161133c565b506001600160a01b03919091166000908152600860205260409020805460ff1916911515919091179055565b611329826103b5565b6113328161133c565b61041d83836114c0565b6113468133611be1565b50565b6113538282610ea4565b61071b576000828152602081815260408083206001600160a01b03851684529091529020805460ff191660011790556113893390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b6000818152600660209081526040918290206005810154600a8201805460ff191690556002820154600383015485516316dc165b60e01b8152955193956001600160a01b03610100909404841695611491959390941693919286926316dc165b9260048082019391829003018186803b15801561144957600080fd5b505afa15801561145d573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061148191906123dc565b6001600160a01b03169190611c45565b50600201546001600160a01b031660009081526005602090815260408220805460018101825590835291200155565b6114ca8282610ea4565b1561071b576000828152602081815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b600354600160a01b900460ff16158061154d57503360009081526008602052604090205460ff165b61158d5760405162461bcd60e51b815260206004820152601160248201527025b2b2b832b91d103337b93134b23232b760791b60448201526064016105d0565b565b6000806116098587866040516020016115aa939291906126c6565b60408051601f1981840301815282825280516020918201207b0ca2ba3432b932bab69029b4b3b732b21026b2b9b9b0b3b29d05199960211b84830152603c8085019190915282518085039091018152605c909301909152815191012090565b90506000806116188386611c75565b9092509050600081600481111561163f57634e487b7160e01b600052602160045260246000fd5b141561166057506003546001600160a01b0391821691161491506116689050565b600093505050505b949350505050565b600082815260066020819052604080832060058101546007820154938201549251631e4c9f7760e11b815291946101009091046001600160a01b03169390928492633c993eee926116c89290918991906004016128a1565b60206040518083038186803b1580156116e057600080fd5b505afa1580156116f4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611718919061235c565b90508061179657611728856113cd565b60028301546040516001600160a01b0390911690600080516020612c3e833981519152906117879088815260406020820181905260169082015275536c697070616765206c696d6974206578636565647360501b606082015260800190565b60405180910390a25050505050565b604080516101208101825260068501548152600060208201819052600486015492820192909252600585015460ff9081161515606083015260088601541615156080820152600385015460a082015260028501546001600160a01b031660c0820152600b8501805483928392839260e08301919061181390612aa7565b80601f016020809104026020016040519081016040528092919081815260200182805461183f90612aa7565b801561188c5780601f106118615761010080835404028352916020019161188c565b820191906000526020600020905b81548152906001019060200180831161186f57829003601f168201915b5050505050815260200188600c01548152509050856001600160a01b031663faeb543a826040518263ffffffff1660e01b81526004016118cc919061276f565b606060405180830381600087803b1580156118e657600080fd5b505af1925050508015611916575060408051601f3d908101601f191682019092526119139181019061250e565b60015b61199057611922612b79565b806308c379a014156112c05750611937612b91565b8061194257506112c2565b61194b8a6113cd565b60028801546040516001600160a01b0390911690600080516020612c3e8339815191529061197c908d9085906127a7565b60405180910390a250505050505050505050565b91955093509150600a8701805460ff19169055604080516316dc165b60e01b815290516000916001600160a01b038916916316dc165b91600480820192602092909190829003018186803b1580156119e757600080fd5b505afa1580156119fb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a1f91906123dc565b6005890154909150611a43906001600160a01b038084169161010090041686611c45565b8760030154841015611a835760028801546003890154611a83916001600160a01b031690611a7290879061293f565b6001600160a01b0384169190611c45565b60a0820184905288825260208201859052600988015460405163030bd96960e31b81526000916001600160a01b038a169163185ecb4891611aca9187918991600401612782565b602060405180830381600087803b158015611ae457600080fd5b505af1158015611af8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b1c91906124f6565b60028a0154604080518e8152602081018490529293506001600160a01b03909116917f46961a5320eafc3fb71b3051774237104d4cec1687a31eed0c32262f0be47902910160405180910390a25050505050505050505050565b6040516001600160a01b03808516602483015283166044820152606481018290526112e39085906323b872dd60e01b906084015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152611cbb565b611beb8282610ea4565b61071b57611c03816001600160a01b03166014611d8d565b611c0e836020611d8d565b604051602001611c1f9291906126ed565b60408051601f198184030181529082905262461bcd60e51b82526105d09160040161275c565b6040516001600160a01b03831660248201526044810182905261041d90849063a9059cbb60e01b90606401611baa565b600080825160411415611cac5760208301516040840151606085015160001a611ca087828585611f75565b94509450505050611cb4565b506000905060025b9250929050565b6000611d10826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166120589092919063ffffffff16565b80519091501561041d5780806020019051810190611d2e919061235c565b61041d5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b60648201526084016105d0565b60606000611d9c836002612920565b611da7906002612908565b6001600160401b03811115611dcc57634e487b7160e01b600052604160045260246000fd5b6040519080825280601f01601f191660200182016040528015611df6576020820181803683370190505b509050600360fc1b81600081518110611e1f57634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a905350600f60fb1b81600181518110611e5c57634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a9053506000611e80846002612920565b611e8b906001612908565b90505b6001811115611f1f576f181899199a1a9b1b9c1cb0b131b232b360811b85600f1660108110611ecd57634e487b7160e01b600052603260045260246000fd5b1a60f81b828281518110611ef157634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a90535060049490941c93611f1881612a90565b9050611e8e565b508315611f6e5760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e7460448201526064016105d0565b9392505050565b6000806fa2a8918ca85bafe22016d0b997e4df60600160ff1b03831115611fa2575060009050600361204f565b8460ff16601b14158015611fba57508460ff16601c14155b15611fcb575060009050600461204f565b6040805160008082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa15801561201f573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b0381166120485760006001925092505061204f565b9150600090505b94509492505050565b60606116688484600085856001600160a01b0385163b6120ba5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016105d0565b600080866001600160a01b031685876040516120d691906126aa565b60006040518083038185875af1925050503d8060008114612113576040519150601f19603f3d011682016040523d82523d6000602084013e612118565b606091505b5091509150612128828286612133565b979650505050505050565b60608315612142575081611f6e565b8251156121525782518084602001fd5b8160405162461bcd60e51b81526004016105d0919061275c565b82805461217890612aa7565b90600052602060002090601f01602090048101928261219a57600085556121e0565b82601f106121b357805160ff19168380011785556121e0565b828001600101855582156121e0579182015b828111156121e05782518255916020019190600101906121c5565b506121ec9291506121f0565b5090565b5b808211156121ec57600081556001016121f1565b60008083601f840112612216578182fd5b5081356001600160401b0381111561222c578182fd5b6020830191508360208260051b8501011115611cb457600080fd5b600082601f830112612257578081fd5b8135612262816128e1565b60405161226f8282612ae2565b828152856020848701011115612283578384fd5b82602086016020830137918201602001929092529392505050565b6000602082840312156122af578081fd5b8135611f6e81612c1a565b600080604083850312156122cc578081fd5b82356122d781612c1a565b915060208301356122e781612c2f565b809150509250929050565b60008060408385031215612304578182fd5b823561230f81612c1a565b946020939093013593505050565b6000806020838503121561232f578182fd5b82356001600160401b03811115612344578283fd5b61235085828601612205565b90969095509350505050565b60006020828403121561236d578081fd5b8151611f6e81612c2f565b600060208284031215612389578081fd5b5035919050565b600080604083850312156123a2578182fd5b8235915060208301356122e781612c1a565b6000602082840312156123c5578081fd5b81356001600160e01b031981168114611f6e578182fd5b6000602082840312156123ed578081fd5b8151611f6e81612c1a565b60008060008060008060008060006101208a8c031215612416578485fd5b895160048110612424578586fd5b8099505060208a0151975060408a0151965060608a0151955060808a0151945060a08a0151935060c08a015161245981612c2f565b8093505060e08a015191506101008a015190509295985092959850929598565b60006020828403121561248a578081fd5b81516001600160401b0381111561249f578182fd5b8201601f810184136124af578182fd5b80516124ba816128e1565b6040516124c78282612ae2565b8281528660208486010111156124db578485fd5b6124ec836020830160208701612a64565b9695505050505050565b600060208284031215612507578081fd5b5051919050565b600080600060608486031215612522578081fd5b8351925060208401519150604084015161253b81612c2f565b809150509250925092565b60008060008060008060008060006101208a8c031215612564578283fd5b8935985060208a0135975060408a013561257d81612c2f565b965060608a013561258d81612c1a565b955060808a0135945060a08a0135935060c08a01356125ab81612c2f565b925060e08a01356001600160401b038111156125c5578283fd5b6125d18c828d01612247565b9250506101008a013590509295985092959850929598565b6001600160a01b03169052565b6000815180845261260e816020860160208601612a64565b601f01601f19169290920160200192915050565b6000610120825184526020830151602085015260408301516040850152606083015115156060850152608083015161265e608086018215159052565b5060a083015160a085015260c083015161267b60c08601826125e9565b5060e08301518160e0860152612693828601826125f6565b610100948501519590940194909452509092915050565b600082516126bc818460208701612a64565b9190910192915050565b600084516126d8818460208901612a64565b91909101928352506020820152604001919050565b76020b1b1b2b9b9a1b7b73a3937b61d1030b1b1b7bab73a1604d1b81526000835161271f816017850160208801612a64565b7001034b99036b4b9b9b4b733903937b6329607d1b6017918401918201528351612750816028840160208801612a64565b01602801949350505050565b602081526000611f6e60208301846125f6565b602081526000611f6e6020830184612622565b6060815260006127956060830186612622565b93151560208301525060400152919050565b82815260406020820152600061166860408301846125f6565b908152604060208201819052601e908201527f526f757465723a205369676e6174757265206469646e2774206d617463680000606082015260800190565b8e8152602081018e90526001600160a01b038d166040820152606081018c9052608081018b905289151560a082015261283a60c082018a6125e9565b8760e08201528661010082015261285661012082018715159052565b8461014082015261286c61016082018515159052565b6101c061018082015260006128856101c08301856125f6565b9050826101a08301529f9e505050505050505050505050505050565b9283526020830191909152604082015260600190565b60008235609e198336030181126126bc578182fd5b60008235607e198336030181126126bc578182fd5b60006001600160401b038211156128fa576128fa612b63565b50601f01601f191660200190565b6000821982111561291b5761291b612b4d565b500190565b600081600019048311821515161561293a5761293a612b4d565b500290565b60008282101561295157612951612b4d565b500390565b600060a08236031215612967578081fd5b60405160a081016001600160401b03808211838310171561298a5761298a612b63565b8160405284358352602085013591506129a282612c1a565b816020840152604085013560408401526060850135606084015260808501359150808211156129cf578384fd5b506129dc36828601612247565b60808301525092915050565b6000608082360312156129f9578081fd5b604051608081016001600160401b038082118383101715612a1c57612a1c612b63565b816040528435835260208501356020840152604085013560408401526060850135915080821115612a4b578384fd5b50612a5836828601612247565b60608301525092915050565b60005b83811015612a7f578181015183820152602001612a67565b838111156112e35750506000910152565b600081612a9f57612a9f612b4d565b506000190190565b600181811c90821680612abb57607f821691505b60208210811415612adc57634e487b7160e01b600052602260045260246000fd5b50919050565b601f8201601f191681016001600160401b0381118282101715612b0757612b07612b63565b6040525050565b6000600019821415612b2257612b22612b4d565b5060010190565b600063ffffffff80831681811415612b4357612b43612b4d565b6001019392505050565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052604160045260246000fd5b600060033d1115612b8e57600481823e5160e01c5b90565b600060443d1015612b9f5790565b6040516003193d81016004833e81513d6001600160401b038083116024840183101715612bce57505050505090565b8285019150815181811115612be65750505050505090565b843d8701016020828501011115612c005750505050505090565b612c0f60208286010187612ae2565b509095945050505050565b6001600160a01b038116811461134657600080fd5b801515811461134657600080fdfec804e178cb25d48cffff5de67dd01d385e72784ce35bbc52affad3e13dfa269a312ffa36dda8ceca985bf8d5ca545c4fb764ddca604f4ba5088109da0b9465f3a26469706673582212202f4dfc8d9dba034c4c1af8fd940c72cfd3f9e7e4593f5a92aea2b875b6d6124d64736f6c634300080400330000000000000000000000002156972c36088aa94faef84359c75fb4bb83c745
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
0000000000000000000000002156972c36088aa94faef84359c75fb4bb83c745
-----Decoded View---------------
Arg [0] : _publisher (address): 0x2156972c36088aa94faef84359c75fb4bb83c745
-----Encoded View---------------
1 Constructor Arguments found :
Arg [0] : 0000000000000000000000002156972c36088aa94faef84359c75fb4bb83c745
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.