Skip to content

Commit 1c48daf

Browse files
doc: updated Exchange.md
1 parent 79433cb commit 1c48daf

File tree

2 files changed

+70
-16
lines changed

2 files changed

+70
-16
lines changed

packages/marketplace/docs/Exchange.md

Lines changed: 70 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
The [Exchange contract](../contracts/Exchange.sol) is the entrypoint and main
66
contract to the marketplace protocol. It safely offers a decentralized way to
7-
exchange tokens of any nature (ERC20, ERC1155, ERC721) using signed orders.It
7+
exchange tokens of any nature (ERC20, ERC1155, ERC721) using signed orders. It
88
also supports exchanging bundles of assets, which can include multiple ERC1155,
99
ERC721, and Quads.
1010

@@ -29,23 +29,81 @@ seller is asking for (and more).
2929
### Bundle Order
3030

3131
In addition to single-asset orders, the protocol supports bundle orders, where
32-
multiple assets are grouped together as a single entity for exchange. Let's
33-
consider this use case:
32+
multiple assets are grouped together as a single entity for exchange. A bundle
33+
can contain:
3434

35-
Order B
35+
- Multiple ERC721 tokens
36+
- Multiple ERC1155 tokens
37+
- Multiple Quads
38+
- Any combination of the above
39+
40+
Important restrictions for bundles:
41+
42+
- Bundles cannot contain ERC20 tokens
43+
- Bundles can only be exchanged for ERC20 tokens (not for other NFTs or bundles)
44+
45+
Each asset in the bundle can have its own individual price, and the total price
46+
of the bundle is the sum of all individual asset prices.
47+
48+
#### Bundle Examples
49+
50+
##### Example 1: Simple Bundle with ERC721 and ERC1155
3651

3752
```
38-
Alice wants to sell a bundle of assets:
39-
1 LAND (ERC721) with token id 1000
53+
Alice wants to sell a bundle containing:
54+
- 1 LAND (ERC721) with token id 1000
4055
- Price: 1200 MATIC
41-
10 ASSET (ERC1155) with token id 2000
42-
- Price: 700 MATIC
43-
against 2000 MATIC (ERC20).
56+
- 10 ASSET (ERC1155) with token id 2000
57+
- Price: 800 MATIC
58+
Total bundle price: 2000 MATIC
4459
```
4560

46-
The order represents this intent and includes the address of the seller, the
47-
address for the tokens(ERC721 and ERC1155), the token ids, the individual prices
48-
of the assets, the address of the ERC20 and the amount the seller is asking for.
61+
##### Example 2: Bundle with Quads
62+
63+
```
64+
Alice wants to sell a bundle containing:
65+
- 2 Quads (3x3 size each)
66+
- First Quad: 500 MATIC
67+
- Second Quad: 500 MATIC
68+
- 1 LAND (ERC721) with token id 1000
69+
- Price: 4000 MATIC
70+
Total bundle price: 5000 MATIC
71+
```
72+
73+
##### Example 3: Bundle with Multiple ERC1155
74+
75+
```
76+
Alice wants to sell a bundle containing:
77+
- 10 ASSET_A (ERC1155) with token id 1000
78+
- Price: 10000 MATIC
79+
- 5 ASSET_B (ERC1155) with token id 2000
80+
- Price: 5000 MATIC
81+
Total bundle price: 15000 MATIC
82+
```
83+
84+
#### Invalid Bundle Examples
85+
86+
##### Example 1: Bundle with ERC20 (Not Allowed)
87+
88+
```
89+
- 1 LAND (ERC721)
90+
- 1000 SAND (ERC20) // ERC20 tokens cannot be part of a bundle
91+
```
92+
93+
##### Example 2: Bundle-to-Bundle Exchange (Not Allowed)
94+
95+
```
96+
- Bundle A (containing ERC721) <-> Bundle B (containing ERC1155)
97+
// Bundles can only be exchanged for ERC20 tokens
98+
```
99+
100+
##### Example 3: Bundle with Value > 1 for ERC721 (Not Allowed)
101+
102+
```
103+
- 2 LAND (ERC721) with token id 1000
104+
- Price: 1200 MATIC each
105+
// ERC721 tokens are unique and cannot have a value > 1 in a bundle
106+
```
49107

50108
### Maker & Taker
51109

packages/marketplace/test/exchange/Bundle.behavior.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,6 @@ export function shouldMatchOrdersForBundle() {
530530
maker,
531531
bundleWithoutERC721Left, // makeAsset
532532
ZeroAddress,
533-
534533
ERC20AssetForLeftOrder, // takeAsset
535534
1,
536535
0,
@@ -541,7 +540,6 @@ export function shouldMatchOrdersForBundle() {
541540
taker,
542541
ERC20AssetForRightOrder, // makeAsset
543542
ZeroAddress,
544-
545543
bundleWithoutERC721Right, // takeAsset
546544
1,
547545
0,
@@ -656,7 +654,6 @@ export function shouldMatchOrdersForBundle() {
656654
maker,
657655
bundleWithoutERC721Left, // makeAsset
658656
ZeroAddress,
659-
660657
ERC20AssetForLeftOrder, // takeAsset
661658
1,
662659
0,
@@ -862,7 +859,6 @@ export function shouldMatchOrdersForBundle() {
862859
maker,
863860
bundleWithoutERC721Left, // makeAsset
864861
ZeroAddress,
865-
866862
ERC20AssetForLeftOrder, // takeAsset
867863
1,
868864
0,

0 commit comments

Comments
 (0)