You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: contracts/old-marketplace/marketplace.md
+21-21Lines changed: 21 additions & 21 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
# Marketplace design document.
2
2
3
-
This is a live document that explains what the [thirdweb](https://thirdweb.com/)`Marketplace` smart contract is, how it works and can be used, and why it is written the way it is.
3
+
This is a live document that explains what the [thirdweb](https://thirdweb.com/)`Marketplace` smart contract is, how it works and can be used, and why it is written the way it is.
4
4
5
5
The document is written for technical and non-technical readers. To ask further questions about `Marketplace`, please join the [thirdweb discord](https://discord.gg/thirdweb) or create a [github issue](https://github.com/thirdweb-dev/contracts/issues).
6
6
@@ -38,7 +38,7 @@ To make an offer to a direct listing, a buyer specifies —
38
38
39
39
When making an offer to a direct listing, the offer amount is not escrowed in the Marketplace. Instead, making an offer requires the buyer to approve Marketplace to transfer the appropriate amount of currency to let Marketplace transfer the offer amount from the buyer to the lister, in case the lister accepts the buyer's offer.
40
40
41
-
To buy NFTs from a direct listing buy paying the listing's specified price, a buyer specifes -
41
+
To buy NFTs from a direct listing buy paying the listing's specified price, a buyer specifies -
42
42
43
43
| Parameter | Type | Description |
44
44
| --- | --- | --- |
@@ -48,7 +48,7 @@ To buy NFTs from a direct listing buy paying the listing's specified price, a bu
48
48
|`currency`| address | The currency in which to pay for the NFTs being bought. |
49
49
|`totalPrice`| uint256 | The total price to pay for the NFTs being bought. |
50
50
51
-
A sale will fail to execute if either (1) the buyer does not own or has not approved Marketplace to transfer the appropriate amount of currency (or hasn't sent the appropriate amount of native tokens), or (2) the lister does not own or has removed Markeplace's approval to transfer the tokens listed for sale.
51
+
A sale will fail to execute if either (1) the buyer does not own or has not approved Marketplace to transfer the appropriate amount of currency (or hasn't sent the appropriate amount of native tokens), or (2) the lister does not own or has removed Marketplace's approval to transfer the tokens listed for sale.
52
52
53
53
A sale is executed when either a buyer pays the fixed price, or the seller accepts an offer made to the listing.
54
54
@@ -78,11 +78,11 @@ Every auction listing obeys two 'buffers' to make it a fair auction:
78
78
79
79
These buffer values are contract-wide, which means every auction conducted in the Marketplace obeys, at any given moment, the same buffers. These buffers can be configured by contract admins i.e. accounts with the `DEFAULT_ADMIN_ROLE` role.
80
80
81
-
The NFTs to list in an auction *do* leave the wallet of the lister, and are escrowed in the market until the closing of the auction. Whenever a new winning bid is made by a buyer, the buyer deposits this bid amount into the market; this bid amount is escrowed in the market until a new winning bid is made. The previous winning bid amount is automatically refunded to the respective bidder.
81
+
The NFTs to list in an auction *do* leave the wallet of the lister, and are escrowed in the market until the closing of the auction. Whenever a new winning bid is made by a buyer, the buyer deposits this bid amount into the market; this bid amount is escrowed in the market until a new winning bid is made. The previous winning bid amount is automatically refunded to the respective bidder.
82
82
83
83
**Note:** As a result, the new winning bidder pays for the gas used in refunding the previous winning bidder. This trade-off is made for better UX for bidders — a bidder that has been outbid is automatically refunded, and does not need to pull out their deposited bid manually. This reduces bidding to a single action, instead of two actions — bidding, and pulling out the bid on being outbid.
84
84
85
-
If the lister sets a `buyoutPricePerToken`, the marketplace expects the `buyoutPricePerToken` to be greater than or equal to the `rerservePricePerToken` of the auction.
85
+
If the lister sets a `buyoutPricePerToken`, the marketplace expects the `buyoutPricePerToken` to be greater than or equal to the `reservePricePerToken` of the auction.
86
86
87
87
Once the auction window ends, the seller collects the highest bid, and the buyer collects the auctioned NFTs.
88
88
@@ -116,16 +116,16 @@ To thirdweb customers, the `Marketplace` can be set up like any of the other thi
116
116
To the end users of thirdweb customers, the experience of using the marketplace will feel familiar to popular marketplace platforms like OpenSea, Zora, etc. The biggest difference in user experience will be that performing any action on the marketplace requires gas fees.
117
117
118
118
- Thirdweb's customers
119
-
- Deploy the marketplace contract like any other thirdweb contract.
120
-
- Can set a % 'platform fee'. This % is collected on every sale — when a buyer buys tokens from a direct listing, and when a seller collects the highest bid on auction closing. This platform fee is distributed to the platform fee recipient (set by a contract admin).
121
-
- Can set auction buffers. These auction buffers apply to all auctions being conducted in the market.
122
-
- End users of thirdweb customers
123
-
- Can list NFTs for sale at a fixed price.
124
-
- Can edit an existing listing's parameters, e.g. the currency accepted. An auction's parameters cannot be edited once it has started.
125
-
- Can make offers to NFTs listed for a fixed price.
126
-
- Can auction NFTs.
127
-
- Can make bids to auctions.
128
-
- Must pay gas fees to perform any actions, including the actions just listed.
119
+
- Deploy the marketplace contract like any other thirdweb contract.
120
+
- Can set a % 'platform fee'. This % is collected on every sale — when a buyer buys tokens from a direct listing, and when a seller collects the highest bid on auction closing. This platform fee is distributed to the platform fee recipient (set by a contract admin).
121
+
- Can set auction buffers. These auction buffers apply to all auctions being conducted in the market.
122
+
- End users of thirdweb customers
123
+
- Can list NFTs for sale at a fixed price.
124
+
- Can edit an existing listing's parameters, e.g. the currency accepted. An auction's parameters cannot be edited once it has started.
125
+
- Can make offers to NFTs listed for a fixed price.
126
+
- Can auction NFTs.
127
+
- Can make bids to auctions.
128
+
- Must pay gas fees to perform any actions, including the actions just listed.
129
129
130
130
## Technical details
131
131
@@ -160,7 +160,7 @@ We use common functions and data structures wherever an (1) action is common to
160
160
**Example**: Common action and data handled.
161
161
162
162
- Action: creating a listing | Data: `ListingParameters`
163
-
163
+
164
164
```solidity
165
165
struct ListingParameters {
166
166
address assetContract;
@@ -183,9 +183,9 @@ An auction has the concept of formally being closed whereas a direct listing doe
183
183
184
184
### EIPs implemented / supported
185
185
186
-
To be able to escrow NFTs in the case of auctions, Marketplace implements the receiver interfaces for [ERC1155](https://eips.ethereum.org/EIPS/eip-1155) and [ERC721](https://eips.ethereum.org/EIPS/eip-721) tokens.
186
+
To be able to escrow NFTs in the case of auctions, Marketplace implements the receiver interfaces for [ERC1155](https://eips.ethereum.org/EIPS/eip-1155) and [ERC721](https://eips.ethereum.org/EIPS/eip-721) tokens.
187
187
188
-
To enable meta-transactions (gasless), Marketplace implements [ERC2771](https://eips.ethereum.org/EIPS/eip-2771).
188
+
To enable meta-transactions (gasless), Marketplace implements [ERC2771](https://eips.ethereum.org/EIPS/eip-2771).
189
189
190
190
Marketplace also honors [ERC2981](https://eips.ethereum.org/EIPS/eip-2981) for the distribution of royalties on direct and auction listings.
191
191
@@ -200,15 +200,15 @@ The `Marketplace` contract supports both ERC20 currencies, and a chain's native
200
200
201
201
💡 **Note**: The only exception is offers to direct listings — these can only be made with ERC20 tokens, since Marketplace needs to transfer the offer amount from the buyer to the lister, in case the lister accepts the buyer's offer. This cannot be done with native tokens without escrowing the requisite amount of currency.
202
202
203
-
The contract wraps all native tokens deposited into it as the canonical ERC20 wrapped version of the native token (e.g. WETH for ether). The contract unwraps the wrapped native token when transferring native tokens to a given address.
203
+
The contract wraps all native tokens deposited into it as the canonical ERC20 wrapped version of the native token (e.g. WETH for ether). The contract unwraps the wrapped native token when transferring native tokens to a given address.
204
204
205
205
If the contract fails to transfer out native tokens, it wraps them back to wrapped native tokens, and transfers the wrapped native tokens to the concerned address. The contract may fail to transfer out native tokens to an address, if the address represents a smart contract that cannot accept native tokens transferred to it directly.
206
206
207
207
### Alternative designs and trade-offs
208
208
209
209
**Two contracts instead of one:**
210
210
211
-
The main alternative design considered for the `Marketplace` was to split the smart contract into two smart contracts, where each handles (1) only direct listings + offers, or (2) only auction listings + bids.
211
+
The main alternative design considered for the `Marketplace` was to split the smart contract into two smart contracts, where each handles (1) only direct listings + offers, or (2) only auction listings + bids.
212
212
213
213
Such a design gives us two 'lean' contracts instead of one large one, and the cost for deploying just one of these two contracts is less than deploying the single, large `Marketplace` contract. Having two separate contracts positions the thirdweb system to be more modular, where a thirdweb customer can only deploy the smart contract that gives them the specific functionality they want.
214
214
@@ -220,4 +220,4 @@ Having a single, large contract gives us less room to add the ability for the ma
220
220
221
221
Marketplace platforms like OpenSea make actions like making an offer to a direct listing, gasless. End users of the marketplace sign messages expressing intent to perform an action (e.g. list *x* NFT for sale at the price of 10 ETH), and a centralized order-book infrastructure matches two seller-buyer intents, and send the respective signed messages by the seller and buyer to their market smart contract for the sale to be executed.
222
222
223
-
We're working on breaking up, sizing down and optimizing the `Marketplace` contract to accommodate such off-chain actions, and coming up with a central order-book infrastructure that each thirdweb customer can run on their own.
223
+
We're working on breaking up, sizing down and optimizing the `Marketplace` contract to accommodate such off-chain actions, and coming up with a central order-book infrastructure that each thirdweb customer can run on their own.
0 commit comments