Source Code
Overview
POL Balance
More Info
ContractCreator
Multichain Info
N/A
Loading...
Loading
This contract may be a proxy contract. Click on More Options and select Is this a proxy? to confirm and enable the "Read as Proxy" & "Write as Proxy" tabs.
Contract Name:
ParlayConditionalTokens
Compiler Version
v0.8.19+commit.7dd6d404
Optimization Enabled:
Yes with 600 runs
Other Settings:
paris EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT pragma solidity ^0.8.19; // solhint-disable one-contract-per-file import { ERC165Checker } from "@openzeppelin/contracts/utils/introspection/ERC165Checker.sol"; import { IERC165Upgradeable } from "@openzeppelin/contracts-upgradeable/utils/introspection/IERC165Upgradeable.sol"; import { ERC1155Upgradeable } from "@openzeppelin/contracts-upgradeable/token/ERC1155/ERC1155Upgradeable.sol"; import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import { IConditionalTokens, IConditionalTokensV1_2, PackedPrices } from "./IConditionalTokensV1_2.sol"; import { ConditionalTokensBase } from "./ConditionalTokensBase.sol"; import { ILegConditionalTokens } from "./ILegConditionalTokens.sol"; import { ParlayLegs, IParlayConditionalTokens, IParlayConditionalTokensEvents } from "./IParlayConditionalTokens.sol"; import { ParlayConditionalTokensErrors } from "./ParlayConditionalTokensErrors.sol"; import { ConditionID, QuestionID, PackedIndices, CTHelpers } from "./CTHelpers.sol"; contract ParlayConditionalTokensStorage { struct LegInfo { ConditionID[] legConditionIds; /// @dev each byte corresponds to a uint8 index PackedIndices indices; } /// @dev conditional tokens for individual legs IConditionalTokensV1_2 public legConditionalTokens; /// @dev storage associating parlay conditon ID with underlying leg info mapping(ConditionID => LegInfo) internal legInfo; uint256[50] private __gap; } contract ParlayConditionalTokens is IConditionalTokensV1_2, IParlayConditionalTokens, IParlayConditionalTokensEvents, ConditionalTokensBase, ParlayConditionalTokensStorage, ParlayConditionalTokensErrors { using ERC165Checker for address; bytes4 private constant CONDITIONAL_TOKENS_INTERFACE_V1_2_ID = 0x306da52d; bytes4 private constant LEG_CONDITIONAL_TOKENS_INTERFACE_ID = 0x06c6babb; /// @dev Limitation of at most 9 conditions. This is due to overflow issues /// when calculating the price/payout for the outcomes. uint256 public constant MAX_LEGS_IN_PARLAY = 9; /// @custom:oz-upgrades-unsafe-allow constructor constructor() { // TODO: assert constants prevent overflow _disableInitializers(); } // solhint-disable-next-line no-empty-blocks function _authorizeUpgrade(address) internal override onlyOwner { } // solhint-disable-next-line ordering function initialize(address legConditionalTokens_) public initializer { __ConditionalTokensBase_init(); legConditionalTokens = IConditionalTokensV1_2(legConditionalTokens_); } /// @inheritdoc IParlayConditionalTokens function getParlayQuestionId( address legOracle, QuestionID[] calldata legQuestionIds, uint256 legQuestionIdMask, uint256[] calldata legIndices ) public pure returns (QuestionID parlayQuestionId) { parlayQuestionId = QuestionID.wrap(keccak256(abi.encode(legOracle, legQuestionIds, legQuestionIdMask, legIndices))); } function getParlayConditionId(QuestionID parlayQuestionId) public pure returns (ConditionID parlayConditionId) { parlayConditionId = CTHelpers.getConditionId(address(0x0), parlayQuestionId, PARLAY_OUTCOME_SLOT_COUNT); } // if statements for reverts are being counted against cyclomatic complexity // solhint-disable-next-line code-complexity function _checkParlayPreconditions(address legOracle, uint256 legQuestionIdMask, ParlayLegs calldata legs) private view returns (ConditionID[] memory legConditionIds) { { bool invalidLengths = legs.questionIds.length != legs.indices.length || legs.questionIds.length != legs.outcomeSlotCounts.length || legs.questionIds.length < 1; if (invalidLengths) revert InvalidParlayArraySizes(); } { // Delaying the interface check until here, because of // chicken-and-egg issue with deploying new conditional tokens. Old // conditional tokens did not have a `supportsInterface` method, so // need to be upgraded to the latest version. However, upgrading the // proxy is an admin action, and deployment is permissionless. So // have to delay the check until after construction bool supportsInterfaces = address(legConditionalTokens).supportsInterface( CONDITIONAL_TOKENS_INTERFACE_V1_2_ID ) && address(legConditionalTokens).supportsInterface(LEG_CONDITIONAL_TOKENS_INTERFACE_ID); if (!supportsInterfaces) revert InvalidConditionalTokensAddress(address(legConditionalTokens)); } if (legs.questionIds.length > MAX_LEGS_IN_PARLAY) revert TooManyConditionsInParlay(); if (legQuestionIdMask == 0x0) revert InvalidQuestionIdMask(); // Validate canonical ordering, and that underlying conditions exist uint256 prevMaskedId = 0x0; legConditionIds = new ConditionID[](legs.questionIds.length); for (uint256 i = 0; i < legs.questionIds.length; i++) { uint256 outcomeSlotCount = legs.outcomeSlotCounts[i]; // Assume last outcome slot is used for refunds, anything including // it or beyond is invalid if (legs.indices[i] >= outcomeSlotCount - 1) revert InvalidIndex(); // Leg ordering is only done with repsect to a bitmasked portion // of the questionId. That way it's possible to disallow having // parlay legs within the same "category", such as for the same // event. This requires the `questionId` to be of a standard // form where particular bytes of the id correspond to an // eventId for example. QuestionID legQuestionId = legs.questionIds[i]; uint256 maskedId = uint256(QuestionID.unwrap(legQuestionId)) & legQuestionIdMask; if (maskedId <= prevMaskedId) revert ParlayInputsNotInCanonicalOrder(); prevMaskedId = maskedId; ConditionID legConditionId = CTHelpers.getConditionId(legOracle, legQuestionId, outcomeSlotCount); if (legConditionalTokens.getOutcomeSlotCount(legConditionId) != outcomeSlotCount) { revert ConditionNotFound(); } if (legConditionalTokens.isResolved(legConditionId)) revert PayoutAlreadyReported(); legConditionIds[i] = legConditionId; } } /// @inheritdoc IParlayConditionalTokens function prepareParlayCondition(address legOracle, uint256 legQuestionIdMask, ParlayLegs calldata legs) external returns (QuestionID parlayQuestionId, ConditionID parlayConditionId) { // Synthetic QuestionID from the parlay legs. parlayQuestionId = getParlayQuestionId(legOracle, legs.questionIds, legQuestionIdMask, legs.indices); parlayConditionId = _prepareCondition(address(0x0), parlayQuestionId, PARLAY_OUTCOME_SLOT_COUNT); // Perform checks and event emit only if not already created if (legInfo[parlayConditionId].legConditionIds.length == 0) { ConditionID[] memory legConditionIds = _checkParlayPreconditions(legOracle, legQuestionIdMask, legs); legInfo[parlayConditionId] = LegInfo(legConditionIds, CTHelpers.encodeIndices(legs.indices)); emit ParlayConditionLegs(parlayConditionId, parlayQuestionId, legOracle, legQuestionIdMask, legs); } } /// @inheritdoc IParlayConditionalTokens function reportParlayPayouts(QuestionID parlayQuestionId) public { ConditionID parlayConditionId = getParlayConditionId(parlayQuestionId); if (payoutNumerators[parlayConditionId].length != PARLAY_OUTCOME_SLOT_COUNT) revert ConditionNotFound(); if (isResolved(parlayConditionId)) return; ConditionID[] storage legConditionIds = legInfo[parlayConditionId].legConditionIds; (uint256[] memory numerators, uint256 denominator) = ILegConditionalTokens(address(legConditionalTokens)) .getParlayPayouts(legConditionIds, legInfo[parlayConditionId].indices); _reportPayouts(address(0x0), parlayQuestionId, numerators, denominator); } /// @inheritdoc IParlayConditionalTokens function batchReportParlayPayouts(QuestionID[] calldata parlayQuestionIds) external { for (uint256 i = 0; i < parlayQuestionIds.length; i++) { reportParlayPayouts(parlayQuestionIds[i]); } } function getFairPrices(ConditionID parlayConditionId) public view returns (uint256[] memory fairPriceDecimals) { ConditionID[] storage legConditionIds = legInfo[parlayConditionId].legConditionIds; return ILegConditionalTokens(address(legConditionalTokens)).getParlayFairPrices( legConditionIds, legInfo[parlayConditionId].indices ); } function isHalted(ConditionID parlayConditionId) external view returns (bool halted) { ConditionID[] memory legConditionIds = legInfo[parlayConditionId].legConditionIds; for (uint256 i = 0; i < legConditionIds.length && !halted; i++) { halted = legConditionalTokens.isHalted(legConditionIds[i]); } } function getPositionInfo(address account, IERC20 collateralToken, ConditionID conditionId) external view returns (uint256[] memory balances, uint256[] memory fairPriceDecimals) { balances = balanceOfCondition(account, collateralToken, conditionId); fairPriceDecimals = getFairPrices(conditionId); } function haltTime(ConditionID parlayConditionId) external view returns (uint32) { return uint32( ILegConditionalTokens(address(legConditionalTokens)).minHaltTime(legInfo[parlayConditionId].legConditionIds) ); } function getPayouts(ConditionID conditionId) external view returns (uint256[] memory numerators, uint256 denominator) { numerators = payoutNumerators[conditionId]; denominator = payoutDenominator[conditionId]; } function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165Upgradeable, ERC1155Upgradeable) returns (bool) { return interfaceId == type(IConditionalTokens).interfaceId || interfaceId == type(IConditionalTokensV1_2).interfaceId || interfaceId == type(IParlayConditionalTokens).interfaceId || ERC1155Upgradeable.supportsInterface(interfaceId); } // ---------------------- // The following functions do not make sense for parlay conditions function reportPayouts(QuestionID questionId, uint256[] calldata payouts) external { uint256 outcomeSlotCount = payouts.length; uint256[] memory numerators = new uint256[](outcomeSlotCount); uint256 den = 0; for (uint256 i = 0; i < outcomeSlotCount; i++) { uint256 num = payouts[i]; den = den + num; numerators[i] = num; } // for parlays of max legs to work, payout denominator cannot be too large if (den > PackedPrices.DIVISOR) revert InvalidPayoutArray(); _reportPayouts(address(0x0), questionId, numerators, den); } function batchReportPayouts(QuestionID[] calldata, uint256[] calldata, uint256[] calldata) external pure { revert OperationNotSupportedWithoutLegInformation(); } function prepareCondition(address, QuestionID, uint256) external pure returns (ConditionID) { revert OperationNotSupportedWithoutLegInformation(); } function prepareConditionByOracle(QuestionID, uint256, bytes calldata, uint32) external pure returns (ConditionID) { revert OperationNotSupportedForParlayConditions(); } function updateFairPrices(ConditionID, bytes calldata) external pure { revert OperationNotSupportedForParlayConditions(); } function batchUpdateFairPrices(PriceUpdate[] calldata) external pure { revert OperationNotSupportedForParlayConditions(); } function getPriceOracle(ConditionID) external pure returns (address) { revert OperationNotSupportedForParlayConditions(); } function updateHaltTime(ConditionID, uint32) external pure { revert OperationNotSupportedForParlayConditions(); } function batchUpdateHaltTimes(HaltUpdate[] calldata) external pure { revert OperationNotSupportedForParlayConditions(); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.2) (utils/introspection/ERC165Checker.sol) pragma solidity ^0.8.0; import "./IERC165.sol"; /** * @dev Library used to query support of an interface declared via {IERC165}. * * Note that these functions return the actual result of the query: they do not * `revert` if an interface is not supported. It is up to the caller to decide * what to do in these cases. */ library ERC165Checker { // As per the EIP-165 spec, no interface should ever match 0xffffffff bytes4 private constant _INTERFACE_ID_INVALID = 0xffffffff; /** * @dev Returns true if `account` supports the {IERC165} interface. */ function supportsERC165(address account) internal view returns (bool) { // Any contract that implements ERC165 must explicitly indicate support of // InterfaceId_ERC165 and explicitly indicate non-support of InterfaceId_Invalid return supportsERC165InterfaceUnchecked(account, type(IERC165).interfaceId) && !supportsERC165InterfaceUnchecked(account, _INTERFACE_ID_INVALID); } /** * @dev Returns true if `account` supports the interface defined by * `interfaceId`. Support for {IERC165} itself is queried automatically. * * See {IERC165-supportsInterface}. */ function supportsInterface(address account, bytes4 interfaceId) internal view returns (bool) { // query support of both ERC165 as per the spec and support of _interfaceId return supportsERC165(account) && supportsERC165InterfaceUnchecked(account, interfaceId); } /** * @dev Returns a boolean array where each value corresponds to the * interfaces passed in and whether they're supported or not. This allows * you to batch check interfaces for a contract where your expectation * is that some interfaces may not be supported. * * See {IERC165-supportsInterface}. * * _Available since v3.4._ */ function getSupportedInterfaces(address account, bytes4[] memory interfaceIds) internal view returns (bool[] memory) { // an array of booleans corresponding to interfaceIds and whether they're supported or not bool[] memory interfaceIdsSupported = new bool[](interfaceIds.length); // query support of ERC165 itself if (supportsERC165(account)) { // query support of each interface in interfaceIds for (uint256 i = 0; i < interfaceIds.length; i++) { interfaceIdsSupported[i] = supportsERC165InterfaceUnchecked(account, interfaceIds[i]); } } return interfaceIdsSupported; } /** * @dev Returns true if `account` supports all the interfaces defined in * `interfaceIds`. Support for {IERC165} itself is queried automatically. * * Batch-querying can lead to gas savings by skipping repeated checks for * {IERC165} support. * * See {IERC165-supportsInterface}. */ function supportsAllInterfaces(address account, bytes4[] memory interfaceIds) internal view returns (bool) { // query support of ERC165 itself if (!supportsERC165(account)) { return false; } // query support of each interface in interfaceIds for (uint256 i = 0; i < interfaceIds.length; i++) { if (!supportsERC165InterfaceUnchecked(account, interfaceIds[i])) { return false; } } // all interfaces supported return true; } /** * @notice Query if a contract implements an interface, does not check ERC165 support * @param account The address of the contract to query for support of an interface * @param interfaceId The interface identifier, as specified in ERC-165 * @return true if the contract at account indicates support of the interface with * identifier interfaceId, false otherwise * @dev Assumes that account contains a contract that supports ERC165, otherwise * the behavior of this method is undefined. This precondition can be checked * with {supportsERC165}. * * Some precompiled contracts will falsely indicate support for a given interface, so caution * should be exercised when using this function. * * Interface identification is specified in ERC-165. */ function supportsERC165InterfaceUnchecked(address account, bytes4 interfaceId) internal view returns (bool) { // prepare call bytes memory encodedParams = abi.encodeWithSelector(IERC165.supportsInterface.selector, interfaceId); // perform static call bool success; uint256 returnSize; uint256 returnValue; assembly { success := staticcall(30000, account, add(encodedParams, 0x20), mload(encodedParams), 0x00, 0x20) returnSize := returndatasize() returnValue := mload(0x00) } return success && returnSize >= 0x20 && returnValue > 0; } }
// 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 IERC165Upgradeable { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (token/ERC1155/ERC1155.sol) pragma solidity ^0.8.0; import "./IERC1155Upgradeable.sol"; import "./IERC1155ReceiverUpgradeable.sol"; import "./extensions/IERC1155MetadataURIUpgradeable.sol"; import "../../utils/AddressUpgradeable.sol"; import "../../utils/ContextUpgradeable.sol"; import "../../utils/introspection/ERC165Upgradeable.sol"; import "../../proxy/utils/Initializable.sol"; /** * @dev Implementation of the basic standard multi-token. * See https://eips.ethereum.org/EIPS/eip-1155 * Originally based on code by Enjin: https://github.com/enjin/erc-1155 * * _Available since v3.1._ */ contract ERC1155Upgradeable is Initializable, ContextUpgradeable, ERC165Upgradeable, IERC1155Upgradeable, IERC1155MetadataURIUpgradeable { using AddressUpgradeable for address; // Mapping from token ID to account balances mapping(uint256 => mapping(address => uint256)) private _balances; // Mapping from account to operator approvals mapping(address => mapping(address => bool)) private _operatorApprovals; // Used as the URI for all token types by relying on ID substitution, e.g. https://token-cdn-domain/{id}.json string private _uri; /** * @dev See {_setURI}. */ function __ERC1155_init(string memory uri_) internal onlyInitializing { __ERC1155_init_unchained(uri_); } function __ERC1155_init_unchained(string memory uri_) internal onlyInitializing { _setURI(uri_); } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165Upgradeable, IERC165Upgradeable) returns (bool) { return interfaceId == type(IERC1155Upgradeable).interfaceId || interfaceId == type(IERC1155MetadataURIUpgradeable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC1155MetadataURI-uri}. * * This implementation returns the same URI for *all* token types. It relies * on the token type ID substitution mechanism * https://eips.ethereum.org/EIPS/eip-1155#metadata[defined in the EIP]. * * Clients calling this function must replace the `\{id\}` substring with the * actual token type ID. */ function uri(uint256) public view virtual override returns (string memory) { return _uri; } /** * @dev See {IERC1155-balanceOf}. * * Requirements: * * - `account` cannot be the zero address. */ function balanceOf(address account, uint256 id) public view virtual override returns (uint256) { require(account != address(0), "ERC1155: address zero is not a valid owner"); return _balances[id][account]; } /** * @dev See {IERC1155-balanceOfBatch}. * * Requirements: * * - `accounts` and `ids` must have the same length. */ function balanceOfBatch(address[] memory accounts, uint256[] memory ids) public view virtual override returns (uint256[] memory) { require(accounts.length == ids.length, "ERC1155: accounts and ids length mismatch"); uint256[] memory batchBalances = new uint256[](accounts.length); for (uint256 i = 0; i < accounts.length; ++i) { batchBalances[i] = balanceOf(accounts[i], ids[i]); } return batchBalances; } /** * @dev See {IERC1155-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual override { _setApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC1155-isApprovedForAll}. */ function isApprovedForAll(address account, address operator) public view virtual override returns (bool) { return _operatorApprovals[account][operator]; } /** * @dev See {IERC1155-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 id, uint256 amount, bytes memory data ) public virtual override { require( from == _msgSender() || isApprovedForAll(from, _msgSender()), "ERC1155: caller is not token owner or approved" ); _safeTransferFrom(from, to, id, amount, data); } /** * @dev See {IERC1155-safeBatchTransferFrom}. */ function safeBatchTransferFrom( address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) public virtual override { require( from == _msgSender() || isApprovedForAll(from, _msgSender()), "ERC1155: caller is not token owner or approved" ); _safeBatchTransferFrom(from, to, ids, amounts, data); } /** * @dev Transfers `amount` tokens of token type `id` from `from` to `to`. * * Emits a {TransferSingle} event. * * Requirements: * * - `to` cannot be the zero address. * - `from` must have a balance of tokens of type `id` of at least `amount`. * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the * acceptance magic value. */ function _safeTransferFrom( address from, address to, uint256 id, uint256 amount, bytes memory data ) internal virtual { require(to != address(0), "ERC1155: transfer to the zero address"); address operator = _msgSender(); uint256[] memory ids = _asSingletonArray(id); uint256[] memory amounts = _asSingletonArray(amount); _beforeTokenTransfer(operator, from, to, ids, amounts, data); uint256 fromBalance = _balances[id][from]; require(fromBalance >= amount, "ERC1155: insufficient balance for transfer"); unchecked { _balances[id][from] = fromBalance - amount; } _balances[id][to] += amount; emit TransferSingle(operator, from, to, id, amount); _afterTokenTransfer(operator, from, to, ids, amounts, data); _doSafeTransferAcceptanceCheck(operator, from, to, id, amount, data); } /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_safeTransferFrom}. * * Emits a {TransferBatch} event. * * Requirements: * * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the * acceptance magic value. */ function _safeBatchTransferFrom( address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) internal virtual { require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch"); require(to != address(0), "ERC1155: transfer to the zero address"); address operator = _msgSender(); _beforeTokenTransfer(operator, from, to, ids, amounts, data); for (uint256 i = 0; i < ids.length; ++i) { uint256 id = ids[i]; uint256 amount = amounts[i]; uint256 fromBalance = _balances[id][from]; require(fromBalance >= amount, "ERC1155: insufficient balance for transfer"); unchecked { _balances[id][from] = fromBalance - amount; } _balances[id][to] += amount; } emit TransferBatch(operator, from, to, ids, amounts); _afterTokenTransfer(operator, from, to, ids, amounts, data); _doSafeBatchTransferAcceptanceCheck(operator, from, to, ids, amounts, data); } /** * @dev Sets a new URI for all token types, by relying on the token type ID * substitution mechanism * https://eips.ethereum.org/EIPS/eip-1155#metadata[defined in the EIP]. * * By this mechanism, any occurrence of the `\{id\}` substring in either the * URI or any of the amounts in the JSON file at said URI will be replaced by * clients with the token type ID. * * For example, the `https://token-cdn-domain/\{id\}.json` URI would be * interpreted by clients as * `https://token-cdn-domain/000000000000000000000000000000000000000000000000000000000004cce0.json` * for token type ID 0x4cce0. * * See {uri}. * * Because these URIs cannot be meaningfully represented by the {URI} event, * this function emits no events. */ function _setURI(string memory newuri) internal virtual { _uri = newuri; } /** * @dev Creates `amount` tokens of token type `id`, and assigns them to `to`. * * Emits a {TransferSingle} event. * * Requirements: * * - `to` cannot be the zero address. * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the * acceptance magic value. */ function _mint( address to, uint256 id, uint256 amount, bytes memory data ) internal virtual { require(to != address(0), "ERC1155: mint to the zero address"); address operator = _msgSender(); uint256[] memory ids = _asSingletonArray(id); uint256[] memory amounts = _asSingletonArray(amount); _beforeTokenTransfer(operator, address(0), to, ids, amounts, data); _balances[id][to] += amount; emit TransferSingle(operator, address(0), to, id, amount); _afterTokenTransfer(operator, address(0), to, ids, amounts, data); _doSafeTransferAcceptanceCheck(operator, address(0), to, id, amount, data); } /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_mint}. * * Emits a {TransferBatch} event. * * Requirements: * * - `ids` and `amounts` must have the same length. * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the * acceptance magic value. */ function _mintBatch( address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) internal virtual { require(to != address(0), "ERC1155: mint to the zero address"); require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch"); address operator = _msgSender(); _beforeTokenTransfer(operator, address(0), to, ids, amounts, data); for (uint256 i = 0; i < ids.length; i++) { _balances[ids[i]][to] += amounts[i]; } emit TransferBatch(operator, address(0), to, ids, amounts); _afterTokenTransfer(operator, address(0), to, ids, amounts, data); _doSafeBatchTransferAcceptanceCheck(operator, address(0), to, ids, amounts, data); } /** * @dev Destroys `amount` tokens of token type `id` from `from` * * Emits a {TransferSingle} event. * * Requirements: * * - `from` cannot be the zero address. * - `from` must have at least `amount` tokens of token type `id`. */ function _burn( address from, uint256 id, uint256 amount ) internal virtual { require(from != address(0), "ERC1155: burn from the zero address"); address operator = _msgSender(); uint256[] memory ids = _asSingletonArray(id); uint256[] memory amounts = _asSingletonArray(amount); _beforeTokenTransfer(operator, from, address(0), ids, amounts, ""); uint256 fromBalance = _balances[id][from]; require(fromBalance >= amount, "ERC1155: burn amount exceeds balance"); unchecked { _balances[id][from] = fromBalance - amount; } emit TransferSingle(operator, from, address(0), id, amount); _afterTokenTransfer(operator, from, address(0), ids, amounts, ""); } /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_burn}. * * Emits a {TransferBatch} event. * * Requirements: * * - `ids` and `amounts` must have the same length. */ function _burnBatch( address from, uint256[] memory ids, uint256[] memory amounts ) internal virtual { require(from != address(0), "ERC1155: burn from the zero address"); require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch"); address operator = _msgSender(); _beforeTokenTransfer(operator, from, address(0), ids, amounts, ""); for (uint256 i = 0; i < ids.length; i++) { uint256 id = ids[i]; uint256 amount = amounts[i]; uint256 fromBalance = _balances[id][from]; require(fromBalance >= amount, "ERC1155: burn amount exceeds balance"); unchecked { _balances[id][from] = fromBalance - amount; } } emit TransferBatch(operator, from, address(0), ids, amounts); _afterTokenTransfer(operator, from, address(0), ids, amounts, ""); } /** * @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, "ERC1155: setting approval status for self"); _operatorApprovals[owner][operator] = approved; emit ApprovalForAll(owner, operator, approved); } /** * @dev Hook that is called before any token transfer. This includes minting * and burning, as well as batched variants. * * The same hook is called on both single and batched variants. For single * transfers, the length of the `ids` and `amounts` arrays will be 1. * * Calling conditions (for each `id` and `amount` pair): * * - When `from` and `to` are both non-zero, `amount` of ``from``'s tokens * of token type `id` will be transferred to `to`. * - When `from` is zero, `amount` tokens of token type `id` will be minted * for `to`. * - when `to` is zero, `amount` of ``from``'s tokens of token type `id` * will be burned. * - `from` and `to` are never both zero. * - `ids` and `amounts` have the same, non-zero length. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address operator, address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) internal virtual {} /** * @dev Hook that is called after any token transfer. This includes minting * and burning, as well as batched variants. * * The same hook is called on both single and batched variants. For single * transfers, the length of the `id` and `amount` arrays will be 1. * * Calling conditions (for each `id` and `amount` pair): * * - When `from` and `to` are both non-zero, `amount` of ``from``'s tokens * of token type `id` will be transferred to `to`. * - When `from` is zero, `amount` tokens of token type `id` will be minted * for `to`. * - when `to` is zero, `amount` of ``from``'s tokens of token type `id` * will be burned. * - `from` and `to` are never both zero. * - `ids` and `amounts` have the same, non-zero length. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _afterTokenTransfer( address operator, address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) internal virtual {} function _doSafeTransferAcceptanceCheck( address operator, address from, address to, uint256 id, uint256 amount, bytes memory data ) private { if (to.isContract()) { try IERC1155ReceiverUpgradeable(to).onERC1155Received(operator, from, id, amount, data) returns (bytes4 response) { if (response != IERC1155ReceiverUpgradeable.onERC1155Received.selector) { revert("ERC1155: ERC1155Receiver rejected tokens"); } } catch Error(string memory reason) { revert(reason); } catch { revert("ERC1155: transfer to non-ERC1155Receiver implementer"); } } } function _doSafeBatchTransferAcceptanceCheck( address operator, address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) private { if (to.isContract()) { try IERC1155ReceiverUpgradeable(to).onERC1155BatchReceived(operator, from, ids, amounts, data) returns ( bytes4 response ) { if (response != IERC1155ReceiverUpgradeable.onERC1155BatchReceived.selector) { revert("ERC1155: ERC1155Receiver rejected tokens"); } } catch Error(string memory reason) { revert(reason); } catch { revert("ERC1155: transfer to non-ERC1155Receiver implementer"); } } } function _asSingletonArray(uint256 element) private pure returns (uint256[] memory) { uint256[] memory array = new uint256[](1); array[0] = element; return array; } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[47] private __gap; }
// 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 pragma solidity ^0.8.19; import { IConditionalTokensEvents, IConditionalTokens, IERC20, ConditionalTokensErrors } from "./IConditionalTokens.sol"; import { PackedPrices } from "../PackedPrices.sol"; import { ConditionID, QuestionID, CTHelpers } from "./CTHelpers.sol"; interface IConditionalTokensEventsV1_2 is IConditionalTokensEvents { /// @dev Event emitted only when a condition is prepared to save on gas costs /// @param conditionId which condition had its price set /// @param packedPrices the encoded prices in a byte array event ConditionPricesUpdated(ConditionID indexed conditionId, bytes packedPrices); /// @dev Halt time for a condition has been updated event HaltTimeUpdated(ConditionID indexed conditionId, uint32 haltTime); } interface IConditionalTokensV1_2 is IConditionalTokens, IConditionalTokensEventsV1_2 { struct PriceUpdate { ConditionID conditionId; bytes packedPrices; } struct HaltUpdate { ConditionID conditionId; /// @dev haltTime as seconds since epoch, same as block.timestamp /// unsigned 32bit epoch timestamp in seconds should be suitable until year 2106 uint32 haltTime; } function prepareConditionByOracle( QuestionID questionId, uint256 outcomeSlotCount, bytes calldata packedPrices, uint32 haltTime_ ) external returns (ConditionID); function updateFairPrices(ConditionID conditionId, bytes calldata packedPrices) external; function batchUpdateFairPrices(PriceUpdate[] calldata priceUpdates) external; function getFairPrices(ConditionID conditionId) external view returns (uint256[] memory fairPriceDecimals); function updateHaltTime(ConditionID conditionId, uint32 haltTime) external; function batchUpdateHaltTimes(HaltUpdate[] calldata haltUpdates) external; /// @dev Returns the halt time of a condition. Will be 0 if no price oracle /// is configured (if old prepareCondition was called). function haltTime(ConditionID conditionId) external view returns (uint32); /// @dev Returns if the condition is halted or already resolved. Halting /// only effects price updates. If no price oracle was configured for a /// condition, this will always return true. This is ok since it does not /// affect any other aspect. function isHalted(ConditionID conditionId) external view returns (bool); /// @dev combines together balanceOfCondition and getFairPrices into one call to minimize gas usage function getPositionInfo(address account, IERC20 collateralToken, ConditionID conditionId) external view returns (uint256[] memory balances, uint256[] memory fairPriceDecimals); /// @dev Get the current payouts for a condition. function getPayouts(ConditionID conditionId) external view returns (uint256[] memory numerators, uint256 denominator); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.19; import { OwnableUpgradeable } from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; import { UUPSUpgradeable } from "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol"; import { ERC1155Upgradeable } from "@openzeppelin/contracts-upgradeable/token/ERC1155/ERC1155Upgradeable.sol"; import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import { IConditionalTokens } from "./IConditionalTokensV1_2.sol"; import { ConditionID, QuestionID, CollectionID, CTHelpers } from "./CTHelpers.sol"; import { ArrayMath } from "../Math.sol"; contract ConditionalTokensStorage { struct PriceStorage { /// @dev saving the condition oracle so it's cheaper to get the oracle /// than recompute it using keccak every time from questionId address conditionOracle; // offset 0, length 20 bytes uint32 haltTime; // offset 20, length 4 bytes // 8 bytes of padding available bytes packedPrices; // offset 32 } /// @dev payoutNumerators and payoutDenominator represent the payout vector associated a condition. PayoutNumberator /// is initialized with a length equal to the outcomeSlotCount when the condition is prepared. /// /// E.g: /// condition with 3 outcomes [A, B, C], two of those are correct: A & B /// payout vector = [0.5, 0.5, 0] /// This is represented as: /// payoutNumerators = [1,1,0] & payoutDenominator = 2 /// /// PayoutNumerators are also used as a check of initialization. If the numerators array is empty (has length zero), /// the condition was not created/prepared. /// /// PayoutDenominator is also used for checking if the condition has been resolved. If the denominator is non-zero, /// then the condition has been resolved. mapping(ConditionID => uint256[]) public payoutNumerators; mapping(ConditionID => uint256) public payoutDenominator; mapping(address => bool) public erc20Whitelist; mapping(ConditionID => PriceStorage) public priceStorage; // NOTE: for fee refunds. // Potential fee solution - store `mapping(UserPositionID => UserPositionInfo)`, that has fee data. // When doing a push, can refund the fees stored in UserPositionInfo, otherwise just ignore // Will also need `mapping(TokenConditionID => uint256)` to store total fees gathered for condition + token uint256[48] private __gap; } /// @dev Basic conditional tokens functionality abstract contract ConditionalTokensBase is UUPSUpgradeable, IConditionalTokens, ERC1155Upgradeable, OwnableUpgradeable, ConditionalTokensStorage { using SafeERC20 for IERC20; using ArrayMath for uint256[]; /// @dev 3 outcomes, because last one is a refund uint256 internal constant PARLAY_OUTCOME_SLOT_COUNT = 3; // solhint-disable-next-line func-name-mixedcase function __ConditionalTokensBase_init() internal onlyInitializing { __ERC1155_init(""); __Ownable_init(); __UUPSUpgradeable_init(); __ConditionalTokensBase_init_unchained(); } // solhint-disable-next-line func-name-mixedcase no-empty-blocks function __ConditionalTokensBase_init_unchained() internal onlyInitializing { } function setERC20Whitelist(IERC20 token, bool approved) external onlyOwner { erc20Whitelist[address(token)] = approved; } function _prepareCondition(address conditionOracle, QuestionID questionId, uint256 outcomeSlotCount) internal returns (ConditionID) { // Limit of 256 because we use a partition array that is a number of 256 bits. if (outcomeSlotCount < 2 || outcomeSlotCount > 255) revert InvalidOutcomeSlotsAmount(); ConditionID conditionId = CTHelpers.getConditionId(conditionOracle, questionId, outcomeSlotCount); // If not prepared, initialize, and emit the event, otherwise just return existing conditionId if (payoutNumerators[conditionId].length == 0) { payoutNumerators[conditionId] = new uint256[](outcomeSlotCount); priceStorage[conditionId].conditionOracle = conditionOracle; // Start condition as unhalted. Otherwise not possible to change halt time priceStorage[conditionId].haltTime = type(uint32).max; emit ConditionPreparation(conditionId, conditionOracle, questionId, outcomeSlotCount); } return conditionId; } /// @dev Internal way for a Conditional Tokens contract to report payouts for a question. /// @param numerators The numerators for the payout ratio for each outcome /// @param denominator The sum of all the numerators function _reportPayouts(address oracle, QuestionID questionId, uint256[] memory numerators, uint256 denominator) internal { uint256 outcomeSlotCount = numerators.length; if (outcomeSlotCount <= 1 || outcomeSlotCount > 255) revert InvalidOutcomeSlotsAmount(); ConditionID conditionId = CTHelpers.getConditionId(oracle, questionId, outcomeSlotCount); if (payoutNumerators[conditionId].length != outcomeSlotCount) revert ConditionNotFound(); if (denominator == 0) revert PayoutsAreAllZero(); // If already reported, silently ignore to ease batch operations and idempotency if (isResolved(conditionId)) return; payoutNumerators[conditionId] = numerators; payoutDenominator[conditionId] = denominator; emit ConditionResolution(conditionId, oracle, questionId, outcomeSlotCount, numerators); } function isResolved(ConditionID conditionId) public view returns (bool) { return payoutDenominator[conditionId] != 0; } /// @notice Deposits an amount of collateral (ERC20) into this contract and mints to the sender the same amount of /// conditional tokens (ERC1155) for each of the outcomes in the specified condition ID. /// @dev When splitting from the collateral, the function will attempt to transfer `amount` collateral from the /// message sender to itself. Regardless, if successful, `amount` stake will be minted in the split target /// positions. If any of the transfers, mints, or burns fail, the transaction will revert. The transaction will also /// revert if the given partition is trivial, invalid, or refers to more slots than the condition is prepared with. /// @param collateralToken The address of the positions' backing collateral token. /// @param conditionId The ID of the condition to split on. /// @param amount The amount of collateral or stake to split. function splitPosition(IERC20 collateralToken, ConditionID conditionId, uint256 amount) external { if (amount == 0) revert InvalidAmount(); // - Only validate erc20 whitelist here, as it's the only way to create conditional tokens. // All other operations are only possible after splitting. // - In the case where a token that was already whitelisted becomes // blacklisted, we only prevent any further creation of conditional // tokens, but allow existing positions to wind down to prevent trapping // the collateral inside the ConditionalTokens contract if (!erc20Whitelist[address(collateralToken)]) revert InvalidERC20(); uint256 outcomeSlotCount = payoutNumerators[conditionId].length; if (outcomeSlotCount == 0) revert ConditionNotFound(); uint256[] memory positionIds = new uint256[](outcomeSlotCount); uint256[] memory amounts = new uint256[](outcomeSlotCount); for (uint256 i = 0; i < outcomeSlotCount; i++) { positionIds[i] = CTHelpers.getPositionId(collateralToken, CTHelpers.getCollectionId(conditionId, i)); amounts[i] = amount; } collateralToken.safeTransferFrom(_msgSender(), address(this), amount); _mintBatch( _msgSender(), // position ID is the ERC 1155 token ID positionIds, amounts, "" ); emit PositionSplit(_msgSender(), collateralToken, conditionId, amount); } /// @notice Burns the specified amount of conditional tokens (ERC1155) for all the positions and returns to the /// sender that amount of collateral (ERC20). /// @param collateralToken The address of the positions' backing collateral token. /// @param conditionId The ID of the condition to split on. /// @param amount The quantity of conditional tokens to merge. function mergePositions(IERC20 collateralToken, ConditionID conditionId, uint256 amount) external { if (amount == 0) revert InvalidAmount(); uint256 outcomeSlotCount = payoutNumerators[conditionId].length; if (outcomeSlotCount == 0) revert ConditionNotFound(); uint256[] memory positionIds = new uint256[](outcomeSlotCount); uint256[] memory amounts = new uint256[](outcomeSlotCount); for (uint256 i = 0; i < outcomeSlotCount; i++) { positionIds[i] = CTHelpers.getPositionId(collateralToken, CTHelpers.getCollectionId(conditionId, i)); amounts[i] = amount; } _burnBatch(_msgSender(), positionIds, amounts); collateralToken.safeTransfer(_msgSender(), amount); emit PositionsMerge(_msgSender(), collateralToken, conditionId, amount); } /// @notice Redeems the collateral corresponding to a particular outcome of a condition /// @param owner The owner account of the conditional tokens /// @param conditionId The ID of the condition /// @param index Outcome index to redeem /// @param burnAmount Amount of conditional tokens to burn /// @return totalPayout The amount of collateral that should be transferred back function _redeemPosition( address owner, uint256 positionId, ConditionID conditionId, uint256 index, uint256 burnAmount ) internal returns (uint256 totalPayout) { uint256 denominator = payoutDenominator[conditionId]; if (denominator == 0) revert ResultNotReceivedYet(); uint256 outcomeSlotCount = payoutNumerators[conditionId].length; assert(outcomeSlotCount != 0); if (index >= outcomeSlotCount) revert InvalidIndex(); uint256 payoutNumerator = payoutNumerators[conditionId][index]; if (burnAmount > 0) { totalPayout = (burnAmount * payoutNumerator) / denominator; _burn(owner, positionId, burnAmount); } } /// @notice Redeem conditional tokens into collateral based on their /// reported payout value. Redeems the sender's tokens and gives the /// proceeds to receiver. /// @param receiver The address that will receive all the proceeds of the redemption. /// @param collateralToken The address of the positions' backing collateral token. /// @param conditionId The ID of the condition to split on. /// @param indices Outcome indices to redeem. /// @param quantities Quantity of conditional tokens for each index to be burned. function redeemPositionsFor( address receiver, IERC20 collateralToken, ConditionID conditionId, uint256[] calldata indices, uint256[] calldata quantities ) public returns (uint256 totalPayout) { if (indices.length != quantities.length) revert InvalidQuantities(); address redeemer = _msgSender(); totalPayout = 0; for (uint256 i = 0; i < indices.length; i++) { uint256 positionId = CTHelpers.getPositionId(collateralToken, CTHelpers.getCollectionId(conditionId, indices[i])); totalPayout += _redeemPosition(redeemer, positionId, conditionId, indices[i], quantities[i]); } // Doing the emit here before the transfer to mirror the ordering done in redeemAll. // There, all the PayoutRedemption emits are done one-by-one, follow by one large safeTransfer. emit PayoutRedemptionFor(receiver, redeemer, collateralToken, conditionId, indices, quantities, totalPayout); if (totalPayout > 0) { collateralToken.safeTransfer(receiver, totalPayout); } } /// @notice Redeem multiple conditions and outcomes in one call for the sender /// @param collateralToken The address of the collateral token used to enter the positions /// @param conditionIds an array of ConditionIDs to redeem /// @param indices an array of outcome indices to redeem from the corresponding entry in the conditionIds array function redeemAll(IERC20 collateralToken, ConditionID[] calldata conditionIds, uint256[] calldata indices) external { redeemAllOf(_msgSender(), collateralToken, conditionIds, indices); } /// @notice Redeem multiple conditions and outcomes in one call on behalf of an owner /// @param ownerAndReceiver The account of the owner of conditional tokens /// @param collateralToken The address of the collateral token used to enter the positions /// @param conditionIds an array of ConditionIDs to redeem /// @param indices an array of outcome indices to redeem from the corresponding entry in the conditionIds array function redeemAllOf( address ownerAndReceiver, IERC20 collateralToken, ConditionID[] calldata conditionIds, uint256[] calldata indices ) public returns (uint256 totalPayout) { if (conditionIds.length != indices.length) revert InvalidIndex(); uint256 totalBurnt = 0; uint256[] memory eventIndices = new uint256[](1); for (uint256 i = 0; i < conditionIds.length; i++) { ConditionID conditionId = conditionIds[i]; uint256 index = indices[i]; uint256 positionId = CTHelpers.getPositionId(collateralToken, CTHelpers.getCollectionId(conditionId, index)); uint256 burnAmount = balanceOf(ownerAndReceiver, positionId); totalBurnt += burnAmount; uint256 payout = _redeemPosition(ownerAndReceiver, positionId, conditionId, index, burnAmount); totalPayout += payout; eventIndices[0] = index; emit PayoutRedemption(ownerAndReceiver, collateralToken, conditionId, eventIndices, payout); } if (totalBurnt == 0) { revert NoPositionsToRedeem(); } if (totalPayout > 0) { collateralToken.safeTransfer(ownerAndReceiver, totalPayout); } } /// @notice Returns the balance array of conditional tokens (ERC1155) of an account for a particular condition ID. /// @param account account address to query for balances. /// @param collateralToken collateral token associated with the position ID. /// @param conditionId condition ID to query for. function balanceOfCondition(address account, IERC20 collateralToken, ConditionID conditionId) public view returns (uint256[] memory) { uint256 outcomeSlotCount = payoutNumerators[conditionId].length; if (outcomeSlotCount == 0) revert ConditionNotFound(); uint256[] memory batchBalances = new uint256[](outcomeSlotCount); for (uint256 i = 0; i < outcomeSlotCount; ++i) { uint256 positionId = CTHelpers.getPositionId(collateralToken, CTHelpers.getCollectionId(conditionId, i)); batchBalances[i] = balanceOf(account, positionId); } return batchBalances; } /// @dev Gets the number of outcome slots for a condition ID. /// @param conditionId ID of the condition. /// @return outcomeSlotCount Number of outcome slots associated with a condition, or zero if condition has not been /// prepared yet. function getOutcomeSlotCount(ConditionID conditionId) public view returns (uint256 outcomeSlotCount) { outcomeSlotCount = payoutNumerators[conditionId].length; } /// @dev Constructs a condition ID from an oracle, a question ID, and the outcome slot count for the question. /// @param oracle The account assigned to report the result for the prepared condition. /// @param questionId An identifier for the question to be answered by the oracle. /// @param outcomeSlotCount The number of outcome slots for this condition. Must not exceed 256. function getConditionId(address oracle, QuestionID questionId, uint256 outcomeSlotCount) external pure returns (ConditionID) { return CTHelpers.getConditionId(oracle, questionId, outcomeSlotCount); } /// @dev Constructs an outcome collection ID /// @param conditionId Condition ID of the outcome collection /// @param index outcome index function getCollectionId(ConditionID conditionId, uint256 index) public pure returns (CollectionID) { return CTHelpers.getCollectionId(conditionId, index); } /// @dev Constructs a position ID from a collateral token and an outcome collection. These IDs are used as the /// ERC-1155 ID for this contract. /// @param collateralToken Collateral token which backs the position. /// @param collectionId ID of the outcome collection associated with this position. function getPositionId(IERC20 collateralToken, CollectionID collectionId) external pure returns (uint256) { return CTHelpers.getPositionId(collateralToken, collectionId); } /// @dev Constructs list of positionIds for a condition. These IDs are used as the ERC-1155 ID for this contract. /// @param collateralToken Collateral token which backs the position. /// @param conditionId ID of the condition function getPositionIds(IERC20 collateralToken, ConditionID conditionId) external view returns (uint256[] memory) { uint256 outcomeSlotCount = getOutcomeSlotCount(conditionId); uint256[] memory positionIds = new uint256[](outcomeSlotCount); for (uint256 i = 0; i < outcomeSlotCount; i++) { positionIds[i] = CTHelpers.getPositionId(collateralToken, getCollectionId(conditionId, i)); } return positionIds; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.19; import { ConditionID, PackedIndices } from "./CTHelpers.sol"; interface ILegConditionalTokens { /// @dev given conditions and indices within those conditions, gives the fair price for the parlay function getParlayFairPrices(ConditionID[] calldata conditionIds, PackedIndices indices) external view returns (uint256[] memory fairPriceDecimals); /// @dev given conditions and indices within those conditions, gives the payout for the parlay function getParlayPayouts(ConditionID[] calldata conditionIds, PackedIndices indices) external view returns (uint256[] memory numerators, uint256 denominator); /// @dev Get the minimum of all halt times of supplied conditions /// @return min as uint256. This is more efficient to return in the evm function minHaltTime(ConditionID[] calldata conditionIds) external view returns (uint256 min); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.19; import { ConditionID, QuestionID } from "./CTHelpers.sol"; struct ParlayLegs { /// @dev list of unique questionIds to be used as legs in the parlay QuestionID[] questionIds; /// @dev the outcome index in each leg of the parlay uint256[] indices; /// @dev number of outcomes for each questionId. Needed to reconstruct the conditionIds uint256[] outcomeSlotCounts; } interface IParlayConditionalTokensEvents { event ParlayConditionLegs( ConditionID indexed conditionId, QuestionID indexed questionId, address indexed legOracle, uint256 legQuestionIdMask, ParlayLegs legs ); } interface IParlayConditionalTokens { /// @dev Prepare a condition that is a parlay of several other conditions as legs of the parlay. /// @param legOracle the condition oracle providing resolutions for all the conditions in the parlay /// @param legQuestionIdMask When considering uniqueness and ordering, this /// bitmask will be applied to the questionId. This can be used to restrict /// parlays to only be possible across different events. /// @param legs list of all legs /// @return parlayQuestionId the synthetic questionID of the parlay /// @return parlayConditionId the conditionId of the parlay function prepareParlayCondition(address legOracle, uint256 legQuestionIdMask, ParlayLegs calldata legs) external returns (QuestionID parlayQuestionId, ConditionID parlayConditionId); /// @dev report parlay payouts for a questionId in a permissionless manner. /// The payout is deterministically decided by the payouts of the legs of the parlay. /// If not all leg conditions are resolved, will revert. /// If parlay condition is already resolved, will do nothing (idempotent) /// @param parlayQuestionId the parlay id (returned when creating the parlay condition) function reportParlayPayouts(QuestionID parlayQuestionId) external; function batchReportParlayPayouts(QuestionID[] calldata parlayQuestionIds) external; /// @dev Calculates the derived Parlay QuestionID from underlying conditional token leg conditions /// @param legOracle the oracle address used for all the underlying legs /// @param legQuestionIds all the leg questionIds /// @param legQuestionIdMask When considering uniqueness and ordering, this /// bitmask will be applied to the questionId. This can be used to restrict /// parlays to only be possible across different events. /// @param legIndices the outcome index in each leg of the parlay /// @return parlayQuestionId the derived QuestionID for the parlay function getParlayQuestionId( address legOracle, QuestionID[] calldata legQuestionIds, uint256 legQuestionIdMask, uint256[] calldata legIndices ) external pure returns (QuestionID); function getParlayConditionId(QuestionID parlayQuestionId) external pure returns (ConditionID); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.19; interface ParlayConditionalTokensErrors { error InvalidParlayArraySizes(); error ParlayInputsNotInCanonicalOrder(); error TooManyConditionsInParlay(); error InvalidQuestionIdMask(); error InvalidConditionalTokensAddress(address conditionalTokens); error OperationNotSupportedWithoutLegInformation(); error OperationNotSupportedForParlayConditions(); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.19; import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; type QuestionID is bytes32; type ConditionID is bytes32; type CollectionID is bytes32; /// @dev Stores up to 32 outcome indices in a single bytes32 value. Length /// should be stored elsewhere type PackedIndices is bytes32; library CTHelpers { /// @dev Constructs a condition ID from an oracle, a question ID, and the /// outcome slot count for the question. /// @param oracle The account assigned to report the result for the prepared condition. /// @param questionId An identifier for the question to be answered by the oracle. /// @param outcomeSlotCount The number of outcome slots which should be used /// for this condition. Must not exceed 256. function getConditionId(address oracle, QuestionID questionId, uint256 outcomeSlotCount) internal pure returns (ConditionID) { assert(outcomeSlotCount < 257); // `<` uses less gas than `<=` return ConditionID.wrap(keccak256(abi.encodePacked(oracle, questionId, outcomeSlotCount))); } /// @dev Constructs an outcome collection ID /// @param conditionId Condition ID of the outcome collection /// @param index outcome index function getCollectionId(ConditionID conditionId, uint256 index) internal pure returns (CollectionID) { return CollectionID.wrap(keccak256(abi.encodePacked(conditionId, index))); } /// @dev Constructs a position ID from a collateral token and an outcome /// collection. These IDs are used as the ERC-1155 ID for this contract. /// @param collateralToken Collateral token which backs the position. /// @param collectionId ID of the outcome collection associated with this position. function getPositionId(IERC20 collateralToken, CollectionID collectionId) internal pure returns (uint256) { return uint256(keccak256(abi.encodePacked(collateralToken, collectionId))); } /// @dev Constructs all position ID in a condition, for a collateral token. /// These IDs are used as the ERC-1155 ID for the ConditionalTokens contract. /// @param collateralToken Collateral token which backs the position. /// @param conditionId ID of the condition associated with all positions /// @param outcomeSlotCount number of outcomes in the condition function getPositionIds(IERC20 collateralToken, ConditionID conditionId, uint256 outcomeSlotCount) internal pure returns (uint256[] memory positionIds) { positionIds = new uint256[](outcomeSlotCount); for (uint256 i = 0; i < outcomeSlotCount; i++) { positionIds[i] = getPositionId(collateralToken, getCollectionId(conditionId, i)); } } function encodeIndices(uint256[] memory indices) internal pure returns (PackedIndices) { bytes32 packedIndices; uint256 length = indices.length; unchecked { for (uint256 i; i < length; i++) { uint256 value = indices[i]; assert(value <= type(uint8).max); packedIndices |= bytes32(value << (8 * i)); } } return PackedIndices.wrap(packedIndices); } function getIndex(PackedIndices indices, uint256 i) internal pure returns (uint256) { return (uint256(PackedIndices.unwrap(indices)) >> (8 * i)) & 0xff; } function decodeIndices(PackedIndices packedIndices, uint256 length) internal pure returns (uint256[] memory indices) { unchecked { indices = new uint256[](length); for (uint256 i; i < length; i++) { indices[i] = getIndex(packedIndices, i); } } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (token/ERC1155/IERC1155.sol) pragma solidity ^0.8.0; import "../../utils/introspection/IERC165Upgradeable.sol"; /** * @dev Required interface of an ERC1155 compliant contract, as defined in the * https://eips.ethereum.org/EIPS/eip-1155[EIP]. * * _Available since v3.1._ */ interface IERC1155Upgradeable is IERC165Upgradeable { /** * @dev Emitted when `value` tokens of token type `id` are transferred from `from` to `to` by `operator`. */ event TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value); /** * @dev Equivalent to multiple {TransferSingle} events, where `operator`, `from` and `to` are the same for all * transfers. */ event TransferBatch( address indexed operator, address indexed from, address indexed to, uint256[] ids, uint256[] values ); /** * @dev Emitted when `account` grants or revokes permission to `operator` to transfer their tokens, according to * `approved`. */ event ApprovalForAll(address indexed account, address indexed operator, bool approved); /** * @dev Emitted when the URI for token type `id` changes to `value`, if it is a non-programmatic URI. * * If an {URI} event was emitted for `id`, the standard * https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[guarantees] that `value` will equal the value * returned by {IERC1155MetadataURI-uri}. */ event URI(string value, uint256 indexed id); /** * @dev Returns the amount of tokens of token type `id` owned by `account`. * * Requirements: * * - `account` cannot be the zero address. */ function balanceOf(address account, uint256 id) external view returns (uint256); /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {balanceOf}. * * Requirements: * * - `accounts` and `ids` must have the same length. */ function balanceOfBatch(address[] calldata accounts, uint256[] calldata ids) external view returns (uint256[] memory); /** * @dev Grants or revokes permission to `operator` to transfer the caller's tokens, according to `approved`, * * Emits an {ApprovalForAll} event. * * Requirements: * * - `operator` cannot be the caller. */ function setApprovalForAll(address operator, bool approved) external; /** * @dev Returns true if `operator` is approved to transfer ``account``'s tokens. * * See {setApprovalForAll}. */ function isApprovedForAll(address account, address operator) external view returns (bool); /** * @dev Transfers `amount` tokens of token type `id` from `from` to `to`. * * Emits a {TransferSingle} event. * * Requirements: * * - `to` cannot be the zero address. * - If the caller is not `from`, it must have been approved to spend ``from``'s tokens via {setApprovalForAll}. * - `from` must have a balance of tokens of type `id` of at least `amount`. * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the * acceptance magic value. */ function safeTransferFrom( address from, address to, uint256 id, uint256 amount, bytes calldata data ) external; /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {safeTransferFrom}. * * Emits a {TransferBatch} event. * * Requirements: * * - `ids` and `amounts` must have the same length. * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the * acceptance magic value. */ function safeBatchTransferFrom( address from, address to, uint256[] calldata ids, uint256[] calldata amounts, bytes calldata data ) external; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (token/ERC1155/IERC1155Receiver.sol) pragma solidity ^0.8.0; import "../../utils/introspection/IERC165Upgradeable.sol"; /** * @dev _Available since v3.1._ */ interface IERC1155ReceiverUpgradeable is IERC165Upgradeable { /** * @dev Handles the receipt of a single ERC1155 token type. This function is * called at the end of a `safeTransferFrom` after the balance has been updated. * * NOTE: To accept the transfer, this must return * `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` * (i.e. 0xf23a6e61, or its own function selector). * * @param operator The address which initiated the transfer (i.e. msg.sender) * @param from The address which previously owned the token * @param id The ID of the token being transferred * @param value The amount of tokens being transferred * @param data Additional data with no specified format * @return `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` if transfer is allowed */ function onERC1155Received( address operator, address from, uint256 id, uint256 value, bytes calldata data ) external returns (bytes4); /** * @dev Handles the receipt of a multiple ERC1155 token types. This function * is called at the end of a `safeBatchTransferFrom` after the balances have * been updated. * * NOTE: To accept the transfer(s), this must return * `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` * (i.e. 0xbc197c81, or its own function selector). * * @param operator The address which initiated the batch transfer (i.e. msg.sender) * @param from The address which previously owned the token * @param ids An array containing ids of each token being transferred (order and length must match values array) * @param values An array containing amounts of each token being transferred (order and length must match ids array) * @param data Additional data with no specified format * @return `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` if transfer is allowed */ function onERC1155BatchReceived( address operator, address from, uint256[] calldata ids, uint256[] calldata values, bytes calldata data ) external returns (bytes4); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC1155/extensions/IERC1155MetadataURI.sol) pragma solidity ^0.8.0; import "../IERC1155Upgradeable.sol"; /** * @dev Interface of the optional ERC1155MetadataExtension interface, as defined * in the https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[EIP]. * * _Available since v3.1._ */ interface IERC1155MetadataURIUpgradeable is IERC1155Upgradeable { /** * @dev Returns the URI for token type `id`. * * If the `\{id\}` substring is present in the URI, it must be replaced by * clients with the actual token type ID. */ function uri(uint256 id) external view returns (string memory); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library AddressUpgradeable { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract. * * _Available since v4.8._ */ function verifyCallResultFromTarget( address target, bool success, bytes memory returndata, string memory errorMessage ) internal view returns (bytes memory) { if (success) { if (returndata.length == 0) { // only check isContract if the call was successful and the return data is empty // otherwise we already know that it was a contract require(isContract(target), "Address: call to non-contract"); } return returndata; } else { _revert(returndata, errorMessage); } } /** * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason or using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { _revert(returndata, errorMessage); } } function _revert(bytes memory returndata, string memory errorMessage) private pure { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly /// @solidity memory-safe-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; import "../proxy/utils/Initializable.sol"; /** * @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 ContextUpgradeable is Initializable { function __Context_init() internal onlyInitializing { } function __Context_init_unchained() internal onlyInitializing { } function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[50] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol) pragma solidity ^0.8.0; import "./IERC165Upgradeable.sol"; import "../../proxy/utils/Initializable.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 ERC165Upgradeable is Initializable, IERC165Upgradeable { function __ERC165_init() internal onlyInitializing { } function __ERC165_init_unchained() internal onlyInitializing { } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165Upgradeable).interfaceId; } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[50] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.1) (proxy/utils/Initializable.sol) pragma solidity ^0.8.2; import "../../utils/AddressUpgradeable.sol"; /** * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect. * * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be * reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in * case an upgrade adds a module that needs to be initialized. * * For example: * * [.hljs-theme-light.nopadding] * ``` * contract MyToken is ERC20Upgradeable { * function initialize() initializer public { * __ERC20_init("MyToken", "MTK"); * } * } * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable { * function initializeV2() reinitializer(2) public { * __ERC20Permit_init("MyToken"); * } * } * ``` * * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}. * * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity. * * [CAUTION] * ==== * Avoid leaving a contract uninitialized. * * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed: * * [.hljs-theme-light.nopadding] * ``` * /// @custom:oz-upgrades-unsafe-allow constructor * constructor() { * _disableInitializers(); * } * ``` * ==== */ abstract contract Initializable { /** * @dev Indicates that the contract has been initialized. * @custom:oz-retyped-from bool */ uint8 private _initialized; /** * @dev Indicates that the contract is in the process of being initialized. */ bool private _initializing; /** * @dev Triggered when the contract has been initialized or reinitialized. */ event Initialized(uint8 version); /** * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope, * `onlyInitializing` functions can be used to initialize parent contracts. * * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a * constructor. * * Emits an {Initialized} event. */ modifier initializer() { bool isTopLevelCall = !_initializing; require( (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1), "Initializable: contract is already initialized" ); _initialized = 1; if (isTopLevelCall) { _initializing = true; } _; if (isTopLevelCall) { _initializing = false; emit Initialized(1); } } /** * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be * used to initialize parent contracts. * * A reinitializer may be used after the original initialization step. This is essential to configure modules that * are added through upgrades and that require initialization. * * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer` * cannot be nested. If one is invoked in the context of another, execution will revert. * * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in * a contract, executing them in the right order is up to the developer or operator. * * WARNING: setting the version to 255 will prevent any future reinitialization. * * Emits an {Initialized} event. */ modifier reinitializer(uint8 version) { require(!_initializing && _initialized < version, "Initializable: contract is already initialized"); _initialized = version; _initializing = true; _; _initializing = false; emit Initialized(version); } /** * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the * {initializer} and {reinitializer} modifiers, directly or indirectly. */ modifier onlyInitializing() { require(_initializing, "Initializable: contract is not initializing"); _; } /** * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call. * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized * to any version. It is recommended to use this to lock implementation contracts that are designed to be called * through proxies. * * Emits an {Initialized} event the first time it is successfully executed. */ function _disableInitializers() internal virtual { require(!_initializing, "Initializable: contract is initializing"); if (_initialized < type(uint8).max) { _initialized = type(uint8).max; emit Initialized(type(uint8).max); } } /** * @dev Returns the highest version that has been initialized. See {reinitializer}. */ function _getInitializedVersion() internal view returns (uint8) { return _initialized; } /** * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}. */ function _isInitializing() internal view returns (bool) { return _initializing; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.19; import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import { IERC1155Upgradeable } from "@openzeppelin/contracts-upgradeable/token/ERC1155/IERC1155Upgradeable.sol"; import { ConditionID, QuestionID } from "./CTHelpers.sol"; import { ConditionalTokensErrors } from "./ConditionalTokensErrors.sol"; /// @title Events emitted by conditional tokens /// @dev Minimal interface to be used for blockchain indexing (e.g subgraph) interface IConditionalTokensEvents { /// @dev Emitted upon the successful preparation of a condition. /// @param conditionId The condition's ID. This ID may be derived from the /// other three parameters via ``keccak256(abi.encodePacked(oracle, /// questionId, outcomeSlotCount))``. /// @param oracle The account assigned to report the result for the prepared condition. /// @param questionId An identifier for the question to be answered by the oracle. /// @param outcomeSlotCount The number of outcome slots which should be used /// for this condition. Must not exceed 256. event ConditionPreparation( ConditionID indexed conditionId, address indexed oracle, QuestionID indexed questionId, uint256 outcomeSlotCount ); event ConditionResolution( ConditionID indexed conditionId, address indexed oracle, QuestionID indexed questionId, uint256 outcomeSlotCount, uint256[] payoutNumerators ); /// @dev Emitted when a position is successfully split. event PositionSplit( address indexed stakeholder, IERC20 collateralToken, ConditionID indexed conditionId, uint256 amount ); /// @dev Emitted when positions are successfully merged. event PositionsMerge( address indexed stakeholder, IERC20 collateralToken, ConditionID indexed conditionId, uint256 amount ); /// @notice Emitted when a subset of outcomes are redeemed for a condition event PayoutRedemption( address indexed redeemer, IERC20 indexed collateralToken, ConditionID conditionId, uint256[] indices, uint256 payout ); /// @notice Emitted when a redemption occurs where the proceeds are given to a different address event PayoutRedemptionFor( address indexed receiver, address indexed redeemer, IERC20 indexed collateralToken, ConditionID conditionId, uint256[] indices, uint256[] quantities, uint256 payout ); } interface IConditionalTokens is IERC1155Upgradeable, IConditionalTokensEvents, ConditionalTokensErrors { function prepareCondition(address oracle, QuestionID questionId, uint256 outcomeSlotCount) external returns (ConditionID); function reportPayouts(QuestionID questionId, uint256[] calldata payouts) external; function batchReportPayouts( QuestionID[] calldata questionIDs, uint256[] calldata payouts, uint256[] calldata outcomeSlotCounts ) external; function splitPosition(IERC20 collateralToken, ConditionID conditionId, uint256 amount) external; function mergePositions(IERC20 collateralToken, ConditionID conditionId, uint256 amount) external; function redeemPositionsFor( address receiver, IERC20 collateralToken, ConditionID conditionId, uint256[] calldata indices, uint256[] calldata quantities ) external returns (uint256); function redeemAll(IERC20 collateralToken, ConditionID[] calldata conditionIds, uint256[] calldata indices) external; function redeemAllOf( address ownerAndReceiver, IERC20 collateralToken, ConditionID[] calldata conditionIds, uint256[] calldata indices ) external returns (uint256 totalPayout); function balanceOfCondition(address account, IERC20 collateralToken, ConditionID conditionId) external view returns (uint256[] memory); function isResolved(ConditionID conditionId) external view returns (bool); function getPositionIds(IERC20 collateralToken, ConditionID conditionId) external view returns (uint256[] memory); /// @dev number of outcome slots in a condition function getOutcomeSlotCount(ConditionID conditionId) external view returns (uint256); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.19; import { Math } from "@openzeppelin/contracts/utils/math/Math.sol"; /// @dev Functions to deal with 16bit prices packed into `bytes`. /// In prediction markets, prices are within the range [0-1]. As such, arbitrary /// magnitude and precision are not necessary. By restricting prices to be fixed /// point integers between 0 and 1e4, we get: /// - Prices fit in 16 bits /// - Can be easily renormalized to 1e18 via a multiplier /// /// The 16bit prices are packed back to back and encoded in big-endian format. /// /// Some notes: /// /// Packing/unpacking is done manually and not via solidity's uint16[]. /// uint16[] arrays are still encoded with all the padding. Additionally, /// working directly with uint16 data types is less efficient than uint256, due /// to bit shifting and masking that is implicitly done library PackedPrices { using Math for uint256; /// @dev a divisor that fits in 16 bits, and easily divides into 1e18 uint256 internal constant DIVISOR = 1e4; /// @dev divisor for majority of decimal calculations uint256 internal constant ONE_DECIMAL = 1e18; /// @dev We store packed prices in 16 bits with a divisor of 1e4. AMM math /// relies on prices having divisor of 1e18. We can go directly from one to /// the other by multiplying by 1e14. uint256 internal constant DECIMAL_CONVERSION_FACTOR = 1e14; /// @dev How many bits to shift to convert between big-endian uint16 and uint256 uint256 internal constant SHIFT_BITS = 30 * 8; /// @dev Given a packed price byte array, unpack into a decimal price array with 1e18 divisor /// @param packedPrices packed byte array /// @return priceDecimals unpacked price array of prices normalized to 1e18 function toPriceDecimals(bytes memory packedPrices) internal pure returns (uint256[] memory priceDecimals) { unchecked { uint256 length = packedPrices.length / 2; priceDecimals = new uint256[](length); for (uint256 i; i < length; i++) { uint256 chunk; uint256 offset = 32 + i * 2; assembly ("memory-safe") { chunk := mload(add(packedPrices, offset)) } priceDecimals[i] = (chunk >> SHIFT_BITS) * DECIMAL_CONVERSION_FACTOR; } } } /// @dev Given a packed price byte array in storage, unpack into a decimal price array with 1e18 divisor /// @param packedPrices packed byte array storage pointer /// @return priceDecimals unpacked price array of prices normalized to 1e18 function toPriceDecimalsFromStorage(bytes storage packedPrices) internal pure returns (uint256[] memory) { // Much easier to copy the byte array into memory first, and then // perform the conversion from memory array, than doing it directly from // storage. // This is because the storage load instruction `SLOAD` costs 200 gas, // while the memory load instruction `MLOAD` costs only 3. The // drastically simpler code that loads each integer one at a time would // be extremely costly with SLOAD, and would require a different // algorithm that amounts to copying into memory first to minimize SLOAD // instructions. return toPriceDecimals(packedPrices); } /// @dev Given an array of integers, packs them into a byte array of 16bit values. /// Integers are taken as-is, with no re-normalization. /// @param prices array of integers less than or equal to type(uint16).max . Otherwise truncation will occur /// @param divisor what to divide prices by before packing /// @return packedPrices packed byte array function toPackedPrices(uint256[] memory prices, uint256 divisor) internal pure returns (bytes memory packedPrices) { unchecked { uint256 length = prices.length; // set the size of bytes array packedPrices = new bytes(length * 2); for (uint256 i; i < length; i++) { uint256 adjustedPrice = prices[i] / divisor; assert(adjustedPrice <= type(uint16).max); uint256 chunk = adjustedPrice << SHIFT_BITS; uint256 offset = 32 + i * 2; assembly { mstore(add(packedPrices, offset), chunk) } } } } /// @dev Sums the values in the packed price byte array /// @param packedPrices the byte array that encodes the packed prices /// @return result the sum of the decoded prices function sum(bytes memory packedPrices) internal pure returns (uint256 result) { unchecked { uint256 length = packedPrices.length / 2; for (uint256 i; i < length; i++) { uint256 chunk; uint256 offset = 32 + i * 2; assembly ("memory-safe") { chunk := mload(add(packedPrices, offset)) } result += chunk >> SHIFT_BITS; } } } function arrayLength(bytes memory packedPrices) internal pure returns (uint256) { return packedPrices.length / 2; } function valueAtIndex(bytes memory packedPrices, uint256 index) internal pure returns (uint256) { uint256 chunk; uint256 offset = 32 + index * 2; assembly ("memory-safe") { chunk := mload(add(packedPrices, offset)) } return (chunk >> SHIFT_BITS); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol) pragma solidity ^0.8.0; import "../utils/ContextUpgradeable.sol"; import "../proxy/utils/Initializable.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract OwnableUpgradeable is Initializable, ContextUpgradeable { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ function __Ownable_init() internal onlyInitializing { __Ownable_init_unchained(); } function __Ownable_init_unchained() internal onlyInitializing { _transferOwnership(_msgSender()); } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { _checkOwner(); _; } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if the sender is not the owner. */ function _checkOwner() internal view virtual { require(owner() == _msgSender(), "Ownable: caller is not the owner"); } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _transferOwnership(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[49] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (proxy/utils/UUPSUpgradeable.sol) pragma solidity ^0.8.0; import "../../interfaces/draft-IERC1822Upgradeable.sol"; import "../ERC1967/ERC1967UpgradeUpgradeable.sol"; import "./Initializable.sol"; /** * @dev An upgradeability mechanism designed for UUPS proxies. The functions included here can perform an upgrade of an * {ERC1967Proxy}, when this contract is set as the implementation behind such a proxy. * * A security mechanism ensures that an upgrade does not turn off upgradeability accidentally, although this risk is * reinstated if the upgrade retains upgradeability but removes the security mechanism, e.g. by replacing * `UUPSUpgradeable` with a custom implementation of upgrades. * * The {_authorizeUpgrade} function must be overridden to include access restriction to the upgrade mechanism. * * _Available since v4.1._ */ abstract contract UUPSUpgradeable is Initializable, IERC1822ProxiableUpgradeable, ERC1967UpgradeUpgradeable { function __UUPSUpgradeable_init() internal onlyInitializing { } function __UUPSUpgradeable_init_unchained() internal onlyInitializing { } /// @custom:oz-upgrades-unsafe-allow state-variable-immutable state-variable-assignment address private immutable __self = address(this); /** * @dev Check that the execution is being performed through a delegatecall call and that the execution context is * a proxy contract with an implementation (as defined in ERC1967) pointing to self. This should only be the case * for UUPS and transparent proxies that are using the current contract as their implementation. Execution of a * function through ERC1167 minimal proxies (clones) would not normally pass this test, but is not guaranteed to * fail. */ modifier onlyProxy() { require(address(this) != __self, "Function must be called through delegatecall"); require(_getImplementation() == __self, "Function must be called through active proxy"); _; } /** * @dev Check that the execution is not being performed through a delegate call. This allows a function to be * callable on the implementing contract but not through proxies. */ modifier notDelegated() { require(address(this) == __self, "UUPSUpgradeable: must not be called through delegatecall"); _; } /** * @dev Implementation of the ERC1822 {proxiableUUID} function. This returns the storage slot used by the * implementation. It is used to validate the implementation's compatibility when performing an upgrade. * * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this * function revert if invoked through a proxy. This is guaranteed by the `notDelegated` modifier. */ function proxiableUUID() external view virtual override notDelegated returns (bytes32) { return _IMPLEMENTATION_SLOT; } /** * @dev Upgrade the implementation of the proxy to `newImplementation`. * * Calls {_authorizeUpgrade}. * * Emits an {Upgraded} event. */ function upgradeTo(address newImplementation) external virtual onlyProxy { _authorizeUpgrade(newImplementation); _upgradeToAndCallUUPS(newImplementation, new bytes(0), false); } /** * @dev Upgrade the implementation of the proxy to `newImplementation`, and subsequently execute the function call * encoded in `data`. * * Calls {_authorizeUpgrade}. * * Emits an {Upgraded} event. */ function upgradeToAndCall(address newImplementation, bytes memory data) external payable virtual onlyProxy { _authorizeUpgrade(newImplementation); _upgradeToAndCallUUPS(newImplementation, data, true); } /** * @dev Function that should revert when `msg.sender` is not authorized to upgrade the contract. Called by * {upgradeTo} and {upgradeToAndCall}. * * Normally, this function will use an xref:access.adoc[access control] modifier such as {Ownable-onlyOwner}. * * ```solidity * function _authorizeUpgrade(address) internal override onlyOwner {} * ``` */ function _authorizeUpgrade(address newImplementation) internal virtual; /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[50] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/utils/SafeERC20.sol) pragma solidity ^0.8.0; import "../IERC20.sol"; import "../extensions/draft-IERC20Permit.sol"; import "../../../utils/Address.sol"; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20 { using Address for address; function safeTransfer( IERC20 token, address to, uint256 value ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom( IERC20 token, address from, address to, uint256 value ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } /** * @dev Deprecated. This function has issues similar to the ones found in * {IERC20-approve}, and its usage is discouraged. * * Whenever possible, use {safeIncreaseAllowance} and * {safeDecreaseAllowance} instead. */ function safeApprove( IERC20 token, address spender, uint256 value ) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' require( (value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function safeIncreaseAllowance( IERC20 token, address spender, uint256 value ) internal { uint256 newAllowance = token.allowance(address(this), spender) + value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function safeDecreaseAllowance( IERC20 token, address spender, uint256 value ) internal { unchecked { uint256 oldAllowance = token.allowance(address(this), spender); require(oldAllowance >= value, "SafeERC20: decreased allowance below zero"); uint256 newAllowance = oldAllowance - value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } } function safePermit( IERC20Permit token, address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) internal { uint256 nonceBefore = token.nonces(owner); token.permit(owner, spender, value, deadline, v, r, s); uint256 nonceAfter = token.nonces(owner); require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed"); } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function _callOptionalReturn(IERC20 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.19; // Note on libraries. If any functions are not `internal`, then contracts that // use the libraries, must be linked. library ArrayMath { function sum(uint256[] memory values) internal pure returns (uint256) { uint256 result = 0; for (uint256 i = 0; i < values.length; i++) { result += values[i]; } return result; } } /// @dev Math with saturation/clamping for overflow/underflow handling library ClampedMath { /// @dev min(upper, max(lower, x)) function clampBetween(uint256 x, uint256 lower, uint256 upper) internal pure returns (uint256) { unchecked { return x < lower ? lower : (x > upper ? upper : x); } } /// @dev max(0, a - b) function subClamp(uint256 a, uint256 b) internal pure returns (uint256) { unchecked { return a > b ? a - b : 0; } } /// @dev min(type(uint256).max, max(0, a + b)) function addClamp(uint256 a, int256 b) internal pure returns (uint256) { unchecked { if (b < 0) { // The absolute value of type(int256).min is not representable // in int256, so have to dance about with the + 1 uint256 positiveB = uint256(-(b + 1)) + 1; return (a > positiveB) ? (a - positiveB) : 0; } else { return type(uint256).max - a > uint256(b) ? a + uint256(b) : type(uint256).max; } } } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.19; interface ConditionalTokensErrors { error ConditionAlreadyPrepared(); error PayoutAlreadyReported(); error PayoutsAreAllZero(); error InvalidOutcomeSlotCountsArray(); error InvalidPayoutArray(); error ResultNotReceivedYet(); error InvalidIndex(); error NoPositionsToRedeem(); error ConditionNotFound(); error InvalidAmount(); error InvalidOutcomeSlotsAmount(); error InvalidQuantities(); error InvalidPrices(); error InvalidConditionOracle(address conditionOracle); error MustBeCalledByOracle(); error InvalidHaltTime(); /// @dev using unapproved ERC20 token with protocol error InvalidERC20(); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/math/Math.sol) pragma solidity ^0.8.0; /** * @dev Standard math utilities missing in the Solidity language. */ library Math { enum Rounding { Down, // Toward negative infinity Up, // Toward infinity Zero // Toward zero } /** * @dev Returns the largest of two numbers. */ function max(uint256 a, uint256 b) internal pure returns (uint256) { return a > b ? a : b; } /** * @dev Returns the smallest of two numbers. */ function min(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; } /** * @dev Returns the average of two numbers. The result is rounded towards * zero. */ function average(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b) / 2 can overflow. return (a & b) + (a ^ b) / 2; } /** * @dev Returns the ceiling of the division of two numbers. * * This differs from standard division with `/` in that it rounds up instead * of rounding down. */ function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b - 1) / b can overflow on addition, so we distribute. return a == 0 ? 0 : (a - 1) / b + 1; } /** * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0 * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) * with further edits by Uniswap Labs also under MIT license. */ function mulDiv( uint256 x, uint256 y, uint256 denominator ) internal pure returns (uint256 result) { unchecked { // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256 // variables such that product = prod1 * 2^256 + prod0. uint256 prod0; // Least significant 256 bits of the product uint256 prod1; // Most significant 256 bits of the product assembly { let mm := mulmod(x, y, not(0)) prod0 := mul(x, y) prod1 := sub(sub(mm, prod0), lt(mm, prod0)) } // Handle non-overflow cases, 256 by 256 division. if (prod1 == 0) { return prod0 / denominator; } // Make sure the result is less than 2^256. Also prevents denominator == 0. require(denominator > prod1); /////////////////////////////////////////////// // 512 by 256 division. /////////////////////////////////////////////// // Make division exact by subtracting the remainder from [prod1 prod0]. uint256 remainder; assembly { // Compute remainder using mulmod. remainder := mulmod(x, y, denominator) // Subtract 256 bit number from 512 bit number. prod1 := sub(prod1, gt(remainder, prod0)) prod0 := sub(prod0, remainder) } // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1. // See https://cs.stackexchange.com/q/138556/92363. // Does not overflow because the denominator cannot be zero at this stage in the function. uint256 twos = denominator & (~denominator + 1); assembly { // Divide denominator by twos. denominator := div(denominator, twos) // Divide [prod1 prod0] by twos. prod0 := div(prod0, twos) // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one. twos := add(div(sub(0, twos), twos), 1) } // Shift in bits from prod1 into prod0. prod0 |= prod1 * twos; // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for // four bits. That is, denominator * inv = 1 mod 2^4. uint256 inverse = (3 * denominator) ^ 2; // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works // in modular arithmetic, doubling the correct bits in each step. inverse *= 2 - denominator * inverse; // inverse mod 2^8 inverse *= 2 - denominator * inverse; // inverse mod 2^16 inverse *= 2 - denominator * inverse; // inverse mod 2^32 inverse *= 2 - denominator * inverse; // inverse mod 2^64 inverse *= 2 - denominator * inverse; // inverse mod 2^128 inverse *= 2 - denominator * inverse; // inverse mod 2^256 // Because the division is now exact we can divide by multiplying with the modular inverse of denominator. // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1 // is no longer required. result = prod0 * inverse; return result; } } /** * @notice Calculates x * y / denominator with full precision, following the selected rounding direction. */ function mulDiv( uint256 x, uint256 y, uint256 denominator, Rounding rounding ) internal pure returns (uint256) { uint256 result = mulDiv(x, y, denominator); if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) { result += 1; } return result; } /** * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down. * * Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11). */ function sqrt(uint256 a) internal pure returns (uint256) { if (a == 0) { return 0; } // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target. // // We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`. // // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)` // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))` // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)` // // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit. uint256 result = 1 << (log2(a) >> 1); // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128, // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision // into the expected uint128 result. unchecked { result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; return min(result, a / result); } } /** * @notice Calculates sqrt(a), following the selected rounding direction. */ function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = sqrt(a); return result + (rounding == Rounding.Up && result * result < a ? 1 : 0); } } /** * @dev Return the log in base 2, rounded down, of a positive value. * Returns 0 if given 0. */ function log2(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >> 128 > 0) { value >>= 128; result += 128; } if (value >> 64 > 0) { value >>= 64; result += 64; } if (value >> 32 > 0) { value >>= 32; result += 32; } if (value >> 16 > 0) { value >>= 16; result += 16; } if (value >> 8 > 0) { value >>= 8; result += 8; } if (value >> 4 > 0) { value >>= 4; result += 4; } if (value >> 2 > 0) { value >>= 2; result += 2; } if (value >> 1 > 0) { result += 1; } } return result; } /** * @dev Return the log in base 2, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log2(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log2(value); return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0); } } /** * @dev Return the log in base 10, rounded down, of a positive value. * Returns 0 if given 0. */ function log10(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >= 10**64) { value /= 10**64; result += 64; } if (value >= 10**32) { value /= 10**32; result += 32; } if (value >= 10**16) { value /= 10**16; result += 16; } if (value >= 10**8) { value /= 10**8; result += 8; } if (value >= 10**4) { value /= 10**4; result += 4; } if (value >= 10**2) { value /= 10**2; result += 2; } if (value >= 10**1) { result += 1; } } return result; } /** * @dev Return the log in base 10, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log10(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log10(value); return result + (rounding == Rounding.Up && 10**result < value ? 1 : 0); } } /** * @dev Return the log in base 256, rounded down, of a positive value. * Returns 0 if given 0. * * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string. */ function log256(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >> 128 > 0) { value >>= 128; result += 16; } if (value >> 64 > 0) { value >>= 64; result += 8; } if (value >> 32 > 0) { value >>= 32; result += 4; } if (value >> 16 > 0) { value >>= 16; result += 2; } if (value >> 8 > 0) { result += 1; } } return result; } /** * @dev Return the log in base 10, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log256(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log256(value); return result + (rounding == Rounding.Up && 1 << (result * 8) < value ? 1 : 0); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (interfaces/draft-IERC1822.sol) pragma solidity ^0.8.0; /** * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified * proxy whose upgrades are fully controlled by the current implementation. */ interface IERC1822ProxiableUpgradeable { /** * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation * address. * * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this * function revert if invoked through a proxy. */ function proxiableUUID() external view returns (bytes32); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.3) (proxy/ERC1967/ERC1967Upgrade.sol) pragma solidity ^0.8.2; import "../beacon/IBeaconUpgradeable.sol"; import "../../interfaces/IERC1967Upgradeable.sol"; import "../../interfaces/draft-IERC1822Upgradeable.sol"; import "../../utils/AddressUpgradeable.sol"; import "../../utils/StorageSlotUpgradeable.sol"; import "../utils/Initializable.sol"; /** * @dev This abstract contract provides getters and event emitting update functions for * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots. * * _Available since v4.1._ * * @custom:oz-upgrades-unsafe-allow delegatecall */ abstract contract ERC1967UpgradeUpgradeable is Initializable, IERC1967Upgradeable { function __ERC1967Upgrade_init() internal onlyInitializing { } function __ERC1967Upgrade_init_unchained() internal onlyInitializing { } // This is the keccak-256 hash of "eip1967.proxy.rollback" subtracted by 1 bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143; /** * @dev Storage slot with the address of the current implementation. * This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1, and is * validated in the constructor. */ bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; /** * @dev Returns the current implementation address. */ function _getImplementation() internal view returns (address) { return StorageSlotUpgradeable.getAddressSlot(_IMPLEMENTATION_SLOT).value; } /** * @dev Stores a new address in the EIP1967 implementation slot. */ function _setImplementation(address newImplementation) private { require(AddressUpgradeable.isContract(newImplementation), "ERC1967: new implementation is not a contract"); StorageSlotUpgradeable.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation; } /** * @dev Perform implementation upgrade * * Emits an {Upgraded} event. */ function _upgradeTo(address newImplementation) internal { _setImplementation(newImplementation); emit Upgraded(newImplementation); } /** * @dev Perform implementation upgrade with additional setup call. * * Emits an {Upgraded} event. */ function _upgradeToAndCall( address newImplementation, bytes memory data, bool forceCall ) internal { _upgradeTo(newImplementation); if (data.length > 0 || forceCall) { _functionDelegateCall(newImplementation, data); } } /** * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call. * * Emits an {Upgraded} event. */ function _upgradeToAndCallUUPS( address newImplementation, bytes memory data, bool forceCall ) internal { // Upgrades from old implementations will perform a rollback test. This test requires the new // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing // this special case will break upgrade paths from old UUPS implementation to new ones. if (StorageSlotUpgradeable.getBooleanSlot(_ROLLBACK_SLOT).value) { _setImplementation(newImplementation); } else { try IERC1822ProxiableUpgradeable(newImplementation).proxiableUUID() returns (bytes32 slot) { require(slot == _IMPLEMENTATION_SLOT, "ERC1967Upgrade: unsupported proxiableUUID"); } catch { revert("ERC1967Upgrade: new implementation is not UUPS"); } _upgradeToAndCall(newImplementation, data, forceCall); } } /** * @dev Storage slot with the admin of the contract. * This is the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1, and is * validated in the constructor. */ bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103; /** * @dev Returns the current admin. */ function _getAdmin() internal view returns (address) { return StorageSlotUpgradeable.getAddressSlot(_ADMIN_SLOT).value; } /** * @dev Stores a new address in the EIP1967 admin slot. */ function _setAdmin(address newAdmin) private { require(newAdmin != address(0), "ERC1967: new admin is the zero address"); StorageSlotUpgradeable.getAddressSlot(_ADMIN_SLOT).value = newAdmin; } /** * @dev Changes the admin of the proxy. * * Emits an {AdminChanged} event. */ function _changeAdmin(address newAdmin) internal { emit AdminChanged(_getAdmin(), newAdmin); _setAdmin(newAdmin); } /** * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy. * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor. */ bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50; /** * @dev Returns the current beacon. */ function _getBeacon() internal view returns (address) { return StorageSlotUpgradeable.getAddressSlot(_BEACON_SLOT).value; } /** * @dev Stores a new beacon in the EIP1967 beacon slot. */ function _setBeacon(address newBeacon) private { require(AddressUpgradeable.isContract(newBeacon), "ERC1967: new beacon is not a contract"); require( AddressUpgradeable.isContract(IBeaconUpgradeable(newBeacon).implementation()), "ERC1967: beacon implementation is not a contract" ); StorageSlotUpgradeable.getAddressSlot(_BEACON_SLOT).value = newBeacon; } /** * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that). * * Emits a {BeaconUpgraded} event. */ function _upgradeBeaconToAndCall( address newBeacon, bytes memory data, bool forceCall ) internal { _setBeacon(newBeacon); emit BeaconUpgraded(newBeacon); if (data.length > 0 || forceCall) { _functionDelegateCall(IBeaconUpgradeable(newBeacon).implementation(), data); } } /** * @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) private returns (bytes memory) { require(AddressUpgradeable.isContract(target), "Address: delegate call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.delegatecall(data); return AddressUpgradeable.verifyCallResult(success, returndata, "Address: low-level delegate call failed"); } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[50] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612]. * * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't * need to send a transaction, and thus is not required to hold Ether at all. */ interface IERC20Permit { /** * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens, * given ``owner``'s signed approval. * * IMPORTANT: The same issues {IERC20-approve} has related to transaction * ordering also apply here. * * Emits an {Approval} event. * * Requirements: * * - `spender` cannot be the zero address. * - `deadline` must be a timestamp in the future. * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner` * over the EIP712-formatted function arguments. * - the signature must use ``owner``'s current nonce (see {nonces}). * * For more information on the signature format, see the * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP * section]. */ function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external; /** * @dev Returns the current nonce for `owner`. This value must be * included whenever a signature is generated for {permit}. * * Every successful call to {permit} increases ``owner``'s nonce by one. This * prevents a signature from being used multiple times. */ function nonces(address owner) external view returns (uint256); /** * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}. */ // solhint-disable-next-line func-name-mixedcase function DOMAIN_SEPARATOR() external view returns (bytes32); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract. * * _Available since v4.8._ */ function verifyCallResultFromTarget( address target, bool success, bytes memory returndata, string memory errorMessage ) internal view returns (bytes memory) { if (success) { if (returndata.length == 0) { // only check isContract if the call was successful and the return data is empty // otherwise we already know that it was a contract require(isContract(target), "Address: call to non-contract"); } return returndata; } else { _revert(returndata, errorMessage); } } /** * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason or using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { _revert(returndata, errorMessage); } } function _revert(bytes memory returndata, string memory errorMessage) private pure { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly /// @solidity memory-safe-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol) pragma solidity ^0.8.0; /** * @dev This is the interface that {BeaconProxy} expects of its beacon. */ interface IBeaconUpgradeable { /** * @dev Must return an address that can be used as a delegate call target. * * {BeaconProxy} will check that this address is a contract. */ function implementation() external view returns (address); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.3) (interfaces/IERC1967.sol) pragma solidity ^0.8.0; /** * @dev ERC-1967: Proxy Storage Slots. This interface contains the events defined in the ERC. * * _Available since v4.9._ */ interface IERC1967Upgradeable { /** * @dev Emitted when the implementation is upgraded. */ event Upgraded(address indexed implementation); /** * @dev Emitted when the admin account has changed. */ event AdminChanged(address previousAdmin, address newAdmin); /** * @dev Emitted when the beacon is changed. */ event BeaconUpgraded(address indexed beacon); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (utils/StorageSlot.sol) pragma solidity ^0.8.0; /** * @dev Library for reading and writing primitive types to specific storage slots. * * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts. * This library helps with reading and writing to such slots without the need for inline assembly. * * The functions in this library return Slot structs that contain a `value` member that can be used to read or write. * * Example usage to set ERC1967 implementation slot: * ``` * contract ERC1967 { * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; * * function _getImplementation() internal view returns (address) { * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value; * } * * function _setImplementation(address newImplementation) internal { * require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract"); * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation; * } * } * ``` * * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._ */ library StorageSlotUpgradeable { struct AddressSlot { address value; } struct BooleanSlot { bool value; } struct Bytes32Slot { bytes32 value; } struct Uint256Slot { uint256 value; } /** * @dev Returns an `AddressSlot` with member `value` located at `slot`. */ function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `BooleanSlot` with member `value` located at `slot`. */ function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `Bytes32Slot` with member `value` located at `slot`. */ function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `Uint256Slot` with member `value` located at `slot`. */ function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } }
{ "remappings": [ "@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/", "@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/", "@prb/math/=lib/prb-math/src/", "ds-test/=lib/forge-std/lib/ds-test/src/", "forge-std/=lib/forge-std/src/", "upgrade-scripts/=lib/upgrade-scripts/src/", "UDS/=lib/upgrade-scripts/lib/UDS/src/", "@prb/test/=lib/prb-math/node_modules/@prb/test/", "futils/=lib/upgrade-scripts/lib/UDS/lib/futils/src/", "openzeppelin-contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/", "openzeppelin-contracts/=lib/openzeppelin-contracts/", "prb-math/=lib/prb-math/src/" ], "optimizer": { "enabled": true, "runs": 600 }, "metadata": { "useLiteralContent": false, "bytecodeHash": "ipfs", "appendCBOR": true }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "evmVersion": "paris", "viaIR": false, "libraries": {} }
[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"ConditionAlreadyPrepared","type":"error"},{"inputs":[],"name":"ConditionNotFound","type":"error"},{"inputs":[],"name":"InvalidAmount","type":"error"},{"inputs":[{"internalType":"address","name":"conditionOracle","type":"address"}],"name":"InvalidConditionOracle","type":"error"},{"inputs":[{"internalType":"address","name":"conditionalTokens","type":"address"}],"name":"InvalidConditionalTokensAddress","type":"error"},{"inputs":[],"name":"InvalidERC20","type":"error"},{"inputs":[],"name":"InvalidHaltTime","type":"error"},{"inputs":[],"name":"InvalidIndex","type":"error"},{"inputs":[],"name":"InvalidOutcomeSlotCountsArray","type":"error"},{"inputs":[],"name":"InvalidOutcomeSlotsAmount","type":"error"},{"inputs":[],"name":"InvalidParlayArraySizes","type":"error"},{"inputs":[],"name":"InvalidPayoutArray","type":"error"},{"inputs":[],"name":"InvalidPrices","type":"error"},{"inputs":[],"name":"InvalidQuantities","type":"error"},{"inputs":[],"name":"InvalidQuestionIdMask","type":"error"},{"inputs":[],"name":"MustBeCalledByOracle","type":"error"},{"inputs":[],"name":"NoPositionsToRedeem","type":"error"},{"inputs":[],"name":"OperationNotSupportedForParlayConditions","type":"error"},{"inputs":[],"name":"OperationNotSupportedWithoutLegInformation","type":"error"},{"inputs":[],"name":"ParlayInputsNotInCanonicalOrder","type":"error"},{"inputs":[],"name":"PayoutAlreadyReported","type":"error"},{"inputs":[],"name":"PayoutsAreAllZero","type":"error"},{"inputs":[],"name":"ResultNotReceivedYet","type":"error"},{"inputs":[],"name":"TooManyConditionsInParlay","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"previousAdmin","type":"address"},{"indexed":false,"internalType":"address","name":"newAdmin","type":"address"}],"name":"AdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","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":"beacon","type":"address"}],"name":"BeaconUpgraded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"ConditionID","name":"conditionId","type":"bytes32"},{"indexed":true,"internalType":"address","name":"oracle","type":"address"},{"indexed":true,"internalType":"QuestionID","name":"questionId","type":"bytes32"},{"indexed":false,"internalType":"uint256","name":"outcomeSlotCount","type":"uint256"}],"name":"ConditionPreparation","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"ConditionID","name":"conditionId","type":"bytes32"},{"indexed":false,"internalType":"bytes","name":"packedPrices","type":"bytes"}],"name":"ConditionPricesUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"ConditionID","name":"conditionId","type":"bytes32"},{"indexed":true,"internalType":"address","name":"oracle","type":"address"},{"indexed":true,"internalType":"QuestionID","name":"questionId","type":"bytes32"},{"indexed":false,"internalType":"uint256","name":"outcomeSlotCount","type":"uint256"},{"indexed":false,"internalType":"uint256[]","name":"payoutNumerators","type":"uint256[]"}],"name":"ConditionResolution","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"ConditionID","name":"conditionId","type":"bytes32"},{"indexed":false,"internalType":"uint32","name":"haltTime","type":"uint32"}],"name":"HaltTimeUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"version","type":"uint8"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"ConditionID","name":"conditionId","type":"bytes32"},{"indexed":true,"internalType":"QuestionID","name":"questionId","type":"bytes32"},{"indexed":true,"internalType":"address","name":"legOracle","type":"address"},{"indexed":false,"internalType":"uint256","name":"legQuestionIdMask","type":"uint256"},{"components":[{"internalType":"QuestionID[]","name":"questionIds","type":"bytes32[]"},{"internalType":"uint256[]","name":"indices","type":"uint256[]"},{"internalType":"uint256[]","name":"outcomeSlotCounts","type":"uint256[]"}],"indexed":false,"internalType":"struct ParlayLegs","name":"legs","type":"tuple"}],"name":"ParlayConditionLegs","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"redeemer","type":"address"},{"indexed":true,"internalType":"contract IERC20","name":"collateralToken","type":"address"},{"indexed":false,"internalType":"ConditionID","name":"conditionId","type":"bytes32"},{"indexed":false,"internalType":"uint256[]","name":"indices","type":"uint256[]"},{"indexed":false,"internalType":"uint256","name":"payout","type":"uint256"}],"name":"PayoutRedemption","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"receiver","type":"address"},{"indexed":true,"internalType":"address","name":"redeemer","type":"address"},{"indexed":true,"internalType":"contract IERC20","name":"collateralToken","type":"address"},{"indexed":false,"internalType":"ConditionID","name":"conditionId","type":"bytes32"},{"indexed":false,"internalType":"uint256[]","name":"indices","type":"uint256[]"},{"indexed":false,"internalType":"uint256[]","name":"quantities","type":"uint256[]"},{"indexed":false,"internalType":"uint256","name":"payout","type":"uint256"}],"name":"PayoutRedemptionFor","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"stakeholder","type":"address"},{"indexed":false,"internalType":"contract IERC20","name":"collateralToken","type":"address"},{"indexed":true,"internalType":"ConditionID","name":"conditionId","type":"bytes32"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"PositionSplit","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"stakeholder","type":"address"},{"indexed":false,"internalType":"contract IERC20","name":"collateralToken","type":"address"},{"indexed":true,"internalType":"ConditionID","name":"conditionId","type":"bytes32"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"PositionsMerge","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256[]","name":"ids","type":"uint256[]"},{"indexed":false,"internalType":"uint256[]","name":"values","type":"uint256[]"}],"name":"TransferBatch","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"id","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"TransferSingle","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"string","name":"value","type":"string"},{"indexed":true,"internalType":"uint256","name":"id","type":"uint256"}],"name":"URI","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"implementation","type":"address"}],"name":"Upgraded","type":"event"},{"inputs":[],"name":"MAX_LEGS_IN_PARLAY","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"id","type":"uint256"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address[]","name":"accounts","type":"address[]"},{"internalType":"uint256[]","name":"ids","type":"uint256[]"}],"name":"balanceOfBatch","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"contract IERC20","name":"collateralToken","type":"address"},{"internalType":"ConditionID","name":"conditionId","type":"bytes32"}],"name":"balanceOfCondition","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"QuestionID[]","name":"parlayQuestionIds","type":"bytes32[]"}],"name":"batchReportParlayPayouts","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"QuestionID[]","name":"","type":"bytes32[]"},{"internalType":"uint256[]","name":"","type":"uint256[]"},{"internalType":"uint256[]","name":"","type":"uint256[]"}],"name":"batchReportPayouts","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"components":[{"internalType":"ConditionID","name":"conditionId","type":"bytes32"},{"internalType":"bytes","name":"packedPrices","type":"bytes"}],"internalType":"struct IConditionalTokensV1_2.PriceUpdate[]","name":"","type":"tuple[]"}],"name":"batchUpdateFairPrices","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"components":[{"internalType":"ConditionID","name":"conditionId","type":"bytes32"},{"internalType":"uint32","name":"haltTime","type":"uint32"}],"internalType":"struct IConditionalTokensV1_2.HaltUpdate[]","name":"","type":"tuple[]"}],"name":"batchUpdateHaltTimes","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"erc20Whitelist","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"ConditionID","name":"conditionId","type":"bytes32"},{"internalType":"uint256","name":"index","type":"uint256"}],"name":"getCollectionId","outputs":[{"internalType":"CollectionID","name":"","type":"bytes32"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"oracle","type":"address"},{"internalType":"QuestionID","name":"questionId","type":"bytes32"},{"internalType":"uint256","name":"outcomeSlotCount","type":"uint256"}],"name":"getConditionId","outputs":[{"internalType":"ConditionID","name":"","type":"bytes32"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"ConditionID","name":"parlayConditionId","type":"bytes32"}],"name":"getFairPrices","outputs":[{"internalType":"uint256[]","name":"fairPriceDecimals","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"ConditionID","name":"conditionId","type":"bytes32"}],"name":"getOutcomeSlotCount","outputs":[{"internalType":"uint256","name":"outcomeSlotCount","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"QuestionID","name":"parlayQuestionId","type":"bytes32"}],"name":"getParlayConditionId","outputs":[{"internalType":"ConditionID","name":"parlayConditionId","type":"bytes32"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"legOracle","type":"address"},{"internalType":"QuestionID[]","name":"legQuestionIds","type":"bytes32[]"},{"internalType":"uint256","name":"legQuestionIdMask","type":"uint256"},{"internalType":"uint256[]","name":"legIndices","type":"uint256[]"}],"name":"getParlayQuestionId","outputs":[{"internalType":"QuestionID","name":"parlayQuestionId","type":"bytes32"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"ConditionID","name":"conditionId","type":"bytes32"}],"name":"getPayouts","outputs":[{"internalType":"uint256[]","name":"numerators","type":"uint256[]"},{"internalType":"uint256","name":"denominator","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"collateralToken","type":"address"},{"internalType":"CollectionID","name":"collectionId","type":"bytes32"}],"name":"getPositionId","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"collateralToken","type":"address"},{"internalType":"ConditionID","name":"conditionId","type":"bytes32"}],"name":"getPositionIds","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"contract IERC20","name":"collateralToken","type":"address"},{"internalType":"ConditionID","name":"conditionId","type":"bytes32"}],"name":"getPositionInfo","outputs":[{"internalType":"uint256[]","name":"balances","type":"uint256[]"},{"internalType":"uint256[]","name":"fairPriceDecimals","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"ConditionID","name":"","type":"bytes32"}],"name":"getPriceOracle","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"ConditionID","name":"parlayConditionId","type":"bytes32"}],"name":"haltTime","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"legConditionalTokens_","type":"address"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"address","name":"operator","type":"address"}],"name":"isApprovedForAll","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"ConditionID","name":"parlayConditionId","type":"bytes32"}],"name":"isHalted","outputs":[{"internalType":"bool","name":"halted","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"ConditionID","name":"conditionId","type":"bytes32"}],"name":"isResolved","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"legConditionalTokens","outputs":[{"internalType":"contract IConditionalTokensV1_2","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"collateralToken","type":"address"},{"internalType":"ConditionID","name":"conditionId","type":"bytes32"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"mergePositions","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"ConditionID","name":"","type":"bytes32"}],"name":"payoutDenominator","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"ConditionID","name":"","type":"bytes32"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"payoutNumerators","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"QuestionID","name":"","type":"bytes32"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"prepareCondition","outputs":[{"internalType":"ConditionID","name":"","type":"bytes32"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"QuestionID","name":"","type":"bytes32"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bytes","name":"","type":"bytes"},{"internalType":"uint32","name":"","type":"uint32"}],"name":"prepareConditionByOracle","outputs":[{"internalType":"ConditionID","name":"","type":"bytes32"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"legOracle","type":"address"},{"internalType":"uint256","name":"legQuestionIdMask","type":"uint256"},{"components":[{"internalType":"QuestionID[]","name":"questionIds","type":"bytes32[]"},{"internalType":"uint256[]","name":"indices","type":"uint256[]"},{"internalType":"uint256[]","name":"outcomeSlotCounts","type":"uint256[]"}],"internalType":"struct ParlayLegs","name":"legs","type":"tuple"}],"name":"prepareParlayCondition","outputs":[{"internalType":"QuestionID","name":"parlayQuestionId","type":"bytes32"},{"internalType":"ConditionID","name":"parlayConditionId","type":"bytes32"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"ConditionID","name":"","type":"bytes32"}],"name":"priceStorage","outputs":[{"internalType":"address","name":"conditionOracle","type":"address"},{"internalType":"uint32","name":"haltTime","type":"uint32"},{"internalType":"bytes","name":"packedPrices","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"proxiableUUID","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"collateralToken","type":"address"},{"internalType":"ConditionID[]","name":"conditionIds","type":"bytes32[]"},{"internalType":"uint256[]","name":"indices","type":"uint256[]"}],"name":"redeemAll","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"ownerAndReceiver","type":"address"},{"internalType":"contract IERC20","name":"collateralToken","type":"address"},{"internalType":"ConditionID[]","name":"conditionIds","type":"bytes32[]"},{"internalType":"uint256[]","name":"indices","type":"uint256[]"}],"name":"redeemAllOf","outputs":[{"internalType":"uint256","name":"totalPayout","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"receiver","type":"address"},{"internalType":"contract IERC20","name":"collateralToken","type":"address"},{"internalType":"ConditionID","name":"conditionId","type":"bytes32"},{"internalType":"uint256[]","name":"indices","type":"uint256[]"},{"internalType":"uint256[]","name":"quantities","type":"uint256[]"}],"name":"redeemPositionsFor","outputs":[{"internalType":"uint256","name":"totalPayout","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"QuestionID","name":"parlayQuestionId","type":"bytes32"}],"name":"reportParlayPayouts","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"QuestionID","name":"questionId","type":"bytes32"},{"internalType":"uint256[]","name":"payouts","type":"uint256[]"}],"name":"reportPayouts","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256[]","name":"ids","type":"uint256[]"},{"internalType":"uint256[]","name":"amounts","type":"uint256[]"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"safeBatchTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"uint256","name":"amount","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":[{"internalType":"contract IERC20","name":"token","type":"address"},{"internalType":"bool","name":"approved","type":"bool"}],"name":"setERC20Whitelist","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"collateralToken","type":"address"},{"internalType":"ConditionID","name":"conditionId","type":"bytes32"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"splitPosition","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"ConditionID","name":"","type":"bytes32"},{"internalType":"bytes","name":"","type":"bytes"}],"name":"updateFairPrices","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"ConditionID","name":"","type":"bytes32"},{"internalType":"uint32","name":"","type":"uint32"}],"name":"updateHaltTime","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"newImplementation","type":"address"}],"name":"upgradeTo","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newImplementation","type":"address"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"upgradeToAndCall","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"uri","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"}]
Contract Creation Code
60a0604052306080523480156200001557600080fd5b506200002062000026565b620000e8565b600054610100900460ff1615620000935760405162461bcd60e51b815260206004820152602760248201527f496e697469616c697a61626c653a20636f6e747261637420697320696e697469604482015266616c697a696e6760c81b606482015260840160405180910390fd5b60005460ff9081161015620000e6576000805460ff191660ff9081179091556040519081527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b565b608051615a366200012060003960008181610e8001528181610f05015281816111af0152818161123401526113520152615a366000f3fe6080604052600436106103495760003560e01c806377309dbe116101bb578063d54a70e8116100f7578063ee973c5111610095578063f2fde38b1161006f578063f2fde38b14610a28578063f9e2b91214610a48578063fb629de514610a68578063fbdd125514610a9d57600080fd5b8063ee973c51146109bc578063f0dded2f146109d7578063f242432a14610a0857600080fd5b8063dd34de67116100d1578063dd34de67146108fa578063de61ece114610928578063e985e9c514610958578063edf0374f146109a157600080fd5b8063d54a70e81461088c578063d96ee754146108ba578063dd142562146108da57600080fd5b8063babf954e11610164578063c49298ac1161013e578063c49298ac146107fe578063c4d66de81461081e578063c87e50091461083e578063d42dc0c21461085e57600080fd5b8063babf954e1461079e578063bafce2dd146107be578063c0f0ec5e146107de57600080fd5b8063a1e7b67e11610195578063a1e7b67e1461073e578063a22cb4651461075e578063b76071a11461077e57600080fd5b806377309dbe146106d1578063852c6ae2146107005780638da5cb5b1461072057600080fd5b80634e1273f41161028a5780635673515811610233578063604d66de1161020d578063604d66de1461064d578063715018a61461066d57806371b3a2301461068257806371ec7eb3146106b057600080fd5b806356735158146105ed57806357ad06301461060d5780635dc7397d1461062d57600080fd5b806352d1902d1161026457806352d1902d146105a357806353f446c1146105b857806354e4cc84146105d857600080fd5b80634e1273f4146105435780634f1ef2861461057057806352cfba861461058357600080fd5b8063289ab7e2116102f75780633659cfe6116102d15780633659cfe6146104c857806338e8789b146104e857806339dd75301461050857806346e303801461052857600080fd5b8063289ab7e2146104585780632eb2c2d61461048d57806330d3df2b146104ad57600080fd5b80630e89341c116103285780630e89341c146103d15780631071844a146103fe578063189e96e21461043657600080fd5b8062fdd58e1461034e57806301ffc9a7146103815780630504c814146103b1575b600080fd5b34801561035a57600080fd5b5061036e6103693660046146ec565b610abd565b6040519081526020015b60405180910390f35b34801561038d57600080fd5b506103a161039c36600461472e565b610b58565b6040519015158152602001610378565b3480156103bd57600080fd5b5061036e6103cc36600461474b565b610bb3565b3480156103dd57600080fd5b506103f16103ec36600461476d565b610be5565b60405161037891906147d6565b34801561040a57600080fd5b5061041e61041936600461476d565b610c79565b6040516001600160a01b039091168152602001610378565b34801561044257600080fd5b50610456610451366004614835565b610c94565b005b34801561046457600080fd5b50610478610473366004614877565b610cad565b60408051928352602083019190915201610378565b34801561049957600080fd5b506104566104a8366004614a23565b610de3565b3480156104b957600080fd5b50610456610451366004614aea565b3480156104d457600080fd5b506104566104e3366004614b16565b610e76565b3480156104f457600080fd5b5061036e610503366004614b33565b610ff1565b34801561051457600080fd5b5061036e6105233660046146ec565b611030565b34801561053457600080fd5b5061036e610419366004614c01565b34801561054f57600080fd5b5061056361055e366004614c69565b61107b565b6040516103789190614d71565b61045661057e366004614d84565b6111a5565b34801561058f57600080fd5b5061045661059e366004614dd8565b611311565b3480156105af57600080fd5b5061036e611345565b3480156105c457600080fd5b506104566105d3366004614835565b61140b565b3480156105e457600080fd5b5061036e600981565b3480156105f957600080fd5b5061036e610608366004614e11565b61144e565b34801561061957600080fd5b5061045661062836600461476d565b611661565b34801561063957600080fd5b5061036e61064836600461476d565b611759565b34801561065957600080fd5b50610563610668366004614e87565b611768565b34801561067957600080fd5b50610456611867565b34801561068e57600080fd5b506106a261069d366004614e87565b61187b565b604051610378929190614ec8565b3480156106bc57600080fd5b506101615461041e906001600160a01b031681565b3480156106dd57600080fd5b506106f16106ec36600461476d565b61189e565b60405161037893929190614eed565b34801561070c57600080fd5b5061036e61071b366004614f1b565b61196e565b34801561072c57600080fd5b5060fb546001600160a01b031661041e565b34801561074a57600080fd5b5061036e61075936600461474b565b611983565b34801561076a57600080fd5b50610456610779366004614dd8565b6119b3565b34801561078a57600080fd5b50610456610799366004614f50565b6119be565b3480156107aa57600080fd5b506105636107b93660046146ec565b6119d4565b3480156107ca57600080fd5b506104566107d9366004614f1b565b611a7d565b3480156107ea57600080fd5b506104566107f9366004614fd3565b611c58565b34801561080a57600080fd5b5061045661081936600461504e565b611c71565b34801561082a57600080fd5b50610456610839366004614b16565b611d52565b34801561084a57600080fd5b5061036e61085936600461509a565b611e8e565b34801561086a57600080fd5b5061036e61087936600461476d565b600090815261012d602052604090205490565b34801561089857600080fd5b506108ac6108a736600461476d565b611ff2565b604051610378929190615139565b3480156108c657600080fd5b5061036e6108d5366004614f1b565b612065565b3480156108e657600080fd5b506104566108f5366004614f1b565b612080565b34801561090657600080fd5b5061036e61091536600461476d565b61012e6020526000908152604090205481565b34801561093457600080fd5b506103a161094336600461476d565b600090815261012e6020526040902054151590565b34801561096457600080fd5b506103a161097336600461515b565b6001600160a01b03918216600090815260ca6020908152604080832093909416825291909152205460ff1690565b3480156109ad57600080fd5b50610456610451366004615189565b3480156109c857600080fd5b506104566104513660046151fe565b3480156109e357600080fd5b506103a16109f2366004614b16565b61012f6020526000908152604090205460ff1681565b348015610a1457600080fd5b50610456610a2336600461523d565b61229a565b348015610a3457600080fd5b50610456610a43366004614b16565b612326565b348015610a5457600080fd5b506103a1610a6336600461476d565b61239c565b348015610a7457600080fd5b50610a88610a8336600461476d565b6124b9565b60405163ffffffff9091168152602001610378565b348015610aa957600080fd5b50610563610ab836600461476d565b612538565b60006001600160a01b038316610b2d5760405162461bcd60e51b815260206004820152602a60248201527f455243313135353a2061646472657373207a65726f206973206e6f742061207660448201526930b634b21037bbb732b960b11b60648201526084015b60405180910390fd5b50600081815260c9602090815260408083206001600160a01b03861684529091529020545b92915050565b60006001600160e01b0319821663219bfdad60e11b1480610b8957506001600160e01b0319821663306da52d60e01b145b80610ba457506001600160e01b031982166349ecb6f560e01b145b80610b525750610b52826125c6565b61012d6020528160005260406000208181548110610bd057600080fd5b90600052602060002001600091509150505481565b606060cb8054610bf4906152a6565b80601f0160208091040260200160405190810160405280929190818152602001828054610c20906152a6565b8015610c6d5780601f10610c4257610100808354040283529160200191610c6d565b820191906000526020600020905b815481529060010190602001808311610c5057829003601f168201915b50505050509050919050565b60006040516356e7318960e11b815260040160405180910390fd5b6040516356e7318960e11b815260040160405180910390fd5b600080610ccc85610cbe85806152e0565b8761050360208901896152e0565b9150610cdb6000836003612616565b6000818152610162602052604081205491925003610ddb576000610d00868686612777565b90506040518060400160405280828152602001610d5d868060200190610d2691906152e0565b80806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250612b4e92505050565b9052600083815261016260209081526040909120825180519192610d8692849290910190614677565b5060208201518160010155905050856001600160a01b031683837f29f41f0b880379a7c7fff68b869c29160e819340ea2b60c7bbba71ababa54d348888604051610dd19291906153ea565b60405180910390a4505b935093915050565b6001600160a01b038516331480610dff5750610dff8533610973565b610e625760405162461bcd60e51b815260206004820152602e60248201527f455243313135353a2063616c6c6572206973206e6f7420746f6b656e206f776e60448201526d195c881bdc88185c1c1c9bdd995960921b6064820152608401610b24565b610e6f8585858585612bab565b5050505050565b6001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000163003610f035760405162461bcd60e51b815260206004820152602c60248201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060448201526b19195b1959d85d1958d85b1b60a21b6064820152608401610b24565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316610f5e7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b6001600160a01b031614610fc95760405162461bcd60e51b815260206004820152602c60248201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060448201526b6163746976652070726f787960a01b6064820152608401610b24565b610fd281612e04565b60408051600080825260208201909252610fee91839190612e0c565b50565b600086868686868660405160200161100e96959493929190615466565b6040516020818303038152906040528051906020012090509695505050505050565b60408051606084901b6bffffffffffffffffffffffff1916602080830191909152603480830185905283518084039091018152605490920190925280519101206000905b9392505050565b606081518351146110e05760405162461bcd60e51b815260206004820152602960248201527f455243313135353a206163636f756e747320616e6420696473206c656e677468604482015268040dad2e6dac2e8c6d60bb1b6064820152608401610b24565b6000835167ffffffffffffffff8111156110fc576110fc6148d7565b604051908082528060200260200182016040528015611125578160200160208202803683370190505b50905060005b845181101561119d57611170858281518110611149576111496154af565b6020026020010151858381518110611163576111636154af565b6020026020010151610abd565b828281518110611182576111826154af565b6020908102919091010152611196816154db565b905061112b565b509392505050565b6001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001630036112325760405162461bcd60e51b815260206004820152602c60248201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060448201526b19195b1959d85d1958d85b1b60a21b6064820152608401610b24565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031661128d7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b6001600160a01b0316146112f85760405162461bcd60e51b815260206004820152602c60248201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060448201526b6163746976652070726f787960a01b6064820152608401610b24565b61130182612e04565b61130d82826001612e0c565b5050565b611319612f98565b6001600160a01b0391909116600090815261012f60205260409020805460ff1916911515919091179055565b6000306001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016146113e55760405162461bcd60e51b815260206004820152603860248201527f555550535570677261646561626c653a206d757374206e6f742062652063616c60448201527f6c6564207468726f7567682064656c656761746563616c6c00000000000000006064820152608401610b24565b507f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5b90565b60005b818110156114495761143783838381811061142b5761142b6154af565b90506020020135611661565b80611441816154db565b91505061140e565b505050565b6000838214611470576040516363df817160e01b815260040160405180910390fd5b6040805160018082528183019092526000918291906020808301908036833701905050905060005b868110156116195760008888838181106114b4576114b46154af565b90506020020135905060008787848181106114d1576114d16154af565b90506020020135905060006115598c6115118585604080516020808201949094528082019290925280518083038201815260609092019052805191012090565b6040516bffffffffffffffffffffffff19606084901b1660208201526034810182905260009060540160408051601f1981840301815291905280516020909101209392505050565b905060006115678e83610abd565b905061157381886154f4565b965060006115848f84878786612ff2565b9050611590818a6154f4565b985083876000815181106115a6576115a66154af565b6020026020010181815250508d6001600160a01b03168f6001600160a01b03167f21336e17fc856aa5e53e3b01d2deceb8e0609196d2756d9463463478727d81e9878a856040516115f993929190615507565b60405180910390a350505050508080611611906154db565b915050611498565b508160000361163b576040516302bc6d3360e01b815260040160405180910390fd5b8215611655576116556001600160a01b0389168a856130c7565b50509695505050505050565b600061166c82611759565b600081815261012d602052604090205490915060031461169f5760405163a1154ec560e01b815260040160405180910390fd5b600081815261012e6020526040902054156116b8575050565b60008181526101626020526040808220610161546001820154925163272ae24560e11b815291939283926001600160a01b0390921691634e55c48a9161170391879190600401615565565b600060405180830381865afa158015611720573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261174891908101906155de565b91509150610e6f600086848461312a565b6000610b52600083600361325b565b600081815261012d602052604081205460609181900361179b5760405163a1154ec560e01b815260040160405180910390fd5b60008167ffffffffffffffff8111156117b6576117b66148d7565b6040519080825280602002602001820160405280156117df578160200160208202803683370190505b50905060005b8281101561185d5760408051602080820188905281830184905282518083038401815260609092019092528051910120600090611823908890611511565b905061182f8882610abd565b838381518110611841576118416154af565b602090810291909101015250611856816154db565b90506117e5565b5095945050505050565b61186f612f98565b61187960006132ba565b565b606080611889858585611768565b915061189483612538565b9050935093915050565b61013060205260009081526040902080546001820180546001600160a01b038316937401000000000000000000000000000000000000000090930463ffffffff169291906118eb906152a6565b80601f0160208091040260200160405190810160405280929190818152602001828054611917906152a6565b80156119645780601f1061193957610100808354040283529160200191611964565b820191906000526020600020905b81548152906001019060200180831161194757829003601f168201915b5050505050905083565b600061197b84848461325b565b949350505050565b60408051602080820185905281830184905282518083038401815260609092019092528051910120600090611074565b61130d33838361330c565b6119cc33868686868661144e565b505050505050565b600081815261012d60205260408120546060918167ffffffffffffffff811115611a0057611a006148d7565b604051908082528060200260200182016040528015611a29578160200160208202803683370190505b50905060005b82811015611a7457611a45866115118784611983565b828281518110611a5757611a576154af565b602090810291909101015280611a6c816154db565b915050611a2f565b50949350505050565b80600003611a9e5760405163162908e360e11b815260040160405180910390fd5b600082815261012d602052604081205490819003611acf5760405163a1154ec560e01b815260040160405180910390fd5b60008167ffffffffffffffff811115611aea57611aea6148d7565b604051908082528060200260200182016040528015611b13578160200160208202803683370190505b50905060008267ffffffffffffffff811115611b3157611b316148d7565b604051908082528060200260200182016040528015611b5a578160200160208202803683370190505b50905060005b83811015611be95760408051602080820189905281830184905282518083038401815260609092019092528051910120611b9b908890611511565b838281518110611bad57611bad6154af565b60200260200101818152505084828281518110611bcc57611bcc6154af565b602090810291909101015280611be1816154db565b915050611b60565b50611bf53383836133ec565b611c096001600160a01b03871633866130c7565b604080516001600160a01b038816815260208101869052869133917fd1034db24aaa2750c79ef3a96a2ffd9fd4b48f900ef4f4f7b6c024053a528a4c91015b60405180910390a3505050505050565b60405163c45f4b3960e01b815260040160405180910390fd5b8060008167ffffffffffffffff811115611c8d57611c8d6148d7565b604051908082528060200260200182016040528015611cb6578160200160208202803683370190505b5090506000805b83811015611d21576000868683818110611cd957611cd96154af565b9050602002013590508083611cee91906154f4565b925080848381518110611d0357611d036154af565b60209081029190910101525080611d19816154db565b915050611cbd565b50612710811115611d455760405163a9a21e6d60e01b815260040160405180910390fd5b6119cc600087848461312a565b600054610100900460ff1615808015611d725750600054600160ff909116105b80611d8c5750303b158015611d8c575060005460ff166001145b611dfe5760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201527f647920696e697469616c697a65640000000000000000000000000000000000006064820152608401610b24565b6000805460ff191660011790558015611e21576000805461ff0019166101001790555b611e29613632565b61016180546001600160a01b0319166001600160a01b038416179055801561130d576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15050565b6000838214611eb057604051630d800f7960e41b815260040160405180910390fd5b50600033815b85811015611f6c576000611f0d8a6115118b8b8b87818110611eda57611eda6154af565b90506020020135604080516020808201949094528082019290925280518083038201815260609092019052805191012090565b9050611f4c83828b8b8b87818110611f2757611f276154af565b905060200201358a8a88818110611f4057611f406154af565b90506020020135612ff2565b611f5690856154f4565b9350508080611f64906154db565b915050611eb6565b50876001600160a01b0316816001600160a01b03168a6001600160a01b03167f84c687ba62d65c1a78e95c861b268d3432f950ac6672b211c145a85cdc3992028a8a8a8a8a8a604051611fc496959493929190615625565b60405180910390a48115611fe657611fe66001600160a01b0389168a846130c7565b50979650505050505050565b600081815261012d6020908152604080832080548251818502810185019093528083526060949383018282801561204857602002820191906000526020600020905b815481526020019060010190808311612034575b5050506000958652505061012e6020526040909320549293915050565b600060405163c45f4b3960e01b815260040160405180910390fd5b806000036120a15760405163162908e360e11b815260040160405180910390fd5b6001600160a01b038316600090815261012f602052604090205460ff166120db57604051630eca12dd60e31b815260040160405180910390fd5b600082815261012d60205260408120549081900361210c5760405163a1154ec560e01b815260040160405180910390fd5b60008167ffffffffffffffff811115612127576121276148d7565b604051908082528060200260200182016040528015612150578160200160208202803683370190505b50905060008267ffffffffffffffff81111561216e5761216e6148d7565b604051908082528060200260200182016040528015612197578160200160208202803683370190505b50905060005b8381101561222657604080516020808201899052818301849052825180830384018152606090920190925280519101206121d8908890611511565b8382815181106121ea576121ea6154af565b60200260200101818152505084828281518110612209576122096154af565b60209081029190910101528061221e816154db565b91505061219d565b5061223c6001600160a01b0387163330876136cd565b61225733838360405180602001604052806000815250613705565b604080516001600160a01b038816815260208101869052869133917fad6a73f49492e69122c9865dd7b0f401d9f90300928019d02755f11b049c93b39101611c48565b6001600160a01b0385163314806122b657506122b68533610973565b6123195760405162461bcd60e51b815260206004820152602e60248201527f455243313135353a2063616c6c6572206973206e6f7420746f6b656e206f776e60448201526d195c881bdc88185c1c1c9bdd995960921b6064820152608401610b24565b610e6f85858585856138cc565b61232e612f98565b6001600160a01b0381166123935760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610b24565b610fee816132ba565b600081815261016260209081526040808320805482518185028101850190935280835284938301828280156123f057602002820191906000526020600020905b8154815260200190600101908083116123dc575b5050505050905060005b815181108015612408575082155b156124b2576101615482516001600160a01b039091169063f9e2b91290849084908110612437576124376154af565b60200260200101516040518263ffffffff1660e01b815260040161245d91815260200190565b602060405180830381865afa15801561247a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061249e9190615666565b9250806124aa816154db565b9150506123fa565b5050919050565b610161546000828152610162602052604080822090516337e545fd60e11b815291926001600160a01b031691636fca8bfa916124f791600401615683565b602060405180830381865afa158015612514573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b529190615696565b60008181526101626020526040908190206101615460018201549251632759f5cb60e01b81526060936001600160a01b0390921691632759f5cb91612581918591600401615565565b600060405180830381865afa15801561259e573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261107491908101906156af565b60006001600160e01b03198216636cdb3d1360e11b14806125f757506001600160e01b031982166303a24d0760e21b145b80610b5257506301ffc9a760e01b6001600160e01b0319831614610b52565b60006002821080612627575060ff82115b1561264557604051636995da1b60e01b815260040160405180910390fd5b600061265285858561325b565b600081815261012d60205260408120549192500361197b578267ffffffffffffffff811115612683576126836148d7565b6040519080825280602002602001820160405280156126ac578160200160208202803683370190505b50600082815261012d6020908152604090912082516126d19391929190910190614677565b50600081815261013060205260409081902080547fffffffffffffffff000000000000000000000000000000000000000000000000166001600160a01b03881690811777ffffffff000000000000000000000000000000000000000017909155905185919083907fab3760c3bd2bb38b5bcf54dc79802ed67338b4cf29f3054ded67ed24661e4177906127679088815260200190565b60405180910390a4949350505050565b6060600061278860208401846152e0565b905061279484806152e0565b90501415806127bc57506127ab60408401846152e0565b90506127b784806152e0565b905014155b806127d2575060016127ce84806152e0565b9050105b905080156127f357604051630e58291160e31b815260040160405180910390fd5b5061016154600090612815906001600160a01b031663306da52d60e01b613a7b565b801561283a57506101615461283a906001600160a01b03166306c6babb60e01b613a7b565b90508061286a57610161546040516365d593c560e11b81526001600160a01b039091166004820152602401610b24565b50600961287783806152e0565b905011156128985760405163ecc2d2d160e01b815260040160405180910390fd5b826000036128b95760405163038c11f960e51b815260040160405180910390fd5b60006128c583806152e0565b905067ffffffffffffffff8111156128df576128df6148d7565b604051908082528060200260200182016040528015612908578160200160208202803683370190505b50915060005b61291884806152e0565b9050811015612b4557600061293060408601866152e0565b83818110612940576129406154af565b90506020020135905060018161295691906156e4565b61296360208701876152e0565b84818110612973576129736154af565b9050602002013510612998576040516363df817160e01b815260040160405180910390fd5b60006129a486806152e0565b848181106129b4576129b46154af565b60200291909101359150508681168481116129e257604051630670e21160e01b815260040160405180910390fd5b80945060006129f28a848661325b565b61016154604051636a16e06160e11b81526004810183905291925085916001600160a01b039091169063d42dc0c290602401602060405180830381865afa158015612a41573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a659190615696565b14612a835760405163a1154ec560e01b815260040160405180910390fd5b6101615460405163de61ece160e01b8152600481018390526001600160a01b039091169063de61ece190602401602060405180830381865afa158015612acd573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612af19190615666565b15612b0f576040516398d2ea1160e01b815260040160405180910390fd5b80878681518110612b2257612b226154af565b602002602001018181525050505050508080612b3d906154db565b91505061290e565b50509392505050565b80516000908190815b81811015612ba2576000858281518110612b7357612b736154af565b6020026020010151905060ff8016811115612b9057612b906156f7565b600882021b9290921791600101612b57565b50909392505050565b8151835114612c0d5760405162461bcd60e51b815260206004820152602860248201527f455243313135353a2069647320616e6420616d6f756e7473206c656e677468206044820152670dad2e6dac2e8c6d60c31b6064820152608401610b24565b6001600160a01b038416612c715760405162461bcd60e51b815260206004820152602560248201527f455243313135353a207472616e7366657220746f20746865207a65726f206164604482015264647265737360d81b6064820152608401610b24565b3360005b8451811015612d9e576000858281518110612c9257612c926154af565b602002602001015190506000858381518110612cb057612cb06154af565b602090810291909101810151600084815260c9835260408082206001600160a01b038e168352909352919091205490915081811015612d445760405162461bcd60e51b815260206004820152602a60248201527f455243313135353a20696e73756666696369656e742062616c616e636520666f60448201526939103a3930b739b332b960b11b6064820152608401610b24565b600083815260c9602090815260408083206001600160a01b038e8116855292528083208585039055908b16825281208054849290612d839084906154f4565b9250508190555050505080612d97906154db565b9050612c75565b50846001600160a01b0316866001600160a01b0316826001600160a01b03167f4a39dc06d4c0dbc64b70af90fd698a233a518aa5d07e595d983b8c0526c8f7fb8787604051612dee929190614ec8565b60405180910390a46119cc818787878787613a97565b610fee612f98565b7f4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd91435460ff1615612e3f5761144983613c45565b826001600160a01b03166352d1902d6040518163ffffffff1660e01b8152600401602060405180830381865afa925050508015612e99575060408051601f3d908101601f19168201909252612e9691810190615696565b60015b612f0b5760405162461bcd60e51b815260206004820152602e60248201527f45524331393637557067726164653a206e657720696d706c656d656e7461746960448201527f6f6e206973206e6f7420555550530000000000000000000000000000000000006064820152608401610b24565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc8114612f8c5760405162461bcd60e51b815260206004820152602960248201527f45524331393637557067726164653a20756e737570706f727465642070726f786044820152681a58589b195555525160ba1b6064820152608401610b24565b50611449838383613d03565b60fb546001600160a01b031633146118795760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610b24565b600083815261012e602052604081205480820361302257604051630cb95b4560e31b815260040160405180910390fd5b600085815261012d602052604081205490819003613042576130426156f7565b808510613062576040516363df817160e01b815260040160405180910390fd5b600086815261012d60205260408120805487908110613083576130836154af565b9060005260206000200154905060008511156130bb57826130a4828761570d565b6130ae9190615724565b93506130bb898987613d28565b50505095945050505050565b6040516001600160a01b03831660248201526044810182905261144990849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152613ea7565b815160018111158061313c575060ff81115b1561315a57604051636995da1b60e01b815260040160405180910390fd5b600061316786868461325b565b600081815261012d602052604090205490915082146131995760405163a1154ec560e01b815260040160405180910390fd5b826000036131ba5760405163f82a70fb60e01b815260040160405180910390fd5b600081815261012e6020526040902054156131d6575050613255565b600081815261012d6020908152604090912085516131f692870190614677565b50600081815261012e6020526040908190208490555185906001600160a01b0388169083907fb44d84d3289691f71497564b85d4233648d9dbae8cbdbb4329f301c3a01858949061324a9087908a90615746565b60405180910390a450505b50505050565b6000610101821061326e5761326e6156f7565b6040516bffffffffffffffffffffffff19606086901b16602082015260348101849052605481018390526074016040516020818303038152906040528051906020012090509392505050565b60fb80546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b816001600160a01b0316836001600160a01b03160361337f5760405162461bcd60e51b815260206004820152602960248201527f455243313135353a2073657474696e6720617070726f76616c20737461747573604482015268103337b91039b2b63360b91b6064820152608401610b24565b6001600160a01b03838116600081815260ca6020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b6001600160a01b03831661344e5760405162461bcd60e51b815260206004820152602360248201527f455243313135353a206275726e2066726f6d20746865207a65726f206164647260448201526265737360e81b6064820152608401610b24565b80518251146134b05760405162461bcd60e51b815260206004820152602860248201527f455243313135353a2069647320616e6420616d6f756e7473206c656e677468206044820152670dad2e6dac2e8c6d60c31b6064820152608401610b24565b604080516020810190915260009081905233905b83518110156135c55760008482815181106134e1576134e16154af565b6020026020010151905060008483815181106134ff576134ff6154af565b602090810291909101810151600084815260c9835260408082206001600160a01b038c16835290935291909120549091508181101561358c5760405162461bcd60e51b8152602060048201526024808201527f455243313135353a206275726e20616d6f756e7420657863656564732062616c604482015263616e636560e01b6064820152608401610b24565b600092835260c9602090815260408085206001600160a01b038b16865290915290922091039055806135bd816154db565b9150506134c4565b5060006001600160a01b0316846001600160a01b0316826001600160a01b03167f4a39dc06d4c0dbc64b70af90fd698a233a518aa5d07e595d983b8c0526c8f7fb8686604051613616929190614ec8565b60405180910390a4604080516020810190915260009052613255565b600054610100900460ff1661369d5760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b6064820152608401610b24565b6136b560405180602001604052806000815250613f79565b6136bd613fed565b6136c5614060565b611879614060565b6040516001600160a01b03808516602483015283166044820152606481018290526132559085906323b872dd60e01b906084016130f3565b6001600160a01b0384166137655760405162461bcd60e51b815260206004820152602160248201527f455243313135353a206d696e7420746f20746865207a65726f206164647265736044820152607360f81b6064820152608401610b24565b81518351146137c75760405162461bcd60e51b815260206004820152602860248201527f455243313135353a2069647320616e6420616d6f756e7473206c656e677468206044820152670dad2e6dac2e8c6d60c31b6064820152608401610b24565b3360005b8451811015613864578381815181106137e6576137e66154af565b602002602001015160c96000878481518110613804576138046154af565b602002602001015181526020019081526020016000206000886001600160a01b03166001600160a01b03168152602001908152602001600020600082825461384c91906154f4565b9091555081905061385c816154db565b9150506137cb565b50846001600160a01b031660006001600160a01b0316826001600160a01b03167f4a39dc06d4c0dbc64b70af90fd698a233a518aa5d07e595d983b8c0526c8f7fb87876040516138b5929190614ec8565b60405180910390a4610e6f81600087878787613a97565b6001600160a01b0384166139305760405162461bcd60e51b815260206004820152602560248201527f455243313135353a207472616e7366657220746f20746865207a65726f206164604482015264647265737360d81b6064820152608401610b24565b33600061393c856140cb565b90506000613949856140cb565b9050600086815260c9602090815260408083206001600160a01b038c168452909152902054858110156139d15760405162461bcd60e51b815260206004820152602a60248201527f455243313135353a20696e73756666696369656e742062616c616e636520666f60448201526939103a3930b739b332b960b11b6064820152608401610b24565b600087815260c9602090815260408083206001600160a01b038d8116855292528083208985039055908a16825281208054889290613a109084906154f4565b909155505060408051888152602081018890526001600160a01b03808b16928c821692918816917fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f62910160405180910390a4613a70848a8a8a8a8a614116565b505050505050505050565b6000613a8683614212565b801561107457506110748383614245565b6001600160a01b0384163b156119cc5760405163bc197c8160e01b81526001600160a01b0385169063bc197c8190613adb908990899088908890889060040161575f565b6020604051808303816000875af1925050508015613b16575060408051601f3d908101601f19168201909252613b13918101906157bd565b60015b613bcb57613b226157da565b806308c379a003613b5b5750613b366157f5565b80613b415750613b5d565b8060405162461bcd60e51b8152600401610b2491906147d6565b505b60405162461bcd60e51b815260206004820152603460248201527f455243313135353a207472616e7366657220746f206e6f6e2d4552433131353560448201527f526563656976657220696d706c656d656e7465720000000000000000000000006064820152608401610b24565b6001600160e01b0319811663bc197c8160e01b14613c3c5760405162461bcd60e51b815260206004820152602860248201527f455243313135353a204552433131353552656365697665722072656a656374656044820152676420746f6b656e7360c01b6064820152608401610b24565b50505050505050565b6001600160a01b0381163b613cc25760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201527f6f74206120636f6e7472616374000000000000000000000000000000000000006064820152608401610b24565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc80546001600160a01b0319166001600160a01b0392909216919091179055565b613d0c836142ce565b600082511180613d195750805b1561144957613255838361430e565b6001600160a01b038316613d8a5760405162461bcd60e51b815260206004820152602360248201527f455243313135353a206275726e2066726f6d20746865207a65726f206164647260448201526265737360e81b6064820152608401610b24565b336000613d96846140cb565b90506000613da3846140cb565b604080516020808201835260009182905288825260c981528282206001600160a01b038b1683529052205490915084811015613e2d5760405162461bcd60e51b8152602060048201526024808201527f455243313135353a206275726e20616d6f756e7420657863656564732062616c604482015263616e636560e01b6064820152608401610b24565b600086815260c9602090815260408083206001600160a01b038b81168086529184528285208a8703905582518b81529384018a90529092908816917fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f62910160405180910390a4604080516020810190915260009052613c3c565b6000613efc826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166144029092919063ffffffff16565b8051909150156114495780806020019051810190613f1a9190615666565b6114495760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610b24565b600054610100900460ff16613fe45760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b6064820152608401610b24565b610fee81614411565b600054610100900460ff166140585760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b6064820152608401610b24565b611879614485565b600054610100900460ff166118795760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b6064820152608401610b24565b60408051600180825281830190925260609160009190602080830190803683370190505090508281600081518110614105576141056154af565b602090810291909101015292915050565b6001600160a01b0384163b156119cc5760405163f23a6e6160e01b81526001600160a01b0385169063f23a6e619061415a908990899088908890889060040161587f565b6020604051808303816000875af1925050508015614195575060408051601f3d908101601f19168201909252614192918101906157bd565b60015b6141a157613b226157da565b6001600160e01b0319811663f23a6e6160e01b14613c3c5760405162461bcd60e51b815260206004820152602860248201527f455243313135353a204552433131353552656365697665722072656a656374656044820152676420746f6b656e7360c01b6064820152608401610b24565b6000614225826301ffc9a760e01b614245565b8015610b52575061423e826001600160e01b0319614245565b1592915050565b604080516001600160e01b03198316602480830191909152825180830390910181526044909101909152602080820180516001600160e01b03166301ffc9a760e01b178152825160009392849283928392918391908a617530fa92503d915060005190508280156142b7575060208210155b80156142c35750600081115b979650505050505050565b6142d781613c45565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b60606001600160a01b0383163b6143765760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b6064820152608401610b24565b600080846001600160a01b03168460405161439191906158b7565b600060405180830381855af49150503d80600081146143cc576040519150601f19603f3d011682016040523d82523d6000602084013e6143d1565b606091505b50915091506143f982826040518060600160405280602781526020016159da602791396144f9565b95945050505050565b606061197b8484600085614512565b600054610100900460ff1661447c5760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b6064820152608401610b24565b610fee816145e2565b600054610100900460ff166144f05760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b6064820152608401610b24565b611879336132ba565b60608315614508575081611074565b61107483836145ee565b6060824710156145735760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401610b24565b600080866001600160a01b0316858760405161458f91906158b7565b60006040518083038185875af1925050503d80600081146145cc576040519150601f19603f3d011682016040523d82523d6000602084013e6145d1565b606091505b50915091506142c3878383876145fe565b60cb61130d8282615919565b815115613b415781518083602001fd5b6060831561466d578251600003614666576001600160a01b0385163b6146665760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610b24565b508161197b565b61197b83836145ee565b8280548282559060005260206000209081019282156146b2579160200282015b828111156146b2578251825591602001919060010190614697565b506146be9291506146c2565b5090565b5b808211156146be57600081556001016146c3565b6001600160a01b0381168114610fee57600080fd5b600080604083850312156146ff57600080fd5b823561470a816146d7565b946020939093013593505050565b6001600160e01b031981168114610fee57600080fd5b60006020828403121561474057600080fd5b813561107481614718565b6000806040838503121561475e57600080fd5b50508035926020909101359150565b60006020828403121561477f57600080fd5b5035919050565b60005b838110156147a1578181015183820152602001614789565b50506000910152565b600081518084526147c2816020860160208601614786565b601f01601f19169290920160200192915050565b60208152600061107460208301846147aa565b60008083601f8401126147fb57600080fd5b50813567ffffffffffffffff81111561481357600080fd5b6020830191508360208260051b850101111561482e57600080fd5b9250929050565b6000806020838503121561484857600080fd5b823567ffffffffffffffff81111561485f57600080fd5b61486b858286016147e9565b90969095509350505050565b60008060006060848603121561488c57600080fd5b8335614897816146d7565b925060208401359150604084013567ffffffffffffffff8111156148ba57600080fd5b8401606081870312156148cc57600080fd5b809150509250925092565b634e487b7160e01b600052604160045260246000fd5b601f8201601f1916810167ffffffffffffffff81118282101715614913576149136148d7565b6040525050565b600067ffffffffffffffff821115614934576149346148d7565b5060051b60200190565b600082601f83011261494f57600080fd5b8135602061495c8261491a565b60405161496982826148ed565b83815260059390931b850182019282810191508684111561498957600080fd5b8286015b848110156149a4578035835291830191830161498d565b509695505050505050565b600082601f8301126149c057600080fd5b813567ffffffffffffffff8111156149da576149da6148d7565b6040516149f1601f8301601f1916602001826148ed565b818152846020838601011115614a0657600080fd5b816020850160208301376000918101602001919091529392505050565b600080600080600060a08688031215614a3b57600080fd5b8535614a46816146d7565b94506020860135614a56816146d7565b9350604086013567ffffffffffffffff80821115614a7357600080fd5b614a7f89838a0161493e565b94506060880135915080821115614a9557600080fd5b614aa189838a0161493e565b93506080880135915080821115614ab757600080fd5b50614ac4888289016149af565b9150509295509295909350565b803563ffffffff81168114614ae557600080fd5b919050565b60008060408385031215614afd57600080fd5b82359150614b0d60208401614ad1565b90509250929050565b600060208284031215614b2857600080fd5b8135611074816146d7565b60008060008060008060808789031215614b4c57600080fd5b8635614b57816146d7565b9550602087013567ffffffffffffffff80821115614b7457600080fd5b614b808a838b016147e9565b9097509550604089013594506060890135915080821115614ba057600080fd5b50614bad89828a016147e9565b979a9699509497509295939492505050565b60008083601f840112614bd157600080fd5b50813567ffffffffffffffff811115614be957600080fd5b60208301915083602082850101111561482e57600080fd5b600080600080600060808688031215614c1957600080fd5b8535945060208601359350604086013567ffffffffffffffff811115614c3e57600080fd5b614c4a88828901614bbf565b9094509250614c5d905060608701614ad1565b90509295509295909350565b60008060408385031215614c7c57600080fd5b823567ffffffffffffffff80821115614c9457600080fd5b818501915085601f830112614ca857600080fd5b81356020614cb58261491a565b604051614cc282826148ed565b83815260059390931b8501820192828101915089841115614ce257600080fd5b948201945b83861015614d09578535614cfa816146d7565b82529482019490820190614ce7565b96505086013592505080821115614d1f57600080fd5b50614d2c8582860161493e565b9150509250929050565b600081518084526020808501945080840160005b83811015614d6657815187529582019590820190600101614d4a565b509495945050505050565b6020815260006110746020830184614d36565b60008060408385031215614d9757600080fd5b8235614da2816146d7565b9150602083013567ffffffffffffffff811115614dbe57600080fd5b614d2c858286016149af565b8015158114610fee57600080fd5b60008060408385031215614deb57600080fd5b8235614df6816146d7565b91506020830135614e0681614dca565b809150509250929050565b60008060008060008060808789031215614e2a57600080fd5b8635614e35816146d7565b95506020870135614e45816146d7565b9450604087013567ffffffffffffffff80821115614e6257600080fd5b614e6e8a838b016147e9565b90965094506060890135915080821115614ba057600080fd5b600080600060608486031215614e9c57600080fd5b8335614ea7816146d7565b92506020840135614eb7816146d7565b929592945050506040919091013590565b604081526000614edb6040830185614d36565b82810360208401526143f98185614d36565b6001600160a01b038416815263ffffffff831660208201526060604082015260006143f960608301846147aa565b600080600060608486031215614f3057600080fd5b8335614f3b816146d7565b95602085013595506040909401359392505050565b600080600080600060608688031215614f6857600080fd5b8535614f73816146d7565b9450602086013567ffffffffffffffff80821115614f9057600080fd5b614f9c89838a016147e9565b90965094506040880135915080821115614fb557600080fd5b50614fc2888289016147e9565b969995985093965092949392505050565b60008060008060008060608789031215614fec57600080fd5b863567ffffffffffffffff8082111561500457600080fd5b6150108a838b016147e9565b9098509650602089013591508082111561502957600080fd5b6150358a838b016147e9565b90965094506040890135915080821115614ba057600080fd5b60008060006040848603121561506357600080fd5b83359250602084013567ffffffffffffffff81111561508157600080fd5b61508d868287016147e9565b9497909650939450505050565b600080600080600080600060a0888a0312156150b557600080fd5b87356150c0816146d7565b965060208801356150d0816146d7565b955060408801359450606088013567ffffffffffffffff808211156150f457600080fd5b6151008b838c016147e9565b909650945060808a013591508082111561511957600080fd5b506151268a828b016147e9565b989b979a50959850939692959293505050565b60408152600061514c6040830185614d36565b90508260208301529392505050565b6000806040838503121561516e57600080fd5b8235615179816146d7565b91506020830135614e06816146d7565b6000806020838503121561519c57600080fd5b823567ffffffffffffffff808211156151b457600080fd5b818501915085601f8301126151c857600080fd5b8135818111156151d757600080fd5b8660208260061b85010111156151ec57600080fd5b60209290920196919550909350505050565b60008060006040848603121561521357600080fd5b83359250602084013567ffffffffffffffff81111561523157600080fd5b61508d86828701614bbf565b600080600080600060a0868803121561525557600080fd5b8535615260816146d7565b94506020860135615270816146d7565b93506040860135925060608601359150608086013567ffffffffffffffff81111561529a57600080fd5b614ac4888289016149af565b600181811c908216806152ba57607f821691505b6020821081036152da57634e487b7160e01b600052602260045260246000fd5b50919050565b6000808335601e198436030181126152f757600080fd5b83018035915067ffffffffffffffff82111561531257600080fd5b6020019150600581901b360382131561482e57600080fd5b6000808335601e1984360301811261534157600080fd5b830160208101925035905067ffffffffffffffff81111561536157600080fd5b8060051b360382131561482e57600080fd5b8183526000602080850194508260005b85811015614d6657813587529582019590820190600101615383565b81835260007f07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8311156153d157600080fd5b8260051b80836020870137939093016020019392505050565b828152604060208201526000615400838461532a565b6060604085015261541560a085018284615373565b915050615425602085018561532a565b603f198086850301606087015261543d84838561539f565b935061544c604088018861532a565b9350915080868503016080870152506142c383838361539f565b6001600160a01b0387168152608060208201526000615489608083018789615373565b85604084015282810360608401526154a281858761539f565b9998505050505050505050565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b6000600182016154ed576154ed6154c5565b5060010190565b80820180821115610b5257610b526154c5565b8381526060602082015260006155206060830185614d36565b9050826040830152949350505050565b6000815480845260208085019450836000528060002060005b83811015614d6657815487529582019560019182019101615549565b60408152600061514c6040830185615530565b600082601f83011261558957600080fd5b815160206155968261491a565b6040516155a382826148ed565b83815260059390931b85018201928281019150868411156155c357600080fd5b8286015b848110156149a457805183529183019183016155c7565b600080604083850312156155f157600080fd5b825167ffffffffffffffff81111561560857600080fd5b61561485828601615578565b925050602083015190509250929050565b86815260806020820152600061563f60808301878961539f565b828103604084015261565281868861539f565b915050826060830152979650505050505050565b60006020828403121561567857600080fd5b815161107481614dca565b6020815260006110746020830184615530565b6000602082840312156156a857600080fd5b5051919050565b6000602082840312156156c157600080fd5b815167ffffffffffffffff8111156156d857600080fd5b61197b84828501615578565b81810381811115610b5257610b526154c5565b634e487b7160e01b600052600160045260246000fd5b8082028115828204841417610b5257610b526154c5565b60008261574157634e487b7160e01b600052601260045260246000fd5b500490565b82815260406020820152600061197b6040830184614d36565b60006001600160a01b03808816835280871660208401525060a0604083015261578b60a0830186614d36565b828103606084015261579d8186614d36565b905082810360808401526157b181856147aa565b98975050505050505050565b6000602082840312156157cf57600080fd5b815161107481614718565b600060033d11156114085760046000803e5060005160e01c90565b600060443d10156158035790565b6040516003193d81016004833e81513d67ffffffffffffffff816024840111818411171561583357505050505090565b828501915081518181111561584b5750505050505090565b843d87010160208285010111156158655750505050505090565b615874602082860101876148ed565b509095945050505050565b60006001600160a01b03808816835280871660208401525084604083015283606083015260a060808301526142c360a08301846147aa565b600082516158c9818460208701614786565b9190910192915050565b601f82111561144957600081815260208120601f850160051c810160208610156158fa5750805b601f850160051c820191505b818110156119cc57828155600101615906565b815167ffffffffffffffff811115615933576159336148d7565b6159478161594184546152a6565b846158d3565b602080601f83116001811461597c57600084156159645750858301515b600019600386901b1c1916600185901b1785556119cc565b600085815260208120601f198616915b828110156159ab5788860151825594840194600190910190840161598c565b50858210156159c95787850151600019600388901b60f8161c191681555b5050505050600190811b0190555056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220acfab0845fd4c656b9f5126781cad9d217e23c9c03f121853a771df711c5cd8264736f6c63430008130033
Deployed Bytecode
0x6080604052600436106103495760003560e01c806377309dbe116101bb578063d54a70e8116100f7578063ee973c5111610095578063f2fde38b1161006f578063f2fde38b14610a28578063f9e2b91214610a48578063fb629de514610a68578063fbdd125514610a9d57600080fd5b8063ee973c51146109bc578063f0dded2f146109d7578063f242432a14610a0857600080fd5b8063dd34de67116100d1578063dd34de67146108fa578063de61ece114610928578063e985e9c514610958578063edf0374f146109a157600080fd5b8063d54a70e81461088c578063d96ee754146108ba578063dd142562146108da57600080fd5b8063babf954e11610164578063c49298ac1161013e578063c49298ac146107fe578063c4d66de81461081e578063c87e50091461083e578063d42dc0c21461085e57600080fd5b8063babf954e1461079e578063bafce2dd146107be578063c0f0ec5e146107de57600080fd5b8063a1e7b67e11610195578063a1e7b67e1461073e578063a22cb4651461075e578063b76071a11461077e57600080fd5b806377309dbe146106d1578063852c6ae2146107005780638da5cb5b1461072057600080fd5b80634e1273f41161028a5780635673515811610233578063604d66de1161020d578063604d66de1461064d578063715018a61461066d57806371b3a2301461068257806371ec7eb3146106b057600080fd5b806356735158146105ed57806357ad06301461060d5780635dc7397d1461062d57600080fd5b806352d1902d1161026457806352d1902d146105a357806353f446c1146105b857806354e4cc84146105d857600080fd5b80634e1273f4146105435780634f1ef2861461057057806352cfba861461058357600080fd5b8063289ab7e2116102f75780633659cfe6116102d15780633659cfe6146104c857806338e8789b146104e857806339dd75301461050857806346e303801461052857600080fd5b8063289ab7e2146104585780632eb2c2d61461048d57806330d3df2b146104ad57600080fd5b80630e89341c116103285780630e89341c146103d15780631071844a146103fe578063189e96e21461043657600080fd5b8062fdd58e1461034e57806301ffc9a7146103815780630504c814146103b1575b600080fd5b34801561035a57600080fd5b5061036e6103693660046146ec565b610abd565b6040519081526020015b60405180910390f35b34801561038d57600080fd5b506103a161039c36600461472e565b610b58565b6040519015158152602001610378565b3480156103bd57600080fd5b5061036e6103cc36600461474b565b610bb3565b3480156103dd57600080fd5b506103f16103ec36600461476d565b610be5565b60405161037891906147d6565b34801561040a57600080fd5b5061041e61041936600461476d565b610c79565b6040516001600160a01b039091168152602001610378565b34801561044257600080fd5b50610456610451366004614835565b610c94565b005b34801561046457600080fd5b50610478610473366004614877565b610cad565b60408051928352602083019190915201610378565b34801561049957600080fd5b506104566104a8366004614a23565b610de3565b3480156104b957600080fd5b50610456610451366004614aea565b3480156104d457600080fd5b506104566104e3366004614b16565b610e76565b3480156104f457600080fd5b5061036e610503366004614b33565b610ff1565b34801561051457600080fd5b5061036e6105233660046146ec565b611030565b34801561053457600080fd5b5061036e610419366004614c01565b34801561054f57600080fd5b5061056361055e366004614c69565b61107b565b6040516103789190614d71565b61045661057e366004614d84565b6111a5565b34801561058f57600080fd5b5061045661059e366004614dd8565b611311565b3480156105af57600080fd5b5061036e611345565b3480156105c457600080fd5b506104566105d3366004614835565b61140b565b3480156105e457600080fd5b5061036e600981565b3480156105f957600080fd5b5061036e610608366004614e11565b61144e565b34801561061957600080fd5b5061045661062836600461476d565b611661565b34801561063957600080fd5b5061036e61064836600461476d565b611759565b34801561065957600080fd5b50610563610668366004614e87565b611768565b34801561067957600080fd5b50610456611867565b34801561068e57600080fd5b506106a261069d366004614e87565b61187b565b604051610378929190614ec8565b3480156106bc57600080fd5b506101615461041e906001600160a01b031681565b3480156106dd57600080fd5b506106f16106ec36600461476d565b61189e565b60405161037893929190614eed565b34801561070c57600080fd5b5061036e61071b366004614f1b565b61196e565b34801561072c57600080fd5b5060fb546001600160a01b031661041e565b34801561074a57600080fd5b5061036e61075936600461474b565b611983565b34801561076a57600080fd5b50610456610779366004614dd8565b6119b3565b34801561078a57600080fd5b50610456610799366004614f50565b6119be565b3480156107aa57600080fd5b506105636107b93660046146ec565b6119d4565b3480156107ca57600080fd5b506104566107d9366004614f1b565b611a7d565b3480156107ea57600080fd5b506104566107f9366004614fd3565b611c58565b34801561080a57600080fd5b5061045661081936600461504e565b611c71565b34801561082a57600080fd5b50610456610839366004614b16565b611d52565b34801561084a57600080fd5b5061036e61085936600461509a565b611e8e565b34801561086a57600080fd5b5061036e61087936600461476d565b600090815261012d602052604090205490565b34801561089857600080fd5b506108ac6108a736600461476d565b611ff2565b604051610378929190615139565b3480156108c657600080fd5b5061036e6108d5366004614f1b565b612065565b3480156108e657600080fd5b506104566108f5366004614f1b565b612080565b34801561090657600080fd5b5061036e61091536600461476d565b61012e6020526000908152604090205481565b34801561093457600080fd5b506103a161094336600461476d565b600090815261012e6020526040902054151590565b34801561096457600080fd5b506103a161097336600461515b565b6001600160a01b03918216600090815260ca6020908152604080832093909416825291909152205460ff1690565b3480156109ad57600080fd5b50610456610451366004615189565b3480156109c857600080fd5b506104566104513660046151fe565b3480156109e357600080fd5b506103a16109f2366004614b16565b61012f6020526000908152604090205460ff1681565b348015610a1457600080fd5b50610456610a2336600461523d565b61229a565b348015610a3457600080fd5b50610456610a43366004614b16565b612326565b348015610a5457600080fd5b506103a1610a6336600461476d565b61239c565b348015610a7457600080fd5b50610a88610a8336600461476d565b6124b9565b60405163ffffffff9091168152602001610378565b348015610aa957600080fd5b50610563610ab836600461476d565b612538565b60006001600160a01b038316610b2d5760405162461bcd60e51b815260206004820152602a60248201527f455243313135353a2061646472657373207a65726f206973206e6f742061207660448201526930b634b21037bbb732b960b11b60648201526084015b60405180910390fd5b50600081815260c9602090815260408083206001600160a01b03861684529091529020545b92915050565b60006001600160e01b0319821663219bfdad60e11b1480610b8957506001600160e01b0319821663306da52d60e01b145b80610ba457506001600160e01b031982166349ecb6f560e01b145b80610b525750610b52826125c6565b61012d6020528160005260406000208181548110610bd057600080fd5b90600052602060002001600091509150505481565b606060cb8054610bf4906152a6565b80601f0160208091040260200160405190810160405280929190818152602001828054610c20906152a6565b8015610c6d5780601f10610c4257610100808354040283529160200191610c6d565b820191906000526020600020905b815481529060010190602001808311610c5057829003601f168201915b50505050509050919050565b60006040516356e7318960e11b815260040160405180910390fd5b6040516356e7318960e11b815260040160405180910390fd5b600080610ccc85610cbe85806152e0565b8761050360208901896152e0565b9150610cdb6000836003612616565b6000818152610162602052604081205491925003610ddb576000610d00868686612777565b90506040518060400160405280828152602001610d5d868060200190610d2691906152e0565b80806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250612b4e92505050565b9052600083815261016260209081526040909120825180519192610d8692849290910190614677565b5060208201518160010155905050856001600160a01b031683837f29f41f0b880379a7c7fff68b869c29160e819340ea2b60c7bbba71ababa54d348888604051610dd19291906153ea565b60405180910390a4505b935093915050565b6001600160a01b038516331480610dff5750610dff8533610973565b610e625760405162461bcd60e51b815260206004820152602e60248201527f455243313135353a2063616c6c6572206973206e6f7420746f6b656e206f776e60448201526d195c881bdc88185c1c1c9bdd995960921b6064820152608401610b24565b610e6f8585858585612bab565b5050505050565b6001600160a01b037f000000000000000000000000b25871a7cb22582f125a14aef11cf6ecc20da164163003610f035760405162461bcd60e51b815260206004820152602c60248201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060448201526b19195b1959d85d1958d85b1b60a21b6064820152608401610b24565b7f000000000000000000000000b25871a7cb22582f125a14aef11cf6ecc20da1646001600160a01b0316610f5e7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b6001600160a01b031614610fc95760405162461bcd60e51b815260206004820152602c60248201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060448201526b6163746976652070726f787960a01b6064820152608401610b24565b610fd281612e04565b60408051600080825260208201909252610fee91839190612e0c565b50565b600086868686868660405160200161100e96959493929190615466565b6040516020818303038152906040528051906020012090509695505050505050565b60408051606084901b6bffffffffffffffffffffffff1916602080830191909152603480830185905283518084039091018152605490920190925280519101206000905b9392505050565b606081518351146110e05760405162461bcd60e51b815260206004820152602960248201527f455243313135353a206163636f756e747320616e6420696473206c656e677468604482015268040dad2e6dac2e8c6d60bb1b6064820152608401610b24565b6000835167ffffffffffffffff8111156110fc576110fc6148d7565b604051908082528060200260200182016040528015611125578160200160208202803683370190505b50905060005b845181101561119d57611170858281518110611149576111496154af565b6020026020010151858381518110611163576111636154af565b6020026020010151610abd565b828281518110611182576111826154af565b6020908102919091010152611196816154db565b905061112b565b509392505050565b6001600160a01b037f000000000000000000000000b25871a7cb22582f125a14aef11cf6ecc20da1641630036112325760405162461bcd60e51b815260206004820152602c60248201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060448201526b19195b1959d85d1958d85b1b60a21b6064820152608401610b24565b7f000000000000000000000000b25871a7cb22582f125a14aef11cf6ecc20da1646001600160a01b031661128d7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b6001600160a01b0316146112f85760405162461bcd60e51b815260206004820152602c60248201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060448201526b6163746976652070726f787960a01b6064820152608401610b24565b61130182612e04565b61130d82826001612e0c565b5050565b611319612f98565b6001600160a01b0391909116600090815261012f60205260409020805460ff1916911515919091179055565b6000306001600160a01b037f000000000000000000000000b25871a7cb22582f125a14aef11cf6ecc20da16416146113e55760405162461bcd60e51b815260206004820152603860248201527f555550535570677261646561626c653a206d757374206e6f742062652063616c60448201527f6c6564207468726f7567682064656c656761746563616c6c00000000000000006064820152608401610b24565b507f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5b90565b60005b818110156114495761143783838381811061142b5761142b6154af565b90506020020135611661565b80611441816154db565b91505061140e565b505050565b6000838214611470576040516363df817160e01b815260040160405180910390fd5b6040805160018082528183019092526000918291906020808301908036833701905050905060005b868110156116195760008888838181106114b4576114b46154af565b90506020020135905060008787848181106114d1576114d16154af565b90506020020135905060006115598c6115118585604080516020808201949094528082019290925280518083038201815260609092019052805191012090565b6040516bffffffffffffffffffffffff19606084901b1660208201526034810182905260009060540160408051601f1981840301815291905280516020909101209392505050565b905060006115678e83610abd565b905061157381886154f4565b965060006115848f84878786612ff2565b9050611590818a6154f4565b985083876000815181106115a6576115a66154af565b6020026020010181815250508d6001600160a01b03168f6001600160a01b03167f21336e17fc856aa5e53e3b01d2deceb8e0609196d2756d9463463478727d81e9878a856040516115f993929190615507565b60405180910390a350505050508080611611906154db565b915050611498565b508160000361163b576040516302bc6d3360e01b815260040160405180910390fd5b8215611655576116556001600160a01b0389168a856130c7565b50509695505050505050565b600061166c82611759565b600081815261012d602052604090205490915060031461169f5760405163a1154ec560e01b815260040160405180910390fd5b600081815261012e6020526040902054156116b8575050565b60008181526101626020526040808220610161546001820154925163272ae24560e11b815291939283926001600160a01b0390921691634e55c48a9161170391879190600401615565565b600060405180830381865afa158015611720573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261174891908101906155de565b91509150610e6f600086848461312a565b6000610b52600083600361325b565b600081815261012d602052604081205460609181900361179b5760405163a1154ec560e01b815260040160405180910390fd5b60008167ffffffffffffffff8111156117b6576117b66148d7565b6040519080825280602002602001820160405280156117df578160200160208202803683370190505b50905060005b8281101561185d5760408051602080820188905281830184905282518083038401815260609092019092528051910120600090611823908890611511565b905061182f8882610abd565b838381518110611841576118416154af565b602090810291909101015250611856816154db565b90506117e5565b5095945050505050565b61186f612f98565b61187960006132ba565b565b606080611889858585611768565b915061189483612538565b9050935093915050565b61013060205260009081526040902080546001820180546001600160a01b038316937401000000000000000000000000000000000000000090930463ffffffff169291906118eb906152a6565b80601f0160208091040260200160405190810160405280929190818152602001828054611917906152a6565b80156119645780601f1061193957610100808354040283529160200191611964565b820191906000526020600020905b81548152906001019060200180831161194757829003601f168201915b5050505050905083565b600061197b84848461325b565b949350505050565b60408051602080820185905281830184905282518083038401815260609092019092528051910120600090611074565b61130d33838361330c565b6119cc33868686868661144e565b505050505050565b600081815261012d60205260408120546060918167ffffffffffffffff811115611a0057611a006148d7565b604051908082528060200260200182016040528015611a29578160200160208202803683370190505b50905060005b82811015611a7457611a45866115118784611983565b828281518110611a5757611a576154af565b602090810291909101015280611a6c816154db565b915050611a2f565b50949350505050565b80600003611a9e5760405163162908e360e11b815260040160405180910390fd5b600082815261012d602052604081205490819003611acf5760405163a1154ec560e01b815260040160405180910390fd5b60008167ffffffffffffffff811115611aea57611aea6148d7565b604051908082528060200260200182016040528015611b13578160200160208202803683370190505b50905060008267ffffffffffffffff811115611b3157611b316148d7565b604051908082528060200260200182016040528015611b5a578160200160208202803683370190505b50905060005b83811015611be95760408051602080820189905281830184905282518083038401815260609092019092528051910120611b9b908890611511565b838281518110611bad57611bad6154af565b60200260200101818152505084828281518110611bcc57611bcc6154af565b602090810291909101015280611be1816154db565b915050611b60565b50611bf53383836133ec565b611c096001600160a01b03871633866130c7565b604080516001600160a01b038816815260208101869052869133917fd1034db24aaa2750c79ef3a96a2ffd9fd4b48f900ef4f4f7b6c024053a528a4c91015b60405180910390a3505050505050565b60405163c45f4b3960e01b815260040160405180910390fd5b8060008167ffffffffffffffff811115611c8d57611c8d6148d7565b604051908082528060200260200182016040528015611cb6578160200160208202803683370190505b5090506000805b83811015611d21576000868683818110611cd957611cd96154af565b9050602002013590508083611cee91906154f4565b925080848381518110611d0357611d036154af565b60209081029190910101525080611d19816154db565b915050611cbd565b50612710811115611d455760405163a9a21e6d60e01b815260040160405180910390fd5b6119cc600087848461312a565b600054610100900460ff1615808015611d725750600054600160ff909116105b80611d8c5750303b158015611d8c575060005460ff166001145b611dfe5760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201527f647920696e697469616c697a65640000000000000000000000000000000000006064820152608401610b24565b6000805460ff191660011790558015611e21576000805461ff0019166101001790555b611e29613632565b61016180546001600160a01b0319166001600160a01b038416179055801561130d576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15050565b6000838214611eb057604051630d800f7960e41b815260040160405180910390fd5b50600033815b85811015611f6c576000611f0d8a6115118b8b8b87818110611eda57611eda6154af565b90506020020135604080516020808201949094528082019290925280518083038201815260609092019052805191012090565b9050611f4c83828b8b8b87818110611f2757611f276154af565b905060200201358a8a88818110611f4057611f406154af565b90506020020135612ff2565b611f5690856154f4565b9350508080611f64906154db565b915050611eb6565b50876001600160a01b0316816001600160a01b03168a6001600160a01b03167f84c687ba62d65c1a78e95c861b268d3432f950ac6672b211c145a85cdc3992028a8a8a8a8a8a604051611fc496959493929190615625565b60405180910390a48115611fe657611fe66001600160a01b0389168a846130c7565b50979650505050505050565b600081815261012d6020908152604080832080548251818502810185019093528083526060949383018282801561204857602002820191906000526020600020905b815481526020019060010190808311612034575b5050506000958652505061012e6020526040909320549293915050565b600060405163c45f4b3960e01b815260040160405180910390fd5b806000036120a15760405163162908e360e11b815260040160405180910390fd5b6001600160a01b038316600090815261012f602052604090205460ff166120db57604051630eca12dd60e31b815260040160405180910390fd5b600082815261012d60205260408120549081900361210c5760405163a1154ec560e01b815260040160405180910390fd5b60008167ffffffffffffffff811115612127576121276148d7565b604051908082528060200260200182016040528015612150578160200160208202803683370190505b50905060008267ffffffffffffffff81111561216e5761216e6148d7565b604051908082528060200260200182016040528015612197578160200160208202803683370190505b50905060005b8381101561222657604080516020808201899052818301849052825180830384018152606090920190925280519101206121d8908890611511565b8382815181106121ea576121ea6154af565b60200260200101818152505084828281518110612209576122096154af565b60209081029190910101528061221e816154db565b91505061219d565b5061223c6001600160a01b0387163330876136cd565b61225733838360405180602001604052806000815250613705565b604080516001600160a01b038816815260208101869052869133917fad6a73f49492e69122c9865dd7b0f401d9f90300928019d02755f11b049c93b39101611c48565b6001600160a01b0385163314806122b657506122b68533610973565b6123195760405162461bcd60e51b815260206004820152602e60248201527f455243313135353a2063616c6c6572206973206e6f7420746f6b656e206f776e60448201526d195c881bdc88185c1c1c9bdd995960921b6064820152608401610b24565b610e6f85858585856138cc565b61232e612f98565b6001600160a01b0381166123935760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610b24565b610fee816132ba565b600081815261016260209081526040808320805482518185028101850190935280835284938301828280156123f057602002820191906000526020600020905b8154815260200190600101908083116123dc575b5050505050905060005b815181108015612408575082155b156124b2576101615482516001600160a01b039091169063f9e2b91290849084908110612437576124376154af565b60200260200101516040518263ffffffff1660e01b815260040161245d91815260200190565b602060405180830381865afa15801561247a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061249e9190615666565b9250806124aa816154db565b9150506123fa565b5050919050565b610161546000828152610162602052604080822090516337e545fd60e11b815291926001600160a01b031691636fca8bfa916124f791600401615683565b602060405180830381865afa158015612514573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b529190615696565b60008181526101626020526040908190206101615460018201549251632759f5cb60e01b81526060936001600160a01b0390921691632759f5cb91612581918591600401615565565b600060405180830381865afa15801561259e573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261107491908101906156af565b60006001600160e01b03198216636cdb3d1360e11b14806125f757506001600160e01b031982166303a24d0760e21b145b80610b5257506301ffc9a760e01b6001600160e01b0319831614610b52565b60006002821080612627575060ff82115b1561264557604051636995da1b60e01b815260040160405180910390fd5b600061265285858561325b565b600081815261012d60205260408120549192500361197b578267ffffffffffffffff811115612683576126836148d7565b6040519080825280602002602001820160405280156126ac578160200160208202803683370190505b50600082815261012d6020908152604090912082516126d19391929190910190614677565b50600081815261013060205260409081902080547fffffffffffffffff000000000000000000000000000000000000000000000000166001600160a01b03881690811777ffffffff000000000000000000000000000000000000000017909155905185919083907fab3760c3bd2bb38b5bcf54dc79802ed67338b4cf29f3054ded67ed24661e4177906127679088815260200190565b60405180910390a4949350505050565b6060600061278860208401846152e0565b905061279484806152e0565b90501415806127bc57506127ab60408401846152e0565b90506127b784806152e0565b905014155b806127d2575060016127ce84806152e0565b9050105b905080156127f357604051630e58291160e31b815260040160405180910390fd5b5061016154600090612815906001600160a01b031663306da52d60e01b613a7b565b801561283a57506101615461283a906001600160a01b03166306c6babb60e01b613a7b565b90508061286a57610161546040516365d593c560e11b81526001600160a01b039091166004820152602401610b24565b50600961287783806152e0565b905011156128985760405163ecc2d2d160e01b815260040160405180910390fd5b826000036128b95760405163038c11f960e51b815260040160405180910390fd5b60006128c583806152e0565b905067ffffffffffffffff8111156128df576128df6148d7565b604051908082528060200260200182016040528015612908578160200160208202803683370190505b50915060005b61291884806152e0565b9050811015612b4557600061293060408601866152e0565b83818110612940576129406154af565b90506020020135905060018161295691906156e4565b61296360208701876152e0565b84818110612973576129736154af565b9050602002013510612998576040516363df817160e01b815260040160405180910390fd5b60006129a486806152e0565b848181106129b4576129b46154af565b60200291909101359150508681168481116129e257604051630670e21160e01b815260040160405180910390fd5b80945060006129f28a848661325b565b61016154604051636a16e06160e11b81526004810183905291925085916001600160a01b039091169063d42dc0c290602401602060405180830381865afa158015612a41573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a659190615696565b14612a835760405163a1154ec560e01b815260040160405180910390fd5b6101615460405163de61ece160e01b8152600481018390526001600160a01b039091169063de61ece190602401602060405180830381865afa158015612acd573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612af19190615666565b15612b0f576040516398d2ea1160e01b815260040160405180910390fd5b80878681518110612b2257612b226154af565b602002602001018181525050505050508080612b3d906154db565b91505061290e565b50509392505050565b80516000908190815b81811015612ba2576000858281518110612b7357612b736154af565b6020026020010151905060ff8016811115612b9057612b906156f7565b600882021b9290921791600101612b57565b50909392505050565b8151835114612c0d5760405162461bcd60e51b815260206004820152602860248201527f455243313135353a2069647320616e6420616d6f756e7473206c656e677468206044820152670dad2e6dac2e8c6d60c31b6064820152608401610b24565b6001600160a01b038416612c715760405162461bcd60e51b815260206004820152602560248201527f455243313135353a207472616e7366657220746f20746865207a65726f206164604482015264647265737360d81b6064820152608401610b24565b3360005b8451811015612d9e576000858281518110612c9257612c926154af565b602002602001015190506000858381518110612cb057612cb06154af565b602090810291909101810151600084815260c9835260408082206001600160a01b038e168352909352919091205490915081811015612d445760405162461bcd60e51b815260206004820152602a60248201527f455243313135353a20696e73756666696369656e742062616c616e636520666f60448201526939103a3930b739b332b960b11b6064820152608401610b24565b600083815260c9602090815260408083206001600160a01b038e8116855292528083208585039055908b16825281208054849290612d839084906154f4565b9250508190555050505080612d97906154db565b9050612c75565b50846001600160a01b0316866001600160a01b0316826001600160a01b03167f4a39dc06d4c0dbc64b70af90fd698a233a518aa5d07e595d983b8c0526c8f7fb8787604051612dee929190614ec8565b60405180910390a46119cc818787878787613a97565b610fee612f98565b7f4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd91435460ff1615612e3f5761144983613c45565b826001600160a01b03166352d1902d6040518163ffffffff1660e01b8152600401602060405180830381865afa925050508015612e99575060408051601f3d908101601f19168201909252612e9691810190615696565b60015b612f0b5760405162461bcd60e51b815260206004820152602e60248201527f45524331393637557067726164653a206e657720696d706c656d656e7461746960448201527f6f6e206973206e6f7420555550530000000000000000000000000000000000006064820152608401610b24565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc8114612f8c5760405162461bcd60e51b815260206004820152602960248201527f45524331393637557067726164653a20756e737570706f727465642070726f786044820152681a58589b195555525160ba1b6064820152608401610b24565b50611449838383613d03565b60fb546001600160a01b031633146118795760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610b24565b600083815261012e602052604081205480820361302257604051630cb95b4560e31b815260040160405180910390fd5b600085815261012d602052604081205490819003613042576130426156f7565b808510613062576040516363df817160e01b815260040160405180910390fd5b600086815261012d60205260408120805487908110613083576130836154af565b9060005260206000200154905060008511156130bb57826130a4828761570d565b6130ae9190615724565b93506130bb898987613d28565b50505095945050505050565b6040516001600160a01b03831660248201526044810182905261144990849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152613ea7565b815160018111158061313c575060ff81115b1561315a57604051636995da1b60e01b815260040160405180910390fd5b600061316786868461325b565b600081815261012d602052604090205490915082146131995760405163a1154ec560e01b815260040160405180910390fd5b826000036131ba5760405163f82a70fb60e01b815260040160405180910390fd5b600081815261012e6020526040902054156131d6575050613255565b600081815261012d6020908152604090912085516131f692870190614677565b50600081815261012e6020526040908190208490555185906001600160a01b0388169083907fb44d84d3289691f71497564b85d4233648d9dbae8cbdbb4329f301c3a01858949061324a9087908a90615746565b60405180910390a450505b50505050565b6000610101821061326e5761326e6156f7565b6040516bffffffffffffffffffffffff19606086901b16602082015260348101849052605481018390526074016040516020818303038152906040528051906020012090509392505050565b60fb80546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b816001600160a01b0316836001600160a01b03160361337f5760405162461bcd60e51b815260206004820152602960248201527f455243313135353a2073657474696e6720617070726f76616c20737461747573604482015268103337b91039b2b63360b91b6064820152608401610b24565b6001600160a01b03838116600081815260ca6020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b6001600160a01b03831661344e5760405162461bcd60e51b815260206004820152602360248201527f455243313135353a206275726e2066726f6d20746865207a65726f206164647260448201526265737360e81b6064820152608401610b24565b80518251146134b05760405162461bcd60e51b815260206004820152602860248201527f455243313135353a2069647320616e6420616d6f756e7473206c656e677468206044820152670dad2e6dac2e8c6d60c31b6064820152608401610b24565b604080516020810190915260009081905233905b83518110156135c55760008482815181106134e1576134e16154af565b6020026020010151905060008483815181106134ff576134ff6154af565b602090810291909101810151600084815260c9835260408082206001600160a01b038c16835290935291909120549091508181101561358c5760405162461bcd60e51b8152602060048201526024808201527f455243313135353a206275726e20616d6f756e7420657863656564732062616c604482015263616e636560e01b6064820152608401610b24565b600092835260c9602090815260408085206001600160a01b038b16865290915290922091039055806135bd816154db565b9150506134c4565b5060006001600160a01b0316846001600160a01b0316826001600160a01b03167f4a39dc06d4c0dbc64b70af90fd698a233a518aa5d07e595d983b8c0526c8f7fb8686604051613616929190614ec8565b60405180910390a4604080516020810190915260009052613255565b600054610100900460ff1661369d5760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b6064820152608401610b24565b6136b560405180602001604052806000815250613f79565b6136bd613fed565b6136c5614060565b611879614060565b6040516001600160a01b03808516602483015283166044820152606481018290526132559085906323b872dd60e01b906084016130f3565b6001600160a01b0384166137655760405162461bcd60e51b815260206004820152602160248201527f455243313135353a206d696e7420746f20746865207a65726f206164647265736044820152607360f81b6064820152608401610b24565b81518351146137c75760405162461bcd60e51b815260206004820152602860248201527f455243313135353a2069647320616e6420616d6f756e7473206c656e677468206044820152670dad2e6dac2e8c6d60c31b6064820152608401610b24565b3360005b8451811015613864578381815181106137e6576137e66154af565b602002602001015160c96000878481518110613804576138046154af565b602002602001015181526020019081526020016000206000886001600160a01b03166001600160a01b03168152602001908152602001600020600082825461384c91906154f4565b9091555081905061385c816154db565b9150506137cb565b50846001600160a01b031660006001600160a01b0316826001600160a01b03167f4a39dc06d4c0dbc64b70af90fd698a233a518aa5d07e595d983b8c0526c8f7fb87876040516138b5929190614ec8565b60405180910390a4610e6f81600087878787613a97565b6001600160a01b0384166139305760405162461bcd60e51b815260206004820152602560248201527f455243313135353a207472616e7366657220746f20746865207a65726f206164604482015264647265737360d81b6064820152608401610b24565b33600061393c856140cb565b90506000613949856140cb565b9050600086815260c9602090815260408083206001600160a01b038c168452909152902054858110156139d15760405162461bcd60e51b815260206004820152602a60248201527f455243313135353a20696e73756666696369656e742062616c616e636520666f60448201526939103a3930b739b332b960b11b6064820152608401610b24565b600087815260c9602090815260408083206001600160a01b038d8116855292528083208985039055908a16825281208054889290613a109084906154f4565b909155505060408051888152602081018890526001600160a01b03808b16928c821692918816917fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f62910160405180910390a4613a70848a8a8a8a8a614116565b505050505050505050565b6000613a8683614212565b801561107457506110748383614245565b6001600160a01b0384163b156119cc5760405163bc197c8160e01b81526001600160a01b0385169063bc197c8190613adb908990899088908890889060040161575f565b6020604051808303816000875af1925050508015613b16575060408051601f3d908101601f19168201909252613b13918101906157bd565b60015b613bcb57613b226157da565b806308c379a003613b5b5750613b366157f5565b80613b415750613b5d565b8060405162461bcd60e51b8152600401610b2491906147d6565b505b60405162461bcd60e51b815260206004820152603460248201527f455243313135353a207472616e7366657220746f206e6f6e2d4552433131353560448201527f526563656976657220696d706c656d656e7465720000000000000000000000006064820152608401610b24565b6001600160e01b0319811663bc197c8160e01b14613c3c5760405162461bcd60e51b815260206004820152602860248201527f455243313135353a204552433131353552656365697665722072656a656374656044820152676420746f6b656e7360c01b6064820152608401610b24565b50505050505050565b6001600160a01b0381163b613cc25760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201527f6f74206120636f6e7472616374000000000000000000000000000000000000006064820152608401610b24565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc80546001600160a01b0319166001600160a01b0392909216919091179055565b613d0c836142ce565b600082511180613d195750805b1561144957613255838361430e565b6001600160a01b038316613d8a5760405162461bcd60e51b815260206004820152602360248201527f455243313135353a206275726e2066726f6d20746865207a65726f206164647260448201526265737360e81b6064820152608401610b24565b336000613d96846140cb565b90506000613da3846140cb565b604080516020808201835260009182905288825260c981528282206001600160a01b038b1683529052205490915084811015613e2d5760405162461bcd60e51b8152602060048201526024808201527f455243313135353a206275726e20616d6f756e7420657863656564732062616c604482015263616e636560e01b6064820152608401610b24565b600086815260c9602090815260408083206001600160a01b038b81168086529184528285208a8703905582518b81529384018a90529092908816917fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f62910160405180910390a4604080516020810190915260009052613c3c565b6000613efc826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166144029092919063ffffffff16565b8051909150156114495780806020019051810190613f1a9190615666565b6114495760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610b24565b600054610100900460ff16613fe45760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b6064820152608401610b24565b610fee81614411565b600054610100900460ff166140585760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b6064820152608401610b24565b611879614485565b600054610100900460ff166118795760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b6064820152608401610b24565b60408051600180825281830190925260609160009190602080830190803683370190505090508281600081518110614105576141056154af565b602090810291909101015292915050565b6001600160a01b0384163b156119cc5760405163f23a6e6160e01b81526001600160a01b0385169063f23a6e619061415a908990899088908890889060040161587f565b6020604051808303816000875af1925050508015614195575060408051601f3d908101601f19168201909252614192918101906157bd565b60015b6141a157613b226157da565b6001600160e01b0319811663f23a6e6160e01b14613c3c5760405162461bcd60e51b815260206004820152602860248201527f455243313135353a204552433131353552656365697665722072656a656374656044820152676420746f6b656e7360c01b6064820152608401610b24565b6000614225826301ffc9a760e01b614245565b8015610b52575061423e826001600160e01b0319614245565b1592915050565b604080516001600160e01b03198316602480830191909152825180830390910181526044909101909152602080820180516001600160e01b03166301ffc9a760e01b178152825160009392849283928392918391908a617530fa92503d915060005190508280156142b7575060208210155b80156142c35750600081115b979650505050505050565b6142d781613c45565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b60606001600160a01b0383163b6143765760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b6064820152608401610b24565b600080846001600160a01b03168460405161439191906158b7565b600060405180830381855af49150503d80600081146143cc576040519150601f19603f3d011682016040523d82523d6000602084013e6143d1565b606091505b50915091506143f982826040518060600160405280602781526020016159da602791396144f9565b95945050505050565b606061197b8484600085614512565b600054610100900460ff1661447c5760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b6064820152608401610b24565b610fee816145e2565b600054610100900460ff166144f05760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b6064820152608401610b24565b611879336132ba565b60608315614508575081611074565b61107483836145ee565b6060824710156145735760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401610b24565b600080866001600160a01b0316858760405161458f91906158b7565b60006040518083038185875af1925050503d80600081146145cc576040519150601f19603f3d011682016040523d82523d6000602084013e6145d1565b606091505b50915091506142c3878383876145fe565b60cb61130d8282615919565b815115613b415781518083602001fd5b6060831561466d578251600003614666576001600160a01b0385163b6146665760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610b24565b508161197b565b61197b83836145ee565b8280548282559060005260206000209081019282156146b2579160200282015b828111156146b2578251825591602001919060010190614697565b506146be9291506146c2565b5090565b5b808211156146be57600081556001016146c3565b6001600160a01b0381168114610fee57600080fd5b600080604083850312156146ff57600080fd5b823561470a816146d7565b946020939093013593505050565b6001600160e01b031981168114610fee57600080fd5b60006020828403121561474057600080fd5b813561107481614718565b6000806040838503121561475e57600080fd5b50508035926020909101359150565b60006020828403121561477f57600080fd5b5035919050565b60005b838110156147a1578181015183820152602001614789565b50506000910152565b600081518084526147c2816020860160208601614786565b601f01601f19169290920160200192915050565b60208152600061107460208301846147aa565b60008083601f8401126147fb57600080fd5b50813567ffffffffffffffff81111561481357600080fd5b6020830191508360208260051b850101111561482e57600080fd5b9250929050565b6000806020838503121561484857600080fd5b823567ffffffffffffffff81111561485f57600080fd5b61486b858286016147e9565b90969095509350505050565b60008060006060848603121561488c57600080fd5b8335614897816146d7565b925060208401359150604084013567ffffffffffffffff8111156148ba57600080fd5b8401606081870312156148cc57600080fd5b809150509250925092565b634e487b7160e01b600052604160045260246000fd5b601f8201601f1916810167ffffffffffffffff81118282101715614913576149136148d7565b6040525050565b600067ffffffffffffffff821115614934576149346148d7565b5060051b60200190565b600082601f83011261494f57600080fd5b8135602061495c8261491a565b60405161496982826148ed565b83815260059390931b850182019282810191508684111561498957600080fd5b8286015b848110156149a4578035835291830191830161498d565b509695505050505050565b600082601f8301126149c057600080fd5b813567ffffffffffffffff8111156149da576149da6148d7565b6040516149f1601f8301601f1916602001826148ed565b818152846020838601011115614a0657600080fd5b816020850160208301376000918101602001919091529392505050565b600080600080600060a08688031215614a3b57600080fd5b8535614a46816146d7565b94506020860135614a56816146d7565b9350604086013567ffffffffffffffff80821115614a7357600080fd5b614a7f89838a0161493e565b94506060880135915080821115614a9557600080fd5b614aa189838a0161493e565b93506080880135915080821115614ab757600080fd5b50614ac4888289016149af565b9150509295509295909350565b803563ffffffff81168114614ae557600080fd5b919050565b60008060408385031215614afd57600080fd5b82359150614b0d60208401614ad1565b90509250929050565b600060208284031215614b2857600080fd5b8135611074816146d7565b60008060008060008060808789031215614b4c57600080fd5b8635614b57816146d7565b9550602087013567ffffffffffffffff80821115614b7457600080fd5b614b808a838b016147e9565b9097509550604089013594506060890135915080821115614ba057600080fd5b50614bad89828a016147e9565b979a9699509497509295939492505050565b60008083601f840112614bd157600080fd5b50813567ffffffffffffffff811115614be957600080fd5b60208301915083602082850101111561482e57600080fd5b600080600080600060808688031215614c1957600080fd5b8535945060208601359350604086013567ffffffffffffffff811115614c3e57600080fd5b614c4a88828901614bbf565b9094509250614c5d905060608701614ad1565b90509295509295909350565b60008060408385031215614c7c57600080fd5b823567ffffffffffffffff80821115614c9457600080fd5b818501915085601f830112614ca857600080fd5b81356020614cb58261491a565b604051614cc282826148ed565b83815260059390931b8501820192828101915089841115614ce257600080fd5b948201945b83861015614d09578535614cfa816146d7565b82529482019490820190614ce7565b96505086013592505080821115614d1f57600080fd5b50614d2c8582860161493e565b9150509250929050565b600081518084526020808501945080840160005b83811015614d6657815187529582019590820190600101614d4a565b509495945050505050565b6020815260006110746020830184614d36565b60008060408385031215614d9757600080fd5b8235614da2816146d7565b9150602083013567ffffffffffffffff811115614dbe57600080fd5b614d2c858286016149af565b8015158114610fee57600080fd5b60008060408385031215614deb57600080fd5b8235614df6816146d7565b91506020830135614e0681614dca565b809150509250929050565b60008060008060008060808789031215614e2a57600080fd5b8635614e35816146d7565b95506020870135614e45816146d7565b9450604087013567ffffffffffffffff80821115614e6257600080fd5b614e6e8a838b016147e9565b90965094506060890135915080821115614ba057600080fd5b600080600060608486031215614e9c57600080fd5b8335614ea7816146d7565b92506020840135614eb7816146d7565b929592945050506040919091013590565b604081526000614edb6040830185614d36565b82810360208401526143f98185614d36565b6001600160a01b038416815263ffffffff831660208201526060604082015260006143f960608301846147aa565b600080600060608486031215614f3057600080fd5b8335614f3b816146d7565b95602085013595506040909401359392505050565b600080600080600060608688031215614f6857600080fd5b8535614f73816146d7565b9450602086013567ffffffffffffffff80821115614f9057600080fd5b614f9c89838a016147e9565b90965094506040880135915080821115614fb557600080fd5b50614fc2888289016147e9565b969995985093965092949392505050565b60008060008060008060608789031215614fec57600080fd5b863567ffffffffffffffff8082111561500457600080fd5b6150108a838b016147e9565b9098509650602089013591508082111561502957600080fd5b6150358a838b016147e9565b90965094506040890135915080821115614ba057600080fd5b60008060006040848603121561506357600080fd5b83359250602084013567ffffffffffffffff81111561508157600080fd5b61508d868287016147e9565b9497909650939450505050565b600080600080600080600060a0888a0312156150b557600080fd5b87356150c0816146d7565b965060208801356150d0816146d7565b955060408801359450606088013567ffffffffffffffff808211156150f457600080fd5b6151008b838c016147e9565b909650945060808a013591508082111561511957600080fd5b506151268a828b016147e9565b989b979a50959850939692959293505050565b60408152600061514c6040830185614d36565b90508260208301529392505050565b6000806040838503121561516e57600080fd5b8235615179816146d7565b91506020830135614e06816146d7565b6000806020838503121561519c57600080fd5b823567ffffffffffffffff808211156151b457600080fd5b818501915085601f8301126151c857600080fd5b8135818111156151d757600080fd5b8660208260061b85010111156151ec57600080fd5b60209290920196919550909350505050565b60008060006040848603121561521357600080fd5b83359250602084013567ffffffffffffffff81111561523157600080fd5b61508d86828701614bbf565b600080600080600060a0868803121561525557600080fd5b8535615260816146d7565b94506020860135615270816146d7565b93506040860135925060608601359150608086013567ffffffffffffffff81111561529a57600080fd5b614ac4888289016149af565b600181811c908216806152ba57607f821691505b6020821081036152da57634e487b7160e01b600052602260045260246000fd5b50919050565b6000808335601e198436030181126152f757600080fd5b83018035915067ffffffffffffffff82111561531257600080fd5b6020019150600581901b360382131561482e57600080fd5b6000808335601e1984360301811261534157600080fd5b830160208101925035905067ffffffffffffffff81111561536157600080fd5b8060051b360382131561482e57600080fd5b8183526000602080850194508260005b85811015614d6657813587529582019590820190600101615383565b81835260007f07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8311156153d157600080fd5b8260051b80836020870137939093016020019392505050565b828152604060208201526000615400838461532a565b6060604085015261541560a085018284615373565b915050615425602085018561532a565b603f198086850301606087015261543d84838561539f565b935061544c604088018861532a565b9350915080868503016080870152506142c383838361539f565b6001600160a01b0387168152608060208201526000615489608083018789615373565b85604084015282810360608401526154a281858761539f565b9998505050505050505050565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b6000600182016154ed576154ed6154c5565b5060010190565b80820180821115610b5257610b526154c5565b8381526060602082015260006155206060830185614d36565b9050826040830152949350505050565b6000815480845260208085019450836000528060002060005b83811015614d6657815487529582019560019182019101615549565b60408152600061514c6040830185615530565b600082601f83011261558957600080fd5b815160206155968261491a565b6040516155a382826148ed565b83815260059390931b85018201928281019150868411156155c357600080fd5b8286015b848110156149a457805183529183019183016155c7565b600080604083850312156155f157600080fd5b825167ffffffffffffffff81111561560857600080fd5b61561485828601615578565b925050602083015190509250929050565b86815260806020820152600061563f60808301878961539f565b828103604084015261565281868861539f565b915050826060830152979650505050505050565b60006020828403121561567857600080fd5b815161107481614dca565b6020815260006110746020830184615530565b6000602082840312156156a857600080fd5b5051919050565b6000602082840312156156c157600080fd5b815167ffffffffffffffff8111156156d857600080fd5b61197b84828501615578565b81810381811115610b5257610b526154c5565b634e487b7160e01b600052600160045260246000fd5b8082028115828204841417610b5257610b526154c5565b60008261574157634e487b7160e01b600052601260045260246000fd5b500490565b82815260406020820152600061197b6040830184614d36565b60006001600160a01b03808816835280871660208401525060a0604083015261578b60a0830186614d36565b828103606084015261579d8186614d36565b905082810360808401526157b181856147aa565b98975050505050505050565b6000602082840312156157cf57600080fd5b815161107481614718565b600060033d11156114085760046000803e5060005160e01c90565b600060443d10156158035790565b6040516003193d81016004833e81513d67ffffffffffffffff816024840111818411171561583357505050505090565b828501915081518181111561584b5750505050505090565b843d87010160208285010111156158655750505050505090565b615874602082860101876148ed565b509095945050505050565b60006001600160a01b03808816835280871660208401525084604083015283606083015260a060808301526142c360a08301846147aa565b600082516158c9818460208701614786565b9190910192915050565b601f82111561144957600081815260208120601f850160051c810160208610156158fa5750805b601f850160051c820191505b818110156119cc57828155600101615906565b815167ffffffffffffffff811115615933576159336148d7565b6159478161594184546152a6565b846158d3565b602080601f83116001811461597c57600084156159645750858301515b600019600386901b1c1916600185901b1785556119cc565b600085815260208120601f198616915b828110156159ab5788860151825594840194600190910190840161598c565b50858210156159c95787850151600019600388901b60f8161c191681555b5050505050600190811b0190555056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220acfab0845fd4c656b9f5126781cad9d217e23c9c03f121853a771df711c5cd8264736f6c63430008130033
Loading...
Loading
Loading...
Loading
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.