Overview
APE Balance
0 APE
APE Value
$0.00More Info
Private Name Tags
ContractCreator
Latest 1 internal transaction
Parent Transaction Hash | Block | From | To | |||
---|---|---|---|---|---|---|
4620439 | 15 hrs ago | Contract Creation | 0 APE |
Loading...
Loading
Contract Source Code Verified (Exact Match)
Contract Name:
ModuleBuyListings
Compiler Version
v0.8.24+commit.e11b9ed9
Contract Source Code (Solidity Standard Json-Input format)
//SPDX-License-Identifier: LicenseRef-PolyForm-Strict-1.0.0 pragma solidity 0.8.24; import "./PaymentProcessorModuleAdvanced.sol"; import "@limitbreak/tm-core-lib/src/licenses/LicenseRef-PolyForm-Strict-1.0.0.sol"; /* @@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@( @@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@ #@@@@@@@@@@@@@@ @@@@@@@@@@@@ @@@@@@@@@@@@@@* @@@@@@@@@@@@ @@@@@@@@@@@@@@@ @ @@@@@@@@@@@@ @@@@@@@@@@@@@@@ @ @@@@@@@@@@@ @@@@@@@@@@@@@@@ @@ @@@@@@@@@@@@ @@@@@@@@@@@@@@@ #@@ @@@@@@@@@@@@/ @@@@@@@@@@@@@@. @@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@ @@@@@&%%%%%%%%&&@@@@@@@@@@@@@@ @@@@@@@@@@@@@@ @@@@@ @@@@@@@@@@@ @@@@@@@@@@@@@@@ @@@@@ @@@@@@@@@@@ @@@@@@@@@@@@@@@ @@@@@@ @@@@@@@@@@@ @@@@@@@@@@@@@@@ @@@@@@@ @@@@@@@@@@@ @@@@@@@@@@@@@@@ @@@@@@@ @@@@@@@@@@@& @@@@@@@@@@@@@@ *@@@@@@@ (@@@@@@@@@@@@ @@@@@@@@@@@@@@@ @@@@@@@@ @@@@@@@@@@@@@@ @@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ .@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@% @@@@@@@@@@@@@@@@@@@@@@@@( @@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@& @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ * @title ModuleBuyListings * @custom:version 3.0.0 * @author Limit Break, Inc. */ contract ModuleBuyListings is PaymentProcessorModuleAdvanced { constructor(address configurationContract) PaymentProcessorModuleAdvanced(configurationContract){} /** * @notice Executes a buy listing transaction for a single order item. * * @dev Throws when the maker's nonce has already been used or has been cancelled. * @dev Throws when the order has expired. * @dev Throws when the combined marketplace and royalty fee exceeds 100%. * @dev Throws when the taker fee on top exceeds 100% of the item sale price. * @dev Throws when the maker's master nonce does not match the order details. * @dev Throws when the order does not comply with the collection payment settings. * @dev Throws when the maker's signature is invalid. * @dev Throws when the order is a cosigned order and the cosignature is invalid. * @dev Throws when the transaction originates from an untrusted channel if untrusted channels are blocked. * @dev Throws when the taker does not have or did not send sufficient funds to complete the purchase. * @dev Throws when the token transfer fails for any reason such as lack of approvals or token no longer owned by maker. * @dev Throws when the maker has revoked the order digest on a ERC1155_PARTIAL_FILL order. * @dev Throws when the order is an ERC1155_PARTIAL_FILL order and the item price is not evenly divisible by the amount. * @dev Throws when the order is an ERC1155_PARTIAL_FILL order and the remaining fillable quantity is less than the requested minimum fill amount. * @dev Any unused native token payment will be returned to the taker as wrapped native token. * * @dev <h4>Postconditions:</h4> * @dev 1. Payment amounts and fees are sent to their respective recipients. * @dev 2. Purchased tokens are sent to the beneficiary. * @dev 3. Maker's nonce is marked as used for ERC721_FILL_OR_KILL and ERC1155_FILL_OR_KILL orders. * @dev 4. Maker's partially fillable order state is updated for ERC1155_PARTIAL_FILL orders. * @dev 5. An `BuyListingERC721` event has been emitted for a ERC721 purchase. * @dev 6. An `BuyListingERC1155` event has been emitted for a ERC1155 purchase. * @dev 7. A `NonceInvalidated` event has been emitted for a ERC721_FILL_OR_KILL or ERC1155_FILL_OR_KILL order. * @dev 8. A `OrderDigestInvalidated` event has been emitted for a ERC1155_PARTIAL_FILL order, if fully filled. * * @param saleDetails The order execution details. * @param sellerSignature The maker's signature authorizing the order execution. * @param cosignature The additional cosignature for a cosigned order, if applicable. * @param feeOnTop The additional fee to add on top of the order, paid by taker. */ function buyListing( Order memory saleDetails, SignatureECDSA memory sellerSignature, Cosignature memory cosignature, FeeOnTop calldata feeOnTop ) public payable { uint256 appendedDataLength; unchecked { appendedDataLength = msg.data.length - BASE_MSG_LENGTH_BUY_LISTING; } TradeContext memory context = TradeContext({ channel: msg.sender, taker: _getTaker(appendedDataLength), disablePartialFill: true, orderDigest: bytes32(0), backfillNumerator: uint16(0), backfillReceiver: address(0), bountyNumerator: uint16(0), exclusiveMarketplace: address(0), useRoyaltyBackfillAsRoyaltySource: false, protocolFeeVersion: saleDetails.protocolFeeVersion, protocolFees: appStorage().protocolFeeVersions[saleDetails.protocolFeeVersion] }); uint256 remainingNativeProceeds = _executeOrderBuySide( context, msg.value, saleDetails, sellerSignature, cosignature, feeOnTop ); _refundUnspentNativeFunds(remainingNativeProceeds, context.taker); } /** * @notice Executes an advanced buy listing transaction for a single order item. * * @dev Throws when the maker's nonce has already been used or has been cancelled. * @dev Throws when the order has expired. * @dev Throws when the combined marketplace and royalty fee exceeds 100%. * @dev Throws when the taker fee on top exceeds 100% of the item sale price. * @dev Throws when the maker's master nonce does not match the order details. * @dev Throws when the order does not comply with the collection payment settings. * @dev Throws when the maker's signature is invalid. * @dev Throws when the order is a cosigned order and the cosignature is invalid. * @dev Throws when the transaction originates from an untrusted channel if untrusted channels are blocked. * @dev Throws when the taker does not have or did not send sufficient funds to complete the purchase. * @dev Throws when the token transfer fails for any reason such as lack of approvals or token no longer owned by maker. * @dev Throws when the maker has revoked the order digest on a ERC1155_PARTIAL_FILL order. * @dev Throws when the order is an ERC1155_PARTIAL_FILL order and the item price is not evenly divisible by the amount. * @dev Throws when the order is an ERC1155_PARTIAL_FILL order and the remaining fillable quantity is less than the requested minimum fill amount. * @dev Any unused native token payment will be returned to the taker as wrapped native token. * @dev Throws when the provided bulk order merkle proof and order index are invalid. * @dev Throws when the provided permit processor does not have approval to move the token or receives an invalid signature. * * @dev <h4>Postconditions:</h4> * @dev 1. Payment amounts and fees are sent to their respective recipients. * @dev 2. Purchased tokens are sent to the beneficiary. * @dev 3. Maker's nonce is marked as used for ERC721_FILL_OR_KILL and ERC1155_FILL_OR_KILL orders. * @dev 4. Maker's partially fillable order state is updated for ERC1155_PARTIAL_FILL orders. * @dev 5. An `BuyListingERC721` event has been emitted for a ERC721 purchase. * @dev 6. An `BuyListingERC1155` event has been emitted for a ERC1155 purchase. * @dev 7. A `NonceInvalidated` event has been emitted for a ERC721_FILL_OR_KILL or ERC1155_FILL_OR_KILL order. * @dev 8. A `OrderDigestInvalidated` event has been emitted for a ERC1155_PARTIAL_FILL order, if fully filled. * * @param advancedListing The cosigner, maker, and taker signatures, order details and permit details. * @param bulkOrderProof The merkle proofs and order index for an offer that was created via signing a merkle tree. * @param feeOnTop The additional fee to add on top of the order, paid by taker. */ function buyListingAdvanced( AdvancedOrder memory advancedListing, BulkOrderProof calldata bulkOrderProof, FeeOnTop calldata feeOnTop ) public payable { uint256 appendedDataLength; unchecked { appendedDataLength = msg.data.length - BASE_MSG_LENGTH_BUY_LISTING_ADVANCED - (PROOF_ELEMENT_SIZE * bulkOrderProof.proof.length); } TradeContext memory context = TradeContext({ channel: msg.sender, taker: _getTaker(appendedDataLength), disablePartialFill: true, orderDigest: bytes32(0), backfillNumerator: uint16(0), backfillReceiver: address(0), bountyNumerator: uint16(0), exclusiveMarketplace: address(0), useRoyaltyBackfillAsRoyaltySource: false, protocolFeeVersion: advancedListing.saleDetails.protocolFeeVersion, protocolFees: appStorage().protocolFeeVersions[advancedListing.saleDetails.protocolFeeVersion] }); uint256 remainingNativeProceeds = _executeOrderBuySideAdvanced( context, msg.value, advancedListing, bulkOrderProof, feeOnTop ); _refundUnspentNativeFunds(remainingNativeProceeds, context.taker); } /** * @notice Executes a buy listing transaction for multiple order items. * * @dev Throws when a maker's nonce has already been used or has been cancelled. * @dev Throws when any order has expired. * @dev Throws when any combined marketplace and royalty fee exceeds 100%. * @dev Throws when any taker fee on top exceeds 100% of the item sale price. * @dev Throws when a maker's master nonce does not match the order details. * @dev Throws when an order does not comply with the collection payment settings. * @dev Throws when a maker's signature is invalid. * @dev Throws when an order is a cosigned order and the cosignature is invalid. * @dev Throws when the transaction originates from an untrusted channel if untrusted channels are blocked. * @dev Throws when the taker does not have or did not send sufficient funds to complete the purchase. * @dev Throws when a maker has revoked the order digest on a ERC1155_PARTIAL_FILL order. * @dev Throws when an order is an ERC1155_PARTIAL_FILL order and the item price is not evenly divisible by the amount. * @dev Throws when an order is an ERC1155_PARTIAL_FILL order and the remaining fillable quantity is less than the requested minimum fill amount. * @dev Will NOT throw when a token fails to transfer but also will not disperse payments for failed items. * @dev Any unused native token payment will be returned to the taker as wrapped native token. * * @dev <h4>Postconditions:</h4> * @dev 1. Payment amounts and fees are sent to their respective recipients. * @dev 2. Purchased tokens are sent to the beneficiary. * @dev 3. Makers nonces are marked as used for ERC721_FILL_OR_KILL and ERC1155_FILL_OR_KILL orders. * @dev 4. Makers partially fillable order states are updated for ERC1155_PARTIAL_FILL orders. * @dev 5. `BuyListingERC721` events have been emitted for each ERC721 purchase. * @dev 6. `BuyListingERC1155` events have been emitted for each ERC1155 purchase. * @dev 7. A `NonceInvalidated` event has been emitted for each ERC721_FILL_OR_KILL or ERC1155_FILL_OR_KILL order. * @dev 8. A `OrderDigestInvalidated` event has been emitted for each ERC1155_PARTIAL_FILL order, if fully filled. * * @param saleDetailsArray An array of order execution details. * @param sellerSignatures An array of maker signatures authorizing the order execution. * @param cosignatures An array of additional cosignatures for cosigned orders, if applicable. * @param feesOnTop An array of additional fees to add on top of the orders, paid by taker. */ function bulkBuyListings( Order[] calldata saleDetailsArray, SignatureECDSA[] calldata sellerSignatures, Cosignature[] calldata cosignatures, FeeOnTop[] calldata feesOnTop ) public payable { if (saleDetailsArray.length != sellerSignatures.length) { revert PaymentProcessor__InputArrayLengthMismatch(); } if (saleDetailsArray.length != cosignatures.length) { revert PaymentProcessor__InputArrayLengthMismatch(); } if (saleDetailsArray.length != feesOnTop.length) { revert PaymentProcessor__InputArrayLengthMismatch(); } if (saleDetailsArray.length == 0) { revert PaymentProcessor__InputArrayLengthCannotBeZero(); } uint256 appendedDataLength; unchecked { appendedDataLength = msg.data.length - BASE_MSG_LENGTH_BULK_BUY_LISTINGS - (BASE_MSG_LENGTH_BULK_BUY_LISTINGS_PER_ITEM * saleDetailsArray.length); } TradeContext memory context = TradeContext({ channel: msg.sender, taker: _getTaker(appendedDataLength), disablePartialFill: false, orderDigest: bytes32(0), backfillNumerator: uint16(0), backfillReceiver: address(0), bountyNumerator: uint16(0), exclusiveMarketplace: address(0), useRoyaltyBackfillAsRoyaltySource: false, protocolFeeVersion: saleDetailsArray[0].protocolFeeVersion, protocolFees: appStorage().protocolFeeVersions[saleDetailsArray[0].protocolFeeVersion] }); uint256 remainingNativeProceeds = msg.value; Order memory saleDetails; SignatureECDSA memory sellerSignature; Cosignature memory cosignature; FeeOnTop calldata feeOnTop; for (uint256 i = 0; i < saleDetailsArray.length;) { saleDetails = saleDetailsArray[i]; sellerSignature = sellerSignatures[i]; cosignature = cosignatures[i]; feeOnTop = feesOnTop[i]; if (context.protocolFeeVersion != saleDetails.protocolFeeVersion) { context.protocolFeeVersion = saleDetails.protocolFeeVersion; context.protocolFees = appStorage().protocolFeeVersions[saleDetails.protocolFeeVersion]; } remainingNativeProceeds = _executeOrderBuySide( context, remainingNativeProceeds, saleDetails, sellerSignature, cosignature, feeOnTop); unchecked { ++i; } } _refundUnspentNativeFunds(remainingNativeProceeds, context.taker); } /** * @notice Executes an advanced buy listing transaction for multiple order items. * * @dev Throws when a maker's nonce has already been used or has been cancelled. * @dev Throws when any order has expired. * @dev Throws when any combined marketplace and royalty fee exceeds 100%. * @dev Throws when any taker fee on top exceeds 100% of the item sale price. * @dev Throws when a maker's master nonce does not match the order details. * @dev Throws when an order does not comply with the collection payment settings. * @dev Throws when a maker's signature is invalid. * @dev Throws when an order is a cosigned order and the cosignature is invalid. * @dev Throws when the transaction originates from an untrusted channel if untrusted channels are blocked. * @dev Throws when the taker does not have or did not send sufficient funds to complete the purchase. * @dev Throws when a maker has revoked the order digest on a ERC1155_PARTIAL_FILL order. * @dev Throws when an order is an ERC1155_PARTIAL_FILL order and the item price is not evenly divisible by the amount. * @dev Throws when an order is an ERC1155_PARTIAL_FILL order and the remaining fillable quantity is less than the requested minimum fill amount. * @dev Throws when any provided bulk order merkle proof and order index are invalid. * @dev Throws when any provided permit processor does not have approval to move the token or receives an invalid signature. * @dev Will NOT throw when a token fails to transfer but also will not disperse payments for failed items. * @dev Any unused native token payment will be returned to the taker as wrapped native token. * * @dev <h4>Postconditions:</h4> * @dev 1. Payment amounts and fees are sent to their respective recipients. * @dev 2. Purchased tokens are sent to the beneficiary. * @dev 3. Makers nonces are marked as used for ERC721_FILL_OR_KILL and ERC1155_FILL_OR_KILL orders. * @dev 4. Makers partially fillable order states are updated for ERC1155_PARTIAL_FILL orders. * @dev 5. `BuyListingERC721` events have been emitted for each ERC721 purchase. * @dev 6. `BuyListingERC1155` events have been emitted for each ERC1155 purchase. * @dev 7. A `NonceInvalidated` event has been emitted for each ERC721_FILL_OR_KILL or ERC1155_FILL_OR_KILL order. * @dev 8. A `OrderDigestInvalidated` event has been emitted for each ERC1155_PARTIAL_FILL order, if fully filled. * * @param advancedListingsArray An array of cosigner, maker, and taker signatures, order details and permit details. * @param bulkOrderProofs The merkle proofs and order index for an offer that was created via signing a merkle tree. * @param feesOnTop An array of additional fees to add on top of the orders, paid by taker. */ function bulkBuyListingsAdvanced( AdvancedOrder[] calldata advancedListingsArray, BulkOrderProof[] calldata bulkOrderProofs, FeeOnTop[] calldata feesOnTop ) public payable { if (advancedListingsArray.length == 0) { revert PaymentProcessor__InputArrayLengthCannotBeZero(); } if (advancedListingsArray.length != feesOnTop.length) { revert PaymentProcessor__InputArrayLengthMismatch(); } if (advancedListingsArray.length != bulkOrderProofs.length) { revert PaymentProcessor__InputArrayLengthMismatch(); } uint256 remainingNativeProceeds = msg.value; uint256 appendedDataLength; unchecked { appendedDataLength = msg.data.length - BASE_MSG_LENGTH_BULK_BUY_LISTINGS_ADVANCED - (BASE_MSG_LENGTH_BULK_BUY_LISTINGS_ADVANCED_PER_ITEM * advancedListingsArray.length); for (uint256 i = 0; i < advancedListingsArray.length; ++i) { appendedDataLength -= PROOF_ELEMENT_SIZE * bulkOrderProofs[i].proof.length; } } TradeContext memory context = TradeContext({ channel: msg.sender, taker: _getTaker(appendedDataLength), disablePartialFill: false, orderDigest: bytes32(0), backfillNumerator: uint16(0), backfillReceiver: address(0), bountyNumerator: uint16(0), exclusiveMarketplace: address(0), useRoyaltyBackfillAsRoyaltySource: false, protocolFeeVersion: advancedListingsArray[0].saleDetails.protocolFeeVersion, protocolFees: appStorage().protocolFeeVersions[advancedListingsArray[0].saleDetails.protocolFeeVersion] }); AdvancedOrder memory advancedListing; for (uint256 i = 0; i < advancedListingsArray.length;) { advancedListing = advancedListingsArray[i]; if (context.protocolFeeVersion != advancedListing.saleDetails.protocolFeeVersion) { context.protocolFeeVersion = advancedListing.saleDetails.protocolFeeVersion; context.protocolFees = appStorage().protocolFeeVersions[advancedListing.saleDetails.protocolFeeVersion]; } remainingNativeProceeds = _executeOrderBuySideAdvanced( context, remainingNativeProceeds, advancedListing, bulkOrderProofs[i], feesOnTop[i]); unchecked { ++i; } } _refundUnspentNativeFunds(remainingNativeProceeds, context.taker); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.4; /// @dev Storage data struct for stored approvals and order approvals struct PackedApproval { // Only used for partial fill position 1155 transfers uint8 state; // Amount allowed uint200 amount; // Permission expiry uint48 expiration; } /// @dev Calldata data struct for order fill amounts struct OrderFillAmounts { uint256 orderStartAmount; uint256 requestedFillAmount; uint256 minimumFillAmount; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.4; import {OrderFillAmounts} from "../DataTypes.sol"; interface IPermitC { /** * ================================================= * ==================== Events ===================== * ================================================= */ /// @dev Emitted when an approval is stored event Approval( address indexed owner, address indexed token, address indexed operator, uint256 id, uint200 amount, uint48 expiration ); /// @dev Emitted when a user increases their master nonce event Lockdown(address indexed owner); /// @dev Emitted when an order is opened event OrderOpened( bytes32 indexed orderId, address indexed owner, address indexed operator, uint256 fillableQuantity ); /// @dev Emitted when an order has a fill event OrderFilled( bytes32 indexed orderId, address indexed owner, address indexed operator, uint256 amount ); /// @dev Emitted when an order has been fully filled or cancelled event OrderClosed( bytes32 indexed orderId, address indexed owner, address indexed operator, bool wasCancellation); /// @dev Emitted when an order has an amount restored due to a failed transfer event OrderRestored( bytes32 indexed orderId, address indexed owner, uint256 amountRestoredToOrder ); /** * ================================================= * ============== Approval Transfers =============== * ================================================= */ function approve(uint256 tokenType, address token, uint256 id, address operator, uint200 amount, uint48 expiration) external; function updateApprovalBySignature( uint256 tokenType, address token, uint256 id, uint256 nonce, uint200 amount, address operator, uint48 approvalExpiration, uint48 sigDeadline, address owner, bytes calldata signedPermit ) external; function allowance( address owner, address operator, uint256 tokenType, address token, uint256 id ) external view returns (uint256 amount, uint256 expiration); /** * ================================================= * ================ Signed Transfers =============== * ================================================= */ function registerAdditionalDataHash(string memory additionalDataTypeString) external; function permitTransferFromERC721( address token, uint256 id, uint256 nonce, uint256 expiration, address owner, address to, bytes calldata signedPermit ) external returns (bool isError); function permitTransferFromWithAdditionalDataERC721( address token, uint256 id, uint256 nonce, uint256 expiration, address owner, address to, bytes32 additionalData, bytes32 advancedPermitHash, bytes calldata signedPermit ) external returns (bool isError); function permitTransferFromERC1155( address token, uint256 id, uint256 nonce, uint256 permitAmount, uint256 expiration, address owner, address to, uint256 transferAmount, bytes calldata signedPermit ) external returns (bool isError); function permitTransferFromWithAdditionalDataERC1155( address token, uint256 id, uint256 nonce, uint256 permitAmount, uint256 expiration, address owner, address to, uint256 transferAmount, bytes32 additionalData, bytes32 advancedPermitHash, bytes calldata signedPermit ) external returns (bool isError); function permitTransferFromERC20( address token, uint256 nonce, uint256 permitAmount, uint256 expiration, address owner, address to, uint256 transferAmount, bytes calldata signedPermit ) external returns (bool isError); function permitTransferFromWithAdditionalDataERC20( address token, uint256 nonce, uint256 permitAmount, uint256 expiration, address owner, address to, uint256 transferAmount, bytes32 additionalData, bytes32 advancedPermitHash, bytes calldata signedPermit ) external returns (bool isError); function isRegisteredTransferAdditionalDataHash(bytes32 hash) external view returns (bool isRegistered); function isRegisteredOrderAdditionalDataHash(bytes32 hash) external view returns (bool isRegistered); /** * ================================================= * =============== Order Transfers ================= * ================================================= */ function fillPermittedOrderERC1155( bytes calldata signedPermit, OrderFillAmounts calldata orderFillAmounts, address token, uint256 id, address owner, address to, uint256 nonce, uint48 expiration, bytes32 orderId, bytes32 advancedPermitHash ) external returns (uint256 quantityFilled, bool isError); function fillPermittedOrderERC20( bytes calldata signedPermit, OrderFillAmounts calldata orderFillAmounts, address token, address owner, address to, uint256 nonce, uint48 expiration, bytes32 orderId, bytes32 advancedPermitHash ) external returns (uint256 quantityFilled, bool isError); function closePermittedOrder( address owner, address operator, uint256 tokenType, address token, uint256 id, bytes32 orderId ) external; function allowance( address owner, address operator, uint256 tokenType, address token, uint256 id, bytes32 orderId ) external view returns (uint256 amount, uint256 expiration); /** * ================================================= * ================ Nonce Management =============== * ================================================= */ function invalidateUnorderedNonce(uint256 nonce) external; function isValidUnorderedNonce(address owner, uint256 nonce) external view returns (bool isValid); function lockdown() external; function masterNonce(address owner) external view returns (uint256); /** * ================================================= * ============== Transfer Functions =============== * ================================================= */ function transferFromERC721( address from, address to, address token, uint256 id ) external returns (bool isError); function transferFromERC1155( address from, address to, address token, uint256 id, uint256 amount ) external returns (bool isError); function transferFromERC20( address from, address to, address token, uint256 amount ) external returns (bool isError); /** * ================================================= * ============ Signature Verification ============= * ================================================= */ function domainSeparatorV4() external view returns (bytes32); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.3) (metatx/ERC2771Context.sol) pragma solidity ^0.8.4; import "@openzeppelin/contracts/utils/Context.sol"; import "./interfaces/ITrustedForwarderFactory.sol"; /** * @title TrustedForwarderERC2771Context * @author Limit Break, Inc. * @notice Context variant that utilizes the TrustedForwarderFactory contract to determine if the sender is a trusted forwarder. */ abstract contract TrustedForwarderERC2771Context is Context { ITrustedForwarderFactory private immutable _factory; constructor(address factory) { _factory = ITrustedForwarderFactory(factory); } /** * @notice Returns true if the sender is a trusted forwarder, false otherwise. * * @dev This function is required by ERC2771Context. * * @param forwarder The address to check. * @return True if the provided address is a trusted forwarder, false otherwise. */ function isTrustedForwarder(address forwarder) public view virtual returns (bool) { return _factory.isTrustedForwarder(forwarder); } function _msgSender() internal view virtual override returns (address sender) { if (_factory.isTrustedForwarder(msg.sender)) { if (msg.data.length >= 20) { // The assembly code is more direct than the Solidity version using `abi.decode`. /// @solidity memory-safe-assembly assembly { sender := shr(96, calldataload(sub(calldatasize(), 20))) } } else { return super._msgSender(); } } else { return super._msgSender(); } } function _msgData() internal view virtual override returns (bytes calldata data) { if (_factory.isTrustedForwarder(msg.sender)) { assembly { let len := calldatasize() // Create a slice that defaults to the entire calldata data.offset := 0 data.length := len // If the calldata is > 20 bytes, it contains the sender address at the end // and needs to be truncated if gt(len, 0x14) { data.length := sub(len, 0x14) } } } else { return super._msgData(); } } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.4; interface ITrustedForwarderFactory { error TrustedForwarderFactory__TrustedForwarderInitFailed(address admin, address appSigner); event TrustedForwarderCreated(address indexed trustedForwarder); function cloneTrustedForwarder(address admin, address appSigner, bytes32 salt) external returns (address trustedForwarder); function forwarders(address) external view returns (bool); function isTrustedForwarder(address sender) external view returns (bool); function trustedForwarderImplementation() external view returns (address); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.4) (utils/Context.sol) pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } function _contextSuffixLength() internal view virtual returns (uint256) { return 0; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (utils/Strings.sol) pragma solidity ^0.8.0; import "./math/Math.sol"; import "./math/SignedMath.sol"; /** * @dev String operations. */ library Strings { bytes16 private constant _SYMBOLS = "0123456789abcdef"; uint8 private constant _ADDRESS_LENGTH = 20; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { unchecked { uint256 length = Math.log10(value) + 1; string memory buffer = new string(length); uint256 ptr; /// @solidity memory-safe-assembly assembly { ptr := add(buffer, add(32, length)) } while (true) { ptr--; /// @solidity memory-safe-assembly assembly { mstore8(ptr, byte(mod(value, 10), _SYMBOLS)) } value /= 10; if (value == 0) break; } return buffer; } } /** * @dev Converts a `int256` to its ASCII `string` decimal representation. */ function toString(int256 value) internal pure returns (string memory) { return string(abi.encodePacked(value < 0 ? "-" : "", toString(SignedMath.abs(value)))); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { unchecked { return toHexString(value, Math.log256(value) + 1); } } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } /** * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation. */ function toHexString(address addr) internal pure returns (string memory) { return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH); } /** * @dev Returns true if the two strings are equal. */ function equal(string memory a, string memory b) internal pure returns (bool) { return keccak256(bytes(a)) == keccak256(bytes(b)); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (utils/cryptography/ECDSA.sol) pragma solidity ^0.8.0; import "../Strings.sol"; /** * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations. * * These functions can be used to verify that a message was signed by the holder * of the private keys of a given address. */ library ECDSA { enum RecoverError { NoError, InvalidSignature, InvalidSignatureLength, InvalidSignatureS, InvalidSignatureV // Deprecated in v4.8 } function _throwError(RecoverError error) private pure { if (error == RecoverError.NoError) { return; // no error: do nothing } else if (error == RecoverError.InvalidSignature) { revert("ECDSA: invalid signature"); } else if (error == RecoverError.InvalidSignatureLength) { revert("ECDSA: invalid signature length"); } else if (error == RecoverError.InvalidSignatureS) { revert("ECDSA: invalid signature 's' value"); } } /** * @dev Returns the address that signed a hashed message (`hash`) with * `signature` or error string. This address can then be used for verification purposes. * * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures: * this function rejects them by requiring the `s` value to be in the lower * half order, and the `v` value to be either 27 or 28. * * IMPORTANT: `hash` _must_ be the result of a hash operation for the * verification to be secure: it is possible to craft signatures that * recover to arbitrary addresses for non-hashed data. A safe way to ensure * this is by receiving a hash of the original message (which may otherwise * be too long), and then calling {toEthSignedMessageHash} on it. * * Documentation for signature generation: * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js] * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers] * * _Available since v4.3._ */ function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) { if (signature.length == 65) { bytes32 r; bytes32 s; uint8 v; // ecrecover takes the signature parameters, and the only way to get them // currently is to use assembly. /// @solidity memory-safe-assembly assembly { r := mload(add(signature, 0x20)) s := mload(add(signature, 0x40)) v := byte(0, mload(add(signature, 0x60))) } return tryRecover(hash, v, r, s); } else { return (address(0), RecoverError.InvalidSignatureLength); } } /** * @dev Returns the address that signed a hashed message (`hash`) with * `signature`. This address can then be used for verification purposes. * * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures: * this function rejects them by requiring the `s` value to be in the lower * half order, and the `v` value to be either 27 or 28. * * IMPORTANT: `hash` _must_ be the result of a hash operation for the * verification to be secure: it is possible to craft signatures that * recover to arbitrary addresses for non-hashed data. A safe way to ensure * this is by receiving a hash of the original message (which may otherwise * be too long), and then calling {toEthSignedMessageHash} on it. */ function recover(bytes32 hash, bytes memory signature) internal pure returns (address) { (address recovered, RecoverError error) = tryRecover(hash, signature); _throwError(error); return recovered; } /** * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately. * * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures] * * _Available since v4.3._ */ function tryRecover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address, RecoverError) { bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff); uint8 v = uint8((uint256(vs) >> 255) + 27); return tryRecover(hash, v, r, s); } /** * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately. * * _Available since v4.2._ */ function recover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address) { (address recovered, RecoverError error) = tryRecover(hash, r, vs); _throwError(error); return recovered; } /** * @dev Overload of {ECDSA-tryRecover} that receives the `v`, * `r` and `s` signature fields separately. * * _Available since v4.3._ */ function tryRecover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal pure returns (address, RecoverError) { // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most // signatures from current libraries generate a unique signature with an s-value in the lower half order. // // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept // these malleable signatures as well. if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) { return (address(0), RecoverError.InvalidSignatureS); } // If the signature is valid (and not malleable), return the signer address address signer = ecrecover(hash, v, r, s); if (signer == address(0)) { return (address(0), RecoverError.InvalidSignature); } return (signer, RecoverError.NoError); } /** * @dev Overload of {ECDSA-recover} that receives the `v`, * `r` and `s` signature fields separately. */ function recover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal pure returns (address) { (address recovered, RecoverError error) = tryRecover(hash, v, r, s); _throwError(error); return recovered; } /** * @dev Returns an Ethereum Signed Message, created from a `hash`. This * produces hash corresponding to the one signed with the * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] * JSON-RPC method as part of EIP-191. * * See {recover}. */ function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32 message) { // 32 is the length in bytes of hash, // enforced by the type signature above /// @solidity memory-safe-assembly assembly { mstore(0x00, "\x19Ethereum Signed Message:\n32") mstore(0x1c, hash) message := keccak256(0x00, 0x3c) } } /** * @dev Returns an Ethereum Signed Message, created from `s`. This * produces hash corresponding to the one signed with the * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] * JSON-RPC method as part of EIP-191. * * See {recover}. */ function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) { return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n", Strings.toString(s.length), s)); } /** * @dev Returns an Ethereum Signed Typed Data, created from a * `domainSeparator` and a `structHash`. This produces hash corresponding * to the one signed with the * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`] * JSON-RPC method as part of EIP-712. * * See {recover}. */ function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32 data) { /// @solidity memory-safe-assembly assembly { let ptr := mload(0x40) mstore(ptr, "\x19\x01") mstore(add(ptr, 0x02), domainSeparator) mstore(add(ptr, 0x22), structHash) data := keccak256(ptr, 0x42) } } /** * @dev Returns an Ethereum Signed Data with intended validator, created from a * `validator` and `data` according to the version 0 of EIP-191. * * See {recover}. */ function toDataWithIntendedValidatorHash(address validator, bytes memory data) internal pure returns (bytes32) { return keccak256(abi.encodePacked("\x19\x00", validator, data)); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.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) { // Solidity will revert if denominator == 0, unlike the div opcode on its own. // The surrounding unchecked block does not change this fact. // See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic. return prod0 / denominator; } // Make sure the result is less than 2^256. Also prevents denominator == 0. require(denominator > prod1, "Math: mulDiv overflow"); /////////////////////////////////////////////// // 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 256, 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 << 3) < value ? 1 : 0); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SignedMath.sol) pragma solidity ^0.8.0; /** * @dev Standard signed math utilities missing in the Solidity language. */ library SignedMath { /** * @dev Returns the largest of two signed numbers. */ function max(int256 a, int256 b) internal pure returns (int256) { return a > b ? a : b; } /** * @dev Returns the smallest of two signed numbers. */ function min(int256 a, int256 b) internal pure returns (int256) { return a < b ? a : b; } /** * @dev Returns the average of two signed numbers without overflow. * The result is rounded towards zero. */ function average(int256 a, int256 b) internal pure returns (int256) { // Formula from the book "Hacker's Delight" int256 x = (a & b) + ((a ^ b) >> 1); return x + (int256(uint256(x) >> 255) & (a ^ b)); } /** * @dev Returns the absolute unsigned value of a signed value. */ function abs(int256 n) internal pure returns (uint256) { unchecked { // must be unchecked in order to support `n = type(int256).min` return uint256(n >= 0 ? n : -n); } } }
//SPDX-License-Identifier: LicenseRef-PolyForm-Strict-1.0.0 pragma solidity ^0.8.0; /* # PolyForm Strict License 1.0.0 <https://polyformproject.org/licenses/strict/1.0.0> ## Acceptance In order to get any license under these terms, you must agree to them as both strict obligations and conditions to all your licenses. ## Copyright License The licensor grants you a copyright license for the software to do everything you might do with the software that would otherwise infringe the licensor's copyright in it for any permitted purpose, other than distributing the software or making changes or new works based on the software. ## Patent License The licensor grants you a patent license for the software that covers patent claims the licensor can license, or becomes able to license, that you would infringe by using the software. ## Noncommercial Purposes Any noncommercial purpose is a permitted purpose. ## Personal Uses Personal use for research, experiment, and testing for the benefit of public knowledge, personal study, private entertainment, hobby projects, amateur pursuits, or religious observance, without any anticipated commercial application, is use for a permitted purpose. ## Noncommercial Organizations Use by any charitable organization, educational institution, public research organization, public safety or health organization, environmental protection organization, or government institution is use for a permitted purpose regardless of the source of funding or obligations resulting from the funding. ## Fair Use You may have "fair use" rights for the software under the law. These terms do not limit them. ## No Other Rights These terms do not allow you to sublicense or transfer any of your licenses to anyone else, or prevent the licensor from granting licenses to anyone else. These terms do not imply any other licenses. ## Patent Defense If you make any written claim that the software infringes or contributes to infringement of any patent, your patent license for the software granted under these terms ends immediately. If your company makes such a claim, your patent license ends immediately for work on behalf of your company. ## Violations The first time you are notified in writing that you have violated any of these terms, or done anything with the software not covered by your licenses, your licenses can nonetheless continue if you come into full compliance with these terms, and take practical steps to correct past violations, within 32 days of receiving notice. Otherwise, all your licenses end immediately. ## No Liability ***As far as the law allows, the software comes as is, without any warranty or condition, and the licensor will not be liable to you for any damages arising out of these terms or the use or nature of the software, under any kind of legal claim.*** ## Definitions The **licensor** is the individual or entity offering these terms, and the **software** is the software the licensor makes available under these terms. **You** refers to the individual or entity agreeing to these terms. **Your company** is any legal entity, sole proprietorship, or other kind of organization that you work for, plus all organizations that have control over, are under the control of, or are under common control with that organization. **Control** means ownership of substantially all the assets of an entity, or the power to direct its management and policies by vote, contract, or otherwise. Control can be direct or indirect. **Your licenses** are all the licenses granted to you for the software under these terms. **Use** means anything you do with the software requiring one of your licenses. */
pragma solidity ^0.8.4; import "../../utils/introspection/IERC165.sol"; /** * @dev Required interface of an ERC1155 compliant contract, as defined in the * https://eips.ethereum.org/EIPS/eip-1155[EIP]. */ interface IERC1155 is IERC165 { /** * @dev Emitted when `value` amount of tokens of 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 value 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 a `value` amount of tokens of type `id` from `from` to `to`. * * WARNING: This function can potentially allow a reentrancy attack when transferring tokens * to an untrusted contract, when invoking {onERC1155Received} on the receiver. * Ensure to follow the checks-effects-interactions pattern and consider employing * reentrancy guards when interacting with untrusted contracts. * * 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 `value` 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 value, bytes calldata data) external; /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {safeTransferFrom}. * * WARNING: This function can potentially allow a reentrancy attack when transferring tokens * to an untrusted contract, when invoking {onERC1155BatchReceived} on the receiver. * Ensure to follow the checks-effects-interactions pattern and consider employing * reentrancy guards when interacting with untrusted contracts. * * Emits either a {TransferSingle} or a {TransferBatch} event, depending on the length of the array arguments. * * Requirements: * * - `ids` and `values` 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 values, bytes calldata data ) external; }
//SPDX-License-Identifier: MIT pragma solidity ^0.8.4; library SafeERC20 { /** * @dev A gas efficient, and fallback-safe method to transfer ERC20 tokens owned by the contract. * * @param tokenAddress The address of the token to transfer. * @param to The address to transfer tokens to. * @param amount The amount of tokens to transfer. * * @return isError True if there was an error transferring, false if the call was successful. */ function safeTransfer( address tokenAddress, address to, uint256 amount ) internal returns(bool isError) { assembly { function _callTransfer(_tokenAddress, _to, _amount) -> _isError { let ptr := mload(0x40) mstore(0x40, add(ptr, 0x60)) mstore(ptr, 0xa9059cbb) mstore(add(0x20, ptr), _to) mstore(add(0x40, ptr), _amount) if call(gas(), _tokenAddress, 0, add(ptr, 0x1C), 0x44, 0x00, 0x00) { if lt(returndatasize(), 0x20) { _isError := iszero(extcodesize(_tokenAddress)) leave } returndatacopy(0x00, 0x00, 0x20) _isError := iszero(mload(0x00)) leave } _isError := true } isError := _callTransfer(tokenAddress, to, amount) } } /** * @dev A gas efficient, and fallback-safe method to transfer ERC20 tokens owned by another address. * * @param tokenAddress The address of the token to transfer. * @param from The address to transfer tokens from. * @param to The address to transfer tokens to. * @param amount The amount of tokens to transfer. * * @return isError True if there was an error transferring, false if the call was successful. */ function safeTransferFrom( address tokenAddress, address from, address to, uint256 amount ) internal returns(bool isError) { assembly { function _callTransferFrom(_tokenAddress, _from, _to, _amount) -> _isError { let ptr := mload(0x40) mstore(0x40, add(ptr, 0x80)) mstore(ptr, 0x23b872dd) mstore(add(0x20, ptr), _from) mstore(add(0x40, ptr), _to) mstore(add(0x60, ptr), _amount) if call(gas(), _tokenAddress, 0, add(ptr, 0x1C), 0x64, 0x00, 0x00) { if lt(returndatasize(), 0x20) { _isError := iszero(extcodesize(_tokenAddress)) leave } returndatacopy(0x00, 0x00, 0x20) _isError := iszero(mload(0x00)) leave } _isError := true } isError := _callTransferFrom(tokenAddress, from, to, amount) } } /** * @dev A gas efficient, and fallback-safe method to set approval on ERC20 tokens. * * @param tokenAddress The address of the token to transfer. * @param spender The address to allow to spend tokens. * @param allowance The amount of tokens to allow `spender` to transfer. * * @return isError True if there was an error setting allowance, false if the call was successful. */ function safeApprove( address tokenAddress, address spender, uint256 allowance ) internal returns(bool isError) { assembly { function _callApprove(_tokenAddress, _spender, _allowance) -> _isError { let ptr := mload(0x40) mstore(0x40, add(ptr, 0x60)) mstore(ptr, 0x095ea7b3) mstore(add(0x20, ptr), _spender) mstore(add(0x40, ptr), _allowance) if call(gas(), _tokenAddress, 0, add(ptr, 0x1C), 0x44, 0x00, 0x00) { if lt(returndatasize(), 0x20) { _isError := iszero(extcodesize(_tokenAddress)) leave } returndatacopy(0x00, 0x00, 0x20) _isError := iszero(mload(0x00)) leave } _isError := true } isError := _callApprove(tokenAddress, spender, allowance) } } /** * @dev A gas efficient, and fallback-safe method to set approval on ERC20 tokens. * @dev If the initial approve fails, it will retry setting the allowance to zero and then * @dev to the new allowance. * * @param tokenAddress The address of the token to transfer. * @param spender The address to allow to spend tokens. * @param allowance The amount of tokens to allow `spender` to transfer. * * @return isError True if there was an error setting allowance, false if the call was successful. */ function safeApproveWithRetryAfterZero( address tokenAddress, address spender, uint256 allowance ) internal returns(bool isError) { assembly { function _callApprove(_ptr, _tokenAddress, _spender, _allowance) -> _isError { mstore(add(0x40, _ptr), _allowance) if call(gas(), _tokenAddress, 0, add(_ptr, 0x1C), 0x44, 0x00, 0x00) { if lt(returndatasize(), 0x20) { _isError := iszero(extcodesize(_tokenAddress)) leave } returndatacopy(0x00, 0x00, 0x20) _isError := iszero(mload(0x00)) leave } _isError := true } let ptr := mload(0x40) mstore(0x40, add(ptr, 0x60)) mstore(ptr, 0x095ea7b3) mstore(add(0x20, ptr), spender) isError := _callApprove(ptr, tokenAddress, spender, allowance) if isError { pop(_callApprove(ptr, tokenAddress, spender, 0x00)) isError := _callApprove(ptr, tokenAddress, spender, allowance) } } } }
pragma solidity ^0.8.4; import "../../utils/introspection/IERC165.sol"; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon * a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external; /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or * {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon * a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom(address from, address to, uint256 tokenId) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721 * or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must * understand this adds an external call which potentially creates a reentrancy vulnerability. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom(address from, address to, uint256 tokenId) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the address zero. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool approved) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.13; /** * @title EfficientHash * * @author Limit Break * * @notice Performs keccak256 hashing of value type parameters more efficiently than * @notice high-level Solidity by utilizing scratch space for one or two values and * @notice efficient utilization of memory for parameter counts greater than two. * * @notice Gas savings for EfficientHash compared to keccak256(abi.encode(...)): * @notice Parameter Count / Gas Savings (Shanghai) / Gas Savings (Cancun): 1 / 67 / 67 * @notice Parameter Count / Gas Savings (Shanghai) / Gas Savings (Cancun): 5 / 66 / 66 * @notice Parameter Count / Gas Savings (Shanghai) / Gas Savings (Cancun): 10 / 58 / 58 * @notice Parameter Count / Gas Savings (Shanghai) / Gas Savings (Cancun): 15 / 1549 / 565 * @notice Parameter Count / Gas Savings (Shanghai) / Gas Savings (Cancun): 20 / 3379 / 1027 * @notice Parameter Count / Gas Savings (Shanghai) / Gas Savings (Cancun): 25 / 5807 / 1650 * @notice Parameter Count / Gas Savings (Shanghai) / Gas Savings (Cancun): 50 / 23691 / 10107 * @notice Parameter Count / Gas Savings (Shanghai) / Gas Savings (Cancun): 75 / 69164 / 41620 * @notice Parameter Count / Gas Savings (Shanghai) / Gas Savings (Cancun): 99 / 172694 / 126646 * * @dev Notes: * @dev - `efficientHash` is overloaded for parameter counts between one and eight. * @dev - Parameter counts between nine and sixteen require two functions to avoid * @dev stack too deep errors. Each parameter count has a dedicated set of functions * @dev (`efficientHashNineStep1`/`efficientHashNineStep2` ... `efficientHashSixteenStep1`/`efficientHashSixteenStep2`) * @dev that must both be called to get the hash. * @dev `Step1` functions take eight parameters and return a memory pointer that is passed to `Step2` * @dev `Step2` functions take the remaining parameters and return the hash of the values * @dev Example: * @dev bytes32 hash = EfficientHash.efficientHashElevenStep2( * @dev EfficientHash.efficientHashElevenStep1( * @dev value1, * @dev value2, * @dev value3, * @dev value4, * @dev value5, * @dev value6, * @dev value7, * @dev value8 * @dev ), * @dev value9, * @dev value10, * @dev value11, * @dev ); * @dev - Parameter counts greater than sixteen must use the `Extension` functions. * @dev Extension starts with `efficientHashExtensionStart` which takes the number * @dev of parameters and the first eight parameters as an input and returns a * @dev memory pointer that is passed to the `Continue` and `End` functions. * @dev While the number of parameters remaining is greater than eight, call the * @dev `efficientHashExtensionContinue` function with the pointer value and * @dev the next eight values. * @dev When the number of parameters remaining is less than or equal to eight * @dev call the `efficientHashExtensionEnd` function with the pointer value * @dev and remaining values. * @dev Example: * @dev bytes32 hash = EfficientHash.efficientHashExtensionEnd( * @dev EfficientHash.efficientHashExtensionContinue( * @dev EfficientHash.efficientHashExtensionStart( * @dev 23, * @dev value1, * @dev value2, * @dev value3, * @dev value4, * @dev value5, * @dev value6, * @dev value7, * @dev value8 * @dev ), * @dev value9, * @dev value10, * @dev value11, * @dev value12, * @dev value13, * @dev value14, * @dev value15, * @dev value16 * @dev ), * @dev value17, * @dev value18, * @dev value19, * @dev value20, * @dev value21, * @dev value22, * @dev value23 * @dev ); */ library EfficientHash { /** * @notice Hashes one value type. * * @param value The value to be hashed. * * @return hash The hash of the value. */ function efficientHash(bytes32 value) internal pure returns(bytes32 hash) { assembly ("memory-safe") { mstore(0x00, value) hash := keccak256(0x00, 0x20) } } /** * @notice Hashes two value types. * * @param value1 Value to be hashed. * @param value2 Value to be hashed. * * @return hash The hash of the values. */ function efficientHash(bytes32 value1, bytes32 value2) internal pure returns(bytes32 hash) { assembly ("memory-safe") { mstore(0x00, value1) mstore(0x20, value2) hash := keccak256(0x00, 0x40) } } /** * @notice Hashes three value types. * * @param value1 Value to be hashed. * @param value2 Value to be hashed. * @param value3 Value to be hashed. * * @return hash The hash of the values. */ function efficientHash(bytes32 value1, bytes32 value2, bytes32 value3) internal pure returns(bytes32 hash) { assembly ("memory-safe") { let ptr := mload(0x40) mstore(0x40, add(ptr, 0x60)) mstore(ptr, value1) mstore(add(ptr, 0x20), value2) mstore(add(ptr, 0x40), value3) hash := keccak256(ptr, 0x60) } } /** * @notice Hashes four value types. * * @param value1 Value to be hashed. * @param value2 Value to be hashed. * @param value3 Value to be hashed. * @param value4 Value to be hashed. * * @return hash The hash of the values. */ function efficientHash( bytes32 value1, bytes32 value2, bytes32 value3, bytes32 value4 ) internal pure returns(bytes32 hash) { assembly ("memory-safe") { let ptr := mload(0x40) mstore(0x40, add(ptr, 0x80)) mstore(ptr, value1) mstore(add(ptr, 0x20), value2) mstore(add(ptr, 0x40), value3) mstore(add(ptr, 0x60), value4) hash := keccak256(ptr, 0x80) } } /** * @notice Hashes five value types. * * @param value1 Value to be hashed. * @param value2 Value to be hashed. * @param value3 Value to be hashed. * @param value4 Value to be hashed. * @param value5 Value to be hashed. * * @return hash The hash of the values. */ function efficientHash( bytes32 value1, bytes32 value2, bytes32 value3, bytes32 value4, bytes32 value5 ) internal pure returns(bytes32 hash) { assembly ("memory-safe") { let ptr := mload(0x40) mstore(0x40, add(ptr, 0xA0)) mstore(ptr, value1) mstore(add(ptr, 0x20), value2) mstore(add(ptr, 0x40), value3) mstore(add(ptr, 0x60), value4) mstore(add(ptr, 0x80), value5) hash := keccak256(ptr, 0xA0) } } /** * @notice Hashes six value types. * * @param value1 Value to be hashed. * @param value2 Value to be hashed. * @param value3 Value to be hashed. * @param value4 Value to be hashed. * @param value5 Value to be hashed. * @param value6 Value to be hashed. * * @return hash The hash of the values. */ function efficientHash( bytes32 value1, bytes32 value2, bytes32 value3, bytes32 value4, bytes32 value5, bytes32 value6 ) internal pure returns(bytes32 hash) { assembly ("memory-safe") { let ptr := mload(0x40) mstore(0x40, add(ptr, 0xC0)) mstore(ptr, value1) mstore(add(ptr, 0x20), value2) mstore(add(ptr, 0x40), value3) mstore(add(ptr, 0x60), value4) mstore(add(ptr, 0x80), value5) mstore(add(ptr, 0xA0), value6) hash := keccak256(ptr, 0xC0) } } /** * @notice Hashes seven value types. * * @param value1 Value to be hashed. * @param value2 Value to be hashed. * @param value3 Value to be hashed. * @param value4 Value to be hashed. * @param value5 Value to be hashed. * @param value6 Value to be hashed. * @param value7 Value to be hashed. * * @return hash The hash of the values. */ function efficientHash( bytes32 value1, bytes32 value2, bytes32 value3, bytes32 value4, bytes32 value5, bytes32 value6, bytes32 value7 ) internal pure returns(bytes32 hash) { assembly ("memory-safe") { let ptr := mload(0x40) mstore(0x40, add(ptr, 0xE0)) mstore(ptr, value1) mstore(add(ptr, 0x20), value2) mstore(add(ptr, 0x40), value3) mstore(add(ptr, 0x60), value4) mstore(add(ptr, 0x80), value5) mstore(add(ptr, 0xA0), value6) mstore(add(ptr, 0xC0), value7) hash := keccak256(ptr, 0xE0) } } /** * @notice Hashes eight value types. * * @param value1 Value to be hashed. * @param value2 Value to be hashed. * @param value3 Value to be hashed. * @param value4 Value to be hashed. * @param value5 Value to be hashed. * @param value6 Value to be hashed. * @param value7 Value to be hashed. * @param value8 Value to be hashed. * * @return hash The hash of the values. */ function efficientHash( bytes32 value1, bytes32 value2, bytes32 value3, bytes32 value4, bytes32 value5, bytes32 value6, bytes32 value7, bytes32 value8 ) internal pure returns(bytes32 hash) { assembly ("memory-safe") { let ptr := mload(0x40) mstore(0x40, add(ptr, 0x100)) mstore(ptr, value1) mstore(add(ptr, 0x20), value2) mstore(add(ptr, 0x40), value3) mstore(add(ptr, 0x60), value4) mstore(add(ptr, 0x80), value5) mstore(add(ptr, 0xA0), value6) mstore(add(ptr, 0xC0), value7) mstore(add(ptr, 0xE0), value8) hash := keccak256(ptr, 0x100) } } /** * @notice Step one of hashing nine values. Must be followed by `efficientHashNineStep2` to hash the values. * * @param value1 Value to be hashed. * @param value2 Value to be hashed. * @param value3 Value to be hashed. * @param value4 Value to be hashed. * @param value5 Value to be hashed. * @param value6 Value to be hashed. * @param value7 Value to be hashed. * @param value8 Value to be hashed. * * @return ptr The memory pointer location for the values to hash. */ function efficientHashNineStep1( bytes32 value1, bytes32 value2, bytes32 value3, bytes32 value4, bytes32 value5, bytes32 value6, bytes32 value7, bytes32 value8 ) internal pure returns(uint256 ptr) { assembly ("memory-safe") { ptr := mload(0x40) mstore(0x40, add(ptr, 0x120)) mstore(ptr, value1) mstore(add(ptr, 0x20), value2) mstore(add(ptr, 0x40), value3) mstore(add(ptr, 0x60), value4) mstore(add(ptr, 0x80), value5) mstore(add(ptr, 0xA0), value6) mstore(add(ptr, 0xC0), value7) mstore(add(ptr, 0xE0), value8) } } /** * @notice Step two of hashing nine values. * * @param ptr The memory pointer location for the values to hash. * @param value9 Value to be hashed. * * @return hash The hash of the values. */ function efficientHashNineStep2( uint256 ptr, bytes32 value9 ) internal pure returns(bytes32 hash) { assembly ("memory-safe") { mstore(add(ptr, 0x100), value9) hash := keccak256(ptr, 0x120) } } /** * @notice Step one of hashing ten values. Must be followed by `efficientHashTenStep2` to hash the values. * * @param value1 Value to be hashed. * @param value2 Value to be hashed. * @param value3 Value to be hashed. * @param value4 Value to be hashed. * @param value5 Value to be hashed. * @param value6 Value to be hashed. * @param value7 Value to be hashed. * @param value8 Value to be hashed. * * @return ptr The memory pointer location for the values to hash. */ function efficientHashTenStep1( bytes32 value1, bytes32 value2, bytes32 value3, bytes32 value4, bytes32 value5, bytes32 value6, bytes32 value7, bytes32 value8 ) internal pure returns(uint256 ptr) { assembly ("memory-safe") { ptr := mload(0x40) mstore(0x40, add(ptr, 0x140)) mstore(ptr, value1) mstore(add(ptr, 0x20), value2) mstore(add(ptr, 0x40), value3) mstore(add(ptr, 0x60), value4) mstore(add(ptr, 0x80), value5) mstore(add(ptr, 0xA0), value6) mstore(add(ptr, 0xC0), value7) mstore(add(ptr, 0xE0), value8) } } /** * @notice Step two of hashing ten values. * * @param ptr The memory pointer location for the values to hash. * @param value9 Value to be hashed. * @param value10 Value to be hashed. * * @return hash The hash of the values. */ function efficientHashTenStep2( uint256 ptr, bytes32 value9, bytes32 value10 ) internal pure returns(bytes32 hash) { assembly ("memory-safe") { mstore(add(ptr, 0x100), value9) mstore(add(ptr, 0x120), value10) hash := keccak256(ptr, 0x140) } } /** * @notice Step one of hashing eleven values. Must be followed by `efficientHashElevenStep2` to hash the values. * * @param value1 Value to be hashed. * @param value2 Value to be hashed. * @param value3 Value to be hashed. * @param value4 Value to be hashed. * @param value5 Value to be hashed. * @param value6 Value to be hashed. * @param value7 Value to be hashed. * @param value8 Value to be hashed. * * @return ptr The memory pointer location for the values to hash. */ function efficientHashElevenStep1( bytes32 value1, bytes32 value2, bytes32 value3, bytes32 value4, bytes32 value5, bytes32 value6, bytes32 value7, bytes32 value8 ) internal pure returns(uint256 ptr) { assembly ("memory-safe") { ptr := mload(0x40) mstore(0x40, add(ptr, 0x160)) mstore(ptr, value1) mstore(add(ptr, 0x20), value2) mstore(add(ptr, 0x40), value3) mstore(add(ptr, 0x60), value4) mstore(add(ptr, 0x80), value5) mstore(add(ptr, 0xA0), value6) mstore(add(ptr, 0xC0), value7) mstore(add(ptr, 0xE0), value8) } } /** * @notice Step two of hashing eleven values. * * @param ptr The memory pointer location for the values to hash. * @param value9 Value to be hashed. * @param value10 Value to be hashed. * @param value11 Value to be hashed. * * @return hash The hash of the values. */ function efficientHashElevenStep2( uint256 ptr, bytes32 value9, bytes32 value10, bytes32 value11 ) internal pure returns(bytes32 hash) { assembly ("memory-safe") { mstore(add(ptr, 0x100), value9) mstore(add(ptr, 0x120), value10) mstore(add(ptr, 0x140), value11) hash := keccak256(ptr, 0x160) } } /** * @notice Step one of hashing twelve values. Must be followed by `efficientHashTwelveStep2` to hash the values. * * @param value1 Value to be hashed. * @param value2 Value to be hashed. * @param value3 Value to be hashed. * @param value4 Value to be hashed. * @param value5 Value to be hashed. * @param value6 Value to be hashed. * @param value7 Value to be hashed. * @param value8 Value to be hashed. * * @return ptr The memory pointer location for the values to hash. */ function efficientHashTwelveStep1( bytes32 value1, bytes32 value2, bytes32 value3, bytes32 value4, bytes32 value5, bytes32 value6, bytes32 value7, bytes32 value8 ) internal pure returns(uint256 ptr) { assembly ("memory-safe") { ptr := mload(0x40) mstore(0x40, add(ptr, 0x180)) mstore(ptr, value1) mstore(add(ptr, 0x20), value2) mstore(add(ptr, 0x40), value3) mstore(add(ptr, 0x60), value4) mstore(add(ptr, 0x80), value5) mstore(add(ptr, 0xA0), value6) mstore(add(ptr, 0xC0), value7) mstore(add(ptr, 0xE0), value8) } } /** * @notice Step two of hashing twelve values. * * @param ptr The memory pointer location for the values to hash. * @param value9 Value to be hashed. * @param value10 Value to be hashed. * @param value11 Value to be hashed. * @param value12 Value to be hashed. * * @return hash The hash of the values. */ function efficientHashTwelveStep2( uint256 ptr, bytes32 value9, bytes32 value10, bytes32 value11, bytes32 value12 ) internal pure returns(bytes32 hash) { assembly ("memory-safe") { mstore(add(ptr, 0x100), value9) mstore(add(ptr, 0x120), value10) mstore(add(ptr, 0x140), value11) mstore(add(ptr, 0x160), value12) hash := keccak256(ptr, 0x180) } } /** * @notice Step one of hashing thirteen values. Must be followed by `efficientHashThirteenStep2` to hash the values. * * @param value1 Value to be hashed. * @param value2 Value to be hashed. * @param value3 Value to be hashed. * @param value4 Value to be hashed. * @param value5 Value to be hashed. * @param value6 Value to be hashed. * @param value7 Value to be hashed. * @param value8 Value to be hashed. * * @return ptr The memory pointer location for the values to hash. */ function efficientHashThirteenStep1( bytes32 value1, bytes32 value2, bytes32 value3, bytes32 value4, bytes32 value5, bytes32 value6, bytes32 value7, bytes32 value8 ) internal pure returns(uint256 ptr) { assembly ("memory-safe") { ptr := mload(0x40) mstore(0x40, add(ptr, 0x1A0)) mstore(ptr, value1) mstore(add(ptr, 0x20), value2) mstore(add(ptr, 0x40), value3) mstore(add(ptr, 0x60), value4) mstore(add(ptr, 0x80), value5) mstore(add(ptr, 0xA0), value6) mstore(add(ptr, 0xC0), value7) mstore(add(ptr, 0xE0), value8) } } /** * @notice Step two of hashing thirteen values. * * @param ptr The memory pointer location for the values to hash. * @param value9 Value to be hashed. * @param value10 Value to be hashed. * @param value11 Value to be hashed. * @param value12 Value to be hashed. * @param value13 Value to be hashed. * * @return hash The hash of the values. */ function efficientHashThirteenStep2( uint256 ptr, bytes32 value9, bytes32 value10, bytes32 value11, bytes32 value12, bytes32 value13 ) internal pure returns(bytes32 hash) { assembly ("memory-safe") { mstore(add(ptr, 0x100), value9) mstore(add(ptr, 0x120), value10) mstore(add(ptr, 0x140), value11) mstore(add(ptr, 0x160), value12) mstore(add(ptr, 0x180), value13) hash := keccak256(ptr, 0x1A0) } } /** * @notice Step one of hashing fourteen values. Must be followed by `efficientHashFourteenStep2` to hash the values. * * @param value1 Value to be hashed. * @param value2 Value to be hashed. * @param value3 Value to be hashed. * @param value4 Value to be hashed. * @param value5 Value to be hashed. * @param value6 Value to be hashed. * @param value7 Value to be hashed. * @param value8 Value to be hashed. * * @return ptr The memory pointer location for the values to hash. */ function efficientHashFourteenStep1( bytes32 value1, bytes32 value2, bytes32 value3, bytes32 value4, bytes32 value5, bytes32 value6, bytes32 value7, bytes32 value8 ) internal pure returns(uint256 ptr) { assembly ("memory-safe") { ptr := mload(0x40) mstore(0x40, add(ptr, 0x1C0)) mstore(ptr, value1) mstore(add(ptr, 0x20), value2) mstore(add(ptr, 0x40), value3) mstore(add(ptr, 0x60), value4) mstore(add(ptr, 0x80), value5) mstore(add(ptr, 0xA0), value6) mstore(add(ptr, 0xC0), value7) mstore(add(ptr, 0xE0), value8) } } /** * @notice Step two of hashing fourteen values. * * @param ptr The memory pointer location for the values to hash. * @param value9 Value to be hashed. * @param value10 Value to be hashed. * @param value11 Value to be hashed. * @param value12 Value to be hashed. * @param value13 Value to be hashed. * @param value14 Value to be hashed. * * @return hash The hash of the values. */ function efficientHashFourteenStep2( uint256 ptr, bytes32 value9, bytes32 value10, bytes32 value11, bytes32 value12, bytes32 value13, bytes32 value14 ) internal pure returns(bytes32 hash) { assembly ("memory-safe") { mstore(add(ptr, 0x100), value9) mstore(add(ptr, 0x120), value10) mstore(add(ptr, 0x140), value11) mstore(add(ptr, 0x160), value12) mstore(add(ptr, 0x180), value13) mstore(add(ptr, 0x1A0), value14) hash := keccak256(ptr, 0x1C0) } } /** * @notice Step one of hashing fifteen values. Must be followed by `efficientHashFifteenStep2` to hash the values. * * @param value1 Value to be hashed. * @param value2 Value to be hashed. * @param value3 Value to be hashed. * @param value4 Value to be hashed. * @param value5 Value to be hashed. * @param value6 Value to be hashed. * @param value7 Value to be hashed. * @param value8 Value to be hashed. * * @return ptr The memory pointer location for the values to hash. */ function efficientHashFifteenStep1( bytes32 value1, bytes32 value2, bytes32 value3, bytes32 value4, bytes32 value5, bytes32 value6, bytes32 value7, bytes32 value8 ) internal pure returns(uint256 ptr) { assembly ("memory-safe") { ptr := mload(0x40) mstore(0x40, add(ptr, 0x1E0)) mstore(ptr, value1) mstore(add(ptr, 0x20), value2) mstore(add(ptr, 0x40), value3) mstore(add(ptr, 0x60), value4) mstore(add(ptr, 0x80), value5) mstore(add(ptr, 0xA0), value6) mstore(add(ptr, 0xC0), value7) mstore(add(ptr, 0xE0), value8) } } /** * @notice Step two of hashing fifteen values. * * @param ptr The memory pointer location for the values to hash. * @param value9 Value to be hashed. * @param value10 Value to be hashed. * @param value11 Value to be hashed. * @param value12 Value to be hashed. * @param value13 Value to be hashed. * @param value14 Value to be hashed. * @param value15 Value to be hashed. * * @return hash The hash of the values. */ function efficientHashFifteenStep2( uint256 ptr, bytes32 value9, bytes32 value10, bytes32 value11, bytes32 value12, bytes32 value13, bytes32 value14, bytes32 value15 ) internal pure returns(bytes32 hash) { assembly ("memory-safe") { mstore(add(ptr, 0x100), value9) mstore(add(ptr, 0x120), value10) mstore(add(ptr, 0x140), value11) mstore(add(ptr, 0x160), value12) mstore(add(ptr, 0x180), value13) mstore(add(ptr, 0x1A0), value14) mstore(add(ptr, 0x1C0), value15) hash := keccak256(ptr, 0x1E0) } } /** * @notice Step one of hashing sixteen values. Must be followed by `efficientHashSixteenStep2` to hash the values. * * @param value1 Value to be hashed. * @param value2 Value to be hashed. * @param value3 Value to be hashed. * @param value4 Value to be hashed. * @param value5 Value to be hashed. * @param value6 Value to be hashed. * @param value7 Value to be hashed. * @param value8 Value to be hashed. * * @return ptr The memory pointer location for the values to hash. */ function efficientHashSixteenStep1( bytes32 value1, bytes32 value2, bytes32 value3, bytes32 value4, bytes32 value5, bytes32 value6, bytes32 value7, bytes32 value8 ) internal pure returns(uint256 ptr) { assembly ("memory-safe") { ptr := mload(0x40) mstore(0x40, add(ptr, 0x200)) mstore(ptr, value1) mstore(add(ptr, 0x20), value2) mstore(add(ptr, 0x40), value3) mstore(add(ptr, 0x60), value4) mstore(add(ptr, 0x80), value5) mstore(add(ptr, 0xA0), value6) mstore(add(ptr, 0xC0), value7) mstore(add(ptr, 0xE0), value8) } } /** * @notice Step two of hashing sixteen values. * * @param ptr The memory pointer location for the values to hash. * @param value9 Value to be hashed. * @param value10 Value to be hashed. * @param value11 Value to be hashed. * @param value12 Value to be hashed. * @param value13 Value to be hashed. * @param value14 Value to be hashed. * @param value15 Value to be hashed. * @param value16 Value to be hashed. * * @return hash The hash of the values. */ function efficientHashSixteenStep2( uint256 ptr, bytes32 value9, bytes32 value10, bytes32 value11, bytes32 value12, bytes32 value13, bytes32 value14, bytes32 value15, bytes32 value16 ) internal pure returns(bytes32 hash) { assembly ("memory-safe") { mstore(add(ptr, 0x100), value9) mstore(add(ptr, 0x120), value10) mstore(add(ptr, 0x140), value11) mstore(add(ptr, 0x160), value12) mstore(add(ptr, 0x180), value13) mstore(add(ptr, 0x1A0), value14) mstore(add(ptr, 0x1C0), value15) mstore(add(ptr, 0x1E0), value16) hash := keccak256(ptr, 0x200) } } /** * @notice Step one of hashing more than sixteen values. * @notice Must be followed by at least one call to * @notice `efficientHashExtensionContinue` and completed with * @notice a call to `efficientHashExtensionEnd` with the remaining * @notice values. * * @param value1 Value to be hashed. * @param value2 Value to be hashed. * @param value3 Value to be hashed. * @param value4 Value to be hashed. * @param value5 Value to be hashed. * @param value6 Value to be hashed. * @param value7 Value to be hashed. * @param value8 Value to be hashed. * * @return ptr The memory pointer location for the values to hash. */ function efficientHashExtensionStart( uint256 numberOfValues, bytes32 value1, bytes32 value2, bytes32 value3, bytes32 value4, bytes32 value5, bytes32 value6, bytes32 value7, bytes32 value8 ) internal pure returns(uint256 ptr) { assembly ("memory-safe") { ptr := mload(0x40) mstore(0x40, add(add(ptr, 0x20), mul(numberOfValues, 0x20))) mstore(ptr, 0x100) mstore(add(ptr, 0x20), value1) mstore(add(ptr, 0x40), value2) mstore(add(ptr, 0x60), value3) mstore(add(ptr, 0x80), value4) mstore(add(ptr, 0xA0), value5) mstore(add(ptr, 0xC0), value6) mstore(add(ptr, 0xE0), value7) mstore(add(ptr, 0x100), value8) } } /** * @notice Second step of hashing more than sixteen values. * @notice Adds another eight values to the values to be hashed. * @notice May be called as many times as necessary until the values * @notice remaining to be added to the hash is less than or equal to * @notice eight. * * @param value1 Value to be hashed. * @param value2 Value to be hashed. * @param value3 Value to be hashed. * @param value4 Value to be hashed. * @param value5 Value to be hashed. * @param value6 Value to be hashed. * @param value7 Value to be hashed. * @param value8 Value to be hashed. * * @return ptrReturn The memory pointer location for the values to hash. */ function efficientHashExtensionContinue( uint256 ptr, bytes32 value1, bytes32 value2, bytes32 value3, bytes32 value4, bytes32 value5, bytes32 value6, bytes32 value7, bytes32 value8 ) internal pure returns(uint256 ptrReturn) { assembly ("memory-safe") { ptrReturn := ptr let length := mload(ptrReturn) mstore(ptrReturn, add(length, 0x100)) ptr := add(ptrReturn, length) mstore(add(ptr, 0x20), value1) mstore(add(ptr, 0x40), value2) mstore(add(ptr, 0x60), value3) mstore(add(ptr, 0x80), value4) mstore(add(ptr, 0xA0), value5) mstore(add(ptr, 0xC0), value6) mstore(add(ptr, 0xE0), value7) mstore(add(ptr, 0x100), value8) } } /** * @notice Final step of hashing more than sixteen values. * * @param ptr The memory pointer location for the values to hash. * @param value1 Value to be hashed. * * @return hash The hash of the values. */ function efficientHashExtensionEnd( uint256 ptr, bytes32 value1 ) internal pure returns(bytes32 hash) { assembly ("memory-safe") { let ptrStart := ptr let length := mload(ptrStart) ptr := add(ptrStart, length) mstore(add(ptr, 0x20), value1) hash := keccak256(add(ptrStart, 0x20), add(length, 0x20)) } } /** * @notice Final step of hashing more than sixteen values. * * @param ptr The memory pointer location for the values to hash. * @param value1 Value to be hashed. * @param value2 Value to be hashed. * * @return hash The hash of the values. */ function efficientHashExtensionEnd( uint256 ptr, bytes32 value1, bytes32 value2 ) internal pure returns(bytes32 hash) { assembly ("memory-safe") { let ptrStart := ptr let length := mload(ptrStart) ptr := add(ptrStart, length) mstore(add(ptr, 0x20), value1) mstore(add(ptr, 0x40), value2) hash := keccak256(add(ptrStart, 0x20), add(length, 0x40)) } } /** * @notice Final step of hashing more than sixteen values. * * @param ptr The memory pointer location for the values to hash. * @param value1 Value to be hashed. * @param value2 Value to be hashed. * @param value3 Value to be hashed. * * @return hash The hash of the values. */ function efficientHashExtensionEnd( uint256 ptr, bytes32 value1, bytes32 value2, bytes32 value3 ) internal pure returns(bytes32 hash) { assembly ("memory-safe") { let ptrStart := ptr let length := mload(ptrStart) ptr := add(ptrStart, length) mstore(add(ptr, 0x20), value1) mstore(add(ptr, 0x40), value2) mstore(add(ptr, 0x60), value3) hash := keccak256(add(ptrStart, 0x20), add(length, 0x60)) } } /** * @notice Final step of hashing more than sixteen values. * * @param ptr The memory pointer location for the values to hash. * @param value1 Value to be hashed. * @param value2 Value to be hashed. * @param value3 Value to be hashed. * @param value4 Value to be hashed. * * @return hash The hash of the values. */ function efficientHashExtensionEnd( uint256 ptr, bytes32 value1, bytes32 value2, bytes32 value3, bytes32 value4 ) internal pure returns(bytes32 hash) { assembly ("memory-safe") { let ptrStart := ptr let length := mload(ptrStart) ptr := add(ptrStart, length) mstore(add(ptr, 0x20), value1) mstore(add(ptr, 0x40), value2) mstore(add(ptr, 0x60), value3) mstore(add(ptr, 0x80), value4) hash := keccak256(add(ptrStart, 0x20), add(length, 0x80)) } } /** * @notice Final step of hashing more than sixteen values. * * @param ptr The memory pointer location for the values to hash. * @param value1 Value to be hashed. * @param value2 Value to be hashed. * @param value3 Value to be hashed. * @param value4 Value to be hashed. * @param value5 Value to be hashed. * * @return hash The hash of the values. */ function efficientHashExtensionEnd( uint256 ptr, bytes32 value1, bytes32 value2, bytes32 value3, bytes32 value4, bytes32 value5 ) internal pure returns(bytes32 hash) { assembly ("memory-safe") { let ptrStart := ptr let length := mload(ptrStart) ptr := add(ptrStart, length) mstore(add(ptr, 0x20), value1) mstore(add(ptr, 0x40), value2) mstore(add(ptr, 0x60), value3) mstore(add(ptr, 0x80), value4) mstore(add(ptr, 0xA0), value5) hash := keccak256(add(ptrStart, 0x20), add(length, 0xA0)) } } /** * @notice Final step of hashing more than sixteen values. * * @param ptr The memory pointer location for the values to hash. * @param value1 Value to be hashed. * @param value2 Value to be hashed. * @param value3 Value to be hashed. * @param value4 Value to be hashed. * @param value5 Value to be hashed. * @param value6 Value to be hashed. * * @return hash The hash of the values. */ function efficientHashExtensionEnd( uint256 ptr, bytes32 value1, bytes32 value2, bytes32 value3, bytes32 value4, bytes32 value5, bytes32 value6 ) internal pure returns(bytes32 hash) { assembly ("memory-safe") { let ptrStart := ptr let length := mload(ptrStart) ptr := add(ptrStart, length) mstore(add(ptr, 0x20), value1) mstore(add(ptr, 0x40), value2) mstore(add(ptr, 0x60), value3) mstore(add(ptr, 0x80), value4) mstore(add(ptr, 0xA0), value5) mstore(add(ptr, 0xC0), value6) hash := keccak256(add(ptrStart, 0x20), add(length, 0xC0)) } } /** * @notice Final step of hashing more than sixteen values. * * @param ptr The memory pointer location for the values to hash. * @param value1 Value to be hashed. * @param value2 Value to be hashed. * @param value3 Value to be hashed. * @param value4 Value to be hashed. * @param value5 Value to be hashed. * @param value6 Value to be hashed. * @param value7 Value to be hashed. * * @return hash The hash of the values. */ function efficientHashExtensionEnd( uint256 ptr, bytes32 value1, bytes32 value2, bytes32 value3, bytes32 value4, bytes32 value5, bytes32 value6, bytes32 value7 ) internal pure returns(bytes32 hash) { assembly ("memory-safe") { let ptrStart := ptr let length := mload(ptrStart) ptr := add(ptrStart, length) mstore(add(ptr, 0x20), value1) mstore(add(ptr, 0x40), value2) mstore(add(ptr, 0x60), value3) mstore(add(ptr, 0x80), value4) mstore(add(ptr, 0xA0), value5) mstore(add(ptr, 0xC0), value6) mstore(add(ptr, 0xE0), value7) hash := keccak256(add(ptrStart, 0x20), add(length, 0xE0)) } } /** * @notice Final step of hashing more than sixteen values. * * @param ptr The memory pointer location for the values to hash. * @param value1 Value to be hashed. * @param value2 Value to be hashed. * @param value3 Value to be hashed. * @param value4 Value to be hashed. * @param value5 Value to be hashed. * @param value6 Value to be hashed. * @param value7 Value to be hashed. * @param value8 Value to be hashed. * * @return hash The hash of the values. */ function efficientHashExtensionEnd( uint256 ptr, bytes32 value1, bytes32 value2, bytes32 value3, bytes32 value4, bytes32 value5, bytes32 value6, bytes32 value7, bytes32 value8 ) internal pure returns(bytes32 hash) { assembly ("memory-safe") { let ptrStart := ptr let length := mload(ptrStart) ptr := add(ptrStart, length) mstore(add(ptr, 0x20), value1) mstore(add(ptr, 0x40), value2) mstore(add(ptr, 0x60), value3) mstore(add(ptr, 0x80), value4) mstore(add(ptr, 0xA0), value5) mstore(add(ptr, 0xC0), value6) mstore(add(ptr, 0xE0), value7) mstore(add(ptr, 0x100), value8) hash := keccak256(add(ptrStart, 0x20), add(length, 0x100)) } } }
pragma solidity ^0.8.4; /** * @dev Interface of the ERC-165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[ERC]. * * 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[ERC 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); }
pragma solidity ^0.8.4; /** * @dev Library for managing * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive * types. * * Sets have the following properties: * * - Elements are added, removed, and checked for existence in constant time * (O(1)). * - Elements are enumerated in O(n). No guarantees are made on the ordering. * * ```solidity * contract Example { * // Add the library methods * using EnumerableSet for EnumerableSet.AddressSet; * * // Declare a set state variable * EnumerableSet.AddressSet private mySet; * } * ``` * * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`) * and `uint256` (`UintSet`) are supported. * * [WARNING] * ==== * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure * unusable. * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info. * * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an * array of EnumerableSet. * ==== */ library EnumerableSet { // To implement this library for multiple types with as little code // repetition as possible, we write it in terms of a generic Set type with // bytes32 values. // The Set implementation uses private functions, and user-facing // implementations (such as AddressSet) are just wrappers around the // underlying Set. // This means that we can only create new EnumerableSets for types that fit // in bytes32. struct Set { // Storage of set values bytes32[] _values; // Position is the index of the value in the `values` array plus 1. // Position 0 is used to mean a value is not in the set. mapping(bytes32 value => uint256) _positions; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function _add(Set storage set, bytes32 value) private returns (bool) { if (!_contains(set, value)) { set._values.push(value); // The value is stored at length-1, but we add 1 to all indexes // and use 0 as a sentinel value set._positions[value] = set._values.length; return true; } else { return false; } } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function _remove(Set storage set, bytes32 value) private returns (bool) { // We cache the value's position to prevent multiple reads from the same storage slot uint256 position = set._positions[value]; if (position != 0) { // Equivalent to contains(set, value) // To delete an element from the _values array in O(1), we swap the element to delete with the last one in // the array, and then remove the last element (sometimes called as 'swap and pop'). // This modifies the order of the array, as noted in {at}. uint256 valueIndex = position - 1; uint256 lastIndex = set._values.length - 1; if (valueIndex != lastIndex) { bytes32 lastValue = set._values[lastIndex]; // Move the lastValue to the index where the value to delete is set._values[valueIndex] = lastValue; // Update the tracked position of the lastValue (that was just moved) set._positions[lastValue] = position; } // Delete the slot where the moved value was stored set._values.pop(); // Delete the tracked position for the deleted slot delete set._positions[value]; return true; } else { return false; } } /** * @dev Returns true if the value is in the set. O(1). */ function _contains(Set storage set, bytes32 value) private view returns (bool) { return set._positions[value] != 0; } /** * @dev Returns the number of values on the set. O(1). */ function _length(Set storage set) private view returns (uint256) { return set._values.length; } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function _at(Set storage set, uint256 index) private view returns (bytes32) { return set._values[index]; } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function _values(Set storage set) private view returns (bytes32[] memory) { return set._values; } // Bytes32Set struct Bytes32Set { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _add(set._inner, value); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _remove(set._inner, value); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) { return _contains(set._inner, value); } /** * @dev Returns the number of values in the set. O(1). */ function length(Bytes32Set storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) { return _at(set._inner, index); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(Bytes32Set storage set) internal view returns (bytes32[] memory) { bytes32[] memory store = _values(set._inner); bytes32[] memory result; /// @solidity memory-safe-assembly assembly { result := store } return result; } // AddressSet struct AddressSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(AddressSet storage set, address value) internal returns (bool) { return _add(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(AddressSet storage set, address value) internal returns (bool) { return _remove(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(AddressSet storage set, address value) internal view returns (bool) { return _contains(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns the number of values in the set. O(1). */ function length(AddressSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(AddressSet storage set, uint256 index) internal view returns (address) { return address(uint160(uint256(_at(set._inner, index)))); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(AddressSet storage set) internal view returns (address[] memory) { bytes32[] memory store = _values(set._inner); address[] memory result; /// @solidity memory-safe-assembly assembly { result := store } return result; } // UintSet struct UintSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(UintSet storage set, uint256 value) internal returns (bool) { return _add(set._inner, bytes32(value)); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(UintSet storage set, uint256 value) internal returns (bool) { return _remove(set._inner, bytes32(value)); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(UintSet storage set, uint256 value) internal view returns (bool) { return _contains(set._inner, bytes32(value)); } /** * @dev Returns the number of values in the set. O(1). */ function length(UintSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(UintSet storage set, uint256 index) internal view returns (uint256) { return uint256(_at(set._inner, index)); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(UintSet storage set) internal view returns (uint256[] memory) { bytes32[] memory store = _values(set._inner); uint256[] memory result; /// @solidity memory-safe-assembly assembly { result := store } return result; } }
//SPDX-License-Identifier: LicenseRef-PolyForm-Strict-1.0.0 pragma solidity 0.8.24; bytes32 constant COSIGNATURE_HASH = keccak256("Cosignature(uint8 v,bytes32 r,bytes32 s,uint256 expiration,address taker)"); bytes32 constant COLLECTION_OFFER_APPROVAL_HASH = keccak256("CollectionOfferApproval(uint8 protocol,address cosigner,address buyer,address beneficiary,address marketplace,address fallbackRoyaltyRecipient,address paymentMethod,address tokenAddress,uint256 amount,uint256 itemPrice,uint256 expiration,uint256 marketplaceFeeNumerator,uint256 nonce,uint256 masterNonce)"); bytes32 constant ITEM_OFFER_APPROVAL_HASH = keccak256("ItemOfferApproval(uint8 protocol,address cosigner,address buyer,address beneficiary,address marketplace,address fallbackRoyaltyRecipient,address paymentMethod,address tokenAddress,uint256 tokenId,uint256 amount,uint256 itemPrice,uint256 expiration,uint256 marketplaceFeeNumerator,uint256 nonce,uint256 masterNonce)"); bytes32 constant TOKEN_SET_OFFER_APPROVAL_HASH = keccak256("TokenSetOfferApproval(uint8 protocol,address cosigner,address buyer,address beneficiary,address marketplace,address fallbackRoyaltyRecipient,address paymentMethod,address tokenAddress,uint256 amount,uint256 itemPrice,uint256 expiration,uint256 marketplaceFeeNumerator,uint256 nonce,uint256 masterNonce,bytes32 tokenSetMerkleRoot)"); bytes32 constant SALE_APPROVAL_HASH = keccak256("SaleApproval(uint8 protocol,address cosigner,address seller,address marketplace,address fallbackRoyaltyRecipient,address paymentMethod,address tokenAddress,uint256 tokenId,uint256 amount,uint256 itemPrice,uint256 expiration,uint256 marketplaceFeeNumerator,uint256 maxRoyaltyFeeNumerator,uint256 nonce,uint256 masterNonce,uint256 protocolFeeVersion)"); bytes32 constant PERMITTED_TRANSFER_SALE_APPROVAL = keccak256("PermitTransferFromWithAdditionalData(uint256 tokenType,address token,uint256 id,uint256 amount,uint256 nonce,address operator,uint256 expiration,uint256 masterNonce,SaleApproval approval)SaleApproval(uint8 protocol,address cosigner,address seller,address marketplace,address fallbackRoyaltyRecipient,address paymentMethod,address tokenAddress,uint256 tokenId,uint256 amount,uint256 itemPrice,uint256 expiration,uint256 marketplaceFeeNumerator,uint256 maxRoyaltyFeeNumerator,uint256 nonce,uint256 masterNonce,uint256 protocolFeeVersion)"); bytes32 constant PERMITTED_ORDER_SALE_APPROVAL = keccak256("PermitOrderWithAdditionalData(uint256 tokenType,address token,uint256 id,uint256 amount,uint256 salt,address operator,uint256 expiration,uint256 masterNonce,SaleApproval approval)SaleApproval(uint8 protocol,address cosigner,address seller,address marketplace,address fallbackRoyaltyRecipient,address paymentMethod,address tokenAddress,uint256 tokenId,uint256 amount,uint256 itemPrice,uint256 expiration,uint256 marketplaceFeeNumerator,uint256 maxRoyaltyFeeNumerator,uint256 nonce,uint256 masterNonce,uint256 protocolFeeVersion)"); // The denominator used when calculating the marketplace fee. // 0.5% fee numerator is 50, 1% fee numerator is 100, 10% fee numerator is 1,000 and so on. uint256 constant FEE_DENOMINATOR = 100_00; // Default Payment Method Whitelist Id uint32 constant DEFAULT_PAYMENT_METHOD_WHITELIST_ID = 0; // Convenience to avoid magic number in bitmask get/set logic. uint256 constant ZERO = uint256(0); uint256 constant ONE = uint256(1); /** * @dev Defines condition to apply to order execution. */ // 0: ERC721 order that must execute in full or not at all. uint256 constant ORDER_PROTOCOLS_ERC721_FILL_OR_KILL = 0; // 1: ERC1155 order that must execute in full or not at all. uint256 constant ORDER_PROTOCOLS_ERC1155_FILL_OR_KILL = 1; // 2: ERC1155 order that may be partially executed. uint256 constant ORDER_PROTOCOLS_ERC1155_FILL_PARTIAL = 2; // 3: Invalid order protocol for type check. uint256 constant ORDER_PROTOCOLS_INVALID = 3; /** * @dev Defines types of offers to be executed */ // 0: Offer for any item in a collection. uint256 constant OFFER_TYPE_COLLECTION_OFFER = 0; // 1: Offer for a specific item in a collection. uint256 constant OFFER_TYPE_ITEM_OFFER = 1; // 2: Offer for a set of tokens in a collection. uint256 constant OFFER_TYPE_TOKEN_SET_OFFER = 2; /// @dev The default protocol fee settings. uint16 constant DEFAULT_PROTOCOL_FEE_MINIMUM_BPS = 25; uint16 constant DEFAULT_PROTOCOL_FEE_MARKETPLACE_TAX_BPS = 15_00; uint16 constant DEFAULT_PROTOCOL_FEE_FEE_ON_TOP_TAX_BPS = 25_00; // The default admin role for NFT collections using Access Control. bytes32 constant DEFAULT_ACCESS_CONTROL_ADMIN_ROLE = 0x00; /// @dev The plain text message to sign for cosigner self-destruct signature verification string constant COSIGNER_SELF_DESTRUCT_MESSAGE_TO_SIGN = "COSIGNER_SELF_DESTRUCT"; /**************************************************************/ /* PRECOMPUTED SELECTORS */ /**************************************************************/ bytes4 constant SELECTOR_DESTROY_COSIGNER = hex"aa04bf59"; bytes4 constant SELECTOR_REVOKE_MASTER_NONCE = hex"226d4adb"; bytes4 constant SELECTOR_REVOKE_SINGLE_NONCE = hex"b6d7dc33"; bytes4 constant SELECTOR_REVOKE_ORDER_DIGEST = hex"96ae0380"; bytes4 constant SELECTOR_BUY_LISTING = hex"27c46dc4"; bytes4 constant SELECTOR_ACCEPT_OFFER = hex"dbbb7e9d"; bytes4 constant SELECTOR_BULK_BUY_LISTINGS = hex"69bdcb08"; bytes4 constant SELECTOR_BULK_ACCEPT_OFFERS = hex"0aa91514"; bytes4 constant SELECTOR_SWEEP_COLLECTION = hex"6a89f68a"; bytes4 constant SELECTOR_BUY_LISTING_ADVANCED = hex"679d2803"; bytes4 constant SELECTOR_ACCEPT_OFFER_ADVANCED = hex"06814765"; bytes4 constant SELECTOR_BULK_BUY_LISTINGS_ADVANCED = hex"7497030d"; bytes4 constant SELECTOR_BULK_ACCEPT_OFFERS_ADVANCED = hex"088df090"; bytes4 constant SELECTOR_SWEEP_COLLECTION_ADVANCED = hex"b9d8d5a6"; /**************************************************************/ /* EXPECTED BASE msg.data LENGTHS */ /**************************************************************/ uint256 constant PROOF_ELEMENT_SIZE = 32; // | 4 | 544 | 96 | 192 | 64 | = 900 bytes // | selector | saleDetails | sellerSignature | cosignature | feeOnTop | uint256 constant BASE_MSG_LENGTH_BUY_LISTING = 900; // | 4 | 32 | 544 | 96 | 32 + (64 + (32 * proof.length)) | 192 | 64 | = 1028 bytes + (32 * proof.length) // | selector | offerType | saleDetails | buyerSignature | tokenSetProof | cosignature | feeOnTop | uint256 constant BASE_MSG_LENGTH_ACCEPT_OFFER = 1028; // | 4 | 64 | 544 * length | 64 | 96 * length | 64 | 192 * length | 64 | 64 * length | = 260 bytes + (896 * saleDetailsArray.length) // | selector | length + offset | saleDetailsArray | length + offset | sellerSignatures | length + offset | cosignatures | length + offset | feesOnTop | uint256 constant BASE_MSG_LENGTH_BULK_BUY_LISTINGS = 260; uint256 constant BASE_MSG_LENGTH_BULK_BUY_LISTINGS_PER_ITEM = 896; // | 4 | 64 | 32 * length | 32 * length | 544 * length | 96 * length | 192 * length | 64 | 64 | 64 * length | 64 | 32 + (64 + (32 * proof.length)) | = 228 bytes + (1056 * saleDetailsArray.length) + (32 * proof.length [for each element]) // | selector | length + offsets | offsets | offerType | saleDetails | signature | cosignature | length + offset | length + offsets | feesOnTop | length + offsets | tokenSetProof | uint256 constant BASE_MSG_LENGTH_BULK_ACCEPT_OFFERS = 196; uint256 constant BASE_MSG_LENGTH_BULK_ACCEPT_OFFERS_PER_ITEM = 1024; // | 4 | 64 | 128 | 64 | 352 * length | 64 | 96 * length | 64 | 192 * length | = 388 bytes + (640 * items.length) // | selector | feeOnTop | sweepOrder | length + offset | items | length + offset | signedSellOrders | length + offset | cosignatures | uint256 constant BASE_MSG_LENGTH_SWEEP_COLLECTION = 388; uint256 constant BASE_MSG_LENGTH_SWEEP_COLLECTION_PER_ITEM = 640; // Advanced Trade Functions // | 4 | 544 | 96 | 192 | 64 | 64 | 32 + (96 + (32 * proof.length)) | = 1092 bytes + (32 * proof.length) // | selector | saleDetails | signature | cosignature | feeOnTop | permitContext | bulkOrderProof | uint256 constant BASE_MSG_LENGTH_BUY_LISTING_ADVANCED = 1092; // | 4 | 32 | 544 | 96 | 192 | 64 | 64 | 32 + (96 + (32 * proof.length)) | 32 + (64 + (32 * proof.length)) | 96 | = 1316 bytes + (32 * tokenSetProof.length) + (32 * bulkOrderProof.length) // | selector | offerType | saleDetails | signature | cosignature | feeOnTop | permitContext | bulkOrderProof | tokenSetProof | sellerPermitSignature | uint256 constant BASE_MSG_LENGTH_ACCEPT_OFFER_ADVANCED = 1316; // | 4 | 64 | 544 * length | 96 * length | 192 * length | 64 * length | 32 + (96 + (32 * proof.length)) | 64 | 64 * length | = 132 bytes + (1088 * advancedListingsArray.length) + (32 * bulkOrderProof.proof.length [for each element]) // | selector | length + offset | saleDetails | signature | cosignature | permitContext | bulkOrderProof | length + offset | feeOnTop | uint256 constant BASE_MSG_LENGTH_BULK_BUY_LISTINGS_ADVANCED = 196; uint256 constant BASE_MSG_LENGTH_BULK_BUY_LISTINGS_ADVANCED_PER_ITEM = 1088; // | 4 | 64 | 32 * length | 544 * length | 96 * length | 192 * length | 64 * length | 96 * length | 64 | 32 + (96 + (32 * proof.length)) | 64 | 64 * length | 64 | 32 + (64 + (32 * proof.length)) | = 260 bytes + (1312 * saleDetailsArray.length) + (32 * proof.length [for each element]) // | selector | length + offset | offerType | saleDetails | signature | cosignatures | permitContext | sellerPermitSignature | length + offset | bulkOrderProof | length + offset | feeOnTop | length + offset | tokenSetProof | uint256 constant BASE_MSG_LENGTH_BULK_ACCEPT_OFFERS_ADVANCED = 260; uint256 constant BASE_MSG_LENGTH_BULK_ACCEPT_OFFERS_ADVANCED_PER_ITEM = 1312; // | 4 | 64 | 128 | 64 | 352 * length | 96 * length | 192 * length | 32 + (96 + (32 * proof.length)) | = 292 bytes + (864 * items.length) + (32 * bulkOrderProof.proof.length [for each element]) // | selector | feeOnTop | sweepOrder | length + offset | items | signature | cosignatures | bulkOrderProof | uint256 constant BASE_MSG_LENGTH_SWEEP_COLLECTION_ADVANCED = 292; uint256 constant BASE_MSG_LENGTH_SWEEP_COLLECTION_ADVANCED_PER_ITEM = 864; /**************************************************************/ /* FLAGS */ /**************************************************************/ // Flags are used to efficiently store and retrieve boolean values in a single uint8. // Each flag is a power of 2, so they can be combined using bitwise OR (|) and checked using bitwise AND (&). // For example, to set the first and third flags, you would use: flags = FLAG1 | FLAG3; // To check if the first flag is set, you would use: if (flags & FLAG1 != 0) { ... } uint8 constant FLAG_IS_ROYALTY_BOUNTY_EXCLUSIVE = 1 << 0; uint8 constant FLAG_BLOCK_TRADES_FROM_UNTRUSTED_CHANNELS = 1 << 1; uint8 constant FLAG_USE_BACKFILL_AS_ROYALTY_SOURCE = 1 << 2; /**************************************************************/ /* BULK ORDER TYPEHASHES */ /**************************************************************/ /// @dev Constant lookup tables for bulk order typehashes. The typehash offset is 32 * (height - 1) bytes. bytes constant BULK_SALE_APPROVAL_TYPEHASHES_LOOKUP = hex"8659f55d4c88f84030fe09241169834754ebf2e61099b616e530c6b65712c6445106f4043cda72e04ca2c760016628ea8d5667309323ba590682ea5254b4e82e71267a8f42e7ccde4ac75848a93b741df7a2f7a58e40274055f2fa51dbaa69ce6e90557aed2a349f8b6efb2b652c4025c56cfa82424c5cd0c6801cc234ebf519caf42fc49ad57705ea6be2ca9e1835c9ccddf7bc6fdea8f851917329b1d53a7f09b32b6b5ffee898d5fe18398652042cc8c46449329c5a1a79e425f4ede9bc2bc2362dea3338b88607906397acfdcc5651f19b40a038ee7c89dc4ab54c736cacf2bbc4f6d7ccfa2b8aab6505f0c8f2868c5a190c6c4cfce8c0de447804904df981f99e15003039550d3597e34e6426b1e230992a5a3727cb5e230754f18f3566012178d0a6b8f8748e48411572bdc391435539737aafc91fcba6f2c24ae156cf"; bytes constant BULK_COLLECTION_OFFER_APPROVAL_TYPEHASHES_LOOKUP = hex"fb1dd652f3a5dcde3cb90b0cbb7ff0d33df15a48f216e6ac0e2306ff3538e33632fc12675167bd2e9c23f1a9b90ce9c0a14daa7e8b3fa5a01105804ad64aa49d22beb101a4a232e5b05a7b5f4727888724dd418194d6c5b1f1ba5ead4cbeed429ba46e6a390d8f8edfb6f752177c215b1cf8b6dcf1f5da395ead6c3e19755698ae93fe4a03206f6bb45035fab04a39964c83e7d265e93fc31521c86dd25a3be4ee3cb9e25b214af21b0d321776864470916324653397b355b267b2894a009a98516d5d5306f95a17cb6d0b84e71f78919a98ac5e3c723fc4b9b1a720193d590df5b1dcad1bd5c8161d6b904513bc658d4c9b8c288b2271e0f27d5938654e418663c21e3ce7e506548c01ef4e6a27a5805f9328e0da83e9a7c765dc28266a5aa19802b2e35d72255f2ae69bed829f0104723aa156059e02dfccfe781ffc955356"; bytes constant BULK_ITEM_OFFER_APPROVAL_TYPEHASHES_LOOKUP = hex"243dc86e63d73b10b2764253a38ab8763ded4ac63a632adef4019e482161964a2ed4880b2bfec74882da06ca9f461158c42fa73fa5974b5abec9fcde7cdd43ee8308607f65c90c023abf48563d2c8bd8c783d1db48ffd02ec324105d9f682f961f7a30dcec9205ff30a5290b3b756e1fd1a1585539bccbc817ab4e59d69a055ecfa8c0abdff5fb2704d1818f38dc974f5bdde6dfe1a4ddc3e22a1f3e593e98f324e3124a40922800d1eb1890240fc7d07f257a303bb383e8c0820e9910be1f97c72769ff919066b8d1f586bb8b7e720ad93f735ffa9570f9e9ef0e865d13251d89338818bfd140179260dbdc6d6bf38461d49661c166f2b76d3b56727acab7adf3e381ed4335a28fa612f4068c58de673cad05c8a7fbfb5c1fd557c2c5a2de9f84c94a0cfd84379f92ed5827593e2218a1dc1b975626bbe5c6948b9d2232f7d7"; bytes constant BULK_TOKEN_SET_OFFER_APPROVAL_TYPEHASHES_LOOKUP = hex"0d0b16c0b281480a518e0ae1543bf94c612edc289e45edc04e8510dac617afa4337b9c051f65323200a3580d4917087d4d82e350fcc68b3397c654c9fc7872c38f8f306a409d08a43b82756f57beb839c3bf5bdd388ba0850d9d21f5c1d0c4dc9f510b8ccf7bbda5c9bd4333d7dcfc8e280aac9eaa9427dcd2f2ffca1fa7a8338599a8fc89aae892d7419812435866d931c9da91198b2f48d1d5318acb524461a0f24864e615845dfa14bee5d4fa28950fcdcf9d31893c68c26f4cfa13402a97621dd1d4cc7477f0587a16f5cd40ea8750209653e7275ccaea3b68623860181b51e570aee92287102d49a7493d337e8aa332c1bc639273de546b428973379fa9a9415346b8de2006517a8de68b2b4147a1d6fd91ce600f4040941627c1c8c3dfb75be8e10d720cf92518936f56974bdfa8e4a723902dd12e415ffba6eb6dde12"; /**************************************************************/ /* ROLES */ /**************************************************************/ bytes32 constant FEE_MANAGER = keccak256("FEE_MANAGER");
//SPDX-License-Identifier: LicenseRef-PolyForm-Strict-1.0.0 pragma solidity 0.8.24; import "@limitbreak/tm-core-lib/src/utils/structs/EnumerableSet.sol"; import { OrderFillAmounts } from "@limitbreak/permit-c/DataTypes.sol"; /** * @dev Used internally to indicate which side of the order the taker is on. */ enum Sides { // 0: Taker is on buy side of order. Buy, // 1: Taker is on sell side of order. Sell } /** * @dev Defines the rules applied to a collection for payments. */ enum PaymentSettings { // 0: Utilize Payment Processor default whitelist. DefaultPaymentMethodWhitelist, // 1: Allow any payment method. AllowAnyPaymentMethod, // 2: Use a custom payment method whitelist. CustomPaymentMethodWhitelist, // 3: Single payment method with floor and ceiling limits on collections only. PricingConstraintsCollectionOnly, // 4: Single payment method with floor and ceiling limits, allows both token and collection level constraints. PricingConstraints, // 5: Pauses trading for the collection. Paused } /** * @dev This struct is used internally for the deployment of the Payment Processor contract and * @dev module deployments to define the default payment method whitelist. */ struct DefaultPaymentMethods { address defaultPaymentMethod1; address defaultPaymentMethod2; address defaultPaymentMethod3; address defaultPaymentMethod4; } /** * @dev This struct is used internally for the deployment of the Payment Processor contract and * @dev module deployments to define the default trusted permit processors. */ struct TrustedPermitProcessors { address permitProcessor1; address permitProcessor2; } /** * @dev This struct is used internally for the deployment of the Payment Processor contract to define the * @dev module addresses to be used for the contract. */ struct PaymentProcessorModules { address moduleOnChainCancellation; address moduleBuyListings; address moduleAcceptOffers; address moduleSweeps; } /** * @dev This struct defines the payment settings parameters for a collection. * * @dev **paymentSettings**: The general rule definition for payment methods allowed. * @dev **paymentMethodWhitelistId**: The list id to be used when paymentSettings is set to CustomPaymentMethodWhitelist. * @dev **royaltyBackfillReceiver**: The backfilled royalty receiver for a collection. * @dev **royaltyBackfillNumerator**: The royalty fee to apply to the collection when ERC2981 is not supported. * @dev **royaltyBountyNumerator**: The percentage of royalties the creator will grant to a marketplace for order fulfillment. * @dev **isRoyaltyBountyExclusive**: If true, royalty bounties will only be paid if the order marketplace is the set exclusive marketplace. * @dev **blockTradesFromUntrustedChannels**: If true, trades that originate from untrusted channels will not be executed. */ struct CollectionPaymentSettings { bool initialized; PaymentSettings paymentSettings; uint32 paymentMethodWhitelistId; address royaltyBackfillReceiver; uint16 royaltyBackfillNumerator; uint16 royaltyBountyNumerator; uint8 flags; } /** * @dev The `v`, `r`, and `s` components of an ECDSA signature. For more information * [refer to this article](https://medium.com/mycrypto/the-magic-of-digital-signatures-on-ethereum-98fe184dc9c7). */ struct SignatureECDSA { uint256 v; bytes32 r; bytes32 s; } /** * @dev This struct defines order execution parameters. * * @dev **protocol**: The order protocol to apply to the order. * @dev **maker**: The user that created and signed the order to be executed by a taker. * @dev **beneficiary**: The account that will receive the tokens. * @dev **marketplace**: The fee receiver of the marketplace that the order was created on. * @dev **fallbackRoyaltyRecipient**: The address that will receive royalties if ERC2981 * @dev is not supported by the collection and the creator has not defined backfilled royalties with Payment Processor. * @dev **paymentMethod**: The payment method for the order. * @dev **tokenAddress**: The address of the token collection the order is for. * @dev **tokenId**: The token id that the order is for. * @dev **amount**: The quantity of token the order is for. * @dev **itemPrice**: The price for the order in base units for the payment method. * @dev **nonce**: The maker's nonce for the order. * @dev **expiration**: The time, in seconds since the Unix epoch, that the order will expire. * @dev **marketplaceFeeNumerator**: The percentage fee that will be sent to the marketplace. * @dev **maxRoyaltyFeeNumerator**: The maximum royalty the maker is willing to accept. This will be used * @dev as the royalty amount when ERC2981 is not supported by the collection. * @dev **requestedFillAmount**: The amount of tokens for an ERC1155 partial fill order that the taker wants to fill. * @dev **minimumFillAmount**: The minimum amount of tokens for an ERC1155 partial fill order that the taker will accept. * @dev **protocolFeeVersion**: The protocol fee version to use when applying protocol fees. */ struct Order { uint256 protocol; address maker; address beneficiary; address marketplace; address fallbackRoyaltyRecipient; address paymentMethod; address tokenAddress; uint256 tokenId; uint256 amount; uint256 itemPrice; uint256 nonce; uint256 expiration; uint256 marketplaceFeeNumerator; uint256 maxRoyaltyFeeNumerator; uint256 requestedFillAmount; uint256 minimumFillAmount; uint256 protocolFeeVersion; } /** * @dev This struct defines the items required to execute an advanced order. * * @dev **saleDetails**: The order execution parameters. * @dev **signature**: The signature of the maker authorizing the order execution. * @dev **cosignature**: The cosignature of the maker authorizing the order execution. * @dev **permitContext**: Contains the address of the permit processor and the permit nonce to be used. */ struct AdvancedOrder { Order saleDetails; SignatureECDSA signature; Cosignature cosignature; PermitContext permitContext; } /** * @dev This struct defines the items required to execute an advanced bid order. * * @dev **offerType**: The type of offer to execute. * @dev **advancedOrder**: The order execution parameters. * @dev **sellerPermitSignature**: The signature of the seller to be used for the permit. */ struct AdvancedBidOrder { uint256 offerType; AdvancedOrder advancedOrder; SignatureECDSA sellerPermitSignature; } /** * @dev This struct defines the items required to execute an advanced sweep order. * * @dev **feeOnTop**: The additional fee to be paid by the taker. * @dev **sweepOrder**: The order execution parameters. * @dev **items**: An array of items to be executed as part of the sweep order. */ struct AdvancedSweep { FeeOnTop feeOnTop; SweepOrder sweepOrder; AdvancedSweepItem[] items; } /** * @dev This struct is a wrapper for a sweep order item that includes the permit context, bulk order information, signature and cosignature. * * @dev **sweepItem**: The sweep order item to be executed. * @dev **signature**: The signature of the maker authorizing the order execution. * @dev **cosignature**: The cosignature of the maker authorizing the order execution. * @dev **permitContext**: Contains the address of the permit processor and the permit nonce to be used. * @dev **bulkOrderProof**: The proof data for the bulk order. */ struct AdvancedSweepItem { SweepItem sweepItem; SignatureECDSA signature; Cosignature cosignature; PermitContext permitContext; BulkOrderProof bulkOrderProof; } /** * @dev This struct defines the cosignature for verifying an order that is a cosigned order. * * @dev **signer**: The address that signed the cosigned order. This must match the cosigner that is part of the order signature. * @dev **taker**: The address of the order taker. * @dev **expiration**: The time, in seconds since the Unix epoch, that the cosignature will expire. * @dev The `v`, `r`, and `s` components of an ECDSA signature. For more information * [refer to this article](https://medium.com/mycrypto/the-magic-of-digital-signatures-on-ethereum-98fe184dc9c7). */ struct Cosignature { address signer; address taker; uint256 expiration; uint256 v; bytes32 r; bytes32 s; } /** * @dev This struct defines an additional fee on top of an order, paid by taker. * * @dev **recipient**: The recipient of the additional fee. * @dev **amount**: The amount of the additional fee, in base units of the payment token. */ struct FeeOnTop { address recipient; uint256 amount; } /** * @dev This struct defines the proof data for accepting an offer that is for a subset * @dev of items in a collection. The computed root hash from the proof must match the root * @dev hash that was signed by the order maker to recover the maker address. * * @dev **proof**: The merkle proofs for the item being supplied to fulfill the offer order. */ struct TokenSetProof { bytes32[] proof; } /** * @dev This struct defines the proof data for a bulk order. * * @dev **orderIndex**: The index of the order in the bulk order. * @dev **proof**: The merkle proofs for the order being supplied to fulfill the bulk order. */ struct BulkOrderProof { uint256 orderIndex; bytes32[] proof; } /** * @dev Current state of a partially fillable order. */ enum PartiallyFillableOrderState { // 0: Order is open and may continue to be filled. Open, // 1: Order has been completely filled. Filled, // 2: Order has been cancelled. Cancelled } /** * @dev This struct defines the current status of a partially fillable order. * * @dev **state**: The current state of the order as defined by the PartiallyFillableOrderState enum. * @dev **remainingFillableQuantity**: The remaining quantity that may be filled for the order. */ struct PartiallyFillableOrderStatus { PartiallyFillableOrderState state; uint248 remainingFillableQuantity; } /** * @dev This struct defines order information that is common to all items in a sweep order. * * @dev **protocol**: The order protocol to apply to the order. * @dev **tokenAddress**: The address of the token collection the order is for. * @dev **paymentMethod**: The payment method for the order. * @dev **beneficiary**: The account that will receive the tokens. */ struct SweepOrder { uint256 protocol; address tokenAddress; address paymentMethod; address beneficiary; } /** * @dev This struct defines order information that is unique to each item of a sweep order. * @dev Combined with the SweepOrder header information to make an Order to execute. * * @dev **maker**: The user that created and signed the order to be executed by a taker. * @dev **marketplace**: The marketplace that the order was created on. * @dev **fallbackRoyaltyRecipient**: The address that will receive royalties if ERC2981 * @dev is not supported by the collection and the creator has not defined royalties with Payment Processor. * @dev **tokenId**: The token id that the order is for. * @dev **amount**: The quantity of token the order is for. * @dev **itemPrice**: The price for the order in base units for the payment method. * @dev **nonce**: The maker's nonce for the order. * @dev **expiration**: The time, in seconds since the Unix epoch, that the order will expire. * @dev **marketplaceFeeNumerator**: The percentage fee that will be sent to the marketplace. * @dev **maxRoyaltyFeeNumerator**: The maximum royalty the maker is willing to accept. This will be used * @dev as the royalty amount when ERC2981 is not supported by the collection. * @dev **protocolFeeVersion**: The protocol fee version to use when applying protocol fees. */ struct SweepItem { address maker; address marketplace; address fallbackRoyaltyRecipient; uint256 tokenId; uint256 amount; uint256 itemPrice; uint256 nonce; uint256 expiration; uint256 marketplaceFeeNumerator; uint256 maxRoyaltyFeeNumerator; uint256 protocolFeeVersion; } /** * @dev This struct is used to define pricing constraints for a collection or individual token. * * @dev **isSet**: When true, this indicates that pricing constraints are set for the collection or token. * @dev **floorPrice**: The minimum price for a token or collection. This is only enforced when * @dev `enforcePricingConstraints` is `true`. * @dev **ceilingPrice**: The maximum price for a token or collection. This is only enforced when * @dev `enforcePricingConstraints` is `true`. */ struct PricingBounds { bool initialized; bool isSet; uint120 floorPrice; uint120 ceilingPrice; } /** * @dev This struct defines the parameters for a bulk offer acceptance transaction. * * * @dev **offerType**: Offer type to execute. * @dev **saleDetails**: Order execution details. * @dev **signature**: Maker signature authorizing the order executions. * @dev **cosignature**: Additional cosignature for cosigned orders, as applicable. */ struct BulkAcceptOffersParams { uint256 offerType; Order saleDetails; SignatureECDSA signature; Cosignature cosignature; } /** * @dev This struct defines the parameters for a sweep execution transaction. * * @dev **fnPointers**: The function pointers to use for the sweep execution. * @dev **accumulator**: The accumulator to use for the sweep execution. * @dev **paymentCoin**: The payment token to use for the sweep execution. * @dev **paymentSettings**: The payment settings to use for the sweep execution. */ struct SweepExecutionParams { FulfillOrderFunctionPointers fnPointers; PayoutsAccumulator accumulator; address paymentCoin; PaymentSettings paymentSettings; } /** * @dev This struct defines the parameters for the proceeds to be split between the seller, marketplace, and royalty recipient. * * @dev **royaltyRecipient**: The address of the royalty recipient. * @dev **royaltyProceeds**: The amount of proceeds to be sent to the royalty recipient. * @dev **marketplaceProceeds**: The amount of proceeds to be sent to the marketplace. * @dev **sellerProceeds**: The amount of proceeds to be sent to the seller. * @dev **infrastructureProceeds**: The amount of proceeds to be sent to the infrastructure recipient. */ struct SplitProceeds { address royaltyRecipient; uint256 royaltyProceeds; uint256 marketplaceProceeds; uint256 sellerProceeds; uint256 infrastructureProceeds; } /** * @dev This struct defines the parameters to be used to accumulate payouts for an order. * * @dev **lastSeller**: The address of the last seller to receive proceeds. * @dev **lastMarketplace**: The address of the last marketplace to receive proceeds. * @dev **lastRoyaltyRecipient**: The address of the last royalty recipient to receive proceeds. * @dev **lastProtocolFeeRecipient**: The address of the last protocol fee recipient to receive proceeds. * @dev **accumulatedSellerProceeds**: The total amount of proceeds accumulated for the seller. * @dev **accumulatedMarketplaceProceeds**: The total amount of proceeds accumulated for the marketplace. * @dev **accumulatedRoyaltyProceeds**: The total amount of proceeds accumulated for the royalty recipient. * @dev **accumulatedInfrastructureProceeds**: The total amount of proceeds accumulated for the infrastructure recipient. */ struct PayoutsAccumulator { address lastSeller; address lastMarketplace; address lastRoyaltyRecipient; address lastProtocolFeeRecipient; uint256 accumulatedSellerProceeds; uint256 accumulatedMarketplaceProceeds; uint256 accumulatedRoyaltyProceeds; uint256 accumulatedInfrastructureProceeds; } /** * @dev This struct defines the function pointers to be used for the fulfillment of an order. * * @dev **funcPayout**: The function pointer to use for the payout. * @dev **funcDispenseToken**: The function pointer to use for the token dispensation. * @dev **funcEmitOrderExecutionEvent**: The function pointer to use for emitting the order execution event. */ struct FulfillOrderFunctionPointers { function(address,address,address,uint256) funcPayout; function(address,address,address,uint256,uint256) returns (bool) funcDispenseToken; function(TradeContext memory, Order memory) funcEmitOrderExecutionEvent; } /** * @dev This struct defines the context to be used for a trade execution. * * @dev **channel**: The address of the channel to use for the trade. * @dev **taker**: The address of the taker for the trade. * @dev **disablePartialFill**: A flag to indicate if partial fills are disabled. * @dev **orderDigest**: The digest of the order to be executed. * @dev **backfillNumerator**: The numerator to use for the backfill. * @dev **backfillReceiver**: The address of the backfill receiver. * @dev **bountyNumerator**: The numerator to use for the bounty. * @dev **exclusiveMarketplace**: The address of the exclusive marketplace. * @dev **useRoyaltyBackfillAsRoyaltySource**: A flag to indicate if the royalty backfill should be used as the royalty source. * @dev **protocolFeeVersion**: The protocol fee version to use when applying protocol fees. * @dev **protocolFees**: Struct containing the loaded protocol fees for the current context. */ struct TradeContext { address channel; address taker; bool disablePartialFill; bytes32 orderDigest; uint16 backfillNumerator; address backfillReceiver; uint16 bountyNumerator; address exclusiveMarketplace; bool useRoyaltyBackfillAsRoyaltySource; uint256 protocolFeeVersion; ProtocolFees protocolFees; } /** * @dev This struct defines the items required to handle a permitted order. * * @dev **permitProcessor**: The address of the permit processor to use for the order. * @dev **permitNonce**: The nonce to use for the permit. */ struct PermitContext { address permitProcessor; uint256 permitNonce; } /** * @dev This struct defines the protocol fees to be applied to a trade based on the protocol fee version. * * @dev **protocolFeeReceiver**: The address to receive protocol fees. * @dev **minimumProtocolFeeBps**: The minimum fee in BPS that is applied to a trade. * @dev **marketplaceFeeProtocolTaxBps**: The fee in BPS that is applied to marketplace fees. * @dev **feeOnTopProtocolTaxBps**: The fee in BPS that is applied to a fee on top. * @dev **versionExpiration**: The timestamp when the protocol fee version expires. */ struct ProtocolFees { address protocolFeeReceiver; uint16 minimumProtocolFeeBps; uint16 marketplaceFeeProtocolTaxBps; uint16 feeOnTopProtocolTaxBps; uint48 versionExpiration; } /** * @dev This struct defines contract-level storage to be used across all Payment Processor modules. * @dev Follows the Diamond storage pattern. */ struct PaymentProcessorStorage { /** * @notice User-specific master nonce that allows buyers and sellers to efficiently cancel all listings or offers * they made previously. The master nonce for a user only changes when they explicitly request to revoke all * existing listings and offers. * * @dev When prompting sellers to sign a listing or offer, marketplaces must query the current master nonce of * the user and include it in the listing/offer signature data. */ mapping(address => uint256) masterNonces; /** * @dev The mapping key is the user address. * * @dev The mapping value is another nested mapping of "slot" (key) to a bitmap (value) containing boolean flags * indicating whether or not a nonce has been used or invalidated. * * @dev Marketplaces MUST track their own nonce by user, incrementing it for every signed listing or offer the user * creates. Listings and purchases may be executed out of order, and they may never be executed if orders * are not matched prior to expriation. * * @dev The slot and the bit offset within the mapped value are computed as: * * @dev ```slot = nonce / 256;``` * @dev ```offset = nonce % 256;``` */ mapping(address => mapping(uint256 => uint256)) invalidatedSignatures; /// @dev Mapping of token contract addresses to the collection payment settings. mapping (address => CollectionPaymentSettings) collectionPaymentSettings; /// @dev Mapping of payment method whitelist id to a defined list of allowed payment methods. mapping (uint32 => EnumerableSet.AddressSet) collectionPaymentMethodWhitelists; /// @dev Mapping of token contract addresses to the collection-level pricing boundaries (floor and ceiling price). mapping (address => PricingBounds) collectionPricingBounds; /// @dev Mapping of token contract addresses to the token-level pricing boundaries (floor and ceiling price). mapping (address => mapping (uint256 => PricingBounds)) tokenPricingBounds; /// @dev Mapping of token contract addresses to the defined pricing constaint payment method. mapping (address => address) collectionConstrainedPricingPaymentMethods; /// @dev Mapping of token contract addresses to the defined exclusive bounty receivers. mapping (address => address) collectionExclusiveBountyReceivers; /// @dev Mapping of maker addresses to a mapping of order digests to the status of the partially fillable order for that digest. mapping (address => mapping(bytes32 => PartiallyFillableOrderStatus)) partiallyFillableOrderStatuses; /// @dev Mapping of token contract addresses to the defined list of trusted channels for the token contract. mapping (address => EnumerableSet.AddressSet) collectionTrustedChannels; /// @dev A mapping of all co-signers that have self-destructed and can never be used as cosigners again. mapping (address => bool) destroyedCosigners; /// @dev An enumerable set of trusted permit processors that may be used. EnumerableSet.AddressSet trustedPermitProcessors; /// @dev Protocol Fee Current Version. uint256 currentProtocolFeeVersion; /// @dev Protocol Fee Version History. mapping (uint256 => ProtocolFees) protocolFeeVersions; }
//SPDX-License-Identifier: LicenseRef-PolyForm-Strict-1.0.0 pragma solidity 0.8.24; /// @dev Thrown when an order is an ERC721 order and the amount is not one. error PaymentProcessor__AmountForERC721SalesMustEqualOne(); /// @dev Thrown when an order is an ERC1155 order and the amount is zero. error PaymentProcessor__AmountForERC1155SalesGreaterThanZero(); /// @dev Thrown when processing a permitted order and the order amount exceeds type(uint248).max error PaymentProcessor__AmountExceedsMaximum(); /// @dev Thrown when appended data length is not zero or twenty bytes. error PaymentProcessor__BadCalldataLength(); /// @dev Thrown when an offer is being accepted and the payment method is the chain native token. error PaymentProcessor__BadPaymentMethod(); /** * @dev Thrown when a call is made to a function that must be called by the Collection Settings Registry * @dev or by a self call from Payment Processor and the caller is not either of those addresses. */ error PaymentProcessor__CallerIsNotSettingsRegistryOrSelf(); /** * @dev Thrown when modifying collection payment settings, pricing bounds, or trusted channels on a collection * @dev that the caller is not the owner of or a member of the default admin role for. */ error PaymentProcessor__CallerMustHaveElevatedPermissionsForSpecifiedNFT(); /// @dev Thrown when the current block time is greater than the expiration time for the cosignature. error PaymentProcessor__CosignatureHasExpired(); /// @dev Thrown when the cosigner has self destructed. error PaymentProcessor__CosignerHasSelfDestructed(); /// @dev Thrown when a token failed to transfer to the beneficiary and partial fills are disabled. error PaymentProcessor__DispensingTokenWasUnsuccessful(); /// @dev Thrown when a maker is a contract and the contract does not return the correct EIP1271 response to validate the signature. error PaymentProcessor__EIP1271SignatureInvalid(); /// @dev Thrown when a native token transfer call fails to transfer the tokens. error PaymentProcessor__FailedToTransferProceeds(); /// @dev Thrown when the additional fee on top exceeds the item price. error PaymentProcessor__FeeOnTopCannotBeGreaterThanItemPrice(); /// @dev Thrown when the supplied root hash, token and proof do not match. error PaymentProcessor__IncorrectTokenSetMerkleProof(); /// @dev Thrown when an input array has zero items in a location where it must have items. error PaymentProcessor__InputArrayLengthCannotBeZero(); /// @dev Thrown when multiple input arrays have different lengths but are required to be the same length. error PaymentProcessor__InputArrayLengthMismatch(); /// @dev Thrown when the height of the bulk order tree is either 0 or greater than 12. error PaymentProcessor__InvalidBulkOrderHeight(); /// @dev Thrown when Payment Processor or a module is being deployed with invalid constructor arguments. error PaymentProcessor__InvalidConstructorArguments(); /// @dev Thrown when an offer type parameter is not a valid offer type. error PaymentProcessor__InvalidOfferType(); /// @dev Thrown when an order protocol parameter is not a valid order protocol type. error PaymentProcessor__InvalidOrderProtocol(); /// @dev Thrown when a signature `v` value is greater than 255. error PaymentProcessor__InvalidSignatureV(); /// @dev Thrown when the combined marketplace and royalty fees will exceed the item price. error PaymentProcessor__MarketplaceAndRoyaltyFeesWillExceedSalePrice(); /// @dev Thrown when the version expiration grace period is exceeded. error PaymentProcessor__MaxGracePeriodExceeded(); /// @dev Thrown when the recovered address from a cosignature does not match the order cosigner. error PaymentProcessor__NotAuthorizedByCosigner(); /// @dev Thrown when the ERC2981 or backfilled royalties exceed the maximum fee specified by the order maker. error PaymentProcessor__OnchainRoyaltiesExceedMaximumApprovedRoyaltyFee(); /// @dev Thrown when the current block timestamp is greater than the order expiration time. error PaymentProcessor__OrderHasExpired(); /// @dev Thrown when attempting to fill a partially fillable order that has already been filled or cancelled. error PaymentProcessor__OrderIsEitherCancelledOrFilled(); /// @dev Thrown when attempting to execute a sweep order for partially fillable orders. error PaymentProcessor__OrderProtocolERC1155FillPartialUnsupportedInSweeps(); /// @dev Thrown when attempting to partially fill an order where the item price is not equally divisible by the amount of tokens. error PaymentProcessor__PartialFillsNotSupportedForNonDivisibleItems(); /// @dev Thrown when attempting to execute an order with a payment method that is not allowed by the collection payment settings. error PaymentProcessor__PaymentCoinIsNotAnApprovedPaymentMethod(); /// @dev Thrown when both a permit and a bulk order proof are submitted for an order, as these features are incompatible. error PaymentProcessor__PermitsAreNotCompatibleWithBulkOrders(); /// @dev Thrown when attempting to use an untrusted permit processing system. error PaymentProcessor__PermitProcessorNotTrusted(); /// @dev Thrown when the protocol fee is set to a value exceeding the maximum fee cap. error PaymentProcessor__ProtocolFeeOrTaxExceedsCap(); /// @dev Thrown when the protocol fee version is expired. error PaymentProcessor__ProtocolFeeVersionExpired(); /// @dev Thrown when distributing payments and fees in native token and the amount remaining is less than the amount to distribute. error PaymentProcessor__RanOutOfNativeFunds(); /// @dev Thrown when a collection is set to pricing constraints and the item price exceeds the defined maximum price. error PaymentProcessor__SalePriceAboveMaximumCeiling(); /// @dev Thrown when a collection is set to pricing constraints and the item price is below the defined minimum price. error PaymentProcessor__SalePriceBelowMinimumFloor(); /// @dev Thrown when a maker's nonce has already been used for an executed order or cancelled by the maker. error PaymentProcessor__SignatureAlreadyUsedOrRevoked(); /// @dev Thrown when a maker's nonce has not already been used for an executed order but an item with that nonce fails to fill. error PaymentProcessor__SignatureNotUsedOrRevoked(); /** * @dev Thrown when a collection is set to block untrusted channels and the order execution originates from a channel * @dev that is not in the collection's trusted channel list. */ error PaymentProcessor__TradeOriginatedFromUntrustedChannel(); /// @dev Thrown when a trading of a specific collection has been paused by the collection owner or admin. error PaymentProcessor__TradingIsPausedForCollection(); /** * @dev Thrown when attempting to fill a partially fillable order and the amount available to fill * @dev is less than the specified minimum to fill. */ error PaymentProcessor__UnableToFillMinimumRequestedQuantity(); /// @dev Thrown when the recovered signer for an order does not match the order maker. error PaymentProcessor__UnauthorizedOrder(); /// @dev Thrown when the taker on a cosigned order does not match the taker on the cosignature. error PaymentProcessor__UnauthorizedTaker(); /// @dev Thrown when the Payment Processor or a module is being deployed with uninitialized configuration values. error PaymentProcessor__UninitializedConfiguration();
//SPDX-License-Identifier: LicenseRef-PolyForm-Strict-1.0.0 pragma solidity 0.8.24; import "../DataTypes.sol"; /** * @title IPaymentProcessorConfiguration * @custom:version 3.0.0 * @author Limit Break, Inc. */ interface IPaymentProcessorConfiguration { /** * @notice Returns the ERC2771 context setup params for payment processor modules. */ function getPaymentProcessorModuleERC2771ContextParams() external view returns ( address /*trustedForwarderFactory*/ ); /** * @notice Returns the setup params for payment processor modules. */ function getPaymentProcessorModuleDeploymentParams() external view returns ( address, /*deterministicPaymentProcessorAddress*/ address, /*wrappedNativeCoin*/ DefaultPaymentMethods memory /*defaultPaymentMethods*/, TrustedPermitProcessors memory /*trustedPermitProcessors*/, address /*collectionPaymentSettings*/, address /*infrastructureFeeReceiver*/ ); /** * @notice Returns the setup params for payment processor. */ function getPaymentProcessorDeploymentParams() external view returns ( address, /*defaultContractOwner*/ PaymentProcessorModules memory /*paymentProcessorModules*/ ); }
//SPDX-License-Identifier: LicenseRef-PolyForm-Strict-1.0.0 pragma solidity 0.8.24; import "../DataTypes.sol"; /** * @title IPaymentProcessorEvents * @custom:version 3.0.0 * @author Limit Break, Inc. */ interface IPaymentProcessorEvents { /// @notice Emitted when an ERC721 listing is purchased. event BuyListingERC721( address indexed buyer, address indexed seller, address indexed tokenAddress, address beneficiary, address paymentCoin, uint256 tokenId, uint256 salePrice); /// @notice Emitted when an ERC1155 listing is purchased. event BuyListingERC1155( address indexed buyer, address indexed seller, address indexed tokenAddress, address beneficiary, address paymentCoin, uint256 tokenId, uint256 amount, uint256 salePrice); /// @notice Emitted when an ERC721 offer is accepted. event AcceptOfferERC721( address indexed seller, address indexed buyer, address indexed tokenAddress, address beneficiary, address paymentCoin, uint256 tokenId, uint256 salePrice); /// @notice Emitted when an ERC1155 offer is accepted. event AcceptOfferERC1155( address indexed seller, address indexed buyer, address indexed tokenAddress, address beneficiary, address paymentCoin, uint256 tokenId, uint256 amount, uint256 salePrice); /// @notice Emitted when a cosigner destroys itself. event DestroyedCosigner(address indexed cosigner); /// @notice Emitted when a user revokes all of their existing listings or offers that share the master nonce. event MasterNonceInvalidated(address indexed account, uint256 nonce); /// @notice Emitted when a user revokes a single listing or offer nonce for a specific marketplace. event NonceInvalidated( uint256 indexed nonce, address indexed account, bool wasCancellation); /// @notice Emitted when a user fills a single listing or offer nonce but item fails to fill. event NonceRestored( uint256 indexed nonce, address indexed account); /// @notice Emitted when a user revokes a single permitted listing nonce. event PermittedOrderNonceInvalidated( uint256 indexed permitNonce, uint256 indexed orderNonce, address indexed account, bool wasCancellation); /// @notice Emitted when protocol fees are updated. event ProtocolFeesUpdated( address indexed newProtocolFeeRecipient, uint16 minimumProtocolFeeBps, uint16 marketplaceFeeProtocolTaxBps, uint16 feeOnTopProtocolTaxBps, uint48 gracePeriodExpiration); /// @notice Emitted the first time a partially fillable 1155 order has items filled on-chain. event OrderDigestOpened( bytes32 indexed orderDigest, address indexed account, uint256 orderStartAmount); /// @notice Emitted when a user fills items on a partially fillable 1155 listing. event OrderDigestItemsFilled( bytes32 indexed orderDigest, address indexed account, uint256 amountFilled); /// @notice Emitted when a user revokes a single partially fillable 1155 listing or offer for a specific marketplace. event OrderDigestInvalidated( bytes32 indexed orderDigest, address indexed account, bool wasCancellation); /// @notice Emitted when a user fills a partially fillable 1155 listing or offer but item fails to fill. event OrderDigestItemsRestored( bytes32 indexed orderDigest, address indexed account, uint256 amountRestoredToOrder); /// @notice Emitted when a coin is added to the approved coins mapping for a whitelist. event PaymentMethodAddedToWhitelist( uint32 indexed paymentMethodWhitelistId, address indexed paymentMethod); /// @notice Emitted when a coin is removed from the approved coins mapping for a whitelist. event PaymentMethodRemovedFromWhitelist( uint32 indexed paymentMethodWhitelistId, address indexed paymentMethod); /// @notice Emitted when a trusted channel is added for a collection event TrustedChannelAddedForCollection( address indexed tokenAddress, address indexed channel); /// @notice Emitted when a trusted channel is removed for a collection. event TrustedChannelRemovedForCollection( address indexed tokenAddress, address indexed channel); /// @notice Emitted when a permit processor is added to the trusted permit processor list. event TrustedPermitProcessorAdded(address indexed permitProcessor); /// @notice Emitted when a permit processor is removed from the trusted permit processor list. event TrustedPermitProcessorRemoved(address indexed permitProcessor); /// @notice Emitted whenever pricing bounds change at a collection level for price-constrained collections. event UpdatedCollectionLevelPricingBoundaries( address indexed tokenAddress, uint256 floorPrice, uint256 ceilingPrice); /// @notice Emitted when payment settings are updated for a collection. event UpdatedCollectionPaymentSettings( address indexed tokenAddress, PaymentSettings paymentSettings, uint32 indexed paymentMethodWhitelistId, address indexed constrainedPricingPaymentMethod, uint16 royaltyBackfillNumerator, address royaltyBackfillReceiver, uint16 royaltyBountyNumerator, address exclusiveBountyReceiver, bool blockTradesFromUntrustedChannels, bool useRoyaltyBackfillAsRoyaltySource); /// @notice Emitted whenever pricing bounds change at a token level for price-constrained collections. event UpdatedTokenLevelPricingBoundaries( address indexed tokenAddress, uint256 indexed tokenId, uint256 floorPrice, uint256 ceilingPrice); }
//SPDX-License-Identifier: LicenseRef-PolyForm-Strict-1.0.0 pragma solidity 0.8.24; import "../interfaces/IPaymentProcessorConfiguration.sol"; import "../interfaces/IPaymentProcessorEvents.sol"; import "../storage/PaymentProcessorStorageAccess.sol"; import "../settings-registry/IPaymentProcessorSettings.sol"; import "../Constants.sol"; import "../Errors.sol"; import "../settings-registry/ICollectionSettingsRegistry.sol"; import "@limitbreak/tm-core-lib/src/token/erc20/utils/SafeERC20.sol"; import "@limitbreak/tm-core-lib/src/utils/cryptography/EfficientHash.sol"; import "@limitbreak/tm-core-lib/src/token/erc721/IERC721.sol"; import "@limitbreak/tm-core-lib/src/token/erc1155/IERC1155.sol"; import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; import {TrustedForwarderERC2771Context} from "@limitbreak/trusted-forwarder/TrustedForwarderERC2771Context.sol"; /* @@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@( @@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@ #@@@@@@@@@@@@@@ @@@@@@@@@@@@ @@@@@@@@@@@@@@* @@@@@@@@@@@@ @@@@@@@@@@@@@@@ @ @@@@@@@@@@@@ @@@@@@@@@@@@@@@ @ @@@@@@@@@@@ @@@@@@@@@@@@@@@ @@ @@@@@@@@@@@@ @@@@@@@@@@@@@@@ #@@ @@@@@@@@@@@@/ @@@@@@@@@@@@@@. @@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@ @@@@@&%%%%%%%%&&@@@@@@@@@@@@@@ @@@@@@@@@@@@@@ @@@@@ @@@@@@@@@@@ @@@@@@@@@@@@@@@ @@@@@ @@@@@@@@@@@ @@@@@@@@@@@@@@@ @@@@@@ @@@@@@@@@@@ @@@@@@@@@@@@@@@ @@@@@@@ @@@@@@@@@@@ @@@@@@@@@@@@@@@ @@@@@@@ @@@@@@@@@@@& @@@@@@@@@@@@@@ *@@@@@@@ (@@@@@@@@@@@@ @@@@@@@@@@@@@@@ @@@@@@@@ @@@@@@@@@@@@@@ @@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ .@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@% @@@@@@@@@@@@@@@@@@@@@@@@( @@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@& @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ * @title PaymentProcessorModule * @custom:version 3.0.0 * @author Limit Break, Inc. */ abstract contract PaymentProcessorModule is TrustedForwarderERC2771Context, PaymentProcessorStorageAccess, IPaymentProcessorEvents { using EnumerableSet for EnumerableSet.AddressSet; // Recommendations For Default Immutable Payment Methods Per Chain // Default Payment Method 1: Wrapped Native Coin // Default Payment Method 2: Wrapped ETH // Default Payment Method 3: USDC (Native) // Default Payment Method 4: USDC (Bridged) /// @dev The address of the ERC20 contract used for wrapped native token. address internal immutable _wrappedNativeCoinAddress; /// @dev The first default payment method defined at contract deployment. Immutable to save SLOAD cost. address internal immutable defaultPaymentMethod1; /// @dev The second default payment method defined at contract deployment. Immutable to save SLOAD cost. address internal immutable defaultPaymentMethod2; /// @dev The third default payment method defined at contract deployment. Immutable to save SLOAD cost. address internal immutable defaultPaymentMethod3; /// @dev The fourth default payment method defined at contract deployment. Immutable to save SLOAD cost. address internal immutable defaultPaymentMethod4; /// @dev The address of the collection settings registry contract. address internal immutable collectionSettingsRegistry; /// @dev The domain separator for EIP-712 signatures. bytes32 internal immutable _cachedDomainSeparator; address internal immutable _defaultInfrastructureFeeReceiver; constructor(address configurationContract) TrustedForwarderERC2771Context( IPaymentProcessorConfiguration(configurationContract).getPaymentProcessorModuleERC2771ContextParams() ) { ( address paymentProcessorAddress_, address wrappedNativeCoinAddress_, DefaultPaymentMethods memory defaultPaymentMethods,, address collectionSettingsRegistry_, address infrastructureFeeReceiver_ ) = IPaymentProcessorConfiguration(configurationContract).getPaymentProcessorModuleDeploymentParams(); if (wrappedNativeCoinAddress_ == address(0) || collectionSettingsRegistry_ == address(0)) { revert PaymentProcessor__InvalidConstructorArguments(); } _wrappedNativeCoinAddress = wrappedNativeCoinAddress_; defaultPaymentMethod1 = defaultPaymentMethods.defaultPaymentMethod1; defaultPaymentMethod2 = defaultPaymentMethods.defaultPaymentMethod2; defaultPaymentMethod3 = defaultPaymentMethods.defaultPaymentMethod3; defaultPaymentMethod4 = defaultPaymentMethods.defaultPaymentMethod4; collectionSettingsRegistry = collectionSettingsRegistry_; _cachedDomainSeparator = keccak256( abi.encode( keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"), keccak256(bytes("PaymentProcessor")), keccak256(bytes("3.0.0")), block.chainid, paymentProcessorAddress_ ) ); _defaultInfrastructureFeeReceiver = infrastructureFeeReceiver_; } /*************************************************************************/ /* Default Payment Methods */ /*************************************************************************/ /** * @notice Returns true if `paymentMethod` is a default payment method. * * @dev This function will return true if the default payment method was added after contract deployment. * * @param paymentMethod The address of the payment method to check. */ function _isDefaultPaymentMethod(address paymentMethod) internal returns (bool) { if (paymentMethod == address(0)) { return true; } else if (paymentMethod == _wrappedNativeCoinAddress) { return true; } else if (paymentMethod == defaultPaymentMethod1) { return true; } else if (paymentMethod == defaultPaymentMethod2) { return true; } else if (paymentMethod == defaultPaymentMethod3) { return true; } else if (paymentMethod == defaultPaymentMethod4) { return true; } else { // If it isn't one of the gas efficient immutable default payment methods, // it may have bee added to the fallback default payment method whitelist, // but there are SLOAD costs. return _isWhitelistedPaymentMethod(DEFAULT_PAYMENT_METHOD_WHITELIST_ID, paymentMethod); } } /** * @notice Returns true if `paymentMethod` is whitelisted for the provided `whitelistId`. * * @dev This function will cache the payment method to the Payment Processor from the Collection Settings Registry * @dev if it is not already cached. * * @param whitelistId The id of the whitelist to check. * @param paymentMethod The address of the payment method to check. */ function _isWhitelistedPaymentMethod(uint32 whitelistId, address paymentMethod) internal returns(bool) { if (appStorage().collectionPaymentMethodWhitelists[whitelistId].contains(paymentMethod)) { return true; } return IPaymentProcessorSettings(address(this)).checkWhitelistedPaymentMethod(whitelistId, paymentMethod); } /** * @notice Adds `paymentMethod` to the provided `whitelistId`. * * @param ptrPaymentMethods The storage pointer to the payment method whitelist. * @param whitelistId The id of the whitelist to add the payment method to. * @param paymentMethod The address of the payment method to add. */ function _addWhitelistedPaymentMethod(EnumerableSet.AddressSet storage ptrPaymentMethods, uint32 whitelistId, address paymentMethod) internal { if (ptrPaymentMethods.add(paymentMethod)) { emit PaymentMethodAddedToWhitelist(whitelistId, paymentMethod); } } /** * @notice Removes `paymentMethod` from the provided `whitelistId`. * * @param ptrPaymentMethods The storage pointer to the payment method whitelist. * @param whitelistId The id of the whitelist to remove the payment method from. * @param paymentMethod The address of the payment method to remove. */ function _removeWhitelistedPaymentMethod(EnumerableSet.AddressSet storage ptrPaymentMethods, uint32 whitelistId, address paymentMethod) internal { if (ptrPaymentMethods.remove(paymentMethod)) { emit PaymentMethodRemovedFromWhitelist(whitelistId, paymentMethod); } } /** * @notice Returns true if the provided `channel` is a trusted channel for the provided `tokenAddress`, false otherwise. * * @dev This function will cache the channel to the Payment Processor from the Collection Settings Registry * @dev if it is not already cached. * * @param tokenAddress The address of the token collection. * @param channel The address of the channel to check. */ function _isCollectionTrustedChannel(address tokenAddress, address channel) internal returns(bool) { if (appStorage().collectionTrustedChannels[tokenAddress].contains(channel)) { return true; } return IPaymentProcessorSettings(address(this)).checkCollectionTrustedChannels(tokenAddress, channel); } /** * @notice Adds `channel` to the trusted channels for the provided `tokenAddress`. * * @param ptrTrustedChannels The storage pointer to the trusted channels set. * @param tokenAddress The address of the token collection. * @param channel The address of the channel to add. */ function _addCollectionTrustedChannel(EnumerableSet.AddressSet storage ptrTrustedChannels, address tokenAddress, address channel) internal { if (ptrTrustedChannels.add(channel)) { emit TrustedChannelAddedForCollection(tokenAddress, channel); } } /** * @notice Removes `channel` from the trusted channels for the provided `tokenAddress`. * * @param ptrTrustedChannels The storage pointer to the trusted channels set. * @param tokenAddress The address of the token collection. * @param channel The address of the channel to remove. */ function _removeCollectionTrustedChannel(EnumerableSet.AddressSet storage ptrTrustedChannels, address tokenAddress, address channel) internal { if (ptrTrustedChannels.remove(channel)) { emit TrustedChannelRemovedForCollection(tokenAddress, channel); } } /** * @notice Adds `permitProcessor` to the trusted permit processors set. * * @param permitProcessor The address of the permit processor to add. */ function _addTrustedPermitProcessor(address permitProcessor) internal { if (appStorage().trustedPermitProcessors.add(permitProcessor)) { emit TrustedPermitProcessorAdded(permitProcessor); } } /** * @notice Removes `permitProcessor` from the trusted permit processors set. * * @param permitProcessor The address of the permit processor to remove. */ function _removeTrustedPermitProcessor(address permitProcessor) internal { if (appStorage().trustedPermitProcessors.remove(permitProcessor)) { emit TrustedPermitProcessorRemoved(permitProcessor); } } /** * @notice Returns an array of the default payment methods defined at contract deployment. * * @dev This array will **NOT** include default payment methods added after contract deployment. */ function _getDefaultPaymentMethods() internal view returns (address[] memory) { address[] memory defaultPaymentMethods = new address[](6); defaultPaymentMethods[0] = address(0); defaultPaymentMethods[1] = _wrappedNativeCoinAddress; defaultPaymentMethods[2] = defaultPaymentMethod1; defaultPaymentMethods[3] = defaultPaymentMethod2; defaultPaymentMethods[4] = defaultPaymentMethod3; defaultPaymentMethods[5] = defaultPaymentMethod4; return defaultPaymentMethods; } /*************************************************************************/ /* Order Execution */ /*************************************************************************/ /** * @notice Adjusts the item price and amount for per unit pricing. * * @dev This function may be called multiple times during a bulk execution. * @dev Throws when a partial fill order is not equally divisible by the number of items in the order. * * @param quantityToFill The quantity of the item to fill. * @param saleDetails The order execution details. */ function _adjustForUnitPricing(uint256 quantityToFill, Order memory saleDetails) internal pure { if (quantityToFill != saleDetails.amount) { if (saleDetails.itemPrice % saleDetails.amount != 0) { revert PaymentProcessor__PartialFillsNotSupportedForNonDivisibleItems(); } saleDetails.itemPrice = saleDetails.itemPrice / saleDetails.amount * quantityToFill; saleDetails.amount = quantityToFill; } } /** * @notice Validates the collection payment settings and fulfills an order. * * @dev This function may be called multiple times during a bulk execution. * @dev Throws when a partial fill order is not equally divisible by the number of items in the order. * @dev Throws when a collection is set to block untrusted channels and the transaction originates * @dev from an untrusted channel. * @dev Throws when the payment method is not an allowed payment method. * @dev Throws when the sweep order is for ERC721 tokens and the amount is set to a value other than one. * @dev Throws when the sweep order is for ERC1155 tokens and the amount is set to zero. * @dev Throws when the marketplace fee and maximum royalty fee will exceed the sales price of an item. * @dev Throws when the current block time is greater than the order expiration. * * * @param side The side of the order to fulfill. * @param context The current execution context to determine the taker. * @param startingNativeFunds The amount of native funds available at the beginning of the order execution. * @param quantityToFill The quantity of the item to fill. * @param saleDetails The order execution details. * @param feeOnTop The additional fee to add on top of the order, paid by taker. */ function _validateAndFulfillOrder( Sides side, TradeContext memory context, uint256 startingNativeFunds, uint256 quantityToFill, Order memory saleDetails, FeeOnTop calldata feeOnTop ) internal returns (uint256 endingNativeFunds) { _adjustForUnitPricing(quantityToFill, saleDetails); _validateBasicOrderDetails(context, saleDetails); endingNativeFunds = _fulfillSingleOrderWithFeeOnTop( startingNativeFunds, context, side == Sides.Buy ? context.taker : saleDetails.maker, side == Sides.Buy ? saleDetails.maker : context.taker, saleDetails.paymentMethod, _getOrderFulfillmentFunctionPointers(side, saleDetails.paymentMethod, saleDetails.protocol), saleDetails, feeOnTop); } /** * @notice Checks order validation and fulfills a buy listing order. * * @dev This function may be called multiple times during a bulk execution. * @dev Throws when a partial fill order is not equally divisible by the number of items in the order. * * @param context The current execution context to determine the taker. * @param startingNativeFunds The amount of native funds available at the beginning of the order execution. * @param saleDetails The order execution details. * @param signedSellOrder The maker's signature authorizing the order execution. * @param cosignature The additional cosignature for a cosigned order, if applicable. * @param feeOnTop The additional fee to add on top of the order, paid by taker. * * @return endingNativeFunds The amount of native funds available at the end of the order execution. */ function _executeOrderBuySide( TradeContext memory context, uint256 startingNativeFunds, Order memory saleDetails, SignatureECDSA memory signedSellOrder, Cosignature memory cosignature, FeeOnTop calldata feeOnTop ) internal returns (uint256 endingNativeFunds) { saleDetails.itemPrice = uint240(saleDetails.itemPrice); uint256 quantityToFill = _verifySaleApproval( context, saleDetails, signedSellOrder, cosignature); endingNativeFunds = _validateAndFulfillOrder( Sides.Buy, context, startingNativeFunds, quantityToFill, saleDetails, feeOnTop); } /** * @notice Checks order validation and fulfills an offer acceptance. * * @dev This function may be called multiple times during a bulk execution. * @dev Throws when the payment method is the chain native token. * @dev Throws when the supplied token for a token set offer cannot be validated with the root hash and proof. * @dev Throws when a partial fill order is not equally divisible by the number of items in the order. * * @param context The current execution context to determine the taker. * @param offerType The offer type to execute. * @param saleDetails The order execution details. * @param signature The maker's signature authorizing the order execution. * @param tokenSetProof The root hash and merkle proofs for an offer that is a subset of tokens in a collection. * @param cosignature The additional cosignature for a cosigned order, if applicable. * @param feeOnTop The additional fee to add on top of the order, paid by taker. */ function _executeOrderSellSide( TradeContext memory context, uint256 offerType, Order memory saleDetails, SignatureECDSA memory signature, TokenSetProof calldata tokenSetProof, Cosignature memory cosignature, FeeOnTop calldata feeOnTop ) internal { if (saleDetails.paymentMethod == address(0)) { revert PaymentProcessor__BadPaymentMethod(); } saleDetails.itemPrice = uint240(saleDetails.itemPrice); uint256 quantityToFill = _verifyBidOrderSignatures( offerType, context, saleDetails, signature, cosignature, tokenSetProof ); _validateAndFulfillOrder( Sides.Sell, context, 0, quantityToFill, saleDetails, feeOnTop); } /** * @notice Checks order validation and fulfills a sweep order. * * @dev Throws when the order protocol is for ERC1155 partial fills. * @dev Throws when the `items`, `signedSellOrders` and `cosignatures` arrays have different lengths. * @dev Throws when the `items` array length is zero. * * @param context The current execution context to determine the taker. * @param startingNativeFunds The amount of native funds available at the beginning of the order execution. * @param feeOnTop The additional fee to add on top of the orders, paid by taker. * @param sweepOrder The order information that is common to all items in the sweep. * @param items An array of items that contains the order information unique to each item. * @param signedSellOrders An array of maker signatures authorizing the order execution. * @param cosignatures An array of additional cosignatures for cosigned orders, if applicable. * * @return endingNativeFunds The amount of native funds available at the end of the order execution. */ function _executeSweepOrder( TradeContext memory context, uint256 startingNativeFunds, FeeOnTop calldata feeOnTop, SweepOrder calldata sweepOrder, SweepItem[] calldata items, SignatureECDSA[] calldata signedSellOrders, Cosignature[] calldata cosignatures ) internal returns (uint256 endingNativeFunds) { if (sweepOrder.protocol == ORDER_PROTOCOLS_ERC1155_FILL_PARTIAL) { revert PaymentProcessor__OrderProtocolERC1155FillPartialUnsupportedInSweeps(); } if (items.length != signedSellOrders.length) { revert PaymentProcessor__InputArrayLengthMismatch(); } if (items.length != cosignatures.length) { revert PaymentProcessor__InputArrayLengthMismatch(); } if (items.length == 0) { revert PaymentProcessor__InputArrayLengthCannotBeZero(); } SweepExecutionParams memory params = _validateSweepOrderHeader(context, sweepOrder); endingNativeFunds = _validateAndFulfillSweepOrder( context, startingNativeFunds, feeOnTop, sweepOrder, items, signedSellOrders, cosignatures, params ); } /*************************************************************************/ /* Order Hashes */ /*************************************************************************/ /** * @notice Generates the order hash for a listing order. * * @param saleDetails The order execution details. * @param signer The address of the signer authorizing the order. * @param cosigner The address of the cosigner authorizing the order. * @param makerMasterNonce The master nonce for the maker. */ function _generateListingOrderHash( Order memory saleDetails, address signer, address cosigner, uint256 makerMasterNonce ) internal pure returns (bytes32 orderHash) { orderHash = EfficientHash.efficientHashExtensionEnd( EfficientHash.efficientHashExtensionContinue( EfficientHash.efficientHashExtensionStart( 17, SALE_APPROVAL_HASH, bytes32(uint256(uint8(saleDetails.protocol))), bytes32(uint256(uint160(cosigner))), bytes32(uint256(uint160(signer))), bytes32(uint256(uint160(saleDetails.marketplace))), bytes32(uint256(uint160(saleDetails.fallbackRoyaltyRecipient))), bytes32(uint256(uint160(saleDetails.paymentMethod))), bytes32(uint256(uint160(saleDetails.tokenAddress))) ), bytes32(saleDetails.tokenId), bytes32(saleDetails.amount), bytes32(saleDetails.itemPrice), bytes32(saleDetails.expiration), bytes32(saleDetails.marketplaceFeeNumerator), bytes32(saleDetails.maxRoyaltyFeeNumerator), bytes32(saleDetails.nonce), bytes32(makerMasterNonce) ), bytes32(saleDetails.protocolFeeVersion) ); } /** * @notice Generates the order hash for a single item offer order. * * @param saleDetails The order execution details. * @param signer The address of the signer authorizing the order. * @param cosigner The address of the cosigner authorizing the order. * @param makerMasterNonce The master nonce for the maker. */ function _generateItemOfferOrderHash( Order memory saleDetails, address signer, address cosigner, uint256 makerMasterNonce ) internal pure returns (bytes32 orderHash) { orderHash = EfficientHash.efficientHashSixteenStep2( EfficientHash.efficientHashSixteenStep1( ITEM_OFFER_APPROVAL_HASH, bytes32(uint256(uint8(saleDetails.protocol))), bytes32(uint256(uint160(cosigner))), bytes32(uint256(uint160(signer))), bytes32(uint256(uint160(saleDetails.beneficiary))), bytes32(uint256(uint160(saleDetails.marketplace))), bytes32(uint256(uint160(saleDetails.fallbackRoyaltyRecipient))), bytes32(uint256(uint160(saleDetails.paymentMethod))) ), bytes32(uint256(uint160(saleDetails.tokenAddress))), bytes32(saleDetails.tokenId), bytes32(saleDetails.amount), bytes32(saleDetails.itemPrice), bytes32(saleDetails.expiration), bytes32(saleDetails.marketplaceFeeNumerator), bytes32(saleDetails.nonce), bytes32(makerMasterNonce) ); } /** * @notice Generates the order hash for a collection offer order. * * @param saleDetails The order execution details. * @param signer The address of the signer authorizing the order. * @param cosigner The address of the cosigner authorizing the order. * @param makerMasterNonce The master nonce for the maker. */ function _generateCollectionOfferOrderHash( Order memory saleDetails, address signer, address cosigner, uint256 makerMasterNonce ) internal pure returns (bytes32 orderHash) { orderHash = EfficientHash.efficientHashFifteenStep2( EfficientHash.efficientHashFifteenStep1( COLLECTION_OFFER_APPROVAL_HASH, bytes32(uint256(uint8(saleDetails.protocol))), bytes32(uint256(uint160(cosigner))), bytes32(uint256(uint160(signer))), bytes32(uint256(uint160(saleDetails.beneficiary))), bytes32(uint256(uint160(saleDetails.marketplace))), bytes32(uint256(uint160(saleDetails.fallbackRoyaltyRecipient))), bytes32(uint256(uint160(saleDetails.paymentMethod))) ), bytes32(uint256(uint160(saleDetails.tokenAddress))), bytes32(saleDetails.amount), bytes32(saleDetails.itemPrice), bytes32(saleDetails.expiration), bytes32(saleDetails.marketplaceFeeNumerator), bytes32(saleDetails.nonce), bytes32(makerMasterNonce) ); } /** * @notice Generates the order hash for a token set offer order. * * @param saleDetails The order execution details. * @param signer The address of the signer authorizing the order. * @param cosigner The address of the cosigner authorizing the order. * @param makerMasterNonce The master nonce for the maker. * @param tokenSetProof The token set proof for the order. */ function _generateTokenSetOfferOrderHash( TokenSetProof calldata tokenSetProof, Order memory saleDetails, address signer, address cosigner, uint256 makerMasterNonce ) internal pure returns (bytes32 orderHash) { bytes32 tokenSetRootHash = _generateTokenSetRootHash(saleDetails.tokenAddress, saleDetails.tokenId, tokenSetProof.proof); orderHash = EfficientHash.efficientHashSixteenStep2( EfficientHash.efficientHashSixteenStep1( TOKEN_SET_OFFER_APPROVAL_HASH, bytes32(uint256(uint8(saleDetails.protocol))), bytes32(uint256(uint160(cosigner))), bytes32(uint256(uint160(signer))), bytes32(uint256(uint160(saleDetails.beneficiary))), bytes32(uint256(uint160(saleDetails.marketplace))), bytes32(uint256(uint160(saleDetails.fallbackRoyaltyRecipient))), bytes32(uint256(uint160(saleDetails.paymentMethod))) ), bytes32(uint256(uint160(saleDetails.tokenAddress))), bytes32(saleDetails.amount), bytes32(saleDetails.itemPrice), bytes32(saleDetails.expiration), bytes32(saleDetails.marketplaceFeeNumerator), bytes32(saleDetails.nonce), bytes32(makerMasterNonce), tokenSetRootHash ); } function _generateTokenSetRootHash( address tokenAddress, uint256 tokenId, bytes32[] calldata proof ) internal pure returns (bytes32 tokenSetRootHash) { tokenSetRootHash = EfficientHash.efficientHash(bytes32(uint256(uint160(tokenAddress))), bytes32(tokenId)); bytes32 currentProof; for (uint256 i; i < proof.length; ++i) { currentProof = proof[i]; if (currentProof < tokenSetRootHash) { tokenSetRootHash = EfficientHash.efficientHash(currentProof, tokenSetRootHash); } else { tokenSetRootHash = EfficientHash.efficientHash(tokenSetRootHash, currentProof); } } } /*************************************************************************/ /* Order Validation */ /*************************************************************************/ /** * @notice Loads collection payment settings to validate a single item order. * * @dev This function may be called multiple times during a bulk execution. * @dev Throws when a collection is set to block untrusted channels and the transaction originates * @dev from an untrusted channel. * @dev Throws when the payment method is not an allowed payment method. * @dev Throws when the sweep order is for ERC721 tokens and the amount is set to a value other than one. * @dev Throws when the sweep order is for ERC1155 tokens and the amount is set to zero. * @dev Throws when the marketplace fee and maximum royalty fee will exceed the sales price of an item. * @dev Throws when the current block time is greater than the order expiration. * * @param context The current execution context to determine the taker. * @param saleDetails The order execution details. */ function _validateBasicOrderDetails( TradeContext memory context, Order memory saleDetails ) internal { if (saleDetails.protocol == ORDER_PROTOCOLS_ERC721_FILL_OR_KILL) { if (saleDetails.amount != ONE) { revert PaymentProcessor__AmountForERC721SalesMustEqualOne(); } } else if (saleDetails.protocol < ORDER_PROTOCOLS_INVALID) { if (saleDetails.amount == 0) { revert PaymentProcessor__AmountForERC1155SalesGreaterThanZero(); } } else { revert PaymentProcessor__InvalidOrderProtocol(); } if (block.timestamp > saleDetails.expiration) { revert PaymentProcessor__OrderHasExpired(); } if (saleDetails.marketplaceFeeNumerator + saleDetails.maxRoyaltyFeeNumerator > FEE_DENOMINATOR) { revert PaymentProcessor__MarketplaceAndRoyaltyFeesWillExceedSalePrice(); } CollectionPaymentSettings storage paymentSettingsForCollection = appStorage().collectionPaymentSettings[saleDetails.tokenAddress]; if (!paymentSettingsForCollection.initialized) { IPaymentProcessorSettings(address(this)).checkSyncCollectionSettings(saleDetails.tokenAddress); } PaymentSettings paymentSettings = paymentSettingsForCollection.paymentSettings; context.backfillReceiver = paymentSettingsForCollection.royaltyBackfillReceiver; context.backfillNumerator = paymentSettingsForCollection.royaltyBackfillNumerator; context.bountyNumerator = paymentSettingsForCollection.royaltyBountyNumerator; uint8 flags = paymentSettingsForCollection.flags; if (_isFlagSet(flags, FLAG_BLOCK_TRADES_FROM_UNTRUSTED_CHANNELS)) { if (!_isCollectionTrustedChannel(saleDetails.tokenAddress, context.channel)) { revert PaymentProcessor__TradeOriginatedFromUntrustedChannel(); } } context.useRoyaltyBackfillAsRoyaltySource = _isFlagSet(flags, FLAG_USE_BACKFILL_AS_ROYALTY_SOURCE); context.exclusiveMarketplace = _isFlagSet(flags, FLAG_IS_ROYALTY_BOUNTY_EXCLUSIVE) ? appStorage().collectionExclusiveBountyReceivers[saleDetails.tokenAddress] : address(0); if (paymentSettings == PaymentSettings.DefaultPaymentMethodWhitelist) { if (!_isDefaultPaymentMethod(saleDetails.paymentMethod)) { revert PaymentProcessor__PaymentCoinIsNotAnApprovedPaymentMethod(); } } else if (paymentSettings == PaymentSettings.CustomPaymentMethodWhitelist) { if (!_isWhitelistedPaymentMethod(paymentSettingsForCollection.paymentMethodWhitelistId, saleDetails.paymentMethod)) { revert PaymentProcessor__PaymentCoinIsNotAnApprovedPaymentMethod(); } } else if (paymentSettings == PaymentSettings.PricingConstraints || paymentSettings == PaymentSettings.PricingConstraintsCollectionOnly) { if (appStorage().collectionConstrainedPricingPaymentMethods[saleDetails.tokenAddress] != saleDetails.paymentMethod) { revert PaymentProcessor__PaymentCoinIsNotAnApprovedPaymentMethod(); } _validateSalePriceInRange( paymentSettings, saleDetails.tokenAddress, saleDetails.tokenId, saleDetails.amount, saleDetails.itemPrice); } else if (paymentSettings == PaymentSettings.Paused) { revert PaymentProcessor__TradingIsPausedForCollection(); } if (block.timestamp > context.protocolFees.versionExpiration) { revert PaymentProcessor__ProtocolFeeVersionExpired(); } if (context.protocolFees.minimumProtocolFeeBps > FEE_DENOMINATOR) { revert PaymentProcessor__ProtocolFeeOrTaxExceedsCap(); } } /** * @notice Validates the sweep order header and returns the sweep execution parameters. * * @dev This function may be called multiple times during a bulk execution. * @dev Throws when a collection is set to block untrusted channels and the transaction originates * @dev from an untrusted channel. * @dev Throws when the payment method is not an allowed payment method. * @dev Throws when trading is paused for the collection. * * @param context The current execution context to determine the taker. * @param sweepOrder The order information that is common to all items in the sweep. */ function _validateSweepOrderHeader( TradeContext memory context, SweepOrder memory sweepOrder ) internal returns ( SweepExecutionParams memory params ) { CollectionPaymentSettings storage paymentSettingsForCollection = appStorage().collectionPaymentSettings[sweepOrder.tokenAddress]; if (!paymentSettingsForCollection.initialized) { IPaymentProcessorSettings(address(this)).checkSyncCollectionSettings(sweepOrder.tokenAddress); } PaymentSettings paymentSettings = paymentSettingsForCollection.paymentSettings; context.backfillReceiver = paymentSettingsForCollection.royaltyBackfillReceiver; context.backfillNumerator = paymentSettingsForCollection.royaltyBackfillNumerator; context.bountyNumerator = paymentSettingsForCollection.royaltyBountyNumerator; uint8 flags = paymentSettingsForCollection.flags; if (_isFlagSet(flags, FLAG_BLOCK_TRADES_FROM_UNTRUSTED_CHANNELS)) { if (!_isCollectionTrustedChannel(sweepOrder.tokenAddress, context.channel)) { revert PaymentProcessor__TradeOriginatedFromUntrustedChannel(); } } context.useRoyaltyBackfillAsRoyaltySource = _isFlagSet(flags, FLAG_USE_BACKFILL_AS_ROYALTY_SOURCE); context.exclusiveMarketplace = _isFlagSet(flags, FLAG_IS_ROYALTY_BOUNTY_EXCLUSIVE) ? appStorage().collectionExclusiveBountyReceivers[sweepOrder.tokenAddress] : address(0); if (paymentSettings == PaymentSettings.DefaultPaymentMethodWhitelist) { if (!_isDefaultPaymentMethod(sweepOrder.paymentMethod)) { revert PaymentProcessor__PaymentCoinIsNotAnApprovedPaymentMethod(); } } else if (paymentSettings == PaymentSettings.CustomPaymentMethodWhitelist) { if (!_isWhitelistedPaymentMethod(paymentSettingsForCollection.paymentMethodWhitelistId, sweepOrder.paymentMethod)) { revert PaymentProcessor__PaymentCoinIsNotAnApprovedPaymentMethod(); } } else if (paymentSettings == PaymentSettings.PricingConstraints || paymentSettings == PaymentSettings.PricingConstraintsCollectionOnly) { if (appStorage().collectionConstrainedPricingPaymentMethods[sweepOrder.tokenAddress] != sweepOrder.paymentMethod) { revert PaymentProcessor__PaymentCoinIsNotAnApprovedPaymentMethod(); } params.paymentSettings = paymentSettings; } else if (paymentSettings == PaymentSettings.Paused) { revert PaymentProcessor__TradingIsPausedForCollection(); } params.fnPointers = _getOrderFulfillmentFunctionPointers(Sides.Buy, sweepOrder.paymentMethod, sweepOrder.protocol); params.paymentCoin = sweepOrder.paymentMethod; } /** * @notice Validates the sales price for a token is within the bounds set. * * @dev Throws when the unit price is above the ceiling bound. * @dev Throws when the unit price is below the floor bound. * * @param tokenAddress The contract address for the token. * @param tokenId The token id. * @param amount The quantity of the token being transacted. * @param salePrice The total price for the token quantity. */ function _validateSalePriceInRange( PaymentSettings paymentSettings, address tokenAddress, uint256 tokenId, uint256 amount, uint256 salePrice ) internal { (uint256 floorPrice, uint256 ceilingPrice) = _getFloorAndCeilingPrices(paymentSettings, tokenAddress, tokenId); unchecked { uint256 unitPrice = salePrice / amount; if (unitPrice > ceilingPrice) { revert PaymentProcessor__SalePriceAboveMaximumCeiling(); } if (unitPrice < floorPrice) { revert PaymentProcessor__SalePriceBelowMinimumFloor(); } } } /** * @notice Returns the floor and ceiling price for a token for collections set to use pricing constraints. * * @dev Returns token pricing bounds if token bounds are set. * @dev If token bounds are not set then returns collection pricing bounds if they are set. * @dev If collection bounds are not set, returns zero floor bound and uint256 max ceiling bound. * * @param tokenAddress The contract address for the token. * @param tokenId The token id. */ function _getFloorAndCeilingPrices( PaymentSettings paymentSettings, address tokenAddress, uint256 tokenId ) internal returns (uint256, uint256) { if (paymentSettings == PaymentSettings.PricingConstraints) { PricingBounds storage tokenLevelPricingBounds = appStorage().tokenPricingBounds[tokenAddress][tokenId]; if (!tokenLevelPricingBounds.initialized) { return IPaymentProcessorSettings(address(this)).checkSyncTokenPricingBounds(tokenAddress, tokenId); } if (tokenLevelPricingBounds.isSet) { return (tokenLevelPricingBounds.floorPrice, tokenLevelPricingBounds.ceilingPrice); } } PricingBounds memory collectionLevelPricingBounds = appStorage().collectionPricingBounds[tokenAddress]; if (collectionLevelPricingBounds.isSet) { return (collectionLevelPricingBounds.floorPrice, collectionLevelPricingBounds.ceilingPrice); } return (0, type(uint256).max); } /*************************************************************************/ /* Order Fulfillment */ /*************************************************************************/ /** * @notice Dispenses tokens and proceeds for a single order. * * @dev This function may be called multiple times during a bulk execution. * @dev Throws when a token false to dispense AND partial fills are disabled. * @dev Throws when the taker did not supply enough native funds. * @dev Throws when the fee on top amount is greater than the item price. * * @param startingNativeFunds The amount of native funds remaining at the beginning of the function call. * @param context The current execution context to determine the taker. * @param purchaser The user that is buying the token. * @param seller The user that is selling the token. * @param paymentCoin The ERC20 token used for payment, will be zero values for chain native token. * @param fnPointers Struct containing the function pointers for dispensing tokens, sending payments * and emitting events. * @param saleDetails The order execution details. * @param feeOnTop The additional fee on top of the item sales price to be paid by the taker. * * @return endingNativeFunds The amount of native funds remaining at the end of the function call. */ function _fulfillSingleOrderWithFeeOnTop( uint256 startingNativeFunds, TradeContext memory context, address purchaser, address seller, address paymentCoin, FulfillOrderFunctionPointers memory fnPointers, Order memory saleDetails, FeeOnTop calldata feeOnTop ) internal returns (uint256 endingNativeFunds) { endingNativeFunds = startingNativeFunds; if (!fnPointers.funcDispenseToken( seller, saleDetails.beneficiary, saleDetails.tokenAddress, saleDetails.tokenId, saleDetails.amount)) { if (context.disablePartialFill) { revert PaymentProcessor__DispensingTokenWasUnsuccessful(); } else { // Nonce or some amount of fillable quantity was burned during order validation, but the item failed to // fill. Since partial fills are allowed, restore the nonce because we can't make assumptions about the // reason the fill failed. Order books should re-simulate there order for removal from order book if it // failed because a fill is impossible. if (saleDetails.protocol == ORDER_PROTOCOLS_ERC1155_FILL_PARTIAL) { _restoreFillableItems(saleDetails.maker, context.orderDigest, saleDetails.amount); } else { _restoreNonce(saleDetails.maker, saleDetails.nonce); } } } else { SplitProceeds memory proceeds = _computePaymentSplits( context, saleDetails.itemPrice, saleDetails.tokenAddress, saleDetails.tokenId, saleDetails.marketplace, saleDetails.marketplaceFeeNumerator, saleDetails.maxRoyaltyFeeNumerator, saleDetails.fallbackRoyaltyRecipient ); uint256 feeOnTopAmount; if (feeOnTop.recipient != address(0)) { feeOnTopAmount = feeOnTop.amount; if (feeOnTopAmount > saleDetails.itemPrice) { revert PaymentProcessor__FeeOnTopCannotBeGreaterThanItemPrice(); } } if (saleDetails.paymentMethod == address(0)) { unchecked { uint256 nativeProceedsToSpend = saleDetails.itemPrice + feeOnTopAmount; if (endingNativeFunds < nativeProceedsToSpend) { revert PaymentProcessor__RanOutOfNativeFunds(); } endingNativeFunds -= nativeProceedsToSpend; } } if (feeOnTopAmount > 0) { unchecked { uint256 feeOnTopAmountInfrastructure = feeOnTopAmount * context.protocolFees.feeOnTopProtocolTaxBps / FEE_DENOMINATOR; fnPointers.funcPayout(feeOnTop.recipient, context.taker, paymentCoin, feeOnTopAmount - feeOnTopAmountInfrastructure); if (purchaser == context.taker) { proceeds.infrastructureProceeds += feeOnTopAmountInfrastructure; } else { if (feeOnTopAmountInfrastructure > 0) { fnPointers.funcPayout(context.protocolFees.protocolFeeReceiver, context.taker, paymentCoin, feeOnTopAmountInfrastructure); } } } } if (proceeds.infrastructureProceeds > 0) { fnPointers.funcPayout(context.protocolFees.protocolFeeReceiver, purchaser, paymentCoin, proceeds.infrastructureProceeds); } if (proceeds.royaltyProceeds > 0) { fnPointers.funcPayout(proceeds.royaltyRecipient, purchaser, paymentCoin, proceeds.royaltyProceeds); } if (proceeds.marketplaceProceeds > 0) { fnPointers.funcPayout(saleDetails.marketplace, purchaser, paymentCoin, proceeds.marketplaceProceeds); } if (proceeds.sellerProceeds > 0) { fnPointers.funcPayout(seller, purchaser, paymentCoin, proceeds.sellerProceeds); } fnPointers.funcEmitOrderExecutionEvent(context, saleDetails); } } /** * @notice Validates a sweep order and fulfills the order. * * @dev Throws when the order protocol is for ERC721 and the amount is not set to one. * @dev Throws when the order protocol is for ERC1155 and the amount is set to zero. * @dev Throws when an invalid order protocol is detected. * @dev Throws when the marketplace fee and maximum royalty fee will exceed the sales price of an item. * @dev Throws when the sale price is outside the pricing constraints. * @dev Throws when the current block time is greater than the order expiration. * @dev Throws when a cosignature is required and the cosignature is invalid. * @dev Throws when the maker signature is invalid. * @dev Throws when the maker's order nonce has already been used or was cancelled. * @dev Throws when a partially fillable order has already been filled, cancelled or * @dev cannot be filled with the minimum fillable amount. * @dev Throws when the taker did not supply enough native funds. * * @param context The current execution context to determine the taker. * @param startingNativeFunds The amount of native funds available at the beginning of the order execution. * @param feeOnTop The additional fee to add on top of the orders, paid by taker. * @param sweepOrder The order information that is common to all items in the sweep. * @param items An array of items that contains the order information unique to each item. * @param signedSellOrders An array of maker signatures authorizing the order execution. * @param cosignatures An array of additional cosignatures for cosigned orders, if applicable. * @param params The sweep execution parameters. */ function _validateAndFulfillSweepOrder( TradeContext memory context, uint256 startingNativeFunds, FeeOnTop calldata feeOnTop, SweepOrder calldata sweepOrder, SweepItem[] calldata items, SignatureECDSA[] memory signedSellOrders, Cosignature[] memory cosignatures, SweepExecutionParams memory params ) internal returns (uint256 endingNativeFunds) { endingNativeFunds = startingNativeFunds; uint256 sumListingPrices; uint256 dispensedPaymentValue; for(uint256 itemIndex;itemIndex < items.length;) { SweepItem calldata sweepItem = items[itemIndex]; Order memory saleDetails = Order({ protocol: sweepOrder.protocol, maker: sweepItem.maker, beneficiary: sweepOrder.beneficiary, marketplace: sweepItem.marketplace, fallbackRoyaltyRecipient: sweepItem.fallbackRoyaltyRecipient, paymentMethod: sweepOrder.paymentMethod, tokenAddress: sweepOrder.tokenAddress, tokenId: sweepItem.tokenId, amount: sweepItem.amount, itemPrice: uint240(sweepItem.itemPrice), nonce: sweepItem.nonce, expiration: sweepItem.expiration, marketplaceFeeNumerator: sweepItem.marketplaceFeeNumerator, maxRoyaltyFeeNumerator: sweepItem.maxRoyaltyFeeNumerator, requestedFillAmount: sweepItem.amount, minimumFillAmount: sweepItem.amount, protocolFeeVersion: sweepItem.protocolFeeVersion }); if (context.protocolFeeVersion != saleDetails.protocolFeeVersion) { context.protocolFeeVersion = saleDetails.protocolFeeVersion; context.protocolFees = appStorage().protocolFeeVersions[saleDetails.protocolFeeVersion]; } sumListingPrices += saleDetails.itemPrice; if (saleDetails.protocol == ORDER_PROTOCOLS_ERC721_FILL_OR_KILL) { if (saleDetails.amount != ONE) { revert PaymentProcessor__AmountForERC721SalesMustEqualOne(); } } else if (saleDetails.protocol == ORDER_PROTOCOLS_ERC1155_FILL_OR_KILL) { if (saleDetails.amount == 0) { revert PaymentProcessor__AmountForERC1155SalesGreaterThanZero(); } } else { revert PaymentProcessor__InvalidOrderProtocol(); } if (saleDetails.marketplaceFeeNumerator + saleDetails.maxRoyaltyFeeNumerator > FEE_DENOMINATOR) { revert PaymentProcessor__MarketplaceAndRoyaltyFeesWillExceedSalePrice(); } if (params.paymentSettings == PaymentSettings.PricingConstraints || params.paymentSettings == PaymentSettings.PricingConstraintsCollectionOnly) { _validateSalePriceInRange( params.paymentSettings, saleDetails.tokenAddress, saleDetails.tokenId, saleDetails.amount, saleDetails.itemPrice); } if (block.timestamp > saleDetails.expiration) { revert PaymentProcessor__OrderHasExpired(); } if (block.timestamp > context.protocolFees.versionExpiration) { revert PaymentProcessor__ProtocolFeeVersionExpired(); } if (context.protocolFees.minimumProtocolFeeBps > FEE_DENOMINATOR) { revert PaymentProcessor__ProtocolFeeOrTaxExceedsCap(); } _verifySaleApproval( context, saleDetails, signedSellOrders[itemIndex], cosignatures[itemIndex] ); (endingNativeFunds, dispensedPaymentValue) = _dispenseAndPayoutSweepItem( context, saleDetails, params, endingNativeFunds, dispensedPaymentValue ); unchecked { ++itemIndex; } } if (feeOnTop.amount > sumListingPrices) { revert PaymentProcessor__FeeOnTopCannotBeGreaterThanItemPrice(); } endingNativeFunds = _finalizePaymentAccumulatorDisbursement( context, params, feeOnTop, dispensedPaymentValue, sumListingPrices, endingNativeFunds ); } /** * @notice Finalizes the payment accumulator disbursement for a sweep order. * * @dev Throws if the taker did not supply enough native funds. * * @param context The current execution context to determine the taker. * @param params The sweep execution parameters. * @param feeOnTop The additional fee to add on top of the orders, paid by taker. * @param dispensedPaymentValue The total value of dispensed payments. * @param sumListingPrices The total value of all listings. * @param startingNativeFunds The amount of native funds available at the beginning of the order execution. */ function _finalizePaymentAccumulatorDisbursement( TradeContext memory context, SweepExecutionParams memory params, FeeOnTop calldata feeOnTop, uint256 dispensedPaymentValue, uint256 sumListingPrices, uint256 startingNativeFunds ) internal returns (uint256 endingNativeFunds) { endingNativeFunds = startingNativeFunds; if (feeOnTop.recipient != address(0)) { if (feeOnTop.amount > 0) { uint256 feeOnTopAmountApp; uint256 feeOnTopAmount = feeOnTop.amount * dispensedPaymentValue / sumListingPrices; uint256 feeOnTopAmountInfrastructure = feeOnTopAmount * context.protocolFees.feeOnTopProtocolTaxBps / FEE_DENOMINATOR; unchecked { feeOnTopAmountApp = feeOnTopAmount - feeOnTopAmountInfrastructure; } if (address(params.paymentCoin) == address(0)) { if (endingNativeFunds < feeOnTopAmount) { revert PaymentProcessor__RanOutOfNativeFunds(); } unchecked { endingNativeFunds -= feeOnTopAmount; } } params.fnPointers.funcPayout( feeOnTop.recipient, context.taker, params.paymentCoin, feeOnTopAmountApp ); unchecked { params.accumulator.accumulatedInfrastructureProceeds += feeOnTopAmountInfrastructure; } } } if(params.accumulator.accumulatedInfrastructureProceeds > 0) { params.fnPointers.funcPayout( context.protocolFees.protocolFeeReceiver, context.taker, params.paymentCoin, params.accumulator.accumulatedInfrastructureProceeds ); } if(params.accumulator.accumulatedRoyaltyProceeds > 0) { params.fnPointers.funcPayout( params.accumulator.lastRoyaltyRecipient, context.taker, params.paymentCoin, params.accumulator.accumulatedRoyaltyProceeds ); } if(params.accumulator.accumulatedMarketplaceProceeds > 0) { params.fnPointers.funcPayout( params.accumulator.lastMarketplace, context.taker, params.paymentCoin, params.accumulator.accumulatedMarketplaceProceeds ); } if(params.accumulator.accumulatedSellerProceeds > 0) { params.fnPointers.funcPayout( params.accumulator.lastSeller, context.taker, params.paymentCoin, params.accumulator.accumulatedSellerProceeds ); } } /** * @notice Dispenses tokens and proceeds for a single sweep item. * * @dev Throws when the taker did not supply enough native funds. * @dev If the token transfer fails, the nonce is restored. * * @param context The current execution context to determine the taker. * @param saleDetails The order execution details. * @param params The sweep execution parameters. * @param startingNativeFunds The amount of native funds available at the beginning of the order execution. */ function _dispenseAndPayoutSweepItem( TradeContext memory context, Order memory saleDetails, SweepExecutionParams memory params, uint256 startingNativeFunds, uint256 startingDispensedPaymentValue ) internal returns( uint256 endingNativeFunds, uint256 endingDispensedPaymentValue ) { endingNativeFunds = startingNativeFunds; endingDispensedPaymentValue = startingDispensedPaymentValue; if (params.fnPointers.funcDispenseToken( saleDetails.maker, saleDetails.beneficiary, saleDetails.tokenAddress, saleDetails.tokenId, saleDetails.amount)) { SplitProceeds memory proceeds = _computePaymentSplits( context, saleDetails.itemPrice, saleDetails.tokenAddress, saleDetails.tokenId, saleDetails.marketplace, saleDetails.marketplaceFeeNumerator, saleDetails.maxRoyaltyFeeNumerator, saleDetails.fallbackRoyaltyRecipient ); unchecked { endingDispensedPaymentValue += saleDetails.itemPrice; } if (saleDetails.paymentMethod == address(0)) { if (endingNativeFunds < saleDetails.itemPrice) { revert PaymentProcessor__RanOutOfNativeFunds(); } unchecked { endingNativeFunds -= saleDetails.itemPrice; } } if (proceeds.royaltyRecipient != params.accumulator.lastRoyaltyRecipient) { if(params.accumulator.accumulatedRoyaltyProceeds > 0) { params.fnPointers.funcPayout(params.accumulator.lastRoyaltyRecipient, context.taker, params.paymentCoin, params.accumulator.accumulatedRoyaltyProceeds); } params.accumulator.lastRoyaltyRecipient = proceeds.royaltyRecipient; params.accumulator.accumulatedRoyaltyProceeds = 0; } if (saleDetails.marketplace != params.accumulator.lastMarketplace) { if(params.accumulator.accumulatedMarketplaceProceeds > 0) { params.fnPointers.funcPayout(params.accumulator.lastMarketplace, context.taker, params.paymentCoin, params.accumulator.accumulatedMarketplaceProceeds); } params.accumulator.lastMarketplace = saleDetails.marketplace; params.accumulator.accumulatedMarketplaceProceeds = 0; } if (saleDetails.maker != params.accumulator.lastSeller) { if(params.accumulator.accumulatedSellerProceeds > 0) { params.fnPointers.funcPayout(params.accumulator.lastSeller, context.taker, params.paymentCoin, params.accumulator.accumulatedSellerProceeds); } params.accumulator.lastSeller = saleDetails.maker; params.accumulator.accumulatedSellerProceeds = 0; } if (context.protocolFees.protocolFeeReceiver != params.accumulator.lastProtocolFeeRecipient) { if (params.accumulator.accumulatedInfrastructureProceeds > 0) { params.fnPointers.funcPayout(params.accumulator.lastProtocolFeeRecipient, context.taker, params.paymentCoin, params.accumulator.accumulatedInfrastructureProceeds); } params.accumulator.lastProtocolFeeRecipient = context.protocolFees.protocolFeeReceiver; params.accumulator.accumulatedInfrastructureProceeds = 0; } unchecked { params.accumulator.accumulatedRoyaltyProceeds += proceeds.royaltyProceeds; params.accumulator.accumulatedMarketplaceProceeds += proceeds.marketplaceProceeds; params.accumulator.accumulatedSellerProceeds += proceeds.sellerProceeds; params.accumulator.accumulatedInfrastructureProceeds += proceeds.infrastructureProceeds; } params.fnPointers.funcEmitOrderExecutionEvent(context, saleDetails); } else { if (saleDetails.protocol != ORDER_PROTOCOLS_ERC1155_FILL_PARTIAL) { _restoreNonce(saleDetails.maker, saleDetails.nonce); } } } /** * @notice Calculates the payment splits between seller, creator and marketplace based * @notice on on-chain royalty information or backfilled royalty information if on-chain * @notice data is unavailable. * * @dev Throws when ERC2981 on-chain royalties are set to an amount greater than the * @dev maker signed maximum. * * @param salePrice The sale price for the token being sold. * @param tokenAddress The contract address for the token being sold. * @param tokenId The token id for the token being sold. * @param marketplaceFeeRecipient The address that will receive the marketplace fee. * If zero, no marketplace fee will be applied. * @param marketplaceFeeNumerator The fee numerator for calculating marketplace fees. * @param maxRoyaltyFeeNumerator The maximum royalty fee authorized by the order maker. * @param fallbackRoyaltyRecipient The address that will receive royalties if not defined onchain. * @param context The royalty backfill and bounty information set onchain by the creator. * * @return proceeds A struct containing the split of payment and receiving addresses for the * seller, creator and marketplace. */ function _computePaymentSplits( TradeContext memory context, uint256 salePrice, address tokenAddress, uint256 tokenId, address marketplaceFeeRecipient, uint256 marketplaceFeeNumerator, uint256 maxRoyaltyFeeNumerator, address fallbackRoyaltyRecipient ) internal view returns (SplitProceeds memory proceeds) { proceeds.sellerProceeds = salePrice; bool useBackfill = context.useRoyaltyBackfillAsRoyaltySource; address royaltyReceiver; uint256 royaltyAmount; if(!useBackfill) { ( royaltyReceiver, royaltyAmount, useBackfill ) = _safeRoyaltyInfo(tokenAddress, tokenId, salePrice); if (royaltyAmount == 0) { useBackfill = true; } } unchecked { if (useBackfill) { // If the token doesn't implement the royaltyInfo function or creator has set // the use backfill royalty flag, then check if there are backfilled royalties. if (context.backfillReceiver != address(0)) { if (context.backfillNumerator > maxRoyaltyFeeNumerator) { revert PaymentProcessor__OnchainRoyaltiesExceedMaximumApprovedRoyaltyFee(); } proceeds.royaltyRecipient = context.backfillReceiver; proceeds.royaltyProceeds = (salePrice * context.backfillNumerator) / FEE_DENOMINATOR; proceeds.sellerProceeds -= proceeds.royaltyProceeds; } else if (fallbackRoyaltyRecipient != address(0)) { proceeds.royaltyRecipient = fallbackRoyaltyRecipient; proceeds.royaltyProceeds = (salePrice * maxRoyaltyFeeNumerator) / FEE_DENOMINATOR; proceeds.sellerProceeds -= proceeds.royaltyProceeds; } } else { if (royaltyReceiver == address(0)) { royaltyAmount = 0; } if (royaltyAmount > 0) { if (royaltyAmount > (salePrice * maxRoyaltyFeeNumerator) / FEE_DENOMINATOR) { revert PaymentProcessor__OnchainRoyaltiesExceedMaximumApprovedRoyaltyFee(); } proceeds.royaltyRecipient = royaltyReceiver; proceeds.royaltyProceeds = royaltyAmount; proceeds.sellerProceeds -= royaltyAmount; } } if (marketplaceFeeRecipient != address(0)) { proceeds.marketplaceProceeds = (salePrice * marketplaceFeeNumerator) / FEE_DENOMINATOR; proceeds.sellerProceeds -= proceeds.marketplaceProceeds; if (context.bountyNumerator > 0) { if (context.exclusiveMarketplace == address(0) || context.exclusiveMarketplace == marketplaceFeeRecipient) { uint256 royaltyBountyProceeds = proceeds.royaltyProceeds * context.bountyNumerator / FEE_DENOMINATOR; if (royaltyBountyProceeds > 0) { proceeds.royaltyProceeds -= royaltyBountyProceeds; proceeds.marketplaceProceeds += royaltyBountyProceeds; } } } proceeds.infrastructureProceeds = proceeds.marketplaceProceeds * context.protocolFees.marketplaceFeeProtocolTaxBps / FEE_DENOMINATOR; proceeds.marketplaceProceeds -= proceeds.infrastructureProceeds; } uint256 minInfrastructureFee = (salePrice * context.protocolFees.minimumProtocolFeeBps) / FEE_DENOMINATOR; if (proceeds.infrastructureProceeds < minInfrastructureFee) { uint256 shortfall = minInfrastructureFee - proceeds.infrastructureProceeds; if (shortfall > proceeds.sellerProceeds) { proceeds.infrastructureProceeds += proceeds.sellerProceeds; proceeds.sellerProceeds = 0; } else { proceeds.sellerProceeds -= shortfall; proceeds.infrastructureProceeds = minInfrastructureFee; } } } } /** * @notice Transfers chain native token to `to`. * * @dev Throws when the native token transfer call reverts. * * @param to The address that will receive chain native tokens. * @param proceeds The amount of chain native token value to transfer. */ function _pushProceeds(address to, uint256 proceeds) internal { bool success; assembly { // Transfer the ETH and store if it succeeded or not. success := call(gas(), to, proceeds, 0, 0, 0, 0) } if (!success) { revert PaymentProcessor__FailedToTransferProceeds(); } } /** * @notice Refunds the taker any unspent native funds. * * @param remainingNativeFunds The amount of native funds that were not spent. * @param taker The address that will receive the unspent native funds. */ function _refundUnspentNativeFunds(uint256 remainingNativeFunds, address taker) internal { if (remainingNativeFunds > 0) { _pushProceeds(taker, remainingNativeFunds); } } /** * @notice Transfers chain native token to `payee`. * * @dev Throws when the native token transfer call reverts. * * @param payee The address that will receive chain native tokens. * @param proceeds The amount of chain native token value to transfer. */ function _payoutNativeCurrency( address payee, address /*payer*/, address /*paymentCoin*/, uint256 proceeds) internal { _pushProceeds(payee, proceeds); } /** * @notice Transfers ERC20 tokens to from `payer` to `payee`. * * @dev Throws when the ERC20 transfer call reverts. * * @param payee The address that will receive ERC20 tokens. * @param payer The address the ERC20 tokens will be sent from. * @param paymentCoin The ERC20 token being transferred. * @param proceeds The amount of token value to transfer. */ function _payoutCoinCurrency( address payee, address payer, address paymentCoin, uint256 proceeds) internal { if (SafeERC20.safeTransferFrom(paymentCoin, payer, payee, proceeds)) { revert PaymentProcessor__FailedToTransferProceeds(); } } /** * @notice Calls the token contract to transfer an ERC721 token from the seller to the buyer. * * @dev This will **NOT** throw if the transfer fails. It will instead return false * @dev so that the calling function can handle the failed transfer. * @dev Returns true if the transfer does not revert. * * @param from The seller of the token. * @param to The beneficiary of the order execution. * @param tokenAddress The contract address for the token being transferred. * @param tokenId The token id for the order. */ function _dispenseERC721Token( address from, address to, address tokenAddress, uint256 tokenId, uint256 /*amount*/) internal returns (bool) { try IERC721(tokenAddress).transferFrom(from, to, tokenId) { return true; } catch { return false; } } /** * @notice Calls the token contract to transfer an ERC1155 token from the seller to the buyer. * * @dev This will **NOT** throw if the transfer fails. It will instead return false * @dev so that the calling function can handle the failed transfer. * @dev Returns true if the transfer does not revert. * * @param from The seller of the token. * @param to The beneficiary of the order execution. * @param tokenAddress The contract address for the token being transferred. * @param tokenId The token id for the order. * @param amount The quantity of the token to transfer. */ function _dispenseERC1155Token( address from, address to, address tokenAddress, uint256 tokenId, uint256 amount) internal returns (bool) { try IERC1155(tokenAddress).safeTransferFrom(from, to, tokenId, amount, "") { return true; } catch { return false; } } /** * @notice Emits a a BuyListingERC721 event. * * @param context The current execution context to determine the taker. * @param saleDetails The order execution details. */ function _emitBuyListingERC721Event(TradeContext memory context, Order memory saleDetails) internal { emit BuyListingERC721( context.taker, saleDetails.maker, saleDetails.tokenAddress, saleDetails.beneficiary, saleDetails.paymentMethod, saleDetails.tokenId, saleDetails.itemPrice); } /** * @notice Emits a BuyListingERC1155 event. * * @param context The current execution context to determine the taker. * @param saleDetails The order execution details. */ function _emitBuyListingERC1155Event(TradeContext memory context, Order memory saleDetails) internal { emit BuyListingERC1155( context.taker, saleDetails.maker, saleDetails.tokenAddress, saleDetails.beneficiary, saleDetails.paymentMethod, saleDetails.tokenId, saleDetails.amount, saleDetails.itemPrice); } /** * @notice Emits an AcceptOfferERC721 event. * * @param context The current execution context to determine the taker. * @param saleDetails The order execution details. */ function _emitAcceptOfferERC721Event(TradeContext memory context, Order memory saleDetails) internal { emit AcceptOfferERC721( context.taker, saleDetails.maker, saleDetails.tokenAddress, saleDetails.beneficiary, saleDetails.paymentMethod, saleDetails.tokenId, saleDetails.itemPrice); } /** * @notice Emits an AcceptOfferERC1155 event. * * @param context The current execution context to determine the taker. * @param saleDetails The order execution details. */ function _emitAcceptOfferERC1155Event(TradeContext memory context, Order memory saleDetails) internal { emit AcceptOfferERC1155( context.taker, saleDetails.maker, saleDetails.tokenAddress, saleDetails.beneficiary, saleDetails.paymentMethod, saleDetails.tokenId, saleDetails.amount, saleDetails.itemPrice); } /** * @notice Returns the appropriate function pointers for payouts, dispensing tokens and event emissions. * * @param side The taker's side of the order. * @param paymentMethod The payment method for the order. If address zero, the chain native token. * @param orderProtocol The type of token and fill method for the order. */ function _getOrderFulfillmentFunctionPointers( Sides side, address paymentMethod, uint256 orderProtocol ) internal pure returns (FulfillOrderFunctionPointers memory orderFulfillmentFunctionPointers) { orderFulfillmentFunctionPointers = FulfillOrderFunctionPointers({ funcPayout: paymentMethod == address(0) ? _payoutNativeCurrency : _payoutCoinCurrency, funcDispenseToken: orderProtocol == ORDER_PROTOCOLS_ERC721_FILL_OR_KILL ? _dispenseERC721Token : _dispenseERC1155Token, funcEmitOrderExecutionEvent: orderProtocol == ORDER_PROTOCOLS_ERC721_FILL_OR_KILL ? (side == Sides.Buy ? _emitBuyListingERC721Event : _emitAcceptOfferERC721Event) : (side == Sides.Buy ?_emitBuyListingERC1155Event : _emitAcceptOfferERC1155Event) }); } /*************************************************************************/ /* Signature Verification */ /*************************************************************************/ /** * @notice Updates the remaining fillable amount and order status for partially fillable orders. * @notice Performs checks for minimum fillable amount and order status. * * @dev Throws when the remaining fillable amount is less than the minimum fillable amount requested. * @dev Throws when the order status is not open. * * @param account The maker account for the order. * @param orderDigest The hash digest of the order execution details. * @param orderStartAmount The original amount for the partially fillable order. * @param requestedFillAmount The amount the taker is requesting to fill. * @param minimumFillAmount The minimum amount the taker is willing to fill. * * @return quantityToFill Lesser of remainingFillableAmount and requestedFillAmount. */ function _checkAndUpdateRemainingFillableItems( address account, bytes32 orderDigest, uint256 orderStartAmount, uint256 requestedFillAmount, uint256 minimumFillAmount ) internal returns (uint256 quantityToFill) { if(orderStartAmount > type(uint248).max) { revert PaymentProcessor__AmountExceedsMaximum(); } quantityToFill = requestedFillAmount; PartiallyFillableOrderStatus storage partialFillStatus = appStorage().partiallyFillableOrderStatuses[account][orderDigest]; if (partialFillStatus.state == PartiallyFillableOrderState.Open) { if (partialFillStatus.remainingFillableQuantity == 0) { partialFillStatus.remainingFillableQuantity = uint248(orderStartAmount); emit OrderDigestOpened(orderDigest, account, orderStartAmount); } if (quantityToFill > partialFillStatus.remainingFillableQuantity) { quantityToFill = partialFillStatus.remainingFillableQuantity; } if (quantityToFill < minimumFillAmount) { revert PaymentProcessor__UnableToFillMinimumRequestedQuantity(); } unchecked { partialFillStatus.remainingFillableQuantity -= uint248(quantityToFill); emit OrderDigestItemsFilled(orderDigest, account, quantityToFill); } if (partialFillStatus.remainingFillableQuantity == 0) { partialFillStatus.state = PartiallyFillableOrderState.Filled; emit OrderDigestInvalidated(orderDigest, account, false); } } else { revert PaymentProcessor__OrderIsEitherCancelledOrFilled(); } } /** * @notice Restored items to a partially fillable order when the items failed to dispense in a bulk order fill. * * @param account The maker account for the order. * @param orderDigest The hash digest of the order execution details. * @param unfilledAmount The amount that was subtracted from the order that needs to be added back. * */ function _restoreFillableItems(address account, bytes32 orderDigest, uint256 unfilledAmount) internal { if (unfilledAmount > 0) { PartiallyFillableOrderStatus storage partialFillStatus = appStorage().partiallyFillableOrderStatuses[account][orderDigest]; unchecked { partialFillStatus.remainingFillableQuantity += uint248(unfilledAmount); } partialFillStatus.state = PartiallyFillableOrderState.Open; emit OrderDigestItemsRestored(orderDigest, account, unfilledAmount); } } /** * @notice Invalidates a maker's nonce and emits a NonceInvalidated event. * * @dev Throws when the nonce has already been invalidated. * * @param account The maker account to invalidate `nonce` of. * @param nonce The nonce to invalidate. * @param wasCancellation If true, the invalidation is the maker cancelling the nonce. * If false, from the nonce being used to execute an order. */ function _checkAndInvalidateNonce( address account, uint256 nonce, bool wasCancellation) internal returns (uint256) { // The following code is equivalent to, but saves 115 gas units: // // mapping(uint256 => uint256) storage ptrInvalidatedSignatureBitmap = // appStorage().invalidatedSignatures[account]; // unchecked { // uint256 slot = nonce / 256; // uint256 offset = nonce % 256; // uint256 slotValue = ptrInvalidatedSignatureBitmap[slot]; // // if (((slotValue >> offset) & ONE) == ONE) { // revert PaymentProcessor__SignatureAlreadyUsedOrRevoked(); // } // // ptrInvalidatedSignatureBitmap[slot] = (slotValue | ONE << offset); // } unchecked { if (uint256(appStorage().invalidatedSignatures[account][uint248(nonce >> 8)] ^= (ONE << uint8(nonce))) & (ONE << uint8(nonce)) == ZERO) { revert PaymentProcessor__SignatureAlreadyUsedOrRevoked(); } } emit NonceInvalidated(nonce, account, wasCancellation); return appStorage().masterNonces[account]; } /** * @notice After a maker's nonce is invalidated, should the order item fail to transfer * we need to restore the nonce so order cannot be griefed. Emits a NonceRestored event. * * @dev Throws when the nonce has already been invalidated. * * @param account The maker account to restore `nonce` of. * @param nonce The nonce to restore. */ function _restoreNonce(address account, uint256 nonce) internal { unchecked { if (uint256(appStorage().invalidatedSignatures[account][uint248(nonce >> 8)] ^= (ONE << uint8(nonce))) & (ONE << uint8(nonce)) != ZERO) { revert PaymentProcessor__SignatureNotUsedOrRevoked(); } } emit NonceRestored(nonce, account); } /** * @notice Updates the state of a maker's order to cancelled and remaining fillable quantity to zero. * * @dev Throws when the current order state is not open. * * @param account The maker account to invalid the order for. * @param orderDigest The hash digest of the order to invalidate. */ function _revokeOrderDigest(address account, bytes32 orderDigest) internal { PartiallyFillableOrderStatus storage partialFillStatus = appStorage().partiallyFillableOrderStatuses[account][orderDigest]; if (partialFillStatus.state == PartiallyFillableOrderState.Open) { partialFillStatus.state = PartiallyFillableOrderState.Cancelled; partialFillStatus.remainingFillableQuantity = 0; emit OrderDigestInvalidated(orderDigest, account, true); } else { revert PaymentProcessor__OrderIsEitherCancelledOrFilled(); } } /** * @notice Invalidates a maker's nonce and emits a NonceInvalidated event. * * @dev Skips nonce invalidation for partial fillable orders. * @dev Throws when the nonce has already been invalidated. * * @param saleDetails The order execution details. */ function _checkAndInvalidateNonceForFillOrKillOrders( Order memory saleDetails ) internal returns (uint256 masterNonce) { masterNonce = saleDetails.protocol == ORDER_PROTOCOLS_ERC1155_FILL_PARTIAL ? appStorage().masterNonces[saleDetails.maker] : _checkAndInvalidateNonce(saleDetails.maker, saleDetails.nonce, false); } /** * Verifies offer is approved by the maker. * * @dev Throws when a cosignature is required and the cosignature is invalid. * @dev Throws when the maker signature is invalid. * @dev Throws when the maker's order nonce has already been used or was cancelled. * @dev Throws when a partially fillable order has already been filled, cancelled or * @dev cannot be filled with the minimum fillable amount. * * @param offerType The type of offer to execute. * @param context The current execution context to determine the taker. * @param saleDetails The order execution details. * @param signature The order maker's signature. * @param cosignature The cosignature from the order cosigner, if applicable. * @param tokenSetProof The token set proof that contains the root hash for the merkle * tree of allowed tokens for accepting the maker's offer. */ function _verifyBidOrderSignatures( uint256 offerType, TradeContext memory context, Order memory saleDetails, SignatureECDSA memory signature, Cosignature memory cosignature, TokenSetProof calldata tokenSetProof ) internal returns (uint256 quantityToFill) { if (offerType == OFFER_TYPE_COLLECTION_OFFER) { quantityToFill = _verifyCollectionOffer( context, saleDetails, signature, cosignature); } else if (offerType == OFFER_TYPE_ITEM_OFFER) { quantityToFill = _verifyItemOffer( context, saleDetails, signature, cosignature); } else if (offerType == OFFER_TYPE_TOKEN_SET_OFFER) { quantityToFill = _verifyTokenSetOffer( context, saleDetails, signature, cosignature, tokenSetProof); } else { revert PaymentProcessor__InvalidOfferType(); } } /** * @notice Verifies a token offer is approved by the maker. * * @dev Throws when a cosignature is required and the cosignature is invalid. * @dev Throws when the maker signature is invalid. * @dev Throws when the maker's order nonce has already been used or was cancelled. * @dev Throws when a partially fillable order has already been filled, cancelled or * @dev cannot be filled with the minimum fillable amount. * * @param context The current execution context to determine the taker. * @param saleDetails The order execution details. * @param signature The order maker's signature. * @param cosignature The cosignature from the order cosigner, if applicable. * * @return quantityToFill The amount of the token that will be filled for this order. */ function _verifyItemOffer( TradeContext memory context, Order memory saleDetails, SignatureECDSA memory signature, Cosignature memory cosignature ) internal returns (uint256 quantityToFill) { quantityToFill = _verifyOrderSignatures( context, saleDetails, signature, cosignature, _generateItemOfferOrderHash( saleDetails, saleDetails.maker, cosignature.signer, _checkAndInvalidateNonceForFillOrKillOrders(saleDetails) ) ); } /** * @notice Verifies a collection offer is approved by the maker. * * @dev Throws when a cosignature is required and the cosignature is invalid. * @dev Throws when the maker signature is invalid. * @dev Throws when the maker's order nonce has already been used or was cancelled. * @dev Throws when a partially fillable order has already been filled, cancelled or * @dev cannot be filled with the minimum fillable amount. * * @param context The current execution context to determine the taker. * @param saleDetails The order execution details. * @param signature The order maker's signature. * @param cosignature The cosignature from the order cosigner, if applicable. * * @return quantityToFill The amount of the token that will be filled for this order. */ function _verifyCollectionOffer( TradeContext memory context, Order memory saleDetails, SignatureECDSA memory signature, Cosignature memory cosignature ) internal returns (uint256 quantityToFill) { quantityToFill = _verifyOrderSignatures( context, saleDetails, signature, cosignature, _generateCollectionOfferOrderHash( saleDetails, saleDetails.maker, cosignature.signer, _checkAndInvalidateNonceForFillOrKillOrders(saleDetails) ) ); } /** * @notice Verifies a token set offer is approved by the maker. * * @dev Throws when a cosignature is required and the cosignature is invalid. * @dev Throws when the maker signature is invalid. * @dev Throws when the maker's order nonce has already been used or was cancelled. * @dev Throws when a partially fillable order has already been filled, cancelled or * @dev cannot be filled with the minimum fillable amount. * * @param context The current execution context to determine the taker. * @param saleDetails The order execution details. * @param signature The order maker's signature. * @param tokenSetProof The token set proof that contains the root hash for the merkle * tree of allowed tokens for accepting the maker's offer. * @param cosignature The cosignature from the order cosigner, if applicable. * * @return quantityToFill The amount of the token that will be filled for this order. */ function _verifyTokenSetOffer( TradeContext memory context, Order memory saleDetails, SignatureECDSA memory signature, Cosignature memory cosignature, TokenSetProof calldata tokenSetProof ) internal returns (uint256 quantityToFill) { bytes32 orderHash = _generateTokenSetOfferOrderHash( tokenSetProof, saleDetails, saleDetails.maker, cosignature.signer, _checkAndInvalidateNonceForFillOrKillOrders(saleDetails) ); quantityToFill = _verifyOrderSignatures( context, saleDetails, signature, cosignature, orderHash ); } /** * @notice Verifies a listing is approved by the maker. * * @dev Throws when a cosignature is required and the cosignature is invalid. * @dev Throws when the maker signature is invalid. * @dev Throws when the maker's order nonce has already been used or was cancelled. * @dev Throws when a partially fillable order has already been filled, cancelled or * @dev cannot be filled with the minimum fillable amount. * * @param context The current execution context to determine the taker. * @param saleDetails The order execution details. * @param signature The order maker's signature. * @param cosignature The cosignature from the order cosigner, if applicable. * * @return quantityToFill The amount of the token that will be filled for this order. */ function _verifySaleApproval( TradeContext memory context, Order memory saleDetails, SignatureECDSA memory signature, Cosignature memory cosignature ) internal returns (uint256 quantityToFill) { quantityToFill = _verifyOrderSignatures( context, saleDetails, signature, cosignature, _generateListingOrderHash( saleDetails, saleDetails.maker, cosignature.signer, _checkAndInvalidateNonceForFillOrKillOrders(saleDetails) ) ); } /** * @notice Verifies a listing is approved by the maker. * * @dev Throws when a cosignature is required and the cosignature is invalid. * @dev Throws when the maker signature is invalid. * @dev Throws when the maker's order nonce has already been used or was cancelled. * @dev Throws when a partially fillable order has already been filled, cancelled or * @dev cannot be filled with the minimum fillable amount. * * @param context The current execution context to determine the taker. * @param saleDetails The order execution details. * @param signature The order maker's signature. * @param cosignature The cosignature from the order cosigner, if applicable. * @param orderHash The hash digest of the order execution details. */ function _verifyOrderSignatures( TradeContext memory context, Order memory saleDetails, SignatureECDSA memory signature, Cosignature memory cosignature, bytes32 orderHash ) internal returns (uint256 quantityToFill) { if (cosignature.signer != address(0)) { _verifyCosignature(context, signature, cosignature); } bytes32 orderDigest = _hashTypedDataV4(_cachedDomainSeparator, orderHash); _verifyMakerSignature(saleDetails.maker, signature, orderDigest); if (saleDetails.protocol == ORDER_PROTOCOLS_ERC1155_FILL_PARTIAL) { quantityToFill = _checkAndUpdateRemainingFillableItems( saleDetails.maker, orderHash, saleDetails.amount, saleDetails.requestedFillAmount, saleDetails.minimumFillAmount); context.orderDigest = orderHash; } else { quantityToFill = saleDetails.amount; } } /** * @notice Reverts a transaction when the recovered signer is not the order maker. * * @dev Throws when the recovered signer for the `signature` and `digest` does not match the order maker AND * @dev - The maker address does not have deployed code, OR * @dev - The maker contract does not return the correct ERC1271 value to validate the signature. * * @param maker The adress for the order maker. * @param signature The order maker's signature. * @param digest The hash digest of the order. */ function _verifyMakerSignature(address maker, SignatureECDSA memory signature, bytes32 digest ) internal view { (bool isError, address signer) = _tryEcdsaRecover(digest, signature.v, signature.r, signature.s); if (maker != signer || isError) { if (maker.code.length > 0) { _verifyEIP1271Signature(maker, digest, signature); } else { revert PaymentProcessor__UnauthorizedOrder(); } } } /** * @notice Reverts the transaction when a supplied cosignature is not valid. * * @dev Throws when the current block timestamp is greater than the cosignature expiration. * @dev Throws when the order taker does not match the cosignature taker. * @dev Throws when the cosigner has self-destructed their account. * @dev Throws when the recovered address for the cosignature does not match the cosigner address. * * @param context The current execution context to determine the order taker. * @param signature The order maker's signature. * @param cosignature The cosignature from the order cosigner. */ function _verifyCosignature( TradeContext memory context, SignatureECDSA memory signature, Cosignature memory cosignature ) internal view { if (block.timestamp > cosignature.expiration) { revert PaymentProcessor__CosignatureHasExpired(); } if (context.taker != cosignature.taker) { revert PaymentProcessor__UnauthorizedTaker(); } if (appStorage().destroyedCosigners[cosignature.signer]) { revert PaymentProcessor__CosignerHasSelfDestructed(); } if (cosignature.signer != _ecdsaRecover( _hashTypedDataV4( _cachedDomainSeparator, EfficientHash.efficientHash( COSIGNATURE_HASH, bytes32(signature.v), signature.r, signature.s, bytes32(cosignature.expiration), bytes32(uint256(uint160(cosignature.taker))) ) ), cosignature.v, cosignature.r, cosignature.s)) { revert PaymentProcessor__NotAuthorizedByCosigner(); } } /** * @notice Reverts the transaction if the contract at `signer` does not return the ERC1271 * @notice isValidSignature selector when called with `hash`. * * @dev Throws when attempting to verify a signature from an address that has deployed * @dev contract code using ERC1271 and the contract does not return the isValidSignature * @dev function selector as its return value. * * @param signer The signer address for a maker order that has deployed contract code. * @param hash The ERC712 hash value of the order. * @param signature The signature for the order hash. */ function _verifyEIP1271Signature( address signer, bytes32 hash, SignatureECDSA memory signature ) internal view { if (!_safeIsValidSignature(signer, hash, signature.v, signature.r, signature.s)) { revert PaymentProcessor__EIP1271SignatureInvalid(); } } /** * @notice A gas efficient, and fallback-safe way to call the isValidSignature function for EIP-1271. * * @param signer The EIP-1271 signer to call to check for a valid signature. * @param hash The hash digest to verify with the EIP-1271 signer. * @param v The `v` value of the signature * @param r The `r` value of the signature * @param s The `s` value of the signature * * @return isValid True if the EIP-1271 signer returns the EIP-1271 magic value. */ function _safeIsValidSignature( address signer, bytes32 hash, uint256 v, bytes32 r, bytes32 s ) private view returns(bool isValid) { if (v > type(uint8).max) { revert PaymentProcessor__InvalidSignatureV(); } assembly { function _callIsValidSignature(_signer, _hash, _r, _s, _v) -> _isValid { let ptr := mload(0x40) // store isValidSignature(bytes32,bytes) selector mstore(ptr, hex"1626ba7e") // store bytes32 hash value in abi encoded location mstore(add(ptr, 0x04), _hash) // store abi encoded location of the bytes signature data mstore(add(ptr, 0x24), 0x40) // store bytes signature length mstore(add(ptr, 0x44), 0x41) // store the signature `_r`, `_v` and `_s` in memory // `_v` is stored before `_s` to avoid shifting mstore(add(ptr, 0x64), _r) mstore(add(ptr, 0x85), _v) mstore(add(ptr, 0x84), _s) // update free memory pointer, 0xC4 is the length of calldata mstore(0x40, add(ptr, 0xC4)) // static call _signer with abi encoded data // skip return data check if call failed or return data size is not at least 32 bytes if and(iszero(lt(returndatasize(), 0x20)), staticcall(gas(), _signer, ptr, 0xC4, 0x00, 0x20)) { // check if return data is equal to isValidSignature magic value _isValid := eq(mload(0x00), hex"1626ba7e") leave } } isValid := _callIsValidSignature(signer, hash, r, s, v) } } /** * @notice Recovers the signer address from a hash and signature. * * @dev Throws when `v` is greater than `type(uint8).max`. * @dev Throws when the recovered address is zero. * * @param digest The hash digest that was signed. * @param v The v-value of the signature. * @param r The r-value of the signature. * @param s The s-value of the signature. * * @return signer The recovered signer address from the signature. */ function _ecdsaRecover( bytes32 digest, uint256 v, bytes32 r, bytes32 s ) internal pure returns (address signer) { bool isError; (isError, signer) = _tryEcdsaRecover(digest, v, r, s); if(isError) { revert PaymentProcessor__UnauthorizedOrder(); } } /** * @notice Recovers the signer address from a hash and signature. * * @dev Does **NOT** revert if invalid input values are provided or `signer` is recovered as address(0) * @dev Returns an `isError` value in those conditions that is handled upstream * * @param digest The hash digest that was signed. * @param v The v-value of the signature. * @param r The r-value of the signature. * @param s The s-value of the signature. * * @return isError True if the ECDSA function is provided invalid inputs * @return signer The recovered signer address from the signature. */ function _tryEcdsaRecover( bytes32 digest, uint256 v, bytes32 r, bytes32 s ) internal pure returns (bool isError, address signer) { if (v > type(uint8).max) { return (true, address(0)); } signer = ecrecover(digest, uint8(v), r, s); isError = (signer == address(0)); } /** * @notice Returns the EIP-712 hash digest for `domainSeparator` and `structHash`. * * @param domainSeparator The domain separator for the EIP-712 hash. * @param structHash The hash of the EIP-712 struct. */ function _hashTypedDataV4(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) { return ECDSA.toTypedDataHash(domainSeparator, structHash); } /*************************************************************************/ /* Miscellaneous */ /*************************************************************************/ /** * @notice Pulls settings from the CollectionSettingsRegistry contract and updates the * @notice applicable cached collection settings in the PaymentProcessor contract. * * @param tokenAddress The contract address for the token to update settings for. */ function _syncCollectionSettings(address tokenAddress) internal { bytes32[] memory noExtensions; ( CollectionRegistryPaymentSettings memory collectionCoreSettings, RegistryPricingBounds memory collectionPricingBounds, address constrainedPricingPaymentMethod, address exclusiveBountyReceiver,, ) = ICollectionSettingsRegistry(collectionSettingsRegistry).getCollectionSettings(tokenAddress, noExtensions, noExtensions); uint8 flags = uint8(collectionCoreSettings.extraData); appStorage().collectionPaymentSettings[tokenAddress] = CollectionPaymentSettings({ initialized: true, paymentSettings: PaymentSettings(collectionCoreSettings.paymentSettingsType), paymentMethodWhitelistId: collectionCoreSettings.paymentMethodWhitelistId, royaltyBackfillReceiver: collectionCoreSettings.royaltyBackfillReceiver, royaltyBackfillNumerator: collectionCoreSettings.royaltyBackfillNumerator, royaltyBountyNumerator: collectionCoreSettings.royaltyBountyNumerator, flags: flags }); if (PaymentSettings(collectionCoreSettings.paymentSettingsType) == PaymentSettings.PricingConstraints || PaymentSettings(collectionCoreSettings.paymentSettingsType) == PaymentSettings.PricingConstraintsCollectionOnly) { appStorage().collectionConstrainedPricingPaymentMethods[tokenAddress] = constrainedPricingPaymentMethod; PricingBounds memory currentPricingBounds = appStorage().collectionPricingBounds[tokenAddress]; if(!(currentPricingBounds.isSet == collectionPricingBounds.isSet && currentPricingBounds.floorPrice == collectionPricingBounds.floorPrice && currentPricingBounds.ceilingPrice == collectionPricingBounds.ceilingPrice) ) { appStorage().collectionPricingBounds[tokenAddress] = PricingBounds({ initialized: true, isSet: collectionPricingBounds.isSet, floorPrice: collectionPricingBounds.floorPrice, ceilingPrice: collectionPricingBounds.ceilingPrice }); emit UpdatedCollectionLevelPricingBoundaries( tokenAddress, collectionPricingBounds.floorPrice, collectionPricingBounds.ceilingPrice); } } if (_isFlagSet(flags, FLAG_IS_ROYALTY_BOUNTY_EXCLUSIVE)) { appStorage().collectionExclusiveBountyReceivers[tokenAddress] = exclusiveBountyReceiver; } emit UpdatedCollectionPaymentSettings( tokenAddress, PaymentSettings(collectionCoreSettings.paymentSettingsType), collectionCoreSettings.paymentMethodWhitelistId, constrainedPricingPaymentMethod, collectionCoreSettings.royaltyBackfillNumerator, collectionCoreSettings.royaltyBackfillReceiver, collectionCoreSettings.royaltyBountyNumerator, exclusiveBountyReceiver, _isFlagSet(flags, FLAG_BLOCK_TRADES_FROM_UNTRUSTED_CHANNELS), _isFlagSet(flags, FLAG_USE_BACKFILL_AS_ROYALTY_SOURCE)); } /** * @notice Reverts the transaction if the caller is not the CollectionSettingsRegistry or the contract itself. */ function _requireCallerIsCollectionSettingsRegistryOrSelf() internal view { if(!(msg.sender == collectionSettingsRegistry || msg.sender == address(this))) { revert PaymentProcessor__CallerIsNotSettingsRegistryOrSelf(); } } /** * @notice Returns true if the `flagValue` has the `flag` set, false otherwise. * * @dev This function uses the bitwise AND operator to check if the `flag` is set in `flagValue`. * * @param flagValue The value to check for the presence of the `flag`. * @param flag The flag to check for in the `flagValue`. */ function _isFlagSet(uint8 flagValue, uint8 flag) internal pure returns (bool flagSet) { flagSet = (flagValue & flag) != 0; } /** * @notice Sets the `flag` in `flagValue` to `flagSet` and returns the updated value. * * @dev This function uses the bitwise OR and AND operators to set or unset the `flag` in `flagValue`. * * @param flagValue The value to set the `flag` in. * @param flag The flag to set in the `flagValue`. * @param flagSet True to set the `flag`, false to unset the `flag`. */ function _setFlag(uint8 flagValue, uint8 flag, bool flagSet) internal pure returns (uint8) { if(flagSet) { return (flagValue | flag); } else { unchecked { return (flagValue & (255 - flag)); } } } /** * @notice A gas efficient, and fallback-safe way to call the royaltyInfo function on a token contract. * * @dev This will get the royaltyInfo if it exists - and when the function is unimplemented, the * @dev presence of a fallback function will not result in halted execution. * * @param tokenAddress The contract address of the token to check for royalties. * @param tokenId The token ID to check for royalties. * @param salePrice The sale price of the token. */ function _safeRoyaltyInfo( address tokenAddress, uint256 tokenId, uint256 salePrice ) internal view returns(address receiver, uint256 royaltyAmount, bool isError) { assembly { function _callRoyaltyInfo(_tokenAddress, _tokenId, _salePrice) -> _receiver, _royaltyAmount, _isError { let ptr := mload(0x40) mstore(0x40, add(ptr, 0x60)) mstore(ptr, 0x2a55205a) mstore(add(0x20, ptr), _tokenId) mstore(add(0x40, ptr), _salePrice) if and(iszero(lt(returndatasize(), 0x40)), staticcall(gas(), _tokenAddress, add(ptr, 0x1C), 0x44, 0x00, 0x40)) { _receiver := mload(0x00) _royaltyAmount := mload(0x20) leave } _isError := true } receiver, royaltyAmount, isError := _callRoyaltyInfo(tokenAddress, tokenId, salePrice) } } /** * @notice A gas efficient, and fallback-safe way to call the owner function on a token contract. * * @dev This will get the owner if it exists - and when the function is unimplemented, the * @dev presence of a fallback function will not result in halted execution. * * @param tokenAddress The contract address of the token to check for the owner. */ function _safeOwner( address tokenAddress ) internal view returns(address owner, bool isError) { assembly { function _callOwner(_tokenAddress) -> _owner, _isError { mstore(0x00, 0x8da5cb5b) if and(iszero(lt(returndatasize(), 0x20)), staticcall(gas(), _tokenAddress, 0x1C, 0x04, 0x00, 0x20)) { _owner := mload(0x00) leave } _isError := true } owner, isError := _callOwner(tokenAddress) } } /** * @notice A gas efficient, and fallback-safe way to call the hasRole function on a token contract. * * @dev This will check if the account `hasRole` if `hasRole` exists - and when the function is unimplemented, the * @dev presence of a fallback function will not result in halted execution. * * @param tokenAddress The contract address of the token to check for the role. * @param role The role to check for. * @param account The account to check for the role. */ function _safeHasRole( address tokenAddress, bytes32 role, address account ) internal view returns(bool hasRole, bool isError) { assembly { function _callHasRole(_tokenAddress, _role, _account) -> _hasRole, _isError { let ptr := mload(0x40) mstore(0x40, add(ptr, 0x60)) mstore(ptr, 0x91d14854) mstore(add(0x20, ptr), _role) mstore(add(0x40, ptr), _account) if and(iszero(lt(returndatasize(), 0x20)), staticcall(gas(), _tokenAddress, add(ptr, 0x1C), 0x44, 0x00, 0x20)) { _hasRole := mload(0x00) leave } _isError := true } hasRole, isError := _callHasRole(tokenAddress, role, account) } } /** * @notice Returns the taker for a transaction with trusted forwarder context if appended data length is 20 bytes. * * @dev Throws when appended data length is not zero or 20 bytes. * * @param appendedDataLength The length of extra calldata sent with a transaction. * * @return taker The address of the taker for the transaction. */ function _getTaker( uint256 appendedDataLength ) internal view returns(address taker) { taker = msg.sender; if (appendedDataLength > 0) { if (appendedDataLength != 20) revert PaymentProcessor__BadCalldataLength(); taker = _msgSender(); } } }
//SPDX-License-Identifier: LicenseRef-PolyForm-Strict-1.0.0 pragma solidity 0.8.24; import "./PaymentProcessorModulePermits.sol"; /* @@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@( @@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@ #@@@@@@@@@@@@@@ @@@@@@@@@@@@ @@@@@@@@@@@@@@* @@@@@@@@@@@@ @@@@@@@@@@@@@@@ @ @@@@@@@@@@@@ @@@@@@@@@@@@@@@ @ @@@@@@@@@@@ @@@@@@@@@@@@@@@ @@ @@@@@@@@@@@@ @@@@@@@@@@@@@@@ #@@ @@@@@@@@@@@@/ @@@@@@@@@@@@@@. @@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@ @@@@@&%%%%%%%%&&@@@@@@@@@@@@@@ @@@@@@@@@@@@@@ @@@@@ @@@@@@@@@@@ @@@@@@@@@@@@@@@ @@@@@ @@@@@@@@@@@ @@@@@@@@@@@@@@@ @@@@@@ @@@@@@@@@@@ @@@@@@@@@@@@@@@ @@@@@@@ @@@@@@@@@@@ @@@@@@@@@@@@@@@ @@@@@@@ @@@@@@@@@@@& @@@@@@@@@@@@@@ *@@@@@@@ (@@@@@@@@@@@@ @@@@@@@@@@@@@@@ @@@@@@@@ @@@@@@@@@@@@@@ @@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ .@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@% @@@@@@@@@@@@@@@@@@@@@@@@( @@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@& @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ * @title PaymentProcessorModuleAdvanced * @custom:version 3.0.0 * @author Limit Break, Inc. */ abstract contract PaymentProcessorModuleAdvanced is PaymentProcessorModulePermits { using EnumerableSet for EnumerableSet.AddressSet; constructor(address configurationContract) PaymentProcessorModulePermits(configurationContract) {} /*************************************************************************/ /* Order Execution */ /*************************************************************************/ /** * @notice Executes an advanced buy side order. An advanced order includes an optional permit context and optional bulk order proof. * * @dev Throws when the permit processor is not trusted. * @dev Throws when the permit processor is provided and the maker created the order by signing a merkle tree root. * * @param tradeContext The execution context of the trade. * @param startingNativeFunds The starting native funds. * @param advancedListing Order details including the permit context, signatures and sale details. * @param bulkOrderProof Optional bulk order proof. * @param feeOnTop The additional fee to add on top of the orders, paid by taker. */ function _executeOrderBuySideAdvanced( TradeContext memory tradeContext, uint256 startingNativeFunds, AdvancedOrder memory advancedListing, BulkOrderProof calldata bulkOrderProof, FeeOnTop calldata feeOnTop ) internal returns (uint256 endingNativeFunds) { if (advancedListing.permitContext.permitProcessor == address(0)) { if (bulkOrderProof.proof.length == 0) { endingNativeFunds = _executeOrderBuySide( tradeContext, startingNativeFunds, advancedListing.saleDetails, advancedListing.signature, advancedListing.cosignature, feeOnTop); } else { endingNativeFunds = _executeOrderBuySideBulk( tradeContext, startingNativeFunds, advancedListing, bulkOrderProof, feeOnTop); } } else { if (bulkOrderProof.proof.length == 0) { if (!_isTrustedPermitProcessor(advancedListing.permitContext.permitProcessor)) { revert PaymentProcessor__PermitProcessorNotTrusted(); } advancedListing.saleDetails.itemPrice = uint240(advancedListing.saleDetails.itemPrice); endingNativeFunds = _validateAndFulfillSinglePermittedOrder( startingNativeFunds, Sides.Buy, advancedListing, tradeContext, feeOnTop); } else { revert PaymentProcessor__PermitsAreNotCompatibleWithBulkOrders(); } } } /** * @notice Verifies the proof and signature of an order that was generated by a signed merkle tree root * @notice and executes the order. * * @dev Throws when the order type is ORDER_PROTOCOLS_ERC1155_FILL_PARTIAL and the remaining fillable * @dev amount is less than the minimum fillable amount requested. * @dev Throws when the order status is not open. * @dev Throws when the nonce has already been invalidated. * @dev Throws when a cosignature is required and the cosignature is invalid. * @dev Throws when the maker's signature is invalid. * * @param tradeContext The execution context of the trade. * @param startingNativeFunds The starting native funds. * @param advancedListing Order details including the permit context, signatures and sale details. * @param bulkOrderProof The bulk order proof and order index. * @param feeOnTop The additional fee to add on top of the orders, paid by taker. */ function _executeOrderBuySideBulk( TradeContext memory tradeContext, uint256 startingNativeFunds, AdvancedOrder memory advancedListing, BulkOrderProof calldata bulkOrderProof, FeeOnTop calldata feeOnTop ) internal returns (uint256 endingNativeFunds) { Order memory saleDetails = advancedListing.saleDetails; saleDetails.itemPrice = uint240(saleDetails.itemPrice); uint256 quantityToFill = _verifyBulkSaleApprovalProofAndSignedTree( tradeContext, saleDetails, advancedListing.signature, advancedListing.cosignature, bulkOrderProof); endingNativeFunds = _validateAndFulfillOrder( Sides.Buy, tradeContext, startingNativeFunds, quantityToFill, saleDetails, feeOnTop); } /** * @notice Executes an advanced sell side order. An advanced order includes an optional permit context and optional bulk order proof. * * @dev Throws when the permit processor is provided and is not trusted. * @dev Throws when the permit processor is provided and the maker created the order by signing a merkle tree root. * @dev Throws when the permit processor is set and the order is paid with the native token. * * @param tradeContext The execution context of the trade. * @param advancedBid Order details including the permit context, signatures and sale details. * @param bulkOrderProof Optional bulk order proof. * @param feeOnTop The additional fee to add on top of the orders, paid by taker. */ function _executeOrderSellSideAdvanced( TradeContext memory tradeContext, AdvancedBidOrder memory advancedBid, BulkOrderProof calldata bulkOrderProof, FeeOnTop calldata feeOnTop, TokenSetProof calldata tokenSetProof ) internal { if (advancedBid.advancedOrder.permitContext.permitProcessor == address(0)) { if (bulkOrderProof.proof.length == 0) { _executeOrderSellSide( tradeContext, advancedBid.offerType, advancedBid.advancedOrder.saleDetails, advancedBid.advancedOrder.signature, tokenSetProof, advancedBid.advancedOrder.cosignature, feeOnTop); } else { _executeOrderSellSideBulk( tradeContext, advancedBid, bulkOrderProof, feeOnTop, tokenSetProof); } } else { if (bulkOrderProof.proof.length == 0) { if (!_isTrustedPermitProcessor(advancedBid.advancedOrder.permitContext.permitProcessor)) { revert PaymentProcessor__PermitProcessorNotTrusted(); } if (advancedBid.advancedOrder.saleDetails.paymentMethod == address(0)) { revert PaymentProcessor__BadPaymentMethod(); } advancedBid.advancedOrder.saleDetails.itemPrice = uint240(advancedBid.advancedOrder.saleDetails.itemPrice); uint256 quantityToFill = _verifyBidOrderSignatures( advancedBid.offerType, tradeContext, advancedBid.advancedOrder.saleDetails, advancedBid.advancedOrder.signature, advancedBid.advancedOrder.cosignature, tokenSetProof); _adjustForUnitPricing(quantityToFill, advancedBid.advancedOrder.saleDetails); advancedBid.advancedOrder.signature = advancedBid.sellerPermitSignature; _validateAndFulfillSinglePermittedOrder(0, Sides.Sell, advancedBid.advancedOrder, tradeContext, feeOnTop); } else { revert PaymentProcessor__PermitsAreNotCompatibleWithBulkOrders(); } } } /** * @notice Verifies the proof and signature of an order that was generated by a signed merkle tree root * @notice and executes the order. * * @dev Throws when the payment method is the native token. * @dev Throws when the token set proof is provided and is invalid. * @dev Throws when the nonce has already been invalidated. * @dev Throws when a cosignature is required and the cosignature is invalid. * @dev Throws when the maker's signature is invalid. * @dev Throws when the order status is not open. * @dev Throws when the order type is ORDER_PROTOCOLS_ERC1155_FILL_PARTIAL and the remaining fillable * @dev amount is less than the minimum fillable amount requested. * * @param tradeContext The execution context of the trade. * @param advancedBid Order details including the permit context, signatures and sale details. * @param bulkOrderProof The bulk order proof and order index. * @param feeOnTop The additional fee to add on top of the orders, paid by taker. * @param tokenSetProof The token set proof that contains the root hash for the merkle * tree of allowed tokens for accepting the maker's offer. */ function _executeOrderSellSideBulk( TradeContext memory tradeContext, AdvancedBidOrder memory advancedBid, BulkOrderProof calldata bulkOrderProof, FeeOnTop calldata feeOnTop, TokenSetProof calldata tokenSetProof ) internal { Order memory saleDetails = advancedBid.advancedOrder.saleDetails; saleDetails.itemPrice = uint240(saleDetails.itemPrice); if (saleDetails.paymentMethod == address(0)) { revert PaymentProcessor__BadPaymentMethod(); } uint256 quantityToFill; uint256 offerType = advancedBid.offerType; if (offerType == OFFER_TYPE_COLLECTION_OFFER) { quantityToFill = _verifyBulkCollectionOfferApprovalProofAndSignedTree( tradeContext, saleDetails, advancedBid.advancedOrder.signature, advancedBid.advancedOrder.cosignature, bulkOrderProof); } else if (offerType == OFFER_TYPE_ITEM_OFFER) { quantityToFill = _verifyBulkItemOfferApprovalProofAndSignedTree( tradeContext, saleDetails, advancedBid.advancedOrder.signature, advancedBid.advancedOrder.cosignature, bulkOrderProof); } else if (offerType == OFFER_TYPE_TOKEN_SET_OFFER) { quantityToFill = _verifyBulkTokenSetOfferApprovalProofAndSignedTree( tradeContext, saleDetails, advancedBid.advancedOrder.signature, tokenSetProof, advancedBid.advancedOrder.cosignature, bulkOrderProof); } else { revert PaymentProcessor__InvalidOfferType(); } _validateAndFulfillOrder( Sides.Sell, tradeContext, 0, quantityToFill, saleDetails, feeOnTop); } /** * @notice Executes a sweep order. A sweep order is a collection of items that are purchased in a single transaction. * * @dev Throws when the sweep order protocol is ORDER_PROTOCOLS_ERC1155_FILL_PARTIAL. * @dev Throws when the sweep order items array is empty. * @dev Throws when a collection is set to block untrusted channels and the transaction originates * @dev from an untrusted channel. * @dev Throws when the payment method is not an allowed payment method. * @dev Throws when trading is paused for the collection. * @dev Throws when any protocol is ORDER_PROTOCOLS_ERC721_FILL_OR_KILL and the amount is not 1. * @dev Throws when any protocol is ORDER_PROTOCOLS_ERC1155_FILL_OR_KILL and the amount is 0. * @dev Throws when any protocol is not ORDER_PROTOCOLS_ERC721_FILL_OR_KILL or ORDER_PROTOCOLS_ERC1155_FILL_OR_KILL. * @dev Throws when the sum of the marketplace fee and the max royalty fee exceeds the fee denominator. * @dev Throws when the sale price is not within the allowed price range. * @dev Throws when the order has expired. * @dev Throws when the fee on top is greater than the sum of the listing prices. * @dev Throws when the payment method is not an allowed payment method. * @dev Throws when a cosignature is required and the cosignature is invalid. * @dev Throws when the maker signature is invalid. * @dev Throws when the maker's order nonce has already been used or was cancelled. * @dev Throws when a partially fillable order has already been filled, cancelled or * @dev cannot be filled with the minimum fillable amount. * * @param tradeContext The execution context of the trade. * @param startingNativeFunds The starting native funds. * @param advancedSweep Order details including the permit context, signatures and sweep details. */ function _executeSweepOrderAdvanced( TradeContext memory tradeContext, uint256 startingNativeFunds, AdvancedSweep calldata advancedSweep ) internal returns (uint256 endingNativeFunds) { if (advancedSweep.sweepOrder.protocol == ORDER_PROTOCOLS_ERC1155_FILL_PARTIAL) { revert PaymentProcessor__OrderProtocolERC1155FillPartialUnsupportedInSweeps(); } if (advancedSweep.items.length == 0) { revert PaymentProcessor__InputArrayLengthCannotBeZero(); } SweepExecutionParams memory params = _validateSweepOrderHeader(tradeContext, advancedSweep.sweepOrder); endingNativeFunds = _validateAndFulfillSweepOrderAdvanced( startingNativeFunds, advancedSweep, tradeContext, params ); } /** * @notice Validates and fulfills a sweep order. * * @dev Throws when any protocol is ORDER_PROTOCOLS_ERC721_FILL_OR_KILL and the amount is not 1. * @dev Throws when any protocol is ORDER_PROTOCOLS_ERC1155_FILL_OR_KILL and the amount is 0. * @dev Throws when any protocol is not ORDER_PROTOCOLS_ERC721_FILL_OR_KILL or ORDER_PROTOCOLS_ERC1155_FILL_OR_KILL. * @dev Throws when the sum of the marketplace fee and the max royalty fee exceeds the fee denominator. * @dev Throws when the sale price is not within the allowed price range. * @dev Throws when the order has expired. * @dev Throws when the fee on top is greater than the sum of the listing prices. * @dev Throws when the payment method is not an allowed payment method. * @dev Throws when a cosignature is required and the cosignature is invalid. * @dev Throws when the maker signature is invalid. * @dev Throws when the maker's order nonce has already been used or was cancelled. * @dev Throws when a partially fillable order has already been filled, cancelled or * @dev cannot be filled with the minimum fillable amount. * * @param startingNativeFunds The starting native funds. * @param advancedSweep Order details including the permit context, signatures and sweep details. * @param context The current exectuion context. * @param params The sweep execution parameters. */ function _validateAndFulfillSweepOrderAdvanced( uint256 startingNativeFunds, AdvancedSweep calldata advancedSweep, TradeContext memory context, SweepExecutionParams memory params ) internal returns (uint256 endingNativeFunds) { endingNativeFunds = startingNativeFunds; uint256 sumListingPrices; uint256 dispensedPaymentValue; SweepOrder calldata sweepOrder = advancedSweep.sweepOrder; AdvancedSweepItem[] calldata items = advancedSweep.items; for(uint256 itemIndex;itemIndex < items.length;) { AdvancedSweepItem calldata advancedSweepItem = items[itemIndex]; SweepItem calldata sweepItem = advancedSweepItem.sweepItem; AdvancedOrder memory advancedOrder; advancedOrder.permitContext = advancedSweepItem.permitContext; advancedOrder.signature = advancedSweepItem.signature; advancedOrder.cosignature = advancedSweepItem.cosignature; advancedOrder.saleDetails = Order({ protocol: sweepOrder.protocol, maker: sweepItem.maker, beneficiary: sweepOrder.beneficiary, marketplace: sweepItem.marketplace, fallbackRoyaltyRecipient: sweepItem.fallbackRoyaltyRecipient, paymentMethod: sweepOrder.paymentMethod, tokenAddress: sweepOrder.tokenAddress, tokenId: sweepItem.tokenId, amount: sweepItem.amount, itemPrice: uint240(sweepItem.itemPrice), nonce: sweepItem.nonce, expiration: sweepItem.expiration, marketplaceFeeNumerator: sweepItem.marketplaceFeeNumerator, maxRoyaltyFeeNumerator: sweepItem.maxRoyaltyFeeNumerator, requestedFillAmount: sweepItem.amount, minimumFillAmount: sweepItem.amount, protocolFeeVersion: sweepItem.protocolFeeVersion }); Order memory saleDetails = advancedOrder.saleDetails; if (context.protocolFeeVersion != saleDetails.protocolFeeVersion) { context.protocolFeeVersion = saleDetails.protocolFeeVersion; context.protocolFees = appStorage().protocolFeeVersions[saleDetails.protocolFeeVersion]; } sumListingPrices += saleDetails.itemPrice; if (saleDetails.protocol == ORDER_PROTOCOLS_ERC721_FILL_OR_KILL) { if (saleDetails.amount != ONE) { revert PaymentProcessor__AmountForERC721SalesMustEqualOne(); } } else if (saleDetails.protocol == ORDER_PROTOCOLS_ERC1155_FILL_OR_KILL) { if (saleDetails.amount == 0) { revert PaymentProcessor__AmountForERC1155SalesGreaterThanZero(); } } else { revert PaymentProcessor__InvalidOrderProtocol(); } if (saleDetails.marketplaceFeeNumerator + saleDetails.maxRoyaltyFeeNumerator > FEE_DENOMINATOR) { revert PaymentProcessor__MarketplaceAndRoyaltyFeesWillExceedSalePrice(); } if (params.paymentSettings == PaymentSettings.PricingConstraints || params.paymentSettings == PaymentSettings.PricingConstraintsCollectionOnly) { _validateSalePriceInRange( params.paymentSettings, saleDetails.tokenAddress, saleDetails.tokenId, saleDetails.amount, saleDetails.itemPrice); } if (block.timestamp > saleDetails.expiration) { revert PaymentProcessor__OrderHasExpired(); } if (block.timestamp > context.protocolFees.versionExpiration) { revert PaymentProcessor__ProtocolFeeVersionExpired(); } if (context.protocolFees.minimumProtocolFeeBps > FEE_DENOMINATOR) { revert PaymentProcessor__ProtocolFeeOrTaxExceedsCap(); } if (advancedOrder.permitContext.permitProcessor == address(0)) { if (advancedSweepItem.bulkOrderProof.proof.length == 0) { _verifySaleApproval( context, saleDetails, advancedOrder.signature, advancedOrder.cosignature ); } else { _verifyBulkSaleApprovalProofAndSignedTree( context, saleDetails, advancedOrder.signature, advancedOrder.cosignature, advancedSweepItem.bulkOrderProof ); } } (endingNativeFunds, dispensedPaymentValue) = _dispenseAndPayoutSweepItemAdvanced( advancedOrder, context, params, endingNativeFunds, dispensedPaymentValue ); unchecked { ++itemIndex; } } if (advancedSweep.feeOnTop.amount > sumListingPrices) { revert PaymentProcessor__FeeOnTopCannotBeGreaterThanItemPrice(); } endingNativeFunds = _finalizePaymentAccumulatorDisbursement( context, params, advancedSweep.feeOnTop, dispensedPaymentValue, sumListingPrices, endingNativeFunds ); } /** * @notice Disburses the accumulated proceeds to the respective recipients. * * @dev Throws when the provided permit processor is not trusted. * @dev Throws when the order has run out of native funds. */ function _dispenseAndPayoutSweepItemAdvanced( AdvancedOrder memory advancedOrder, TradeContext memory context, SweepExecutionParams memory params, uint256 startingNativeFunds, uint256 startingDispensedPaymentValue ) internal returns( uint256 endingNativeFunds, uint256 endingDispensedPaymentValue ) { endingNativeFunds = startingNativeFunds; endingDispensedPaymentValue = startingDispensedPaymentValue; Order memory saleDetails = advancedOrder.saleDetails; bool failedToDispense; if (advancedOrder.permitContext.permitProcessor == address(0)) { failedToDispense = !params.fnPointers.funcDispenseToken( saleDetails.maker, saleDetails.beneficiary, saleDetails.tokenAddress, saleDetails.tokenId, saleDetails.amount); if(failedToDispense) { if (saleDetails.protocol != ORDER_PROTOCOLS_ERC1155_FILL_PARTIAL) { _restoreNonce(saleDetails.maker, saleDetails.nonce); } } } else { if (!_isTrustedPermitProcessor(advancedOrder.permitContext.permitProcessor)) { revert PaymentProcessor__PermitProcessorNotTrusted(); } uint256 quantityToFill; (quantityToFill, failedToDispense) = _verifyPermittedSaleApprovalAndDispense(true, saleDetails.maker, advancedOrder, context); _adjustForUnitPricing(quantityToFill, saleDetails); } if (!failedToDispense) { SplitProceeds memory proceeds = _computePaymentSplits( context, saleDetails.itemPrice, saleDetails.tokenAddress, saleDetails.tokenId, saleDetails.marketplace, saleDetails.marketplaceFeeNumerator, saleDetails.maxRoyaltyFeeNumerator, saleDetails.fallbackRoyaltyRecipient ); unchecked { endingDispensedPaymentValue += saleDetails.itemPrice; } if (saleDetails.paymentMethod == address(0)) { if (endingNativeFunds < saleDetails.itemPrice) { revert PaymentProcessor__RanOutOfNativeFunds(); } unchecked { endingNativeFunds -= saleDetails.itemPrice; } } if (proceeds.royaltyRecipient != params.accumulator.lastRoyaltyRecipient) { if(params.accumulator.accumulatedRoyaltyProceeds > 0) { params.fnPointers.funcPayout(params.accumulator.lastRoyaltyRecipient, context.taker, params.paymentCoin, params.accumulator.accumulatedRoyaltyProceeds); } params.accumulator.lastRoyaltyRecipient = proceeds.royaltyRecipient; params.accumulator.accumulatedRoyaltyProceeds = 0; } if (saleDetails.marketplace != params.accumulator.lastMarketplace) { if(params.accumulator.accumulatedMarketplaceProceeds > 0) { params.fnPointers.funcPayout(params.accumulator.lastMarketplace, context.taker, params.paymentCoin, params.accumulator.accumulatedMarketplaceProceeds); } params.accumulator.lastMarketplace = saleDetails.marketplace; params.accumulator.accumulatedMarketplaceProceeds = 0; } if (saleDetails.maker != params.accumulator.lastSeller) { if(params.accumulator.accumulatedSellerProceeds > 0) { params.fnPointers.funcPayout(params.accumulator.lastSeller, context.taker, params.paymentCoin, params.accumulator.accumulatedSellerProceeds); } params.accumulator.lastSeller = saleDetails.maker; params.accumulator.accumulatedSellerProceeds = 0; } if (context.protocolFees.protocolFeeReceiver != params.accumulator.lastProtocolFeeRecipient) { if (params.accumulator.accumulatedInfrastructureProceeds > 0) { params.fnPointers.funcPayout(params.accumulator.lastProtocolFeeRecipient, context.taker, params.paymentCoin, params.accumulator.accumulatedInfrastructureProceeds); } params.accumulator.lastProtocolFeeRecipient = context.protocolFees.protocolFeeReceiver; params.accumulator.accumulatedInfrastructureProceeds = 0; } unchecked { params.accumulator.accumulatedRoyaltyProceeds += proceeds.royaltyProceeds; params.accumulator.accumulatedMarketplaceProceeds += proceeds.marketplaceProceeds; params.accumulator.accumulatedSellerProceeds += proceeds.sellerProceeds; params.accumulator.accumulatedInfrastructureProceeds += proceeds.infrastructureProceeds; } params.fnPointers.funcEmitOrderExecutionEvent(context, saleDetails); } } /** * @notice Verifies the proof and signature of an order that was generated by a signed merkle tree root. * * @dev Throws when the maker's signature is invalid. * @dev Throws when the order status is not open. * @dev Throws when the nonce has already been invalidated. * @dev Throws when a cosignature is required and the cosignature is invalid. * @dev Throws when the order type is ORDER_PROTOCOLS_ERC1155_FILL_PARTIAL and the remaining fillable * @dev amount is less than the minimum fillable amount requested. * * @param context The execution context of the trade. * @param saleDetails The details of the sale. * @param signature The maker's signature authorizing the order execution. * @param cosignature The additional cosignature for a cosigned order, if applicable. * @param bulkOrderProof The bulk order proof and order index. * @param orderHash The digest generated from the order details. * @param _getBulkOrderTypehashByTreeHeight The function to get the bulk order typehash by tree height. */ function _verifyBulkOrderSignatures( TradeContext memory context, Order memory saleDetails, SignatureECDSA memory signature, Cosignature memory cosignature, BulkOrderProof calldata bulkOrderProof, bytes32 orderHash, function(uint256) internal pure returns(bytes32) _getBulkOrderTypehashByTreeHeight ) internal returns (uint256 quantityToFill) { uint256 orderIndex = bulkOrderProof.orderIndex; bytes32 bulkOrderRootHash = orderHash; bytes32[] calldata proof = bulkOrderProof.proof; for (uint256 i; i < proof.length;) { if (orderIndex & 1 == 0) { bulkOrderRootHash = EfficientHash.efficientHash(bulkOrderRootHash, proof[i]); } else { bulkOrderRootHash = EfficientHash.efficientHash(proof[i], bulkOrderRootHash); } orderIndex >>= 1; unchecked { ++i; } } if (cosignature.signer != address(0)) { _verifyCosignature(context, signature, cosignature); } _verifyMakerSignature( saleDetails.maker, signature, _hashTypedDataV4( _cachedDomainSeparator, EfficientHash.efficientHash( _getBulkOrderTypehashByTreeHeight(bulkOrderProof.proof.length), bulkOrderRootHash ) ) ); if (saleDetails.protocol == ORDER_PROTOCOLS_ERC1155_FILL_PARTIAL) { quantityToFill = _checkAndUpdateRemainingFillableItems( saleDetails.maker, orderHash, saleDetails.amount, saleDetails.requestedFillAmount, saleDetails.minimumFillAmount); context.orderDigest = orderHash; } else { quantityToFill = saleDetails.amount; } } /** * @notice Generate the order digest and verify the bulk order proof and signatures for an item. * * @dev Throws when the maker's signature is invalid. * @dev Throws when the order status is not open. * @dev Throws when the nonce has already been invalidated. * @dev Throws when a cosignature is required and the cosignature is invalid. * @dev Throws when the order type is ORDER_PROTOCOLS_ERC1155_FILL_PARTIAL and the remaining fillable * @dev amount is less than the minimum fillable amount requested. * * @param tradeContext The execution context of the trade. * @param saleDetails The details of the sale. * @param signature The maker's signature authorizing the order execution. * @param cosignature The additional cosignature for a cosigned order, if applicable. * @param bulkOrderProof The bulk order proof and order index. */ function _verifyBulkItemOfferApprovalProofAndSignedTree( TradeContext memory tradeContext, Order memory saleDetails, SignatureECDSA memory signature, Cosignature memory cosignature, BulkOrderProof calldata bulkOrderProof ) internal returns (uint256 quantityToFill) { bytes32 orderHash = _generateItemOfferOrderHash( saleDetails, saleDetails.maker, cosignature.signer, _checkAndInvalidateNonceForFillOrKillOrders(saleDetails) ); quantityToFill = _verifyBulkOrderSignatures( tradeContext, saleDetails, signature, cosignature, bulkOrderProof, orderHash, _getBulkItemOfferApprovalTypehash ); } /** * @notice Generate the order digest and verify the bulk order proof and signatures for a collection. * * @dev Throws when the maker's signature is invalid. * @dev Throws when the order status is not open. * @dev Throws when the nonce has already been invalidated. * @dev Throws when a cosignature is required and the cosignature is invalid. * @dev Throws when the order type is ORDER_PROTOCOLS_ERC1155_FILL_PARTIAL and the remaining fillable * @dev amount is less than the minimum fillable amount requested. * * @param tradeContext The execution context of the trade. * @param saleDetails The details of the sale. * @param signature The maker's signature authorizing the order execution. * @param cosignature The additional cosignature for a cosigned order, if applicable. * @param bulkOrderProof The bulk order proof and order index. */ function _verifyBulkCollectionOfferApprovalProofAndSignedTree( TradeContext memory tradeContext, Order memory saleDetails, SignatureECDSA memory signature, Cosignature memory cosignature, BulkOrderProof calldata bulkOrderProof ) internal returns (uint256 quantityToFill) { bytes32 orderHash = _generateCollectionOfferOrderHash( saleDetails, saleDetails.maker, cosignature.signer, _checkAndInvalidateNonceForFillOrKillOrders(saleDetails) ); quantityToFill = _verifyBulkOrderSignatures( tradeContext, saleDetails, signature, cosignature, bulkOrderProof, orderHash, _getBulkCollectionOfferApprovalTypehash ); } /** * @notice Generate the order digest and verify the bulk order proof and signatures for a token set order. * * @dev Throws when the maker's signature is invalid. * @dev Throws when the order status is not open. * @dev Throws when the nonce has already been invalidated. * @dev Throws when a cosignature is required and the cosignature is invalid. * @dev Throws when the order type is ORDER_PROTOCOLS_ERC1155_FILL_PARTIAL and the remaining fillable * @dev amount is less than the minimum fillable amount requested. * * @param tradeContext The execution context of the trade. * @param saleDetails The details of the sale. * @param signature The maker's signature authorizing the order execution. * @param tokenSetProof The merkle proofs for an offer that is a subset of tokens in a collection. * @param cosignature The additional cosignature for a cosigned order, if applicable. * @param bulkOrderProof The bulk order proof and order index. */ function _verifyBulkTokenSetOfferApprovalProofAndSignedTree( TradeContext memory tradeContext, Order memory saleDetails, SignatureECDSA memory signature, TokenSetProof calldata tokenSetProof, Cosignature memory cosignature, BulkOrderProof calldata bulkOrderProof ) internal returns (uint256 quantityToFill) { bytes32 orderHash = _generateTokenSetOfferOrderHash( tokenSetProof, saleDetails, saleDetails.maker, cosignature.signer, _checkAndInvalidateNonceForFillOrKillOrders(saleDetails) ); quantityToFill = _verifyBulkOrderSignatures( tradeContext, saleDetails, signature, cosignature, bulkOrderProof, orderHash, _getBulkTokenSetOfferApprovalTypehash ); } /** * @notice Generate the order digest and verify the bulk order proof and signatures for a sale approval. * * @dev Throws when the maker's signature is invalid. * @dev Throws when the order status is not open. * @dev Throws when the nonce has already been invalidated. * @dev Throws when a cosignature is required and the cosignature is invalid. * @dev Throws when the order type is ORDER_PROTOCOLS_ERC1155_FILL_PARTIAL and the remaining fillable * @dev amount is less than the minimum fillable amount requested. * * @param tradeContext The execution context of the trade. * @param saleDetails The details of the sale. * @param signature The maker's signature authorizing the order execution. * @param cosignature The additional cosignature for a cosigned order, if applicable. * @param bulkOrderProof The bulk order proof and order index. */ function _verifyBulkSaleApprovalProofAndSignedTree( TradeContext memory tradeContext, Order memory saleDetails, SignatureECDSA memory signature, Cosignature memory cosignature, BulkOrderProof calldata bulkOrderProof ) internal returns (uint256 quantityToFill) { bytes32 orderHash = _generateListingOrderHash( saleDetails, saleDetails.maker, cosignature.signer, _checkAndInvalidateNonceForFillOrKillOrders(saleDetails) ); quantityToFill = _verifyBulkOrderSignatures( tradeContext, saleDetails, signature, cosignature, bulkOrderProof, orderHash, _getBulkSaleApprovalTypehash ); } /** * @notice Helper function which returns the bulk sale approval typehash for a provided height. * * @param height The height of the typehash. */ function _getBulkSaleApprovalTypehash(uint256 height) internal pure returns(bytes32 hash) { if(height > 10 || height == 0) { revert PaymentProcessor__InvalidBulkOrderHeight(); } bytes memory memTypehashes = BULK_SALE_APPROVAL_TYPEHASHES_LOOKUP; assembly { hash := mload(add(memTypehashes, shl(5, height))) } } /** * @notice Helper function which returns the bulk collection offer approval typehash for a provided height. * * @param height The height of the typehash. */ function _getBulkCollectionOfferApprovalTypehash(uint256 height) internal pure returns(bytes32 hash) { if(height > 10 || height == 0) { revert PaymentProcessor__InvalidBulkOrderHeight(); } bytes memory memTypehashes = BULK_COLLECTION_OFFER_APPROVAL_TYPEHASHES_LOOKUP; assembly { hash := mload(add(memTypehashes, shl(5, height))) } } /** * @notice Helper function which returns the bulk item offer approval typehash for a provided height. * * @param height The height of the typehash. */ function _getBulkItemOfferApprovalTypehash(uint256 height) internal pure returns(bytes32 hash) { if(height > 10 || height == 0) { revert PaymentProcessor__InvalidBulkOrderHeight(); } bytes memory memTypehashes = BULK_ITEM_OFFER_APPROVAL_TYPEHASHES_LOOKUP; assembly { hash := mload(add(memTypehashes, shl(5, height))) } } /** * @notice Helper function which returns the bulk token set offer approval typehash for a provided height. * * @param height The height of the typehash. */ function _getBulkTokenSetOfferApprovalTypehash(uint256 height) internal pure returns(bytes32 hash) { if(height > 10 || height == 0) { revert PaymentProcessor__InvalidBulkOrderHeight(); } bytes memory memTypehashes = BULK_TOKEN_SET_OFFER_APPROVAL_TYPEHASHES_LOOKUP; assembly { hash := mload(add(memTypehashes, shl(5, height))) } } }
//SPDX-License-Identifier: LicenseRef-PolyForm-Strict-1.0.0 pragma solidity 0.8.24; import "./PaymentProcessorModule.sol"; import { IPermitC } from "@limitbreak/permit-c/interfaces/IPermitC.sol"; /* @@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@( @@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@ #@@@@@@@@@@@@@@ @@@@@@@@@@@@ @@@@@@@@@@@@@@* @@@@@@@@@@@@ @@@@@@@@@@@@@@@ @ @@@@@@@@@@@@ @@@@@@@@@@@@@@@ @ @@@@@@@@@@@ @@@@@@@@@@@@@@@ @@ @@@@@@@@@@@@ @@@@@@@@@@@@@@@ #@@ @@@@@@@@@@@@/ @@@@@@@@@@@@@@. @@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@ @@@@@&%%%%%%%%&&@@@@@@@@@@@@@@ @@@@@@@@@@@@@@ @@@@@ @@@@@@@@@@@ @@@@@@@@@@@@@@@ @@@@@ @@@@@@@@@@@ @@@@@@@@@@@@@@@ @@@@@@ @@@@@@@@@@@ @@@@@@@@@@@@@@@ @@@@@@@ @@@@@@@@@@@ @@@@@@@@@@@@@@@ @@@@@@@ @@@@@@@@@@@& @@@@@@@@@@@@@@ *@@@@@@@ (@@@@@@@@@@@@ @@@@@@@@@@@@@@@ @@@@@@@@ @@@@@@@@@@@@@@ @@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ .@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@% @@@@@@@@@@@@@@@@@@@@@@@@( @@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@& @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ * @title PaymentProcessorModulePermits * @custom:version 3.0.0 * @author Limit Break, Inc. */ abstract contract PaymentProcessorModulePermits is PaymentProcessorModule { using EnumerableSet for EnumerableSet.AddressSet; address private immutable permitProcessor1; address private immutable permitProcessor2; constructor(address configurationContract) PaymentProcessorModule(configurationContract) { (,,,TrustedPermitProcessors memory trustedPermitProcessors,, ) = IPaymentProcessorConfiguration(configurationContract).getPaymentProcessorModuleDeploymentParams(); permitProcessor1 = trustedPermitProcessors.permitProcessor1; permitProcessor2 = trustedPermitProcessors.permitProcessor2; } /*************************************************************************/ /* Default Permit Processors */ /*************************************************************************/ /** * @notice Returns true if `permitProcessor` is a trusted permit processor. * * @dev This function will also return true if the permit processor was added after contract deployment. */ function _isTrustedPermitProcessor(address permitProcessor) internal returns (bool) { if (permitProcessor == permitProcessor1 || permitProcessor == permitProcessor2) { return true; } if (appStorage().trustedPermitProcessors.contains(permitProcessor)) { return true; } return IPaymentProcessorSettings(address(this)).checkTrustedPermitProcessors(permitProcessor); } /** * @notice Returns an array of the default payment methods defined at contract deployment. * * @dev This array will **NOT** include default payment methods added after contract deployment. */ function _getTrustedPermitProcessors() internal view returns (address[] memory trustedPermitProcessors) { trustedPermitProcessors = new address[](2); trustedPermitProcessors[0] = permitProcessor1; trustedPermitProcessors[1] = permitProcessor2; } /*************************************************************************/ /* Order Fulfillment */ /*************************************************************************/ /** * @notice Validates and fulfills a single permitted order. * * @dev Throws if the order is buy side, requires a cosignature, and the cosignature is invalid. * @dev Throws if the permit nonce is invalid. * @dev Throws if the permit signature is invalid. * * @param startingNativeFunds The starting native funds. * @param side The side of the order. * @param matchedOrder The order to fulfill. * @param tradeContext The execution context of the trade. * @param feeOnTop The additional fee to add on top of the order, paid by taker. */ function _validateAndFulfillSinglePermittedOrder( uint256 startingNativeFunds, Sides side, AdvancedOrder memory matchedOrder, TradeContext memory tradeContext, FeeOnTop calldata feeOnTop ) internal returns (uint256 endingNativeFunds) { endingNativeFunds = startingNativeFunds; Order memory saleDetails = matchedOrder.saleDetails; address purchaser = tradeContext.taker; address seller = matchedOrder.saleDetails.maker; bool isBuySide = side == Sides.Buy; if (!isBuySide) { purchaser = matchedOrder.saleDetails.maker; seller = tradeContext.taker; } (uint256 quantityToFill, bool failedToDispense) = _verifyPermittedSaleApprovalAndDispense(isBuySide, seller, matchedOrder, tradeContext); _adjustForUnitPricing(quantityToFill, saleDetails); _validateBasicOrderDetails(tradeContext, saleDetails); if (failedToDispense) { if (tradeContext.disablePartialFill) { revert PaymentProcessor__DispensingTokenWasUnsuccessful(); } } else { SplitProceeds memory proceeds = _computePaymentSplits( tradeContext, saleDetails.itemPrice, saleDetails.tokenAddress, saleDetails.tokenId, saleDetails.marketplace, saleDetails.marketplaceFeeNumerator, saleDetails.maxRoyaltyFeeNumerator, saleDetails.fallbackRoyaltyRecipient ); uint256 feeOnTopAmount; if (feeOnTop.recipient != address(0)) { feeOnTopAmount = feeOnTop.amount; if (feeOnTopAmount > saleDetails.itemPrice) { revert PaymentProcessor__FeeOnTopCannotBeGreaterThanItemPrice(); } } if (saleDetails.paymentMethod == address(0)) { unchecked { uint256 nativeProceedsToSpend = saleDetails.itemPrice + feeOnTopAmount; if (endingNativeFunds < nativeProceedsToSpend) { revert PaymentProcessor__RanOutOfNativeFunds(); } endingNativeFunds -= nativeProceedsToSpend; } } FulfillOrderFunctionPointers memory fnPointers = _getOrderFulfillmentFunctionPointers(side, saleDetails.paymentMethod, saleDetails.protocol); if (feeOnTopAmount > 0) { unchecked { uint256 feeOnTopAmountInfrastructure = feeOnTopAmount * tradeContext.protocolFees.feeOnTopProtocolTaxBps / FEE_DENOMINATOR; fnPointers.funcPayout(feeOnTop.recipient, tradeContext.taker, saleDetails.paymentMethod, feeOnTopAmount - feeOnTopAmountInfrastructure); if (purchaser == tradeContext.taker) { proceeds.infrastructureProceeds += feeOnTopAmountInfrastructure; } else { if (feeOnTopAmountInfrastructure > 0) { fnPointers.funcPayout(tradeContext.protocolFees.protocolFeeReceiver, tradeContext.taker, saleDetails.paymentMethod, feeOnTopAmountInfrastructure); } } } } if (proceeds.infrastructureProceeds > 0) { fnPointers.funcPayout(tradeContext.protocolFees.protocolFeeReceiver, purchaser, saleDetails.paymentMethod, proceeds.infrastructureProceeds); } if (proceeds.royaltyProceeds > 0) { fnPointers.funcPayout(proceeds.royaltyRecipient, purchaser, saleDetails.paymentMethod, proceeds.royaltyProceeds); } if (proceeds.marketplaceProceeds > 0) { fnPointers.funcPayout(saleDetails.marketplace, purchaser, saleDetails.paymentMethod, proceeds.marketplaceProceeds); } if (proceeds.sellerProceeds > 0) { fnPointers.funcPayout(seller, purchaser, saleDetails.paymentMethod, proceeds.sellerProceeds); } fnPointers.funcEmitOrderExecutionEvent(tradeContext, saleDetails); } } /*************************************************************************/ /* Signature Verification */ /*************************************************************************/ /** * @notice Performs initial verification of a permit signature and processes it via the permit processor. * * @dev Throws if the order is buy side, requires a cosignature, and the cosignature is invalid. * @dev Throws if the permit nonce is invalid. * @dev Throws if the permit signature is invalid. * * @param isBuySide True if the order is buy side, false otherwise. * @param seller The seller of the order. * @param matchedOrder The order to verify. * @param tradeContext The trade context. */ function _verifyPermittedSaleApprovalAndDispense( bool isBuySide, address seller, AdvancedOrder memory matchedOrder, TradeContext memory tradeContext ) internal returns (uint256 quantityToFill, bool isError) { Order memory saleDetails = matchedOrder.saleDetails; bytes32 orderDigest = _generateListingOrderHash( matchedOrder.saleDetails, seller, isBuySide ? matchedOrder.cosignature.signer : address(0), appStorage().masterNonces[seller] ); if (isBuySide) { if (matchedOrder.cosignature.signer != address(0)) { _verifyCosignature( tradeContext, matchedOrder.signature, matchedOrder.cosignature); } } if (saleDetails.protocol == ORDER_PROTOCOLS_ERC1155_FILL_PARTIAL) { if (isBuySide) { (quantityToFill, isError) = _fillPermittedOrderERC1155(seller, orderDigest, matchedOrder); } else { isError = _permitTransferFromWithAdditionalDataERC1155(seller, orderDigest, matchedOrder); quantityToFill = saleDetails.amount; } } else { quantityToFill = saleDetails.amount; if (saleDetails.protocol == ORDER_PROTOCOLS_ERC721_FILL_OR_KILL) { isError = _permitTransferFromWithAdditionalDataERC721(seller, orderDigest, matchedOrder); } else { isError = _permitTransferFromWithAdditionalDataERC1155(seller, orderDigest, matchedOrder); } } } /** * @notice Processes a permit signature for an ERC1155 order. * * @dev Throws if the permit nonce is invalid. * @dev Throws if the permit signature is invalid. * @dev Throws if the amount remaining is less than the minimum fill amount. * @dev Throws if the quantity to fill exceeds uint248 max. * * @param seller The seller of the order. * @param orderDigest The order digest. * @param matchedOrder The order to verify. */ function _fillPermittedOrderERC1155( address seller, bytes32 orderDigest, AdvancedOrder memory matchedOrder ) internal returns (uint256 quantityToFill, bool isError) { Order memory saleDetails = matchedOrder.saleDetails; ( quantityToFill, isError ) = IPermitC(matchedOrder.permitContext.permitProcessor).fillPermittedOrderERC1155( _repackSignature(matchedOrder.signature), OrderFillAmounts({ orderStartAmount: saleDetails.amount, requestedFillAmount: saleDetails.requestedFillAmount, minimumFillAmount: saleDetails.minimumFillAmount }), saleDetails.tokenAddress, saleDetails.tokenId, seller, saleDetails.beneficiary, matchedOrder.permitContext.permitNonce, uint48(saleDetails.expiration), orderDigest, PERMITTED_ORDER_SALE_APPROVAL ); if(quantityToFill > type(uint248).max) { revert PaymentProcessor__AmountExceedsMaximum(); } } /** * @notice Processes a permit signature with additional data for an ERC1155 order. * * @dev Throws if the permit nonce is invalid. * @dev Throws if the permit signature is invalid. * * @param seller The seller of the order. * @param orderDigest The order digest. * @param matchedOrder The order to verify. */ function _permitTransferFromWithAdditionalDataERC1155( address seller, bytes32 orderDigest, AdvancedOrder memory matchedOrder ) internal returns (bool isError) { Order memory saleDetails = matchedOrder.saleDetails; isError = IPermitC(matchedOrder.permitContext.permitProcessor).permitTransferFromWithAdditionalDataERC1155( saleDetails.tokenAddress, saleDetails.tokenId, matchedOrder.permitContext.permitNonce, saleDetails.amount, saleDetails.expiration, seller, saleDetails.beneficiary, saleDetails.amount, orderDigest, PERMITTED_TRANSFER_SALE_APPROVAL, _repackSignature(matchedOrder.signature) ); if (!isError) { emit PermittedOrderNonceInvalidated( matchedOrder.permitContext.permitNonce, saleDetails.nonce, seller, false ); } } /** * @notice Processes a permit signature with additional data for an ERC721 order. * * @dev Throws if the permit nonce is invalid. * @dev Throws if the permit signature is invalid. * * @param seller The seller of the order. * @param orderDigest The order digest. * @param matchedOrder The order to verify. */ function _permitTransferFromWithAdditionalDataERC721( address seller, bytes32 orderDigest, AdvancedOrder memory matchedOrder ) internal returns (bool isError) { Order memory saleDetails = matchedOrder.saleDetails; isError = IPermitC(matchedOrder.permitContext.permitProcessor).permitTransferFromWithAdditionalDataERC721( saleDetails.tokenAddress, saleDetails.tokenId, matchedOrder.permitContext.permitNonce, saleDetails.expiration, seller, saleDetails.beneficiary, orderDigest, PERMITTED_TRANSFER_SALE_APPROVAL, _repackSignature(matchedOrder.signature) ); if (!isError) { emit PermittedOrderNonceInvalidated( matchedOrder.permitContext.permitNonce, saleDetails.nonce, seller, false ); } } /** * @notice Concatenates the r, s, and v values of a signature into a single bytes array. * * @param signature The signature to repack. */ function _repackSignature(SignatureECDSA memory signature) internal pure returns (bytes memory) { if(signature.v > type(uint8).max) { revert PaymentProcessor__InvalidSignatureV(); } return abi.encodePacked(signature.r, signature.s, uint8(signature.v)); } }
//SPDX-License-Identifier: LicenseRef-PolyForm-Strict-1.0.0 pragma solidity 0.8.24; import "./IPaymentProcessorSettings.sol"; import "./SettingsDataTypes.sol"; /** * @title ICollectionSettingsRegistry * @custom:version 3.0.0 * @author Limit Break, Inc. */ interface ICollectionSettingsRegistry { /// @notice Emitted when a new payment method whitelist is created. event CreatedPaymentMethodWhitelist( uint32 indexed paymentMethodWhitelistId, address indexed whitelistOwner, string whitelistName); /// @notice Emitted when a coin is added to the approved coins mapping for a whitelist. event PaymentMethodAddedToWhitelist( uint32 indexed paymentMethodWhitelistId, address indexed paymentMethod); /// @notice Emitted when a coin is removed from the approved coins mapping for a whitelist. event PaymentMethodRemovedFromWhitelist( uint32 indexed paymentMethodWhitelistId, address indexed paymentMethod); /// @notice Emitted when a permit processor is added to the trusted permit processor list. event TrustedPermitProcessorAdded(address indexed permitProcessor); /// @notice Emitted when a permit processor is removed from the trusted permit processor list. event TrustedPermitProcessorRemoved(address indexed permitProcessor); /// @notice Emitted when payment settings are updated for a collection. event UpdatedCollectionPaymentSettings( address indexed tokenAddress, CollectionPaymentSettingsParams params ); /// @notice Emitted whenever pricing bounds change at a token level for price-constrained collections. event UpdatedTokenLevelPricingBoundaries( address indexed tokenAddress, uint256 indexed tokenId, uint256 floorPrice, uint256 ceilingPrice); /// @notice Emitted when a trusted channel is removed for a collection. event TrustedChannelRemovedForCollection( address indexed tokenAddress, address indexed channel); /// @notice Emitted when a trusted channel is added for a collection. event TrustedChannelAddedForCollection( address indexed tokenAddress, address indexed channel); /// @notice Emitted when a payment method whitelist is reassigned to a new owner. event ReassignedPaymentMethodWhitelistOwnership(uint32 indexed id, address indexed newOwner); function isCollectionSettingsInitialized(address tokenAddress) external view returns (bool); function getCollectionSettings( address tokenAddress, bytes32[] calldata dataExtensions, bytes32[] calldata wordExtensions ) external view returns ( CollectionRegistryPaymentSettings memory collectionCoreSettings, RegistryPricingBounds memory collectionPricingBounds, address constrainedPricingPaymentMethod, address exclusiveBountyReceiver, bytes[] memory data, bytes32[] memory words ); function getCollectionSettingsExtendedData( address tokenAddress, bytes32[] calldata extensions ) external view returns (bytes[] memory data); function getCollectionSettingsExtendedWords( address tokenAddress, bytes32[] calldata extensions ) external view returns (bytes32[] memory words); function isWhitelistedPaymentMethod( uint32 whitelistId, address paymentMethod ) external view returns (bool paymentMethodWhitelisted); function isTrustedChannelForCollection( address tokenAddress, address channel ) external view returns (bool channelIsTrusted); function isTrustedPermitProcessor( address permitProcessor ) external view returns (bool isTrusted); function getTokenBoundPricing( address tokenAddress, uint256 tokenId ) external view returns (RegistryPricingBounds memory); }
//SPDX-License-Identifier: LicenseRef-PolyForm-Strict-1.0.0 pragma solidity 0.8.24; import "./SettingsDataTypes.sol"; /** * @title IPaymentProcessorSettings * @custom:version 3.0.0 * @author Limit Break, Inc. */ interface IPaymentProcessorSettings { function registrySyncSettings(address tokenAddress) external; function registryUpdateWhitelistPaymentMethods( uint32 paymentMethodWhitelistId, address[] calldata paymentMethods, bool paymentMethodsAdded ) external; function registryUpdateTrustedChannels( address tokenAddress, address[] calldata channelsToUpdate, bool channelsAdded ) external; function registryUpdateTokenPricingBounds( address tokenAddress, uint256[] calldata tokenIds, RegistryPricingBounds[] calldata pricingBounds ) external; function registryUpdateTrustedPermitProcessors( address[] calldata permitProcessors, bool permitProcessorsAdded ) external; function checkSyncCollectionSettings( address tokenAddress ) external; function checkSyncTokenPricingBounds( address tokenAddress, uint256 tokenId ) external returns (uint256, uint256); function checkWhitelistedPaymentMethod( uint32 whitelistId, address paymentMethod ) external returns (bool isWhitelisted); function checkCollectionTrustedChannels( address tokenAddress, address channel ) external returns (bool isAllowed); function checkTrustedPermitProcessors( address permitProcessor ) external returns (bool isTrusted); }
//SPDX-License-Identifier: LicenseRef-PolyForm-Strict-1.0.0 pragma solidity 0.8.24; /** * @dev This struct defines the payment settings for a collection. * * @dev **initialized**: True if the payment settings have been initialized, false otherwise. * @dev **paymentSettingsType**: The type of payment settings for the collection. * @dev **paymentMethodWhitelistId**: The ID of the payment method whitelist to use for the collection. * @dev **royaltyBackfillReceiver**: The address to use as the royalty backfill receiver. * @dev **royaltyBackfillNumerator**: The numerator to use for the royalty backfill. * @dev **royaltyBountyNumerator**: The numerator to use for the royalty bounty. * @dev **extraData**: Extra data for the payment settings. */ struct CollectionRegistryPaymentSettings { bool initialized; uint8 paymentSettingsType; uint32 paymentMethodWhitelistId; address royaltyBackfillReceiver; uint16 royaltyBackfillNumerator; uint16 royaltyBountyNumerator; uint16 extraData; } /** * @dev This struct defines the parameters for collection payment settings. * * @dev **paymentSettings**: The payment settings for the collection. * @dev **paymentMethodWhitelistId**: The ID of the payment method whitelist to use for the collection. * @dev **constrainedPricingPaymentMethod**: The payment method to use for constrained pricing. * @dev **royaltyBackfillNumerator**: The numerator to use for the royalty backfill. * @dev **royaltyBackfillReceiver**: The address to use as the royalty backfill receiver. * @dev **royaltyBountyNumerator**: The numerator to use for the royalty bounty. * @dev **exclusiveBountyReceiver**: The address to use as the exclusive bounty receiver. * @dev **extraData**: Extra data for the payment settings. * @dev **collectionMinimumFloorPrice**: The minimum floor price for the collection. * @dev **collectionMaximumCeilingPrice**: The maximum ceiling price for the collection. * @dev **flags**: The flags for the payment settings. */ struct CollectionPaymentSettingsParams { uint8 paymentSettings; uint32 paymentMethodWhitelistId; address constrainedPricingPaymentMethod; uint16 royaltyBackfillNumerator; address royaltyBackfillReceiver; uint16 royaltyBountyNumerator; address exclusiveBountyReceiver; uint16 extraData; uint120 collectionMinimumFloorPrice; uint120 collectionMaximumCeilingPrice; } /** * @dev This struct defines the pricing bounds for a registry. * * @dev **isSet**: True if the pricing bounds are set, false otherwise. * @dev **floorPrice**: The floor price for the registry. * @dev **ceilingPrice**: The ceiling price for the registry. */ struct RegistryPricingBounds { bool isSet; uint120 floorPrice; uint120 ceilingPrice; }
//SPDX-License-Identifier: LicenseRef-PolyForm-Strict-1.0.0 pragma solidity 0.8.24; import "../DataTypes.sol"; /** * @title PaymentProcessorStorageAccess * @custom:version 3.0.0 * @author Limit Break, Inc. */ contract PaymentProcessorStorageAccess { /// @dev The base storage slot for Payment Processor contract storage items. bytes32 constant DIAMOND_STORAGE_PAYMENT_PROCESSOR = 0x0000000000000000000000000000000000000000000000000000000000009A1D; /** * @dev Returns a storage object that follows the Diamond standard storage pattern for * @dev contract storage across multiple module contracts. */ function appStorage() internal pure returns (PaymentProcessorStorage storage diamondStorage) { bytes32 slot = DIAMOND_STORAGE_PAYMENT_PROCESSOR; assembly { diamondStorage.slot := slot } } }
{ "remappings": [ "ds-test/=lib/forge-std/lib/ds-test/src/", "forge-std/=lib/forge-std/src/", "@openzeppelin/=lib/openzeppelin-contracts/", "@rari-capital/solmate/=lib/solmate/", "murky/=lib/murky/src/", "@limitbreak/trusted-forwarder/=lib/TrustedForwarder/src/", "@limitbreak/permit-c/=lib/PermitC/src/", "@limitbreak/tm-core-lib/=lib/tm-core-lib/", "@limitbreak/wrapped-native/=lib/wrapped-native/src/", "@limitbreak/tm-role-server/=lib/tm-role-server/src/", "PermitC/=lib/PermitC/", "TrustedForwarder/=lib/TrustedForwarder/", "erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/", "forge-gas-metering/=lib/PermitC/lib/forge-gas-metering/", "openzeppelin-contracts/=lib/openzeppelin-contracts/", "openzeppelin/=lib/openzeppelin-contracts/contracts/", "solady/=lib/PermitC/lib/forge-gas-metering/lib/solady/", "solmate/=lib/solmate/src/", "tm-core-lib/=lib/tm-core-lib/src/", "tm-role-server/=lib/tm-role-server/src/", "wrapped-native/=lib/wrapped-native/" ], "optimizer": { "enabled": true, "runs": 40000 }, "metadata": { "useLiteralContent": false, "bytecodeHash": "ipfs", "appendCBOR": true }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "abi" ] } }, "evmVersion": "cancun", "viaIR": false, "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[{"internalType":"address","name":"configurationContract","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"PaymentProcessor__AmountExceedsMaximum","type":"error"},{"inputs":[],"name":"PaymentProcessor__AmountForERC1155SalesGreaterThanZero","type":"error"},{"inputs":[],"name":"PaymentProcessor__AmountForERC721SalesMustEqualOne","type":"error"},{"inputs":[],"name":"PaymentProcessor__BadCalldataLength","type":"error"},{"inputs":[],"name":"PaymentProcessor__CosignatureHasExpired","type":"error"},{"inputs":[],"name":"PaymentProcessor__CosignerHasSelfDestructed","type":"error"},{"inputs":[],"name":"PaymentProcessor__DispensingTokenWasUnsuccessful","type":"error"},{"inputs":[],"name":"PaymentProcessor__EIP1271SignatureInvalid","type":"error"},{"inputs":[],"name":"PaymentProcessor__FailedToTransferProceeds","type":"error"},{"inputs":[],"name":"PaymentProcessor__FeeOnTopCannotBeGreaterThanItemPrice","type":"error"},{"inputs":[],"name":"PaymentProcessor__InputArrayLengthCannotBeZero","type":"error"},{"inputs":[],"name":"PaymentProcessor__InputArrayLengthMismatch","type":"error"},{"inputs":[],"name":"PaymentProcessor__InvalidBulkOrderHeight","type":"error"},{"inputs":[],"name":"PaymentProcessor__InvalidConstructorArguments","type":"error"},{"inputs":[],"name":"PaymentProcessor__InvalidOrderProtocol","type":"error"},{"inputs":[],"name":"PaymentProcessor__InvalidSignatureV","type":"error"},{"inputs":[],"name":"PaymentProcessor__MarketplaceAndRoyaltyFeesWillExceedSalePrice","type":"error"},{"inputs":[],"name":"PaymentProcessor__NotAuthorizedByCosigner","type":"error"},{"inputs":[],"name":"PaymentProcessor__OnchainRoyaltiesExceedMaximumApprovedRoyaltyFee","type":"error"},{"inputs":[],"name":"PaymentProcessor__OrderHasExpired","type":"error"},{"inputs":[],"name":"PaymentProcessor__OrderIsEitherCancelledOrFilled","type":"error"},{"inputs":[],"name":"PaymentProcessor__PartialFillsNotSupportedForNonDivisibleItems","type":"error"},{"inputs":[],"name":"PaymentProcessor__PaymentCoinIsNotAnApprovedPaymentMethod","type":"error"},{"inputs":[],"name":"PaymentProcessor__PermitProcessorNotTrusted","type":"error"},{"inputs":[],"name":"PaymentProcessor__PermitsAreNotCompatibleWithBulkOrders","type":"error"},{"inputs":[],"name":"PaymentProcessor__ProtocolFeeOrTaxExceedsCap","type":"error"},{"inputs":[],"name":"PaymentProcessor__ProtocolFeeVersionExpired","type":"error"},{"inputs":[],"name":"PaymentProcessor__RanOutOfNativeFunds","type":"error"},{"inputs":[],"name":"PaymentProcessor__SalePriceAboveMaximumCeiling","type":"error"},{"inputs":[],"name":"PaymentProcessor__SalePriceBelowMinimumFloor","type":"error"},{"inputs":[],"name":"PaymentProcessor__SignatureAlreadyUsedOrRevoked","type":"error"},{"inputs":[],"name":"PaymentProcessor__SignatureNotUsedOrRevoked","type":"error"},{"inputs":[],"name":"PaymentProcessor__TradeOriginatedFromUntrustedChannel","type":"error"},{"inputs":[],"name":"PaymentProcessor__TradingIsPausedForCollection","type":"error"},{"inputs":[],"name":"PaymentProcessor__UnableToFillMinimumRequestedQuantity","type":"error"},{"inputs":[],"name":"PaymentProcessor__UnauthorizedOrder","type":"error"},{"inputs":[],"name":"PaymentProcessor__UnauthorizedTaker","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"seller","type":"address"},{"indexed":true,"internalType":"address","name":"buyer","type":"address"},{"indexed":true,"internalType":"address","name":"tokenAddress","type":"address"},{"indexed":false,"internalType":"address","name":"beneficiary","type":"address"},{"indexed":false,"internalType":"address","name":"paymentCoin","type":"address"},{"indexed":false,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"salePrice","type":"uint256"}],"name":"AcceptOfferERC1155","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"seller","type":"address"},{"indexed":true,"internalType":"address","name":"buyer","type":"address"},{"indexed":true,"internalType":"address","name":"tokenAddress","type":"address"},{"indexed":false,"internalType":"address","name":"beneficiary","type":"address"},{"indexed":false,"internalType":"address","name":"paymentCoin","type":"address"},{"indexed":false,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"salePrice","type":"uint256"}],"name":"AcceptOfferERC721","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"buyer","type":"address"},{"indexed":true,"internalType":"address","name":"seller","type":"address"},{"indexed":true,"internalType":"address","name":"tokenAddress","type":"address"},{"indexed":false,"internalType":"address","name":"beneficiary","type":"address"},{"indexed":false,"internalType":"address","name":"paymentCoin","type":"address"},{"indexed":false,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"salePrice","type":"uint256"}],"name":"BuyListingERC1155","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"buyer","type":"address"},{"indexed":true,"internalType":"address","name":"seller","type":"address"},{"indexed":true,"internalType":"address","name":"tokenAddress","type":"address"},{"indexed":false,"internalType":"address","name":"beneficiary","type":"address"},{"indexed":false,"internalType":"address","name":"paymentCoin","type":"address"},{"indexed":false,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"salePrice","type":"uint256"}],"name":"BuyListingERC721","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"cosigner","type":"address"}],"name":"DestroyedCosigner","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"uint256","name":"nonce","type":"uint256"}],"name":"MasterNonceInvalidated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"nonce","type":"uint256"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"bool","name":"wasCancellation","type":"bool"}],"name":"NonceInvalidated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"nonce","type":"uint256"},{"indexed":true,"internalType":"address","name":"account","type":"address"}],"name":"NonceRestored","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"orderDigest","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"bool","name":"wasCancellation","type":"bool"}],"name":"OrderDigestInvalidated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"orderDigest","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"uint256","name":"amountFilled","type":"uint256"}],"name":"OrderDigestItemsFilled","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"orderDigest","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"uint256","name":"amountRestoredToOrder","type":"uint256"}],"name":"OrderDigestItemsRestored","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"orderDigest","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"uint256","name":"orderStartAmount","type":"uint256"}],"name":"OrderDigestOpened","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint32","name":"paymentMethodWhitelistId","type":"uint32"},{"indexed":true,"internalType":"address","name":"paymentMethod","type":"address"}],"name":"PaymentMethodAddedToWhitelist","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint32","name":"paymentMethodWhitelistId","type":"uint32"},{"indexed":true,"internalType":"address","name":"paymentMethod","type":"address"}],"name":"PaymentMethodRemovedFromWhitelist","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"permitNonce","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"orderNonce","type":"uint256"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"bool","name":"wasCancellation","type":"bool"}],"name":"PermittedOrderNonceInvalidated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"newProtocolFeeRecipient","type":"address"},{"indexed":false,"internalType":"uint16","name":"minimumProtocolFeeBps","type":"uint16"},{"indexed":false,"internalType":"uint16","name":"marketplaceFeeProtocolTaxBps","type":"uint16"},{"indexed":false,"internalType":"uint16","name":"feeOnTopProtocolTaxBps","type":"uint16"},{"indexed":false,"internalType":"uint48","name":"gracePeriodExpiration","type":"uint48"}],"name":"ProtocolFeesUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"tokenAddress","type":"address"},{"indexed":true,"internalType":"address","name":"channel","type":"address"}],"name":"TrustedChannelAddedForCollection","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"tokenAddress","type":"address"},{"indexed":true,"internalType":"address","name":"channel","type":"address"}],"name":"TrustedChannelRemovedForCollection","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"permitProcessor","type":"address"}],"name":"TrustedPermitProcessorAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"permitProcessor","type":"address"}],"name":"TrustedPermitProcessorRemoved","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"tokenAddress","type":"address"},{"indexed":false,"internalType":"uint256","name":"floorPrice","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"ceilingPrice","type":"uint256"}],"name":"UpdatedCollectionLevelPricingBoundaries","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"tokenAddress","type":"address"},{"indexed":false,"internalType":"enum PaymentSettings","name":"paymentSettings","type":"uint8"},{"indexed":true,"internalType":"uint32","name":"paymentMethodWhitelistId","type":"uint32"},{"indexed":true,"internalType":"address","name":"constrainedPricingPaymentMethod","type":"address"},{"indexed":false,"internalType":"uint16","name":"royaltyBackfillNumerator","type":"uint16"},{"indexed":false,"internalType":"address","name":"royaltyBackfillReceiver","type":"address"},{"indexed":false,"internalType":"uint16","name":"royaltyBountyNumerator","type":"uint16"},{"indexed":false,"internalType":"address","name":"exclusiveBountyReceiver","type":"address"},{"indexed":false,"internalType":"bool","name":"blockTradesFromUntrustedChannels","type":"bool"},{"indexed":false,"internalType":"bool","name":"useRoyaltyBackfillAsRoyaltySource","type":"bool"}],"name":"UpdatedCollectionPaymentSettings","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"tokenAddress","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"floorPrice","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"ceilingPrice","type":"uint256"}],"name":"UpdatedTokenLevelPricingBoundaries","type":"event"},{"inputs":[{"components":[{"internalType":"uint256","name":"protocol","type":"uint256"},{"internalType":"address","name":"maker","type":"address"},{"internalType":"address","name":"beneficiary","type":"address"},{"internalType":"address","name":"marketplace","type":"address"},{"internalType":"address","name":"fallbackRoyaltyRecipient","type":"address"},{"internalType":"address","name":"paymentMethod","type":"address"},{"internalType":"address","name":"tokenAddress","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"itemPrice","type":"uint256"},{"internalType":"uint256","name":"nonce","type":"uint256"},{"internalType":"uint256","name":"expiration","type":"uint256"},{"internalType":"uint256","name":"marketplaceFeeNumerator","type":"uint256"},{"internalType":"uint256","name":"maxRoyaltyFeeNumerator","type":"uint256"},{"internalType":"uint256","name":"requestedFillAmount","type":"uint256"},{"internalType":"uint256","name":"minimumFillAmount","type":"uint256"},{"internalType":"uint256","name":"protocolFeeVersion","type":"uint256"}],"internalType":"struct Order[]","name":"saleDetailsArray","type":"tuple[]"},{"components":[{"internalType":"uint256","name":"v","type":"uint256"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"internalType":"struct SignatureECDSA[]","name":"sellerSignatures","type":"tuple[]"},{"components":[{"internalType":"address","name":"signer","type":"address"},{"internalType":"address","name":"taker","type":"address"},{"internalType":"uint256","name":"expiration","type":"uint256"},{"internalType":"uint256","name":"v","type":"uint256"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"internalType":"struct Cosignature[]","name":"cosignatures","type":"tuple[]"},{"components":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"internalType":"struct FeeOnTop[]","name":"feesOnTop","type":"tuple[]"}],"name":"bulkBuyListings","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"components":[{"components":[{"internalType":"uint256","name":"protocol","type":"uint256"},{"internalType":"address","name":"maker","type":"address"},{"internalType":"address","name":"beneficiary","type":"address"},{"internalType":"address","name":"marketplace","type":"address"},{"internalType":"address","name":"fallbackRoyaltyRecipient","type":"address"},{"internalType":"address","name":"paymentMethod","type":"address"},{"internalType":"address","name":"tokenAddress","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"itemPrice","type":"uint256"},{"internalType":"uint256","name":"nonce","type":"uint256"},{"internalType":"uint256","name":"expiration","type":"uint256"},{"internalType":"uint256","name":"marketplaceFeeNumerator","type":"uint256"},{"internalType":"uint256","name":"maxRoyaltyFeeNumerator","type":"uint256"},{"internalType":"uint256","name":"requestedFillAmount","type":"uint256"},{"internalType":"uint256","name":"minimumFillAmount","type":"uint256"},{"internalType":"uint256","name":"protocolFeeVersion","type":"uint256"}],"internalType":"struct Order","name":"saleDetails","type":"tuple"},{"components":[{"internalType":"uint256","name":"v","type":"uint256"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"internalType":"struct SignatureECDSA","name":"signature","type":"tuple"},{"components":[{"internalType":"address","name":"signer","type":"address"},{"internalType":"address","name":"taker","type":"address"},{"internalType":"uint256","name":"expiration","type":"uint256"},{"internalType":"uint256","name":"v","type":"uint256"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"internalType":"struct Cosignature","name":"cosignature","type":"tuple"},{"components":[{"internalType":"address","name":"permitProcessor","type":"address"},{"internalType":"uint256","name":"permitNonce","type":"uint256"}],"internalType":"struct PermitContext","name":"permitContext","type":"tuple"}],"internalType":"struct AdvancedOrder[]","name":"advancedListingsArray","type":"tuple[]"},{"components":[{"internalType":"uint256","name":"orderIndex","type":"uint256"},{"internalType":"bytes32[]","name":"proof","type":"bytes32[]"}],"internalType":"struct BulkOrderProof[]","name":"bulkOrderProofs","type":"tuple[]"},{"components":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"internalType":"struct FeeOnTop[]","name":"feesOnTop","type":"tuple[]"}],"name":"bulkBuyListingsAdvanced","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"protocol","type":"uint256"},{"internalType":"address","name":"maker","type":"address"},{"internalType":"address","name":"beneficiary","type":"address"},{"internalType":"address","name":"marketplace","type":"address"},{"internalType":"address","name":"fallbackRoyaltyRecipient","type":"address"},{"internalType":"address","name":"paymentMethod","type":"address"},{"internalType":"address","name":"tokenAddress","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"itemPrice","type":"uint256"},{"internalType":"uint256","name":"nonce","type":"uint256"},{"internalType":"uint256","name":"expiration","type":"uint256"},{"internalType":"uint256","name":"marketplaceFeeNumerator","type":"uint256"},{"internalType":"uint256","name":"maxRoyaltyFeeNumerator","type":"uint256"},{"internalType":"uint256","name":"requestedFillAmount","type":"uint256"},{"internalType":"uint256","name":"minimumFillAmount","type":"uint256"},{"internalType":"uint256","name":"protocolFeeVersion","type":"uint256"}],"internalType":"struct Order","name":"saleDetails","type":"tuple"},{"components":[{"internalType":"uint256","name":"v","type":"uint256"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"internalType":"struct SignatureECDSA","name":"sellerSignature","type":"tuple"},{"components":[{"internalType":"address","name":"signer","type":"address"},{"internalType":"address","name":"taker","type":"address"},{"internalType":"uint256","name":"expiration","type":"uint256"},{"internalType":"uint256","name":"v","type":"uint256"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"internalType":"struct Cosignature","name":"cosignature","type":"tuple"},{"components":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"internalType":"struct FeeOnTop","name":"feeOnTop","type":"tuple"}],"name":"buyListing","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"components":[{"components":[{"internalType":"uint256","name":"protocol","type":"uint256"},{"internalType":"address","name":"maker","type":"address"},{"internalType":"address","name":"beneficiary","type":"address"},{"internalType":"address","name":"marketplace","type":"address"},{"internalType":"address","name":"fallbackRoyaltyRecipient","type":"address"},{"internalType":"address","name":"paymentMethod","type":"address"},{"internalType":"address","name":"tokenAddress","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"itemPrice","type":"uint256"},{"internalType":"uint256","name":"nonce","type":"uint256"},{"internalType":"uint256","name":"expiration","type":"uint256"},{"internalType":"uint256","name":"marketplaceFeeNumerator","type":"uint256"},{"internalType":"uint256","name":"maxRoyaltyFeeNumerator","type":"uint256"},{"internalType":"uint256","name":"requestedFillAmount","type":"uint256"},{"internalType":"uint256","name":"minimumFillAmount","type":"uint256"},{"internalType":"uint256","name":"protocolFeeVersion","type":"uint256"}],"internalType":"struct Order","name":"saleDetails","type":"tuple"},{"components":[{"internalType":"uint256","name":"v","type":"uint256"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"internalType":"struct SignatureECDSA","name":"signature","type":"tuple"},{"components":[{"internalType":"address","name":"signer","type":"address"},{"internalType":"address","name":"taker","type":"address"},{"internalType":"uint256","name":"expiration","type":"uint256"},{"internalType":"uint256","name":"v","type":"uint256"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"internalType":"struct Cosignature","name":"cosignature","type":"tuple"},{"components":[{"internalType":"address","name":"permitProcessor","type":"address"},{"internalType":"uint256","name":"permitNonce","type":"uint256"}],"internalType":"struct PermitContext","name":"permitContext","type":"tuple"}],"internalType":"struct AdvancedOrder","name":"advancedListing","type":"tuple"},{"components":[{"internalType":"uint256","name":"orderIndex","type":"uint256"},{"internalType":"bytes32[]","name":"proof","type":"bytes32[]"}],"internalType":"struct BulkOrderProof","name":"bulkOrderProof","type":"tuple"},{"components":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"internalType":"struct FeeOnTop","name":"feeOnTop","type":"tuple"}],"name":"buyListingAdvanced","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"forwarder","type":"address"}],"name":"isTrustedForwarder","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"}]
Contract Creation Code
6101e060405234801562000011575f80fd5b5060405162005a7c38038062005a7c83398101604081905262000034916200035f565b808080806001600160a01b031663ed7e776c6040518163ffffffff1660e01b8152600401602060405180830381865afa15801562000074573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906200009a91906200035f565b806001600160a01b03166080816001600160a01b031681525050505f805f805f856001600160a01b0316638e71e7196040518163ffffffff1660e01b815260040161014060405180830381865afa158015620000f8573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906200011e9190620003ef565b95509550509450945094505f6001600160a01b0316846001600160a01b031614806200015157506001600160a01b038216155b15620001705760405163049b2c3f60e31b815260040160405180910390fd5b6001600160a01b0380851660a0528351811660c052602080850151821660e05260408086015183166101005260608601518316610120529184166101405281518083018352601081526f2830bcb6b2b73a283937b1b2b9b9b7b960811b908201528151808301835260058152640332e302e360dc1b90820152905162000287917f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f917fdab569368da3525b394950b18252b2a008851cf1162b59295579c87c37790526917fd7a1ce683065975771bedf401ecab037f4f4c62cc51fefdc8b39dd246ff0343a9146918b91019485526020850193909352604084019190915260608301526001600160a01b0316608082015260a00190565b60408051601f198184030181528282528051602090910120610160526001600160a01b0392831661018052638e71e71960e01b8252515f97509188169550638e71e7199450600480820194506101409350908290030181865afa158015620002f1573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190620003179190620003ef565b505080516001600160a01b039081166101a052602090910151166101c05250620004f395505050505050565b80516001600160a01b03811681146200035a575f80fd5b919050565b5f6020828403121562000370575f80fd5b6200037b8262000343565b9392505050565b5f6040828403121562000393575f80fd5b604080519081016001600160401b0381118282101715620003c257634e487b7160e01b5f52604160045260245ffd5b604052905080620003d38362000343565b8152620003e36020840162000343565b60208201525092915050565b5f805f805f8086880361014081121562000407575f80fd5b620004128862000343565b9650620004226020890162000343565b95506080603f198201121562000436575f80fd5b50604051608081016001600160401b03811182821017156200046657634e487b7160e01b5f52604160045260245ffd5b8060405250620004796040890162000343565b8152620004896060890162000343565b60208201526200049c6080890162000343565b6040820152620004af60a0890162000343565b60608201529350620004c58860c0890162000382565b9250620004d6610100880162000343565b9150620004e7610120880162000343565b90509295509295509295565b60805160a05160c05160e05161010051610120516101405161016051610180516101a0516101c0516155006200057c5f395f61130601525f6112b101525f50505f81816118f401528181612b7f0152613bd601525f50505f6132c901525f61326e01525f61321301525f6131b801525f61315d01525f81816102c2015261109b01526155005ff3fe608060405260043610610058575f3560e01c8063679d280311610041578063679d2803146100a457806369bdcb08146100b75780637497030d146100ca575f80fd5b806327c46dc41461005c578063572b6c0514610071575b5f80fd5b61006f61006a366004614a7a565b6100dd565b005b34801561007c575f80fd5b5061009061008b366004614ad3565b61027b565b604051901515815260200160405180910390f35b61006f6100b2366004614bdf565b610333565b61006f6100c5366004614d08565b6104e6565b61006f6100d8366004614e30565b610a1c565b6040805161016081019091523381527ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc7c3601905f906020810161011f84610e86565b73ffffffffffffffffffffffffffffffffffffffff168152600160208201525f60408201819052606082018190526080820181905260a0820181905260c0820181905260e082015261020088015161010082015261012001619a1d6102008901515f908152600e9190910160209081526040808320815160a081018352905473ffffffffffffffffffffffffffffffffffffffff8116825261ffff740100000000000000000000000000000000000000008204811694830194909452760100000000000000000000000000000000000000000000810484169282019290925278010000000000000000000000000000000000000000000000008204909216606083015265ffffffffffff7a010000000000000000000000000000000000000000000000000000909104166080820152909152909150610262823489898989610ed4565b9050610272818360200151610f27565b50505050505050565b6040517f572b6c0500000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff82811660048301525f917f00000000000000000000000000000000000000000000000000000000000000009091169063572b6c0590602401602060405180830381865afa158015610309573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061032d9190614efe565b92915050565b5f6103416020840184614f17565b604080516101608101909152338152602091820236037ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffbbc0193505f925090810161038a84610e86565b73ffffffffffffffffffffffffffffffffffffffff168152600160208201525f60408201819052606082018190526080820181905260a0820181905260c0820181905260e08201528651610200015161010082015261012001619a1d875161020001515f908152600e9190910160209081526040808320815160a081018352905473ffffffffffffffffffffffffffffffffffffffff8116825261ffff740100000000000000000000000000000000000000008204811694830194909452760100000000000000000000000000000000000000000000810484169282019290925278010000000000000000000000000000000000000000000000008204909216606083015265ffffffffffff7a0100000000000000000000000000000000000000000000000000009091041660808201529091529091506104ce8234888888610f3b565b90506104de818360200151610f27565b505050505050565b86851461051f576040517fb62503e300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b868314610558576040517fb62503e300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b868114610591576040517fb62503e300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f8790036105cb576040517fdb560cb500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b604080516101608101909152338152610380880236037ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffefc01905f906020810161061384610e86565b73ffffffffffffffffffffffffffffffffffffffff1681525f6020820181905260408201819052606082018190526080820181905260a0820181905260c0820181905260e08201819052610100909101908c908c908161067557610675614f7b565b905061022002016102000135815260200161068f619a1d90565b600e015f8d8d5f8181106106a5576106a5614f7b565b6102209081029290920161020090810135845260208085019590955260409384015f908120855160a08082018852915473ffffffffffffffffffffffffffffffffffffffff8116825274010000000000000000000000000000000000000000810461ffff908116838b015276010000000000000000000000000000000000000000000082048116838a015278010000000000000000000000000000000000000000000000008204166060808401919091527a01000000000000000000000000000000000000000000000000000090910465ffffffffffff16608080840191909152919099528651958601875282865285880183905285870183905285890183905285810183905285820183905260c080870184905260e08701849052610100870184905261012087018490526101408701849052610160870184905261018087018490526101a087018490526101c087018490526101e087018490529386018390528651808a01885283815280890184905280880184905287519485018852838552978401839052958301829052968201819052938101849052948501839052509394503493929036905b8e8110156109fc578f8f8281811061086a5761086a614f7b565b905061022002018036038101906108819190614fa8565b94508d8d8281811061089557610895614f7b565b9050606002018036038101906108ab9190614fc3565b93508b8b828181106108bf576108bf614f7b565b905060c002018036038101906108d59190614fdd565b92508989828181106108e9576108e9614f7b565b9050604002019150846102000151876101200151146109e45761020085018051610120890152515f908152619a2b6020908152604091829020825160a081018452905473ffffffffffffffffffffffffffffffffffffffff8116825274010000000000000000000000000000000000000000810461ffff9081169383019390935276010000000000000000000000000000000000000000000081048316938201939093527801000000000000000000000000000000000000000000000000830490911660608201527a01000000000000000000000000000000000000000000000000000090910465ffffffffffff1660808201526101408801525b6109f2878787878787610ed4565b9550600101610850565b50610a0b858760200151610f27565b505050505050505050505050505050565b5f859003610a56576040517fdb560cb500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b848114610a8f576040517fb62503e300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b848314610ac8576040517fb62503e300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b34610440860236037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff3c015f5b87811015610b3e57868682818110610b0e57610b0e614f7b565b9050602002810190610b209190614ff7565b610b2e906020810190614f17565b6020029092039150600101610af4565b505f6040518061016001604052803373ffffffffffffffffffffffffffffffffffffffff168152602001610b7184610e86565b73ffffffffffffffffffffffffffffffffffffffff1681525f6020820181905260408201819052606082018190526080820181905260a0820181905260c0820181905260e08201819052610100909101908b908b9081610bd357610bd3614f7b565b905061038002015f0161020001358152602001610bef619a1d90565b600e015f8c8c5f818110610c0557610c05614f7b565b6103800291909101610200013582525060208082019290925260409081015f20815160a081018352905473ffffffffffffffffffffffffffffffffffffffff8116825274010000000000000000000000000000000000000000810461ffff9081169483019490945276010000000000000000000000000000000000000000000081048416928201929092527801000000000000000000000000000000000000000000000000820490921660608301527a010000000000000000000000000000000000000000000000000000900465ffffffffffff16608082015290529050610ceb6145eb565b5f5b89811015610e6b578a8a82818110610d0757610d07614f7b565b90506103800201803603810190610d1e9190615033565b8051610200015161012085015191935014610e1a57815161020090810151610120850152825101515f908152619a2b6020908152604091829020825160a081018452905473ffffffffffffffffffffffffffffffffffffffff8116825274010000000000000000000000000000000000000000810461ffff9081169383019390935276010000000000000000000000000000000000000000000081048316938201939093527801000000000000000000000000000000000000000000000000830490911660608201527a01000000000000000000000000000000000000000000000000000090910465ffffffffffff1660808201526101408401525b610e618386848c8c86818110610e3257610e32614f7b565b9050602002810190610e449190614ff7565b8b8b87818110610e5657610e56614f7b565b905060400201610f3b565b9450600101610ced565b50610e7a848360200151610f27565b50505050505050505050565b338115610ecf5781601414610ec7576040517f06dbb06700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61032d61106b565b919050565b610120840180517dffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1690525f80610f0b88878787611156565b9050610f1b5f8989848a8861117e565b98975050505050505050565b8115610f3757610f37818361120e565b5050565b6060830151515f9073ffffffffffffffffffffffffffffffffffffffff16610f9f57610f6a6020840184614f17565b90505f03610f9257610f8b8686865f01518760200151886040015187610ed4565b9050611062565b610f8b8686868686611255565b610fac6020840184614f17565b90505f0361103057606084015151610fc3906112ae565b610ff9576040517f14db8bdb00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b83516101200180517dffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff169052610f8b855f8689866113e3565b6040517f0a57e20b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b95945050505050565b6040517f572b6c050000000000000000000000000000000000000000000000000000000081523360048201525f907f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff169063572b6c0590602401602060405180830381865afa1580156110f5573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906111199190614efe565b15611151576014361061115157507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec36013560601c90565b503390565b5f61106285858585611179898a60200151895f01516111748d611736565b611788565b6118c4565b5f6111898484611993565b6111938684611a1a565b61120385875f8a60018111156111ab576111ab61504e565b146111ba5785602001516111c0565b88602001515b5f8b60018111156111d3576111d361504e565b146111e25789602001516111e8565b86602001515b60a088015188516111fc908e908390611fbf565b89896120b0565b979650505050505050565b5f805f805f85875af1905080611250576040517f6c998d3e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b505050565b8251610120810180517dffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff169052602084015160408501515f9291839161129e918a91859190896123e9565b9050610f1b5f898984868961117e565b5f7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16148061135457507f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16145b1561136157506001919050565b61136d619a2883612414565b1561137a57506001919050565b6040517fa15c173d00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff83166004820152309063a15c173d906024016020604051808303815f875af1158015610309573d5f803e3d5ffd5b825160208084015190820151879291905f808960018111156114075761140761504e565b1490508061142157875f0151602001519250866020015191505b5f8061142f83858c8c612445565b9150915061143d8287611993565b6114478987611a1a565b801561148e57886040015115611489576040517ff40863ff00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b611727565b5f6114be8a8861012001518960c001518a60e001518b606001518c61018001518d6101a001518e60800151612561565b90505f806114cf60208c018c614ad3565b73ffffffffffffffffffffffffffffffffffffffff16146115305789602001359050876101200151811115611530576040517f1d6203f500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60a088015173ffffffffffffffffffffffffffffffffffffffff16611596576101208801518101808a1015611591576040517f70d5b32e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b909803975b5f6115a98e8a60a001518b5f0151611fbf565b9050811561166e575f6127108d61014001516060015161ffff168402816115d2576115d261507b565b0490506115fd6115e560208e018e614ad3565b60208f015160a08d015185518588039063ffffffff16565b8c6020015173ffffffffffffffffffffffffffffffffffffffff168973ffffffffffffffffffffffffffffffffffffffff1603611643576080840180518201905261166c565b801561166c5761166c8d61014001515f01518e602001518c60a0015184865f015163ffffffff16565b505b60808301511561169b5761169b8c61014001515f0151898b60a001518660800151855f015163ffffffff16565b6020830151156116c3576116c3835f0151898b60a001518660200151855f015163ffffffff16565b6040830151156116ec576116ec8960600151898b60a001518660400151855f015163ffffffff16565b6060830151156117115761171187898b60a001518660600151855f015163ffffffff16565b6117238c8a836040015163ffffffff16565b5050505b50505050505095945050505050565b80515f9060021461175a5761175582602001518361014001515f6128f6565b61032d565b619a1d60209283015173ffffffffffffffffffffffffffffffffffffffff165f908152925250604090205490565b835160608086015160808088015160a0808a015160c0808c015160408051610240810182526101008082527f36e5aab0dde52c07206863cf8fe7b4b1a25be63a3ae5286f8fe80d159c154c4f602083015260ff909b169181019190915273ffffffffffffffffffffffffffffffffffffffff8c8116998201999099528c8916968101969096529587169285019290925291851690830152831660e08201529116918101919091525f90611062906118a99060e08801516101008901516101208a01516101608b01516101808c01516101a08d01516101408e01518b88516101008082018b526020918b019182019990995260408101979097526060870195909552608086019390935260a085019190915260c084015260e083015291015290565b61020087015181516020818401810192909252810191012090565b81515f9073ffffffffffffffffffffffffffffffffffffffff16156118ee576118ee8685856129ef565b5f6119197f000000000000000000000000000000000000000000000000000000000000000084612c24565b905061192a86602001518683612c63565b85517ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0161198057611972866020015184886101000151896101c001518a6101e00151612d1c565b606088018490529150611989565b85610100015191505b5095945050505050565b8061010001518214610f37578061010001518161012001516119b591906150a8565b156119ec576040517ffe41cfc900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b81816101000151826101200151611a0391906150e8565b611a0d91906150fb565b6101208201526101000152565b8051611a6457600181610100015114611a5f576040517fdb3ca79a00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b611ade565b805160031115611aac578061010001515f03611a5f576040517f26db27f100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040517fa799542700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b806101600151421115611b1d576040517fac492cc000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b612710816101a00151826101800151611b369190615112565b1115611b6e576040517fca9d1e5400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60c081015173ffffffffffffffffffffffffffffffffffffffff165f908152619a1f60205260409020805460ff16611c215760c08201516040517fc1f8dd0c00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff9091166004820152309063c1f8dd0c906024015f604051808303815f87803b158015611c0a575f80fd5b505af1158015611c1c573d5f803e3d5ffd5b505050505b805473ffffffffffffffffffffffffffffffffffffffff660100000000000082041660a085015261ffff7a0100000000000000000000000000000000000000000000000000008204811660808601527c010000000000000000000000000000000000000000000000000000000082041660c085015260ff61010082048116917e01000000000000000000000000000000000000000000000000000000000000900416611cd381600260ff911616151590565b15611d1f57611ce98460c00151865f0151613065565b611d1f576040517f292d235200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60048116151561010086015260018116611d39575f611d67565b60c084015173ffffffffffffffffffffffffffffffffffffffff9081165f908152619a246020526040902054165b73ffffffffffffffffffffffffffffffffffffffff1660e08601525f826005811115611d9557611d9561504e565b03611de257611da78460a00151613137565b611ddd576040517fab9c00de00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b611f24565b6002826005811115611df657611df661504e565b03611e1857825460a0850151611da79162010000900463ffffffff1690613328565b6004826005811115611e2c57611e2c61504e565b1480611e4957506003826005811115611e4757611e4761504e565b145b15611ed95760a084015160c085015173ffffffffffffffffffffffffffffffffffffffff9081165f908152619a2360205260409020548116911614611eba576040517fab9c00de00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b611ddd828560c001518660e001518761010001518861012001516133b8565b6005826005811115611eed57611eed61504e565b03611f24576040517fba78259100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8461014001516080015165ffffffffffff16421115611f6f576040517f1463d5d500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6127108561014001516020015161ffff161115611fb8576040517febaa3f7900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5050505050565b611fe6604051806060016040528061477e815260200161477e815260200161477e81525090565b60408051606081019091528073ffffffffffffffffffffffffffffffffffffffff8516156120165761345a61201a565b6134a35b67ffffffffffffffff1681526020018315612037576134ad61203b565b61355f5b67ffffffffffffffff1681526020018315612078575f8660018111156120635761206361504e565b14612070576135c561209c565b6136a861209c565b5f86600181111561208b5761208b61504e565b146120985761377f61209c565b6138475b67ffffffffffffffff169052949350505050565b5f8890506120da8684604001518560c001518660e00151876101000151896020015163ffffffff16565b6121725787604001511561211a576040517ff40863ff00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b82517ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0161215f5761215a8360200151896060015185610100015161390f565b610f1b565b61215a83602001518461014001516139d4565b5f6121a2898561012001518660c001518760e0015188606001518961018001518a6101a001518b60800151612561565b90505f806121b36020860186614ad3565b73ffffffffffffffffffffffffffffffffffffffff16146122145783602001359050846101200151811115612214576040517f1d6203f500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60a085015173ffffffffffffffffffffffffffffffffffffffff1661227a57610120850151810180841015612275576040517f70d5b32e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b909203915b8015612336575f6127108b61014001516060015161ffff168302816122a1576122a161507b565b0490506122c96122b46020870187614ad3565b8c602001518a8486038b5f015163ffffffff16565b8a6020015173ffffffffffffffffffffffffffffffffffffffff168a73ffffffffffffffffffffffffffffffffffffffff160361230f5760808301805182019052612334565b8015612334576123348b61014001515f01518c602001518a848b5f015163ffffffff16565b505b60808201511561235f5761235f8a61014001515f01518a8985608001518a5f015163ffffffff16565b60208201511561238357612383825f01518a8985602001518a5f015163ffffffff16565b6040820151156123a8576123a885606001518a8985604001518a5f015163ffffffff16565b6060820151156123c9576123c9888a8985606001518a5f015163ffffffff16565b6123db8a86886040015163ffffffff16565b505098975050505050505050565b5f80612401868760200151865f01516111748a611736565b9050611203878787878786613a96613b08565b73ffffffffffffffffffffffffffffffffffffffff81165f90815260018301602052604081205415155b9392505050565b81515f9081908161248e82888a61245c575f612463565b6040890151515b73ffffffffffffffffffffffffffffffffffffffff8b165f908152619a1d6020526040902054611788565b905087156124ca5760408601515173ffffffffffffffffffffffffffffffffffffffff16156124ca576124ca85876020015188604001516129ef565b81517ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0161252757871561250d57612503878288613c98565b9094509250612556565b612518878288613e07565b92508161010001519350612556565b610100820151825190945061254857612541878288613f63565b9250612556565b612553878288613e07565b92505b505094509492505050565b6125a46040518060a001604052805f73ffffffffffffffffffffffffffffffffffffffff1681526020015f81526020015f81526020015f81526020015f81525090565b606081018890526101008901515f80826125d7576125c38a8a8d614000565b945090925090505f8190036125d757600192505b82156126ca5760a08c015173ffffffffffffffffffffffffffffffffffffffff161561268557858c6080015161ffff16111561263f576040517f1bdbc8f400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60a08c015173ffffffffffffffffffffffffffffffffffffffff16845260808c01516127109061ffff168c025b046020850181905260608501805191909103905261275a565b73ffffffffffffffffffffffffffffffffffffffff8516156126c55773ffffffffffffffffffffffffffffffffffffffff851684526127108b870261266c565b61275a565b73ffffffffffffffffffffffffffffffffffffffff82166126e857505f5b801561275a576127108b87020481111561272e576040517f1bdbc8f400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff821684526020840181905260608401805182900390525b73ffffffffffffffffffffffffffffffffffffffff881615612873576127108b8802046040850181905260608501805191909103905260c08c015161ffff161561283a5760e08c015173ffffffffffffffffffffffffffffffffffffffff1615806127f457508773ffffffffffffffffffffffffffffffffffffffff168c60e0015173ffffffffffffffffffffffffffffffffffffffff16145b1561283a575f6127108d60c0015161ffff16866020015102816128195761281961507b565b0490508015612838576020850180518290039052604085018051820190525b505b6127108c61014001516040015161ffff168560400151028161285e5761285e61507b565b04608085018190526040850180519190910390525b5f6127108d61014001516020015161ffff168d02816128945761289461507b565b04905080856080015110156128e65760808501516060860151908203908111156128d15760608601805160808801805190910190525f90526128e4565b6060860180518290039052608086018290525b505b5050505098975050505050505050565b73ffffffffffffffffffffffffffffffffffffffff83165f908152619a1e60209081526040808320600886901c845290915281208054600160ff86161b9081189182905516612971576040517f548db54000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8373ffffffffffffffffffffffffffffffffffffffff16837ff3003920635c7d35c4f314eaeeed4b4c653ccb36608a86d57df761d460eab09d846040516129bc911515815260200190565b60405180910390a350505073ffffffffffffffffffffffffffffffffffffffff165f908152619a1d602052604090205490565b8060400151421115612a2d576040517f39db6a8400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b806020015173ffffffffffffffffffffffffffffffffffffffff16836020015173ffffffffffffffffffffffffffffffffffffffff1614612a9a576040517f53b220dd00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b805173ffffffffffffffffffffffffffffffffffffffff165f908152619a27602052604090205460ff1615612afb576040517fb5095d2d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b81516020808401516040808601518582015186850151835160c080820186527f347b7818601b168f6faadc037723496e9130b057c1ffef2ec4128311e19142f2825296810197909752928601939093526060850152608084019190915273ffffffffffffffffffffffffffffffffffffffff1660a08301529020612bbd90612ba9907f000000000000000000000000000000000000000000000000000000000000000090612c24565b612c24565b826060015183608001518460a00151614077565b73ffffffffffffffffffffffffffffffffffffffff16815f015173ffffffffffffffffffffffffffffffffffffffff1614611250576040517fdb2d3d4e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040517f190100000000000000000000000000000000000000000000000000000000000081526002810183905260228101829052604290205f9061243e565b5f80612c7c83855f0151866020015187604001516140ca565b915091508073ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff16141580612cb85750815b15611fb85773ffffffffffffffffffffffffffffffffffffffff85163b15612cea57612ce585848661417f565b611fb8565b6040517f33e929a000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f7effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff841115612d76576040517f9e0e41d300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5073ffffffffffffffffffffffffffffffffffffffff85165f908152619a25602090815260408083208784529091528120805484929060ff166002811115612dc057612dc061504e565b0361303357805461010090047effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff165f03612e6f57805460ff166101007effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff87160217815560405185815273ffffffffffffffffffffffffffffffffffffffff88169087907f0363038f06c44447365467317554445fad3b007628b98200e08224f1aecb1c579060200160405180910390a35b805461010090047effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff16821115612ec957805461010090047effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1691505b82821015612f03576040517fa10cbd9500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b80547effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff61010080830482168590039091160260ff90911617815560405182815273ffffffffffffffffffffffffffffffffffffffff88169087907f0f72b72442c719b271089c5e7774fb382e47457791f8dc3b147e72c9c685df999060200160405180910390a3805461010090047effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff165f0361302e5780547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660011781556040515f815273ffffffffffffffffffffffffffffffffffffffff88169087907fc63c82396a1b7865295ff481988a98493c2c3cc29066c229b8001c6f5dd647a99060200160405180910390a35b611989565b6040517fab2ccbf500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff82165f908152619a26602052604081206130949083612414565b156130a15750600161032d565b6040517f7a3f5d8c00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8085166004830152831660248201523090637a3f5d8c906044015b6020604051808303815f875af1158015613113573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061243e9190614efe565b5f73ffffffffffffffffffffffffffffffffffffffff821661315b57506001919050565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16036131b657506001919050565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff160361321157506001919050565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff160361326c57506001919050565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16036132c757506001919050565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff160361332257506001919050565b61032d5f835b63ffffffff8281165f908152619a2060205260408120909161334d9190849061241416565b1561335a5750600161032d565b6040517feb5e068d00000000000000000000000000000000000000000000000000000000815263ffffffff8416600482015273ffffffffffffffffffffffffffffffffffffffff83166024820152309063eb5e068d906044016130f7565b5f806133c58787876141cd565b915091505f8484816133d9576133d961507b565b04905081811115613416576040517f9837ddd700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b82811015613450576040517f9318944000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5050505050505050565b613466828486846143ec565b1561349d576040517f6c998d3e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b50505050565b61349d848261120e565b6040517ff242432a00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff86811660048301528581166024830152604482018490526064820183905260a060848301525f60a48301819052919085169063f242432a9060c4015b5f604051808303815f87803b15801561353b575f80fd5b505af192505050801561354c575060015b61355757505f611062565b506001611062565b6040517f23b872dd00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff86811660048301528581166024830152604482018490525f91908516906323b872dd90606401613524565b8060c0015173ffffffffffffffffffffffffffffffffffffffff16816020015173ffffffffffffffffffffffffffffffffffffffff16836020015173ffffffffffffffffffffffffffffffffffffffff167f6f4c56c4b9a9d2479f963d802b19d17b02293ce1225461ac0cb846c482ee3c3e84604001518560a001518660e0015187610100015188610120015160405161369c95949392919073ffffffffffffffffffffffffffffffffffffffff958616815293909416602084015260408301919091526060820152608081019190915260a00190565b60405180910390a45050565b8060c0015173ffffffffffffffffffffffffffffffffffffffff16816020015173ffffffffffffffffffffffffffffffffffffffff16836020015173ffffffffffffffffffffffffffffffffffffffff167f1217006325a98bdcc6afc9c44965bb66ac7460a44dc57c2ac47622561d25c45a84604001518560a001518660e0015187610100015188610120015160405161369c95949392919073ffffffffffffffffffffffffffffffffffffffff958616815293909416602084015260408301919091526060820152608081019190915260a00190565b8060c0015173ffffffffffffffffffffffffffffffffffffffff16816020015173ffffffffffffffffffffffffffffffffffffffff16836020015173ffffffffffffffffffffffffffffffffffffffff167f8b87c0b049fe52718fe6ff466b514c5a93c405fb0de8fbd761a23483f9f9e19884604001518560a001518660e0015187610120015160405161369c949392919073ffffffffffffffffffffffffffffffffffffffff94851681529290931660208301526040820152606081019190915260800190565b8060c0015173ffffffffffffffffffffffffffffffffffffffff16816020015173ffffffffffffffffffffffffffffffffffffffff16836020015173ffffffffffffffffffffffffffffffffffffffff167fffb29e9cf48456d56b6d414855b66a7ec060ce2054dcb124a1876310e1b7355c84604001518560a001518660e0015187610120015160405161369c949392919073ffffffffffffffffffffffffffffffffffffffff94851681529290931660208301526040820152606081019190915260800190565b80156112505773ffffffffffffffffffffffffffffffffffffffff83165f818152619a256020908152604080832086845282529182902080547effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff610100918290048116870116027fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00168155915184815291929185917f02c470cc26bb0c92da643e89f3654f5866091d4ae5af326c4face0f1611d736b910160405180910390a350505050565b73ffffffffffffffffffffffffffffffffffffffff82165f908152619a1e60209081526040808320600885901c845290915290208054600160ff84161b908118918290551615613a50576040517fee8e6a3a00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60405173ffffffffffffffffffffffffffffffffffffffff83169082907f86983746fe0ad3ad6fceb2a9aa2d498430d4343ec3c8fead646124f0615f4ba6905f90a35050565b5f600a821180613aa4575081155b15613adb576040517ffde01ad000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f604051806101600160405280610140815260200161538b610140913960059390931b9092015192915050565b5f8335833683613b1b6020890189614f17565b915091505f5b81811015613b9f57846001165f03613b6557613b5e84848484818110613b4957613b49614f7b565b905060200201355f9182526020526040902090565b9350613b93565b613b90838383818110613b7a57613b7a614f7b565b90506020020135855f9182526020526040902090565b93505b600194851c9401613b21565b50885173ffffffffffffffffffffffffffffffffffffffff1615613bc857613bc88c8b8b6129ef565b613c2a8b602001518b613c257f0000000000000000000000000000000000000000000000000000000000000000612ba4613c168e8060200190613c0b9190614f17565b90508d63ffffffff16565b895f9182526020526040902090565b612c63565b8a517ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01613c8057613c728b60200151888d61010001518e6101c001518f6101e00151612d1c565b60608d018890529450613c89565b8a610100015194505b50505050979650505050505050565b5f805f835f0151905083606001515f015173ffffffffffffffffffffffffffffffffffffffff16633779e6fd613cd18660200151614463565b60405180606001604052808561010001518152602001856101c001518152602001856101e001518152508460c001518560e001518b87604001518b60600151602001518961016001518e7f06ad108efb587ddea4f632c87662b13c59dbba674c2ea7289b2fb10575a49d796040518b63ffffffff1660e01b8152600401613d619a99989796959493929190615186565b60408051808303815f875af1158015613d7c573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190613da09190615221565b90935091507effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff831115613dfe576040517f9e0e41d300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b50935093915050565b5f80825f0151905082606001515f015173ffffffffffffffffffffffffffffffffffffffff16630f59197d8260c001518360e001518660600151602001518561010001518661016001518b88604001518961010001518d7fb1cb65a3e643070d9d33047fdfd384badc7cd70b2415e548b37db5a10c708716613e8c8f60200151614463565b6040518c63ffffffff1660e01b8152600401613eb29b9a9998979695949392919061524b565b6020604051808303815f875af1158015613ece573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190613ef29190614efe565b915081613f5b578473ffffffffffffffffffffffffffffffffffffffff168161014001518460600151602001517f68db558b3492d318070ad648fde8dab15f9d5cff3058c951bf13070512b4064b5f604051613f52911515815260200190565b60405180910390a45b509392505050565b5f80825f0151905082606001515f015173ffffffffffffffffffffffffffffffffffffffff1663b3992ab18260c001518360e001518660600151602001518561016001518a87604001518b7fb1cb65a3e643070d9d33047fdfd384badc7cd70b2415e548b37db5a10c708716613fdc8d60200151614463565b6040518a63ffffffff1660e01b8152600401613eb2999897969594939291906152cb565b5f805f61405d565b5f805f60405160608101604052632a55205a815285816020015286816040015260405f6044601c8401885afa60403d1015161561404e575f519350602051925050614054565b50600190505b93509350939050565b614068848688614008565b92509250925093509350939050565b5f80614085868686866140ca565b9250905080156140c1576040517f33e929a000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b50949350505050565b5f8060ff8511156140e05750600190505f614176565b604080515f81526020810180835288905260ff871691810191909152606081018590526080810184905260019060a0016020604051602081039080840390855afa158015614130573d5f803e3d5ffd5b50506040517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0015173ffffffffffffffffffffffffffffffffffffffff81161593509150505b94509492505050565b6141978383835f015184602001518560400151614500565b611250576040517ff83b002000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f8060048560058111156141e3576141e361504e565b036143085773ffffffffffffffffffffffffffffffffffffffff84165f908152619a22602090815260408083208684529091529020805460ff166142be576040517f7a67b4a000000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff86166004820152602481018590523090637a67b4a09060440160408051808303815f875af1158015614290573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906142b4919061533b565b92509250506143e4565b8054610100900460ff161561430657546effffffffffffffffffffffffffffff62010000820481169350710100000000000000000000000000000000009091041690506143e4565b505b73ffffffffffffffffffffffffffffffffffffffff84165f908152619a2160209081526040918290208251608081018452905460ff80821615158352610100820416158015938301939093526effffffffffffffffffffffffffffff62010000820481169483019490945271010000000000000000000000000000000000900490921660608301526143bc5760408101516060909101516effffffffffffffffffffffffffffff91821693501690506143e4565b5f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff92509250505b935093915050565b5f614457565b5f604051608081016040526323b872dd81528381602001528481604001528581606001525f806064601c84015f875af1156144495760203d101561443a575050803b1561444f565b60205f803e50505f511561444f565b50600190505b949350505050565b611062828486886143f2565b805160609060ff10156144a2576040517fe19a3e7b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60208281015160408085015185518251948501939093529083015260f81b7fff000000000000000000000000000000000000000000000000000000000000001660608201526061016040516020818303038152906040529050919050565b5f60ff84111561453c576040517fe19a3e7b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6145d4565b5f6040517f1626ba7e000000000000000000000000000000000000000000000000000000008152836004820152604060248201526041604482015284606482015286608582015285608482015260c4810160405260205f60c483865afa60203d101516156119895750505f517f1626ba7e0000000000000000000000000000000000000000000000000000000014611062565b6145e1848385888a614541565b9695505050505050565b60405180608001604052806146f06040518061022001604052805f81526020015f73ffffffffffffffffffffffffffffffffffffffff1681526020015f73ffffffffffffffffffffffffffffffffffffffff1681526020015f73ffffffffffffffffffffffffffffffffffffffff1681526020015f73ffffffffffffffffffffffffffffffffffffffff1681526020015f73ffffffffffffffffffffffffffffffffffffffff1681526020015f73ffffffffffffffffffffffffffffffffffffffff1681526020015f81526020015f81526020015f81526020015f81526020015f81526020015f81526020015f81526020015f81526020015f81526020015f81525090565b8152604080516060810182525f80825260208281018290529282015291019081526040805160c0810182525f8082526020828101829052928201819052606082018190526080820181905260a0820152910190815260200161477960405180604001604052805f73ffffffffffffffffffffffffffffffffffffffff1681526020015f81525090565b905290565b61478661535d565b565b604051610220810167ffffffffffffffff811182821017156147d1577f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b60405290565b6040805190810167ffffffffffffffff811182821017156147d1577f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b803573ffffffffffffffffffffffffffffffffffffffff81168114610ecf575f80fd5b5f6102208284031215614853575f80fd5b61485b614788565b90508135815261486d6020830161481f565b602082015261487e6040830161481f565b604082015261488f6060830161481f565b60608201526148a06080830161481f565b60808201526148b160a0830161481f565b60a08201526148c260c0830161481f565b60c082015260e08281013590820152610100808301359082015261012080830135908201526101408083013590820152610160808301359082015261018080830135908201526101a080830135908201526101c080830135908201526101e080830135908201526102009182013591810191909152919050565b5f6060828403121561494c575f80fd5b6040516060810181811067ffffffffffffffff82111715614994577f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b80604052508091508235815260208301356020820152604083013560408201525092915050565b5f60c082840312156149cb575f80fd5b60405160c0810181811067ffffffffffffffff82111715614a13577f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b604052905080614a228361481f565b8152614a306020840161481f565b602082015260408301356040820152606083013560608201526080830135608082015260a083013560a08201525092915050565b5f60408284031215614a74575f80fd5b50919050565b5f805f806103808587031215614a8e575f80fd5b614a988686614842565b9350614aa886610220870161493c565b9250614ab88661028087016149bb565b9150614ac8866103408701614a64565b905092959194509250565b5f60208284031215614ae3575f80fd5b61243e8261481f565b5f818303610380811215614afe575f80fd5b6040516080810181811067ffffffffffffffff82111715614b46577f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b604052915081614b568585614842565b8152614b6685610220860161493c565b6020820152614b798561028086016149bb565b604082015260407ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffcc083011215614bad575f80fd5b614bb56147d7565b9150614bc4610340850161481f565b82526103608401356020830152816060820152505092915050565b5f805f6103e08486031215614bf2575f80fd5b614bfc8585614aec565b925061038084013567ffffffffffffffff811115614c18575f80fd5b614c2486828701614a64565b925050614c35856103a08601614a64565b90509250925092565b5f8083601f840112614c4e575f80fd5b50813567ffffffffffffffff811115614c65575f80fd5b602083019150836020606083028501011115614c7f575f80fd5b9250929050565b5f8083601f840112614c96575f80fd5b50813567ffffffffffffffff811115614cad575f80fd5b60208301915083602060c083028501011115614c7f575f80fd5b5f8083601f840112614cd7575f80fd5b50813567ffffffffffffffff811115614cee575f80fd5b6020830191508360208260061b8501011115614c7f575f80fd5b5f805f805f805f806080898b031215614d1f575f80fd5b883567ffffffffffffffff80821115614d36575f80fd5b818b0191508b601f830112614d49575f80fd5b813581811115614d57575f80fd5b8c602061022083028501011115614d6c575f80fd5b60209283019a509850908a01359080821115614d86575f80fd5b614d928c838d01614c3e565b909850965060408b0135915080821115614daa575f80fd5b614db68c838d01614c86565b909650945060608b0135915080821115614dce575f80fd5b50614ddb8b828c01614cc7565b999c989b5096995094979396929594505050565b5f8083601f840112614dff575f80fd5b50813567ffffffffffffffff811115614e16575f80fd5b6020830191508360208260051b8501011115614c7f575f80fd5b5f805f805f8060608789031215614e45575f80fd5b863567ffffffffffffffff80821115614e5c575f80fd5b818901915089601f830112614e6f575f80fd5b813581811115614e7d575f80fd5b8a602061038083028501011115614e92575f80fd5b602092830198509650908801359080821115614eac575f80fd5b614eb88a838b01614def565b90965094506040890135915080821115614ed0575f80fd5b50614edd89828a01614cc7565b979a9699509497509295939492505050565b80518015158114610ecf575f80fd5b5f60208284031215614f0e575f80fd5b61243e82614eef565b5f8083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe1843603018112614f4a575f80fd5b83018035915067ffffffffffffffff821115614f64575f80fd5b6020019150600581901b3603821315614c7f575f80fd5b7f4e487b71000000000000000000000000000000000000000000000000000000005f52603260045260245ffd5b5f6102208284031215614fb9575f80fd5b61243e8383614842565b5f60608284031215614fd3575f80fd5b61243e838361493c565b5f60c08284031215614fed575f80fd5b61243e83836149bb565b5f82357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc1833603018112615029575f80fd5b9190910192915050565b5f6103808284031215615044575f80fd5b61243e8383614aec565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52602160045260245ffd5b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601260045260245ffd5b5f826150b6576150b661507b565b500690565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b5f826150f6576150f661507b565b500490565b808202811582820484141761032d5761032d6150bb565b8082018082111561032d5761032d6150bb565b5f81518084525f5b818110156151495760208185018101518683018201520161512d565b505f6020828601015260207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f83011685010191505092915050565b5f6101808083526151998184018e615125565b9150508a51602083015260208b0151604083015260408b0151606083015273ffffffffffffffffffffffffffffffffffffffff808b1660808401528960a084015280891660c084015280881660e0840152508561010083015261520761012083018665ffffffffffff169052565b610140820193909352610160015298975050505050505050565b5f8060408385031215615232575f80fd5b8251915061524260208401614eef565b90509250929050565b5f61016073ffffffffffffffffffffffffffffffffffffffff808f1684528d60208501528c60408501528b60608501528a6080850152808a1660a085015280891660c0850152508660e08401528561010084015284610120840152806101408401526152b981840185615125565b9e9d5050505050505050505050505050565b5f61012073ffffffffffffffffffffffffffffffffffffffff808d1684528b60208501528a6040850152896060850152808916608085015280881660a0850152508560c08401528460e08401528061010084015261532b81840185615125565b9c9b505050505050505050505050565b5f806040838503121561534c575f80fd5b505080516020909101519092909150565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52605160045260245ffdfe8659f55d4c88f84030fe09241169834754ebf2e61099b616e530c6b65712c6445106f4043cda72e04ca2c760016628ea8d5667309323ba590682ea5254b4e82e71267a8f42e7ccde4ac75848a93b741df7a2f7a58e40274055f2fa51dbaa69ce6e90557aed2a349f8b6efb2b652c4025c56cfa82424c5cd0c6801cc234ebf519caf42fc49ad57705ea6be2ca9e1835c9ccddf7bc6fdea8f851917329b1d53a7f09b32b6b5ffee898d5fe18398652042cc8c46449329c5a1a79e425f4ede9bc2bc2362dea3338b88607906397acfdcc5651f19b40a038ee7c89dc4ab54c736cacf2bbc4f6d7ccfa2b8aab6505f0c8f2868c5a190c6c4cfce8c0de447804904df981f99e15003039550d3597e34e6426b1e230992a5a3727cb5e230754f18f3566012178d0a6b8f8748e48411572bdc391435539737aafc91fcba6f2c24ae156cfa264697066735822122075aac895672e0a96b09542e79949004bbdc52b6c0b74f5956c9c6973376a113064736f6c634300081800330000000000000000000000009a1d00773287950891b8a48be6f21e951eff91b3
Deployed Bytecode
0x608060405260043610610058575f3560e01c8063679d280311610041578063679d2803146100a457806369bdcb08146100b75780637497030d146100ca575f80fd5b806327c46dc41461005c578063572b6c0514610071575b5f80fd5b61006f61006a366004614a7a565b6100dd565b005b34801561007c575f80fd5b5061009061008b366004614ad3565b61027b565b604051901515815260200160405180910390f35b61006f6100b2366004614bdf565b610333565b61006f6100c5366004614d08565b6104e6565b61006f6100d8366004614e30565b610a1c565b6040805161016081019091523381527ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc7c3601905f906020810161011f84610e86565b73ffffffffffffffffffffffffffffffffffffffff168152600160208201525f60408201819052606082018190526080820181905260a0820181905260c0820181905260e082015261020088015161010082015261012001619a1d6102008901515f908152600e9190910160209081526040808320815160a081018352905473ffffffffffffffffffffffffffffffffffffffff8116825261ffff740100000000000000000000000000000000000000008204811694830194909452760100000000000000000000000000000000000000000000810484169282019290925278010000000000000000000000000000000000000000000000008204909216606083015265ffffffffffff7a010000000000000000000000000000000000000000000000000000909104166080820152909152909150610262823489898989610ed4565b9050610272818360200151610f27565b50505050505050565b6040517f572b6c0500000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff82811660048301525f917f000000000000000000000000ff0000b6c4352714cce809000d0cd30a0e0c8dce9091169063572b6c0590602401602060405180830381865afa158015610309573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061032d9190614efe565b92915050565b5f6103416020840184614f17565b604080516101608101909152338152602091820236037ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffbbc0193505f925090810161038a84610e86565b73ffffffffffffffffffffffffffffffffffffffff168152600160208201525f60408201819052606082018190526080820181905260a0820181905260c0820181905260e08201528651610200015161010082015261012001619a1d875161020001515f908152600e9190910160209081526040808320815160a081018352905473ffffffffffffffffffffffffffffffffffffffff8116825261ffff740100000000000000000000000000000000000000008204811694830194909452760100000000000000000000000000000000000000000000810484169282019290925278010000000000000000000000000000000000000000000000008204909216606083015265ffffffffffff7a0100000000000000000000000000000000000000000000000000009091041660808201529091529091506104ce8234888888610f3b565b90506104de818360200151610f27565b505050505050565b86851461051f576040517fb62503e300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b868314610558576040517fb62503e300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b868114610591576040517fb62503e300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f8790036105cb576040517fdb560cb500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b604080516101608101909152338152610380880236037ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffefc01905f906020810161061384610e86565b73ffffffffffffffffffffffffffffffffffffffff1681525f6020820181905260408201819052606082018190526080820181905260a0820181905260c0820181905260e08201819052610100909101908c908c908161067557610675614f7b565b905061022002016102000135815260200161068f619a1d90565b600e015f8d8d5f8181106106a5576106a5614f7b565b6102209081029290920161020090810135845260208085019590955260409384015f908120855160a08082018852915473ffffffffffffffffffffffffffffffffffffffff8116825274010000000000000000000000000000000000000000810461ffff908116838b015276010000000000000000000000000000000000000000000082048116838a015278010000000000000000000000000000000000000000000000008204166060808401919091527a01000000000000000000000000000000000000000000000000000090910465ffffffffffff16608080840191909152919099528651958601875282865285880183905285870183905285890183905285810183905285820183905260c080870184905260e08701849052610100870184905261012087018490526101408701849052610160870184905261018087018490526101a087018490526101c087018490526101e087018490529386018390528651808a01885283815280890184905280880184905287519485018852838552978401839052958301829052968201819052938101849052948501839052509394503493929036905b8e8110156109fc578f8f8281811061086a5761086a614f7b565b905061022002018036038101906108819190614fa8565b94508d8d8281811061089557610895614f7b565b9050606002018036038101906108ab9190614fc3565b93508b8b828181106108bf576108bf614f7b565b905060c002018036038101906108d59190614fdd565b92508989828181106108e9576108e9614f7b565b9050604002019150846102000151876101200151146109e45761020085018051610120890152515f908152619a2b6020908152604091829020825160a081018452905473ffffffffffffffffffffffffffffffffffffffff8116825274010000000000000000000000000000000000000000810461ffff9081169383019390935276010000000000000000000000000000000000000000000081048316938201939093527801000000000000000000000000000000000000000000000000830490911660608201527a01000000000000000000000000000000000000000000000000000090910465ffffffffffff1660808201526101408801525b6109f2878787878787610ed4565b9550600101610850565b50610a0b858760200151610f27565b505050505050505050505050505050565b5f859003610a56576040517fdb560cb500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b848114610a8f576040517fb62503e300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b848314610ac8576040517fb62503e300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b34610440860236037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff3c015f5b87811015610b3e57868682818110610b0e57610b0e614f7b565b9050602002810190610b209190614ff7565b610b2e906020810190614f17565b6020029092039150600101610af4565b505f6040518061016001604052803373ffffffffffffffffffffffffffffffffffffffff168152602001610b7184610e86565b73ffffffffffffffffffffffffffffffffffffffff1681525f6020820181905260408201819052606082018190526080820181905260a0820181905260c0820181905260e08201819052610100909101908b908b9081610bd357610bd3614f7b565b905061038002015f0161020001358152602001610bef619a1d90565b600e015f8c8c5f818110610c0557610c05614f7b565b6103800291909101610200013582525060208082019290925260409081015f20815160a081018352905473ffffffffffffffffffffffffffffffffffffffff8116825274010000000000000000000000000000000000000000810461ffff9081169483019490945276010000000000000000000000000000000000000000000081048416928201929092527801000000000000000000000000000000000000000000000000820490921660608301527a010000000000000000000000000000000000000000000000000000900465ffffffffffff16608082015290529050610ceb6145eb565b5f5b89811015610e6b578a8a82818110610d0757610d07614f7b565b90506103800201803603810190610d1e9190615033565b8051610200015161012085015191935014610e1a57815161020090810151610120850152825101515f908152619a2b6020908152604091829020825160a081018452905473ffffffffffffffffffffffffffffffffffffffff8116825274010000000000000000000000000000000000000000810461ffff9081169383019390935276010000000000000000000000000000000000000000000081048316938201939093527801000000000000000000000000000000000000000000000000830490911660608201527a01000000000000000000000000000000000000000000000000000090910465ffffffffffff1660808201526101408401525b610e618386848c8c86818110610e3257610e32614f7b565b9050602002810190610e449190614ff7565b8b8b87818110610e5657610e56614f7b565b905060400201610f3b565b9450600101610ced565b50610e7a848360200151610f27565b50505050505050505050565b338115610ecf5781601414610ec7576040517f06dbb06700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61032d61106b565b919050565b610120840180517dffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1690525f80610f0b88878787611156565b9050610f1b5f8989848a8861117e565b98975050505050505050565b8115610f3757610f37818361120e565b5050565b6060830151515f9073ffffffffffffffffffffffffffffffffffffffff16610f9f57610f6a6020840184614f17565b90505f03610f9257610f8b8686865f01518760200151886040015187610ed4565b9050611062565b610f8b8686868686611255565b610fac6020840184614f17565b90505f0361103057606084015151610fc3906112ae565b610ff9576040517f14db8bdb00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b83516101200180517dffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff169052610f8b855f8689866113e3565b6040517f0a57e20b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b95945050505050565b6040517f572b6c050000000000000000000000000000000000000000000000000000000081523360048201525f907f000000000000000000000000ff0000b6c4352714cce809000d0cd30a0e0c8dce73ffffffffffffffffffffffffffffffffffffffff169063572b6c0590602401602060405180830381865afa1580156110f5573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906111199190614efe565b15611151576014361061115157507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec36013560601c90565b503390565b5f61106285858585611179898a60200151895f01516111748d611736565b611788565b6118c4565b5f6111898484611993565b6111938684611a1a565b61120385875f8a60018111156111ab576111ab61504e565b146111ba5785602001516111c0565b88602001515b5f8b60018111156111d3576111d361504e565b146111e25789602001516111e8565b86602001515b60a088015188516111fc908e908390611fbf565b89896120b0565b979650505050505050565b5f805f805f85875af1905080611250576040517f6c998d3e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b505050565b8251610120810180517dffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff169052602084015160408501515f9291839161129e918a91859190896123e9565b9050610f1b5f898984868961117e565b5f7f000000000000000000000000721c002b0059009a671d00ad1700c9748146cd1b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16148061135457507f000000000000000000000000721c0078c2328597ca70f5451fff5a7b38d4e94773ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16145b1561136157506001919050565b61136d619a2883612414565b1561137a57506001919050565b6040517fa15c173d00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff83166004820152309063a15c173d906024016020604051808303815f875af1158015610309573d5f803e3d5ffd5b825160208084015190820151879291905f808960018111156114075761140761504e565b1490508061142157875f0151602001519250866020015191505b5f8061142f83858c8c612445565b9150915061143d8287611993565b6114478987611a1a565b801561148e57886040015115611489576040517ff40863ff00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b611727565b5f6114be8a8861012001518960c001518a60e001518b606001518c61018001518d6101a001518e60800151612561565b90505f806114cf60208c018c614ad3565b73ffffffffffffffffffffffffffffffffffffffff16146115305789602001359050876101200151811115611530576040517f1d6203f500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60a088015173ffffffffffffffffffffffffffffffffffffffff16611596576101208801518101808a1015611591576040517f70d5b32e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b909803975b5f6115a98e8a60a001518b5f0151611fbf565b9050811561166e575f6127108d61014001516060015161ffff168402816115d2576115d261507b565b0490506115fd6115e560208e018e614ad3565b60208f015160a08d015185518588039063ffffffff16565b8c6020015173ffffffffffffffffffffffffffffffffffffffff168973ffffffffffffffffffffffffffffffffffffffff1603611643576080840180518201905261166c565b801561166c5761166c8d61014001515f01518e602001518c60a0015184865f015163ffffffff16565b505b60808301511561169b5761169b8c61014001515f0151898b60a001518660800151855f015163ffffffff16565b6020830151156116c3576116c3835f0151898b60a001518660200151855f015163ffffffff16565b6040830151156116ec576116ec8960600151898b60a001518660400151855f015163ffffffff16565b6060830151156117115761171187898b60a001518660600151855f015163ffffffff16565b6117238c8a836040015163ffffffff16565b5050505b50505050505095945050505050565b80515f9060021461175a5761175582602001518361014001515f6128f6565b61032d565b619a1d60209283015173ffffffffffffffffffffffffffffffffffffffff165f908152925250604090205490565b835160608086015160808088015160a0808a015160c0808c015160408051610240810182526101008082527f36e5aab0dde52c07206863cf8fe7b4b1a25be63a3ae5286f8fe80d159c154c4f602083015260ff909b169181019190915273ffffffffffffffffffffffffffffffffffffffff8c8116998201999099528c8916968101969096529587169285019290925291851690830152831660e08201529116918101919091525f90611062906118a99060e08801516101008901516101208a01516101608b01516101808c01516101a08d01516101408e01518b88516101008082018b526020918b019182019990995260408101979097526060870195909552608086019390935260a085019190915260c084015260e083015291015290565b61020087015181516020818401810192909252810191012090565b81515f9073ffffffffffffffffffffffffffffffffffffffff16156118ee576118ee8685856129ef565b5f6119197f308ffbd37fdea620a0ae29a038519a27ab4ab6334e7bcd22e619feeb7893735d84612c24565b905061192a86602001518683612c63565b85517ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0161198057611972866020015184886101000151896101c001518a6101e00151612d1c565b606088018490529150611989565b85610100015191505b5095945050505050565b8061010001518214610f37578061010001518161012001516119b591906150a8565b156119ec576040517ffe41cfc900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b81816101000151826101200151611a0391906150e8565b611a0d91906150fb565b6101208201526101000152565b8051611a6457600181610100015114611a5f576040517fdb3ca79a00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b611ade565b805160031115611aac578061010001515f03611a5f576040517f26db27f100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040517fa799542700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b806101600151421115611b1d576040517fac492cc000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b612710816101a00151826101800151611b369190615112565b1115611b6e576040517fca9d1e5400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60c081015173ffffffffffffffffffffffffffffffffffffffff165f908152619a1f60205260409020805460ff16611c215760c08201516040517fc1f8dd0c00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff9091166004820152309063c1f8dd0c906024015f604051808303815f87803b158015611c0a575f80fd5b505af1158015611c1c573d5f803e3d5ffd5b505050505b805473ffffffffffffffffffffffffffffffffffffffff660100000000000082041660a085015261ffff7a0100000000000000000000000000000000000000000000000000008204811660808601527c010000000000000000000000000000000000000000000000000000000082041660c085015260ff61010082048116917e01000000000000000000000000000000000000000000000000000000000000900416611cd381600260ff911616151590565b15611d1f57611ce98460c00151865f0151613065565b611d1f576040517f292d235200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60048116151561010086015260018116611d39575f611d67565b60c084015173ffffffffffffffffffffffffffffffffffffffff9081165f908152619a246020526040902054165b73ffffffffffffffffffffffffffffffffffffffff1660e08601525f826005811115611d9557611d9561504e565b03611de257611da78460a00151613137565b611ddd576040517fab9c00de00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b611f24565b6002826005811115611df657611df661504e565b03611e1857825460a0850151611da79162010000900463ffffffff1690613328565b6004826005811115611e2c57611e2c61504e565b1480611e4957506003826005811115611e4757611e4761504e565b145b15611ed95760a084015160c085015173ffffffffffffffffffffffffffffffffffffffff9081165f908152619a2360205260409020548116911614611eba576040517fab9c00de00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b611ddd828560c001518660e001518761010001518861012001516133b8565b6005826005811115611eed57611eed61504e565b03611f24576040517fba78259100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8461014001516080015165ffffffffffff16421115611f6f576040517f1463d5d500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6127108561014001516020015161ffff161115611fb8576040517febaa3f7900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5050505050565b611fe6604051806060016040528061477e815260200161477e815260200161477e81525090565b60408051606081019091528073ffffffffffffffffffffffffffffffffffffffff8516156120165761345a61201a565b6134a35b67ffffffffffffffff1681526020018315612037576134ad61203b565b61355f5b67ffffffffffffffff1681526020018315612078575f8660018111156120635761206361504e565b14612070576135c561209c565b6136a861209c565b5f86600181111561208b5761208b61504e565b146120985761377f61209c565b6138475b67ffffffffffffffff169052949350505050565b5f8890506120da8684604001518560c001518660e00151876101000151896020015163ffffffff16565b6121725787604001511561211a576040517ff40863ff00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b82517ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0161215f5761215a8360200151896060015185610100015161390f565b610f1b565b61215a83602001518461014001516139d4565b5f6121a2898561012001518660c001518760e0015188606001518961018001518a6101a001518b60800151612561565b90505f806121b36020860186614ad3565b73ffffffffffffffffffffffffffffffffffffffff16146122145783602001359050846101200151811115612214576040517f1d6203f500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60a085015173ffffffffffffffffffffffffffffffffffffffff1661227a57610120850151810180841015612275576040517f70d5b32e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b909203915b8015612336575f6127108b61014001516060015161ffff168302816122a1576122a161507b565b0490506122c96122b46020870187614ad3565b8c602001518a8486038b5f015163ffffffff16565b8a6020015173ffffffffffffffffffffffffffffffffffffffff168a73ffffffffffffffffffffffffffffffffffffffff160361230f5760808301805182019052612334565b8015612334576123348b61014001515f01518c602001518a848b5f015163ffffffff16565b505b60808201511561235f5761235f8a61014001515f01518a8985608001518a5f015163ffffffff16565b60208201511561238357612383825f01518a8985602001518a5f015163ffffffff16565b6040820151156123a8576123a885606001518a8985604001518a5f015163ffffffff16565b6060820151156123c9576123c9888a8985606001518a5f015163ffffffff16565b6123db8a86886040015163ffffffff16565b505098975050505050505050565b5f80612401868760200151865f01516111748a611736565b9050611203878787878786613a96613b08565b73ffffffffffffffffffffffffffffffffffffffff81165f90815260018301602052604081205415155b9392505050565b81515f9081908161248e82888a61245c575f612463565b6040890151515b73ffffffffffffffffffffffffffffffffffffffff8b165f908152619a1d6020526040902054611788565b905087156124ca5760408601515173ffffffffffffffffffffffffffffffffffffffff16156124ca576124ca85876020015188604001516129ef565b81517ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0161252757871561250d57612503878288613c98565b9094509250612556565b612518878288613e07565b92508161010001519350612556565b610100820151825190945061254857612541878288613f63565b9250612556565b612553878288613e07565b92505b505094509492505050565b6125a46040518060a001604052805f73ffffffffffffffffffffffffffffffffffffffff1681526020015f81526020015f81526020015f81526020015f81525090565b606081018890526101008901515f80826125d7576125c38a8a8d614000565b945090925090505f8190036125d757600192505b82156126ca5760a08c015173ffffffffffffffffffffffffffffffffffffffff161561268557858c6080015161ffff16111561263f576040517f1bdbc8f400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60a08c015173ffffffffffffffffffffffffffffffffffffffff16845260808c01516127109061ffff168c025b046020850181905260608501805191909103905261275a565b73ffffffffffffffffffffffffffffffffffffffff8516156126c55773ffffffffffffffffffffffffffffffffffffffff851684526127108b870261266c565b61275a565b73ffffffffffffffffffffffffffffffffffffffff82166126e857505f5b801561275a576127108b87020481111561272e576040517f1bdbc8f400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff821684526020840181905260608401805182900390525b73ffffffffffffffffffffffffffffffffffffffff881615612873576127108b8802046040850181905260608501805191909103905260c08c015161ffff161561283a5760e08c015173ffffffffffffffffffffffffffffffffffffffff1615806127f457508773ffffffffffffffffffffffffffffffffffffffff168c60e0015173ffffffffffffffffffffffffffffffffffffffff16145b1561283a575f6127108d60c0015161ffff16866020015102816128195761281961507b565b0490508015612838576020850180518290039052604085018051820190525b505b6127108c61014001516040015161ffff168560400151028161285e5761285e61507b565b04608085018190526040850180519190910390525b5f6127108d61014001516020015161ffff168d02816128945761289461507b565b04905080856080015110156128e65760808501516060860151908203908111156128d15760608601805160808801805190910190525f90526128e4565b6060860180518290039052608086018290525b505b5050505098975050505050505050565b73ffffffffffffffffffffffffffffffffffffffff83165f908152619a1e60209081526040808320600886901c845290915281208054600160ff86161b9081189182905516612971576040517f548db54000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8373ffffffffffffffffffffffffffffffffffffffff16837ff3003920635c7d35c4f314eaeeed4b4c653ccb36608a86d57df761d460eab09d846040516129bc911515815260200190565b60405180910390a350505073ffffffffffffffffffffffffffffffffffffffff165f908152619a1d602052604090205490565b8060400151421115612a2d576040517f39db6a8400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b806020015173ffffffffffffffffffffffffffffffffffffffff16836020015173ffffffffffffffffffffffffffffffffffffffff1614612a9a576040517f53b220dd00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b805173ffffffffffffffffffffffffffffffffffffffff165f908152619a27602052604090205460ff1615612afb576040517fb5095d2d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b81516020808401516040808601518582015186850151835160c080820186527f347b7818601b168f6faadc037723496e9130b057c1ffef2ec4128311e19142f2825296810197909752928601939093526060850152608084019190915273ffffffffffffffffffffffffffffffffffffffff1660a08301529020612bbd90612ba9907f308ffbd37fdea620a0ae29a038519a27ab4ab6334e7bcd22e619feeb7893735d90612c24565b612c24565b826060015183608001518460a00151614077565b73ffffffffffffffffffffffffffffffffffffffff16815f015173ffffffffffffffffffffffffffffffffffffffff1614611250576040517fdb2d3d4e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040517f190100000000000000000000000000000000000000000000000000000000000081526002810183905260228101829052604290205f9061243e565b5f80612c7c83855f0151866020015187604001516140ca565b915091508073ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff16141580612cb85750815b15611fb85773ffffffffffffffffffffffffffffffffffffffff85163b15612cea57612ce585848661417f565b611fb8565b6040517f33e929a000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f7effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff841115612d76576040517f9e0e41d300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5073ffffffffffffffffffffffffffffffffffffffff85165f908152619a25602090815260408083208784529091528120805484929060ff166002811115612dc057612dc061504e565b0361303357805461010090047effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff165f03612e6f57805460ff166101007effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff87160217815560405185815273ffffffffffffffffffffffffffffffffffffffff88169087907f0363038f06c44447365467317554445fad3b007628b98200e08224f1aecb1c579060200160405180910390a35b805461010090047effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff16821115612ec957805461010090047effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1691505b82821015612f03576040517fa10cbd9500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b80547effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff61010080830482168590039091160260ff90911617815560405182815273ffffffffffffffffffffffffffffffffffffffff88169087907f0f72b72442c719b271089c5e7774fb382e47457791f8dc3b147e72c9c685df999060200160405180910390a3805461010090047effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff165f0361302e5780547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660011781556040515f815273ffffffffffffffffffffffffffffffffffffffff88169087907fc63c82396a1b7865295ff481988a98493c2c3cc29066c229b8001c6f5dd647a99060200160405180910390a35b611989565b6040517fab2ccbf500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff82165f908152619a26602052604081206130949083612414565b156130a15750600161032d565b6040517f7a3f5d8c00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8085166004830152831660248201523090637a3f5d8c906044015b6020604051808303815f875af1158015613113573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061243e9190614efe565b5f73ffffffffffffffffffffffffffffffffffffffff821661315b57506001919050565b7f0000000000000000000000006000030000842044000077551d00cfc6b400590073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16036131b657506001919050565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff160361321157506001919050565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff160361326c57506001919050565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16036132c757506001919050565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff160361332257506001919050565b61032d5f835b63ffffffff8281165f908152619a2060205260408120909161334d9190849061241416565b1561335a5750600161032d565b6040517feb5e068d00000000000000000000000000000000000000000000000000000000815263ffffffff8416600482015273ffffffffffffffffffffffffffffffffffffffff83166024820152309063eb5e068d906044016130f7565b5f806133c58787876141cd565b915091505f8484816133d9576133d961507b565b04905081811115613416576040517f9837ddd700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b82811015613450576040517f9318944000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5050505050505050565b613466828486846143ec565b1561349d576040517f6c998d3e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b50505050565b61349d848261120e565b6040517ff242432a00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff86811660048301528581166024830152604482018490526064820183905260a060848301525f60a48301819052919085169063f242432a9060c4015b5f604051808303815f87803b15801561353b575f80fd5b505af192505050801561354c575060015b61355757505f611062565b506001611062565b6040517f23b872dd00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff86811660048301528581166024830152604482018490525f91908516906323b872dd90606401613524565b8060c0015173ffffffffffffffffffffffffffffffffffffffff16816020015173ffffffffffffffffffffffffffffffffffffffff16836020015173ffffffffffffffffffffffffffffffffffffffff167f6f4c56c4b9a9d2479f963d802b19d17b02293ce1225461ac0cb846c482ee3c3e84604001518560a001518660e0015187610100015188610120015160405161369c95949392919073ffffffffffffffffffffffffffffffffffffffff958616815293909416602084015260408301919091526060820152608081019190915260a00190565b60405180910390a45050565b8060c0015173ffffffffffffffffffffffffffffffffffffffff16816020015173ffffffffffffffffffffffffffffffffffffffff16836020015173ffffffffffffffffffffffffffffffffffffffff167f1217006325a98bdcc6afc9c44965bb66ac7460a44dc57c2ac47622561d25c45a84604001518560a001518660e0015187610100015188610120015160405161369c95949392919073ffffffffffffffffffffffffffffffffffffffff958616815293909416602084015260408301919091526060820152608081019190915260a00190565b8060c0015173ffffffffffffffffffffffffffffffffffffffff16816020015173ffffffffffffffffffffffffffffffffffffffff16836020015173ffffffffffffffffffffffffffffffffffffffff167f8b87c0b049fe52718fe6ff466b514c5a93c405fb0de8fbd761a23483f9f9e19884604001518560a001518660e0015187610120015160405161369c949392919073ffffffffffffffffffffffffffffffffffffffff94851681529290931660208301526040820152606081019190915260800190565b8060c0015173ffffffffffffffffffffffffffffffffffffffff16816020015173ffffffffffffffffffffffffffffffffffffffff16836020015173ffffffffffffffffffffffffffffffffffffffff167fffb29e9cf48456d56b6d414855b66a7ec060ce2054dcb124a1876310e1b7355c84604001518560a001518660e0015187610120015160405161369c949392919073ffffffffffffffffffffffffffffffffffffffff94851681529290931660208301526040820152606081019190915260800190565b80156112505773ffffffffffffffffffffffffffffffffffffffff83165f818152619a256020908152604080832086845282529182902080547effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff610100918290048116870116027fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00168155915184815291929185917f02c470cc26bb0c92da643e89f3654f5866091d4ae5af326c4face0f1611d736b910160405180910390a350505050565b73ffffffffffffffffffffffffffffffffffffffff82165f908152619a1e60209081526040808320600885901c845290915290208054600160ff84161b908118918290551615613a50576040517fee8e6a3a00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60405173ffffffffffffffffffffffffffffffffffffffff83169082907f86983746fe0ad3ad6fceb2a9aa2d498430d4343ec3c8fead646124f0615f4ba6905f90a35050565b5f600a821180613aa4575081155b15613adb576040517ffde01ad000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f604051806101600160405280610140815260200161538b610140913960059390931b9092015192915050565b5f8335833683613b1b6020890189614f17565b915091505f5b81811015613b9f57846001165f03613b6557613b5e84848484818110613b4957613b49614f7b565b905060200201355f9182526020526040902090565b9350613b93565b613b90838383818110613b7a57613b7a614f7b565b90506020020135855f9182526020526040902090565b93505b600194851c9401613b21565b50885173ffffffffffffffffffffffffffffffffffffffff1615613bc857613bc88c8b8b6129ef565b613c2a8b602001518b613c257f308ffbd37fdea620a0ae29a038519a27ab4ab6334e7bcd22e619feeb7893735d612ba4613c168e8060200190613c0b9190614f17565b90508d63ffffffff16565b895f9182526020526040902090565b612c63565b8a517ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01613c8057613c728b60200151888d61010001518e6101c001518f6101e00151612d1c565b60608d018890529450613c89565b8a610100015194505b50505050979650505050505050565b5f805f835f0151905083606001515f015173ffffffffffffffffffffffffffffffffffffffff16633779e6fd613cd18660200151614463565b60405180606001604052808561010001518152602001856101c001518152602001856101e001518152508460c001518560e001518b87604001518b60600151602001518961016001518e7f06ad108efb587ddea4f632c87662b13c59dbba674c2ea7289b2fb10575a49d796040518b63ffffffff1660e01b8152600401613d619a99989796959493929190615186565b60408051808303815f875af1158015613d7c573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190613da09190615221565b90935091507effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff831115613dfe576040517f9e0e41d300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b50935093915050565b5f80825f0151905082606001515f015173ffffffffffffffffffffffffffffffffffffffff16630f59197d8260c001518360e001518660600151602001518561010001518661016001518b88604001518961010001518d7fb1cb65a3e643070d9d33047fdfd384badc7cd70b2415e548b37db5a10c708716613e8c8f60200151614463565b6040518c63ffffffff1660e01b8152600401613eb29b9a9998979695949392919061524b565b6020604051808303815f875af1158015613ece573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190613ef29190614efe565b915081613f5b578473ffffffffffffffffffffffffffffffffffffffff168161014001518460600151602001517f68db558b3492d318070ad648fde8dab15f9d5cff3058c951bf13070512b4064b5f604051613f52911515815260200190565b60405180910390a45b509392505050565b5f80825f0151905082606001515f015173ffffffffffffffffffffffffffffffffffffffff1663b3992ab18260c001518360e001518660600151602001518561016001518a87604001518b7fb1cb65a3e643070d9d33047fdfd384badc7cd70b2415e548b37db5a10c708716613fdc8d60200151614463565b6040518a63ffffffff1660e01b8152600401613eb2999897969594939291906152cb565b5f805f61405d565b5f805f60405160608101604052632a55205a815285816020015286816040015260405f6044601c8401885afa60403d1015161561404e575f519350602051925050614054565b50600190505b93509350939050565b614068848688614008565b92509250925093509350939050565b5f80614085868686866140ca565b9250905080156140c1576040517f33e929a000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b50949350505050565b5f8060ff8511156140e05750600190505f614176565b604080515f81526020810180835288905260ff871691810191909152606081018590526080810184905260019060a0016020604051602081039080840390855afa158015614130573d5f803e3d5ffd5b50506040517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0015173ffffffffffffffffffffffffffffffffffffffff81161593509150505b94509492505050565b6141978383835f015184602001518560400151614500565b611250576040517ff83b002000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f8060048560058111156141e3576141e361504e565b036143085773ffffffffffffffffffffffffffffffffffffffff84165f908152619a22602090815260408083208684529091529020805460ff166142be576040517f7a67b4a000000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff86166004820152602481018590523090637a67b4a09060440160408051808303815f875af1158015614290573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906142b4919061533b565b92509250506143e4565b8054610100900460ff161561430657546effffffffffffffffffffffffffffff62010000820481169350710100000000000000000000000000000000009091041690506143e4565b505b73ffffffffffffffffffffffffffffffffffffffff84165f908152619a2160209081526040918290208251608081018452905460ff80821615158352610100820416158015938301939093526effffffffffffffffffffffffffffff62010000820481169483019490945271010000000000000000000000000000000000900490921660608301526143bc5760408101516060909101516effffffffffffffffffffffffffffff91821693501690506143e4565b5f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff92509250505b935093915050565b5f614457565b5f604051608081016040526323b872dd81528381602001528481604001528581606001525f806064601c84015f875af1156144495760203d101561443a575050803b1561444f565b60205f803e50505f511561444f565b50600190505b949350505050565b611062828486886143f2565b805160609060ff10156144a2576040517fe19a3e7b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60208281015160408085015185518251948501939093529083015260f81b7fff000000000000000000000000000000000000000000000000000000000000001660608201526061016040516020818303038152906040529050919050565b5f60ff84111561453c576040517fe19a3e7b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6145d4565b5f6040517f1626ba7e000000000000000000000000000000000000000000000000000000008152836004820152604060248201526041604482015284606482015286608582015285608482015260c4810160405260205f60c483865afa60203d101516156119895750505f517f1626ba7e0000000000000000000000000000000000000000000000000000000014611062565b6145e1848385888a614541565b9695505050505050565b60405180608001604052806146f06040518061022001604052805f81526020015f73ffffffffffffffffffffffffffffffffffffffff1681526020015f73ffffffffffffffffffffffffffffffffffffffff1681526020015f73ffffffffffffffffffffffffffffffffffffffff1681526020015f73ffffffffffffffffffffffffffffffffffffffff1681526020015f73ffffffffffffffffffffffffffffffffffffffff1681526020015f73ffffffffffffffffffffffffffffffffffffffff1681526020015f81526020015f81526020015f81526020015f81526020015f81526020015f81526020015f81526020015f81526020015f81526020015f81525090565b8152604080516060810182525f80825260208281018290529282015291019081526040805160c0810182525f8082526020828101829052928201819052606082018190526080820181905260a0820152910190815260200161477960405180604001604052805f73ffffffffffffffffffffffffffffffffffffffff1681526020015f81525090565b905290565b61478661535d565b565b604051610220810167ffffffffffffffff811182821017156147d1577f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b60405290565b6040805190810167ffffffffffffffff811182821017156147d1577f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b803573ffffffffffffffffffffffffffffffffffffffff81168114610ecf575f80fd5b5f6102208284031215614853575f80fd5b61485b614788565b90508135815261486d6020830161481f565b602082015261487e6040830161481f565b604082015261488f6060830161481f565b60608201526148a06080830161481f565b60808201526148b160a0830161481f565b60a08201526148c260c0830161481f565b60c082015260e08281013590820152610100808301359082015261012080830135908201526101408083013590820152610160808301359082015261018080830135908201526101a080830135908201526101c080830135908201526101e080830135908201526102009182013591810191909152919050565b5f6060828403121561494c575f80fd5b6040516060810181811067ffffffffffffffff82111715614994577f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b80604052508091508235815260208301356020820152604083013560408201525092915050565b5f60c082840312156149cb575f80fd5b60405160c0810181811067ffffffffffffffff82111715614a13577f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b604052905080614a228361481f565b8152614a306020840161481f565b602082015260408301356040820152606083013560608201526080830135608082015260a083013560a08201525092915050565b5f60408284031215614a74575f80fd5b50919050565b5f805f806103808587031215614a8e575f80fd5b614a988686614842565b9350614aa886610220870161493c565b9250614ab88661028087016149bb565b9150614ac8866103408701614a64565b905092959194509250565b5f60208284031215614ae3575f80fd5b61243e8261481f565b5f818303610380811215614afe575f80fd5b6040516080810181811067ffffffffffffffff82111715614b46577f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b604052915081614b568585614842565b8152614b6685610220860161493c565b6020820152614b798561028086016149bb565b604082015260407ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffcc083011215614bad575f80fd5b614bb56147d7565b9150614bc4610340850161481f565b82526103608401356020830152816060820152505092915050565b5f805f6103e08486031215614bf2575f80fd5b614bfc8585614aec565b925061038084013567ffffffffffffffff811115614c18575f80fd5b614c2486828701614a64565b925050614c35856103a08601614a64565b90509250925092565b5f8083601f840112614c4e575f80fd5b50813567ffffffffffffffff811115614c65575f80fd5b602083019150836020606083028501011115614c7f575f80fd5b9250929050565b5f8083601f840112614c96575f80fd5b50813567ffffffffffffffff811115614cad575f80fd5b60208301915083602060c083028501011115614c7f575f80fd5b5f8083601f840112614cd7575f80fd5b50813567ffffffffffffffff811115614cee575f80fd5b6020830191508360208260061b8501011115614c7f575f80fd5b5f805f805f805f806080898b031215614d1f575f80fd5b883567ffffffffffffffff80821115614d36575f80fd5b818b0191508b601f830112614d49575f80fd5b813581811115614d57575f80fd5b8c602061022083028501011115614d6c575f80fd5b60209283019a509850908a01359080821115614d86575f80fd5b614d928c838d01614c3e565b909850965060408b0135915080821115614daa575f80fd5b614db68c838d01614c86565b909650945060608b0135915080821115614dce575f80fd5b50614ddb8b828c01614cc7565b999c989b5096995094979396929594505050565b5f8083601f840112614dff575f80fd5b50813567ffffffffffffffff811115614e16575f80fd5b6020830191508360208260051b8501011115614c7f575f80fd5b5f805f805f8060608789031215614e45575f80fd5b863567ffffffffffffffff80821115614e5c575f80fd5b818901915089601f830112614e6f575f80fd5b813581811115614e7d575f80fd5b8a602061038083028501011115614e92575f80fd5b602092830198509650908801359080821115614eac575f80fd5b614eb88a838b01614def565b90965094506040890135915080821115614ed0575f80fd5b50614edd89828a01614cc7565b979a9699509497509295939492505050565b80518015158114610ecf575f80fd5b5f60208284031215614f0e575f80fd5b61243e82614eef565b5f8083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe1843603018112614f4a575f80fd5b83018035915067ffffffffffffffff821115614f64575f80fd5b6020019150600581901b3603821315614c7f575f80fd5b7f4e487b71000000000000000000000000000000000000000000000000000000005f52603260045260245ffd5b5f6102208284031215614fb9575f80fd5b61243e8383614842565b5f60608284031215614fd3575f80fd5b61243e838361493c565b5f60c08284031215614fed575f80fd5b61243e83836149bb565b5f82357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc1833603018112615029575f80fd5b9190910192915050565b5f6103808284031215615044575f80fd5b61243e8383614aec565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52602160045260245ffd5b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601260045260245ffd5b5f826150b6576150b661507b565b500690565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b5f826150f6576150f661507b565b500490565b808202811582820484141761032d5761032d6150bb565b8082018082111561032d5761032d6150bb565b5f81518084525f5b818110156151495760208185018101518683018201520161512d565b505f6020828601015260207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f83011685010191505092915050565b5f6101808083526151998184018e615125565b9150508a51602083015260208b0151604083015260408b0151606083015273ffffffffffffffffffffffffffffffffffffffff808b1660808401528960a084015280891660c084015280881660e0840152508561010083015261520761012083018665ffffffffffff169052565b610140820193909352610160015298975050505050505050565b5f8060408385031215615232575f80fd5b8251915061524260208401614eef565b90509250929050565b5f61016073ffffffffffffffffffffffffffffffffffffffff808f1684528d60208501528c60408501528b60608501528a6080850152808a1660a085015280891660c0850152508660e08401528561010084015284610120840152806101408401526152b981840185615125565b9e9d5050505050505050505050505050565b5f61012073ffffffffffffffffffffffffffffffffffffffff808d1684528b60208501528a6040850152896060850152808916608085015280881660a0850152508560c08401528460e08401528061010084015261532b81840185615125565b9c9b505050505050505050505050565b5f806040838503121561534c575f80fd5b505080516020909101519092909150565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52605160045260245ffdfe8659f55d4c88f84030fe09241169834754ebf2e61099b616e530c6b65712c6445106f4043cda72e04ca2c760016628ea8d5667309323ba590682ea5254b4e82e71267a8f42e7ccde4ac75848a93b741df7a2f7a58e40274055f2fa51dbaa69ce6e90557aed2a349f8b6efb2b652c4025c56cfa82424c5cd0c6801cc234ebf519caf42fc49ad57705ea6be2ca9e1835c9ccddf7bc6fdea8f851917329b1d53a7f09b32b6b5ffee898d5fe18398652042cc8c46449329c5a1a79e425f4ede9bc2bc2362dea3338b88607906397acfdcc5651f19b40a038ee7c89dc4ab54c736cacf2bbc4f6d7ccfa2b8aab6505f0c8f2868c5a190c6c4cfce8c0de447804904df981f99e15003039550d3597e34e6426b1e230992a5a3727cb5e230754f18f3566012178d0a6b8f8748e48411572bdc391435539737aafc91fcba6f2c24ae156cfa264697066735822122075aac895672e0a96b09542e79949004bbdc52b6c0b74f5956c9c6973376a113064736f6c63430008180033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
0000000000000000000000009a1d00773287950891b8a48be6f21e951eff91b3
-----Decoded View---------------
Arg [0] : configurationContract (address): 0x9A1D00773287950891B8A48Be6f21e951EFF91b3
-----Encoded View---------------
1 Constructor Arguments found :
Arg [0] : 0000000000000000000000009a1d00773287950891b8a48be6f21e951eff91b3
Deployed Bytecode Sourcemap
3060:19837:21:-:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;5956:1293;;;;;;:::i;:::-;;:::i;:::-;;969:144:2;;;;;;;;;;-1:-1:-1;969:144:2;;;;;:::i;:::-;;:::i;:::-;;;5292:14:29;;5285:22;5267:41;;5255:2;5240:18;969:144:2;;;;;;;10206:1398:21;;;;;;:::i;:::-;;:::i;14359:2832::-;;;;;;:::i;:::-;;:::i;20172:2723::-;;;;;;:::i;:::-;;:::i;5956:1293::-;6342:562;;;;;;;;;6378:10;6342:562;;6246:45;:8;:45;;6165:26;;6342:562;;;6409:29;6246:45;6409:9;:29::i;:::-;6342:562;;;;6472:4;6342:562;;;;-1:-1:-1;6342:562:21;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;6771:30;;;;6342:562;;;;;;402:66:28;6862:30:21;;;;6829:64;;;;:32;;;;;:64;;;;;;;;6342:562;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;6312:592;;-1:-1:-1;6962:204:21;6312:592;7025:9;6862:11;7082:15;7115:11;7144:8;6962:20;:204::i;:::-;6915:251;;7177:65;7203:23;7228:7;:13;;;7177:25;:65::i;:::-;6155:1094;;;5956:1293;;;;:::o;969:144:2:-;1068:38;;;;;:27;11963:55:29;;;1068:38:2;;;11945:74:29;1045:4:2;;1068:8;:27;;;;;;11918:18:29;;1068:38:2;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;1061:45;969:144;-1:-1:-1;;969:144:2:o;10206:1398:21:-;10395:26;10605:20;;;;:14;:20;:::i;:::-;10684:594;;;;;;;;;10720:10;10684:594;;6046:2:16;10584:48:21;;;10493:8;:140;:71;:140;;-1:-1:-1;10493:8:21;;-1:-1:-1;10684:594:21;;;10751:29;10493:140;10751:9;:29::i;:::-;10684:594;;;;10814:4;10684:594;;;;-1:-1:-1;10684:594:21;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;11113:27;;:46;;;10684:594;;;;;;402:66:28;11220:27:21;;:46;;;11187:80;;;;:32;;;;;:80;;;;;;;;10684:594;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;10654:624;;-1:-1:-1;11336:185:21;10654:624;11407:9;11220:15;11467:14;11499:8;11336:28;:185::i;:::-;11289:232;;11532:65;11558:23;11583:7;:13;;;11532:25;:65::i;:::-;10385:1219;;;10206:1398;;;:::o;14359:2832::-;14598:50;;;14594:132;;14671:44;;;;;;;;;;;;;;14594:132;14740:46;;;14736:128;;14809:44;;;;;;;;;;;;;;14736:128;14878:43;;;14874:125;;14944:44;;;;;;;;;;;;;;14874:125;15040:1;15013:28;;;15009:114;;15064:48;;;;;;;;;;;;;;15009:114;15440:579;;;;;;;;;15476:10;15440:579;;7094:3:16;15320:68:21;;15231:8;:158;:68;:158;;15133:26;;15440:579;;;15507:29;15231:158;15507:9;:29::i;:::-;15440:579;;;;15570:5;15440:579;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;15870:16;;;;:19;;;;;:::i;:::-;;;;;;:38;;;15440:579;;;;15936:12;402:66:28;;645:227;15936:12:21;:32;;:72;15969:16;;15986:1;15969:19;;;;;;;:::i;:::-;;;;;;;;;:38;;;;;15936:72;;;;;;;;;;;;;;-1:-1:-1;15936:72:21;;;15440:579;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;15440:579:21;-1:-1:-1;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;15410:609:21;;-1:-1:-1;16064:9:21;;-1:-1:-1;;16205:26:21;;16242:867;16262:27;;;16242:867;;;16320:16;;16337:1;16320:19;;;;;;;:::i;:::-;;;;;;16306:33;;;;;;;;;;:::i;:::-;;;16371:16;;16388:1;16371:19;;;;;;;:::i;:::-;;;;;;16353:37;;;;;;;;;;:::i;:::-;;;16418:12;;16431:1;16418:15;;;;;;;:::i;:::-;;;;;;16404:29;;;;;;;;;;:::i;:::-;;;16458:9;;16468:1;16458:12;;;;;;;:::i;:::-;;;;;;16447:23;;16519:11;:30;;;16489:7;:26;;;:60;16485:263;;16598:30;;;;;16569:26;;;:59;16702:30;16669:64;;;;:32;:64;;;;;;;;;16646:87;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:20;;;:87;16485:263;16805:233;16847:7;16877:23;16923:11;16957:15;16995:11;17029:8;16805:20;:233::i;:::-;16762:276;-1:-1:-1;17081:3:21;;16242:867;;;;17119:65;17145:23;17170:7;:13;;;17119:25;:65::i;:::-;14584:2607;;;;;;;14359:2832;;;;;;;;:::o;20172:2723::-;20419:1;20387:33;;;20383:119;;20443:48;;;;;;;;;;;;;;20383:119;20516:48;;;20512:130;;20587:44;;;;;;;;;;;;;;20512:130;20656:54;;;20652:136;;20733:44;;;;;;;;;;;;;;20652:136;20832:9;9709:4:16;21048:82:21;;20950:8;:181;:77;:181;20798:31;21146:166;21166:32;;;21146:166;;;21266:15;;21282:1;21266:18;;;;;;;:::i;:::-;;;;;;;;;;;;:::i;:::-;:24;;;;;;;:::i;:::-;6046:2:16;21245:52:21;21223:74;;;;-1:-1:-1;21200:3:21;;21146:166;;;;21332:27;21362:613;;;;;;;;21398:10;21362:613;;;;;;21429:29;21439:18;21429:9;:29::i;:::-;21362:613;;;;21492:5;21362:613;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;21792:21;;;;:24;;;;;:::i;:::-;;;;;;:36;;:55;;;21362:613;;;;21875:12;402:66:28;;645:227;21875:12:21;:32;;:89;21908:21;;21930:1;21908:24;;;;;;;:::i;:::-;;;;;;;:55;;;21875:89;;-1:-1:-1;21875:89:21;;;;;;;;;;;;-1:-1:-1;21875:89:21;21362:613;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;21332:643;-1:-1:-1;21986:36:21;;:::i;:::-;22038:9;22033:780;22053:32;;;22033:780;;;22120:21;;22142:1;22120:24;;;;;;;:::i;:::-;;;;;;22102:42;;;;;;;;;;:::i;:::-;22192:27;;:46;;;22162:26;;;;22102:42;;-1:-1:-1;22162:76:21;22158:311;;22287:27;;:46;;;;;22258:26;;;:75;22407:27;;:46;;22374:80;;;;:32;:80;;;;;;;;;22351:103;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:20;;;:103;22158:311;22526:216;22576:7;22606:23;22652:15;22689;;22705:1;22689:18;;;;;;;:::i;:::-;;;;;;;;;;;;:::i;:::-;22729:9;;22739:1;22729:12;;;;;;;:::i;:::-;;;;;;22526:28;:216::i;:::-;22483:259;-1:-1:-1;22785:3:21;;22033:780;;;;22823:65;22849:23;22874:7;:13;;;22823:25;:65::i;:::-;20373:2522;;;;20172:2723;;;;;;:::o;115193:303:22:-;115309:10;115333:22;;115329:161;;115375:18;115397:2;115375:24;115371:74;;115408:37;;;;;;;;;;;;;;115371:74;115467:12;:10;:12::i;115329:161::-;115193:303;;;:::o;18598:792::-;18952:21;;;;;18920:54;;;;18883:25;;19010:123;19043:7;18952:11;19091:15;19121:11;19010:19;:123::i;:::-;18985:148;;19177:206;19219:9;19247:7;19273:19;19311:14;19344:11;19374:8;19177:24;:206::i;:::-;19144:239;18598:792;-1:-1:-1;;;;;;;;18598:792:22:o;71425:202::-;71528:24;;71524:97;;71568:42;71582:5;71589:20;71568:13;:42::i;:::-;71425:202;;:::o;4231:1762:23:-;4543:29;;;;:45;4502:25;;4543:59;;4539:1448;;4622:20;;;;:14;:20;:::i;:::-;:27;;4653:1;4622:32;4618:624;;4694:271;4736:12;4770:19;4811:15;:27;;;4860:15;:25;;;4907:15;:27;;;4956:8;4694:20;:271::i;:::-;4674:291;;4539:1448;;4618:624;5024:203;5070:12;5104:19;5145:15;5182:14;5218:8;5024:24;:203::i;4539:1448::-;5276:20;;;;:14;:20;:::i;:::-;:27;;5307:1;5276:32;5272:705;;5359:29;;;;:45;5333:72;;:25;:72::i;:::-;5328:172;;5436:45;;;;;;;;;;;;;;5328:172;5565:27;;:37;;;;5517:86;;;;5646:213;5707:19;5565:27;:15;5816:12;5850:8;5646:39;:213::i;5272:705::-;5905:57;;;;;;;;;;;;;;5272:705;4231:1762;;;;;;;:::o;1119:596:2:-;1211:39;;;;;1239:10;1211:39;;;11945:74:29;1181:14:2;;1211:8;:27;;;;;11918:18:29;;1211:39:2;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;1207:502;;;1289:2;1270:8;:21;1266:377;;-1:-1:-1;1522:23:2;1526:14;1522:23;1509:37;1505:2;1501:46;1119:596;:::o;1266:377::-;-1:-1:-1;734:10:4;;1119:596:2:o;94532:621:22:-;94738:22;94789:357;94825:7;94847:11;94873:9;94897:11;94923:213;94966:11;94995;:17;;;95030:11;:18;;;95066:56;95110:11;95066:43;:56::i;:::-;94923:25;:213::i;:::-;94789:22;:357::i;16785:849::-;17039:25;17076:50;17098:14;17114:11;17076:21;:50::i;:::-;17137:48;17164:7;17173:11;17137:26;:48::i;:::-;17216:411;17261:19;17294:7;17323:9;17315:4;:17;;;;;;;;:::i;:::-;;:53;;17351:11;:17;;;17315:53;;;17335:7;:13;;;17315:53;17390:9;17382:4;:17;;;;;;;;:::i;:::-;;:53;;17422:7;:13;;;17382:53;;;17402:11;:17;;;17382:53;17449:25;;;;17558:20;;17488:91;;17525:4;;17449:25;;17488:36;:91::i;:::-;17593:11;17618:8;17216:31;:411::i;:::-;17196:431;16785:849;-1:-1:-1;;;;;;;16785:849:22:o;70814:348::-;70886:12;71044:1;71041;71038;71035;71025:8;71021:2;71014:5;71009:37;70998:48;;71071:7;71066:90;;71101:44;;;;;;;;;;;;;;71066:90;70876:286;70814:348;;:::o;7043:941:23:-;7374:27;;7443:21;;;;;7411:54;;;;7619:25;;;;7662:27;;;;7310:25;;7374:27;7310:25;;7501:221;;7560:12;;7374:27;;7619:25;7707:14;7501:41;:221::i;:::-;7476:246;;7766:211;7808:9;7836:12;7867:19;7905:14;7938:11;7968:8;7766:24;:211::i;4177:445:24:-;4255:4;4294:16;4275:35;;:15;:35;;;:87;;;;4346:16;4327:35;;:15;:35;;;4275:87;4271:129;;;-1:-1:-1;4385:4:24;;4177:445;-1:-1:-1;4177:445:24:o;4271:129::-;4413:62;:36;4459:15;4413:45;:62::i;:::-;4409:104;;;-1:-1:-1;4498:4:24;;4177:445;-1:-1:-1;4177:445:24:o;4409:104::-;4529:86;;;;;11975:42:29;11963:55;;4529:86:24;;;11945:74:29;4563:4:24;;4529:69;;11918:18:29;;4529:86:24;;;;;;;;;;;;;;;;;;;;;;;6022:4321;6387:24;;6442:18;;;;;6487:30;;;;6330:19;;6387:24;6442:18;6273:25;;6544:4;:17;;;;;;;;:::i;:::-;;6527:34;;6577:9;6572:124;;6614:12;:24;;;:30;;;6602:42;;6667:12;:18;;;6658:27;;6572:124;6707:22;6731:21;6769:86;6809:9;6820:6;6828:12;6842;6769:39;:86::i;:::-;6706:149;;;;6874:50;6896:14;6912:11;6874:21;:50::i;:::-;6935:53;6962:12;6976:11;6935:26;:53::i;:::-;7003:16;6999:3338;;;7039:12;:31;;;7035:127;;;7097:50;;;;;;;;;;;;;;7035:127;6999:3338;;;7192:29;7240:419;7283:12;7317:11;:21;;;7360:11;:24;;;7406:11;:19;;;7447:11;:23;;;7492:11;:35;;;7549:11;:34;;;7605:11;:36;;;7240:21;:419::i;:::-;7192:467;-1:-1:-1;7674:22:24;;7714:18;;;;:8;:18;:::i;:::-;:32;;;7710:269;;7783:8;:15;;;7766:32;;7838:11;:21;;;7821:14;:38;7817:148;;;7890:56;;;;;;;;;;;;;;7817:148;7997:25;;;;:39;;7993:426;;8120:21;;;;:38;;8184:41;;;8180:142;;;8260:39;;;;;;;;;;;;;;8180:142;8344:42;;;;7993:426;8433:46;8499:91;8536:4;8542:11;:25;;;8569:11;:20;;;8499:36;:91::i;:::-;8433:157;-1:-1:-1;8609:18:24;;8605:851;;8679:36;3128:6:16;8735:12:24;:25;;;:48;;;8718:65;;:14;:65;:83;;;;;:::i;:::-;;;-1:-1:-1;8823:135:24;8845:18;;;;:8;:18;:::i;:::-;8865;;;;8885:25;;;;8823:21;;8912:45;;;;8823:135;;:::i;:::-;8998:12;:18;;;8985:31;;:9;:31;;;8981:443;;9044:31;;;:63;;;;;;8981:443;;;9166:32;;9162:240;;9230:145;9252:12;:25;;;:45;;;9299:12;:18;;;9319:11;:25;;;9346:28;9230:10;:21;;;:145;;:::i;:::-;8647:795;8605:851;9474:31;;;;:35;9470:213;;9529:139;9551:12;:25;;;:45;;;9598:9;9609:11;:25;;;9636:8;:31;;;9529:10;:21;;;:139;;:::i;:::-;9701:24;;;;:28;9697:179;;9749:112;9771:8;:25;;;9798:9;9809:11;:25;;;9836:8;:24;;;9749:10;:21;;;:112;;:::i;:::-;9894:28;;;;:32;9890:185;;9946:114;9968:11;:23;;;9993:9;10004:11;:25;;;10031:8;:28;;;9946:10;:21;;;:114;;:::i;:::-;10093:23;;;;:27;10089:158;;10140:92;10162:6;10170:9;10181:11;:25;;;10208:8;:23;;;10140:10;:21;;;:92;;:::i;:::-;10261:65;10300:12;10314:11;10261:10;:38;;;:65;;:::i;:::-;7178:3159;;;6999:3338;6300:4043;;;;;;6022:4321;;;;;;;:::o;86313:388:22:-;86482:20;;86424:19;;3778:1:16;86482:60:22;:212;;86625:69;86650:11;:17;;;86669:11;:17;;;86688:5;86625:24;:69::i;:::-;86482:212;;;402:66:28;86588:17:22;;;;;86562:44;;:25;:44;;;;;-1:-1:-1;86562:44:22;;;;;86313:388::o;24532:1530::-;25051:20;;25244:23;;;;;25320:36;;;;;25409:25;;;;;25487:24;;;;;29506:4:13;29500:11;;29537:46;;;29524:60;;29609:5;29597:18;;;1382:361:16;29577:4:13;29541:14;;29641:30;25037:36:22;;;;29691:14:13;;;29684:30;;;;25108:26:22;;;;29734:14:13;;;29727:30;;;;25169:24:22;;;29777:14:13;;;29770:30;;;;25228:41:22;;;29820:14:13;;;29813:30;;;;25304:54:22;;;29863:14:13;;;29856:30;25393:43:22;;29915:4:13;29906:14;;29899:30;25471:42:22;;29949:15:13;;;29942:31;;;;24714:17:22;;24767:1288;;24824:1160;;25566:19;;;;25616:18;;;;25665:21;;;;25717:22;;;;25770:35;;;;25836:34;;;;25901:17;;;;25949:16;31082::13;;31141:5;31129:18;;;31111:37;;31233:4;31169:22;;;31224:14;;;31217:30;;;;31276:4;31267:14;;31260:30;;;;31319:4;31310:14;;31303:30;;;;31362:4;31353:14;;31346:30;;;;31405:4;31396:14;;31389:30;;;;31448:4;31439:14;;31432:30;31491:4;31482:14;;31475:30;31525:15;;31518:31;31052:3;30738:827;24824:1160:22;26010:30;;;;32041:15:13;;32140:4;32077:21;;;32131:14;;32124:30;;;;32207:17;;32186:19;;32176:49;;31824:417;95988:1013:22;96261:18;;96223:22;;96261:32;;;96257:114;;96309:51;96328:7;96337:9;96348:11;96309:18;:51::i;:::-;96382:19;96404:51;96421:22;96445:9;96404:16;:51::i;:::-;96382:73;;96466:64;96488:11;:17;;;96507:9;96518:11;96466:21;:64::i;:::-;96545:20;;:60;;96541:454;;96638:235;96693:11;:17;;;96729:9;96757:11;:18;;;96794:11;:31;;;96843:11;:29;;;96638:37;:235::i;:::-;96887:19;;;:31;;;96621:252;-1:-1:-1;96541:454:22;;;96966:11;:18;;;96949:35;;96541:454;96247:754;95988:1013;;;;;;;:::o;14843:481::-;14970:11;:18;;;14952:14;:36;14948:370;;15032:11;:18;;;15008:11;:21;;;:42;;;;:::i;:::-;:47;15004:157;;15082:64;;;;;;;;;;;;;;15004:157;15244:14;15223:11;:18;;;15199:11;:21;;;:42;;;;:::i;:::-;:59;;;;:::i;:::-;15175:21;;;:83;15272:18;;:35;14843:481::o;33268:3920::-;33404:20;;33400:497;;3364:1:16;33483:11:22;:18;;;:25;33479:123;;33535:52;;;;;;;;;;;;;;33479:123;33400:497;;;33622:20;;3869:1:16;-1:-1:-1;33618:279:22;;;33688:11;:18;;;33710:1;33688:23;33684:125;;33738:56;;;;;;;;;;;;;;33618:279;33846:40;;;;;;;;;;;;;;33618:279;33929:11;:22;;;33911:15;:40;33907:113;;;33974:35;;;;;;;;;;;;;;33907:113;3128:6:16;34072:11:22;:34;;;34034:11;:35;;;:72;;;;:::i;:::-;:90;34030:192;;;34147:64;;;;;;;;;;;;;;34030:192;34349:24;;;;34310:64;;34232:62;34310:64;;;:38;:64;;;;;34390:40;;;;34385:166;;34515:24;;;;34446:94;;;;;11975:42:29;11963:55;;;34446:94:22;;;11945:74:29;34480:4:22;;34446:68;;11918:18:29;;34446:94:22;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;34385:166;34595:44;;34676:52;;;;;34649:24;;;:79;34766:53;;;;;;34738:25;;;:81;34855:51;;;;34829:23;;;:77;34595:44;;;;;;;34931:34;;;;34980:60;34931:34;11696:6:16;110189:23:22;110190:16;;110189:23;;;;110083:136;34980:60;34976:262;;;35061:70;35089:11;:24;;;35115:7;:15;;;35061:27;:70::i;:::-;35056:172;;35158:55;;;;;;;;;;;;;;35056:172;11757:6:16;110190:16:22;;110189:23;;35248:41;;;:98;11629:6:16;110190:16:22;;35401:156;;35555:1;35401:156;;;35519:24;;;;35471:73;;;;;;;;:47;:73;;;;;;;35401:156;35357:200;;:28;;;:200;35599:45;35580:15;:64;;;;;;;;:::i;:::-;;35576:1303;;35665:50;35689:11;:25;;;35665:23;:50::i;:::-;35660:156;;35742:59;;;;;;;;;;;;;;35660:156;35576:1303;;;35855:44;35836:15;:63;;;;;;;;:::i;:::-;;35832:1047;;35948:53;;36003:25;;;;35920:109;;35948:53;;;;;;35920:27;:109::i;35832:1047::-;36169:34;36150:15;:53;;;;;;;;:::i;:::-;;:124;;;-1:-1:-1;36226:48:22;36207:15;:67;;;;;;;;:::i;:::-;;36150:124;36146:733;;;36379:25;;;;36350:24;;;;36294:110;:81;;;;;;;:55;:81;;;;;;;;:110;;;36290:215;;36431:59;;;;;;;;;;;;;;36290:215;36519:216;36562:15;36595:11;:24;;;36638:11;:19;;;36676:11;:18;;;36713:11;:21;;;36519:25;:216::i;36146:733::-;36775:22;36756:15;:41;;;;;;;;:::i;:::-;;36752:127;;36820:48;;;;;;;;;;;;;;36752:127;36911:7;:20;;;:38;;;36893:56;;:15;:56;36889:139;;;36972:45;;;;;;;;;;;;;;36889:139;3128:6:16;37042:7:22;:20;;;:42;;;:60;;;37038:144;;;37125:46;;;;;;;;;;;;;;37038:144;33390:3798;;;33268:3920;;:::o;77771:842::-;77928:68;-1:-1:-1;;;;;;;;;;;;;;;;;;;;;;;;77928:68:22;78043:563;;;;;;;;;;78098:27;;;;:73;;78152:19;78098:73;;;78128:21;78098:73;78043:563;;;;;;78204:52;;:99;;78282:21;78204:99;;;78259:20;78204:99;78043:563;;;;;;78346:52;;:249;;78525:9;78517:4;:17;;;;;;;;:::i;:::-;;:77;;78566:28;78346:249;;78517:77;78536:27;78346:249;;;78427:9;78419:4;:17;;;;;;;;:::i;:::-;;:76;;78468:27;78419:76;;;78439:26;78419:76;78043:563;;;;78008:598;77771:842;-1:-1:-1;;;;77771:842:22:o;45064:4465::-;45409:25;45466:19;45446:39;;45501:213;45547:6;45572:11;:23;;;45614:11;:24;;;45657:11;:19;;;45695:11;:18;;;45501:10;:28;;;:213;;:::i;:::-;45496:4027;;45734:7;:26;;;45730:878;;;45787:50;;;;;;;;;;;;;;45730:878;46312:20;;:60;;46308:286;;46396:81;46418:11;:17;;;46437:7;:19;;;46458:11;:18;;;46396:21;:81::i;:::-;45496:4027;;46308:286;46524:51;46538:11;:17;;;46557:11;:17;;;46524:13;:51::i;45496:4027::-;46638:29;46686:414;46729:7;46758:11;:21;;;46801:11;:24;;;46847:11;:19;;;46888:11;:23;;;46933:11;:35;;;46990:11;:34;;;47046:11;:36;;;46686:21;:414::i;:::-;46638:462;-1:-1:-1;47115:22:22;;47155:18;;;;:8;:18;:::i;:::-;:32;;;47151:285;;47224:8;:15;;;47207:32;;47295:11;:21;;;47278:14;:38;47274:148;;;47347:56;;;;;;;;;;;;;;47274:148;47454:25;;;;:39;;47450:426;;47577:21;;;;:38;;47641:41;;;47637:142;;;47717:39;;;;;;;;;;;;;;47637:142;47801:42;;;;47450:426;47894:18;;47890:818;;47964:36;3128:6:16;48020:7:22;:20;;;:43;;;48003:60;;:14;:60;:78;;;;;:::i;:::-;;;-1:-1:-1;48103:116:22;48125:18;;;;:8;:18;:::i;:::-;48145:7;:13;;;48160:11;48190:28;48173:14;:45;48103:10;:21;;;:116;;:::i;:::-;48279:7;:13;;;48266:26;;:9;:26;;;48262:414;;48320:31;;;:63;;;;;;48262:414;;;48442:32;;48438:216;;48506:121;48528:7;:20;;;:40;;;48570:7;:13;;;48585:11;48598:28;48506:10;:21;;;:121;;:::i;:::-;47932:762;47890:818;48726:31;;;;:35;48722:194;;48781:120;48803:7;:20;;;:40;;;48845:9;48856:11;48869:8;:31;;;48781:10;:21;;;:120;;:::i;:::-;48934:24;;;;:28;48930:165;;48982:98;49004:8;:25;;;49031:9;49042:11;49055:8;:24;;;48982:10;:21;;;:98;;:::i;:::-;49113:28;;;;:32;49109:171;;49165:100;49187:11;:23;;;49212:9;49223:11;49236:8;:28;;;49165:10;:21;;;:100;;:::i;:::-;49298:23;;;;:27;49294:144;;49345:78;49367:6;49375:9;49386:11;49399:8;:23;;;49345:10;:21;;;:78;;:::i;:::-;49452:60;49491:7;49500:11;49452:10;:38;;;:60;;:::i;:::-;46624:2899;;45064:4465;;;;;;;;;;:::o;39692:831:23:-;39972:22;40006:17;40039:216;40082:11;40112;:17;;;40148:11;:18;;;40185:56;40229:11;40185:43;:56::i;40039:216::-;40006:249;;40283:233;40323:12;40350:11;40376:9;40400:11;40426:14;40455:9;40478:28;40283:26;:233::i;8665:165:15:-;8798:23;;;8745:4;4154:21;;;:14;;;:21;;;;;;:26;;8768:55;8761:62;8665:165;-1:-1:-1;;;8665:165:15:o;11179:1645:24:-;11460:24;;11385:22;;;;;11517:210;11460:24;11594:6;11614:9;:56;;11668:1;11614:56;;;11626:24;;;;:31;11614:56;11684:33;;;:25;:33;;;402:66:28;11684:33:24;;;;;;11517:25;:210::i;:::-;11495:232;;11742:9;11738:268;;;11771:24;;;;:31;:45;;;11767:229;;11836:145;11876:12;11911;:22;;;11956:12;:24;;;11836:18;:145::i;:::-;12020:20;;:60;;12016:802;;12100:9;12096:318;;;12157:61;12184:6;12192:11;12205:12;12157:26;:61::i;:::-;12129:89;;-1:-1:-1;12129:89:24;-1:-1:-1;12016:802:24;;12096:318;12267:79;12312:6;12320:11;12333:12;12267:44;:79::i;:::-;12257:89;;12381:11;:18;;;12364:35;;12016:802;;;12461:18;;;;12498:20;;12461:18;;-1:-1:-1;12494:314:24;;12587:78;12631:6;12639:11;12652:12;12587:43;:78::i;:::-;12577:88;;12494:314;;;12714:79;12759:6;12767:11;12780:12;12714:44;:79::i;:::-;12704:89;;12494:314;11423:1401;;11179:1645;;;;;;;:::o;65990:4494:22:-;66333:29;-1:-1:-1;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;66333:29:22;66375:23;;;:35;;;66440:41;;;;66421:16;;66440:41;66556:293;;66699:50;66716:12;66730:7;66739:9;66699:16;:50::i;:::-;66587:162;-1:-1:-1;66587:162:22;;-1:-1:-1;66587:162:22;-1:-1:-1;66785:1:22;66768:18;;;66764:75;;66820:4;66806:18;;66764:75;66886:11;66882:1752;;;67111:24;;;;:38;;;67107:887;;67205:22;67177:7;:25;;;:50;;;67173:179;;;67262:67;;;;;;;;;;;;;;67173:179;67410:24;;;;67382:52;;;;67521:25;;;;3128:6:16;;67509:37:22;;;;67508:57;;67456:24;;;:109;;;67596:23;;;:51;;;;;;;;66882:1752;;67107:887;67676:38;;;;67672:322;;67738:52;;;;;3128:6:16;67840:34:22;;;67839:54;;67672:322;66882:1752;;;68036:29;;;68032:93;;-1:-1:-1;68105:1:22;68032:93;68155:17;;68151:469;;3128:6:16;68217:34:22;;;68216:54;68200:13;:70;68196:199;;;68305:67;;;;;;;;;;;;;;68196:199;68425:43;;;;;68490:24;;;:40;;;68561:23;;;:40;;;;;;;68151:469;68652:37;;;;68648:1155;;3128:6:16;68741:35:22;;;68740:55;68709:28;;;:86;;;68813:23;;;:55;;;;;;;;68891:23;;;;:27;;;68887:649;;68946:28;;;;:42;;;;:126;;;69049:23;69017:55;;:7;:28;;;:55;;;68946:126;68942:576;;;69100:29;3128:6:16;69188:7:22;:23;;;69161:50;;:8;:24;;;:50;:68;;;;;:::i;:::-;;;-1:-1:-1;69280:25:22;;69276:220;;69337:24;;;:49;;;;;;;69416:28;;;:53;;;;;;69276:220;69074:444;68942:576;3128:6:16;69640:7:22;:20;;;:49;;;69609:80;;:8;:28;;;:80;:98;;;;;:::i;:::-;;69554:31;;;:153;;;69725:28;;;:63;;;;;;;;68648:1155;69817:28;3128:6:16;69861:7:22;:20;;;:42;;;69849:54;;:9;:54;69848:74;;;;;:::i;:::-;;69817:105;;69974:20;69940:8;:31;;;:54;69936:532;;;70057:31;;;;70122:23;;;;70034:54;;;;70110:35;;70106:348;;;70204:23;;;;;70169:31;;;:58;;;;;;;-1:-1:-1;70249:27:22;;70106:348;;;70323:23;;;:36;;;;;;;70381:31;;;:54;;;70106:348;69996:472;69936:532;66858:3620;66364:4120;;;65990:4494;;;;;;;;;;:::o;82996:1234::-;83867:43;;;83129:7;83867:43;;;:34;:43;;;;;;;;83928:1;83919:10;;;83867:64;;;;;;;:89;;3364:1:16;83978:19:22;;;;83867:89;;;;;;;83859:139;83855:242;;84033:49;;;;;;;;;;;;;;83855:242;84146:7;84122:49;;84139:5;84122:49;84155:15;84122:49;;;;5292:14:29;5285:22;5267:41;;5255:2;5240:18;;5127:187;84122:49:22;;;;;;;;-1:-1:-1;;;84189:34:22;;:25;:34;;;402:66:28;84189:34:22;;;;;;;82996:1234::o;98727:1190::-;98927:11;:22;;;98909:15;:40;98905:119;;;98972:41;;;;;;;;;;;;;;98905:119;99055:11;:17;;;99038:34;;:7;:13;;;:34;;;99034:109;;99095:37;;;;;;;;;;;;;;99034:109;99189:18;;99157:51;;;;;;:31;:51;;;;;;;;99153:134;;;99231:45;;;;;;;;;;;;;;99153:134;99520:11;;99554;;;;;99587;;;;;99628:22;;;;99697:17;;;;8912:11:13;;8958:4;8949:14;;;8936:28;;121:86:16;8978:19:13;;9017:14;;;9010:30;;;;9060:14;;;9053:30;;;;9112:4;9103:14;;9096:30;9155:4;9146:14;;9139:30;;;;99681:35:22;;9198:4:13;9189:14;;9182:30;9246:20;;99323:511:22;;99350:399;;99384:22;;99350:16;:399::i;99425:310::-;99350:16;:399::i;:::-;99764:11;:13;;;99792:11;:13;;;99820:11;:13;;;99323;:511::i;:::-;99301:533;;:11;:18;;;:533;;;99297:614;;99857:43;;;;;;;;;;;;;;105332:177;8536:4:6;8530:11;8566:10;8554:23;;8606:4;8597:14;;8590:39;;;8658:4;8649:14;;8642:34;;;8712:4;8697:20;;105426:7:22;;105452:50;8336:397:6;97560:480:22;97681:12;97695:14;97713:63;97730:6;97738:9;:11;;;97751:9;:11;;;97764:9;:11;;;97713:16;:63::i;:::-;97680:96;;;;97799:6;97790:15;;:5;:15;;;;:26;;;;97809:7;97790:26;97786:248;;;97836:17;;;;:21;97832:192;;97877:49;97901:5;97908:6;97916:9;97877:23;:49::i;:::-;97832:192;;;97972:37;;;;;;;;;;;;;;79732:1774;79964:22;80020:17;80001:36;;79998:113;;;80060:40;;;;;;;;;;;;;;79998:113;-1:-1:-1;80237:52:22;;;80167:54;80237:52;;;:43;:52;;;;;;;;:65;;;;;;;;80321:23;;80138:19;;80167:54;80321:23;;:59;;;;;;;;:::i;:::-;;80317:1183;;80400:43;;;;;;;;:48;80396:238;;80468:71;;;;;;;;;;;;80562:57;;15818:25:29;;;80562:57:22;;;;80580:11;;80562:57;;15806:2:29;15791:18;80562:57:22;;;;;;;80396:238;80669:43;;;;;;;80652:60;;80648:159;;;80749:43;;;;;;;;-1:-1:-1;80648:159:22;80842:17;80825:14;:34;80821:136;;;80886:56;;;;;;;;;;;;;;80821:136;80999:70;;;;;;;;;;;;;;;;;;;;;;;81092:60;;15818:25:29;;;81092:60:22;;;;81115:11;;81092:60;;15806:2:29;15791:18;81092:60:22;;;;;;;81185:43;;;;;;;;:48;81181:221;;81253:60;;;;81279:34;81253:60;;;81336:51;;-1:-1:-1;5267:41:29;;81336:51:22;;;;81359:11;;81336:51;;5255:2:29;5240:18;81336:51:22;;;;;;;81181:221;80317:1183;;;81439:50;;;;;;;;;;;;;;11012:338;11125:52;;;11105:4;11125:52;;;:38;:52;;;;;:70;;11187:7;11125:61;:70::i;:::-;11121:112;;;-1:-1:-1;11218:4:22;11211:11;;11121:112;11249:94;;;;;16038:42:29;16107:15;;;11249:94:22;;;16089:34:29;16159:15;;16139:18;;;16132:43;11283:4:22;;11249:71;;16001:18:29;;11249:94:22;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;7553:933::-;7627:4;7647:27;;;7643:837;;-1:-1:-1;7697:4:22;;7553:933;-1:-1:-1;7553:933:22:o;7643:837::-;7739:25;7722:42;;:13;:42;;;7718:762;;-1:-1:-1;7787:4:22;;7553:933;-1:-1:-1;7553:933:22:o;7718:762::-;7829:21;7812:38;;:13;:38;;;7808:672;;-1:-1:-1;7873:4:22;;7553:933;-1:-1:-1;7553:933:22:o;7808:672::-;7915:21;7898:38;;:13;:38;;;7894:586;;-1:-1:-1;7959:4:22;;7553:933;-1:-1:-1;7553:933:22:o;7894:586::-;8001:21;7984:38;;:13;:38;;;7980:500;;-1:-1:-1;8045:4:22;;7553:933;-1:-1:-1;7553:933:22:o;7980:500::-;8087:21;8070:38;;:13;:38;;;8066:414;;-1:-1:-1;8131:4:22;;7553:933;-1:-1:-1;7553:933:22:o;8066:414::-;8390:79;3230:1:16;8455:13:22;8918:359;9035:59;;;;9015:4;9035:59;;;:46;:59;;;;;9015:4;;9035:83;;:59;9104:13;;9035:68;:83;:::i;:::-;9031:125;;;-1:-1:-1;9141:4:22;9134:11;;9031:125;9172:98;;;;;16388:10:29;16376:23;;9172:98:22;;;16358:42:29;16448;16436:55;;16416:18;;;16409:83;9206:4:22;;9172:70;;16331:18:29;;9172:98:22;16186:312:29;41200:670:22;41411:18;41431:20;41455:65;41481:15;41498:12;41512:7;41455:25;:65::i;:::-;41410:110;;;;41555:17;41587:6;41575:9;:18;;;;;:::i;:::-;;41555:38;;41624:12;41612:9;:24;41608:118;;;41663:48;;;;;;;;;;;;;;41608:118;41756:10;41744:9;:22;41740:114;;;41793:46;;;;;;;;;;;;;;41740:114;41531:333;41400:470;;41200:670;;;;;:::o;72556:304::-;72713:63;72740:11;72753:5;72760;72767:8;72713:26;:63::i;:::-;72709:145;;;72799:44;;;;;;;;;;;;;;72709:145;72556:304;;;;:::o;71938:200::-;72101:30;72115:5;72122:8;72101:13;:30::i;74503:352::-;74698:70;;;;;:39;16877:15:29;;;74698:70:22;;;16859:34:29;16929:15;;;16909:18;;;16902:43;16961:18;;;16954:34;;;17004:18;;;16997:34;;;17068:3;17047:19;;;17040:32;74678:4:22;17088:19:29;;;17081:30;;;74678:4:22;74698:39;;;;;;17128:19:29;;74698:70:22;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;74694:155;;-1:-1:-1;74833:5:22;74826:12;;74694:155;-1:-1:-1;74790:4:22;74783:11;;73479:338;73677:53;;;;;:34;17439:15:29;;;73677:53:22;;;17421:34:29;17491:15;;;17471:18;;;17464:43;17523:18;;;17516:34;;;73657:4:22;;73677:34;;;;;;17333:18:29;;73677:53:22;17158:398:29;76956:447:22;77175:11;:24;;;77073:323;;77140:11;:17;;;77073:323;;77109:7;:13;;;77073:323;;;77217:11;:23;;;77258:11;:25;;;77301:11;:19;;;77338:11;:18;;;77374:11;:21;;;77073:323;;;;;;;;;17830:42:29;17899:15;;;17881:34;;17951:15;;;;17946:2;17931:18;;17924:43;17998:2;17983:18;;17976:34;;;;18041:2;18026:18;;18019:34;18084:3;18069:19;;18062:35;;;;17807:3;17792:19;;17561:542;77073:323:22;;;;;;;;76956:447;;:::o;75681:445::-;75898:11;:24;;;75797:322;;75863:11;:17;;;75797:322;;75832:7;:13;;;75797:322;;;75940:11;:23;;;75981:11;:25;;;76024:11;:19;;;76061:11;:18;;;76097:11;:21;;;75797:322;;;;;;;;;17830:42:29;17899:15;;;17881:34;;17951:15;;;;17946:2;17931:18;;17924:43;17998:2;17983:18;;17976:34;;;;18041:2;18026:18;;18019:34;18084:3;18069:19;;18062:35;;;;17807:3;17792:19;;17561:542;76336:409:22;76553:11;:24;;;76452:286;;76518:11;:17;;;76452:286;;76487:7;:13;;;76452:286;;;76595:11;:23;;;76636:11;:25;;;76679:11;:19;;;76716:11;:21;;;76452:286;;;;;;;;18349:42:29;18418:15;;;18400:34;;18470:15;;;;18465:2;18450:18;;18443:43;18517:2;18502:18;;18495:34;18560:2;18545:18;;18538:34;;;;18326:3;18311:19;;18108:470;75065:407:22;75280:11;:24;;;75180:285;;75245:11;:17;;;75180:285;;75214:7;:13;;;75180:285;;;75322:11;:23;;;75363:11;:25;;;75406:11;:19;;;75443:11;:21;;;75180:285;;;;;;;;18349:42:29;18418:15;;;18400:34;;18470:15;;;;18465:2;18450:18;;18443:43;18517:2;18502:18;;18495:34;18560:2;18545:18;;18538:34;;;;18326:3;18311:19;;18108:470;81916:588:22;82032:18;;82028:470;;82140:52;;;82066:54;82140:52;;;:43;:52;;;;;;;;:65;;;;;;;;;82248:70;;;;;;;;;;;;;;;82347:58;;;82425:62;;15818:25:29;;;82140:65:22;;:52;:65;;82425:62;;15791:18:29;82425:62:22;;;;;;;82052:446;81916:588;;;:::o;84652:397::-;84762:43;;;3329:1:16;84762:43:22;;;:34;:43;;;;;;;;84823:1;84814:10;;;84762:64;;;;;;;:89;;3364:1:16;84873:19:22;;;;84762:89;;;;;;;84754:139;:147;84750:238;;84928:45;;;;;;;;;;;;;;84750:238;85013:29;;;;;;85027:5;;85013:29;;;;;84652:397;;:::o;40702:377:23:-;40778:12;40814:2;40805:6;:11;:26;;;-1:-1:-1;40820:11:23;;40805:26;40802:105;;;40854:42;;;;;;;;;;;;;;40802:105;40916:26;40945:36;;;;;;;;;;;;;;;;;41051:1;41047:14;;;;41028:34;;;41022:41;;40702:377;-1:-1:-1;;40702:377:23:o;31121:1933::-;31500:22;31555:25;;31618:9;31637:24;31500:22;31664:20;;;;31555:14;31664:20;:::i;:::-;31637:47;;;;31699:9;31694:397;31710:16;;;31694:397;;;31747:10;31760:1;31747:14;31765:1;31747:19;31743:249;;31806:56;31834:17;31853:5;;31859:1;31853:8;;;;;;;:::i;:::-;;;;;;;5809:12:13;5872:20;;;5912:4;5905:20;5975:4;5959:21;;;5732:264;31806:56:23;31786:76;;31743:249;;;31921:56;31949:5;;31955:1;31949:8;;;;;;;:::i;:::-;;;;;;;31959:17;5809:12:13;5872:20;;;5912:4;5905:20;5975:4;5959:21;;;5732:264;31921:56:23;31901:76;;31743:249;32020:1;32005:16;;;;32063:3;31694:397;;;-1:-1:-1;32105:18:23;;:32;;;32101:114;;32153:51;32172:7;32181:9;32192:11;32153:18;:51::i;:::-;32225:358;32260:11;:17;;;32292:9;32316:257;32350:22;32391:168;32440:62;32474:14;:20;;;;;;;;:::i;:::-;:27;;32440:33;:62;;:::i;:::-;32524:17;5809:12:13;5872:20;;;5912:4;5905:20;5975:4;5959:21;;;5732:264;32316:257:23;32225:21;:358::i;:::-;32598:20;;:60;;32594:454;;32691:235;32746:11;:17;;;32782:9;32810:11;:18;;;32847:11;:31;;;32896:11;:29;;;32691:37;:235::i;:::-;32940:19;;;:31;;;32674:252;-1:-1:-1;32594:454:23;;;33019:11;:18;;;33002:35;;32594:454;31524:1530;;;;31121:1933;;;;;;;;;:::o;13343:1127:24:-;13499:22;13523:12;13547:24;13574:12;:24;;;13547:51;;13681:12;:26;;;:42;;;13672:78;;;13764:40;13781:12;:22;;;13764:16;:40::i;:::-;13818:222;;;;;;;;13871:11;:18;;;13818:222;;;;13928:11;:31;;;13818:222;;;;13996:11;:29;;;13818:222;;;14054:11;:24;;;14092:11;:19;;;14125:6;14145:11;:23;;;14182:12;:26;;;:38;;;14241:11;:22;;;14278:11;2396:540:16;13672:670:24;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;13609:733;;-1:-1:-1;13609:733:24;-1:-1:-1;14373:17:24;14356:34;;14353:111;;;14413:40;;;;;;;;;;;;;;14353:111;13537:933;13343:1127;;;;;;:::o;14860:1024::-;15034:12;15058:24;15085:12;:24;;;15058:51;;15139:12;:26;;;:42;;;15130:96;;;15240:11;:24;;;15278:11;:19;;;15311:12;:26;;;:38;;;15363:11;:18;;;15395:11;:22;;;15431:6;15451:11;:23;;;15488:11;:18;;;15520:11;1797:548:16;15591:40:24;15608:12;:22;;;15591:16;:40::i;:::-;15130:511;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;15120:521;;15657:7;15652:226;;15824:6;15685:182;;15789:11;:17;;;15733:12;:26;;;:38;;;15685:182;15848:5;15685:182;;;;5292:14:29;5285:22;5267:41;;5255:2;5240:18;;5127:187;15685:182:24;;;;;;;;15652:226;15048:836;14860:1024;;;;;:::o;16274:958::-;16447:12;16471:24;16498:12;:24;;;16471:51;;16552:12;:26;;;:42;;;16543:95;;;16652:11;:24;;;16690:11;:19;;;16723:12;:26;;;:38;;;16775:11;:22;;;16811:6;16831:11;:23;;;16868:11;1797:548:16;16939:40:24;16956:12;:22;;;16939:16;:40::i;:::-;16543:446;;;;;;;;;;;;;;;;;;;;;;;:::i;111463:983:22:-;111601:16;111619:21;111642:12;111689:642;;;111755:9;111766:14;111782:8;111826:4;111820:11;111870:4;111865:3;111861:14;111855:4;111848:28;111905:10;111900:3;111893:23;111956:8;111950:3;111944:4;111940:14;111933:32;112005:10;111999:3;111993:4;111989:14;111982:34;112137:4;112131;112125;112118;112113:3;112109:14;112094:13;112087:5;112076:66;112068:4;112050:16;112047:26;112040:34;112036:107;112033:251;;;112185:4;112179:11;112166:24;;112235:4;112229:11;112211:29;;112261:5;;;112033:251;;112313:4;112301:16;;111689:642;;;;;;;;:::o;:::-;112380:50;112420:9;112411:7;112397:12;112380:50;:::i;:::-;112344:86;;;;;;111463:983;;;;;;;:::o;103739:334::-;103875:14;103901:12;103943:33;103960:6;103968:1;103971;103974;103943:16;:33::i;:::-;103923:53;-1:-1:-1;103923:53:22;-1:-1:-1;103986:81:22;;;;104019:37;;;;;;;;;;;;;;103986:81;103891:182;103739:334;;;;;;:::o;104730:355::-;104869:12;;104917:15;104913:19;;104909:75;;;-1:-1:-1;104956:4:22;;-1:-1:-1;104970:1:22;104948:25;;104909:75;105003:33;;;;;;;;;;;;22800:25:29;;;22873:4;22861:17;;22841:18;;;22834:45;;;;22895:18;;;22888:34;;;22938:18;;;22931:34;;;105003:33:22;;22772:19:29;;105003:33:22;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;105003:33:22;;;;;105057:20;;;;;-1:-1:-1;105003:33:22;-1:-1:-1;;104730:355:22;;;;;;;;:::o;100564:314::-;100721:74;100743:6;100751:4;100757:9;:11;;;100770:9;:11;;;100783:9;:11;;;100721:21;:74::i;:::-;100716:156;;100818:43;;;;;;;;;;;;;;42397:1050;42553:7;;42604:34;42585:15;:53;;;;;;;;:::i;:::-;;42581:534;;42702:45;;;42654;42702;;;:31;:45;;;;;;;;:54;;;;;;;;42775:35;;;;42770:173;;42837:91;;;;;23180:42:29;23168:55;;42837:91:22;;;23150:74:29;23240:18;;;23233:34;;;42871:4:22;;42837:68;;23123:18:29;;42837:91:22;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;42830:98;;;;;;;42770:173;42960:29;;;;;;;42956:149;;;43017:34;;;;;;;;-1:-1:-1;43053:36:22;;;;;;-1:-1:-1;43009:81:22;;42956:149;42640:475;42581:534;43185:50;;;43133:49;43185:50;;;:36;:50;;;;;;;;;43133:102;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;43245:156;;43307:39;;;;43348:41;;;;;43299:91;;;;;-1:-1:-1;43299:91:22;;-1:-1:-1;43299:91:22;;43245:156;43419:1;43422:17;43411:29;;;;;42397:1050;;;;;;;:::o;1992:1075:11:-;2137:12;2184:794;;;2250:8;2294:4;2288:11;2338:4;2333:3;2329:14;2323:4;2316:28;2373:10;2368:3;2361:23;2424:5;2418:3;2412:4;2408:14;2401:29;2470:3;2464;2458:4;2454:14;2447:27;2514:7;2508:3;2502:4;2498:14;2491:31;2600:4;2594;2588;2581;2576:3;2572:14;2569:1;2554:13;2547:5;2542:63;2539:392;;;2652:4;2634:16;2631:26;2628:154;;;-1:-1:-1;;2703:26:11;;2696:34;2755:5;;2628:154;2830:4;2824;2818;2803:32;-1:-1:-1;;2881:4:11;2875:11;2868:19;2908:5;;2539:392;;2960:4;2948:16;;2184:794;;;;;;;:::o;:::-;3002:49;3044:6;3040:2;3034:4;3020:12;3002:49;:::i;17403:294:24:-;17512:11;;17485:12;;17526:15;-1:-1:-1;17509:103:24;;;17564:37;;;;;;;;;;;;;;17509:103;17645:11;;;;;17658;;;;;17677;;17628:62;;;;;23709:19:29;;;;23744:12;;;23737:28;23803:3;23799:16;23817:66;23795:89;23781:12;;;23774:111;23901:12;;17628:62:24;;;;;;;;;;;;17621:69;;17403:294;;;:::o;101435:1809:22:-;101596:12;101628:15;101624:19;;101620:94;;;101666:37;;;;;;;;;;;;;;101620:94;101747:1413;;;101809:8;101853:4;101847:11;101953:13;101948:3;101941:26;102075:5;102068:4;102063:3;102059:14;102052:29;102195:4;102188;102183:3;102179:14;102172:28;102288:4;102281;102276:3;102272:14;102265:28;102466:2;102459:4;102454:3;102450:14;102443:26;102509:2;102502:4;102497:3;102493:14;102486:26;102552:2;102545:4;102540:3;102536:14;102529:26;102672:4;102667:3;102663:14;102657:4;102650:28;102946:4;102940;102934;102929:3;102920:7;102913:5;102902:49;102894:4;102876:16;102873:26;102866:34;102862:90;102859:287;;;-1:-1:-1;;103081:4:22;103075:11;103088:13;103072:30;103123:5;;101747:1413;103184:44;103226:1;103223;103220;103214:4;103206:6;103184:44;:::i;:::-;103173:55;101435:1809;-1:-1:-1;;;;;;101435:1809:22:o;-1:-1:-1:-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::o;:::-;;;:::i;:::-;:::o;14:409:29:-;86:2;80:9;128:6;116:19;;165:18;150:34;;186:22;;;147:62;144:242;;;242:77;239:1;232:88;343:4;340:1;333:15;371:4;368:1;361:15;144:242;402:2;395:22;14:409;:::o;428:406::-;495:4;489:11;;;527:17;;574:18;559:34;;595:22;;;556:62;553:242;;;651:77;648:1;641:88;752:4;749:1;742:15;780:4;777:1;770:15;839:196;907:20;;967:42;956:54;;946:65;;936:93;;1025:1;1022;1015:12;1040:1499;1092:5;1140:6;1128:9;1123:3;1119:19;1115:32;1112:52;;;1160:1;1157;1150:12;1112:52;1182:22;;:::i;:::-;1173:31;;1240:9;1227:23;1220:5;1213:38;1283;1317:2;1306:9;1302:18;1283:38;:::i;:::-;1278:2;1271:5;1267:14;1260:62;1354:38;1388:2;1377:9;1373:18;1354:38;:::i;:::-;1349:2;1342:5;1338:14;1331:62;1425:38;1459:2;1448:9;1444:18;1425:38;:::i;:::-;1420:2;1413:5;1409:14;1402:62;1497:39;1531:3;1520:9;1516:19;1497:39;:::i;:::-;1491:3;1484:5;1480:15;1473:64;1570:39;1604:3;1593:9;1589:19;1570:39;:::i;:::-;1564:3;1557:5;1553:15;1546:64;1643:39;1677:3;1666:9;1662:19;1643:39;:::i;:::-;1637:3;1626:15;;1619:64;1744:3;1729:19;;;1716:33;1699:15;;;1692:58;1769:3;1817:18;;;1804:32;1788:14;;;1781:56;1856:3;1904:18;;;1891:32;1875:14;;;1868:56;1943:3;1991:18;;;1978:32;1962:14;;;1955:56;2030:3;2078:18;;;2065:32;2049:14;;;2042:56;2117:3;2165:18;;;2152:32;2136:14;;;2129:56;2204:3;2252:18;;;2239:32;2223:14;;;2216:56;2291:3;2339:18;;;2326:32;2310:14;;;2303:56;2378:3;2426:18;;;2413:32;2397:14;;;2390:56;2465:3;2513:18;;;2500:32;2484:14;;;2477:56;;;;1630:5;1040:1499;-1:-1:-1;1040:1499:29:o;2544:699::-;2605:5;2653:4;2641:9;2636:3;2632:19;2628:30;2625:50;;;2671:1;2668;2661:12;2625:50;2704:2;2698:9;2746:4;2738:6;2734:17;2817:6;2805:10;2802:22;2781:18;2769:10;2766:34;2763:62;2760:242;;;2858:77;2855:1;2848:88;2959:4;2956:1;2949:15;2987:4;2984:1;2977:15;2760:242;3022:10;3018:2;3011:22;;3051:6;3042:15;;3094:9;3081:23;3073:6;3066:39;3166:2;3155:9;3151:18;3138:32;3133:2;3125:6;3121:15;3114:57;3232:2;3221:9;3217:18;3204:32;3199:2;3191:6;3187:15;3180:57;;2544:699;;;;:::o;3248:910::-;3306:5;3354:4;3342:9;3337:3;3333:19;3329:30;3326:50;;;3372:1;3369;3362:12;3326:50;3405:2;3399:9;3447:4;3439:6;3435:17;3518:6;3506:10;3503:22;3482:18;3470:10;3467:34;3464:62;3461:242;;;3559:77;3556:1;3549:88;3660:4;3657:1;3650:15;3688:4;3685:1;3678:15;3461:242;3719:2;3712:22;3752:6;-1:-1:-1;3752:6:29;3782:29;3801:9;3782:29;:::i;:::-;3774:6;3767:45;3845:38;3879:2;3868:9;3864:18;3845:38;:::i;:::-;3840:2;3832:6;3828:15;3821:63;3945:2;3934:9;3930:18;3917:32;3912:2;3904:6;3900:15;3893:57;4011:2;4000:9;3996:18;3983:32;3978:2;3970:6;3966:15;3959:57;4078:3;4067:9;4063:19;4050:33;4044:3;4036:6;4032:16;4025:59;4146:3;4135:9;4131:19;4118:33;4112:3;4104:6;4100:16;4093:59;;3248:910;;;;:::o;4163:156::-;4224:5;4269:2;4260:6;4255:3;4251:16;4247:25;4244:45;;;4285:1;4282;4275:12;4244:45;-1:-1:-1;4307:6:29;4163:156;-1:-1:-1;4163:156:29:o;4324:607::-;4522:6;4530;4538;4546;4599:3;4587:9;4578:7;4574:23;4570:33;4567:53;;;4616:1;4613;4606:12;4567:53;4639:43;4674:7;4663:9;4639:43;:::i;:::-;4629:53;;4701:62;4755:7;4749:3;4738:9;4734:19;4701:62;:::i;:::-;4691:72;;4782:59;4833:7;4827:3;4816:9;4812:19;4782:59;:::i;:::-;4772:69;;4860:65;4917:7;4911:3;4900:9;4896:19;4860:65;:::i;:::-;4850:75;;4324:607;;;;;;;:::o;4936:186::-;4995:6;5048:2;5036:9;5027:7;5023:23;5019:32;5016:52;;;5064:1;5061;5054:12;5016:52;5087:29;5106:9;5087:29;:::i;5319:1120::-;5379:5;5418:9;5413:3;5409:19;5448:6;5444:2;5440:15;5437:35;;;5468:1;5465;5458:12;5437:35;5501:2;5495:9;5543:4;5535:6;5531:17;5614:6;5602:10;5599:22;5578:18;5566:10;5563:34;5560:62;5557:242;;;5655:77;5652:1;5645:88;5756:4;5753:1;5746:15;5784:4;5781:1;5774:15;5557:242;5815:2;5808:22;5848:6;-1:-1:-1;5848:6:29;5878:39;5913:3;5902:9;5878:39;:::i;:::-;5870:6;5863:55;5953:58;6007:3;6001;5990:9;5986:19;5953:58;:::i;:::-;5946:4;5938:6;5934:17;5927:85;6045:55;6096:3;6090;6079:9;6075:19;6045:55;:::i;:::-;6040:2;6032:6;6028:15;6021:80;6194:2;6125:66;6121:2;6117:75;6113:84;6110:104;;;6210:1;6207;6200:12;6110:104;6238:17;;:::i;:::-;6223:32;;6280:39;6314:3;6303:9;6299:19;6280:39;:::i;:::-;6271:7;6264:56;6384:3;6373:9;6369:19;6356:33;6349:4;6340:7;6336:18;6329:61;6425:7;6418:4;6410:6;6406:17;6399:34;;;5319:1120;;;;:::o;6444:622::-;6614:6;6622;6630;6683:3;6671:9;6662:7;6658:23;6654:33;6651:53;;;6700:1;6697;6690:12;6651:53;6723:51;6766:7;6755:9;6723:51;:::i;:::-;6713:61;;6825:3;6814:9;6810:19;6797:33;6853:18;6845:6;6842:30;6839:50;;;6885:1;6882;6875:12;6839:50;6908:68;6968:7;6959:6;6948:9;6944:22;6908:68;:::i;:::-;6898:78;;;6995:65;7052:7;7046:3;7035:9;7031:19;6995:65;:::i;:::-;6985:75;;6444:622;;;;;:::o;7071:393::-;7157:8;7167:6;7221:3;7214:4;7206:6;7202:17;7198:27;7188:55;;7239:1;7236;7229:12;7188:55;-1:-1:-1;7262:20:29;;7305:18;7294:30;;7291:50;;;7337:1;7334;7327:12;7291:50;7374:4;7366:6;7362:17;7350:29;;7437:3;7430:4;7422;7414:6;7410:17;7402:6;7398:30;7394:41;7391:50;7388:70;;;7454:1;7451;7444:12;7388:70;7071:393;;;;;:::o;7469:390::-;7552:8;7562:6;7616:3;7609:4;7601:6;7597:17;7593:27;7583:55;;7634:1;7631;7624:12;7583:55;-1:-1:-1;7657:20:29;;7700:18;7689:30;;7686:50;;;7732:1;7729;7722:12;7686:50;7769:4;7761:6;7757:17;7745:29;;7832:3;7825:4;7817;7809:6;7805:17;7797:6;7793:30;7789:41;7786:50;7783:70;;;7849:1;7846;7839:12;7864:384;7944:8;7954:6;8008:3;8001:4;7993:6;7989:17;7985:27;7975:55;;8026:1;8023;8016:12;7975:55;-1:-1:-1;8049:20:29;;8092:18;8081:30;;8078:50;;;8124:1;8121;8114:12;8078:50;8161:4;8153:6;8149:17;8137:29;;8221:3;8214:4;8204:6;8201:1;8197:14;8189:6;8185:27;8181:38;8178:47;8175:67;;;8238:1;8235;8228:12;8253:1750;8565:6;8573;8581;8589;8597;8605;8613;8621;8674:3;8662:9;8653:7;8649:23;8645:33;8642:53;;;8691:1;8688;8681:12;8642:53;8731:9;8718:23;8760:18;8801:2;8793:6;8790:14;8787:34;;;8817:1;8814;8807:12;8787:34;8855:6;8844:9;8840:22;8830:32;;8900:7;8893:4;8889:2;8885:13;8881:27;8871:55;;8922:1;8919;8912:12;8871:55;8962:2;8949:16;8988:2;8980:6;8977:14;8974:34;;;9004:1;9001;8994:12;8974:34;9064:7;9057:4;9047:6;9039;9035:19;9031:2;9027:28;9023:39;9020:52;9017:72;;;9085:1;9082;9075:12;9017:72;9116:4;9108:13;;;;-1:-1:-1;9140:6:29;-1:-1:-1;9184:20:29;;;9171:34;;9217:16;;;9214:36;;;9246:1;9243;9236:12;9214:36;9285:95;9372:7;9361:8;9350:9;9346:24;9285:95;:::i;:::-;9399:8;;-1:-1:-1;9259:121:29;-1:-1:-1;9487:2:29;9472:18;;9459:32;;-1:-1:-1;9503:16:29;;;9500:36;;;9532:1;9529;9522:12;9500:36;9571:92;9655:7;9644:8;9633:9;9629:24;9571:92;:::i;:::-;9682:8;;-1:-1:-1;9545:118:29;-1:-1:-1;9770:2:29;9755:18;;9742:32;;-1:-1:-1;9786:16:29;;;9783:36;;;9815:1;9812;9805:12;9783:36;;9854:89;9935:7;9924:8;9913:9;9909:24;9854:89;:::i;:::-;8253:1750;;;;-1:-1:-1;8253:1750:29;;-1:-1:-1;8253:1750:29;;;;;;9962:8;-1:-1:-1;;;8253:1750:29:o;10008:390::-;10094:8;10104:6;10158:3;10151:4;10143:6;10139:17;10135:27;10125:55;;10176:1;10173;10166:12;10125:55;-1:-1:-1;10199:20:29;;10242:18;10231:30;;10228:50;;;10274:1;10271;10264:12;10228:50;10311:4;10303:6;10299:17;10287:29;;10371:3;10364:4;10354:6;10351:1;10347:14;10339:6;10335:27;10331:38;10328:47;10325:67;;;10388:1;10385;10378:12;10403:1391;10656:6;10664;10672;10680;10688;10696;10749:2;10737:9;10728:7;10724:23;10720:32;10717:52;;;10765:1;10762;10755:12;10717:52;10805:9;10792:23;10834:18;10875:2;10867:6;10864:14;10861:34;;;10891:1;10888;10881:12;10861:34;10929:6;10918:9;10914:22;10904:32;;10974:7;10967:4;10963:2;10959:13;10955:27;10945:55;;10996:1;10993;10986:12;10945:55;11036:2;11023:16;11062:2;11054:6;11051:14;11048:34;;;11078:1;11075;11068:12;11048:34;11138:7;11131:4;11121:6;11113;11109:19;11105:2;11101:28;11097:39;11094:52;11091:72;;;11159:1;11156;11149:12;11091:72;11190:4;11182:13;;;;-1:-1:-1;11214:6:29;-1:-1:-1;11258:20:29;;;11245:34;;11291:16;;;11288:36;;;11320:1;11317;11310:12;11288:36;11359:95;11446:7;11435:8;11424:9;11420:24;11359:95;:::i;:::-;11473:8;;-1:-1:-1;11333:121:29;-1:-1:-1;11561:2:29;11546:18;;11533:32;;-1:-1:-1;11577:16:29;;;11574:36;;;11606:1;11603;11596:12;11574:36;;11645:89;11726:7;11715:8;11704:9;11700:24;11645:89;:::i;:::-;10403:1391;;;;-1:-1:-1;10403:1391:29;;-1:-1:-1;10403:1391:29;;11753:8;;10403:1391;-1:-1:-1;;;10403:1391:29:o;12030:164::-;12106:13;;12155;;12148:21;12138:32;;12128:60;;12184:1;12181;12174:12;12199:202;12266:6;12319:2;12307:9;12298:7;12294:23;12290:32;12287:52;;;12335:1;12332;12325:12;12287:52;12358:37;12385:9;12358:37;:::i;12406:604::-;12499:4;12505:6;12565:11;12552:25;12655:66;12644:8;12628:14;12624:29;12620:102;12600:18;12596:127;12586:155;;12737:1;12734;12727:12;12586:155;12764:33;;12816:20;;;-1:-1:-1;12859:18:29;12848:30;;12845:50;;;12891:1;12888;12881:12;12845:50;12924:4;12912:17;;-1:-1:-1;12975:1:29;12971:14;;;12955;12951:35;12941:46;;12938:66;;;13000:1;12997;12990:12;13015:184;13067:77;13064:1;13057:88;13164:4;13161:1;13154:15;13188:4;13185:1;13178:15;13204:224;13286:6;13339:3;13327:9;13318:7;13314:23;13310:33;13307:53;;;13356:1;13353;13346:12;13307:53;13379:43;13414:7;13403:9;13379:43;:::i;13433:241::-;13524:6;13577:2;13565:9;13556:7;13552:23;13548:32;13545:52;;;13593:1;13590;13583:12;13545:52;13616;13660:7;13649:9;13616:52;:::i;13679:236::-;13767:6;13820:3;13808:9;13799:7;13795:23;13791:33;13788:53;;;13837:1;13834;13827:12;13788:53;13860:49;13901:7;13890:9;13860:49;:::i;13920:390::-;14020:4;14078:11;14065:25;14168:66;14157:8;14141:14;14137:29;14133:102;14113:18;14109:127;14099:155;;14250:1;14247;14240:12;14099:155;14271:33;;;;;13920:390;-1:-1:-1;;13920:390:29:o;14315:240::-;14405:6;14458:3;14446:9;14437:7;14433:23;14429:33;14426:53;;;14475:1;14472;14465:12;14426:53;14498:51;14541:7;14530:9;14498:51;:::i;14560:184::-;14612:77;14609:1;14602:88;14709:4;14706:1;14699:15;14733:4;14730:1;14723:15;14749:184;14801:77;14798:1;14791:88;14898:4;14895:1;14888:15;14922:4;14919:1;14912:15;14938:112;14970:1;14996;14986:35;;15001:18;;:::i;:::-;-1:-1:-1;15035:9:29;;14938:112::o;15055:184::-;15107:77;15104:1;15097:88;15204:4;15201:1;15194:15;15228:4;15225:1;15218:15;15244:120;15284:1;15310;15300:35;;15315:18;;:::i;:::-;-1:-1:-1;15349:9:29;;15244:120::o;15369:168::-;15442:9;;;15473;;15490:15;;;15484:22;;15470:37;15460:71;;15511:18;;:::i;15542:125::-;15607:9;;;15628:10;;;15625:36;;;15641:18;;:::i;18583:481::-;18624:3;18662:5;18656:12;18689:6;18684:3;18677:19;18714:1;18724:162;18738:6;18735:1;18732:13;18724:162;;;18800:4;18856:13;;;18852:22;;18846:29;18828:11;;;18824:20;;18817:59;18753:12;18724:162;;;18728:3;18931:1;18924:4;18915:6;18910:3;18906:16;18902:27;18895:38;19053:4;18983:66;18978:2;18970:6;18966:15;18962:88;18957:3;18953:98;18949:109;18942:116;;;18583:481;;;;:::o;19172:1172::-;19596:4;19625:3;19655:2;19644:9;19637:21;19675:44;19715:2;19704:9;19700:18;19692:6;19675:44;:::i;:::-;19667:52;;;19761:6;19755:13;19750:2;19739:9;19735:18;19728:41;19823:2;19815:6;19811:15;19805:22;19800:2;19789:9;19785:18;19778:50;19882:2;19874:6;19870:15;19864:22;19859:2;19848:9;19844:18;19837:50;19906:42;19997:2;19989:6;19985:15;19979:3;19968:9;19964:19;19957:44;20038:6;20032:3;20021:9;20017:19;20010:35;20094:2;20086:6;20082:15;20076:3;20065:9;20061:19;20054:44;20147:2;20139:6;20135:15;20129:3;20118:9;20114:19;20107:44;;20188:6;20182:3;20171:9;20167:19;20160:35;20204:46;20245:3;20234:9;20230:19;20222:6;19145:14;19134:26;19122:39;;19069:98;20204:46;20281:3;20266:19;;20259:35;;;;20325:3;20310:19;20303:35;19172:1172;;-1:-1:-1;;;;;;;;19172:1172:29:o;20349:263::-;20425:6;20433;20486:2;20474:9;20465:7;20461:23;20457:32;20454:52;;;20502:1;20499;20492:12;20454:52;20531:9;20525:16;20515:26;;20560:46;20602:2;20591:9;20587:18;20560:46;:::i;:::-;20550:56;;20349:263;;;;;:::o;20617:1046::-;21008:4;21037:3;21059:42;21140:2;21132:6;21128:15;21117:9;21110:34;21180:6;21175:2;21164:9;21160:18;21153:34;21223:6;21218:2;21207:9;21203:18;21196:34;21266:6;21261:2;21250:9;21246:18;21239:34;21310:6;21304:3;21293:9;21289:19;21282:35;21366:2;21358:6;21354:15;21348:3;21337:9;21333:19;21326:44;21419:2;21411:6;21407:15;21401:3;21390:9;21386:19;21379:44;;21460:6;21454:3;21443:9;21439:19;21432:35;21504:6;21498:3;21487:9;21483:19;21476:35;21548:6;21542:3;21531:9;21527:19;21520:35;21592:2;21586:3;21575:9;21571:19;21564:31;21612:45;21653:2;21642:9;21638:18;21629:7;21612:45;:::i;:::-;21604:53;20617:1046;-1:-1:-1;;;;;;;;;;;;;;20617:1046:29:o;21668:900::-;22002:4;22031:3;22053:42;22134:2;22126:6;22122:15;22111:9;22104:34;22174:6;22169:2;22158:9;22154:18;22147:34;22217:6;22212:2;22201:9;22197:18;22190:34;22260:6;22255:2;22244:9;22240:18;22233:34;22316:2;22308:6;22304:15;22298:3;22287:9;22283:19;22276:44;22369:2;22361:6;22357:15;22351:3;22340:9;22336:19;22329:44;;22410:6;22404:3;22393:9;22389:19;22382:35;22454:6;22448:3;22437:9;22433:19;22426:35;22498:2;22492:3;22481:9;22477:19;22470:31;22518:44;22558:2;22547:9;22543:18;22535:6;22518:44;:::i;:::-;22510:52;21668:900;-1:-1:-1;;;;;;;;;;;;21668:900:29:o;23278:245::-;23357:6;23365;23418:2;23406:9;23397:7;23393:23;23389:32;23386:52;;;23434:1;23431;23424:12;23386:52;-1:-1:-1;;23457:16:29;;23513:2;23498:18;;;23492:25;23457:16;;23492:25;;-1:-1:-1;23278:245:29:o;23924:184::-;23976:77;23973:1;23966:88;24073:4;24070:1;24063:15;24097:4;24094:1;24087:15
Swarm Source
ipfs://75aac895672e0a96b09542e79949004bbdc52b6c0b74f5956c9c6973376a1130
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 30 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|
[ Download: CSV Export ]
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.