ETH Price: $3,486.46 (+0.46%)

Contract

0x9A1D0059f5534E7a6C6c4DAe390ebD3a731Bd7Dc
 

Overview

ETH Balance

0 ETH

Eth Value

$0.00

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To

There are no matching entries

1 Internal Transaction found.

Latest 1 internal transaction

Advanced mode:
Parent Transaction Hash Block
From
To
191427752024-02-02 19:24:35327 days ago1706901875  Contract Creation0 ETH
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
ModuleTrades

Compiler Version
v0.8.19+commit.7dd6d404

Optimization Enabled:
Yes with 30000 runs

Other Settings:
paris EvmVersion
File 1 of 28 : ModuleTrades.sol
// SPDX-License-Identifier: BSL-1.1
pragma solidity 0.8.19;

import "./PaymentProcessorModule.sol";

/*
                                                     @@@@@@@@@@@@@@             
                                                    @@@@@@@@@@@@@@@@@@(         
                                                   @@@@@@@@@@@@@@@@@@@@@        
                                                  @@@@@@@@@@@@@@@@@@@@@@@@      
                                                           #@@@@@@@@@@@@@@      
                                                               @@@@@@@@@@@@     
                            @@@@@@@@@@@@@@*                    @@@@@@@@@@@@     
                           @@@@@@@@@@@@@@@     @               @@@@@@@@@@@@     
                          @@@@@@@@@@@@@@@     @                @@@@@@@@@@@      
                         @@@@@@@@@@@@@@@     @@               @@@@@@@@@@@@      
                        @@@@@@@@@@@@@@@     #@@             @@@@@@@@@@@@/       
                        @@@@@@@@@@@@@@.     @@@@@@@@@@@@@@@@@@@@@@@@@@@         
                       @@@@@@@@@@@@@@@     @@@@@@@@@@@@@@@@@@@@@@@@@            
                      @@@@@@@@@@@@@@@     @@@@@@@@@@@@@@@@@@@@@@@@@             
                     @@@@@@@@@@@@@@@     @@@@@@@@@@@@@@@@@@@@@@@@@@@@           
                    @@@@@@@@@@@@@@@     @@@@@&%%%%%%%%&&@@@@@@@@@@@@@@          
                    @@@@@@@@@@@@@@      @@@@@               @@@@@@@@@@@         
                   @@@@@@@@@@@@@@@     @@@@@                 @@@@@@@@@@@        
                  @@@@@@@@@@@@@@@     @@@@@@                 @@@@@@@@@@@        
                 @@@@@@@@@@@@@@@     @@@@@@@                 @@@@@@@@@@@        
                @@@@@@@@@@@@@@@     @@@@@@@                 @@@@@@@@@@@&        
                @@@@@@@@@@@@@@     *@@@@@@@               (@@@@@@@@@@@@         
               @@@@@@@@@@@@@@@     @@@@@@@@             @@@@@@@@@@@@@@          
              @@@@@@@@@@@@@@@     @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@           
             @@@@@@@@@@@@@@@     @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@            
            @@@@@@@@@@@@@@@     @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@              
           .@@@@@@@@@@@@@@     @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@                 
           @@@@@@@@@@@@@@%     @@@@@@@@@@@@@@@@@@@@@@@@(                        
          @@@@@@@@@@@@@@@                                                       
         @@@@@@@@@@@@@@@                                                        
        @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@                                         
       @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@                                          
       @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@&                                          
      @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@                                           
 
* @title Payment Processor
* @custom:version 2.0.0
* @author Limit Break, Inc.
*/ 

