EscrowUpgradeable
This contract manages the escrow system for a marketplace trading ERC721 and ERC20 tokens. It's upgradeable using the UUPS (Universal Upgradeable Proxy Standard) mechanism.
Uses OpenZeppelin and other contracts for secure, standard compliant and upgradeable structures.
saleIdCounter
sales
activeSales
buyerChallengeWindow
Returns the current challenge window for buyers.
Return Values
saleFundingWindow
Returns the current funding window for buyers.
Return Values
constructor
The constructor initializes the base contract.
initialize
_Initializes the contract with the provided name. Initializes the upgradeable parts of the contract, the signature validator and the market hub registrar. Sets the buyerChallengeWindow to 48 and the saleFundingWindow to 24. Emits two events: BuyerChallengeWindowChanged with the new value of buyerChallengeWindow, and SaleFundingWindowChanged with the new value of saleFundingWindow.
Requirements:
This function can only be called once, at the time of contract initialization._
Parameters
_name
string
string The name for the contract.
onlyMarket
Only functions with this modifier can be called by a registered market
setBuyerChallengeWindow
Sets the time window during which buyers can challenge a sale. Can only be called by the colle.
Parameters
_hours
uint256
The new challenge window in hours.
setSaleFundingWindow
Sets the time window during which a sale can be funded. Can only be called by the colle.
Parameters
_hours
uint256
The new funding window in hours.
createSale
Creates a new sale. Can only be called by the market.
Parameters
_buyer
address
The buyer's address.
_spender
address
The address spending the ERC20 tokens.
_erc20
address
The address of the ERC20 token being used as currency.
_price
uint256
The price in ERC20 tokens.
_seller
address
The seller's address.
_erc721
address
The address of the ERC721 token being sold.
_tokenId
uint256
The id of the ERC721 token being sold.
updateSaleTaxesToCollect
Updates the sales tax for a pre-pending sale.
Parameters
_saleId
uint256
The id of the sale.
_taxes
struct Tax
The new taxes to collect in ERC20 tokens.
_createSale
Creates a new sale.
Parameters
_buyer
address
The buyer's address.
_spender
address
The address spending the ERC20 tokens.
_erc20
address
The address of the ERC20 token being used as currency.
_price
uint256
The price in ERC20 tokens.
_seller
address
The seller's address.
_erc721
address
The address of the ERC721 token being sold.
_tokenId
uint256
The id of the ERC721 token being sold.
getSale
Returns details of a sale.
Parameters
_saleId
uint256
The id of the sale.
Return Values
[0]
struct IEscrow.Sale
Sale The details of the sale.
hasActiveSale
Checks if a particular ERC721 token is currently part of an active sale.
Parameters
_erc721
address
The address of the ERC721 token.
_tokenId
uint256
The id of the ERC721 token.
Return Values
[0]
bool
bool Whether the token is part of an active sale or not.
updateSale
Updates the state of a sale. Can only be called by the buyer, the seller, or the colle.
Parameters
_saleId
uint256
The id of the sale.
_newState
enum IEscrow.State
The new state of the sale.
permitUpdateSale
Allows a signer to permit the update of a sale's state.
The function is virtual, can be overridden and can only be called by the Colle if the signature is valid.
Parameters
_saleId
uint256
The id of the sale.
_newState
enum IEscrow.State
The new state of the sale.
_signature
struct Signature
The signer's signature, deadline and signer address.
supportsInterface
Checks if the contract implements an interface.
Parameters
_interfaceId
bytes4
The ID of the interface.
Return Values
[0]
bool
True if the contract implements the interface, false otherwise.
_updateSale
Internal function to update the state of a sale. Only the buyer, seller or the Colle can update the sale.
Parameters
_sender
address
The address initiating the sale update.
_saleId
uint256
The id of the sale.
_newState
enum IEscrow.State
The new state of the sale.
_updateSaleToSaleCancelled
Internal function to transition a sale to the "SaleCancelled" state.
Parameters
_sender
address
The address initiating the sale update.
_sale
struct IEscrow.Sale
The sale struct in memory
_updateSaleToIssueWithProduct
Internal function to transition a sale to the "ShippingToColleForDispute" state.
Parameters
_sender
address
The address initiating the sale update.
_sale
struct IEscrow.Sale
The id of the sale.
_updateSaleToIssueWithDelivery
Internal function to transition a sale to the "ShippingToColleForDispute" state.
Parameters
_sender
address
The address initiating the sale update.
_sale
struct IEscrow.Sale
The id of the sale.
_updateSaleToSaleSuccess
Internal function to transition a sale to the "ShippingToColleForDispute" state.
Parameters
_sender
address
The address initiating the sale update.
_sale
struct IEscrow.Sale
The id of the sale.
_payout
Internal function to payout the seller, colle, and royalty pool after a sale completes.
Parameters
_sale
struct IEscrow.Sale
The id of the sale.
_colleComissionPoolAmount
uint256
The amount of comission funds to be distributed to the relayer
_initialOwnerRoyaltyPayout
uint256
The amount of royalty funds to be distributed the initial seller
_recentOwnerRoyaltyPayout
uint256
The amount of royalty funds to be distributed to each recent seller in the royalty pool
_amountToSeller
uint256
The price of the sale, minus the royalty and comission pool amounts, to be sent to the current seller
_updateSaleState
_authorizeUpgrade
Internal function called on UUPS upgrade to verify that the contract is approved to update to the new implementation
Parameters
_newImplementation
address
The address of the new implementation.
_getPermitUpdateSaleHash
Internal function to get the expected EIP-712 signed hash to permit updating a sale's state
Parameters
_signature
struct Signature
The address of the signer.
_saleId
uint256
The id of the sale.
_newState
enum IEscrow.State
The new state of the sale.
Last updated