Colle Marketplace
Colle.ioWebApp (Live)WebApp (Test)
  • Contracts Overview
  • Functional Requirements
  • Contract Descriptions
  • Technical Project & Audit Details
  • Test Coverage Report
  • Static Analysis
  • Royalty Pool Explained
  • Sale State Explained
  • Sales Tax Explained
  • marketplace
    • IMarketHub
    • IMarketHubRegistrar
    • MarketHub
    • MarketHubRegistrar
    • MarketHubRegistrarUpgradeable
    • collections
      • ColleCollection
      • ColleCollectionUpgradeable
      • CollectionRegistry
      • IColleCollection
      • IColleCollectionUpgradeable
      • ICollectionRegistry
    • currencies
      • BaseCurrency
      • CurrencyRegistry
      • ICurrency
      • ICurrencyRegistry
      • USDCCurrency
    • escrow
      • EscrowUpgradeable
      • IEscrow
      • IEscrowRegistry
    • kycs
      • Account
      • IKYCRegistry
      • KYCRegistry
    • markets
      • BaseMarketUpgradeable
      • IListingMarket
      • IMarket
      • IMarketRegistry
      • IOfferMarket
      • ListingMarketUpgradeable
      • MarketRegistry
      • OfferMarketUpgradeable
    • royalties
      • BaseRoyalty
      • BlackTierRoyalty
      • GoldTierRoyalty
      • GreenTierRoyalty
      • IRoyalty
      • IRoyaltyPool
      • IRoyaltyRegistry
      • PlatinumTierRoyalty
      • RoyaltyPool
      • RoyaltyRegistry
      • v1
        • BlackTierRoyaltyV1
        • GoldTierRoyaltyV1
        • GreenTierRoyaltyV1
        • PlatinumTierRoyaltyV1
    • taxes
      • ITaxPolicyRegistry
      • Tax
      • TaxPolicyRegistry
    • upgrade-gatekeeper
      • IUpgradeGatekeeper
      • UpgradeGatekeeper
    • vaults
      • IVault
      • IVaultRegistry
      • VaultUpgradeable
  • team-smart-wallet
    • ITeamSmartWallet
    • ITeamSmartWalletHelper
    • TeamSmartWallet
    • TeamSmartWalletFactory
    • TeamSmartWalletPermitHelper
  • utils
    • MarketAccess
    • MarketAccessUpgradeable
    • Signature
    • SignatureValidator
Powered by GitBook
On this page
  • saleIdCounter
  • sales
  • activeSales
  • buyerChallengeWindow
  • Return Values
  • saleFundingWindow
  • Return Values
  • constructor
  • initialize
  • Parameters
  • onlyMarket
  • setBuyerChallengeWindow
  • Parameters
  • setSaleFundingWindow
  • Parameters
  • createSale
  • Parameters
  • updateSaleTaxesToCollect
  • Parameters
  • _createSale
  • Parameters
  • getSale
  • Parameters
  • Return Values
  • hasActiveSale
  • Parameters
  • Return Values
  • updateSale
  • Parameters
  • permitUpdateSale
  • Parameters
  • supportsInterface
  • Parameters
  • Return Values
  • _updateSale
  • Parameters
  • _updateSaleToSaleCancelled
  • Parameters
  • _updateSaleToIssueWithProduct
  • Parameters
  • _updateSaleToIssueWithDelivery
  • Parameters
  • _updateSaleToSaleSuccess
  • Parameters
  • _payout
  • Parameters
  • _updateSaleState
  • _authorizeUpgrade
  • Parameters
  • _getPermitUpdateSaleHash
  • Parameters
  1. marketplace
  2. escrow

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

uint256 saleIdCounter

sales

mapping(uint256 => struct IEscrow.Sale) sales

activeSales

mapping(address => mapping(uint256 => bool)) activeSales

buyerChallengeWindow

uint256 buyerChallengeWindow

Returns the current challenge window for buyers.

Return Values

saleFundingWindow

uint256 saleFundingWindow

Returns the current funding window for buyers.

Return Values

constructor

constructor() public

The constructor initializes the base contract.

initialize

function initialize(string _name) public

_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
Type
Description

_name

string

string The name for the contract.

onlyMarket

modifier onlyMarket()

Only functions with this modifier can be called by a registered market

setBuyerChallengeWindow

function setBuyerChallengeWindow(uint256 _hours) public virtual

Sets the time window during which buyers can challenge a sale. Can only be called by the colle.

Parameters

Name
Type
Description

_hours

uint256

The new challenge window in hours.

setSaleFundingWindow

function setSaleFundingWindow(uint256 _hours) public virtual

Sets the time window during which a sale can be funded. Can only be called by the colle.

Parameters

Name
Type
Description

_hours

uint256

The new funding window in hours.

createSale

function createSale(address _buyer, address _spender, address _erc20, uint256 _price, address _seller, address _erc721, uint256 _tokenId) public virtual