contract ModuleTrades is PaymentProcessorModule {

    constructor(address configurationContract) PaymentProcessorModule(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 maker or taker is a banned account for the collection.
     * @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  domainSeparator The domain separator to be used when verifying the order signature.
     * @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(
        bytes32 domainSeparator, 
        Order memory saleDetails, 
        SignatureECDSA memory sellerSignature,
        Cosignature memory cosignature,
        FeeOnTop memory feeOnTop
    ) public payable {
        uint256 appendedDataLength;
        unchecked {
            appendedDataLength = msg.data.length - BASE_MSG_LENGTH_BUY_LISTING;
        }

        TradeContext memory context = TradeContext({
            domainSeparator: domainSeparator,
            channel: msg.sender,
            taker: appendedDataLength == 20 ? _msgSender() : msg.sender,
            disablePartialFill: true
        });

        uint256 remainingNativeProceeds = 
            _executeOrderBuySide(
                context,
                msg.value,
                saleDetails, 
                sellerSignature,
                cosignature,
                feeOnTop
            );

        if (remainingNativeProceeds > 0) {
            _pushProceeds(wrappedNativeCoinAddress, remainingNativeProceeds, gasleft());
            IERC20(wrappedNativeCoinAddress).
                transferFrom(address(this), context.taker, remainingNativeProceeds);
        }
    }

    /**
     * @notice Executes an offer accept 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 maker or taker is a banned account for the collection.
     * @dev    Throws when the maker does not have sufficient funds to complete the purchase.
     * @dev    Throws when the token transfer fails for any reason such as lack of approvals or token not owned by the taker.
     * @dev    Throws when the token the offer is being accepted for does not match the conditions set by the 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    <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 `AcceptOfferERC721` event has been emitted for a ERC721 sale.
     * @dev    6. An `AcceptOfferERC1155` event has been emitted for a ERC1155 sale.
     * @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  domainSeparator        The domain separator to be used when verifying the order signature.
     * @param  isCollectionLevelOffer The flag to indicate if an offer is for any token in the collection.
     * @param  saleDetails            The order execution details.
     * @param  buyerSignature         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 acceptOffer(
        bytes32 domainSeparator, 
        bool isCollectionLevelOffer, 
        Order memory saleDetails, 
        SignatureECDSA memory buyerSignature,
        TokenSetProof memory tokenSetProof,
        Cosignature memory cosignature,
        FeeOnTop memory feeOnTop
    ) public {
        uint256 appendedDataLength;
        unchecked {
            appendedDataLength = 
                msg.data.length - 
                BASE_MSG_LENGTH_ACCEPT_OFFER - 
                (PROOF_ELEMENT_SIZE * tokenSetProof.proof.length);
        }

        _executeOrderSellSide(
            TradeContext({
                domainSeparator: domainSeparator,
                channel: msg.sender,
                taker: appendedDataLength == 20 ? _msgSender() : msg.sender,
                disablePartialFill: true
            }),
            isCollectionLevelOffer, 
            saleDetails, 
            buyerSignature,
            tokenSetProof,
            cosignature,
            feeOnTop);
    }

    /**
     * @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 any maker or taker is a banned account for the collection.
     * @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  domainSeparator  The domain separator to be used when verifying the order signature.
     * @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(
        bytes32 domainSeparator, 
        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 remainingNativeProceeds = msg.value;

        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({
            domainSeparator: domainSeparator,
            channel: msg.sender,
            taker: appendedDataLength == 20 ? _msgSender() : msg.sender,
            disablePartialFill: false
        });

        Order memory saleDetails;
        SignatureECDSA memory sellerSignature;
        Cosignature memory cosignature;
        FeeOnTop memory feeOnTop;

        for (uint256 i = 0; i < saleDetailsArray.length;) {
            saleDetails = saleDetailsArray[i];
            sellerSignature = sellerSignatures[i];
            cosignature = cosignatures[i];
            feeOnTop = feesOnTop[i];

            if(saleDetails.paymentMethod == address(0)) {
                remainingNativeProceeds = 
                    _executeOrderBuySide(
                        context, 
                        remainingNativeProceeds, 
                        saleDetails, 
                        sellerSignature, 
                        cosignature, 
                        feeOnTop);
            } else {
                _executeOrderBuySide(context, 0, saleDetails, sellerSignature, cosignature, feeOnTop);
            }

            unchecked {
                ++i;
            }
        }

        if (remainingNativeProceeds > 0) {
            _pushProceeds(wrappedNativeCoinAddress, remainingNativeProceeds, gasleft());
            IERC20(wrappedNativeCoinAddress).
                transferFrom(address(this), context.taker, remainingNativeProceeds);
        }
    }

    /**
     * @notice Executes an accept offer 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 any maker or taker is a banned account for the collection.
     * @dev    Throws when a maker does not have sufficient funds to complete the purchase.
     * @dev    Throws when the token an offer is being accepted for does not match the conditions set by the maker.
     * @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    <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. `AcceptOfferERC721` events have been emitted for each ERC721 sale.
     * @dev    6. `AcceptOfferERC1155` events have been emitted for each ERC1155 sale.
     * @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  domainSeparator The domain separator to be used when verifying the order signature.
     * @param  params          The parameters for the bulk offers being accepted.
     */
    function bulkAcceptOffers(
        bytes32 domainSeparator, 
        BulkAcceptOffersParams memory params
    ) public {
        if (params.saleDetailsArray.length != params.isCollectionLevelOfferArray.length) {
            revert PaymentProcessor__InputArrayLengthMismatch();
        }

        if (params.saleDetailsArray.length != params.buyerSignaturesArray.length) {
            revert PaymentProcessor__InputArrayLengthMismatch();
        }

        if (params.saleDetailsArray.length != params.tokenSetProofsArray.length) {
            revert PaymentProcessor__InputArrayLengthMismatch();
        }

        if (params.saleDetailsArray.length != params.cosignaturesArray.length) {
            revert PaymentProcessor__InputArrayLengthMismatch();
        }

        if (params.saleDetailsArray.length != params.feesOnTopArray.length) {
            revert PaymentProcessor__InputArrayLengthMismatch();
        }

        if (params.saleDetailsArray.length == 0) {
            revert PaymentProcessor__InputArrayLengthCannotBeZero();
        }

        uint256 appendedDataLength;
        unchecked {
            appendedDataLength = 
                msg.data.length - 
                BASE_MSG_LENGTH_BULK_ACCEPT_OFFERS - 
                (BASE_MSG_LENGTH_BULK_ACCEPT_OFFERS_PER_ITEM * params.saleDetailsArray.length);

            for (uint256 i = 0; i < params.tokenSetProofsArray.length;) {
                appendedDataLength -= PROOF_ELEMENT_SIZE * params.tokenSetProofsArray[i].proof.length;
                ++i;
            }
        }

        TradeContext memory context = TradeContext({
            domainSeparator: domainSeparator,
            channel: msg.sender,
            taker: appendedDataLength == 20 ? _msgSender() : msg.sender,
            disablePartialFill: false
        });

        for (uint256 i = 0; i < params.saleDetailsArray.length;) {
            _executeOrderSellSide(
                context,
                params.isCollectionLevelOfferArray[i], 
                params.saleDetailsArray[i], 
                params.buyerSignaturesArray[i],
                params.tokenSetProofsArray[i],
                params.cosignaturesArray[i],
                params.feesOnTopArray[i]);

            unchecked {
                ++i;
            }
        }
    }
}

File 2 of 28 : PaymentProcessorModule.sol
// SPDX-License-Identifier: BSL-1.1
pragma solidity 0.8.19;

import "../IOwnable.sol";
import "../interfaces/IPaymentProcessorConfiguration.sol";
import "../interfaces/IPaymentProcessorEvents.sol";
import "../storage/PaymentProcessorStorageAccess.sol";
import "../Constants.sol";
import "../Errors.sol";

import "@openzeppelin/contracts/access/IAccessControl.sol";
import "@openzeppelin/contracts/interfaces/IERC1271.sol";
import "@openzeppelin/contracts/interfaces/IERC2981.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts/token/ERC721/IERC721.sol";
import "@openzeppelin/contracts/token/ERC1155/IERC1155.sol";
import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
import "@openzeppelin/contracts/utils/cryptography/MerkleProof.sol";

import {TrustedForwarderERC2771Context} from "@limitbreak/trusted-forwarder/TrustedForwarderERC2771Context.sol";

/*
                                                     @@@@@@@@@@@@@@             
                                                    @@@@@@@@@@@@@@@@@@(         
                                                   @@@@@@@@@@@@@@@@@@@@@        
                                                  @@@@@@@@@@@@@@@@@@@@@@@@      
                                                           #@@@@@@@@@@@@@@      
                                                               @@@@@@@@@@@@     
                            @@@@@@@@@@@@@@*                    @@@@@@@@@@@@     
                           @@@@@@@@@@@@@@@     @               @@@@@@@@@@@@     
                          @@@@@@@@@@@@@@@     @                @@@@@@@@@@@      
                         @@@@@@@@@@@@@@@     @@               @@@@@@@@@@@@      
                        @@@@@@@@@@@@@@@     #@@             @@@@@@@@@@@@/       
                        @@@@@@@@@@@@@@.     @@@@@@@@@@@@@@@@@@@@@@@@@@@         
                       @@@@@@@@@@@@@@@     @@@@@@@@@@@@@@@@@@@@@@@@@            
                      @@@@@@@@@@@@@@@     @@@@@@@@@@@@@@@@@@@@@@@@@             
                     @@@@@@@@@@@@@@@     @@@@@@@@@@@@@@@@@@@@@@@@@@@@           
                    @@@@@@@@@@@@@@@     @@@@@&%%%%%%%%&&@@@@@@@@@@@@@@          
                    @@@@@@@@@@@@@@      @@@@@               @@@@@@@@@@@         
                   @@@@@@@@@@@@@@@     @@@@@                 @@@@@@@@@@@        
                  @@@@@@@@@@@@@@@     @@@@@@                 @@@@@@@@@@@        
                 @@@@@@@@@@@@@@@     @@@@@@@                 @@@@@@@@@@@        
                @@@@@@@@@@@@@@@     @@@@@@@                 @@@@@@@@@@@&        
                @@@@@@@@@@@@@@     *@@@@@@@               (@@@@@@@@@@@@         
               @@@@@@@@@@@@@@@     @@@@@@@@             @@@@@@@@@@@@@@          
              @@@@@@@@@@@@@@@     @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@           
             @@@@@@@@@@@@@@@     @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@            
            @@@@@@@@@@@@@@@     @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@              
           .@@@@@@@@@@@@@@     @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@                 
           @@@@@@@@@@@@@@%     @@@@@@@@@@@@@@@@@@@@@@@@(                        
          @@@@@@@@@@@@@@@                                                       
         @@@@@@@@@@@@@@@                                                        
        @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@                                         
       @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@                                          
       @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@&                                          
      @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@                                           
 
* @title Payment Processor
* @custom:version 2.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 amount of gas units to be supplied with native token transfers.
    uint256 private immutable pushPaymentGasLimit;

    /// @dev The address of the ERC20 contract used for wrapped native token.
    address public immutable wrappedNativeCoinAddress;

    /// @dev The first default payment method defined at contract deployment. Immutable to save SLOAD cost.
    address private immutable defaultPaymentMethod1;

    /// @dev The second default payment method defined at contract deployment. Immutable to save SLOAD cost.
    address private immutable defaultPaymentMethod2;

    /// @dev The third default payment method defined at contract deployment. Immutable to save SLOAD cost.
    address private immutable defaultPaymentMethod3;

    /// @dev The fourth default payment method defined at contract deployment. Immutable to save SLOAD cost.
    address private immutable defaultPaymentMethod4;

    constructor(address configurationContract)
    TrustedForwarderERC2771Context(
        IPaymentProcessorConfiguration(configurationContract).getPaymentProcessorModuleERC2771ContextParams()
    ) {
        (
            uint32 pushPaymentGasLimit_,
            address wrappedNativeCoinAddress_,
            DefaultPaymentMethods memory defaultPaymentMethods
        ) = IPaymentProcessorConfiguration(configurationContract).getPaymentProcessorModuleDeploymentParams();
        
        if (pushPaymentGasLimit_ == 0 || wrappedNativeCoinAddress_ == address(0)) {
            revert PaymentProcessor__InvalidConstructorArguments();
        }

        pushPaymentGasLimit = pushPaymentGasLimit_;
        wrappedNativeCoinAddress = wrappedNativeCoinAddress_;
        defaultPaymentMethod1 = defaultPaymentMethods.defaultPaymentMethod1;
        defaultPaymentMethod2 = defaultPaymentMethods.defaultPaymentMethod2;
        defaultPaymentMethod3 = defaultPaymentMethods.defaultPaymentMethod3;
        defaultPaymentMethod4 = defaultPaymentMethods.defaultPaymentMethod4;
    }

    /*************************************************************************/
    /*                        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.
     */
    function _isDefaultPaymentMethod(address paymentMethod) internal view returns (bool) {
        if (paymentMethod == address(0)) {
            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 appStorage().collectionPaymentMethodWhitelists[DEFAULT_PAYMENT_METHOD_WHITELIST_ID].contains(paymentMethod);
        }
    }

    /**
     * @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[](5);
        defaultPaymentMethods[0] = address(0);
        defaultPaymentMethods[1] = defaultPaymentMethod1;
        defaultPaymentMethods[2] = defaultPaymentMethod2;
        defaultPaymentMethods[3] = defaultPaymentMethod3;
        defaultPaymentMethods[4] = defaultPaymentMethod4;
        return defaultPaymentMethods;
    }

    /*************************************************************************/
    /*                            Order Execution                            */
    /*************************************************************************/

    /**
     * @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 memory feeOnTop
    ) internal returns (uint256 endingNativeFunds) {
        uint248 quantityToFill = _verifySaleApproval(
            context, 
            saleDetails, 
            signedSellOrder, 
            cosignature);

        if (quantityToFill != saleDetails.amount) {
            if (saleDetails.itemPrice % saleDetails.amount != 0) {
                revert PaymentProcessor__PartialFillsNotSupportedForNonDivisibleItems();
            }

            saleDetails.itemPrice = saleDetails.itemPrice / saleDetails.amount * quantityToFill;
            saleDetails.amount = quantityToFill;
        }

        RoyaltyBackfillAndBounty memory royaltyBackfillAndBounty = _validateBasicOrderDetails(context, saleDetails);

        endingNativeFunds = _fulfillSingleOrderWithFeeOnTop(
            startingNativeFunds,
            context,
            context.taker,
            saleDetails.maker,
            IERC20(saleDetails.paymentMethod),
            _getOrderFulfillmentFunctionPointers(Sides.Buy, saleDetails.paymentMethod, saleDetails.protocol),
            saleDetails,
            royaltyBackfillAndBounty,
            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  isCollectionLevelOrder The flag to indicate if an offer is for any token in the collection.
     * @param  saleDetails            The order execution details.
     * @param  buyerSignature         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,
        bool isCollectionLevelOrder, 
        Order memory saleDetails,
        SignatureECDSA memory buyerSignature,
        TokenSetProof memory tokenSetProof,
        Cosignature memory cosignature,
        FeeOnTop memory feeOnTop
    ) internal {
        if (saleDetails.paymentMethod == address(0)) {
            revert PaymentProcessor__BadPaymentMethod();
        }

        uint248 quantityToFill;

        if (isCollectionLevelOrder) {
            if (tokenSetProof.rootHash == bytes32(0)) {
                quantityToFill = _verifyCollectionOffer(
                    context, 
                    saleDetails, 
                    buyerSignature, 
                    cosignature);
            } else {
                if(!MerkleProof.verify(
                    tokenSetProof.proof, 
                    tokenSetProof.rootHash, 
                    keccak256(abi.encode(saleDetails.tokenAddress, saleDetails.tokenId)))) {
                    revert PaymentProcessor__IncorrectTokenSetMerkleProof();
                }

                quantityToFill = _verifyTokenSetOffer(
                    context, 
                    saleDetails, 
                    buyerSignature, 
                    tokenSetProof, 
                    cosignature);
            }
        } else {
            quantityToFill = _verifyItemOffer(
                context,
                saleDetails, 
                buyerSignature, 
                cosignature);
        }

        if (quantityToFill != saleDetails.amount) {
            if (saleDetails.itemPrice % saleDetails.amount != 0) {
                revert PaymentProcessor__PartialFillsNotSupportedForNonDivisibleItems();
            }
            
            saleDetails.itemPrice = saleDetails.itemPrice / saleDetails.amount * quantityToFill;
            saleDetails.amount = quantityToFill;
        }

        RoyaltyBackfillAndBounty memory royaltyBackfillAndBounty = _validateBasicOrderDetails(context, saleDetails);

        _fulfillSingleOrderWithFeeOnTop(
            0,
            context,
            saleDetails.maker,
            context.taker,
            IERC20(saleDetails.paymentMethod),
            _getOrderFulfillmentFunctionPointers(Sides.Sell, saleDetails.paymentMethod, saleDetails.protocol),
            saleDetails,
            royaltyBackfillAndBounty,
            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 memory feeOnTop,
        SweepOrder memory sweepOrder,
        SweepItem[] memory items,
        SignatureECDSA[] memory signedSellOrders,
        Cosignature[] memory cosignatures
    ) internal returns (uint256 endingNativeFunds) {

        if (sweepOrder.protocol == OrderProtocols.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();
        }

        (Order[] memory saleDetailsBatch, RoyaltyBackfillAndBounty memory royaltyBackfillAndBounty) = 
            _validateSweepOrder(
                context,
                feeOnTop,
                sweepOrder,
                items,
                signedSellOrders,
                cosignatures
            );

        endingNativeFunds = _fulfillSweepOrderWithFeeOnTop(
            context,
            startingNativeFunds,
            SweepCollectionComputeAndDistributeProceedsParams({
                paymentCoin: IERC20(sweepOrder.paymentMethod),
                fnPointers: _getOrderFulfillmentFunctionPointers(
                    Sides.Buy, 
                    sweepOrder.paymentMethod, 
                    sweepOrder.protocol),
                feeOnTop: feeOnTop,
                royaltyBackfillAndBounty: royaltyBackfillAndBounty,
                saleDetailsBatch: saleDetailsBatch
            })
        );
    }

    /*************************************************************************/
    /*                           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 maker or taker is a banned account for the collection.
     * @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.
     * 
     * @return royaltyBackfillAndBounty The on-chain royalty backfill and bounty information defined by the creator.
     */
    function _validateBasicOrderDetails(
        TradeContext memory context,
        Order memory saleDetails
    ) private view returns (RoyaltyBackfillAndBounty memory royaltyBackfillAndBounty) {
        if (saleDetails.protocol == OrderProtocols.ERC721_FILL_OR_KILL) {
            if (saleDetails.amount != ONE) {
                revert PaymentProcessor__AmountForERC721SalesMustEqualOne();
            }
        } else {
            if (saleDetails.amount == 0) {
                revert PaymentProcessor__AmountForERC1155SalesGreaterThanZero();
            }
        }

        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];

        PaymentSettings paymentSettings = paymentSettingsForCollection.paymentSettings;
        royaltyBackfillAndBounty.backfillNumerator = paymentSettingsForCollection.royaltyBackfillNumerator;
        royaltyBackfillAndBounty.bountyNumerator = paymentSettingsForCollection.royaltyBountyNumerator;

        if (paymentSettingsForCollection.blockBannedAccounts) {
            EnumerableSet.AddressSet storage bannedAccounts = 
                appStorage().collectionBannedAccounts[saleDetails.tokenAddress];

            if (bannedAccounts.contains(saleDetails.maker)) {
                revert PaymentProcessor__MakerOrTakerIsBannedAccount();
            }

            if (bannedAccounts.contains(context.taker)) {
                revert PaymentProcessor__MakerOrTakerIsBannedAccount();
            }
        }

        if (paymentSettingsForCollection.blockTradesFromUntrustedChannels) {
            EnumerableSet.AddressSet storage trustedChannels = 
                appStorage().collectionTrustedChannels[saleDetails.tokenAddress];

            if (trustedChannels.length() > 0) {
                if (!trustedChannels.contains(context.channel)) {
                    revert PaymentProcessor__TradeOriginatedFromUntrustedChannel();
                }
            }
        }

        if (paymentSettingsForCollection.royaltyBackfillNumerator > 0) {
            royaltyBackfillAndBounty.backfillReceiver = 
                appStorage().collectionRoyaltyBackfillReceivers[saleDetails.tokenAddress];
        }

        if (paymentSettingsForCollection.isRoyaltyBountyExclusive) {
            royaltyBackfillAndBounty.exclusiveMarketplace = 
                appStorage().collectionExclusiveBountyReceivers[saleDetails.tokenAddress];
        }
        
        if (paymentSettings == PaymentSettings.DefaultPaymentMethodWhitelist) {
            if (!_isDefaultPaymentMethod(saleDetails.paymentMethod)) {
                revert PaymentProcessor__PaymentCoinIsNotAnApprovedPaymentMethod();
            }
        } else if (paymentSettings == PaymentSettings.CustomPaymentMethodWhitelist) {
            if (!appStorage().collectionPaymentMethodWhitelists[paymentSettingsForCollection.paymentMethodWhitelistId].contains(saleDetails.paymentMethod)) {
                revert PaymentProcessor__PaymentCoinIsNotAnApprovedPaymentMethod();
            }
        } else if (paymentSettings == PaymentSettings.PricingConstraints) {
            if (paymentSettingsForCollection.constrainedPricingPaymentMethod != saleDetails.paymentMethod) {
                revert PaymentProcessor__PaymentCoinIsNotAnApprovedPaymentMethod();
            }

            _validateSalePriceInRange(
                saleDetails.tokenAddress, 
                saleDetails.tokenId, 
                saleDetails.amount, 
                saleDetails.itemPrice);
        } else if (paymentSettings == PaymentSettings.Paused) {
            revert PaymentProcessor__TradingIsPausedForCollection();
        }
    }

    /**
     * @notice Loads collection payment settings to validate a sweep 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.
     * @dev    Throws when the fee on top amount exceeds the sum of all items.
     * 
     * @param context          The current execution context to determine the taker.
     * @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 saleDetailsBatch         An array of order execution details.
     * @return royaltyBackfillAndBounty The on-chain royalty backfill and bounty information defined by the creator.
     */
    function _validateSweepOrder(
        TradeContext memory context,
        FeeOnTop memory feeOnTop,
        SweepOrder memory sweepOrder,
        SweepItem[] memory items,
        SignatureECDSA[] memory signedSellOrders,
        Cosignature[] memory cosignatures
    ) private returns (Order[] memory saleDetailsBatch, RoyaltyBackfillAndBounty memory royaltyBackfillAndBounty) {
        CollectionPaymentSettings storage paymentSettingsForCollection = 
            appStorage().collectionPaymentSettings[sweepOrder.tokenAddress];

        PaymentSettings paymentSettings = paymentSettingsForCollection.paymentSettings;
        royaltyBackfillAndBounty.backfillNumerator = paymentSettingsForCollection.royaltyBackfillNumerator;
        royaltyBackfillAndBounty.bountyNumerator = paymentSettingsForCollection.royaltyBountyNumerator;

        if (paymentSettingsForCollection.blockTradesFromUntrustedChannels) {
            EnumerableSet.AddressSet storage trustedChannels = 
                appStorage().collectionTrustedChannels[sweepOrder.tokenAddress];

            if (trustedChannels.length() > 0) {
                if (!trustedChannels.contains(context.channel)) {
                    revert PaymentProcessor__TradeOriginatedFromUntrustedChannel();
                }
            }
        }

        if (paymentSettingsForCollection.royaltyBackfillNumerator > 0) {
            royaltyBackfillAndBounty.backfillReceiver = 
                appStorage().collectionRoyaltyBackfillReceivers[sweepOrder.tokenAddress];
        }

        if (paymentSettingsForCollection.isRoyaltyBountyExclusive) {
            royaltyBackfillAndBounty.exclusiveMarketplace = 
                appStorage().collectionExclusiveBountyReceivers[sweepOrder.tokenAddress];
        }

        if (paymentSettings == PaymentSettings.DefaultPaymentMethodWhitelist) {
            if (!_isDefaultPaymentMethod(sweepOrder.paymentMethod)) {
                revert PaymentProcessor__PaymentCoinIsNotAnApprovedPaymentMethod();
            }
        } else if (paymentSettings == PaymentSettings.CustomPaymentMethodWhitelist) {
            if (!appStorage().collectionPaymentMethodWhitelists[paymentSettingsForCollection.paymentMethodWhitelistId].contains(sweepOrder.paymentMethod)) {
                revert PaymentProcessor__PaymentCoinIsNotAnApprovedPaymentMethod();
            }
        } else if (paymentSettings == PaymentSettings.PricingConstraints) {
            if (paymentSettingsForCollection.constrainedPricingPaymentMethod != sweepOrder.paymentMethod) {
                revert PaymentProcessor__PaymentCoinIsNotAnApprovedPaymentMethod();
            }
        } else if (paymentSettings == PaymentSettings.Paused) {
            revert PaymentProcessor__TradingIsPausedForCollection();
        }

        EnumerableSet.AddressSet storage bannedAccounts = 
            appStorage().collectionBannedAccounts[sweepOrder.tokenAddress];

        if (paymentSettingsForCollection.blockBannedAccounts) {
            if (bannedAccounts.contains(context.taker)) {
                revert PaymentProcessor__MakerOrTakerIsBannedAccount();
            }
        }

        uint256 itemsLength = items.length;

        saleDetailsBatch = new Order[](itemsLength);
        uint256 sumListingPrices;

        for (uint256 i = 0; i < itemsLength;) {
            Order memory saleDetails = 
                Order({
                    protocol: sweepOrder.protocol,
                    maker: items[i].maker,
                    beneficiary: sweepOrder.beneficiary,
                    marketplace: items[i].marketplace,
                    fallbackRoyaltyRecipient: items[i].fallbackRoyaltyRecipient,
                    paymentMethod: sweepOrder.paymentMethod,
                    tokenAddress: sweepOrder.tokenAddress,
                    tokenId: items[i].tokenId,
                    amount: items[i].amount,
                    itemPrice: items[i].itemPrice,
                    nonce: items[i].nonce,
                    expiration: items[i].expiration,
                    marketplaceFeeNumerator: items[i].marketplaceFeeNumerator,
                    maxRoyaltyFeeNumerator: items[i].maxRoyaltyFeeNumerator,
                    requestedFillAmount: items[i].amount,
                    minimumFillAmount: items[i].amount
                });

            saleDetailsBatch[i] = saleDetails;
            sumListingPrices += saleDetails.itemPrice;

            if (paymentSettingsForCollection.blockBannedAccounts) {
                if (bannedAccounts.contains(saleDetails.maker)) {
                    revert PaymentProcessor__MakerOrTakerIsBannedAccount();
                }
            }

            if (saleDetails.protocol == OrderProtocols.ERC721_FILL_OR_KILL) {
                if (saleDetails.amount != ONE) {
                    revert PaymentProcessor__AmountForERC721SalesMustEqualOne();
                }
            } else {
                if (saleDetails.amount == 0) {
                    revert PaymentProcessor__AmountForERC1155SalesGreaterThanZero();
                }
            }

            if (saleDetails.marketplaceFeeNumerator + saleDetails.maxRoyaltyFeeNumerator > FEE_DENOMINATOR) {
                revert PaymentProcessor__MarketplaceAndRoyaltyFeesWillExceedSalePrice();
            }

            if (paymentSettings == PaymentSettings.PricingConstraints) {
                _validateSalePriceInRange(
                    saleDetails.tokenAddress, 
                    saleDetails.tokenId, 
                    saleDetails.amount, 
                    saleDetails.itemPrice);
            }

            if (block.timestamp > saleDetails.expiration) {
                    revert PaymentProcessor__OrderHasExpired();
            }

            _verifySaleApproval(context, saleDetails, signedSellOrders[i], cosignatures[i]);

            unchecked {
                ++i;
            }
        }

        if (feeOnTop.amount > sumListingPrices) {
            revert PaymentProcessor__FeeOnTopCannotBeGreaterThanItemPrice();
        }
    }

    /**
     * @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(
        address tokenAddress, 
        uint256 tokenId, 
        uint256 amount, 
        uint256 salePrice
    ) private view {
        (uint256 floorPrice, uint256 ceilingPrice) = _getFloorAndCeilingPrices(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(
        address tokenAddress, 
        uint256 tokenId
    ) internal view returns (uint256, uint256) {
        PricingBounds memory tokenLevelPricingBounds = appStorage().tokenPricingBounds[tokenAddress][tokenId];
        if (tokenLevelPricingBounds.isSet) {
            return (tokenLevelPricingBounds.floorPrice, tokenLevelPricingBounds.ceilingPrice);
        } else {
            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 royaltyBackfillAndBounty Struct containing the royalty backfill and bounty information.
     * @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,
        IERC20 paymentCoin,
        FulfillOrderFunctionPointers memory fnPointers,
        Order memory saleDetails,
        RoyaltyBackfillAndBounty memory royaltyBackfillAndBounty,
        FeeOnTop memory feeOnTop
    ) private returns (uint256 endingNativeFunds) {
        endingNativeFunds = startingNativeFunds;

        if (!fnPointers.funcDispenseToken(
                seller, 
                saleDetails.beneficiary, 
                saleDetails.tokenAddress, 
                saleDetails.tokenId, 
                saleDetails.amount)) {
            if (context.disablePartialFill) {
                revert PaymentProcessor__DispensingTokenWasUnsuccessful();
            }
        } else {
            SplitProceeds memory proceeds =
                _computePaymentSplits(
                    saleDetails.itemPrice,
                    saleDetails.tokenAddress,
                    saleDetails.tokenId,
                    saleDetails.marketplace,
                    saleDetails.marketplaceFeeNumerator,
                    saleDetails.maxRoyaltyFeeNumerator,
                    saleDetails.fallbackRoyaltyRecipient,
                    royaltyBackfillAndBounty
                );

            uint256 feeOnTopAmount;
            if (feeOnTop.recipient != address(0)) {
                feeOnTopAmount = feeOnTop.amount;
            }

            if (saleDetails.paymentMethod == address(0)) {
                uint256 nativeProceedsToSpend = saleDetails.itemPrice + feeOnTopAmount;
                if (endingNativeFunds < nativeProceedsToSpend) {
                    revert PaymentProcessor__RanOutOfNativeFunds();
                }

                unchecked {
                    endingNativeFunds -= nativeProceedsToSpend;
                }
            }

            if (proceeds.royaltyProceeds > 0) {
                fnPointers.funcPayout(proceeds.royaltyRecipient, purchaser, paymentCoin, proceeds.royaltyProceeds, pushPaymentGasLimit);
            }

            if (proceeds.marketplaceProceeds > 0) {
                fnPointers.funcPayout(saleDetails.marketplace, purchaser, paymentCoin, proceeds.marketplaceProceeds, pushPaymentGasLimit);
            }

            if (proceeds.sellerProceeds > 0) {
                fnPointers.funcPayout(seller, purchaser, paymentCoin, proceeds.sellerProceeds, pushPaymentGasLimit);
            }

            if (feeOnTopAmount > 0) {
                if (feeOnTopAmount > saleDetails.itemPrice) {
                    revert PaymentProcessor__FeeOnTopCannotBeGreaterThanItemPrice();
                }

                fnPointers.funcPayout(feeOnTop.recipient, context.taker, paymentCoin, feeOnTop.amount, pushPaymentGasLimit);
            }

            fnPointers.funcEmitOrderExecutionEvent(context, saleDetails);
        }
    }

    /**
     * @notice Dispenses tokens and proceeds for a sweep order.
     * 
     * @dev    This function will **NOT** throw if a token fails to dispense.
     * @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 remaining at the beginning of the function call.
     * @param params              Struct containing the order execution details, backfilled royalty information 
     *                            and fulfillment function pointers.
     *
     * @return endingNativeFunds  The amount of native funds remaining at the end of the function call.
     */
    function _fulfillSweepOrderWithFeeOnTop(
        TradeContext memory context,
        uint256 startingNativeFunds,
        SweepCollectionComputeAndDistributeProceedsParams memory params
    ) private returns (uint256 endingNativeFunds) {
        endingNativeFunds = startingNativeFunds;

        PayoutsAccumulator memory accumulator = PayoutsAccumulator({
            lastSeller: address(0),
            lastMarketplace: address(0),
            lastRoyaltyRecipient: address(0),
            accumulatedSellerProceeds: 0,
            accumulatedMarketplaceProceeds: 0,
            accumulatedRoyaltyProceeds: 0
        });

        for (uint256 i = 0; i < params.saleDetailsBatch.length;) {
            Order memory saleDetails = params.saleDetailsBatch[i];

            if (!params.fnPointers.funcDispenseToken(
                    saleDetails.maker, 
                    saleDetails.beneficiary, 
                    saleDetails.tokenAddress, 
                    saleDetails.tokenId, 
                    saleDetails.amount)) {
            } else {
                SplitProceeds memory proceeds =
                    _computePaymentSplits(
                        saleDetails.itemPrice,
                        saleDetails.tokenAddress,
                        saleDetails.tokenId,
                        saleDetails.marketplace,
                        saleDetails.marketplaceFeeNumerator,
                        saleDetails.maxRoyaltyFeeNumerator,
                        saleDetails.fallbackRoyaltyRecipient,
                        params.royaltyBackfillAndBounty
                    );

                if (saleDetails.paymentMethod == address(0)) {
                    if (endingNativeFunds < saleDetails.itemPrice) {
                        revert PaymentProcessor__RanOutOfNativeFunds();
                    }
    
                    unchecked {
                        endingNativeFunds -= saleDetails.itemPrice;
                    }
                }
    
                if (proceeds.royaltyRecipient != accumulator.lastRoyaltyRecipient) {
                    if(accumulator.accumulatedRoyaltyProceeds > 0) {
                        params.fnPointers.funcPayout(accumulator.lastRoyaltyRecipient, context.taker, params.paymentCoin, accumulator.accumulatedRoyaltyProceeds, pushPaymentGasLimit);
                    }
    
                    accumulator.lastRoyaltyRecipient = proceeds.royaltyRecipient;
                    accumulator.accumulatedRoyaltyProceeds = 0;
                }
    
                if (saleDetails.marketplace != accumulator.lastMarketplace) {
                    if(accumulator.accumulatedMarketplaceProceeds > 0) {
                        params.fnPointers.funcPayout(accumulator.lastMarketplace, context.taker, params.paymentCoin, accumulator.accumulatedMarketplaceProceeds, pushPaymentGasLimit);
                    }
    
                    accumulator.lastMarketplace = saleDetails.marketplace;
                    accumulator.accumulatedMarketplaceProceeds = 0;
                }
    
                if (saleDetails.maker != accumulator.lastSeller) {
                    if(accumulator.accumulatedSellerProceeds > 0) {
                        params.fnPointers.funcPayout(accumulator.lastSeller, context.taker, params.paymentCoin, accumulator.accumulatedSellerProceeds, pushPaymentGasLimit);
                    }
    
                    accumulator.lastSeller = saleDetails.maker;
                    accumulator.accumulatedSellerProceeds = 0;
                }

                unchecked {
                    accumulator.accumulatedRoyaltyProceeds += proceeds.royaltyProceeds;
                    accumulator.accumulatedMarketplaceProceeds += proceeds.marketplaceProceeds;
                    accumulator.accumulatedSellerProceeds += proceeds.sellerProceeds;
                }

                params.fnPointers.funcEmitOrderExecutionEvent(context, saleDetails);
            }

            unchecked {
                ++i;
            }
        }

        if(accumulator.accumulatedRoyaltyProceeds > 0) {
            params.fnPointers.funcPayout(accumulator.lastRoyaltyRecipient, context.taker, params.paymentCoin, accumulator.accumulatedRoyaltyProceeds, pushPaymentGasLimit);
        }

        if(accumulator.accumulatedMarketplaceProceeds > 0) {
            params.fnPointers.funcPayout(accumulator.lastMarketplace, context.taker, params.paymentCoin, accumulator.accumulatedMarketplaceProceeds, pushPaymentGasLimit);
        }

        if(accumulator.accumulatedSellerProceeds > 0) {
            params.fnPointers.funcPayout(accumulator.lastSeller, context.taker, params.paymentCoin, accumulator.accumulatedSellerProceeds, pushPaymentGasLimit);
        }

        if (params.feeOnTop.recipient != address(0)) {
            if (params.feeOnTop.amount > 0) {
                if (address(params.paymentCoin) == address(0)) {
                    if (endingNativeFunds < params.feeOnTop.amount) {
                        revert PaymentProcessor__RanOutOfNativeFunds();
                    }
    
                    unchecked {
                        endingNativeFunds -= params.feeOnTop.amount;
                    }
                }

                params.fnPointers.funcPayout(params.feeOnTop.recipient, context.taker, params.paymentCoin, params.feeOnTop.amount, pushPaymentGasLimit);
            }
        }
    }

    /**
     * @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 royaltyBackfillAndBounty 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(
        uint256 salePrice,
        address tokenAddress,
        uint256 tokenId,
        address marketplaceFeeRecipient,
        uint256 marketplaceFeeNumerator,
        uint256 maxRoyaltyFeeNumerator,
        address fallbackRoyaltyRecipient,
        RoyaltyBackfillAndBounty memory royaltyBackfillAndBounty
    ) private view returns (SplitProceeds memory proceeds) {

        proceeds.sellerProceeds = salePrice;

        try IERC2981(tokenAddress).royaltyInfo(
            tokenId, 
            salePrice) 
            returns (address royaltyReceiver, uint256 royaltyAmount) {
            if (royaltyReceiver == address(0)) {
                royaltyAmount = 0;
            }

            if (royaltyAmount > 0) {
                if (royaltyAmount > (salePrice * maxRoyaltyFeeNumerator) / FEE_DENOMINATOR) {
                    revert PaymentProcessor__OnchainRoyaltiesExceedMaximumApprovedRoyaltyFee();
                }

                proceeds.royaltyRecipient = royaltyReceiver;
                proceeds.royaltyProceeds = royaltyAmount;

                unchecked {
                    proceeds.sellerProceeds -= royaltyAmount;
                }
            }
        } catch (bytes memory) {
            // If the token doesn't implement the royaltyInfo function, then check if there are backfilled royalties.
            if (royaltyBackfillAndBounty.backfillReceiver != address(0)) {
                if (royaltyBackfillAndBounty.backfillNumerator > maxRoyaltyFeeNumerator) {
                    revert PaymentProcessor__OnchainRoyaltiesExceedMaximumApprovedRoyaltyFee();
                }

                proceeds.royaltyRecipient = royaltyBackfillAndBounty.backfillReceiver;
                proceeds.royaltyProceeds = 
                    (salePrice * royaltyBackfillAndBounty.backfillNumerator) / FEE_DENOMINATOR;

                unchecked {
                    proceeds.sellerProceeds -= proceeds.royaltyProceeds;
                }
            } else if (fallbackRoyaltyRecipient != address(0)) {
                proceeds.royaltyRecipient = fallbackRoyaltyRecipient;
                proceeds.royaltyProceeds = (salePrice * maxRoyaltyFeeNumerator) / FEE_DENOMINATOR;

                unchecked {
                    proceeds.sellerProceeds -= proceeds.royaltyProceeds;
                }
            }
        }

        if (marketplaceFeeRecipient != address(0)) {
            proceeds.marketplaceProceeds = (salePrice * marketplaceFeeNumerator) / FEE_DENOMINATOR;
            unchecked {
                proceeds.sellerProceeds -= proceeds.marketplaceProceeds;
            }

            if (royaltyBackfillAndBounty.exclusiveMarketplace == address(0) || 
                royaltyBackfillAndBounty.exclusiveMarketplace == marketplaceFeeRecipient) {
                uint256 royaltyBountyProceeds = 
                    proceeds.royaltyProceeds * royaltyBackfillAndBounty.bountyNumerator / FEE_DENOMINATOR;
            
                if (royaltyBountyProceeds > 0) {
                    unchecked {
                        proceeds.royaltyProceeds -= royaltyBountyProceeds;
                        proceeds.marketplaceProceeds += royaltyBountyProceeds;
                    }
                }
            }
        }
    }

    /**
     * @notice Transfers chain native token to `to`.
     * 
     * @dev    Throws when the native token transfer call reverts.
     * @dev    Throws when the payee uses more gas than `gasLimit_`.
     *
     * @param to                   The address that will receive chain native tokens.
     * @param proceeds             The amount of chain native token value to transfer.
     * @param pushPaymentGasLimit_ The amount of gas units to allow the payee to use.
     */
    function _pushProceeds(address to, uint256 proceeds, uint256 pushPaymentGasLimit_) internal {
        bool success;

        assembly {
            // Transfer the ETH and store if it succeeded or not.
            success := call(pushPaymentGasLimit_, to, proceeds, 0, 0, 0, 0)
        }

        if (!success) {
            revert PaymentProcessor__FailedToTransferProceeds();
        }
    }

    /**
     * @notice Transfers chain native token to `payee`.
     * 
     * @dev    Throws when the native token transfer call reverts.
     * @dev    Throws when the payee uses more gas than `gasLimit_`.
     *
     * @param payee     The address that will receive chain native tokens.
     * @param proceeds  The amount of chain native token value to transfer.
     * @param gasLimit_ The amount of gas units to allow the payee to use.
     */
    function _payoutNativeCurrency(
        address payee, 
        address /*payer*/, 
        IERC20 /*paymentCoin*/, 
        uint256 proceeds, 
        uint256 gasLimit_) internal {
        _pushProceeds(payee, proceeds, gasLimit_);
    }

    /**
     * @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, 
        IERC20 paymentCoin, 
        uint256 proceeds, 
        uint256 /*gasLimit_*/) internal {
        SafeERC20.safeTransferFrom(paymentCoin, payer, payee, proceeds);
    }

    /**
     * @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,
        OrderProtocols orderProtocol
    ) private view returns (FulfillOrderFunctionPointers memory orderFulfillmentFunctionPointers) {
        orderFulfillmentFunctionPointers = FulfillOrderFunctionPointers({
            funcPayout: paymentMethod == address(0) ? _payoutNativeCurrency : _payoutCoinCurrency,
            funcDispenseToken: orderProtocol == OrderProtocols.ERC721_FILL_OR_KILL ? _dispenseERC721Token : _dispenseERC1155Token,
            funcEmitOrderExecutionEvent: orderProtocol == OrderProtocols.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, 
        uint248 orderStartAmount,
        uint248 requestedFillAmount,
        uint248 minimumFillAmount
    ) private returns (uint248 quantityToFill) {
        quantityToFill = requestedFillAmount;
        PartiallyFillableOrderStatus storage partialFillStatus = 
            appStorage().partiallyFillableOrderStatuses[account][orderDigest];
    
        if (partialFillStatus.state == PartiallyFillableOrderState.Open) {
            if (partialFillStatus.remainingFillableQuantity == 0) {
                partialFillStatus.remainingFillableQuantity = uint248(orderStartAmount);
            }

            if (quantityToFill > partialFillStatus.remainingFillableQuantity) {
                quantityToFill = partialFillStatus.remainingFillableQuantity;
            }

            if (quantityToFill < minimumFillAmount) {
                revert PaymentProcessor__UnableToFillMinimumRequestedQuantity();
            }

            unchecked {
                partialFillStatus.remainingFillableQuantity -= quantityToFill;
            }

            if (partialFillStatus.remainingFillableQuantity == 0) {
                partialFillStatus.state = PartiallyFillableOrderState.Filled;
                emit OrderDigestInvalidated(orderDigest, account, false);
            }
        } else {
            revert PaymentProcessor__OrderIsEitherCancelledOrFilled();
        }
    }

    /**
     * @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 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 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
    ) private returns (uint248 quantityToFill) {
        if (cosignature.signer != address(0)) {
            _verifyCosignature(context, signature, cosignature);
        }

        bytes32 orderDigest = _hashTypedDataV4(context.domainSeparator, keccak256(
            bytes.concat(
                abi.encode(
                    ITEM_OFFER_APPROVAL_HASH,
                    uint8(saleDetails.protocol),
                    cosignature.signer,
                    saleDetails.maker,
                    saleDetails.beneficiary,
                    saleDetails.marketplace,
                    saleDetails.fallbackRoyaltyRecipient,
                    saleDetails.paymentMethod,
                    saleDetails.tokenAddress
                ),
                abi.encode(
                    saleDetails.tokenId,
                    saleDetails.amount,
                    saleDetails.itemPrice,
                    saleDetails.expiration,
                    saleDetails.marketplaceFeeNumerator,
                    saleDetails.nonce,
                    saleDetails.protocol == OrderProtocols.ERC1155_FILL_PARTIAL ? 
                        appStorage().masterNonces[saleDetails.maker] :
                        _checkAndInvalidateNonce(saleDetails.maker, saleDetails.nonce, false)
                )
            )
        ));

        _verifyMakerSignature(saleDetails.maker, signature, orderDigest);

        quantityToFill = saleDetails.protocol == OrderProtocols.ERC1155_FILL_PARTIAL ? 
            _checkAndUpdateRemainingFillableItems(
                saleDetails.maker, 
                orderDigest, 
                saleDetails.amount, 
                saleDetails.requestedFillAmount,
                saleDetails.minimumFillAmount) :
            saleDetails.amount;
    }

    /**
     * @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
    ) private returns (uint248 quantityToFill) {
        if (cosignature.signer != address(0)) {
            _verifyCosignature(context, signature, cosignature);
        }

        bytes32 orderDigest = _hashTypedDataV4(context.domainSeparator, keccak256(
            bytes.concat(
                abi.encode(
                    COLLECTION_OFFER_APPROVAL_HASH,
                    uint8(saleDetails.protocol),
                    cosignature.signer,
                    saleDetails.maker,
                    saleDetails.beneficiary,
                    saleDetails.marketplace,
                    saleDetails.fallbackRoyaltyRecipient,
                    saleDetails.paymentMethod,
                    saleDetails.tokenAddress
                ),
                abi.encode(
                    saleDetails.amount,
                    saleDetails.itemPrice,
                    saleDetails.expiration,
                    saleDetails.marketplaceFeeNumerator,
                    saleDetails.nonce,
                    saleDetails.protocol == OrderProtocols.ERC1155_FILL_PARTIAL ? 
                        appStorage().masterNonces[saleDetails.maker] :
                        _checkAndInvalidateNonce(saleDetails.maker, saleDetails.nonce, false)
                )
            )
        ));

        _verifyMakerSignature(saleDetails.maker, signature, orderDigest);

        quantityToFill = saleDetails.protocol == OrderProtocols.ERC1155_FILL_PARTIAL ? 
            _checkAndUpdateRemainingFillableItems(
                saleDetails.maker, 
                orderDigest, 
                saleDetails.amount, 
                saleDetails.requestedFillAmount,
                saleDetails.minimumFillAmount) :
            saleDetails.amount;
    }

    /**
     * @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,
        TokenSetProof memory tokenSetProof,
        Cosignature memory cosignature
    ) private returns (uint248 quantityToFill) {
        if (cosignature.signer != address(0)) {
            _verifyCosignature(context, signature, cosignature);
        }

        bytes32 orderDigest = _hashTypedDataV4(context.domainSeparator, keccak256(
            bytes.concat(
                abi.encode(
                    TOKEN_SET_OFFER_APPROVAL_HASH,
                    uint8(saleDetails.protocol),
                    cosignature.signer,
                    saleDetails.maker,
                    saleDetails.beneficiary,
                    saleDetails.marketplace,
                    saleDetails.fallbackRoyaltyRecipient,
                    saleDetails.paymentMethod,
                    saleDetails.tokenAddress
                ),
                abi.encode(
                    saleDetails.amount,
                    saleDetails.itemPrice,
                    saleDetails.expiration,
                    saleDetails.marketplaceFeeNumerator,
                    saleDetails.nonce,
                    saleDetails.protocol == OrderProtocols.ERC1155_FILL_PARTIAL ? 
                        appStorage().masterNonces[saleDetails.maker] :
                        _checkAndInvalidateNonce(saleDetails.maker, saleDetails.nonce, false),
                    tokenSetProof.rootHash
                )
            )
        ));

        _verifyMakerSignature(saleDetails.maker, signature, orderDigest);

        quantityToFill = saleDetails.protocol == OrderProtocols.ERC1155_FILL_PARTIAL ? 
            _checkAndUpdateRemainingFillableItems(
                saleDetails.maker, 
                orderDigest, 
                saleDetails.amount, 
                saleDetails.requestedFillAmount,
                saleDetails.minimumFillAmount) :
            saleDetails.amount;
    }

    /**
     * @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
    ) private returns (uint248 quantityToFill) {
        if (cosignature.signer != address(0)) {
            _verifyCosignature(context, signature, cosignature);
        }

        bytes32 orderDigest = _hashTypedDataV4(context.domainSeparator, keccak256(
            bytes.concat(
                abi.encode(
                    SALE_APPROVAL_HASH,
                    uint8(saleDetails.protocol),
                    cosignature.signer,
                    saleDetails.maker,
                    saleDetails.marketplace,
                    saleDetails.fallbackRoyaltyRecipient,
                    saleDetails.paymentMethod,
                    saleDetails.tokenAddress,
                    saleDetails.tokenId
                ),
                abi.encode(
                    saleDetails.amount,
                    saleDetails.itemPrice,
                    saleDetails.expiration,
                    saleDetails.marketplaceFeeNumerator,
                    saleDetails.maxRoyaltyFeeNumerator,
                    saleDetails.nonce,
                    saleDetails.protocol == OrderProtocols.ERC1155_FILL_PARTIAL ? 
                        appStorage().masterNonces[saleDetails.maker] :
                        _checkAndInvalidateNonce(saleDetails.maker, saleDetails.nonce, false)
                )
            )
        ));

        _verifyMakerSignature(saleDetails.maker, signature, orderDigest);

        quantityToFill = saleDetails.protocol == OrderProtocols.ERC1155_FILL_PARTIAL ? 
            _checkAndUpdateRemainingFillableItems(
                saleDetails.maker, 
                orderDigest, 
                saleDetails.amount, 
                saleDetails.requestedFillAmount,
                saleDetails.minimumFillAmount) :
            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 ) private view {
        if (maker != _ecdsaRecover(digest, signature.v, signature.r, signature.s)) {
            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
    ) private 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(context.domainSeparator, keccak256(
                abi.encode(
                    COSIGNATURE_HASH,
                    signature.v,
                    signature.r,
                    signature.s,
                    cosignature.expiration,
                    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) private view {
        bool isValidSignatureNow;
        
        try IERC1271(signer).isValidSignature(
            hash, 
            abi.encodePacked(signature.r, signature.s, signature.v)) 
            returns (bytes4 magicValue) {
            isValidSignatureNow = magicValue == IERC1271.isValidSignature.selector;
        } catch {}

        if (!isValidSignatureNow) {
            revert PaymentProcessor__EIP1271SignatureInvalid();
        }
    }

    /**
     * @notice Recovers the signer address from a hash and signature.
     * 
     * @dev Throws when `s` is greater than 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0 to
     * @dev prevent malleable signatures from being utilized. 
     * @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, 
        uint8 v, 
        bytes32 r, 
        bytes32 s
    ) private pure returns (address signer) {
        if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {
            revert PaymentProcessor__UnauthorizedOrder();
        }

        signer = ecrecover(digest, v, r, s);
        if (signer == address(0)) {
            revert PaymentProcessor__UnauthorizedOrder();
        }
    }

    /**
     * @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) private pure returns (bytes32) {
        return ECDSA.toTypedDataHash(domainSeparator, structHash);
    }

    /*************************************************************************/
    /*                             Miscellaneous                             */
    /*************************************************************************/

    /**
     * @notice Transfers ownership of a payment method whitelist.
     * 
     * @dev    Throws when the caller is not the owner of the payment method whitelist.
     *
     * @param id       The payment method whitelist id to transfer ownership of.
     * @param newOwner The address to transfer ownership to.
     */
    function _reassignOwnershipOfPaymentMethodWhitelist(uint32 id, address newOwner) internal {
        _requireCallerOwnsPaymentMethodWhitelist(id);
        appStorage().paymentMethodWhitelistOwners[id] = newOwner;
        emit ReassignedPaymentMethodWhitelistOwnership(id, newOwner);
    }

    /**
     * @notice Reverts the transaction if the caller is not the owner of the payment method whitelist.
     *
     * @dev    Throws when the caller is not the owner of the payment method whitelist.
     *
     * @param paymentMethodWhitelistId The payment method whitelist id to check ownership for.
     */
    function _requireCallerOwnsPaymentMethodWhitelist(uint32 paymentMethodWhitelistId) internal view {
        if(_msgSender() != appStorage().paymentMethodWhitelistOwners[paymentMethodWhitelistId]) {
            revert PaymentProcessor__CallerDoesNotOwnPaymentMethodWhitelist();
        }
    }

    /**
     * @notice Reverts the transaction if the caller is not the owner or assigned the default
     * @notice admin role of the contract at `tokenAddress`.
     *
     * @dev    Throws when the caller is neither owner nor assigned the default admin role.
     * 
     * @param tokenAddress The contract address of the token to check permissions for.
     */
    function _requireCallerIsNFTOrContractOwnerOrAdmin(address tokenAddress) internal view {
        bool callerHasPermissions = false;

        address caller = _msgSender();
        
        callerHasPermissions = caller == tokenAddress;
        if(!callerHasPermissions) {
            try IOwnable(tokenAddress).owner() returns (address contractOwner) {
                callerHasPermissions = caller == contractOwner;
            } catch {}

            if(!callerHasPermissions) {
                try IAccessControl(tokenAddress).hasRole(DEFAULT_ACCESS_CONTROL_ADMIN_ROLE, caller) 
                    returns (bool callerIsContractAdmin) {
                    callerHasPermissions = callerIsContractAdmin;
                } catch {}
            }
        }

        if(!callerHasPermissions) {
            revert PaymentProcessor__CallerMustHaveElevatedPermissionsForSpecifiedNFT();
        }
    }
}

