Token Buffer
Overview ERC-721
Total Supply:
0 BFR
Holders:
2 addresses
Transfers:
-
Contract:
[ Download CSV Export ]
[ Download CSV Export ]
# | Exchange | Pair | Price | 24H Volume | % Volume |
---|
Contract Name:
BufferBinaryOptions
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 "ERC721.sol"; import "AccessControl.sol"; import "SafeERC20.sol"; import "Interfaces.sol"; /** * @author Heisenberg * @title Buffer Options * @notice Creates ERC721 Options */ contract BufferBinaryOptions is IBufferBinaryOptions, ReentrancyGuard, ERC721, AccessControl { using SafeERC20 for ERC20; uint256 public nextTokenId = 0; uint256 public totalLockedAmount; bool public isPaused; uint16 public baseSettlementFeePercentageForAbove; // Factor of 1e2 uint16 public baseSettlementFeePercentageForBelow; // Factor of 1e2 uint16 public stepSize = 25; // Factor of 1e2 string public override assetPair; ILiquidityPool public override pool; IOptionsConfig public override config; IReferralStorage public referral; AssetCategory public assetCategory; ERC20 public override tokenX; mapping(uint256 => Option) public override options; mapping(address => uint256[]) public userOptionIds; mapping(uint8 => uint8) public nftTierStep; bytes32 public constant ROUTER_ROLE = keccak256("ROUTER_ROLE"); /************************************************ * INITIALIZATION FUNCTIONS ***********************************************/ constructor( ERC20 _tokenX, ILiquidityPool _pool, IOptionsConfig _config, IReferralStorage _referral, AssetCategory _category, string memory _assetPair ) ERC721("Buffer", "BFR") { tokenX = _tokenX; pool = _pool; config = _config; referral = _referral; assetPair = _assetPair; assetCategory = _category; _setupRole(DEFAULT_ADMIN_ROLE, msg.sender); } /** * @notice Used to configure the contracts */ function configure( uint16 _baseSettlementFeePercentageForAbove, uint16 _baseSettlementFeePercentageForBelow, uint8[4] calldata _nftTierStep ) external onlyRole(DEFAULT_ADMIN_ROLE) { require(10e2 <= _baseSettlementFeePercentageForAbove, "O27"); require(_baseSettlementFeePercentageForAbove <= 50e2, "O28"); baseSettlementFeePercentageForAbove = _baseSettlementFeePercentageForAbove; // Percent with a factor of 1e2 require(10e2 <= _baseSettlementFeePercentageForBelow, "O27"); require(_baseSettlementFeePercentageForBelow <= 50e2, "O28"); baseSettlementFeePercentageForBelow = _baseSettlementFeePercentageForBelow; for (uint8 i; i < 4; i++) { nftTierStep[i] = _nftTierStep[i]; } } /** * @notice Grants complete approval from the pool */ function approvePoolToTransferTokenX() public { tokenX.approve(address(pool), ~uint256(0)); } /** * @notice Pauses/Unpauses the option creation */ function toggleCreation() public onlyRole(DEFAULT_ADMIN_ROLE) { isPaused = !isPaused; emit Pause(isPaused); } /************************************************ * ROUTER ONLY FUNCTIONS ***********************************************/ /** * @notice Creates an option with the specified parameters * @dev Can only be called by router */ function createFromRouter( OptionParams calldata optionParams, bool isReferralValid, uint256 queuedTime ) external override onlyRole(ROUTER_ROLE) returns (uint256 optionID) { Option memory option = Option( State.Active, optionParams.strike, optionParams.amount, optionParams.amount, optionParams.amount / 2, queuedTime + optionParams.period, optionParams.isAbove, optionParams.totalFee, queuedTime ); totalLockedAmount += optionParams.amount; optionID = _generateTokenId(); userOptionIds[optionParams.user].push(optionID); options[optionID] = option; _mint(optionParams.user, optionID); uint256 referrerFee = _processReferralRebate( optionParams.user, optionParams.totalFee, optionParams.amount, optionParams.referralCode, optionParams.isAbove, isReferralValid ); uint256 settlementFee = optionParams.totalFee - option.premium - referrerFee; tokenX.safeTransfer( config.settlementFeeDisbursalContract(), settlementFee ); pool.lock(optionID, option.lockedAmount, option.premium); emit Create( optionParams.user, optionID, settlementFee, optionParams.totalFee ); } /** * @notice Unlocks/Exercises the active options * @dev Can only be called router */ function unlock(uint256 optionID, uint256 priceAtExpiration) external override onlyRole(ROUTER_ROLE) { require(_exists(optionID), "O10"); Option storage option = options[optionID]; require(option.expiration <= block.timestamp, "O4"); require(option.state == State.Active, "O5"); if ( (option.isAbove && priceAtExpiration > option.strike) || (!option.isAbove && priceAtExpiration < option.strike) ) { _exercise(optionID, priceAtExpiration); } else { option.state = State.Expired; pool.unlock(optionID); _burn(optionID); emit Expire(optionID, option.premium, priceAtExpiration); } totalLockedAmount -= option.lockedAmount; } /************************************************ * READ ONLY FUNCTIONS ***********************************************/ /** * @notice Returns decimals of the pool token */ function decimals() public view returns (uint256) { return tokenX.decimals(); } /** * @notice Calculates the fees for buying an option */ function fees( uint256 amount, address user, bool isAbove, string calldata referralCode, uint256 traderNFTId ) public view override returns ( uint256 total, uint256 settlementFee, uint256 premium ) { (uint256 settlementFeePercentage, ) = _getSettlementFeePercentage( referral.codeOwner(referralCode), user, _getbaseSettlementFeePercentage(isAbove), traderNFTId ); (total, settlementFee, premium) = _fees( amount, settlementFeePercentage ); } /** * @notice Checks if the strike price at which the trade is opened lies within the slippage bounds */ function isStrikeValid( uint256 slippage, uint256 strike, uint256 expectedStrike ) external pure override returns (bool) { if ( (strike <= (expectedStrike * (1e4 + slippage)) / 1e4) && (strike >= (expectedStrike * (1e4 - slippage)) / 1e4) ) { return true; } else return false; } /** * @notice Checks if the market is open at the time of option creation and execution. * Used only for forex options */ function isInCreationWindow(uint256 period) public view returns (bool) { uint256 currentTime = block.timestamp; uint256 currentDay = ((currentTime / 86400) + 4) % 7; uint256 expirationDay = (((currentTime + period) / 86400) + 4) % 7; if (currentDay == expirationDay) { uint256 currentHour = (currentTime / 3600) % 24; uint256 currentMinute = (currentTime % 3600) / 60; uint256 expirationHour = ((currentTime + period) / 3600) % 24; uint256 expirationMinute = ((currentTime + period) % 3600) / 60; ( uint256 startHour, uint256 startMinute, uint256 endHour, uint256 endMinute ) = config.marketTimes(uint8(currentDay)); if ( (currentHour > startHour || (currentHour == startHour && currentMinute >= startMinute)) && (currentHour < endHour || (currentHour == endHour && currentMinute < endMinute)) && (expirationHour < endHour || (expirationHour == endHour && expirationMinute < endMinute)) ) { return true; } } return false; } /** * @notice Runs the basic checks for option creation */ function runInitialChecks( uint256 slippage, uint256 period, uint256 totalFee ) external view override { require(!isPaused, "O33"); require(slippage <= 5e2, "O34"); // 5% is the max slippage a user can use require(period >= config.minPeriod(), "O21"); require(period <= config.maxPeriod(), "O25"); require(totalFee >= config.minFee(), "O35"); } /** * @notice Calculates max option amount based on the pool's capacity */ function getMaxUtilization() public view override returns (uint256 maxAmount) { // Calculate the max option size due to asset wise pool utilization limit uint256 totalPoolBalance = pool.totalTokenXBalance(); uint256 availableBalance = totalPoolBalance - totalLockedAmount; uint256 utilizationLimit = config.assetUtilizationLimit(); uint256 maxAssetWiseUtilizationAmount = _getMaxUtilization( totalPoolBalance, availableBalance, utilizationLimit ); // Calculate the max option size due to overall pool utilization limit utilizationLimit = config.overallPoolUtilizationLimit(); availableBalance = pool.availableBalance(); uint256 maxUtilizationAmount = _getMaxUtilization( totalPoolBalance, availableBalance, utilizationLimit ); // Take the min of the above 2 values maxAmount = min(maxUtilizationAmount, maxAssetWiseUtilizationAmount); } /** * @notice Runs all the checks on the option parameters and * returns the revised amount and fee */ function checkParams(OptionParams calldata optionParams) external view override returns ( uint256 amount, uint256 revisedFee, bool isReferralValid ) { require(!isPaused, "O33"); require( assetCategory != AssetCategory.Forex || isInCreationWindow(optionParams.period), "O30" ); uint256 maxAmount = getMaxUtilization(); // Calculate the max fee due to the max txn limit uint256 maxPerTxnFee = ((pool.availableBalance() * config.optionFeePerTxnLimitPercent()) / 100e2); uint256 newFee = min(optionParams.totalFee, maxPerTxnFee); // Calculate the amount here from the new fees uint256 settlementFeePercentage; ( settlementFeePercentage, isReferralValid ) = _getSettlementFeePercentage( referral.codeOwner(optionParams.referralCode), optionParams.user, _getbaseSettlementFeePercentage(optionParams.isAbove), optionParams.traderNFTId ); (uint256 unitFee, , ) = _fees(10**decimals(), settlementFeePercentage); amount = (newFee * 10**decimals()) / unitFee; // Recalculate the amount and the fees if values are greater than the max and partial fill is allowed if (amount > maxAmount || newFee < optionParams.totalFee) { require(optionParams.allowPartialFill, "O29"); amount = min(amount, maxAmount); (revisedFee, , ) = _fees(amount, settlementFeePercentage); } else { revisedFee = optionParams.totalFee; } } /************************************************ * ERC721 FUNCTIONS ***********************************************/ function _generateTokenId() internal returns (uint256) { return nextTokenId++; } function min(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; } function supportsInterface(bytes4 interfaceId) public view override(ERC721, AccessControl) returns (bool) { return super.supportsInterface(interfaceId); } /************************************************ * INTERNAL OPTION UTILITY FUNCTIONS ***********************************************/ /** * @notice Returns the base settlement fee based on option type */ function _getbaseSettlementFeePercentage(bool isAbove) internal view returns (uint16 baseSettlementFeePercentage) { baseSettlementFeePercentage = isAbove ? baseSettlementFeePercentageForAbove : baseSettlementFeePercentageForBelow; } /** * @notice Calculates the max utilization */ function _getMaxUtilization( uint256 totalPoolBalance, uint256 availableBalance, uint256 utilizationLimit ) internal pure returns (uint256) { require( availableBalance > (((1e4 - utilizationLimit) * totalPoolBalance) / 1e4), "O31" ); return availableBalance - (((1e4 - utilizationLimit) * totalPoolBalance) / 1e4); } /** * @notice Calculates the fees for buying an option */ function _fees(uint256 amount, uint256 settlementFeePercentage) internal pure returns ( uint256 total, uint256 settlementFee, uint256 premium ) { // Probability for ATM options will always be 0.5 due to which we can skip using BSM premium = amount / 2; total = (premium * 1e4) / (1e4 - settlementFeePercentage); settlementFee = total - premium; } /** * @notice Exercises the ITM options */ function _exercise(uint256 optionID, uint256 priceAtExpiration) internal returns (uint256 profit) { Option storage option = options[optionID]; address user = ownerOf(optionID); profit = option.lockedAmount; pool.send(optionID, user, profit); // Burn the option _burn(optionID); option.state = State.Exercised; emit Exercise(user, optionID, profit, priceAtExpiration); } /** * @notice Sends the referral rebate to the referrer and * updates the stats in the referral storage contract */ function _processReferralRebate( address user, uint256 totalFee, uint256 amount, string calldata referralCode, bool isAbove, bool isReferralValid ) internal returns (uint256 referrerFee) { address referrer = referral.codeOwner(referralCode); if ( referrer != user && referrer != address(0) && referrer.code.length == 0 ) { referrerFee = ((totalFee * referral.referrerTierDiscount( referral.referrerTier(referrer) )) / (1e4 * 1e3)); if (referrerFee > 0) { tokenX.safeTransfer(referrer, referrerFee); (uint256 formerUnitFee, , ) = _fees( 10**decimals(), _getbaseSettlementFeePercentage(isAbove) ); emit UpdateReferral( user, referrer, isReferralValid, totalFee, referrerFee, (((formerUnitFee * amount) / 10**decimals()) - totalFee), referralCode ); } } } /** * @notice Calculates the discount to be applied on settlement fee based on * NFT and referrer tiers */ function _getSettlementFeeDiscount( address referrer, address user, uint256 traderNFTId ) public view returns (bool isReferralValid, uint8 maxStep) { if (config.traderNFTContract() != address(0)) { ITraderNFT nftContract = ITraderNFT(config.traderNFTContract()); if (nftContract.tokenOwner(traderNFTId) == user) maxStep = nftTierStep[ nftContract.tokenTierMappings(traderNFTId) ]; } if ( referrer != user && referrer != address(0) && referrer.code.length == 0 ) { uint8 step = referral.referrerTierStep( referral.referrerTier(referrer) ); if (step > maxStep) { maxStep = step; isReferralValid = true; } } } /** * @notice Returns the discounted settlement fee */ function _getSettlementFeePercentage( address referrer, address user, uint16 baseSettlementFeePercentage, uint256 traderNFTId ) internal view returns (uint256 settlementFeePercentage, bool isReferralValid) { settlementFeePercentage = baseSettlementFeePercentage; uint256 maxStep; (isReferralValid, maxStep) = _getSettlementFeeDiscount( referrer, user, traderNFTId ); settlementFeePercentage = settlementFeePercentage - (stepSize * maxStep); } }
// 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) (token/ERC721/ERC721.sol) pragma solidity ^0.8.0; import "IERC721.sol"; import "IERC721Receiver.sol"; import "IERC721Metadata.sol"; import "Address.sol"; import "Context.sol"; import "Strings.sol"; import "ERC165.sol"; /** * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including * the Metadata extension, but not including the Enumerable extension, which is available separately as * {ERC721Enumerable}. */ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata { using Address for address; using Strings for uint256; // Token name string private _name; // Token symbol string private _symbol; // Mapping from token ID to owner address mapping(uint256 => address) private _owners; // Mapping owner address to token count mapping(address => uint256) private _balances; // Mapping from token ID to approved address mapping(uint256 => address) private _tokenApprovals; // Mapping from owner to operator approvals mapping(address => mapping(address => bool)) private _operatorApprovals; /** * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC721).interfaceId || interfaceId == type(IERC721Metadata).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721-balanceOf}. */ function balanceOf(address owner) public view virtual override returns (uint256) { require(owner != address(0), "ERC721: address zero is not a valid owner"); return _balances[owner]; } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view virtual override returns (address) { address owner = _owners[tokenId]; require(owner != address(0), "ERC721: invalid token ID"); return owner; } /** * @dev See {IERC721Metadata-name}. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev See {IERC721Metadata-symbol}. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { _requireMinted(tokenId); string memory baseURI = _baseURI(); return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : ""; } /** * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each * token will be the concatenation of the `baseURI` and the `tokenId`. Empty * by default, can be overridden in child contracts. */ function _baseURI() internal view virtual returns (string memory) { return ""; } /** * @dev See {IERC721-approve}. */ function approve(address to, uint256 tokenId) public virtual override { address owner = ERC721.ownerOf(tokenId); require(to != owner, "ERC721: approval to current owner"); require( _msgSender() == owner || isApprovedForAll(owner, _msgSender()), "ERC721: approve caller is not token owner nor approved for all" ); _approve(to, tokenId); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view virtual override returns (address) { _requireMinted(tokenId); return _tokenApprovals[tokenId]; } /** * @dev See {IERC721-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual override { _setApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC721-isApprovedForAll}. */ function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { return _operatorApprovals[owner][operator]; } /** * @dev See {IERC721-transferFrom}. */ function transferFrom( address from, address to, uint256 tokenId ) public virtual override { //solhint-disable-next-line max-line-length require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: caller is not token owner nor approved"); _transfer(from, to, tokenId); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId ) public virtual override { safeTransferFrom(from, to, tokenId, ""); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes memory data ) public virtual override { require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: caller is not token owner nor approved"); _safeTransfer(from, to, tokenId, data); } /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * `data` is additional data, it has no specified format and it is sent in call to `to`. * * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g. * implement alternative mechanisms to perform token transfer, such as signature-based. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeTransfer( address from, address to, uint256 tokenId, bytes memory data ) internal virtual { _transfer(from, to, tokenId); require(_checkOnERC721Received(from, to, tokenId, data), "ERC721: transfer to non ERC721Receiver implementer"); } /** * @dev Returns whether `tokenId` exists. * * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}. * * Tokens start existing when they are minted (`_mint`), * and stop existing when they are burned (`_burn`). */ function _exists(uint256 tokenId) internal view virtual returns (bool) { return _owners[tokenId] != address(0); } /** * @dev Returns whether `spender` is allowed to manage `tokenId`. * * Requirements: * * - `tokenId` must exist. */ function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) { address owner = ERC721.ownerOf(tokenId); return (spender == owner || isApprovedForAll(owner, spender) || getApproved(tokenId) == spender); } /** * @dev Safely mints `tokenId` and transfers it to `to`. * * Requirements: * * - `tokenId` must not exist. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeMint(address to, uint256 tokenId) internal virtual { _safeMint(to, tokenId, ""); } /** * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is * forwarded in {IERC721Receiver-onERC721Received} to contract recipients. */ function _safeMint( address to, uint256 tokenId, bytes memory data ) internal virtual { _mint(to, tokenId); require( _checkOnERC721Received(address(0), to, tokenId, data), "ERC721: transfer to non ERC721Receiver implementer" ); } /** * @dev Mints `tokenId` and transfers it to `to`. * * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible * * Requirements: * * - `tokenId` must not exist. * - `to` cannot be the zero address. * * Emits a {Transfer} event. */ function _mint(address to, uint256 tokenId) internal virtual { require(to != address(0), "ERC721: mint to the zero address"); require(!_exists(tokenId), "ERC721: token already minted"); _beforeTokenTransfer(address(0), to, tokenId); _balances[to] += 1; _owners[tokenId] = to; emit Transfer(address(0), to, tokenId); _afterTokenTransfer(address(0), to, tokenId); } /** * @dev Destroys `tokenId`. * The approval is cleared when the token is burned. * * Requirements: * * - `tokenId` must exist. * * Emits a {Transfer} event. */ function _burn(uint256 tokenId) internal virtual { address owner = ERC721.ownerOf(tokenId); _beforeTokenTransfer(owner, address(0), tokenId); // Clear approvals _approve(address(0), tokenId); _balances[owner] -= 1; delete _owners[tokenId]; emit Transfer(owner, address(0), tokenId); _afterTokenTransfer(owner, address(0), tokenId); } /** * @dev Transfers `tokenId` from `from` to `to`. * As opposed to {transferFrom}, this imposes no restrictions on msg.sender. * * Requirements: * * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * * Emits a {Transfer} event. */ function _transfer( address from, address to, uint256 tokenId ) internal virtual { require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer from incorrect owner"); require(to != address(0), "ERC721: transfer to the zero address"); _beforeTokenTransfer(from, to, tokenId); // Clear approvals from the previous owner _approve(address(0), tokenId); _balances[from] -= 1; _balances[to] += 1; _owners[tokenId] = to; emit Transfer(from, to, tokenId); _afterTokenTransfer(from, to, tokenId); } /** * @dev Approve `to` to operate on `tokenId` * * Emits an {Approval} event. */ function _approve(address to, uint256 tokenId) internal virtual { _tokenApprovals[tokenId] = to; emit Approval(ERC721.ownerOf(tokenId), to, tokenId); } /** * @dev Approve `operator` to operate on all of `owner` tokens * * Emits an {ApprovalForAll} event. */ function _setApprovalForAll( address owner, address operator, bool approved ) internal virtual { require(owner != operator, "ERC721: approve to caller"); _operatorApprovals[owner][operator] = approved; emit ApprovalForAll(owner, operator, approved); } /** * @dev Reverts if the `tokenId` has not been minted yet. */ function _requireMinted(uint256 tokenId) internal view virtual { require(_exists(tokenId), "ERC721: invalid token ID"); } /** * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address. * The call is not executed if the target address is not a contract. * * @param from address representing the previous owner of the given token ID * @param to target address that will receive the tokens * @param tokenId uint256 ID of the token to be transferred * @param data bytes optional data to send along with the call * @return bool whether the call correctly returned the expected magic value */ function _checkOnERC721Received( address from, address to, uint256 tokenId, bytes memory data ) private returns (bool) { if (to.isContract()) { try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, data) returns (bytes4 retval) { return retval == IERC721Receiver.onERC721Received.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert("ERC721: transfer to non ERC721Receiver implementer"); } else { /// @solidity memory-safe-assembly assembly { revert(add(32, reason), mload(reason)) } } } } else { return true; } } /** * @dev Hook that is called before any token transfer. This includes minting * and burning. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, ``from``'s `tokenId` 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 tokenId ) 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. * - `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 tokenId ) internal virtual {} }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (token/ERC721/IERC721.sol) pragma solidity ^0.8.0; import "IERC165.sol"; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes calldata data ) external; /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts 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.6.0) (token/ERC721/IERC721Receiver.sol) pragma solidity ^0.8.0; /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ interface IERC721Receiver { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. * * The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`. */ function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol) pragma solidity ^0.8.0; import "IERC721.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Metadata is IERC721 { /** * @dev Returns the token collection name. */ function name() external view returns (string memory); /** * @dev Returns the token collection symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) external view returns (string memory); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.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: 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 (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 (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: 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": { "BufferBinaryOptions.sol": {} }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } } }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[{"internalType":"contract ERC20","name":"_tokenX","type":"address"},{"internalType":"contract ILiquidityPool","name":"_pool","type":"address"},{"internalType":"contract IOptionsConfig","name":"_config","type":"address"},{"internalType":"contract IReferralStorage","name":"_referral","type":"address"},{"internalType":"enum IBufferBinaryOptions.AssetCategory","name":"_category","type":"uint8"},{"internalType":"string","name":"_assetPair","type":"string"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"approved","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":false,"internalType":"bool","name":"approved","type":"bool"}],"name":"ApprovalForAll","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"uint256","name":"id","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"settlementFee","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"totalFee","type":"uint256"}],"name":"Create","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"uint256","name":"id","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"profit","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"priceAtExpiration","type":"uint256"}],"name":"Exercise","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"id","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"premium","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"priceAtExpiration","type":"uint256"}],"name":"Expire","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bool","name":"isPaused","type":"bool"}],"name":"Pause","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"address","name":"referrer","type":"address"},{"indexed":false,"internalType":"bool","name":"isReferralValid","type":"bool"},{"indexed":false,"internalType":"uint256","name":"totalFee","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"referrerFee","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"rebate","type":"uint256"},{"indexed":false,"internalType":"string","name":"referralCode","type":"string"}],"name":"UpdateReferral","type":"event"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ROUTER_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"referrer","type":"address"},{"internalType":"address","name":"user","type":"address"},{"internalType":"uint256","name":"traderNFTId","type":"uint256"}],"name":"_getSettlementFeeDiscount","outputs":[{"internalType":"bool","name":"isReferralValid","type":"bool"},{"internalType":"uint8","name":"maxStep","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"approve","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"approvePoolToTransferTokenX","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"assetCategory","outputs":[{"internalType":"enum IBufferBinaryOptions.AssetCategory","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"assetPair","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"baseSettlementFeePercentageForAbove","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"baseSettlementFeePercentageForBelow","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"strike","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"period","type":"uint256"},{"internalType":"bool","name":"isAbove","type":"bool"},{"internalType":"bool","name":"allowPartialFill","type":"bool"},{"internalType":"uint256","name":"totalFee","type":"uint256"},{"internalType":"address","name":"user","type":"address"},{"internalType":"string","name":"referralCode","type":"string"},{"internalType":"uint256","name":"traderNFTId","type":"uint256"}],"internalType":"struct IBufferBinaryOptions.OptionParams","name":"optionParams","type":"tuple"}],"name":"checkParams","outputs":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"revisedFee","type":"uint256"},{"internalType":"bool","name":"isReferralValid","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"config","outputs":[{"internalType":"contract IOptionsConfig","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint16","name":"_baseSettlementFeePercentageForAbove","type":"uint16"},{"internalType":"uint16","name":"_baseSettlementFeePercentageForBelow","type":"uint16"},{"internalType":"uint8[4]","name":"_nftTierStep","type":"uint8[4]"}],"name":"configure","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"strike","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"period","type":"uint256"},{"internalType":"bool","name":"isAbove","type":"bool"},{"internalType":"bool","name":"allowPartialFill","type":"bool"},{"internalType":"uint256","name":"totalFee","type":"uint256"},{"internalType":"address","name":"user","type":"address"},{"internalType":"string","name":"referralCode","type":"string"},{"internalType":"uint256","name":"traderNFTId","type":"uint256"}],"internalType":"struct IBufferBinaryOptions.OptionParams","name":"optionParams","type":"tuple"},{"internalType":"bool","name":"isReferralValid","type":"bool"},{"internalType":"uint256","name":"queuedTime","type":"uint256"}],"name":"createFromRouter","outputs":[{"internalType":"uint256","name":"optionID","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"address","name":"user","type":"address"},{"internalType":"bool","name":"isAbove","type":"bool"},{"internalType":"string","name":"referralCode","type":"string"},{"internalType":"uint256","name":"traderNFTId","type":"uint256"}],"name":"fees","outputs":[{"internalType":"uint256","name":"total","type":"uint256"},{"internalType":"uint256","name":"settlementFee","type":"uint256"},{"internalType":"uint256","name":"premium","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getApproved","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getMaxUtilization","outputs":[{"internalType":"uint256","name":"maxAmount","type":"uint256"}],"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":"address","name":"owner","type":"address"},{"internalType":"address","name":"operator","type":"address"}],"name":"isApprovedForAll","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"period","type":"uint256"}],"name":"isInCreationWindow","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"isPaused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"slippage","type":"uint256"},{"internalType":"uint256","name":"strike","type":"uint256"},{"internalType":"uint256","name":"expectedStrike","type":"uint256"}],"name":"isStrikeValid","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"nextTokenId","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint8","name":"","type":"uint8"}],"name":"nftTierStep","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"options","outputs":[{"internalType":"enum IBufferBinaryOptions.State","name":"state","type":"uint8"},{"internalType":"uint256","name":"strike","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"lockedAmount","type":"uint256"},{"internalType":"uint256","name":"premium","type":"uint256"},{"internalType":"uint256","name":"expiration","type":"uint256"},{"internalType":"bool","name":"isAbove","type":"bool"},{"internalType":"uint256","name":"totalFee","type":"uint256"},{"internalType":"uint256","name":"createdAt","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"ownerOf","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pool","outputs":[{"internalType":"contract ILiquidityPool","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"referral","outputs":[{"internalType":"contract IReferralStorage","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"slippage","type":"uint256"},{"internalType":"uint256","name":"period","type":"uint256"},{"internalType":"uint256","name":"totalFee","type":"uint256"}],"name":"runInitialChecks","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"bool","name":"approved","type":"bool"}],"name":"setApprovalForAll","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"stepSize","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"toggleCreation","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"tokenURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"tokenX","outputs":[{"internalType":"contract ERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalLockedAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"transferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"optionID","type":"uint256"},{"internalType":"uint256","name":"priceAtExpiration","type":"uint256"}],"name":"unlock","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"userOptionIds","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"}]
Contract Creation Code
60806040526000600855600a805461ffff60281b1916651900000000001790553480156200002c57600080fd5b50604051620047c4380380620047c48339810160408190526200004f91620002c2565b6040805180820182526006815265213ab33332b960d11b60208083019182528351808501909452600384526221232960e91b908401526001600081905582519293926200009d92906200021c565b508051620000b39060029060208401906200021c565b5050600f80546001600160a01b03808a166001600160a01b031992831617909255600c8054898416908316179055600d8054888416908316179055600e8054928716929091169190911790555080516200011590600b9060208401906200021c565b50600e805483919060ff60a01b1916600160a01b8360028111156200014a57634e487b7160e01b600052602160045260246000fd5b02179055506200015c60003362000168565b50505050505062000474565b62000174828262000178565b5050565b60008281526007602090815260408083206001600160a01b038516845290915290205460ff16620001745760008281526007602090815260408083206001600160a01b03851684529091529020805460ff19166001179055620001d83390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b8280546200022a9062000408565b90600052602060002090601f0160209004810192826200024e576000855562000299565b82601f106200026957805160ff191683800117855562000299565b8280016001018555821562000299579182015b82811115620002995782518255916020019190600101906200027c565b50620002a7929150620002ab565b5090565b5b80821115620002a75760008155600101620002ac565b60008060008060008060c08789031215620002db578182fd5b8651620002e8816200045b565b80965050602080880151620002fd816200045b565b604089015190965062000310816200045b565b606089015190955062000323816200045b565b60808901519094506003811062000338578384fd5b60a08901519093506001600160401b038082111562000355578384fd5b818a0191508a601f83011262000369578384fd5b8151818111156200037e576200037e62000445565b604051601f8201601f19908116603f01168101908382118183101715620003a957620003a962000445565b816040528281528d86848701011115620003c1578687fd5b8693505b82841015620003e45784840186015181850187015292850192620003c5565b82841115620003f557868684830101525b8096505050505050509295509295509295565b600181811c908216806200041d57607f821691505b602082108114156200043f57634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052604160045260246000fd5b6001600160a01b03811681146200047157600080fd5b50565b61434080620004846000396000f3fe608060405234801561001057600080fd5b50600436106102305760003560e01c806301ffc9a71461023557806305a9f2741461025d57806306fdde0314610274578063081812fc14610289578063095ea7b3146102a957806310082c75146102be5780631441a5a9146102c657806316dc165b146102d957806316f0115b146102ec578063185ecb48146102ff57806323b872dd14610312578063245445b314610325578063248a9ca31461034b5780632c26d8ee1461035e5780632f2ff15d1461037f57806330d643b514610392578063313ce567146103a757806336568abe146103af57806336ebafe9146103c25780633c993eee146103d7578063409e2205146103ea57806342842e0e1461045e57806346c2048f146104715780634cc19ad3146104795780635a6ce476146104815780635bfadb24146104b157806360489a34146104c45780636352211e146104f0578063645734e6146105035780636bbfe61b1461050b57806370a082311461051e57806375794a3c1461053157806379502c551461053a57806391d148541461054d57806395d89b4114610560578063a217fddf14610568578063a22cb46514610570578063b187bd2614610583578063b88d4fde14610590578063b916aa85146105a3578063c87b56dd146105b6578063c962ca12146105c9578063cfe97fb2146105dc578063d547741f146105f1578063e985e9c514610604578063eb2f5d4b14610617578063f7d52fa114610639578063faeb543a1461064c575b600080fd5b610248610243366004613932565b61067c565b60405190151581526020015b60405180910390f35b61026660095481565b604051908152602001610254565b61027c61068d565b6040516102549190613e5b565b61029c6102973660046138f6565b61071f565b6040516102549190613d1c565b6102bc6102b7366004613893565b610746565b005b61027c610861565b600e5461029c906001600160a01b031681565b600f5461029c906001600160a01b031681565b600c5461029c906001600160a01b031681565b61026661030d36600461399c565b6108ef565b6102bc61032036600461374e565b610c87565b600a5461033890610100900461ffff1681565b60405161ffff9091168152602001610254565b6102666103593660046138f6565b610cb8565b600e5461037290600160a01b900460ff1681565b6040516102549190613dda565b6102bc61038d36600461390e565b610ccd565b6102666000805160206142eb83398151915281565b610266610ce9565b6102bc6103bd36600461390e565b610d6e565b600a5461033890600160281b900461ffff1681565b6102486103e5366004613b28565b610dec565b6104496103f83660046138f6565b60106020526000908152604090208054600182015460028301546003840154600485015460058601546006870154600788015460089098015460ff9788169896979596949593949293909116919089565b60405161025499989796959493929190613df4565b6102bc61046c36600461374e565b610e56565b6102bc610e71565b610266610eca565b6104a461048f366004613b77565b60126020526000908152604090205460ff1681565b6040516102549190613fad565b6102bc6104bf366004613b07565b61113b565b6104d76104d236600461374e565b61134b565b60408051921515835260ff909116602083015201610254565b61029c6104fe3660046138f6565b6116f7565b6102bc61172c565b6102bc6105193660046139fe565b6117b9565b61026661052c3660046136de565b611911565b61026660085481565b600d5461029c906001600160a01b031681565b61024861055b36600461390e565b611997565b61027c6119c2565b610266600081565b6102bc61057e366004613866565b6119d1565b600a546102489060ff1681565b6102bc61059e36600461378e565b6119dc565b6102bc6105b1366004613b28565b611a14565b61027c6105c43660046138f6565b611cac565b6102666105d7366004613893565b611d1f565b600a54610338906301000000900461ffff1681565b6102bc6105ff36600461390e565b611d50565b610248610612366004613716565b611d6c565b61062a610625366004613a63565b611d9a565b60405161025493929190613f97565b6102486106473660046138f6565b611e57565b61065f61065a36600461396a565b61205e565b604080519384526020840192909252151590820152606001610254565b6000610687826123e9565b92915050565b60606001805461069c90614196565b80601f01602080910402602001604051908101604052809291908181526020018280546106c890614196565b80156107155780601f106106ea57610100808354040283529160200191610715565b820191906000526020600020905b8154815290600101906020018083116106f857829003601f168201915b5050505050905090565b600061072a8261240e565b506000908152600560205260409020546001600160a01b031690565b6000610751826116f7565b9050806001600160a01b0316836001600160a01b031614156107c45760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b60648201526084015b60405180910390fd5b336001600160a01b03821614806107e057506107e08133611d6c565b6108525760405162461bcd60e51b815260206004820152603e60248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f7420746f60448201527f6b656e206f776e6572206e6f7220617070726f76656420666f7220616c6c000060648201526084016107bb565b61085c8383612433565b505050565b600b805461086e90614196565b80601f016020809104026020016040519081016040528092919081815260200182805461089a90614196565b80156108e75780601f106108bc576101008083540402835291602001916108e7565b820191906000526020600020905b8154815290600101906020018083116108ca57829003601f168201915b505050505081565b60006000805160206142eb833981519152610909816124a1565b60408051610120810182526001815286356020808301919091528701359181018290526060810182905260009160808201906109479060029061401e565b815260200161095a604089013587614006565b815260200161096f6080890160608a016138be565b151581526020018760a00135815260200185815250905085602001356009600082825461099c9190614006565b909155506109aa90506124ab565b9250601160006109c060e0890160c08a016136de565b6001600160a01b031681526020808201929092526040908101600090812080546001818101835591835284832001879055868252601090935220825181548493839160ff191690836003811115610a2757634e487b7160e01b600052602160045260246000fd5b02179055506020820151600182015560408201516002820155606082015160038201556080820151600482015560a0820151600582015560c08083015160068301805460ff191691151591909117905560e080840151600784015561010090930151600890920191909155610aab91610aa5919089019089016136de565b846124c5565b6000610aed610ac060e0890160c08a016136de565b60a089013560208a0135610ad760e08c018c613fbb565b610ae760808e0160608f016138be565b8c6125e5565b905060008183608001518960a00135610b06919061413c565b610b10919061413c565b9050610bae600d60009054906101000a90046001600160a01b03166001600160a01b031663136834366040518163ffffffff1660e01b815260040160206040518083038186803b158015610b6357600080fd5b505afa158015610b77573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b9b91906136fa565b600f546001600160a01b03169083612895565b600c546060840151608085015160405163edd0d42160e01b81526001600160a01b039093169263edd0d42192610be8928a92600401613f97565b600060405180830381600087803b158015610c0257600080fd5b505af1158015610c16573d6000803e3d6000fd5b50879250610c2d91505060e08a0160c08b016136de565b6001600160a01b03167fe3a07e2ac405f9c908f600ba464ed28dd28f04e308ccc0610a33ca7ed1c59abb838b60a00135604051610c74929190918252602082015260400190565b60405180910390a3505050509392505050565b610c9133826128eb565b610cad5760405162461bcd60e51b81526004016107bb90613f49565b61085c83838361294a565b60009081526007602052604090206001015490565b610cd682610cb8565b610cdf816124a1565b61085c8383612ad4565b600f546040805163313ce56760e01b815290516000926001600160a01b03169163313ce567916004808301926020929190829003018186803b158015610d2e57600080fd5b505afa158015610d42573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d669190613b93565b60ff16905090565b6001600160a01b0381163314610dde5760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b60648201526084016107bb565b610de88282612b5a565b5050565b6000612710610dfb8582614006565b610e05908461411d565b610e0f919061401e565b8311158015610e3e5750612710610e26858261413c565b610e30908461411d565b610e3a919061401e565b8310155b15610e4b57506001610e4f565b5060005b9392505050565b61085c838383604051806020016040528060008152506119dc565b6000610e7c816124a1565b600a805460ff8082161560ff1990921682179092556040519116151581527f9422424b175dda897495a07b091ef74a3ef715cf6d866fc972954c1c7f4593049060200160405180910390a150565b600080600c60009054906101000a90046001600160a01b03166001600160a01b031663d9ac10d96040518163ffffffff1660e01b815260040160206040518083038186803b158015610f1b57600080fd5b505afa158015610f2f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f539190613a4b565b9050600060095482610f65919061413c565b90506000600d60009054906101000a90046001600160a01b03166001600160a01b0316631b3a1f5b6040518163ffffffff1660e01b815260040160206040518083038186803b158015610fb757600080fd5b505afa158015610fcb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fef91906139e2565b61ffff1690506000611002848484612bc1565b9050600d60009054906101000a90046001600160a01b03166001600160a01b031663e4efa6076040518163ffffffff1660e01b815260040160206040518083038186803b15801561105257600080fd5b505afa158015611066573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061108a91906139e2565b61ffff169150600c60009054906101000a90046001600160a01b03166001600160a01b031663ab2f0e516040518163ffffffff1660e01b815260040160206040518083038186803b1580156110de57600080fd5b505afa1580156110f2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111169190613a4b565b92506000611125858585612bc1565b90506111318183612c45565b9550505050505090565b6000805160206142eb833981519152611153816124a1565b61115c83612c5b565b61118e5760405162461bcd60e51b815260206004820152600360248201526204f31360ec1b60448201526064016107bb565b600083815260106020526040902060058101544210156111d55760405162461bcd60e51b815260206004820152600260248201526113cd60f21b60448201526064016107bb565b6001815460ff1660038111156111fb57634e487b7160e01b600052602160045260246000fd5b1461122d5760405162461bcd60e51b81526020600482015260026024820152614f3560f01b60448201526064016107bb565b600681015460ff1680156112445750806001015483115b806112625750600681015460ff161580156112625750806001015483105b15611277576112718484612c78565b5061132a565b805460ff19166003178155600c54604051636198e33960e01b8152600481018690526001600160a01b0390911690636198e33990602401600060405180830381600087803b1580156112c857600080fd5b505af11580156112dc573d6000803e3d6000fd5b505050506112e984612d68565b6004810154604080519182526020820185905285917f8df989ec4d63ff27cc8613c3967b232fc87098777add68203a63bbca1e508ffa910160405180910390a25b806003015460096000828254611340919061413c565b909155505050505050565b60008060006001600160a01b0316600d60009054906101000a90046001600160a01b03166001600160a01b031663fc8e90f26040518163ffffffff1660e01b815260040160206040518083038186803b1580156113a757600080fd5b505afa1580156113bb573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113df91906136fa565b6001600160a01b03161461159d57600d5460408051637e47487960e11b815290516000926001600160a01b03169163fc8e90f2916004808301926020929190829003018186803b15801561143257600080fd5b505afa158015611446573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061146a91906136fa565b9050846001600160a01b0316816001600160a01b0316631caaa487866040518263ffffffff1660e01b81526004016114a491815260200190565b60206040518083038186803b1580156114bc57600080fd5b505afa1580156114d0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114f491906136fa565b6001600160a01b0316141561159b57604051634e8ba86160e11b8152600481018590526012906000906001600160a01b03841690639d1750c29060240160206040518083038186803b15801561154957600080fd5b505afa15801561155d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115819190613b93565b60ff90811682526020820192909252604001600020541691505b505b836001600160a01b0316856001600160a01b0316141580156115c757506001600160a01b03851615155b80156115db57506001600160a01b0385163b155b156116ef57600e5460405163010de89960e21b81526000916001600160a01b03169063ad1b1493908290630437a26490611619908b90600401613d1c565b60206040518083038186803b15801561163157600080fd5b505afa158015611645573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116699190613b93565b6040518263ffffffff1660e01b81526004016116859190613fad565b60206040518083038186803b15801561169d57600080fd5b505afa1580156116b1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116d59190613b93565b90508160ff168160ff1611156116ed57809150600192505b505b935093915050565b6000818152600360205260408120546001600160a01b0316806106875760405162461bcd60e51b81526004016107bb90613f17565b600f54600c5460405163095ea7b360e01b81526001600160a01b039283169263095ea7b3926117649291169060001990600401613dc1565b602060405180830381600087803b15801561177e57600080fd5b505af1158015611792573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117b691906138da565b50565b60006117c4816124a1565b8361ffff166103e811156117ea5760405162461bcd60e51b81526004016107bb90613e6e565b6113888461ffff1611156118105760405162461bcd60e51b81526004016107bb90613efa565b600a805461ffff8087166101000262ffff00199092169190911790915583166103e811156118505760405162461bcd60e51b81526004016107bb90613e6e565b6113888361ffff1611156118765760405162461bcd60e51b81526004016107bb90613efa565b600a805464ffff0000001916630100000061ffff86160217905560005b60048160ff16101561190a57828160ff16600481106118c257634e487b7160e01b600052603260045260246000fd5b6020020160208101906118d59190613b77565b60ff8281166000908152601260205260409020805460ff19169290911691909117905580611902816141e6565b915050611893565b5050505050565b60006001600160a01b03821661197b5760405162461bcd60e51b815260206004820152602960248201527f4552433732313a2061646472657373207a65726f206973206e6f7420612076616044820152683634b21037bbb732b960b91b60648201526084016107bb565b506001600160a01b031660009081526004602052604090205490565b60009182526007602090815260408084206001600160a01b0393909316845291905290205460ff1690565b60606002805461069c90614196565b610de8338383612df1565b6119e633836128eb565b611a025760405162461bcd60e51b81526004016107bb90613f49565b611a0e84848484612ebc565b50505050565b600a5460ff1615611a375760405162461bcd60e51b81526004016107bb90613edd565b6101f4831115611a6f5760405162461bcd60e51b815260206004820152600360248201526213cccd60ea1b60448201526064016107bb565b600d60009054906101000a90046001600160a01b03166001600160a01b031663ffd49c846040518163ffffffff1660e01b815260040160206040518083038186803b158015611abd57600080fd5b505afa158015611ad1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611af59190613b53565b63ffffffff16821015611b305760405162461bcd60e51b81526020600482015260036024820152624f323160e81b60448201526064016107bb565b600d60009054906101000a90046001600160a01b03166001600160a01b03166349b9a67f6040518163ffffffff1660e01b815260040160206040518083038186803b158015611b7e57600080fd5b505afa158015611b92573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611bb69190613b53565b63ffffffff16821115611bf15760405162461bcd60e51b81526020600482015260036024820152624f323560e81b60448201526064016107bb565b600d60009054906101000a90046001600160a01b03166001600160a01b03166324ec75906040518163ffffffff1660e01b815260040160206040518083038186803b158015611c3f57600080fd5b505afa158015611c53573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c779190613a4b565b81101561085c5760405162461bcd60e51b81526020600482015260036024820152624f333560e81b60448201526064016107bb565b6060611cb78261240e565b6000611cce60408051602081019091526000815290565b90506000815111611cee5760405180602001604052806000815250610e4f565b80611cf884612eef565b604051602001611d09929190613c7e565b6040516020818303038152906040529392505050565b60116020528160005260406000208181548110611d3b57600080fd5b90600052602060002001600091509150505481565b611d5982610cb8565b611d62816124a1565b61085c8383612b5a565b6001600160a01b03918216600090815260066020908152604080832093909416825291909152205460ff1690565b600e54604051637d191bdb60e01b8152600091829182918291611e37916001600160a01b031690637d191bdb90611dd7908b908b90600401613e47565b60206040518083038186803b158015611def57600080fd5b505afa158015611e03573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e2791906136fa565b8a611e318b613008565b88613033565b509050611e448a8261307d565b919c909b50909950975050505050505050565b600042816007611e6a620151808461401e565b611e75906004614006565b611e7f9190614206565b90506000600762015180611e938786614006565b611e9d919061401e565b611ea8906004614006565b611eb29190614206565b9050808214156120535760006018611ecc610e108661401e565b611ed69190614206565b90506000603c611ee8610e1087614206565b611ef2919061401e565b905060006018610e10611f058a89614006565b611f0f919061401e565b611f199190614206565b90506000603c610e10611f2c8b8a614006565b611f369190614206565b611f40919061401e565b600d54604051631b1c13eb60e21b81529192506000918291829182916001600160a01b031690636c704fac90611f7a908d90600401613fad565b60806040518083038186803b158015611f9257600080fd5b505afa158015611fa6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611fca9190613baf565b60ff16935060ff16935060ff16935060ff16935083881180611ff657508388148015611ff65750828710155b80156120145750818810806120145750818814801561201457508087105b80156120325750818610806120325750818614801561203257508085105b1561204a575060019c9b505050505050505050505050565b50505050505050505b506000949350505050565b600a546000908190819060ff16156120885760405162461bcd60e51b81526004016107bb90613edd565b6000600e54600160a01b900460ff1660028111156120b657634e487b7160e01b600052602160045260246000fd5b1415806120cb57506120cb8460400135611e57565b6120fd5760405162461bcd60e51b815260206004820152600360248201526204f33360ec1b60448201526064016107bb565b6000612107610eca565b90506000612710600d60009054906101000a90046001600160a01b03166001600160a01b03166324b49d596040518163ffffffff1660e01b815260040160206040518083038186803b15801561215c57600080fd5b505afa158015612170573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061219491906139e2565b61ffff16600c60009054906101000a90046001600160a01b03166001600160a01b031663ab2f0e516040518163ffffffff1660e01b815260040160206040518083038186803b1580156121e657600080fd5b505afa1580156121fa573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061221e9190613a4b565b612228919061411d565b612232919061401e565b905060006122448760a0013583612c45565b600e5490915060009061230c906001600160a01b0316637d191bdb61226c60e08c018c613fbb565b6040518363ffffffff1660e01b8152600401612289929190613e47565b60206040518083038186803b1580156122a157600080fd5b505afa1580156122b5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122d991906136fa565b6122e960e08b0160c08c016136de565b6123016122fc60808d0160608e016138be565b613008565b8b6101000135613033565b95509050600061232e61231d610ce9565b61232890600a614075565b8361307d565b505090508061233b610ce9565b61234690600a614075565b612350908561411d565b61235a919061401e565b97508488118061236d57508860a0013583105b156123d55761238260a08a0160808b016138be565b6123b45760405162461bcd60e51b81526020600482015260036024820152624f323960e81b60448201526064016107bb565b6123be8886612c45565b97506123ca888361307d565b509097506123dd9050565b8860a0013596505b50505050509193909250565b60006001600160e01b03198216637965db0b60e01b14806106875750610687826130c5565b61241781612c5b565b6117b65760405162461bcd60e51b81526004016107bb90613f17565b600081815260056020526040902080546001600160a01b0319166001600160a01b0384169081179091558190612468826116f7565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6117b68133613115565b60088054600091826124bc836141cb565b91905055905090565b6001600160a01b03821661251b5760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f206164647265737360448201526064016107bb565b61252481612c5b565b156125705760405162461bcd60e51b815260206004820152601c60248201527b115490cdcc8c4e881d1bdad95b88185b1c9958591e481b5a5b9d195960221b60448201526064016107bb565b6001600160a01b0382166000908152600460205260408120805460019290612599908490614006565b909155505060008181526003602052604080822080546001600160a01b0319166001600160a01b03861690811790915590518392906000805160206142cb833981519152908290a45050565b600e54604051637d191bdb60e01b815260009182916001600160a01b0390911690637d191bdb9061261c9089908990600401613e47565b60206040518083038186803b15801561263457600080fd5b505afa158015612648573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061266c91906136fa565b9050886001600160a01b0316816001600160a01b03161415801561269857506001600160a01b03811615155b80156126ac57506001600160a01b0381163b155b1561288957600e5460405163010de89960e21b815262989680916001600160a01b031690639c5b5a74908290630437a264906126ec908790600401613d1c565b60206040518083038186803b15801561270457600080fd5b505afa158015612718573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061273c9190613b93565b6040518263ffffffff1660e01b81526004016127589190613fad565b60206040518083038186803b15801561277057600080fd5b505afa158015612784573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127a89190613b53565b6127b89063ffffffff168a61411d565b6127c2919061401e565b9150811561288957600f546127e1906001600160a01b03168284612895565b600061280b6127ee610ce9565b6127f990600a614075565b61280287613008565b61ffff1661307d565b505090507f4dcf678c034d0e315232ac598af6dbd0ac15f49f05df2c425292d10736d95b368a83868c878e61283e610ce9565b61284990600a614075565b8f89612855919061411d565b61285f919061401e565b612869919061413c565b8d8d60405161287f989796959493929190613d30565b60405180910390a1505b50979650505050505050565b61085c8363a9059cbb60e01b84846040516024016128b4929190613dc1565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152613179565b6000806128f7836116f7565b9050806001600160a01b0316846001600160a01b0316148061291e575061291e8185611d6c565b806129425750836001600160a01b03166129378461071f565b6001600160a01b0316145b949350505050565b826001600160a01b031661295d826116f7565b6001600160a01b0316146129c15760405162461bcd60e51b815260206004820152602560248201527f4552433732313a207472616e736665722066726f6d20696e636f72726563742060448201526437bbb732b960d91b60648201526084016107bb565b6001600160a01b038216612a235760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b60648201526084016107bb565b612a2e600082612433565b6001600160a01b0383166000908152600460205260408120805460019290612a5790849061413c565b90915550506001600160a01b0382166000908152600460205260408120805460019290612a85908490614006565b909155505060008181526003602052604080822080546001600160a01b0319166001600160a01b0386811691821790925591518493918716916000805160206142cb83398151915291a4505050565b612ade8282611997565b610de85760008281526007602090815260408083206001600160a01b03851684529091529020805460ff19166001179055612b163390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b612b648282611997565b15610de85760008281526007602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b600061271084612bd1848361413c565b612bdb919061411d565b612be5919061401e565b8311612c195760405162461bcd60e51b81526020600482015260036024820152624f333160e81b60448201526064016107bb565b61271084612c27848361413c565b612c31919061411d565b612c3b919061401e565b612942908461413c565b6000818310612c545781610e4f565b5090919050565b6000908152600360205260409020546001600160a01b0316151590565b600082815260106020526040812081612c90856116f7565b6003830154600c546040516381b34f1560e01b8152600481018990526001600160a01b0380851660248301526044820184905292965092935016906381b34f1590606401600060405180830381600087803b158015612cee57600080fd5b505af1158015612d02573d6000803e3d6000fd5b50505050612d0f85612d68565b815460ff19166002178255604080518481526020810186905286916001600160a01b038416917fe4d92883d01c4cebb3cfe4b9ce51b235e47ab25776cdc003281bc47cc1ec28be910160405180910390a3505092915050565b6000612d73826116f7565b9050612d80600083612433565b6001600160a01b0381166000908152600460205260408120805460019290612da990849061413c565b909155505060008281526003602052604080822080546001600160a01b0319169055518391906001600160a01b038416906000805160206142cb833981519152908390a45050565b816001600160a01b0316836001600160a01b03161415612e4f5760405162461bcd60e51b815260206004820152601960248201527822a9219b99189d1030b8383937bb32903a379031b0b63632b960391b60448201526064016107bb565b6001600160a01b03838116600081815260066020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b612ec784848461294a565b612ed38484848461324b565b611a0e5760405162461bcd60e51b81526004016107bb90613e8b565b606081612f135750506040805180820190915260018152600360fc1b602082015290565b8160005b8115612f3d5780612f27816141cb565b9150612f369050600a8361401e565b9150612f17565b6000816001600160401b03811115612f6557634e487b7160e01b600052604160045260246000fd5b6040519080825280601f01601f191660200182016040528015612f8f576020820181803683370190505b5090505b841561294257612fa460018361413c565b9150612fb1600a86614206565b612fbc906030614006565b60f81b818381518110612fdf57634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a905350613001600a8661401e565b9450612f93565b60008161302257600a546301000000900461ffff16610687565b5050600a54610100900461ffff1690565b61ffff821660008061304687878661134b565b600a5491935060ff169150613067908290600160281b900461ffff1661411d565b613071908461413c565b92505094509492505050565b6000808061308c60028661401e565b905061309a8461271061413c565b6130a68261271061411d565b6130b0919061401e565b92506130bc818461413c565b91509250925092565b60006001600160e01b031982166380ac58cd60e01b14806130f657506001600160e01b03198216635b5e139f60e01b145b8061068757506301ffc9a760e01b6001600160e01b0319831614610687565b61311f8282611997565b610de857613137816001600160a01b0316601461335f565b61314283602061335f565b604051602001613153929190613cad565b60408051601f198184030181529082905262461bcd60e51b82526107bb91600401613e5b565b60006131ce826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166135409092919063ffffffff16565b80519091501561085c57808060200190518101906131ec91906138da565b61085c5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b60648201526084016107bb565b600061325f846001600160a01b031661354f565b1561335457604051630a85bd0160e11b81526001600160a01b0385169063150b7a0290613296903390899088908890600401613d84565b602060405180830381600087803b1580156132b057600080fd5b505af19250505080156132e0575060408051601f3d908101601f191682019092526132dd9181019061394e565b60015b61333a573d80801561330e576040519150601f19603f3d011682016040523d82523d6000602084013e613313565b606091505b5080516133325760405162461bcd60e51b81526004016107bb90613e8b565b805181602001fd5b6001600160e01b031916630a85bd0160e11b149050612942565b506001949350505050565b6060600061336e83600261411d565b613379906002614006565b6001600160401b0381111561339e57634e487b7160e01b600052604160045260246000fd5b6040519080825280601f01601f1916602001820160405280156133c8576020820181803683370190505b509050600360fc1b816000815181106133f157634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a905350600f60fb1b8160018151811061342e57634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a905350600061345284600261411d565b61345d906001614006565b90505b60018111156134f1576f181899199a1a9b1b9c1cb0b131b232b360811b85600f166010811061349f57634e487b7160e01b600052603260045260246000fd5b1a60f81b8282815181106134c357634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a90535060049490941c936134ea8161417f565b9050613460565b508315610e4f5760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e7460448201526064016107bb565b6060612942848460008561355e565b6001600160a01b03163b151590565b6060824710156135bf5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b60648201526084016107bb565b6135c88561354f565b6136145760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016107bb565b600080866001600160a01b031685876040516136309190613c62565b60006040518083038185875af1925050503d806000811461366d576040519150601f19603f3d011682016040523d82523d6000602084013e613672565b606091505b509150915061368282828661368d565b979650505050505050565b6060831561369c575081610e4f565b8251156136ac5782518084602001fd5b8160405162461bcd60e51b81526004016107bb9190613e5b565b600061012082840312156136d8578081fd5b50919050565b6000602082840312156136ef578081fd5b8135610e4f81614272565b60006020828403121561370b578081fd5b8151610e4f81614272565b60008060408385031215613728578081fd5b823561373381614272565b9150602083013561374381614272565b809150509250929050565b600080600060608486031215613762578081fd5b833561376d81614272565b9250602084013561377d81614272565b929592945050506040919091013590565b600080600080608085870312156137a3578081fd5b84356137ae81614272565b935060208501356137be81614272565b92506040850135915060608501356001600160401b03808211156137e0578283fd5b818701915087601f8301126137f3578283fd5b8135818111156138055761380561425c565b604051601f8201601f19908116603f0116810190838211818310171561382d5761382d61425c565b816040528281528a6020848701011115613845578586fd5b82602086016020830137918201602001949094529598949750929550505050565b60008060408385031215613878578182fd5b823561388381614272565b9150602083013561374381614287565b600080604083850312156138a5578182fd5b82356138b081614272565b946020939093013593505050565b6000602082840312156138cf578081fd5b8135610e4f81614287565b6000602082840312156138eb578081fd5b8151610e4f81614287565b600060208284031215613907578081fd5b5035919050565b60008060408385031215613920578182fd5b82359150602083013561374381614272565b600060208284031215613943578081fd5b8135610e4f81614295565b60006020828403121561395f578081fd5b8151610e4f81614295565b60006020828403121561397b578081fd5b81356001600160401b03811115613990578182fd5b612942848285016136c6565b6000806000606084860312156139b0578081fd5b83356001600160401b038111156139c5578182fd5b6139d1868287016136c6565b935050602084013561377d81614287565b6000602082840312156139f3578081fd5b8151610e4f816142ab565b600080600060c08486031215613a12578081fd5b8335613a1d816142ab565b92506020840135613a2d816142ab565b915060c08401851015613a3e578081fd5b6040840190509250925092565b600060208284031215613a5c578081fd5b5051919050565b60008060008060008060a08789031215613a7b578384fd5b863595506020870135613a8d81614272565b94506040870135613a9d81614287565b935060608701356001600160401b0380821115613ab8578384fd5b818901915089601f830112613acb578384fd5b813581811115613ad9578485fd5b8a6020828501011115613aea578485fd5b602083019550809450505050608087013590509295509295509295565b60008060408385031215613b19578182fd5b50508035926020909101359150565b600080600060608486031215613b3c578081fd5b505081359360208301359350604090920135919050565b600060208284031215613b64578081fd5b815163ffffffff81168114610e4f578182fd5b600060208284031215613b88578081fd5b8135610e4f816142bb565b600060208284031215613ba4578081fd5b8151610e4f816142bb565b60008060008060808587031215613bc4578182fd5b8451613bcf816142bb565b6020860151909450613be0816142bb565b6040860151909350613bf1816142bb565b6060860151909250613c02816142bb565b939692955090935050565b60008151808452613c25816020860160208601614153565b601f01601f19169290920160200192915050565b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b60008251613c74818460208701614153565b9190910192915050565b60008351613c90818460208801614153565b835190830190613ca4818360208801614153565b01949350505050565b76020b1b1b2b9b9a1b7b73a3937b61d1030b1b1b7bab73a1604d1b815260008351613cdf816017850160208801614153565b7001034b99036b4b9b9b4b733903937b6329607d1b6017918401918201528351613d10816028840160208801614153565b01602801949350505050565b6001600160a01b0391909116815260200190565b600060018060a01b03808b168352808a1660208401525087151560408301528660608301528560808301528460a083015260e060c0830152613d7660e083018486613c39565b9a9950505050505050505050565b6001600160a01b0385811682528416602082015260408101839052608060608201819052600090613db790830184613c0d565b9695505050505050565b6001600160a01b03929092168252602082015260400190565b6020810160038310613dee57613dee614246565b91905290565b610120810160048b10613e0957613e09614246565b998152602081019890985260408801969096526060870194909452608086019290925260a0850152151560c084015260e08301526101009091015290565b602081526000612942602083018486613c39565b602081526000610e4f6020830184613c0d565b6020808252600390820152624f323760e81b604082015260600190565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b6020808252600390820152624f333360e81b604082015260600190565b60208082526003908201526209e64760eb1b604082015260600190565b602080825260189082015277115490cdcc8c4e881a5b9d985b1a59081d1bdad95b88125160421b604082015260600190565b6020808252602e908201527f4552433732313a2063616c6c6572206973206e6f7420746f6b656e206f776e6560408201526d1c881b9bdc88185c1c1c9bdd995960921b606082015260800190565b9283526020830191909152604082015260600190565b60ff91909116815260200190565b6000808335601e19843603018112613fd1578283fd5b8301803591506001600160401b03821115613fea578283fd5b602001915036819003821315613fff57600080fd5b9250929050565b600082198211156140195761401961421a565b500190565b60008261402d5761402d614230565b500490565b600181815b8085111561406d5781600019048211156140535761405361421a565b8085161561406057918102915b93841c9390800290614037565b509250929050565b6000610e4f838360008261408b57506001610687565b8161409857506000610687565b81600181146140ae57600281146140b8576140d4565b6001915050610687565b60ff8411156140c9576140c961421a565b50506001821b610687565b5060208310610133831016604e8410600b84101617156140f7575081810a610687565b6141018383614032565b80600019048211156141155761411561421a565b029392505050565b60008160001904831182151516156141375761413761421a565b500290565b60008282101561414e5761414e61421a565b500390565b60005b8381101561416e578181015183820152602001614156565b83811115611a0e5750506000910152565b60008161418e5761418e61421a565b506000190190565b600181811c908216806141aa57607f821691505b602082108114156136d857634e487b7160e01b600052602260045260246000fd5b60006000198214156141df576141df61421a565b5060010190565b600060ff821660ff8114156141fd576141fd61421a565b60010192915050565b60008261421557614215614230565b500690565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052602160045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b03811681146117b657600080fd5b80151581146117b657600080fd5b6001600160e01b0319811681146117b657600080fd5b61ffff811681146117b657600080fd5b60ff811681146117b657600080fdfeddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef7a05a596cb0ce7fdea8a1e1ec73be300bdb35097c944ce1897202f7a13122eb2a2646970667358221220aca7e9ce56f0dce14bb5d7f9085d224d159cacb4231aaa4a823fa984e9cd8bc864736f6c63430008040033000000000000000000000000ff970a61a04b1ca14834a43f5de4533ebddb5cc80000000000000000000000006ec7b10bf7331794adaaf235cb47a2a292cd9c7e00000000000000000000000008d5e019fb16f92822befac9986e7b7402dae610000000000000000000000000fea57b9548cd72d8705e4bb0fa83aa35966d9c29000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000000064254435553440000000000000000000000000000000000000000000000000000
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
000000000000000000000000ff970a61a04b1ca14834a43f5de4533ebddb5cc80000000000000000000000006ec7b10bf7331794adaaf235cb47a2a292cd9c7e00000000000000000000000008d5e019fb16f92822befac9986e7b7402dae610000000000000000000000000fea57b9548cd72d8705e4bb0fa83aa35966d9c29000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000000064254435553440000000000000000000000000000000000000000000000000000
-----Decoded View---------------
Arg [0] : _tokenX (address): 0xff970a61a04b1ca14834a43f5de4533ebddb5cc8
Arg [1] : _pool (address): 0x6ec7b10bf7331794adaaf235cb47a2a292cd9c7e
Arg [2] : _config (address): 0x08d5e019fb16f92822befac9986e7b7402dae610
Arg [3] : _referral (address): 0xfea57b9548cd72d8705e4bb0fa83aa35966d9c29
Arg [4] : _category (uint8): 1
Arg [5] : _assetPair (string): BTCUSD
-----Encoded View---------------
8 Constructor Arguments found :
Arg [0] : 000000000000000000000000ff970a61a04b1ca14834a43f5de4533ebddb5cc8
Arg [1] : 0000000000000000000000006ec7b10bf7331794adaaf235cb47a2a292cd9c7e
Arg [2] : 00000000000000000000000008d5e019fb16f92822befac9986e7b7402dae610
Arg [3] : 000000000000000000000000fea57b9548cd72d8705e4bb0fa83aa35966d9c29
Arg [4] : 0000000000000000000000000000000000000000000000000000000000000001
Arg [5] : 00000000000000000000000000000000000000000000000000000000000000c0
Arg [6] : 0000000000000000000000000000000000000000000000000000000000000006
Arg [7] : 4254435553440000000000000000000000000000000000000000000000000000