Creates a new sale. Can only be called by the market.

Parameters

Name
Type
Description

_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

function updateSaleTaxesToCollect(uint256 _saleId, struct Tax _taxes) public virtual

Updates the sales tax for a pre-pending sale.

Parameters

Name
Type
Description

_saleId

uint256

The id of the sale.

_taxes

struct Tax

The new taxes to collect in ERC20 tokens.

_createSale

function _createSale(address _buyer, address _spender, address _erc20, uint256 _price, address _seller, address _erc721, uint256 _tokenId) internal virtual

Creates a new sale.

Parameters

Name
Type
Description

_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

function getSale(uint256 _saleId) external view virtual returns (struct IEscrow.Sale)

Returns details of a sale.

Parameters

Name
Type
Description

_saleId

uint256

The id of the sale.

Return Values

Name
Type
Description

[0]

struct IEscrow.Sale

Sale The details of the sale.

hasActiveSale

function hasActiveSale(address _erc721, uint256 _tokenId) external view virtual returns (bool)

Checks if a particular ERC721 token is currently part of an active sale.

Parameters

Name
Type
Description

_erc721

address

The address of the ERC721 token.

_tokenId

uint256

The id of the ERC721 token.

Return Values

Name
Type
Description

[0]

bool

bool Whether the token is part of an active sale or not.

updateSale

function updateSale(uint256 _saleId, enum IEscrow.State _newState) external virtual

Updates the state of a sale. Can only be called by the buyer, the seller, or the colle.

Parameters

Name
Type
Description

_saleId

uint256

The id of the sale.

_newState

enum IEscrow.State

The new state of the sale.

permitUpdateSale

function permitUpdateSale(uint256 _saleId, enum IEscrow.State _newState, struct Signature _signature) external virtual

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

Name
Type
Description

_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

function supportsInterface(bytes4 _interfaceId) public view virtual returns (bool)

Checks if the contract implements an interface.

Parameters

Name
Type
Description

_interfaceId

bytes4

The ID of the interface.

Return Values

Name
Type
Description

[0]

bool

True if the contract implements the interface, false otherwise.

_updateSale

function _updateSale(address _sender, uint256 _saleId, enum IEscrow.State _newState) internal virtual

Internal function to update the state of a sale. Only the buyer, seller or the Colle can update the sale.

Parameters

Name
Type
Description

_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

function _updateSaleToSaleCancelled(address _sender, struct IEscrow.Sale _sale) internal virtual

Internal function to transition a sale to the "SaleCancelled" state.

Parameters

Name
Type
Description

_sender

address

The address initiating the sale update.

_sale

struct IEscrow.Sale

The sale struct in memory

_updateSaleToIssueWithProduct

function _updateSaleToIssueWithProduct(address _sender, struct IEscrow.Sale _sale) internal virtual

Internal function to transition a sale to the "ShippingToColleForDispute" state.

Parameters

Name
Type
Description

_sender

address

The address initiating the sale update.

_sale

struct IEscrow.Sale

The id of the sale.

_updateSaleToIssueWithDelivery

function _updateSaleToIssueWithDelivery(address _sender, struct IEscrow.Sale _sale) internal virtual

Internal function to transition a sale to the "ShippingToColleForDispute" state.

Parameters

Name
Type
Description

_sender

address

The address initiating the sale update.

_sale

struct IEscrow.Sale

The id of the sale.

_updateSaleToSaleSuccess

function _updateSaleToSaleSuccess(address _sender, struct IEscrow.Sale _sale) internal virtual

Internal function to transition a sale to the "ShippingToColleForDispute" state.

Parameters

Name
Type
Description

_sender

address

The address initiating the sale update.

_sale

struct IEscrow.Sale

The id of the sale.

_payout

function _payout(struct IEscrow.Sale _sale, uint256 _colleComissionPoolAmount, uint256 _initialOwnerRoyaltyPayout, uint256 _recentOwnerRoyaltyPayout, uint256 _amountToSeller) internal virtual

Internal function to payout the seller, colle, and royalty pool after a sale completes.

Parameters

Name
Type
Description

_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

function _updateSaleState(uint256 _saleId, enum IEscrow.State state) internal virtual

_authorizeUpgrade

function _authorizeUpgrade(address _newImplementation) internal

Internal function called on UUPS upgrade to verify that the contract is approved to update to the new implementation

Parameters

Name
Type
Description

_newImplementation

address

The address of the new implementation.

_getPermitUpdateSaleHash

function _getPermitUpdateSaleHash(struct Signature _signature, uint256 _saleId, enum IEscrow.State _newState) internal view virtual returns (bytes32)

Internal function to get the expected EIP-712 signed hash to permit updating a sale's state

Parameters

Name
Type
Description

_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.

PreviousescrowNextIEscrow

Last updated 1 year ago