File 3 of 28 : IOwnable.sol
// SPDX-License-Identifier: BSL-1.1

pragma solidity 0.8.19;

/**
 * @dev ERC-173 Ownable Interface
 */
interface IOwnable {
    function owner() external view returns (address);
}

File 4 of 28 : IPaymentProcessorConfiguration.sol
// SPDX-License-Identifier: BSL-1.1
pragma solidity 0.8.19;

import "../DataTypes.sol";

/** 
* @title PaymentProcessor
* @custom:version 2.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 (
            uint32, /*defaultPushPaymentGasLimit*/
            address, /*wrappedNativeCoin*/
            DefaultPaymentMethods memory /*defaultPaymentMethods*/
        );

    /**
     * @notice Returns the setup params for payment processor.
     */
    function getPaymentProcessorDeploymentParams()
        external
        view
        returns (
            address, /*defaultContractOwner*/
            PaymentProcessorModules memory /*paymentProcessorModules*/
        );
}

File 5 of 28 : IPaymentProcessorEvents.sol
// SPDX-License-Identifier: BSL-1.1
pragma solidity 0.8.19;

import "../DataTypes.sol";

/** 
* @title Payment Processor
* @custom:version 2.0.0
* @author Limit Break, Inc.
*/ 
interface IPaymentProcessorEvents {
    /// @notice Emitted when an account is banned from trading a collection
    event BannedAccountAddedForCollection(
        address indexed tokenAddress, 
        address indexed account);

    /// @notice Emitted when an account ban has been lifted on a collection
    event BannedAccountRemovedForCollection(
        address indexed tokenAddress, 
        address indexed account);

    /// @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 new payment method whitelist is created.
    event CreatedPaymentMethodWhitelist(
        uint32 indexed paymentMethodWhitelistId, 
        address indexed whitelistOwner,
        string whitelistName);

    /// @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 revokes a single listing or offer nonce for a specific marketplace.
    event OrderDigestInvalidated(
        bytes32 indexed orderDigest, 
        address indexed account, 
        bool wasCancellation);

    /// @notice Emitted when a coin is added to the approved coins mapping for a security policy
    event PaymentMethodAddedToWhitelist(
        uint32 indexed paymentMethodWhitelistId, 
        address indexed paymentMethod);

    /// @notice Emitted when a coin is removed from the approved coins mapping for a security policy
    event PaymentMethodRemovedFromWhitelist(
        uint32 indexed paymentMethodWhitelistId, 
        address indexed paymentMethod);

    /// @notice Emitted when a payment method whitelist is reassigned to a new owner
    event ReassignedPaymentMethodWhitelistOwnership(uint32 indexed id, address indexed newOwner);

    /// @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 whenever pricing bounds change at a collection level for price-constrained collections.
    event UpdatedCollectionLevelPricingBoundaries(
        address indexed tokenAddress, 
        uint256 floorPrice, 
        uint256 ceilingPrice);

    /// @notice Emitted whenever the supported ERC-20 payment is set for price-constrained collections.
    event UpdatedCollectionPaymentSettings(
        address indexed tokenAddress, 
        PaymentSettings paymentSettings, 
        uint32 indexed paymentMethodWhitelistId, 
        address indexed constrainedPricingPaymentMethod,
        uint16 royaltyBackfillNumerator,
        address royaltyBackfillReceiver,
        uint16 royaltyBountyNumerator,
        address exclusiveBountyReceiver,
        bool blockTradesFromUntrustedChannels,
        bool blockBannedAccounts);

    /// @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);
}

File 6 of 28 : PaymentProcessorStorageAccess.sol
// SPDX-License-Identifier: BSL-1.1
pragma solidity 0.8.19;

import "../DataTypes.sol";

/** 
* @title Payment Processor
* @custom:version 2.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 = 
        keccak256("diamond.storage.payment.processor");

    /**
     * @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
        }
    }
}

File 7 of 28 : Constants.sol
// SPDX-License-Identifier: BSL-1.1
pragma solidity 0.8.19;

// keccack256("Cosignature(uint8 v,bytes32 r,bytes32 s,uint256 expiration,address taker)")
bytes32 constant COSIGNATURE_HASH = 0x347b7818601b168f6faadc037723496e9130b057c1ffef2ec4128311e19142f2;

// keccack256("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 COLLECTION_OFFER_APPROVAL_HASH = 0x8fe9498e93fe26b30ebf76fac07bd4705201c8609227362697082288e3b4af9c;

// keccack256("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 ITEM_OFFER_APPROVAL_HASH = 0xce2e9706d63e89ddf7ee16ce0508a1c3c9bd1904c582db2e647e6f4690a0bf6b;

//   keccack256("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 TOKEN_SET_OFFER_APPROVAL_HASH = 0x244905ade6b0e455d12fb539a4b17d7f675db14797d514168d09814a09c70e70;

// keccack256("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)")
bytes32 constant SALE_APPROVAL_HASH = 0x938786a8256d04dc45d6d5b997005aa07c0c9e3e4925d0d6c33128d240096ebc;

// 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);

// 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_REASSIGN_OWNERSHIP_OF_PAYMENT_METHOD_WHITELIST= hex"a1e6917e";
bytes4 constant SELECTOR_RENOUNCE_OWNERSHIP_OF_PAYMENT_METHOD_WHITELIST= hex"0886702e";
bytes4 constant SELECTOR_WHITELIST_PAYMENT_METHOD = hex"bb39ce91";
bytes4 constant SELECTOR_UNWHITELIST_PAYMENT_METHOD = hex"e9d4c14e";
bytes4 constant SELECTOR_SET_COLLECTION_PAYMENT_SETTINGS = hex"fc5d8393";
bytes4 constant SELECTOR_SET_COLLECTION_PRICING_BOUNDS = hex"7141ae10";
bytes4 constant SELECTOR_SET_TOKEN_PRICING_BOUNDS = hex"22146d70";
bytes4 constant SELECTOR_ADD_TRUSTED_CHANNEL_FOR_COLLECTION = hex"ab559c14";
bytes4 constant SELECTOR_REMOVE_TRUSTED_CHANNEL_FOR_COLLECTION = hex"282e89f8";
bytes4 constant SELECTOR_ADD_BANNED_ACCOUNT_FOR_COLLECTION = hex"e21dde50";
bytes4 constant SELECTOR_REMOVE_BANNED_ACCOUNT_FOR_COLLECTION = hex"adf14a76";

bytes4 constant SELECTOR_DESTROY_COSIGNER = hex"2aebdefe";
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"a9272951";
bytes4 constant SELECTOR_ACCEPT_OFFER = hex"e35bb9b7";
bytes4 constant SELECTOR_BULK_BUY_LISTINGS = hex"27add047";
bytes4 constant SELECTOR_BULK_ACCEPT_OFFERS = hex"b3cdebdb";
bytes4 constant SELECTOR_SWEEP_COLLECTION = hex"206576f6";

/**************************************************************/
/*                   EXPECTED BASE msg.data LENGTHS           */
/**************************************************************/

uint256 constant PROOF_ELEMENT_SIZE = 32;

// | 4        | 32              | 512         | 96              | 192         | 64       | = 900 bytes
// | selector | domainSeparator | saleDetails | sellerSignature | cosignature | feeOnTop |
uint256 constant BASE_MSG_LENGTH_BUY_LISTING = 900;

// | 4        | 32              | 32                     | 512         |  96             | 32 + (96 + (32 * proof.length)) | 192         | 64       | = 1060 bytes + (32 * proof.length)
// | selector | domainSeparator | isCollectionLevelOffer | saleDetails |  buyerSignature | tokenSetProof                   | cosignature | feeOnTop |
uint256 constant BASE_MSG_LENGTH_ACCEPT_OFFER = 1060;

// | 4        | 32              | 64              | 512 * length      | 64              | 96 * length      | 64              | 192 * length | 64              | 64 * length | = 292 bytes + (864 * saleDetailsArray.length)
// | selector | domainSeparator | length + offset | saleDetailsArray  | length + offset | sellerSignatures | length + offset | cosignatures | length + offset | feesOnTop   |
uint256 constant BASE_MSG_LENGTH_BULK_BUY_LISTINGS = 292;
uint256 constant BASE_MSG_LENGTH_BULK_BUY_LISTINGS_PER_ITEM = 864;

// | 4        | 32              | 32           | 64              | 32 * length                 | 64              | 512 * length      | 64              | 96 * length          | 64              | 32 + (96 + (32 * proof.length)) | 64              | 192 * length | 64              | 64 * length | = 452 bytes + (1024 * saleDetailsArray.length) + (32 * proof.length [for each element])
// | selector | domainSeparator | struct info? | length + offset | isCollectionLevelOfferArray | length + offset | saleDetailsArray  | length + offset | buyerSignaturesArray | length + offset | tokenSetProof                   | length + offset | cosignatures | length + offset | feesOnTop   |
uint256 constant BASE_MSG_LENGTH_BULK_ACCEPT_OFFERS = 452;
uint256 constant BASE_MSG_LENGTH_BULK_ACCEPT_OFFERS_PER_ITEM = 1024;

// | 4        | 32              | 64       | 128        | 64              | 320 * length | 64              | 96 * length      | 64              | 192 * length | = 420 bytes + (608 * items.length)
// | selector | domainSeparator | feeOnTop | sweepOrder | length + offset | items        | length + offset | signedSellOrders | length + offset | cosignatures |
uint256 constant BASE_MSG_LENGTH_SWEEP_COLLECTION = 420;
uint256 constant BASE_MSG_LENGTH_SWEEP_COLLECTION_PER_ITEM = 608;

File 8 of 28 : Errors.sol
// SPDX-License-Identifier: BSL-1.1
pragma solidity 0.8.19;

/// @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 an offer is being accepted and the payment method is the chain native token.
error PaymentProcessor__BadPaymentMethod();

/// @dev Thrown when adding or removing a payment method from a whitelist that the caller does not own.
error PaymentProcessor__CallerDoesNotOwnPaymentMethodWhitelist();

/**
 * @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 setting a collection or token pricing constraint with a floor price greater than ceiling price.
error PaymentProcessor__CeilingPriceMustBeGreaterThanFloorPrice();

/// @dev Thrown when adding a trusted channel that is not a trusted forwarder deployed by the trusted forwarder factory.
error PaymentProcessor__ChannelIsNotTrustedForwarder();

/// @dev Thrown when removing a payment method from a whitelist when that payment method is not on the whitelist.
error PaymentProcessor__CoinIsNotApproved();

/// @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 Payment Processor or a module is being deployed with invalid constructor arguments.
error PaymentProcessor__InvalidConstructorArguments();

/// @dev Thrown when the maker or taker is a banned account on the collection being traded.
error PaymentProcessor__MakerOrTakerIsBannedAccount();

/// @dev Thrown when the combined marketplace and royalty fees will exceed the item price.
error PaymentProcessor__MarketplaceAndRoyaltyFeesWillExceedSalePrice();

/// @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 adding a payment method to a whitelist when that payment method is already on the list.
error PaymentProcessor__PaymentMethodIsAlreadyApproved();

/// @dev Thrown when setting collection payment settings with a whitelist id that does not exist.
error PaymentProcessor__PaymentMethodWhitelistDoesNotExist();

/// @dev Thrown when attempting to transfer ownership of a payment method whitelist to the zero address.
error PaymentProcessor__PaymentMethodWhitelistOwnershipCannotBeTransferredToZeroAddress();

/// @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 attempting to set a royalty backfill numerator that would result in royalties greater than 100%.
error PaymentProcessor__RoyaltyBackfillNumeratorCannotExceedFeeDenominator();

/// @dev Thrown when attempting to set a royalty bounty numerator that would result in royalty bounties greater than 100%.
error PaymentProcessor__RoyaltyBountyNumeratorCannotExceedFeeDenominator();

/// @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 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();

File 9 of 28 : IAccessControl.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol)

pragma solidity ^0.8.0;

/**
 * @dev External interface of AccessControl declared to support ERC165 detection.
 */
