initialize(address,string,address,uint256) :
This function is the initializer for the contract. It sets up the contract by setting the timeBuffer, bidBufferBps, contractURI, platformFeeBps, platformFeeRecipient, and setting up the roles of DEFAULT_ADMIN_ROLE, LISTER_ROLE, and ASSET_ROLE. It also calls the __ReentrancyGuard_init() and __ERC2771Context_init() functions to set up the contract. (autogenerated documentation)
contractType() :
This function returns a bytes32 value that represents the type of the contract. It does this by simply returning the value of the MODULE_TYPE constant, which is set when the contract is deployed. (autogenerated documentation)
contractVersion() :
This function returns the version of the contract. It does this by returning the value of the constant variable VERSION, which is declared at the top of the contract. (autogenerated documentation)
onERC1155Received(uint256,,uint256,) :
This function is an override of the ERC1155Received function, which is part of the ERC1155 standard. It is used to handle the receipt of ERC1155 tokens. It takes in five parameters: two addresses, two uint256 values, and a bytes memory value. It then returns a bytes4 value, which is the selector for the onERC1155Received function. This function is used to ensure that the ERC1155 tokens are received correctly and securely. (autogenerated documentation)
onERC1155BatchReceived(uint256[],uint256[]) :
This function is an override of the ERC1155 standard and is used to receive a batch of ERC1155 tokens. It takes in five parameters: two addresses, two uint256 arrays, and a bytes memory. The first address is the sender of the tokens, the second address is the recipient of the tokens, the first uint256 array is an array of token IDs, the second uint256 array is an array of token amounts, and the bytes memory is a data payload. The function returns a bytes4, which is the selector of the onERC1155BatchReceived function. (autogenerated documentation)
onERC721Received(uint256,) :
This function is an override of the ERC721Received function, which is used to handle the receipt of ERC721 tokens. It is triggered when a token is sent to a contract, and it returns the selector of the onERC721Received function. This allows the contract to determine which function to call when a token is received. (autogenerated documentation)
supportsInterface(bytes4) :
This function is used to check if a contract supports a given interface. It takes a bytes4 interfaceId as an argument and returns a boolean value indicating whether the contract supports the interface or not. The function first checks if the interfaceId matches the interfaceId of the IERC1155ReceiverUpgradeable or IERC721ReceiverUpgradeable interfaces. If it does, it returns true. Otherwise, it calls the super.supportsInterface() function to check if the interfaceId matches any of the interfaces supported by the parent contract. If it does, it returns true. Otherwise, it returns false. (autogenerated documentation)
createListing() :
This function creates a new listing on the exchange. It takes in a ListingParameters memory object as an argument, which contains information about the listing such as the asset contract, token ID, start time, seconds until end time, currency to accept, reserve price per token, buyout price per token, token type, and listing type. The function then checks that the quantity to list is greater than 0, that the sender has the lister role, that the asset contract has the asset role, and that the buyout price is greater than or equal to the reserve price (if the listing type is an auction). It then validates the ownership and approval of the token owner, and creates a new Listing memory object with the provided (autogenerated documentation)
updateListing(uint256,uint256,uint256,uint256,address,uint256,uint256) :
This function allows the creator of a listing to update the details of the listing. It takes in parameters such as the listing ID, the quantity to list, the reserve price per token, the buyout price per token, the currency to accept, the start time, and the seconds until the end time. It then checks if the listing is an auction and if the start time is in the past. It then updates the listing with the new parameters and checks if the quantity has changed. If it has, it transfers the tokens from the owner to the contract and validates the ownership and approval of the tokens. Finally, it emits an event to signal that the listing has been updated. (autogenerated documentation)
cancelDirectListing(uint256) :
This function allows the listing creator to cancel a direct listing. It takes in the listing ID as an argument and checks that the listing type is direct. If it is, the listing is removed from the listings mapping and a ListingRemoved event is emitted. (autogenerated documentation)
buy(uint256,address,uint256,address,uint256) :
This function allows a user to buy a listing on the marketplace. It takes in the listing ID, the address of the buyer, the quantity to buy, the currency, and the total price as parameters. It then checks that the currency and total price match the listing's currency and buyout price per token multiplied by the quantity to buy. If these conditions are met, it executes the sale by transferring the tokens to the buyer and transferring the payment to the seller. (autogenerated documentation)
acceptOffer(uint256,address,address,uint256) :
This function allows the listing creator to accept an offer for a listing. It takes in the listing ID, the offeror's address, the currency of the offer, and the price per token as parameters. It first checks that the currency and price per token match the offer, and that the offer has not expired. It then deletes the offer from the offers mapping and executes the sale, transferring the tokens from the offeror to the listing creator. (autogenerated documentation)
executeSale(address,address,address,uint256,uint256) :
This function executes a sale of a listing on the exchange. It first validates the sale by ensuring that the payer has enough currency and listing tokens to complete the sale. It then updates the quantity of the listing to reflect the sale, pays out the currency to the listing owner, transfers the listing tokens to the receiver, and emits an event to notify of the sale. (autogenerated documentation)
offer(uint256,uint256,address,uint256,uint256) :
This function allows users to make offers on a listing. It first checks to make sure that the listing is active, and then checks the listing type to determine how to handle the offer. If the listing type is an auction, the offer must use the approved currency and the quantityWanted is set to the quantity of the listing. If the listing type is direct, the currency is set to the native token and the quantityWanted is set to the quantity specified in the offer. Finally, the offer is handled by either the handleBid or handleOffer function. (autogenerated documentation)
handleOffer() :
This function handles the creation of a new offer for a given listing. It requires that the quantity of tokens wanted is less than or equal to the quantity available in the listing, and that the offeror has sufficient balance and allowance in the specified currency to cover the cost of the offer. If these conditions are met, the offer is stored in the offers mapping and a NewOffer event is emitted. (autogenerated documentation)
handleBid() :
This function handles a bid for a listing on the exchange. It first checks if the incoming bid is greater than or equal to the buyout price for the listing, and if so, it closes the auction for the bidder. If not, it checks if the incoming bid is greater than the reserve price for the listing, and if so, it sets the incoming bid as the winning bid. It then transfers the currency from the current winning bidder to the exchange, and from the incoming bidder to the exchange. Finally, it emits an event to notify of the new offer. (autogenerated documentation)
isNewWinningBid(uint256,uint256,uint256) :
This function checks if an incoming bid is a valid new winning bid. It does this by first checking if the current winning bid amount is 0, in which case the incoming bid must be greater than or equal to the reserve amount. If the current winning bid amount is not 0, then the incoming bid must be greater than the current winning bid amount and the difference between the incoming bid and the current winning bid must be greater than the bid buffer BPS. (autogenerated documentation)
closeAuction(uint256,address) :
This function is used to close an auction. It takes two parameters, a listing ID and an address to close the auction for. It first checks to make sure that the listing is an auction, and then checks if the auction should be cancelled (if the start time is in the future or if there is no winning bid). If the auction should be cancelled, it calls the _cancelAuction function. If the auction should not be cancelled, it checks if the address to close the auction for is the auction creator or the bidder. If it is the auction creator, it calls the _closeAuctionForAuctionCreator function. If it is the bidder, it calls the _closeAuctionForBidder function. (autogenerated documentation)
_cancelAuction() :
This function cancels an auction by deleting the listing from the listings mapping and transferring the listing tokens back to the listing creator. It emits an AuctionClosed event with the listing ID, the sender, a boolean indicating that the auction was cancelled, the token owner, and an address of 0. (autogenerated documentation)
_closeAuctionForAuctionCreator() :
This function is used to close an auction for the auction creator. It calculates the payout amount for the auction creator, sets the quantity of the listing to 0, sets the price per token of the winning bid to 0, and calls the payout function to transfer the payout amount to the auction creator. Finally, it emits an AuctionClosed event. (autogenerated documentation)
_closeAuctionForBidder() :
This function is used to close an auction for a bidder. It sets the end time of the listing to the current block timestamp, sets the quantity wanted of the winning bid to 0, stores the winning bid and listing in the respective mappings, transfers the listing tokens from the contract to the winning bidder, and emits an AuctionClosed event. (autogenerated documentation)
s function transferListingTokens(address,address,uint256) :
This function is used to transfer tokens from one address to another. It takes four parameters: the address of the sender, the address of the recipient, the quantity of tokens to be transferred, and a listing object containing information about the token type and the asset contract. Depending on the token type, the function will call either the safeTransferFrom() function of the IERC1155Upgradeable contract or the safeTransferFrom() function of the IERC721Upgradeable contract. This will transfer the specified quantity of tokens from the sender to the recipient. (autogenerated documentation)
payout(address,address,address,uint256) :
This function is used to pay out a given amount of currency to a payee. It takes in the address of the payer, the address of the payee, the address of the currency to use, the total payout amount, and a listing as parameters. It then calculates the platform fee cut and the royalty cut, and transfers the currency to the platform fee recipient, the royalty recipient, and the payee. It uses the CurrencyTransferLib to transfer the currency with a native token wrapper. (autogenerated documentation)
validateERC20BalAndAllowance(address,address,uint256) :
This function is used to validate the balance and allowance of an ERC20 token for a given address. It takes in three parameters: the address to check, the address of the ERC20 token, and the amount of the token to check against. It then uses the IERC20Upgradeable interface to check the balance and allowance of the given address for the given token. If the balance and allowance are both greater than or equal to the amount to check against, the function returns true. Otherwise, it returns false. (autogenerated documentation)
validateOwnershipAndApproval(address,address,uint256,uint256) :
This function is used to validate the ownership and approval of a token. It takes in the address of the token owner, the address of the asset contract, the token ID, the quantity, and the token type as parameters. Depending on the token type, it checks if the token owner has enough balance of the token and if the token is approved for the market address. If both conditions are met, it returns true, otherwise it throws an error. (autogenerated documentation)
validateDirectListingSale(address,uint256,address,uint256) :
This function is used to validate a direct listing sale. It checks that the listing type is direct, that the quantity of tokens to buy is valid, that the sale is within the sale window, that the payment is valid (either in ETH or ERC20 tokens), and that the ownership and approval of the token is valid. (autogenerated documentation)
s function getSafeQuantity(uint256) :
This function is used to check the quantity of a token type and return a safe quantity. It takes two parameters, a token type and a quantity to check. If the quantity to check is 0, the safe quantity is set to 0. Otherwise, if the token type is ERC721, the safe quantity is set to 1, otherwise it is set to the quantity to check. (autogenerated documentation)
getTokenType(address) :
This function is used to determine the type of token associated with a given address. It does this by checking if the address supports the ERC1155 or ERC721 interface. If the address supports either of these interfaces, the function will return the corresponding TokenType (ERC1155 or ERC721). If the address does not support either of these interfaces, the function will revert. (autogenerated documentation)
getPlatformFeeInfo() :
This function returns the address of the platform fee recipient and the platform fee rate (in basis points) for the contract. The platform fee rate is a percentage of the total amount of a transaction that is charged as a fee. The platform fee recipient is the address that will receive the fee. (autogenerated documentation)
s function setPlatformFeeInfo(address,uint256) :
This function sets the platform fee information for the contract. It requires that the platform fee recipient address and the platform fee bps (basis points) be passed in as parameters. The platform fee bps must be less than or equal to the maximum bps (10000). The platform fee recipient address and platform fee bps are then stored in the contract. Finally, an event is emitted to indicate that the platform fee information has been updated. (autogenerated documentation)
setAuctionBuffers(uint256,uint256) :
This function sets the auction buffers for the auction contract. It takes two parameters, a time buffer and a bid buffer BPS. The time buffer is used to set the minimum amount of time that must pass between two consecutive bids, while the bid buffer BPS is used to set the minimum amount of BPS that must be exceeded for a bid to be accepted. The function requires that the bid buffer BPS is less than the maximum BPS, and emits an event when the buffers are updated. (autogenerated documentation)
setContractURI(string) :
This function sets the contractURI variable to the value of the _uri parameter. It can only be called by an account with the DEFAULT_ADMIN_ROLE. This allows the contract to store a URI that can be used to access additional information about the contract. (autogenerated documentation)
_msgSender() :
This function is used to retrieve the address of the sender of the current message. It works by calling the _msgSender() function from the ERC2771ContextUpgradeable contract, which returns the address of the sender. (autogenerated documentation)
_msgData() :
This function is used to retrieve the data associated with a given message call. It works by calling the _msgData() function from the ERC2771ContextUpgradeable contract, which returns the data associated with the message call as a byte array. (autogenerated documentation)