interface IAccessControl {
    /**
     * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`
     *
     * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite
     * {RoleAdminChanged} not being emitted signaling this.
     *
     * _Available since v3.1._
     */
    event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);

    /**
     * @dev Emitted when `account` is granted `role`.
     *
     * `sender` is the account that originated the contract call, an admin role
     * bearer except when using {AccessControl-_setupRole}.
     */
    event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);

    /**
     * @dev Emitted when `account` is revoked `role`.
     *
     * `sender` is the account that originated the contract call:
     *   - if using `revokeRole`, it is the admin role bearer
     *   - if using `renounceRole`, it is the role bearer (i.e. `account`)
     */
    event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);

    /**
     * @dev Returns `true` if `account` has been granted `role`.
     */
    function hasRole(bytes32 role, address account) external view returns (bool);

    /**
     * @dev Returns the admin role that controls `role`. See {grantRole} and
     * {revokeRole}.
     *
     * To change a role's admin, use {AccessControl-_setRoleAdmin}.
     */
    function getRoleAdmin(bytes32 role) external view returns (bytes32);

    /**
     * @dev Grants `role` to `account`.
     *
     * If `account` had not been already granted `role`, emits a {RoleGranted}
     * event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     */
    function grantRole(bytes32 role, address account) external;

    /**
     * @dev Revokes `role` from `account`.
     *
     * If `account` had been granted `role`, emits a {RoleRevoked} event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     */
    function revokeRole(bytes32 role, address account) external;

    /**
     * @dev Revokes `role` from the calling account.
     *
     * Roles are often managed via {grantRole} and {revokeRole}: this function's
     * purpose is to provide a mechanism for accounts to lose their privileges
     * if they are compromised (such as when a trusted device is misplaced).
     *
     * If the calling account had been granted `role`, emits a {RoleRevoked}
     * event.
     *
     * Requirements:
     *
     * - the caller must be `account`.
     */
    function renounceRole(bytes32 role, address account) external;
}

File 10 of 28 : IERC1271.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (interfaces/IERC1271.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC1271 standard signature validation method for
 * contracts as defined in https://eips.ethereum.org/EIPS/eip-1271[ERC-1271].
 *
 * _Available since v4.1._
 */
interface IERC1271 {
    /**
     * @dev Should return whether the signature provided is valid for the provided data
     * @param hash      Hash of the data to be signed
     * @param signature Signature byte array associated with _data
     */
    function isValidSignature(bytes32 hash, bytes memory signature) external view returns (bytes4 magicValue);
}

File 11 of 28 : IERC2981.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (interfaces/IERC2981.sol)

pragma solidity ^0.8.0;

import "../utils/introspection/IERC165.sol";

/**
 * @dev Interface for the NFT Royalty Standard.
 *
 * A standardized way to retrieve royalty payment information for non-fungible tokens (NFTs) to enable universal
 * support for royalty payments across all NFT marketplaces and ecosystem participants.
 *
 * _Available since v4.5._
 */
interface IERC2981 is IERC165 {
    /**
     * @dev Returns how much royalty is owed and to whom, based on a sale price that may be denominated in any unit of
     * exchange. The royalty amount is denominated and should be paid in that same unit of exchange.
     */
    function royaltyInfo(
        uint256 tokenId,
        uint256 salePrice
    ) external view returns (address receiver, uint256 royaltyAmount);
}

File 12 of 28 : SafeERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.3) (token/ERC20/utils/SafeERC20.sol)

pragma solidity ^0.8.0;

import "../IERC20.sol";
import "../extensions/IERC20Permit.sol";
import "../../../utils/Address.sol";

/**
 * @title SafeERC20
 * @dev Wrappers around ERC20 operations that throw on failure (when the token
 * contract returns false). Tokens that return no value (and instead revert or
 * throw on failure) are also supported, non-reverting calls are assumed to be
 * successful.
 * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
 * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
 */
library SafeERC20 {
    using Address for address;

    /**
     * @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,
     * non-reverting calls are assumed to be successful.
     */
    function safeTransfer(IERC20 token, address to, uint256 value) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
    }

    /**
     * @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the
     * calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.
     */
    function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
    }

    /**
     * @dev Deprecated. This function has issues similar to the ones found in
     * {IERC20-approve}, and its usage is discouraged.
     *
     * Whenever possible, use {safeIncreaseAllowance} and
     * {safeDecreaseAllowance} instead.
     */
    function safeApprove(IERC20 token, address spender, uint256 value) internal {
        // safeApprove should only be called when setting an initial allowance,
        // or when resetting it to zero. To increase and decrease it, use
        // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
        require(
            (value == 0) || (token.allowance(address(this), spender) == 0),
            "SafeERC20: approve from non-zero to non-zero allowance"
        );
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
    }

    /**
     * @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
     * non-reverting calls are assumed to be successful.
     */
    function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
        uint256 oldAllowance = token.allowance(address(this), spender);
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance + value));
    }

    /**
     * @dev Decrease the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
     * non-reverting calls are assumed to be successful.
     */
    function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal {
        unchecked {
            uint256 oldAllowance = token.allowance(address(this), spender);
            require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
            _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance - value));
        }
    }

    /**
     * @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,
     * non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval
     * to be set to zero before setting it to a non-zero value, such as USDT.
     */
    function forceApprove(IERC20 token, address spender, uint256 value) internal {
        bytes memory approvalCall = abi.encodeWithSelector(token.approve.selector, spender, value);

        if (!_callOptionalReturnBool(token, approvalCall)) {
            _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, 0));
            _callOptionalReturn(token, approvalCall);
        }
    }

    /**
     * @dev Use a ERC-2612 signature to set the `owner` approval toward `spender` on `token`.
     * Revert on invalid signature.
     */
    function safePermit(
        IERC20Permit token,
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) internal {
        uint256 nonceBefore = token.nonces(owner);
        token.permit(owner, spender, value, deadline, v, r, s);
        uint256 nonceAfter = token.nonces(owner);
        require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed");
    }

    /**
     * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
     * on the return value: the return value is optional (but if data is returned, it must not be false).
     * @param token The token targeted by the call.
     * @param data The call data (encoded using abi.encode or one of its variants).
     */
    function _callOptionalReturn(IERC20 token, bytes memory data) private {
        // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
        // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that
        // the target address contains contract code and also asserts for success in the low-level call.

        bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
        require(returndata.length == 0 || abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
    }

    /**
     * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
     * on the return value: the return value is optional (but if data is returned, it must not be false).
     * @param token The token targeted by the call.
     * @param data The call data (encoded using abi.encode or one of its variants).
     *
     * This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead.
     */
    function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
        // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
        // we're implementing it ourselves. We cannot use {Address-functionCall} here since this should return false
        // and not revert is the subcall reverts.

        (bool success, bytes memory returndata) = address(token).call(data);
        return
            success && (returndata.length == 0 || abi.decode(returndata, (bool))) && Address.isContract(address(token));
    }
}

File 13 of 28 : IERC721.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC721/IERC721.sol)

pragma solidity ^0.8.0;

import "../../utils/introspection/IERC165.sol";

/**
 * @dev Required interface of an ERC721 compliant contract.
 */
interface IERC721 is IERC165 {
    /**
     * @dev Emitted when `tokenId` token is transferred from `from` to `to`.
     */
    event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);

    /**
     * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.
     */
    event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);

    /**
     * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
     */
    event ApprovalForAll(address indexed owner, address indexed operator, bool approved);

    /**
     * @dev Returns the number of tokens in ``owner``'s account.
     */
    function balanceOf(address owner) external view returns (uint256 balance);

    /**
     * @dev Returns the owner of the `tokenId` token.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function ownerOf(uint256 tokenId) external view returns (address owner);

    /**
     * @dev Safely transfers `tokenId` token from `from` to `to`.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must exist and be owned by `from`.
     * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external;

    /**
     * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
     * are aware of the ERC721 protocol to prevent tokens from being forever locked.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must exist and be owned by `from`.
     * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or {setApprovalForAll}.
     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function safeTransferFrom(address from, address to, uint256 tokenId) external;

    /**
     * @dev Transfers `tokenId` token from `from` to `to`.
     *
     * WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721
     * or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must
     * understand this adds an external call which potentially creates a reentrancy vulnerability.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must be owned by `from`.
     * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(address from, address to, uint256 tokenId) external;

    /**
     * @dev Gives permission to `to` to transfer `tokenId` token to another account.
     * The approval is cleared when the token is transferred.
     *
     * Only a single account can be approved at a time, so approving the zero address clears previous approvals.
     *
     * Requirements:
     *
     * - The caller must own the token or be an approved operator.
     * - `tokenId` must exist.
     *
     * Emits an {Approval} event.
     */
    function approve(address to, uint256 tokenId) external;

    /**
     * @dev Approve or remove `operator` as an operator for the caller.
     * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
     *
     * Requirements:
     *
     * - The `operator` cannot be the caller.
     *
     * Emits an {ApprovalForAll} event.
     */
    function setApprovalForAll(address operator, bool approved) external;

    /**
     * @dev Returns the account approved for `tokenId` token.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function getApproved(uint256 tokenId) external view returns (address operator);

    /**
     * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
     *
     * See {setApprovalForAll}
     */
    function isApprovedForAll(address owner, address operator) external view returns (bool);
}

File 14 of 28 : IERC1155.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC1155/IERC1155.sol)

pragma solidity ^0.8.0;

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].
 *
 * _Available since v3.1._
 */
interface IERC1155 is IERC165 {
    /**
     * @dev Emitted when `value` tokens of token type `id` are transferred from `from` to `to` by `operator`.
     */
    event TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value);

    /**
     * @dev Equivalent to multiple {TransferSingle} events, where `operator`, `from` and `to` are the same for all
     * transfers.
     */
    event TransferBatch(
        address indexed operator,
        address indexed from,
        address indexed to,
        uint256[] ids,
        uint256[] values
    );

    /**
     * @dev Emitted when `account` grants or revokes permission to `operator` to transfer their tokens, according to
     * `approved`.
     */
    event ApprovalForAll(address indexed account, address indexed operator, bool approved);

    /**
     * @dev Emitted when the URI for token type `id` changes to `value`, if it is a non-programmatic URI.
     *
     * If an {URI} event was emitted for `id`, the standard
     * https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[guarantees] that `value` will equal the value
     * returned by {IERC1155MetadataURI-uri}.
     */
    event URI(string value, uint256 indexed id);

    /**
     * @dev Returns the amount of tokens of token type `id` owned by `account`.
     *
     * Requirements:
     *
     * - `account` cannot be the zero address.
     */
    function balanceOf(address account, uint256 id) external view returns (uint256);

    /**
     * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {balanceOf}.
     *
     * Requirements:
     *
     * - `accounts` and `ids` must have the same length.
     */
    function balanceOfBatch(
        address[] calldata accounts,
        uint256[] calldata ids
    ) external view returns (uint256[] memory);

    /**
     * @dev Grants or revokes permission to `operator` to transfer the caller's tokens, according to `approved`,
     *
     * Emits an {ApprovalForAll} event.
     *
     * Requirements:
     *
     * - `operator` cannot be the caller.
     */
    function setApprovalForAll(address operator, bool approved) external;

    /**
     * @dev Returns true if `operator` is approved to transfer ``account``'s tokens.
     *
     * See {setApprovalForAll}.
     */
    function isApprovedForAll(address account, address operator) external view returns (bool);

    /**
     * @dev Transfers `amount` tokens of token type `id` from `from` to `to`.
     *
     * Emits a {TransferSingle} event.
     *
     * Requirements:
     *
     * - `to` cannot be the zero address.
     * - If the caller is not `from`, it must have been approved to spend ``from``'s tokens via {setApprovalForAll}.
     * - `from` must have a balance of tokens of type `id` of at least `amount`.
     * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the
     * acceptance magic value.
     */
    function safeTransferFrom(address from, address to, uint256 id, uint256 amount, bytes calldata data) external;

    /**
     * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {safeTransferFrom}.
     *
     * Emits a {TransferBatch} event.
     *
     * Requirements:
     *
     * - `ids` and `amounts` must have the same length.
     * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the
     * acceptance magic value.
     */
    function safeBatchTransferFrom(
        address from,
        address to,
        uint256[] calldata ids,
        uint256[] calldata amounts,
        bytes calldata data
    ) external;
}

File 15 of 28 : ECDSA.sol
// 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));
    }
}

File 16 of 28 : MerkleProof.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.2) (utils/cryptography/MerkleProof.sol)

pragma solidity ^0.8.0;

/**
 * @dev These functions deal with verification of Merkle Tree proofs.
 *
 * The tree and the proofs can be generated using our
 * https://github.com/OpenZeppelin/merkle-tree[JavaScript library].
 * You will find a quickstart guide in the readme.
 *
 * WARNING: You should avoid using leaf values that are 64 bytes long prior to
 * hashing, or use a hash function other than keccak256 for hashing leaves.
 * This is because the concatenation of a sorted pair of internal nodes in
 * the merkle tree could be reinterpreted as a leaf value.
 * OpenZeppelin's JavaScript library generates merkle trees that are safe
 * against this attack out of the box.
 */
library MerkleProof {
    /**
     * @dev Returns true if a `leaf` can be proved to be a part of a Merkle tree
     * defined by `root`. For this, a `proof` must be provided, containing
     * sibling hashes on the branch from the leaf to the root of the tree. Each
     * pair of leaves and each pair of pre-images are assumed to be sorted.
     */
    function verify(bytes32[] memory proof, bytes32 root, bytes32 leaf) internal pure returns (bool) {
        return processProof(proof, leaf) == root;
    }

    /**
     * @dev Calldata version of {verify}
     *
     * _Available since v4.7._
     */
    function verifyCalldata(bytes32[] calldata proof, bytes32 root, bytes32 leaf) internal pure returns (bool) {
        return processProofCalldata(proof, leaf) == root;
    }

    /**
     * @dev Returns the rebuilt hash obtained by traversing a Merkle tree up
     * from `leaf` using `proof`. A `proof` is valid if and only if the rebuilt
     * hash matches the root of the tree. When processing the proof, the pairs
     * of leafs & pre-images are assumed to be sorted.
     *
     * _Available since v4.4._
     */
    function processProof(bytes32[] memory proof, bytes32 leaf) internal pure returns (bytes32) {
        bytes32 computedHash = leaf;
        for (uint256 i = 0; i < proof.length; i++) {
            computedHash = _hashPair(computedHash, proof[i]);
        }
        return computedHash;
    }

    /**
     * @dev Calldata version of {processProof}
     *
     * _Available since v4.7._
     */
    function processProofCalldata(bytes32[] calldata proof, bytes32 leaf) internal pure returns (bytes32) {
        bytes32 computedHash = leaf;
        for (uint256 i = 0; i < proof.length; i++) {
            computedHash = _hashPair(computedHash, proof[i]);
        }
        return computedHash;
    }

    /**
     * @dev Returns true if the `leaves` can be simultaneously proven to be a part of a merkle tree defined by
     * `root`, according to `proof` and `proofFlags` as described in {processMultiProof}.
     *
     * CAUTION: Not all merkle trees admit multiproofs. See {processMultiProof} for details.
     *
     * _Available since v4.7._
     */
    function multiProofVerify(
        bytes32[] memory proof,
        bool[] memory proofFlags,
        bytes32 root,
        bytes32[] memory leaves
    ) internal pure returns (bool) {
        return processMultiProof(proof, proofFlags, leaves) == root;
    }

    /**
     * @dev Calldata version of {multiProofVerify}
     *
     * CAUTION: Not all merkle trees admit multiproofs. See {processMultiProof} for details.
     *
     * _Available since v4.7._
     */
    function multiProofVerifyCalldata(
        bytes32[] calldata proof,
        bool[] calldata proofFlags,
        bytes32 root,
        bytes32[] memory leaves
    ) internal pure returns (bool) {
        return processMultiProofCalldata(proof, proofFlags, leaves) == root;
    }

    /**
     * @dev Returns the root of a tree reconstructed from `leaves` and sibling nodes in `proof`. The reconstruction
     * proceeds by incrementally reconstructing all inner nodes by combining a leaf/inner node with either another
     * leaf/inner node or a proof sibling node, depending on whether each `proofFlags` item is true or false
     * respectively.
     *
     * CAUTION: Not all merkle trees admit multiproofs. To use multiproofs, it is sufficient to ensure that: 1) the tree
     * is complete (but not necessarily perfect), 2) the leaves to be proven are in the opposite order they are in the
     * tree (i.e., as seen from right to left starting at the deepest layer and continuing at the next layer).
     *
     * _Available since v4.7._
     */
    function processMultiProof(
        bytes32[] memory proof,
        bool[] memory proofFlags,
        bytes32[] memory leaves
    ) internal pure returns (bytes32 merkleRoot) {
        // This function rebuilds the root hash by traversing the tree up from the leaves. The root is rebuilt by
        // consuming and producing values on a queue. The queue starts with the `leaves` array, then goes onto the
        // `hashes` array. At the end of the process, the last hash in the `hashes` array should contain the root of
        // the merkle tree.
        uint256 leavesLen = leaves.length;
        uint256 proofLen = proof.length;
        uint256 totalHashes = proofFlags.length;

        // Check proof validity.
        require(leavesLen + proofLen - 1 == totalHashes, "MerkleProof: invalid multiproof");

        // The xxxPos values are "pointers" to the next value to consume in each array. All accesses are done using
        // `xxx[xxxPos++]`, which return the current value and increment the pointer, thus mimicking a queue's "pop".
        bytes32[] memory hashes = new bytes32[](totalHashes);
        uint256 leafPos = 0;
        uint256 hashPos = 0;
        uint256 proofPos = 0;
        // At each step, we compute the next hash using two values:
        // - a value from the "main queue". If not all leaves have been consumed, we get the next leaf, otherwise we
        //   get the next hash.
        // - depending on the flag, either another value from the "main queue" (merging branches) or an element from the
        //   `proof` array.
        for (uint256 i = 0; i < totalHashes; i++) {
            bytes32 a = leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++];
            bytes32 b = proofFlags[i]
                ? (leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++])
                : proof[proofPos++];
            hashes[i] = _hashPair(a, b);
        }

        if (totalHashes > 0) {
            require(proofPos == proofLen, "MerkleProof: invalid multiproof");
            unchecked {
                return hashes[totalHashes - 1];
            }
        } else if (leavesLen > 0) {
            return leaves[0];
        } else {
            return proof[0];
        }
    }

    /**
     * @dev Calldata version of {processMultiProof}.
     *
     * CAUTION: Not all merkle trees admit multiproofs. See {processMultiProof} for details.
     *
     * _Available since v4.7._
     */
    function processMultiProofCalldata(
        bytes32[] calldata proof,
        bool[] calldata proofFlags,
        bytes32[] memory leaves
    ) internal pure returns (bytes32 merkleRoot) {
        // This function rebuilds the root hash by traversing the tree up from the leaves. The root is rebuilt by
        // consuming and producing values on a queue. The queue starts with the `leaves` array, then goes onto the
        // `hashes` array. At the end of the process, the last hash in the `hashes` array should contain the root of
        // the merkle tree.
        uint256 leavesLen = leaves.length;
        uint256 proofLen = proof.length;
        uint256 totalHashes = proofFlags.length;

        // Check proof validity.
        require(leavesLen + proofLen - 1 == totalHashes, "MerkleProof: invalid multiproof");

        // The xxxPos values are "pointers" to the next value to consume in each array. All accesses are done using
        // `xxx[xxxPos++]`, which return the current value and increment the pointer, thus mimicking a queue's "pop".
        bytes32[] memory hashes = new bytes32[](totalHashes);
        uint256 leafPos = 0;
        uint256 hashPos = 0;
        uint256 proofPos = 0;
        // At each step, we compute the next hash using two values:
        // - a value from the "main queue". If not all leaves have been consumed, we get the next leaf, otherwise we
        //   get the next hash.
        // - depending on the flag, either another value from the "main queue" (merging branches) or an element from the
        //   `proof` array.
        for (uint256 i = 0; i < totalHashes; i++) {
            bytes32 a = leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++];
            bytes32 b = proofFlags[i]
                ? (leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++])
                : proof[proofPos++];
            hashes[i] = _hashPair(a, b);
        }

        if (totalHashes > 0) {
            require(proofPos == proofLen, "MerkleProof: invalid multiproof");
            unchecked {
                return hashes[totalHashes - 1];
            }
        } else if (leavesLen > 0) {
            return leaves[0];
        } else {
            return proof[0];
        }
    }

    function _hashPair(bytes32 a, bytes32 b) private pure returns (bytes32) {
        return a < b ? _efficientHash(a, b) : _efficientHash(b, a);
    }

    function _efficientHash(bytes32 a, bytes32 b) private pure returns (bytes32 value) {
        /// @solidity memory-safe-assembly
        assembly {
            mstore(0x00, a)
            mstore(0x20, b)
            value := keccak256(0x00, 0x40)
        }
    }
}

File 17 of 28 : TrustedForwarderERC2771Context.sol
// 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();
        }
    }
}

File 18 of 28 : DataTypes.sol
// SPDX-License-Identifier: BSL-1.1
pragma solidity 0.8.19;

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/utils/structs/EnumerableSet.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 condition to apply to order execution.
 */
enum OrderProtocols { 
    // 0: ERC721 order that must execute in full or not at all.
    ERC721_FILL_OR_KILL,

    // 1: ERC1155 order that must execute in full or not at all.
    ERC1155_FILL_OR_KILL,

    // 2: ERC1155 order that may be partially executed.
    ERC1155_FILL_PARTIAL
}

/**
 * @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.
    PricingConstraints,

    // 4: 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 to define the
 * @dev module addresses to be used for the contract.
 */
struct PaymentProcessorModules {
    address modulePaymentSettings;
    address moduleOnChainCancellation;
    address moduleTrades;
    address moduleTradesAdvanced;
}

/**
 * @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 **constraintedPricingPaymentMethod**: The payment method to be used when paymentSettings is set to PricingConstraints.
 * @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.
 * @dev **blockBannedAccounts**: If true, banned accounts can be neither maker or taker for trades on a per-collection basis.
 */
struct CollectionPaymentSettings {
    PaymentSettings paymentSettings;
    uint32 paymentMethodWhitelistId;
    address constrainedPricingPaymentMethod;
    uint16 royaltyBackfillNumerator;
    uint16 royaltyBountyNumerator;
    bool isRoyaltyBountyExclusive;
    bool blockTradesFromUntrustedChannels;
    bool blockBannedAccounts;
}

/**
 * @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 {
    uint8 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.
 */
struct Order {
    OrderProtocols protocol;
    address maker;
    address beneficiary;
    address marketplace;
    address fallbackRoyaltyRecipient;
    address paymentMethod;
    address tokenAddress;
    uint256 tokenId;
    uint248 amount;
    uint256 itemPrice;
    uint256 nonce;
    uint256 expiration;
    uint256 marketplaceFeeNumerator;
    uint256 maxRoyaltyFeeNumerator;
    uint248 requestedFillAmount;
    uint248 minimumFillAmount;
}

/**
 * @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;
    uint8 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 root hash and proof data for accepting an offer that is for a subset
 * @dev of items in a collection. The root hash must match the root hash specified as part of the 
 * @dev maker's order signature.
 * 
 * @dev **rootHash**: The merkletree root hash for the items that may be used to fulfill the offer order.
 * @dev **proof**: The merkle proofs for the item being supplied to fulfill the offer order.
 */
struct TokenSetProof {
    bytes32 rootHash;
    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 the royalty backfill and bounty information. Its data for an
 * @dev order execution is constructed internally based on the collection settings and
 * @dev order execution details.
 * 
 * @dev **backfillNumerator**: The percentage of the order amount to pay as royalties
 * @dev for a collection that does not support ERC2981.
 * @dev **backfillReceiver**: The recipient of backfill royalties.
 * @dev **bountyNumerator**: The percentage of royalties to share with the marketplace for order fulfillment.
 * @dev **exclusiveMarketplace**: If non-zero, the address of the exclusive marketplace for royalty bounties.
 */
struct RoyaltyBackfillAndBounty {
    uint16 backfillNumerator;
    address backfillReceiver;
    uint16 bountyNumerator;
    address exclusiveMarketplace;
}

/**
 * @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 {
    OrderProtocols 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.
 */
struct SweepItem {
    address maker;
    address marketplace;
    address fallbackRoyaltyRecipient;
    uint256 tokenId;
    uint248 amount;
    uint256 itemPrice;
    uint256 nonce;
    uint256 expiration;
    uint256 marketplaceFeeNumerator;
    uint256 maxRoyaltyFeeNumerator;
}

/**
 * @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 isSet;
    uint120 floorPrice;
    uint120 ceilingPrice;
}

/**
 * @dev This struct defines the parameters for a bulk offer acceptance transaction.
 * 
 * 
 * @dev **isCollectionLevelOfferArray**: An array of flags to indicate if an offer is for any token in the collection.
 * @dev **saleDetailsArray**: An array of order execution details.
 * @dev **buyerSignaturesArray**: An array of maker signatures authorizing the order executions.
 * @dev **tokenSetProofsArray**: An array of root hashes and merkle proofs for offers that are a subset of tokens in a collection.
 * @dev **cosignaturesArray**: An array of additional cosignatures for cosigned orders, as applicable.
 * @dev **feesOnTopArray**: An array of additional fees to add on top of the orders, paid by taker.
 */
struct BulkAcceptOffersParams {
    bool[] isCollectionLevelOfferArray;
    Order[] saleDetailsArray;
    SignatureECDSA[] buyerSignaturesArray;
    TokenSetProof[] tokenSetProofsArray;
    Cosignature[] cosignaturesArray;
    FeeOnTop[] feesOnTopArray;
}

/** 
 * @dev Internal contract use only - this is not a public-facing struct
 */
struct SplitProceeds {
    address royaltyRecipient;
    uint256 royaltyProceeds;
    uint256 marketplaceProceeds;
    uint256 sellerProceeds;
}

/** 
 * @dev Internal contract use only - this is not a public-facing struct
 */
struct PayoutsAccumulator {
    address lastSeller;
    address lastMarketplace;
    address lastRoyaltyRecipient;
    uint256 accumulatedSellerProceeds;
    uint256 accumulatedMarketplaceProceeds;
    uint256 accumulatedRoyaltyProceeds;
}

/** 
 * @dev Internal contract use only - this is not a public-facing struct
 */
struct SweepCollectionComputeAndDistributeProceedsParams {
    IERC20 paymentCoin;
    FulfillOrderFunctionPointers fnPointers;
    FeeOnTop feeOnTop;
    RoyaltyBackfillAndBounty royaltyBackfillAndBounty;
    Order[] saleDetailsBatch;
}

/** 
 * @dev Internal contract use only - this is not a public-facing struct
 */
 struct FulfillOrderFunctionPointers {
    function(address,address,IERC20,uint256,uint256) funcPayout;
    function(address,address,address,uint256,uint256) returns (bool) funcDispenseToken;
    function(TradeContext memory, Order memory) funcEmitOrderExecutionEvent;
 }

 /** 
 * @dev Internal contract use only - this is not a public-facing struct
 */
 struct TradeContext {
    bytes32 domainSeparator;
    address channel;
    address taker;
    bool disablePartialFill;
 }

/**
 * @dev This struct defines contract-level storage to be used across all Payment Processor modules.
 * @dev Follows the Diamond storage pattern.
 */
struct PaymentProcessorStorage {
    /// @dev Tracks the most recently created payment method whitelist id
    uint32 lastPaymentMethodWhitelistId;

    /**
     * @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 keccak256 hash of marketplace address and user address.
     *
     * @dev ```keccak256(abi.encodePacked(marketplace, user))```
     *
     * @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 the owner address for the list.
    mapping (uint32 => address) paymentMethodWhitelistOwners;

    /// @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 royalty backfill receiver addresses.
    mapping (address => address) collectionRoyaltyBackfillReceivers;

    /// @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 Mapping of token contract addresses to the defined list of banned accounts for the token contract.
    mapping (address => EnumerableSet.AddressSet) collectionBannedAccounts;

    /// @dev A mapping of all co-signers that have self-destructed and can never be used as cosigners again.
    mapping (address => bool) destroyedCosigners;
}

File 19 of 28 : IERC165.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC165 standard, as defined in the
 * https://eips.ethereum.org/EIPS/eip-165[EIP].
 *
 * Implementers can declare support of contract interfaces, which can then be
 * queried by others ({ERC165Checker}).
 *
 * For an implementation, see {ERC165}.
 */
interface IERC165 {
    /**
     * @dev Returns true if this contract implements the interface defined by
     * `interfaceId`. See the corresponding
     * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
     * to learn more about how these ids are created.
     *
     * This function call must use less than 30 000 gas.
     */
    function supportsInterface(bytes4 interfaceId) external view returns (bool);
}

File 20 of 28 : IERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/IERC20.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
interface IERC20 {
    /**
     * @dev Emitted when `value` tokens are moved from one account (`from`) to
     * another (`to`).
     *
     * Note that `value` may be zero.
     */
    event Transfer(address indexed from, address indexed to, uint256 value);

    /**
     * @dev Emitted when the allowance of a `spender` for an `owner` is set by
     * a call to {approve}. `value` is the new allowance.
     */
    event Approval(address indexed owner, address indexed spender, uint256 value);

    /**
     * @dev Returns the amount of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

    /**
     * @dev Returns the amount of tokens owned by `account`.
     */
    function balanceOf(address account) external view returns (uint256);

    /**
     * @dev Moves `amount` tokens from the caller's account to `to`.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transfer(address to, uint256 amount) external returns (bool);

    /**
     * @dev Returns the remaining number of tokens that `spender` will be
     * allowed to spend on behalf of `owner` through {transferFrom}. This is
     * zero by default.
     *
     * This value changes when {approve} or {transferFrom} are called.
     */
    function allowance(address owner, address spender) external view returns (uint256);

    /**
     * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * IMPORTANT: Beware that changing an allowance with this method brings the risk
     * that someone may use both the old and the new allowance by unfortunate
     * transaction ordering. One possible solution to mitigate this race
     * condition is to first reduce the spender's allowance to 0 and set the
     * desired value afterwards:
     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
     *
     * Emits an {Approval} event.
     */
    function approve(address spender, uint256 amount) external returns (bool);

    /**
     * @dev Moves `amount` tokens from `from` to `to` using the
     * allowance mechanism. `amount` is then deducted from the caller's
     * allowance.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(address from, address to, uint256 amount) external returns (bool);
}

File 21 of 28 : IERC20Permit.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/extensions/IERC20Permit.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
 * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
 *
 * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
 * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't
 * need to send a transaction, and thus is not required to hold Ether at all.
 */
interface IERC20Permit {
    /**
     * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,
     * given ``owner``'s signed approval.
     *
     * IMPORTANT: The same issues {IERC20-approve} has related to transaction
     * ordering also apply here.
     *
     * Emits an {Approval} event.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     * - `deadline` must be a timestamp in the future.
     * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`
     * over the EIP712-formatted function arguments.
     * - the signature must use ``owner``'s current nonce (see {nonces}).
     *
     * For more information on the signature format, see the
     * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP
     * section].
     */
    function permit(
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) external;

    /**
     * @dev Returns the current nonce for `owner`. This value must be
     * included whenever a signature is generated for {permit}.
     *
     * Every successful call to {permit} increases ``owner``'s nonce by one. This
     * prevents a signature from being used multiple times.
     */
    function nonces(address owner) external view returns (uint256);

    /**
     * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.
     */
    // solhint-disable-next-line func-name-mixedcase
    function DOMAIN_SEPARATOR() external view returns (bytes32);
}

File 22 of 28 : Address.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol)

pragma solidity ^0.8.1;

/**
 * @dev Collection of functions related to the address type
 */
library Address {
    /**
     * @dev Returns true if `account` is a contract.
     *
     * [IMPORTANT]
     * ====
     * It is unsafe to assume that an address for which this function returns
     * false is an externally-owned account (EOA) and not a contract.
     *
     * Among others, `isContract` will return false for the following
     * types of addresses:
     *
     *  - an externally-owned account
     *  - a contract in construction
     *  - an address where a contract will be created
     *  - an address where a contract lived, but was destroyed
     *
     * Furthermore, `isContract` will also return true if the target contract within
     * the same transaction is already scheduled for destruction by `SELFDESTRUCT`,
     * which only has an effect at the end of a transaction.
     * ====
     *
     * [IMPORTANT]
     * ====
     * You shouldn't rely on `isContract` to protect against flash loan attacks!
     *
     * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
     * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
     * constructor.
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // This method relies on extcodesize/address.code.length, which returns 0
        // for contracts in construction, since the code is only stored at the end
        // of the constructor execution.

        return account.code.length > 0;
    }

    /**
     * @dev Replacement for Solidity's `transfer`: sends `amount` wei to
     * `recipient`, forwarding all available gas and reverting on errors.
     *
     * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
     * of certain opcodes, possibly making contracts go over the 2300 gas limit
     * imposed by `transfer`, making them unable to receive funds via
     * `transfer`. {sendValue} removes this limitation.
     *
     * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].
     *
     * IMPORTANT: because control is transferred to `recipient`, care must be
     * taken to not create reentrancy vulnerabilities. Consider using
     * {ReentrancyGuard} or the
     * https://solidity.readthedocs.io/en/v0.8.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
     */
    function sendValue(address payable recipient, uint256 amount) internal {
        require(address(this).balance >= amount, "Address: insufficient balance");

        (bool success, ) = recipient.call{value: amount}("");
        require(success, "Address: unable to send value, recipient may have reverted");
    }

    /**
     * @dev Performs a Solidity function call using a low level `call`. A
     * plain `call` is an unsafe replacement for a function call: use this
     * function instead.
     *
     * If `target` reverts with a revert reason, it is bubbled up by this
     * function (like regular Solidity function calls).
     *
     * Returns the raw returned data. To convert to the expected return value,
     * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
     *
     * Requirements:
     *
     * - `target` must be a contract.
     * - calling `target` with `data` must not revert.
     *
     * _Available since v3.1._
     */
    function functionCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionCallWithValue(target, data, 0, "Address: low-level call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
     * `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal returns (bytes memory) {
        return functionCallWithValue(target, data, 0, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but also transferring `value` wei to `target`.
     *
     * Requirements:
     *
     * - the calling contract must have an ETH balance of at least `value`.
     * - the called Solidity function must be `payable`.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
        return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
    }

    /**
     * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
     * with `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(
        address target,
        bytes memory data,
        uint256 value,
        string memory errorMessage
    ) internal returns (bytes memory) {
        require(address(this).balance >= value, "Address: insufficient balance for call");
        (bool success, bytes memory returndata) = target.call{value: value}(data);
        return verifyCallResultFromTarget(target, success, returndata, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
        return functionStaticCall(target, data, "Address: low-level static call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal view returns (bytes memory) {
        (bool success, bytes memory returndata) = target.staticcall(data);
        return verifyCallResultFromTarget(target, success, returndata, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.4._
     */
    function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionDelegateCall(target, data, "Address: low-level delegate call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.4._
     */
    function functionDelegateCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal returns (bytes memory) {
        (bool success, bytes memory returndata) = target.delegatecall(data);
        return verifyCallResultFromTarget(target, success, returndata, errorMessage);
    }

    /**
     * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling
     * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.
     *
     * _Available since v4.8._
     */
    function verifyCallResultFromTarget(
        address target,
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal view returns (bytes memory) {
        if (success) {
            if (returndata.length == 0) {
                // only check isContract if the call was successful and the return data is empty
                // otherwise we already know that it was a contract
                require(isContract(target), "Address: call to non-contract");
            }
            return returndata;
        } else {
            _revert(returndata, errorMessage);
        }
    }

    /**
     * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the
     * revert reason or using the provided one.
     *
     * _Available since v4.3._
     */
    function verifyCallResult(
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal pure returns (bytes memory) {
        if (success) {
            return returndata;
        } else {
            _revert(returndata, errorMessage);
        }
    }

    function _revert(bytes memory returndata, string memory errorMessage) private pure {
        // Look for revert reason and bubble it up if present
        if (returndata.length > 0) {
            // The easiest way to bubble the revert reason is using memory via assembly
            /// @solidity memory-safe-assembly
            assembly {
                let returndata_size := mload(returndata)
                revert(add(32, returndata), returndata_size)
            }
        } else {
            revert(errorMessage);
        }
    }
}

File 23 of 28 : Strings.sol
// 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));
    }
}

File 24 of 28 : Context.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)

pragma solidity ^0.8.0;

/**
 * @dev Provides information about the current execution context, including the
 * sender of the transaction and its data. While these are generally available
 * via msg.sender and msg.data, they should not be accessed in such a direct
 * manner, since when dealing with meta-transactions the account sending and
 * paying for execution may not be the actual sender (as far as an application
 * is concerned).
 *
 * This contract is only required for intermediate, library-like contracts.
 */
abstract contract Context {
    function _msgSender() internal view virtual returns (address) {
        return msg.sender;
    }

    function _msgData() internal view virtual returns (bytes calldata) {
        return msg.data;
    }
}

File 25 of 28 : ITrustedForwarderFactory.sol
// 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);
}

File 26 of 28 : EnumerableSet.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/structs/EnumerableSet.sol)
// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.

pragma solidity ^0.8.0;

/**
 * @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 of the value in the `values` array, plus 1 because index 0
        // means a value is not in the set.
        mapping(bytes32 => uint256) _indexes;
    }

    /**
     * @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._indexes[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 read and store the value's index to prevent multiple reads from the same storage slot
        uint256 valueIndex = set._indexes[value];

        if (valueIndex != 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 toDeleteIndex = valueIndex - 1;
            uint256 lastIndex = set._values.length - 1;

            if (lastIndex != toDeleteIndex) {
                bytes32 lastValue = set._values[lastIndex];

                // Move the last value to the index where the value to delete is
                set._values[toDeleteIndex] = lastValue;
                // Update the index for the moved value
                set._indexes[lastValue] = valueIndex; // Replace lastValue's index to valueIndex
            }

            // Delete the slot where the moved value was stored
            set._values.pop();

            // Delete the index for the deleted slot
            delete set._indexes[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._indexes[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;
    }
}

File 27 of 28 : Math.sol
// 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);
        }
    }
}

File 28 of 28 : SignedMath.sol
// 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);
        }
    }
}

Settings
{
  "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/",
    "TrustedForwarder/=lib/TrustedForwarder/",
    "erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/",
    "openzeppelin-contracts/=lib/openzeppelin-contracts/",
    "openzeppelin/=lib/openzeppelin-contracts/contracts/",
    "solmate/=lib/solmate/src/"
  ],
  "optimizer": {
    "enabled": true,
    "runs": 30000
  },
  "metadata": {
    "useLiteralContent": false,
    "bytecodeHash": "ipfs",
    "appendCBOR": true
  },
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  },
  "evmVersion": "paris",
  "libraries": {}
}

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"address","name":"configurationContract","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"PaymentProcessor__AmountForERC1155SalesGreaterThanZero","type":"error"},{"inputs":[],"name":"PaymentProcessor__AmountForERC721SalesMustEqualOne","type":"error"},{"inputs":[],"name":"PaymentProcessor__BadPaymentMethod","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__IncorrectTokenSetMerkleProof","type":"error"},{"inputs":[],"name":"PaymentProcessor__InputArrayLengthCannotBeZero","type":"error"},{"inputs":[],"name":"PaymentProcessor__InputArrayLengthMismatch","type":"error"},{"inputs":[],"name":"PaymentProcessor__InvalidConstructorArguments","type":"error"},{"inputs":[],"name":"PaymentProcessor__MakerOrTakerIsBannedAccount","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__RanOutOfNativeFunds","type":"error"},{"inputs":[],"name":"PaymentProcessor__SalePriceAboveMaximumCeiling","type":"error"},{"inputs":[],"name":"PaymentProcessor__SalePriceBelowMinimumFloor","type":"error"},{"inputs":[],"name":"PaymentProcessor__SignatureAlreadyUsedOrRevoked","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":"tokenAddress","type":"address"},{"indexed":true,"internalType":"address","name":"account","type":"address"}],"name":"BannedAccountAddedForCollection","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"tokenAddress","type":"address"},{"indexed":true,"internalType":"address","name":"account","type":"address"}],"name":"BannedAccountRemovedForCollection","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":"uint32","name":"paymentMethodWhitelistId","type":"uint32"},{"indexed":true,"internalType":"address","name":"whitelistOwner","type":"address"},{"indexed":false,"internalType":"string","name":"whitelistName","type":"string"}],"name":"CreatedPaymentMethodWhitelist","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":"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":"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":"uint32","name":"id","type":"uint32"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"ReassignedPaymentMethodWhitelistOwnership","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":"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":"blockBannedAccounts","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":[{"internalType":"bytes32","name":"domainSeparator","type":"bytes32"},{"internalType":"bool","name":"isCollectionLevelOffer","type":"bool"},{"components":[{"internalType":"enum OrderProtocols","name":"protocol","type":"uint8"},{"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":"uint248","name":"amount","type":"uint248"},{"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":"uint248","name":"requestedFillAmount","type":"uint248"},{"internalType":"uint248","name":"minimumFillAmount","type":"uint248"}],"internalType":"struct Order","name":"saleDetails","type":"tuple"},{"components":[{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"internalType":"struct SignatureECDSA","name":"buyerSignature","type":"tuple"},{"components":[{"internalType":"bytes32","name":"rootHash","type":"bytes32"},{"internalType":"bytes32[]","name":"proof","type":"bytes32[]"}],"internalType":"struct TokenSetProof","name":"tokenSetProof","type":"tuple"},{"components":[{"internalType":"address","name":"signer","type":"address"},{"internalType":"address","name":"taker","type":"address"},{"internalType":"uint256","name":"expiration","type":"uint256"},{"internalType":"uint8","name":"v","type":"uint8"},{"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":"acceptOffer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"domainSeparator","type":"bytes32"},{"components":[{"internalType":"bool[]","name":"isCollectionLevelOfferArray","type":"bool[]"},{"components":[{"internalType":"enum OrderProtocols","name":"protocol","type":"uint8"},{"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":"uint248","name":"amount","type":"uint248"},{"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":"uint248","name":"requestedFillAmount","type":"uint248"},{"internalType":"uint248","name":"minimumFillAmount","type":"uint248"}],"internalType":"struct Order[]","name":"saleDetailsArray","type":"tuple[]"},{"components":[{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"internalType":"struct SignatureECDSA[]","name":"buyerSignaturesArray","type":"tuple[]"},{"components":[{"internalType":"bytes32","name":"rootHash","type":"bytes32"},{"internalType":"bytes32[]","name":"proof","type":"bytes32[]"}],"internalType":"struct TokenSetProof[]","name":"tokenSetProofsArray","type":"tuple[]"},{"components":[{"internalType":"address","name":"signer","type":"address"},{"internalType":"address","name":"taker","type":"address"},{"internalType":"uint256","name":"expiration","type":"uint256"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"internalType":"struct Cosignature[]","name":"cosignaturesArray","type":"tuple[]"},{"components":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"internalType":"struct FeeOnTop[]","name":"feesOnTopArray","type":"tuple[]"}],"internalType":"struct BulkAcceptOffersParams","name":"params","type":"tuple"}],"name":"bulkAcceptOffers","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"domainSeparator","type":"bytes32"},{"components":[{"internalType":"enum OrderProtocols","name":"protocol","type":"uint8"},{"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":"uint248","name":"amount","type":"uint248"},{"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":"uint248","name":"requestedFillAmount","type":"uint248"},{"internalType":"uint248","name":"minimumFillAmount","type":"uint248"}],"internalType":"struct Order[]","name":"saleDetailsArray","type":"tuple[]"},{"components":[{"internalType":"uint8","name":"v","type":"uint8"},{"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":"uint8","name":"v","type":"uint8"},{"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":[{"internalType":"bytes32","name":"domainSeparator","type":"bytes32"},{"components":[{"internalType":"enum OrderProtocols","name":"protocol","type":"uint8"},{"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":"uint248","name":"amount","type":"uint248"},{"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":"uint248","name":"requestedFillAmount","type":"uint248"},{"internalType":"uint248","name":"minimumFillAmount","type":"uint248"}],"internalType":"struct Order","name":"saleDetails","type":"tuple"},{"components":[{"internalType":"uint8","name":"v","type":"uint8"},{"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":"uint8","name":"v","type":"uint8"},{"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":[{"internalType":"address","name":"forwarder","type":"address"}],"name":"isTrustedForwarder","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"wrappedNativeCoinAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"}]

6101606040523480156200001257600080fd5b506040516200522c3803806200522c8339810160408190526200003591620001c9565b80806001600160a01b031663ed7e776c6040518163ffffffff1660e01b8152600401602060405180830381865afa15801562000075573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200009b9190620001c9565b806001600160a01b03166080816001600160a01b031681525050506000806000836001600160a01b0316638e71e7196040518163ffffffff1660e01b815260040160c060405180830381865afa158015620000fa573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620001209190620001ee565b9250925092508263ffffffff16600014806200014357506001600160a01b038216155b15620001625760405163049b2c3f60e31b815260040160405180910390fd5b63ffffffff90921660a0526001600160a01b0390811660c0528151811660e05260208201518116610100526040820151811661012052606090910151166101405250620002ca9050565b80516001600160a01b0381168114620001c457600080fd5b919050565b600060208284031215620001dc57600080fd5b620001e782620001ac565b9392505050565b600080600083850360c08112156200020557600080fd5b845163ffffffff811681146200021a57600080fd5b93506200022a60208601620001ac565b92506080603f19820112156200023f57600080fd5b50604051608081016001600160401b03811182821017156200027157634e487b7160e01b600052604160045260246000fd5b80604052506200028460408601620001ac565b81526200029460608601620001ac565b6020820152620002a760808601620001ac565b6040820152620002ba60a08601620001ac565b6060820152809150509250925092565b60805160a05160c05160e051610100516101205161014051614ed06200035c6000396000612e4101526000612de601526000612d8b01526000612d3001526000818160f9015281816104b00152818161052d015281816106fd015261077a015260008181611d9301528181611dda01528181611e1d0152611ea30152600081816105f80152610bdd0152614ed06000f3fe6080604052600436106100655760003560e01c8063b3cdebdb11610043578063b3cdebdb146100c7578063b5ca58e5146100e7578063e35bb9b71461014057600080fd5b806327add0471461006a578063572b6c051461007f578063a9272951146100b4575b600080fd5b61007d6100783660046140fe565b610160565b005b34801561008b57600080fd5b5061009f61009a36600461422f565b6105b0565b60405190151581526020015b60405180910390f35b61007d6100c23660046145a1565b61066b565b3480156100d357600080fd5b5061007d6100e2366004614970565b6107f5565b3480156100f357600080fd5b5061011b7f000000000000000000000000000000000000000000000000000000000000000081565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020016100ab565b34801561014c57600080fd5b5061007d61015b366004614a9d565b610b22565b868514610199576040517fb62503e300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8683146101d2576040517fb62503e300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b86811461020b576040517fb62503e300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000879003610246576040517fdb560cb500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b604080516080810182528a815233602082015234916103608a0236037ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffedc019160009181016014841461029857336102a0565b6102a0610bac565b73ffffffffffffffffffffffffffffffffffffffff1681526000602091820181905260408051610200810182528281529283018290528201819052606082018190526080820181905260a0820181905260c0820181905260e08201819052610100820181905261012082018190526101408201819052610160820181905261018082018190526101a082018190526101c082018190526101e082015290915060408051606081018252600080825260208201819052918101919091526040805160c081018252600080825260208201819052918101829052606081018290526080810182905260a0810191909152604080518082019091526000808252602082015260005b8e8110156104a4578f8f828181106103bf576103bf614b42565b905061020002018036038101906103d69190614b71565b94508d8d828181106103ea576103ea614b42565b9050606002018036038101906104009190614b8e565b93508b8b8281811061041457610414614b42565b905060c0020180360381019061042a9190614baa565b925089898281811061043e5761043e614b42565b9050604002018036038101906104549190614bc6565b60a086015190925073ffffffffffffffffffffffffffffffffffffffff1661048b57610484868987878787610c9a565b975061049c565b61049a86600087878787610c9a565b505b6001016103a5565b50861561059e576104d67f0000000000000000000000000000000000000000000000000000000000000000885a610e44565b60408581015190517f23b872dd00000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff9182166024820152604481018990527f0000000000000000000000000000000000000000000000000000000000000000909116906323b872dd906064016020604051808303816000875af1158015610578573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061059c9190614be2565b505b50505050505050505050505050505050565b6040517f572b6c0500000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff82811660048301526000917f00000000000000000000000000000000000000000000000000000000000000009091169063572b6c0590602401602060405180830381865afa158015610641573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106659190614be2565b92915050565b604080516080810182528681523360208201527ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc7c360191600091908101601484146106b657336106be565b6106be610bac565b73ffffffffffffffffffffffffffffffffffffffff1681526001602090910152905060006106f0823489898989610c9a565b905080156107eb576107237f0000000000000000000000000000000000000000000000000000000000000000825a610e44565b60408281015190517f23b872dd00000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff9182166024820152604481018390527f0000000000000000000000000000000000000000000000000000000000000000909116906323b872dd906064016020604051808303816000875af11580156107c5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107e99190614be2565b505b5050505050505050565b80515160208201515114610835576040517fb62503e300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b80604001515181602001515114610878576040517fb62503e300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b806060015151816020015151146108bb576040517fb62503e300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b806080015151816020015151146108fe576040517fb62503e300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8060a001515181602001515114610941576040517fb62503e300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b806020015151600003610980576040517fdb560cb500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6020810151516104000236037ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe3c0160005b8260600151518110156109f357826060015181815181106109d4576109d4614b42565b60200260200101516020015151602002820391508060010190506109b1565b5060408051608081018252848152336020820152600091810160148414610a1a5733610a22565b610a22610bac565b73ffffffffffffffffffffffffffffffffffffffff16815260200160001515815250905060005b836020015151811015610b1b57610b138285600001518381518110610a7057610a70614b42565b602002602001015186602001518481518110610a8e57610a8e614b42565b602002602001015187604001518581518110610aac57610aac614b42565b602002602001015188606001518681518110610aca57610aca614b42565b602002602001015189608001518781518110610ae857610ae8614b42565b60200260200101518a60a001518881518110610b0657610b06614b42565b6020026020010151610e8f565b600101610a49565b5050505050565b60208084015151604080516080810182528a815233818501529190920236037ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffbdc01916107eb9190810160148414610b795733610b81565b610b81610bac565b73ffffffffffffffffffffffffffffffffffffffff1681526001602090910152888888888888610e8f565b6040517f572b6c050000000000000000000000000000000000000000000000000000000081523360048201526000907f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff169063572b6c0590602401602060405180830381865afa158015610c39573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c5d9190614be2565b15610c955760143610610c9557507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec36013560601c90565b503390565b600080610ca98887878761114d565b90508561010001517effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff16817effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1614610df9578561010001517effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff16866101200151610d309190614c2e565b15610d67576040517ffe41cfc900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b807effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff168661010001517effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff16876101200151610dc09190614c71565b610dca9190614c85565b6101208701527effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff81166101008701525b6000610e058988611426565b9050610e37888a8b604001518a602001518b60a00151610e2f60008e60a001518f60000151611b00565b8d888c611c19565b9998505050505050505050565b6000806000806000868887f1905080610e89576040517f6c998d3e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b50505050565b60a085015173ffffffffffffffffffffffffffffffffffffffff16610ee0576040517f1f9ed49100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60008615610fa5578351610f0157610efa88878786611ef0565b9050610fb4565b602080850151855160c089015160e08a0151604051610f6295610f479392910173ffffffffffffffffffffffffffffffffffffffff929092168252602082015260400190565b60405160208183030381529060405280519060200120612109565b610f98576040517f12f0d2cc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610efa888787878761211f565b610fb1888787866123a4565b90505b8561010001517effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff16817effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1614611102578561010001517effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff168661012001516110399190614c2e565b15611070576040517ffe41cfc900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b807effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff168661010001517effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff168761012001516110c99190614c71565b6110d39190614c85565b6101208701527effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff81166101008701525b600061110e8988611426565b905061114160008a89602001518c604001518b60a0015161113960018e60a001518f60000151611b00565b8d888b611c19565b50505050505050505050565b805160009073ffffffffffffffffffffffffffffffffffffffff1615611178576111788584846125cf565b845184516000916113c6917f938786a8256d04dc45d6d5b997005aa07c0c9e3e4925d0d6c33128d240096ebc9060028111156111b6576111b6614c9c565b866000015189602001518a606001518b608001518c60a001518d60c001518e60e001516040516020016112489998979695949392919098895260ff97909716602089015273ffffffffffffffffffffffffffffffffffffffff958616604089015293851660608801529184166080870152831660a0860152821660c08501521660e08301526101008201526101200190565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529190526101008801516101208901516101608a01516101808b01516101a08c01516101408d015160028e5160028111156112af576112af614c9c565b146112ce576112c98e602001518f6101400151600061280b565b611319565b6020808f015173ffffffffffffffffffffffffffffffffffffffff1660009081527f06290179fae592fb2a78508cd3db8ee54727dcb8adda2f153fc506694ab1f84c90915260409020545b604080517effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff90981660208901528701959095526060860193909352608085019190915260a084015260c083015260e0820152610100015b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0818403018152908290526113ab9291602001614cef565b60405160208183030381529060405280519060200120612942565b90506113d785602001518583612985565b6002855160028111156113ec576113ec614c9c565b146113fc5784610100015161141c565b61141c856020015182876101000151886101c00151896101e00151612a29565b9695505050505050565b60408051608081018252600080825260208201819052918101829052606081019190915260008251600281111561145f5761145f614c9c565b036114c95760018261010001517effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff16146114c4576040517fdb3ca79a00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b611529565b8161010001517effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff16600003611529576040517f26db27f100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b816101600151421115611568576040517fac492cc000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b612710826101a001518361018001516115819190614d1e565b11156115b9576040517fca9d1e5400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60c082015173ffffffffffffffffffffffffffffffffffffffff1660009081527f06290179fae592fb2a78508cd3db8ee54727dcb8adda2f153fc506694ab1f84e602052604090819020805461ffff7901000000000000000000000000000000000000000000000000008204811685527b01000000000000000000000000000000000000000000000000000000820416928401929092529060ff808216917f01000000000000000000000000000000000000000000000000000000000000009004161561175a5760c084015173ffffffffffffffffffffffffffffffffffffffff1660009081527f06290179fae592fb2a78508cd3db8ee54727dcb8adda2f153fc506694ab1f85760209081526040909120908501516116da908290612cd0565b15611711576040517fadffdc8600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040860151611721908290612cd0565b15611758576040517fadffdc8600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b505b81547e01000000000000000000000000000000000000000000000000000000000000900460ff16156118265760c084015173ffffffffffffffffffffffffffffffffffffffff1660009081527f06290179fae592fb2a78508cd3db8ee54727dcb8adda2f153fc506694ab1f85660205260408120906117d882612cff565b11156118245760208601516117ee908290612cd0565b611824576040517f292d235200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b505b8154790100000000000000000000000000000000000000000000000000900461ffff16156118a45760c084015173ffffffffffffffffffffffffffffffffffffffff90811660009081527f06290179fae592fb2a78508cd3db8ee54727dcb8adda2f153fc506694ab1f8536020908152604090912054909116908401525b81547d010000000000000000000000000000000000000000000000000000000000900460ff16156119215760c084015173ffffffffffffffffffffffffffffffffffffffff90811660009081527f06290179fae592fb2a78508cd3db8ee54727dcb8adda2f153fc506694ab1f85460205260409020541660608401525b600081600481111561193557611935614c9c565b03611982576119478460a00151612d09565b61197d576040517fab9c00de00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b611af8565b600281600481111561199657611996614c9c565b036119f4576119478460a001516119ca7f06290179fae592fb2a78508cd3db8ee54727dcb8adda2f153fc506694ab1f84b90565b845463ffffffff6101009091048116600090815260059290920160205260409091209190612cd016565b6003816004811115611a0857611a08614c9c565b03611aad5760a0840151825465010000000000900473ffffffffffffffffffffffffffffffffffffffff908116911614611a6e576040517fab9c00de00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61197d8460c001518560e001518661010001517effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff16876101200151612ef1565b6004816004811115611ac157611ac1614c9c565b03611af8576040517fba78259100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b505092915050565b611b2760405180606001604052806140258152602001614025815260200161402581525090565b60408051606081019091528073ffffffffffffffffffffffffffffffffffffffff851615611b5757612f93611b5b565b612f9f5b67ffffffffffffffff1681526020016000846002811115611b7e57611b7e614c9c565b14611b8b57612faa611b8f565b6130665b67ffffffffffffffff1681526020016000846002811115611bb257611bb2614c9c565b14611be0576000866001811115611bcb57611bcb614c9c565b14611bd8576130cd611c05565b6131d1611c05565b6000866001811115611bf457611bf4614c9c565b14611c01576132c9611c05565b6133915b67ffffffffffffffff169052949350505050565b6000899050611c658785604001518660c001518760e001518861010001517effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff168a6020015163ffffffff16565b611caa57886060015115611ca5576040517ff40863ff00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610e37565b6000611cdb8561012001518660c001518760e0015188606001518961018001518a6101a001518b608001518b613459565b835190915060009073ffffffffffffffffffffffffffffffffffffffff1615611d05575060208301515b60a086015173ffffffffffffffffffffffffffffffffffffffff16611d7857600081876101200151611d379190614d1e565b905080841015611d73576040517f70d5b32e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b909203915b602082015115611dbf57611dbf82600001518b8a85602001517f00000000000000000000000000000000000000000000000000000000000000008c6000015163ffffffff16565b604082015115611e0657611e0686606001518b8a85604001517f00000000000000000000000000000000000000000000000000000000000000008c6000015163ffffffff16565b606082015115611e4957611e49898b8a85606001517f00000000000000000000000000000000000000000000000000000000000000008c6000015163ffffffff16565b8015611ecf57856101200151811115611e8e576040517f1d6203f500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b611ecf84600001518c604001518a87602001517f00000000000000000000000000000000000000000000000000000000000000008c6000015163ffffffff16565b611ee18b87896040015163ffffffff16565b50509998505050505050505050565b805160009073ffffffffffffffffffffffffffffffffffffffff1615611f1b57611f1b8584846125cf565b845184516000916113c6917f8fe9498e93fe26b30ebf76fac07bd4705201c8609227362697082288e3b4af9c906002811115611f5957611f59614c9c565b866000015189602001518a604001518b606001518c608001518d60a001518e60c00151604051602001611fed9998979695949392919098895260ff97909716602089015273ffffffffffffffffffffffffffffffffffffffff958616604089015293851660608801529184166080870152831660a0860152821660c0850152811660e0840152166101008201526101200190565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529190526101008801516101208901516101608a01516101808b01516101408c015160028d51600281111561204e5761204e614c9c565b1461206d576120688d602001518e6101400151600061280b565b6120b8565b60208d81015173ffffffffffffffffffffffffffffffffffffffff1660009081527f06290179fae592fb2a78508cd3db8ee54727dcb8adda2f153fc506694ab1f84c90915260409020545b604080517effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff90971660208801528601949094526060850192909252608084015260a083015260c082015260e00161136f565b6000826121168584613830565b14949350505050565b805160009073ffffffffffffffffffffffffffffffffffffffff161561214a5761214a8685846125cf565b85518551600091612343917f244905ade6b0e455d12fb539a4b17d7f675db14797d514168d09814a09c70e7090600281111561218857612188614c9c565b86600001518a602001518b604001518c606001518d608001518e60a001518f60c0015160405160200161221c9998979695949392919098895260ff97909716602089015273ffffffffffffffffffffffffffffffffffffffff958616604089015293851660608801529184166080870152831660a0860152821660c0850152811660e0840152166101008201526101200190565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529190526101008901516101208a01516101608b01516101808c01516101408d015160028e51600281111561227d5761227d614c9c565b1461229c576122978e602001518f6101400151600061280b565b6122e7565b6020808f015173ffffffffffffffffffffffffffffffffffffffff1660009081527f06290179fae592fb2a78508cd3db8ee54727dcb8adda2f153fc506694ab1f84c90915260409020545b8c51604080517effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff90981660208901528701959095526060860193909352608085019190915260a084015260c083015260e08201526101000161136f565b905061235486602001518683612985565b60028651600281111561236957612369614c9c565b1461237957856101000151612399565b612399866020015182886101000151896101c001518a6101e00151612a29565b979650505050505050565b805160009073ffffffffffffffffffffffffffffffffffffffff16156123cf576123cf8584846125cf565b845184516000916113c6917fce2e9706d63e89ddf7ee16ce0508a1c3c9bd1904c582db2e647e6f4690a0bf6b90600281111561240d5761240d614c9c565b866000015189602001518a604001518b606001518c608001518d60a001518e60c001516040516020016124a19998979695949392919098895260ff97909716602089015273ffffffffffffffffffffffffffffffffffffffff958616604089015293851660608801529184166080870152831660a0860152821660c0850152811660e0840152166101008201526101200190565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe081840301815291905260e08801516101008901516101208a01516101608b01516101808c01516101408d015160028e51600281111561250757612507614c9c565b14612526576125218e602001518f6101400151600061280b565b612571565b6020808f015173ffffffffffffffffffffffffffffffffffffffff1660009081527f06290179fae592fb2a78508cd3db8ee54727dcb8adda2f153fc506694ab1f84c90915260409020545b6040805160208101989098527effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff909616958701959095526060860193909352608085019190915260a084015260c083015260e08201526101000161136f565b806040015142111561260d576040517f39db6a8400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b806020015173ffffffffffffffffffffffffffffffffffffffff16836040015173ffffffffffffffffffffffffffffffffffffffff161461267a576040517f53b220dd00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b805173ffffffffffffffffffffffffffffffffffffffff1660009081527f06290179fae592fb2a78508cd3db8ee54727dcb8adda2f153fc506694ab1f858602052604090205460ff16156126fa576040517fb5095d2d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b82518251602080850151604080870151868201518785015183517f347b7818601b168f6faadc037723496e9130b057c1ffef2ec4128311e19142f29681019690965260ff909616928501929092526060840192909252608083019190915260a082015273ffffffffffffffffffffffffffffffffffffffff90911660c082015261279e9161278a9160e0016113ab565b826060015183608001518460a0015161387d565b73ffffffffffffffffffffffffffffffffffffffff16816000015173ffffffffffffffffffffffffffffffffffffffff1614612806576040517fdb2d3d4e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b505050565b73ffffffffffffffffffffffffffffffffffffffff831660009081527f06290179fae592fb2a78508cd3db8ee54727dcb8adda2f153fc506694ab1f84d60209081526040808320600886901c845290915281208054600160ff86161b90811891829055166128a5576040517f548db54000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8373ffffffffffffffffffffffffffffffffffffffff16837ff3003920635c7d35c4f314eaeeed4b4c653ccb36608a86d57df761d460eab09d846040516128f0911515815260200190565b60405180910390a350505073ffffffffffffffffffffffffffffffffffffffff1660009081527f06290179fae592fb2a78508cd3db8ee54727dcb8adda2f153fc506694ab1f84c602052604090205490565b6040517f190100000000000000000000000000000000000000000000000000000000000081526002810183905260228101829052604290206000905b9392505050565b61299d8183600001518460200151856040015161387d565b73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16146128065773ffffffffffffffffffffffffffffffffffffffff83163b156129f7576128068382846139ac565b6040517f33e929a000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff851660009081527f06290179fae592fb2a78508cd3db8ee54727dcb8adda2f153fc506694ab1f855602090815260408083208784529091528120805484929060ff166002811115612a9157612a91614c9c565b03612c9457805461010090047effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff16600003612af457805460ff166101007effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8716021781555b80547effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff61010090910481169083161115612b5257805461010090047effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1691505b827effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff16827effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff161015612bce576040517fa10cbd9500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b80547effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff61010080830482168590038216810260ff909316929092178084559190910416600003612c8f5780547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660011781556040516000815273ffffffffffffffffffffffffffffffffffffffff88169087907fc63c82396a1b7865295ff481988a98493c2c3cc29066c229b8001c6f5dd647a99060200160405180910390a35b612cc6565b6040517fab2ccbf500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5095945050505050565b73ffffffffffffffffffffffffffffffffffffffff81166000908152600183016020526040812054151561297e565b6000610665825490565b600073ffffffffffffffffffffffffffffffffffffffff8216612d2e57506001919050565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603612d8957506001919050565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603612de457506001919050565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603612e3f57506001919050565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603612e9a57506001919050565b600080527f06290179fae592fb2a78508cd3db8ee54727dcb8adda2f153fc506694ab1f8506020526106657f7e3fc5ae914741b6ec1965d9e45a90f0f1bf058adf965b4325d4338c7ac8f9ff83612cd0565b919050565b600080612efe8686613b28565b915091506000848481612f1357612f13614bff565b04905081811115612f50576040517f9837ddd700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b82811015612f8a576040517f9318944000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b50505050505050565b610b1b83858785613cec565b610b1b858383610e44565b6040517ff242432a00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff86811660048301528581166024830152604482018490526064820183905260a06084830152600060a48301819052919085169063f242432a9060c4015b600060405180830381600087803b15801561303c57600080fd5b505af192505050801561304d575060015b6130595750600061305d565b5060015b95945050505050565b6040517f23b872dd00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8681166004830152858116602483015260448201849052600091908516906323b872dd90606401613022565b8060c0015173ffffffffffffffffffffffffffffffffffffffff16816020015173ffffffffffffffffffffffffffffffffffffffff16836040015173ffffffffffffffffffffffffffffffffffffffff167f6f4c56c4b9a9d2479f963d802b19d17b02293ce1225461ac0cb846c482ee3c3e84604001518560a001518660e001518761010001518861012001516040516131c595949392919073ffffffffffffffffffffffffffffffffffffffff958616815293909416602084015260408301919091527effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff166060820152608081019190915260a00190565b60405180910390a45050565b8060c0015173ffffffffffffffffffffffffffffffffffffffff16816020015173ffffffffffffffffffffffffffffffffffffffff16836040015173ffffffffffffffffffffffffffffffffffffffff167f1217006325a98bdcc6afc9c44965bb66ac7460a44dc57c2ac47622561d25c45a84604001518560a001518660e001518761010001518861012001516040516131c595949392919073ffffffffffffffffffffffffffffffffffffffff958616815293909416602084015260408301919091527effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff166060820152608081019190915260a00190565b8060c0015173ffffffffffffffffffffffffffffffffffffffff16816020015173ffffffffffffffffffffffffffffffffffffffff16836040015173ffffffffffffffffffffffffffffffffffffffff167f8b87c0b049fe52718fe6ff466b514c5a93c405fb0de8fbd761a23483f9f9e19884604001518560a001518660e001518761012001516040516131c5949392919073ffffffffffffffffffffffffffffffffffffffff94851681529290931660208301526040820152606081019190915260800190565b8060c0015173ffffffffffffffffffffffffffffffffffffffff16816020015173ffffffffffffffffffffffffffffffffffffffff16836040015173ffffffffffffffffffffffffffffffffffffffff167fffb29e9cf48456d56b6d414855b66a7ec060ce2054dcb124a1876310e1b7355c84604001518560a001518660e001518761012001516040516131c5949392919073ffffffffffffffffffffffffffffffffffffffff94851681529290931660208301526040820152606081019190915260800190565b61349a6040518060800160405280600073ffffffffffffffffffffffffffffffffffffffff1681526020016000815260200160008152602001600081525090565b606081018990526040517f2a55205a00000000000000000000000000000000000000000000000000000000815260048101889052602481018a905273ffffffffffffffffffffffffffffffffffffffff891690632a55205a906044016040805180830381865afa92505050801561354c575060408051601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016820190925261354991810190614d31565b60015b613698573d80801561357a576040519150601f19603f3d011682016040523d82523d6000602084013e61357f565b606091505b50602083015173ffffffffffffffffffffffffffffffffffffffff161561363257825161ffff168510156135df576040517f1bdbc8f400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b602083015173ffffffffffffffffffffffffffffffffffffffff1682528251612710906136109061ffff168c614c85565b61361a9190614c71565b60208301819052606083018051919091039052613692565b73ffffffffffffffffffffffffffffffffffffffff8416156136925773ffffffffffffffffffffffffffffffffffffffff84168252612710613674868c614c85565b61367e9190614c71565b602083018190526060830180519190910390525b5061373c565b73ffffffffffffffffffffffffffffffffffffffff82166136b7575060005b8015613739576127106136ca878d614c85565b6136d49190614c71565b81111561370d576040517f1bdbc8f400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff821683526020830181905260608301805182900390525b50505b73ffffffffffffffffffffffffffffffffffffffff86161561382457612710613765868b614c85565b61376f9190614c71565b60408201819052606080830180519290920390915282015173ffffffffffffffffffffffffffffffffffffffff1615806137d857508573ffffffffffffffffffffffffffffffffffffffff16826060015173ffffffffffffffffffffffffffffffffffffffff16145b15613824576000612710836040015161ffff1683602001516137fa9190614c85565b6138049190614c71565b90508015613822576020820180518290039052604082018051820190525b505b98975050505050505050565b600081815b8451811015613875576138618286838151811061385457613854614b42565b6020026020010151613d81565b91508061386d81614d5f565b915050613835565b509392505050565b60007f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a08211156138d9576040517f33e929a000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60408051600081526020810180835287905260ff861691810191909152606081018490526080810183905260019060a0016020604051602081039080840390855afa15801561392c573d6000803e3d6000fd5b50506040517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0015191505073ffffffffffffffffffffffffffffffffffffffff81166139a4576040517f33e929a000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b949350505050565b60008373ffffffffffffffffffffffffffffffffffffffff16631626ba7e84846020015185604001518660000151604051602001613a2293929190928352602083019190915260f81b7fff0000000000000000000000000000000000000000000000000000000000000016604082015260410190565b6040516020818303038152906040526040518363ffffffff1660e01b8152600401613a4e929190614de1565b602060405180830381865afa925050508015613aa5575060408051601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0168201909252613aa291810190614dfa565b60015b15613af1577fffffffff00000000000000000000000000000000000000000000000000000000167f1626ba7e000000000000000000000000000000000000000000000000000000001490505b80610e89576040517ff83b002000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff821660009081527f06290179fae592fb2a78508cd3db8ee54727dcb8adda2f153fc506694ab1f8526020908152604080832084845282528083208151606081018352905460ff811615801583526effffffffffffffffffffffffffffff6101008304811695840195909552700100000000000000000000000000000000909104909316918101919091528291613bf55760208101516040909101516effffffffffffffffffffffffffffff9182169350169050613ce5565b73ffffffffffffffffffffffffffffffffffffffff851660009081527f06290179fae592fb2a78508cd3db8ee54727dcb8adda2f153fc506694ab1f85160209081526040918290208251606081018452905460ff811615801583526effffffffffffffffffffffffffffff610100830481169484019490945270010000000000000000000000000000000090910490921692810192909252613cbb5760208101516040909101516effffffffffffffffffffffffffffff9182169450169150613ce59050565b5060007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff92509250505b9250929050565b6040805173ffffffffffffffffffffffffffffffffffffffff85811660248301528416604482015260648082018490528251808303909101815260849091019091526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f23b872dd00000000000000000000000000000000000000000000000000000000179052610e89908590613db0565b6000818310613d9d57600082815260208490526040902061297e565b600083815260208390526040902061297e565b6000613e12826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff16613ec49092919063ffffffff16565b9050805160001480613e33575080806020019051810190613e339190614be2565b612806576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f7420737563636565640000000000000000000000000000000000000000000060648201526084015b60405180910390fd5b60606139a48484600085856000808673ffffffffffffffffffffffffffffffffffffffff168587604051613ef89190614e3c565b60006040518083038185875af1925050503d8060008114613f35576040519150601f19603f3d011682016040523d82523d6000602084013e613f3a565b606091505b50915091506123998783838760608315613fdc578251600003613fd55773ffffffffffffffffffffffffffffffffffffffff85163b613fd5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401613ebb565b50816139a4565b6139a48383815115613ff15781518083602001fd5b806040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401613ebb9190614e58565b61402d614e6b565b565b60008083601f84011261404157600080fd5b50813567ffffffffffffffff81111561405957600080fd5b602083019150836020606083028501011115613ce557600080fd5b60008083601f84011261408657600080fd5b50813567ffffffffffffffff81111561409e57600080fd5b60208301915083602060c083028501011115613ce557600080fd5b60008083601f8401126140cb57600080fd5b50813567ffffffffffffffff8111156140e357600080fd5b6020830191508360208260061b8501011115613ce557600080fd5b600080600080600080600080600060a08a8c03121561411c57600080fd5b8935985060208a013567ffffffffffffffff8082111561413b57600080fd5b818c0191508c601f83011261414f57600080fd5b81358181111561415e57600080fd5b8d60208260091b850101111561417357600080fd5b602083019a508099505060408c013591508082111561419157600080fd5b61419d8d838e0161402f565b909850965060608c01359150808211156141b657600080fd5b6141c28d838e01614074565b909650945060808c01359150808211156141db57600080fd5b506141e88c828d016140b9565b915080935050809150509295985092959850929598565b73ffffffffffffffffffffffffffffffffffffffff8116811461422157600080fd5b50565b8035612eec816141ff565b60006020828403121561424157600080fd5b813561297e816141ff565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b604051610200810167ffffffffffffffff8111828210171561429f5761429f61424c565b60405290565b60405160c0810167ffffffffffffffff8111828210171561429f5761429f61424c565b6040805190810167ffffffffffffffff8111828210171561429f5761429f61424c565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff811182821017156143325761433261424c565b604052919050565b803560038110612eec57600080fd5b80357effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff81168114612eec57600080fd5b6000610200828403121561438b57600080fd5b61439361427b565b905061439e8261433a565b81526143ac60208301614224565b60208201526143bd60408301614224565b60408201526143ce60608301614224565b60608201526143df60808301614224565b60808201526143f060a08301614224565b60a082015261440160c08301614224565b60c082015260e082013560e082015261010061441e818401614349565b9082015261012082810135908201526101408083013590820152610160808301359082015261018080830135908201526101a080830135908201526101c0614467818401614349565b908201526101e0614479838201614349565b9082015292915050565b803560ff81168114612eec57600080fd5b6000606082840312156144a657600080fd5b6040516060810181811067ffffffffffffffff821117156144c9576144c961424c565b6040529050806144d883614483565b815260208301356020820152604083013560408201525092915050565b600060c0828403121561450757600080fd5b61450f6142a5565b9050813561451c816141ff565b8152602082013561452c816141ff565b60208201526040828101359082015261454760608301614483565b60608201526080820135608082015260a082013560a082015292915050565b60006040828403121561457857600080fd5b6145806142c8565b9050813561458d816141ff565b808252506020820135602082015292915050565b600080600080600061038086880312156145ba57600080fd5b853594506145cb8760208801614378565b93506145db876102208801614494565b92506145eb8761028088016144f5565b91506145fb876103408801614566565b90509295509295909350565b600067ffffffffffffffff8211156146215761462161424c565b5060051b60200190565b801515811461422157600080fd5b600082601f83011261464a57600080fd5b8135602061465f61465a83614607565b6142eb565b82815260059290921b8401810191818101908684111561467e57600080fd5b8286015b848110156146a25780356146958161462b565b8352918301918301614682565b509695505050505050565b600082601f8301126146be57600080fd5b813560206146ce61465a83614607565b82815260099290921b840181019181810190868411156146ed57600080fd5b8286015b848110156146a2576147038882614378565b835291830191610200016146f1565b600082601f83011261472357600080fd5b8135602061473361465a83614607565b8281526060928302850182019282820191908785111561475257600080fd5b8387015b85811015614775576147688982614494565b8452928401928101614756565b5090979650505050505050565b60006040828403121561479457600080fd5b61479c6142c8565b90508135815260208083013567ffffffffffffffff8111156147bd57600080fd5b8301601f810185136147ce57600080fd5b80356147dc61465a82614607565b81815260059190911b820183019083810190878311156147fb57600080fd5b928401925b8284101561481957833582529284019290840190614800565b8085870152505050505092915050565b600082601f83011261483a57600080fd5b8135602061484a61465a83614607565b82815260059290921b8401810191818101908684111561486957600080fd5b8286015b848110156146a257803567ffffffffffffffff81111561488d5760008081fd5b61489b8986838b0101614782565b84525091830191830161486d565b600082601f8301126148ba57600080fd5b813560206148ca61465a83614607565b82815260c092830285018201928282019190878511156148e957600080fd5b8387015b85811015614775576148ff89826144f5565b84529284019281016148ed565b600082601f83011261491d57600080fd5b8135602061492d61465a83614607565b82815260069290921b8401810191818101908684111561494c57600080fd5b8286015b848110156146a2576149628882614566565b835291830191604001614950565b6000806040838503121561498357600080fd5b82359150602083013567ffffffffffffffff808211156149a257600080fd5b9084019060c082870312156149b657600080fd5b6149be6142a5565b8235828111156149cd57600080fd5b6149d988828601614639565b8252506020830135828111156149ee57600080fd5b6149fa888286016146ad565b602083015250604083013582811115614a1257600080fd5b614a1e88828601614712565b604083015250606083013582811115614a3657600080fd5b614a4288828601614829565b606083015250608083013582811115614a5a57600080fd5b614a66888286016148a9565b60808301525060a083013582811115614a7e57600080fd5b614a8a8882860161490c565b60a0830152508093505050509250929050565b60008060008060008060006103c0888a031215614ab957600080fd5b873596506020880135614acb8161462b565b9550614ada8960408a01614378565b9450614aea896102408a01614494565b93506102a088013567ffffffffffffffff811115614b0757600080fd5b614b138a828b01614782565b935050614b24896102c08a016144f5565b9150614b34896103808a01614566565b905092959891949750929550565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60006102008284031215614b8457600080fd5b61297e8383614378565b600060608284031215614ba057600080fd5b61297e8383614494565b600060c08284031215614bbc57600080fd5b61297e83836144f5565b600060408284031215614bd857600080fd5b61297e8383614566565b600060208284031215614bf457600080fd5b815161297e8161462b565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b600082614c3d57614c3d614bff565b500690565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b600082614c8057614c80614bff565b500490565b808202811582820484141761066557610665614c42565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b60005b83811015614ce6578181015183820152602001614cce565b50506000910152565b60008351614d01818460208801614ccb565b835190830190614d15818360208801614ccb565b01949350505050565b8082018082111561066557610665614c42565b60008060408385031215614d4457600080fd5b8251614d4f816141ff565b6020939093015192949293505050565b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8203614d9057614d90614c42565b5060010190565b60008151808452614daf816020860160208601614ccb565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b8281526040602082015260006139a46040830184614d97565b600060208284031215614e0c57600080fd5b81517fffffffff000000000000000000000000000000000000000000000000000000008116811461297e57600080fd5b60008251614e4e818460208701614ccb565b9190910192915050565b60208152600061297e6020830184614d97565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052605160045260246000fdfea26469706673582212204b480c3bdfe3997e63700a17a99044b67df1af378c390f56d5f35eaf8094cb9764736f6c634300081300330000000000000000000000009a1d00bc981da5cea8300a999c0d15e2f7f03008

Deployed Bytecode

0x6080604052600436106100655760003560e01c8063b3cdebdb11610043578063b3cdebdb146100c7578063b5ca58e5146100e7578063e35bb9b71461014057600080fd5b806327add0471461006a578063572b6c051461007f578063a9272951146100b4575b600080fd5b61007d6100783660046140fe565b610160565b005b34801561008b57600080fd5b5061009f61009a36600461422f565b6105b0565b60405190151581526020015b60405180910390f35b61007d6100c23660046145a1565b61066b565b3480156100d357600080fd5b5061007d6100e2366004614970565b6107f5565b3480156100f357600080fd5b5061011b7f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc281565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020016100ab565b34801561014c57600080fd5b5061007d61015b366004614a9d565b610b22565b868514610199576040517fb62503e300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8683146101d2576040517fb62503e300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b86811461020b576040517fb62503e300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000879003610246576040517fdb560cb500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b604080516080810182528a815233602082015234916103608a0236037ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffedc019160009181016014841461029857336102a0565b6102a0610bac565b73ffffffffffffffffffffffffffffffffffffffff1681526000602091820181905260408051610200810182528281529283018290528201819052606082018190526080820181905260a0820181905260c0820181905260e08201819052610100820181905261012082018190526101408201819052610160820181905261018082018190526101a082018190526101c082018190526101e082015290915060408051606081018252600080825260208201819052918101919091526040805160c081018252600080825260208201819052918101829052606081018290526080810182905260a0810191909152604080518082019091526000808252602082015260005b8e8110156104a4578f8f828181106103bf576103bf614b42565b905061020002018036038101906103d69190614b71565b94508d8d828181106103ea576103ea614b42565b9050606002018036038101906104009190614b8e565b93508b8b8281811061041457610414614b42565b905060c0020180360381019061042a9190614baa565b925089898281811061043e5761043e614b42565b9050604002018036038101906104549190614bc6565b60a086015190925073ffffffffffffffffffffffffffffffffffffffff1661048b57610484868987878787610c9a565b975061049c565b61049a86600087878787610c9a565b505b6001016103a5565b50861561059e576104d67f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2885a610e44565b60408581015190517f23b872dd00000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff9182166024820152604481018990527f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2909116906323b872dd906064016020604051808303816000875af1158015610578573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061059c9190614be2565b505b50505050505050505050505050505050565b6040517f572b6c0500000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff82811660048301526000917f000000000000000000000000ff0000b6c4352714cce809000d0cd30a0e0c8dce9091169063572b6c0590602401602060405180830381865afa158015610641573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106659190614be2565b92915050565b604080516080810182528681523360208201527ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc7c360191600091908101601484146106b657336106be565b6106be610bac565b73ffffffffffffffffffffffffffffffffffffffff1681526001602090910152905060006106f0823489898989610c9a565b905080156107eb576107237f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2825a610e44565b60408281015190517f23b872dd00000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff9182166024820152604481018390527f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2909116906323b872dd906064016020604051808303816000875af11580156107c5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107e99190614be2565b505b5050505050505050565b80515160208201515114610835576040517fb62503e300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b80604001515181602001515114610878576040517fb62503e300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b806060015151816020015151146108bb576040517fb62503e300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b806080015151816020015151146108fe576040517fb62503e300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8060a001515181602001515114610941576040517fb62503e300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b806020015151600003610980576040517fdb560cb500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6020810151516104000236037ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe3c0160005b8260600151518110156109f357826060015181815181106109d4576109d4614b42565b60200260200101516020015151602002820391508060010190506109b1565b5060408051608081018252848152336020820152600091810160148414610a1a5733610a22565b610a22610bac565b73ffffffffffffffffffffffffffffffffffffffff16815260200160001515815250905060005b836020015151811015610b1b57610b138285600001518381518110610a7057610a70614b42565b602002602001015186602001518481518110610a8e57610a8e614b42565b602002602001015187604001518581518110610aac57610aac614b42565b602002602001015188606001518681518110610aca57610aca614b42565b602002602001015189608001518781518110610ae857610ae8614b42565b60200260200101518a60a001518881518110610b0657610b06614b42565b6020026020010151610e8f565b600101610a49565b5050505050565b60208084015151604080516080810182528a815233818501529190920236037ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffbdc01916107eb9190810160148414610b795733610b81565b610b81610bac565b73ffffffffffffffffffffffffffffffffffffffff1681526001602090910152888888888888610e8f565b6040517f572b6c050000000000000000000000000000000000000000000000000000000081523360048201526000907f000000000000000000000000ff0000b6c4352714cce809000d0cd30a0e0c8dce73ffffffffffffffffffffffffffffffffffffffff169063572b6c0590602401602060405180830381865afa158015610c39573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c5d9190614be2565b15610c955760143610610c9557507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec36013560601c90565b503390565b600080610ca98887878761114d565b90508561010001517effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff16817effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1614610df9578561010001517effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff16866101200151610d309190614c2e565b15610d67576040517ffe41cfc900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b807effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff168661010001517effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff16876101200151610dc09190614c71565b610dca9190614c85565b6101208701527effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff81166101008701525b6000610e058988611426565b9050610e37888a8b604001518a602001518b60a00151610e2f60008e60a001518f60000151611b00565b8d888c611c19565b9998505050505050505050565b6000806000806000868887f1905080610e89576040517f6c998d3e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b50505050565b60a085015173ffffffffffffffffffffffffffffffffffffffff16610ee0576040517f1f9ed49100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60008615610fa5578351610f0157610efa88878786611ef0565b9050610fb4565b602080850151855160c089015160e08a0151604051610f6295610f479392910173ffffffffffffffffffffffffffffffffffffffff929092168252602082015260400190565b60405160208183030381529060405280519060200120612109565b610f98576040517f12f0d2cc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610efa888787878761211f565b610fb1888787866123a4565b90505b8561010001517effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff16817effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1614611102578561010001517effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff168661012001516110399190614c2e565b15611070576040517ffe41cfc900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b807effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff168661010001517effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff168761012001516110c99190614c71565b6110d39190614c85565b6101208701527effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff81166101008701525b600061110e8988611426565b905061114160008a89602001518c604001518b60a0015161113960018e60a001518f60000151611b00565b8d888b611c19565b50505050505050505050565b805160009073ffffffffffffffffffffffffffffffffffffffff1615611178576111788584846125cf565b845184516000916113c6917f938786a8256d04dc45d6d5b997005aa07c0c9e3e4925d0d6c33128d240096ebc9060028111156111b6576111b6614c9c565b866000015189602001518a606001518b608001518c60a001518d60c001518e60e001516040516020016112489998979695949392919098895260ff97909716602089015273ffffffffffffffffffffffffffffffffffffffff958616604089015293851660608801529184166080870152831660a0860152821660c08501521660e08301526101008201526101200190565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529190526101008801516101208901516101608a01516101808b01516101a08c01516101408d015160028e5160028111156112af576112af614c9c565b146112ce576112c98e602001518f6101400151600061280b565b611319565b6020808f015173ffffffffffffffffffffffffffffffffffffffff1660009081527f06290179fae592fb2a78508cd3db8ee54727dcb8adda2f153fc506694ab1f84c90915260409020545b604080517effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff90981660208901528701959095526060860193909352608085019190915260a084015260c083015260e0820152610100015b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0818403018152908290526113ab9291602001614cef565b60405160208183030381529060405280519060200120612942565b90506113d785602001518583612985565b6002855160028111156113ec576113ec614c9c565b146113fc5784610100015161141c565b61141c856020015182876101000151886101c00151896101e00151612a29565b9695505050505050565b60408051608081018252600080825260208201819052918101829052606081019190915260008251600281111561145f5761145f614c9c565b036114c95760018261010001517effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff16146114c4576040517fdb3ca79a00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b611529565b8161010001517effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff16600003611529576040517f26db27f100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b816101600151421115611568576040517fac492cc000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b612710826101a001518361018001516115819190614d1e565b11156115b9576040517fca9d1e5400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60c082015173ffffffffffffffffffffffffffffffffffffffff1660009081527f06290179fae592fb2a78508cd3db8ee54727dcb8adda2f153fc506694ab1f84e602052604090819020805461ffff7901000000000000000000000000000000000000000000000000008204811685527b01000000000000000000000000000000000000000000000000000000820416928401929092529060ff808216917f01000000000000000000000000000000000000000000000000000000000000009004161561175a5760c084015173ffffffffffffffffffffffffffffffffffffffff1660009081527f06290179fae592fb2a78508cd3db8ee54727dcb8adda2f153fc506694ab1f85760209081526040909120908501516116da908290612cd0565b15611711576040517fadffdc8600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040860151611721908290612cd0565b15611758576040517fadffdc8600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b505b81547e01000000000000000000000000000000000000000000000000000000000000900460ff16156118265760c084015173ffffffffffffffffffffffffffffffffffffffff1660009081527f06290179fae592fb2a78508cd3db8ee54727dcb8adda2f153fc506694ab1f85660205260408120906117d882612cff565b11156118245760208601516117ee908290612cd0565b611824576040517f292d235200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b505b8154790100000000000000000000000000000000000000000000000000900461ffff16156118a45760c084015173ffffffffffffffffffffffffffffffffffffffff90811660009081527f06290179fae592fb2a78508cd3db8ee54727dcb8adda2f153fc506694ab1f8536020908152604090912054909116908401525b81547d010000000000000000000000000000000000000000000000000000000000900460ff16156119215760c084015173ffffffffffffffffffffffffffffffffffffffff90811660009081527f06290179fae592fb2a78508cd3db8ee54727dcb8adda2f153fc506694ab1f85460205260409020541660608401525b600081600481111561193557611935614c9c565b03611982576119478460a00151612d09565b61197d576040517fab9c00de00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b611af8565b600281600481111561199657611996614c9c565b036119f4576119478460a001516119ca7f06290179fae592fb2a78508cd3db8ee54727dcb8adda2f153fc506694ab1f84b90565b845463ffffffff6101009091048116600090815260059290920160205260409091209190612cd016565b6003816004811115611a0857611a08614c9c565b03611aad5760a0840151825465010000000000900473ffffffffffffffffffffffffffffffffffffffff908116911614611a6e576040517fab9c00de00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61197d8460c001518560e001518661010001517effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff16876101200151612ef1565b6004816004811115611ac157611ac1614c9c565b03611af8576040517fba78259100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b505092915050565b611b2760405180606001604052806140258152602001614025815260200161402581525090565b60408051606081019091528073ffffffffffffffffffffffffffffffffffffffff851615611b5757612f93611b5b565b612f9f5b67ffffffffffffffff1681526020016000846002811115611b7e57611b7e614c9c565b14611b8b57612faa611b8f565b6130665b67ffffffffffffffff1681526020016000846002811115611bb257611bb2614c9c565b14611be0576000866001811115611bcb57611bcb614c9c565b14611bd8576130cd611c05565b6131d1611c05565b6000866001811115611bf457611bf4614c9c565b14611c01576132c9611c05565b6133915b67ffffffffffffffff169052949350505050565b6000899050611c658785604001518660c001518760e001518861010001517effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff168a6020015163ffffffff16565b611caa57886060015115611ca5576040517ff40863ff00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610e37565b6000611cdb8561012001518660c001518760e0015188606001518961018001518a6101a001518b608001518b613459565b835190915060009073ffffffffffffffffffffffffffffffffffffffff1615611d05575060208301515b60a086015173ffffffffffffffffffffffffffffffffffffffff16611d7857600081876101200151611d379190614d1e565b905080841015611d73576040517f70d5b32e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b909203915b602082015115611dbf57611dbf82600001518b8a85602001517f0000000000000000000000000000000000000000000000000000000000001f408c6000015163ffffffff16565b604082015115611e0657611e0686606001518b8a85604001517f0000000000000000000000000000000000000000000000000000000000001f408c6000015163ffffffff16565b606082015115611e4957611e49898b8a85606001517f0000000000000000000000000000000000000000000000000000000000001f408c6000015163ffffffff16565b8015611ecf57856101200151811115611e8e576040517f1d6203f500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b611ecf84600001518c604001518a87602001517f0000000000000000000000000000000000000000000000000000000000001f408c6000015163ffffffff16565b611ee18b87896040015163ffffffff16565b50509998505050505050505050565b805160009073ffffffffffffffffffffffffffffffffffffffff1615611f1b57611f1b8584846125cf565b845184516000916113c6917f8fe9498e93fe26b30ebf76fac07bd4705201c8609227362697082288e3b4af9c906002811115611f5957611f59614c9c565b866000015189602001518a604001518b606001518c608001518d60a001518e60c00151604051602001611fed9998979695949392919098895260ff97909716602089015273ffffffffffffffffffffffffffffffffffffffff958616604089015293851660608801529184166080870152831660a0860152821660c0850152811660e0840152166101008201526101200190565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529190526101008801516101208901516101608a01516101808b01516101408c015160028d51600281111561204e5761204e614c9c565b1461206d576120688d602001518e6101400151600061280b565b6120b8565b60208d81015173ffffffffffffffffffffffffffffffffffffffff1660009081527f06290179fae592fb2a78508cd3db8ee54727dcb8adda2f153fc506694ab1f84c90915260409020545b604080517effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff90971660208801528601949094526060850192909252608084015260a083015260c082015260e00161136f565b6000826121168584613830565b14949350505050565b805160009073ffffffffffffffffffffffffffffffffffffffff161561214a5761214a8685846125cf565b85518551600091612343917f244905ade6b0e455d12fb539a4b17d7f675db14797d514168d09814a09c70e7090600281111561218857612188614c9c565b86600001518a602001518b604001518c606001518d608001518e60a001518f60c0015160405160200161221c9998979695949392919098895260ff97909716602089015273ffffffffffffffffffffffffffffffffffffffff958616604089015293851660608801529184166080870152831660a0860152821660c0850152811660e0840152166101008201526101200190565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529190526101008901516101208a01516101608b01516101808c01516101408d015160028e51600281111561227d5761227d614c9c565b1461229c576122978e602001518f6101400151600061280b565b6122e7565b6020808f015173ffffffffffffffffffffffffffffffffffffffff1660009081527f06290179fae592fb2a78508cd3db8ee54727dcb8adda2f153fc506694ab1f84c90915260409020545b8c51604080517effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff90981660208901528701959095526060860193909352608085019190915260a084015260c083015260e08201526101000161136f565b905061235486602001518683612985565b60028651600281111561236957612369614c9c565b1461237957856101000151612399565b612399866020015182886101000151896101c001518a6101e00151612a29565b979650505050505050565b805160009073ffffffffffffffffffffffffffffffffffffffff16156123cf576123cf8584846125cf565b845184516000916113c6917fce2e9706d63e89ddf7ee16ce0508a1c3c9bd1904c582db2e647e6f4690a0bf6b90600281111561240d5761240d614c9c565b866000015189602001518a604001518b606001518c608001518d60a001518e60c001516040516020016124a19998979695949392919098895260ff97909716602089015273ffffffffffffffffffffffffffffffffffffffff958616604089015293851660608801529184166080870152831660a0860152821660c0850152811660e0840152166101008201526101200190565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe081840301815291905260e08801516101008901516101208a01516101608b01516101808c01516101408d015160028e51600281111561250757612507614c9c565b14612526576125218e602001518f6101400151600061280b565b612571565b6020808f015173ffffffffffffffffffffffffffffffffffffffff1660009081527f06290179fae592fb2a78508cd3db8ee54727dcb8adda2f153fc506694ab1f84c90915260409020545b6040805160208101989098527effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff909616958701959095526060860193909352608085019190915260a084015260c083015260e08201526101000161136f565b806040015142111561260d576040517f39db6a8400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b806020015173ffffffffffffffffffffffffffffffffffffffff16836040015173ffffffffffffffffffffffffffffffffffffffff161461267a576040517f53b220dd00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b805173ffffffffffffffffffffffffffffffffffffffff1660009081527f06290179fae592fb2a78508cd3db8ee54727dcb8adda2f153fc506694ab1f858602052604090205460ff16156126fa576040517fb5095d2d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b82518251602080850151604080870151868201518785015183517f347b7818601b168f6faadc037723496e9130b057c1ffef2ec4128311e19142f29681019690965260ff909616928501929092526060840192909252608083019190915260a082015273ffffffffffffffffffffffffffffffffffffffff90911660c082015261279e9161278a9160e0016113ab565b826060015183608001518460a0015161387d565b73ffffffffffffffffffffffffffffffffffffffff16816000015173ffffffffffffffffffffffffffffffffffffffff1614612806576040517fdb2d3d4e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b505050565b73ffffffffffffffffffffffffffffffffffffffff831660009081527f06290179fae592fb2a78508cd3db8ee54727dcb8adda2f153fc506694ab1f84d60209081526040808320600886901c845290915281208054600160ff86161b90811891829055166128a5576040517f548db54000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8373ffffffffffffffffffffffffffffffffffffffff16837ff3003920635c7d35c4f314eaeeed4b4c653ccb36608a86d57df761d460eab09d846040516128f0911515815260200190565b60405180910390a350505073ffffffffffffffffffffffffffffffffffffffff1660009081527f06290179fae592fb2a78508cd3db8ee54727dcb8adda2f153fc506694ab1f84c602052604090205490565b6040517f190100000000000000000000000000000000000000000000000000000000000081526002810183905260228101829052604290206000905b9392505050565b61299d8183600001518460200151856040015161387d565b73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16146128065773ffffffffffffffffffffffffffffffffffffffff83163b156129f7576128068382846139ac565b6040517f33e929a000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff851660009081527f06290179fae592fb2a78508cd3db8ee54727dcb8adda2f153fc506694ab1f855602090815260408083208784529091528120805484929060ff166002811115612a9157612a91614c9c565b03612c9457805461010090047effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff16600003612af457805460ff166101007effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8716021781555b80547effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff61010090910481169083161115612b5257805461010090047effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1691505b827effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff16827effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff161015612bce576040517fa10cbd9500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b80547effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff61010080830482168590038216810260ff909316929092178084559190910416600003612c8f5780547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660011781556040516000815273ffffffffffffffffffffffffffffffffffffffff88169087907fc63c82396a1b7865295ff481988a98493c2c3cc29066c229b8001c6f5dd647a99060200160405180910390a35b612cc6565b6040517fab2ccbf500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5095945050505050565b73ffffffffffffffffffffffffffffffffffffffff81166000908152600183016020526040812054151561297e565b6000610665825490565b600073ffffffffffffffffffffffffffffffffffffffff8216612d2e57506001919050565b7f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc273ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603612d8957506001919050565b7f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc273ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603612de457506001919050565b7f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4873ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603612e3f57506001919050565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603612e9a57506001919050565b600080527f06290179fae592fb2a78508cd3db8ee54727dcb8adda2f153fc506694ab1f8506020526106657f7e3fc5ae914741b6ec1965d9e45a90f0f1bf058adf965b4325d4338c7ac8f9ff83612cd0565b919050565b600080612efe8686613b28565b915091506000848481612f1357612f13614bff565b04905081811115612f50576040517f9837ddd700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b82811015612f8a576040517f9318944000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b50505050505050565b610b1b83858785613cec565b610b1b858383610e44565b6040517ff242432a00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff86811660048301528581166024830152604482018490526064820183905260a06084830152600060a48301819052919085169063f242432a9060c4015b600060405180830381600087803b15801561303c57600080fd5b505af192505050801561304d575060015b6130595750600061305d565b5060015b95945050505050565b6040517f23b872dd00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8681166004830152858116602483015260448201849052600091908516906323b872dd90606401613022565b8060c0015173ffffffffffffffffffffffffffffffffffffffff16816020015173ffffffffffffffffffffffffffffffffffffffff16836040015173ffffffffffffffffffffffffffffffffffffffff167f6f4c56c4b9a9d2479f963d802b19d17b02293ce1225461ac0cb846c482ee3c3e84604001518560a001518660e001518761010001518861012001516040516131c595949392919073ffffffffffffffffffffffffffffffffffffffff958616815293909416602084015260408301919091527effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff166060820152608081019190915260a00190565b60405180910390a45050565b8060c0015173ffffffffffffffffffffffffffffffffffffffff16816020015173ffffffffffffffffffffffffffffffffffffffff16836040015173ffffffffffffffffffffffffffffffffffffffff167f1217006325a98bdcc6afc9c44965bb66ac7460a44dc57c2ac47622561d25c45a84604001518560a001518660e001518761010001518861012001516040516131c595949392919073ffffffffffffffffffffffffffffffffffffffff958616815293909416602084015260408301919091527effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff166060820152608081019190915260a00190565b8060c0015173ffffffffffffffffffffffffffffffffffffffff16816020015173ffffffffffffffffffffffffffffffffffffffff16836040015173ffffffffffffffffffffffffffffffffffffffff167f8b87c0b049fe52718fe6ff466b514c5a93c405fb0de8fbd761a23483f9f9e19884604001518560a001518660e001518761012001516040516131c5949392919073ffffffffffffffffffffffffffffffffffffffff94851681529290931660208301526040820152606081019190915260800190565b8060c0015173ffffffffffffffffffffffffffffffffffffffff16816020015173ffffffffffffffffffffffffffffffffffffffff16836040015173ffffffffffffffffffffffffffffffffffffffff167fffb29e9cf48456d56b6d414855b66a7ec060ce2054dcb124a1876310e1b7355c84604001518560a001518660e001518761012001516040516131c5949392919073ffffffffffffffffffffffffffffffffffffffff94851681529290931660208301526040820152606081019190915260800190565b61349a6040518060800160405280600073ffffffffffffffffffffffffffffffffffffffff1681526020016000815260200160008152602001600081525090565b606081018990526040517f2a55205a00000000000000000000000000000000000000000000000000000000815260048101889052602481018a905273ffffffffffffffffffffffffffffffffffffffff891690632a55205a906044016040805180830381865afa92505050801561354c575060408051601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016820190925261354991810190614d31565b60015b613698573d80801561357a576040519150601f19603f3d011682016040523d82523d6000602084013e61357f565b606091505b50602083015173ffffffffffffffffffffffffffffffffffffffff161561363257825161ffff168510156135df576040517f1bdbc8f400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b602083015173ffffffffffffffffffffffffffffffffffffffff1682528251612710906136109061ffff168c614c85565b61361a9190614c71565b60208301819052606083018051919091039052613692565b73ffffffffffffffffffffffffffffffffffffffff8416156136925773ffffffffffffffffffffffffffffffffffffffff84168252612710613674868c614c85565b61367e9190614c71565b602083018190526060830180519190910390525b5061373c565b73ffffffffffffffffffffffffffffffffffffffff82166136b7575060005b8015613739576127106136ca878d614c85565b6136d49190614c71565b81111561370d576040517f1bdbc8f400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff821683526020830181905260608301805182900390525b50505b73ffffffffffffffffffffffffffffffffffffffff86161561382457612710613765868b614c85565b61376f9190614c71565b60408201819052606080830180519290920390915282015173ffffffffffffffffffffffffffffffffffffffff1615806137d857508573ffffffffffffffffffffffffffffffffffffffff16826060015173ffffffffffffffffffffffffffffffffffffffff16145b15613824576000612710836040015161ffff1683602001516137fa9190614c85565b6138049190614c71565b90508015613822576020820180518290039052604082018051820190525b505b98975050505050505050565b600081815b8451811015613875576138618286838151811061385457613854614b42565b6020026020010151613d81565b91508061386d81614d5f565b915050613835565b509392505050565b60007f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a08211156138d9576040517f33e929a000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60408051600081526020810180835287905260ff861691810191909152606081018490526080810183905260019060a0016020604051602081039080840390855afa15801561392c573d6000803e3d6000fd5b50506040517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0015191505073ffffffffffffffffffffffffffffffffffffffff81166139a4576040517f33e929a000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b949350505050565b60008373ffffffffffffffffffffffffffffffffffffffff16631626ba7e84846020015185604001518660000151604051602001613a2293929190928352602083019190915260f81b7fff0000000000000000000000000000000000000000000000000000000000000016604082015260410190565b6040516020818303038152906040526040518363ffffffff1660e01b8152600401613a4e929190614de1565b602060405180830381865afa925050508015613aa5575060408051601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0168201909252613aa291810190614dfa565b60015b15613af1577fffffffff00000000000000000000000000000000000000000000000000000000167f1626ba7e000000000000000000000000000000000000000000000000000000001490505b80610e89576040517ff83b002000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff821660009081527f06290179fae592fb2a78508cd3db8ee54727dcb8adda2f153fc506694ab1f8526020908152604080832084845282528083208151606081018352905460ff811615801583526effffffffffffffffffffffffffffff6101008304811695840195909552700100000000000000000000000000000000909104909316918101919091528291613bf55760208101516040909101516effffffffffffffffffffffffffffff9182169350169050613ce5565b73ffffffffffffffffffffffffffffffffffffffff851660009081527f06290179fae592fb2a78508cd3db8ee54727dcb8adda2f153fc506694ab1f85160209081526040918290208251606081018452905460ff811615801583526effffffffffffffffffffffffffffff610100830481169484019490945270010000000000000000000000000000000090910490921692810192909252613cbb5760208101516040909101516effffffffffffffffffffffffffffff9182169450169150613ce59050565b5060007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff92509250505b9250929050565b6040805173ffffffffffffffffffffffffffffffffffffffff85811660248301528416604482015260648082018490528251808303909101815260849091019091526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f23b872dd00000000000000000000000000000000000000000000000000000000179052610e89908590613db0565b6000818310613d9d57600082815260208490526040902061297e565b600083815260208390526040902061297e565b6000613e12826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff16613ec49092919063ffffffff16565b9050805160001480613e33575080806020019051810190613e339190614be2565b612806576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f7420737563636565640000000000000000000000000000000000000000000060648201526084015b60405180910390fd5b60606139a48484600085856000808673ffffffffffffffffffffffffffffffffffffffff168587604051613ef89190614e3c565b60006040518083038185875af1925050503d8060008114613f35576040519150601f19603f3d011682016040523d82523d6000602084013e613f3a565b606091505b50915091506123998783838760608315613fdc578251600003613fd55773ffffffffffffffffffffffffffffffffffffffff85163b613fd5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401613ebb565b50816139a4565b6139a48383815115613ff15781518083602001fd5b806040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401613ebb9190614e58565b61402d614e6b565b565b60008083601f84011261404157600080fd5b50813567ffffffffffffffff81111561405957600080fd5b602083019150836020606083028501011115613ce557600080fd5b60008083601f84011261408657600080fd5b50813567ffffffffffffffff81111561409e57600080fd5b60208301915083602060c083028501011115613ce557600080fd5b60008083601f8401126140cb57600080fd5b50813567ffffffffffffffff8111156140e357600080fd5b6020830191508360208260061b8501011115613ce557600080fd5b600080600080600080600080600060a08a8c03121561411c57600080fd5b8935985060208a013567ffffffffffffffff8082111561413b57600080fd5b818c0191508c601f83011261414f57600080fd5b81358181111561415e57600080fd5b8d60208260091b850101111561417357600080fd5b602083019a508099505060408c013591508082111561419157600080fd5b61419d8d838e0161402f565b909850965060608c01359150808211156141b657600080fd5b6141c28d838e01614074565b909650945060808c01359150808211156141db57600080fd5b506141e88c828d016140b9565b915080935050809150509295985092959850929598565b73ffffffffffffffffffffffffffffffffffffffff8116811461422157600080fd5b50565b8035612eec816141ff565b60006020828403121561424157600080fd5b813561297e816141ff565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b604051610200810167ffffffffffffffff8111828210171561429f5761429f61424c565b60405290565b60405160c0810167ffffffffffffffff8111828210171561429f5761429f61424c565b6040805190810167ffffffffffffffff8111828210171561429f5761429f61424c565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff811182821017156143325761433261424c565b604052919050565b803560038110612eec57600080fd5b80357effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff81168114612eec57600080fd5b6000610200828403121561438b57600080fd5b61439361427b565b905061439e8261433a565b81526143ac60208301614224565b60208201526143bd60408301614224565b60408201526143ce60608301614224565b60608201526143df60808301614224565b60808201526143f060a08301614224565b60a082015261440160c08301614224565b60c082015260e082013560e082015261010061441e818401614349565b9082015261012082810135908201526101408083013590820152610160808301359082015261018080830135908201526101a080830135908201526101c0614467818401614349565b908201526101e0614479838201614349565b9082015292915050565b803560ff81168114612eec57600080fd5b6000606082840312156144a657600080fd5b6040516060810181811067ffffffffffffffff821117156144c9576144c961424c565b6040529050806144d883614483565b815260208301356020820152604083013560408201525092915050565b600060c0828403121561450757600080fd5b61450f6142a5565b9050813561451c816141ff565b8152602082013561452c816141ff565b60208201526040828101359082015261454760608301614483565b60608201526080820135608082015260a082013560a082015292915050565b60006040828403121561457857600080fd5b6145806142c8565b9050813561458d816141ff565b808252506020820135602082015292915050565b600080600080600061038086880312156145ba57600080fd5b853594506145cb8760208801614378565b93506145db876102208801614494565b92506145eb8761028088016144f5565b91506145fb876103408801614566565b90509295509295909350565b600067ffffffffffffffff8211156146215761462161424c565b5060051b60200190565b801515811461422157600080fd5b600082601f83011261464a57600080fd5b8135602061465f61465a83614607565b6142eb565b82815260059290921b8401810191818101908684111561467e57600080fd5b8286015b848110156146a25780356146958161462b565b8352918301918301614682565b509695505050505050565b600082601f8301126146be57600080fd5b813560206146ce61465a83614607565b82815260099290921b840181019181810190868411156146ed57600080fd5b8286015b848110156146a2576147038882614378565b835291830191610200016146f1565b600082601f83011261472357600080fd5b8135602061473361465a83614607565b8281526060928302850182019282820191908785111561475257600080fd5b8387015b85811015614775576147688982614494565b8452928401928101614756565b5090979650505050505050565b60006040828403121561479457600080fd5b61479c6142c8565b90508135815260208083013567ffffffffffffffff8111156147bd57600080fd5b8301601f810185136147ce57600080fd5b80356147dc61465a82614607565b81815260059190911b820183019083810190878311156147fb57600080fd5b928401925b8284101561481957833582529284019290840190614800565b8085870152505050505092915050565b600082601f83011261483a57600080fd5b8135602061484a61465a83614607565b82815260059290921b8401810191818101908684111561486957600080fd5b8286015b848110156146a257803567ffffffffffffffff81111561488d5760008081fd5b61489b8986838b0101614782565b84525091830191830161486d565b600082601f8301126148ba57600080fd5b813560206148ca61465a83614607565b82815260c092830285018201928282019190878511156148e957600080fd5b8387015b85811015614775576148ff89826144f5565b84529284019281016148ed565b600082601f83011261491d57600080fd5b8135602061492d61465a83614607565b82815260069290921b8401810191818101908684111561494c57600080fd5b8286015b848110156146a2576149628882614566565b835291830191604001614950565b6000806040838503121561498357600080fd5b82359150602083013567ffffffffffffffff808211156149a257600080fd5b9084019060c082870312156149b657600080fd5b6149be6142a5565b8235828111156149cd57600080fd5b6149d988828601614639565b8252506020830135828111156149ee57600080fd5b6149fa888286016146ad565b602083015250604083013582811115614a1257600080fd5b614a1e88828601614712565b604083015250606083013582811115614a3657600080fd5b614a4288828601614829565b606083015250608083013582811115614a5a57600080fd5b614a66888286016148a9565b60808301525060a083013582811115614a7e57600080fd5b614a8a8882860161490c565b60a0830152508093505050509250929050565b60008060008060008060006103c0888a031215614ab957600080fd5b873596506020880135614acb8161462b565b9550614ada8960408a01614378565b9450614aea896102408a01614494565b93506102a088013567ffffffffffffffff811115614b0757600080fd5b614b138a828b01614782565b935050614b24896102c08a016144f5565b9150614b34896103808a01614566565b905092959891949750929550565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60006102008284031215614b8457600080fd5b61297e8383614378565b600060608284031215614ba057600080fd5b61297e8383614494565b600060c08284031215614bbc57600080fd5b61297e83836144f5565b600060408284031215614bd857600080fd5b61297e8383614566565b600060208284031215614bf457600080fd5b815161297e8161462b565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b600082614c3d57614c3d614bff565b500690565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b600082614c8057614c80614bff565b500490565b808202811582820484141761066557610665614c42565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b60005b83811015614ce6578181015183820152602001614cce565b50506000910152565b60008351614d01818460208801614ccb565b835190830190614d15818360208801614ccb565b01949350505050565b8082018082111561066557610665614c42565b60008060408385031215614d4457600080fd5b8251614d4f816141ff565b6020939093015192949293505050565b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8203614d9057614d90614c42565b5060010190565b60008151808452614daf816020860160208601614ccb565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b8281526040602082015260006139a46040830184614d97565b600060208284031215614e0c57600080fd5b81517fffffffff000000000000000000000000000000000000000000000000000000008116811461297e57600080fd5b60008251614e4e818460208701614ccb565b9190910192915050565b60208152600061297e6020830184614d97565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052605160045260246000fdfea26469706673582212204b480c3bdfe3997e63700a17a99044b67df1af378c390f56d5f35eaf8094cb9764736f6c63430008130033

Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)

0000000000000000000000009a1d00bc981da5cea8300a999c0d15e2f7f03008

-----Decoded View---------------
Arg [0] : configurationContract (address): 0x9A1D00Bc981DA5cea8300a999c0d15E2f7F03008

-----Encoded View---------------
1 Constructor Arguments found :
Arg [0] : 0000000000000000000000009a1d00bc981da5cea8300a999c0d15e2f7f03008


Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

Block Uncle Number Difficulty Gas Used Reward
View All Uncles
Loading...
Loading
Loading...
Loading

Validator Index Block Amount
View All Withdrawals

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits
Loading...
Loading
[ 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.