generated from 0age/foundry-template
-
Notifications
You must be signed in to change notification settings - Fork 25
/
BaseMarketConfig.sol
559 lines (526 loc) · 19.5 KB
/
BaseMarketConfig.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.7;
import { SetupCall, TestOrderPayload, TestOrderContext, TestCallParameters, TestItem20, TestItem721, TestItem1155 } from "./Types.sol";
abstract contract BaseMarketConfig {
/**
* @dev Market name used in results
*/
function name() external pure virtual returns (string memory);
function market() public view virtual returns (address);
/**
* @dev Address that should be approved for nft tokens
* (ERC721 and ERC1155). Should be set during `beforeAllPrepareMarketplace`.
*/
address public sellerNftApprovalTarget;
address public buyerNftApprovalTarget;
/**
* @dev Address that should be approved for ERC1155 tokens. Only set if
* different than ERC721 which is defined above. Set during `beforeAllPrepareMarketplace`.
*/
address public sellerErc1155ApprovalTarget;
address public buyerErc1155ApprovalTarget;
/**
* @dev Address that should be approved for erc20 tokens.
* Should be set during `beforeAllPrepareMarketplace`.
*/
address public sellerErc20ApprovalTarget;
address public buyerErc20ApprovalTarget;
/**
* @dev Get calldata to call from test prior to starting tests
* (used by wyvern to create proxies)
* @ param seller The seller address used for testing the marketplace
* @ param buyer The buyer address used for testing the marketplace
* @return From address, to address, and calldata
*/
function beforeAllPrepareMarketplaceCall(
address, /* seller */
address, /* buyer */
address[] calldata, /* erc20Tokens*/
address[] calldata /* erc721Tokens*/
) external virtual returns (SetupCall[] memory) {
SetupCall[] memory empty = new SetupCall[](0);
return empty;
}
/**
* @dev Final setup prior to starting tests
* @ param seller The seller address used for testing the marketplace
* @ param buyer The buyer address used for testing the marketplace
*/
function beforeAllPrepareMarketplace(
address, /* seller */
address /* buyer */
) external virtual;
/*//////////////////////////////////////////////////////////////
Test Payload Calls
//////////////////////////////////////////////////////////////*/
/**
* @dev Get call parameters to execute an order selling a 721 token for Ether.
* If `context.listOnChain` is true and marketplace does not support on-chain
* listing, this function must revert with NotImplemented.
* @ param context Order context, including the buyer and seller and whether the
* order should be listed on chain.
* @ param nft Address and ID for ERC721 token to be sold.
* @ param ethAmount Amount of Ether to be received for the NFT.
*/
function getPayload_BuyOfferedERC721WithEther(
TestOrderContext calldata, /* context */
TestItem721 calldata, /* nft */
uint256 /* ethAmount */
)
external
virtual
returns (
TestOrderPayload memory /* execution */
)
{
_notImplemented();
}
/**
* @dev Get call parameters to execute an order selling an 1155 token for Ether.
* If `context.listOnChain` is true and marketplace does not support on-chain
* listing, this function must revert with NotImplemented.
* @ param context Order context, including the buyer and seller and whether the
* order should be listed on chain.
* @ param nft Address, ID and amount for ERC1155 token to be sold.
* @ param ethAmount Amount of Ether to be received for the NFT.
*/
function getPayload_BuyOfferedERC1155WithEther(
TestOrderContext calldata, /* context */
TestItem1155 calldata, /* nft */
uint256 /* ethAmount */
)
external
view
virtual
returns (
TestOrderPayload memory /* execution */
)
{
_notImplemented();
}
/**
* @dev Get call parameters to execute an order selling a 721 token for an ERC20.
* If `context.listOnChain` is true and marketplace does not support on-chain
* listing, this function must revert with NotImplemented.
* @ param context Order context, including the buyer and seller and whether the
* order should be listed on chain.
* @ param nft Address and ID of 721 token to be sold.
* @ param erc20 Address and amount for ERC20 to be received for nft.
*/
function getPayload_BuyOfferedERC721WithERC20(
TestOrderContext calldata, /* context */
TestItem721 calldata, /* nft */
TestItem20 calldata /* erc20 */
)
external
virtual
returns (
TestOrderPayload memory /* execution */
)
{
_notImplemented();
}
/**
* @dev Get call parameters to execute an order selling a 721 token for WETH.
* If `context.listOnChain` is true and marketplace does not support on-chain
* listing, this function must revert with NotImplemented.
* @ param context Order context, including the buyer and seller and whether the
* order should be listed on chain.
* @ param nft Address and ID of 721 token to be sold.
* @ param erc20 Address and amount for WETH to be received for nft.
*/
function getPayload_BuyOfferedERC721WithWETH(
TestOrderContext calldata, /* context */
TestItem721 calldata, /* nft */
TestItem20 calldata /* erc20 */
)
external
virtual
returns (
TestOrderPayload memory /* execution */
)
{
_notImplemented();
}
/**
* @dev Get call parameters to execute an order selling a 721 token for WETH.
* If `context.listOnChain` is true and marketplace does not support on-chain
* listing, this function must revert with NotImplemented.
* @ param context Order context, including the buyer and seller and whether the
* order should be listed on chain.
* @ param nft Address and ID of 721 token to be sold.
* @ param erc20 Address and amount for WETH to be received for nft.
*/
function getPayload_BuyOfferedERC721WithBETH(
TestOrderContext calldata, /* context */
TestItem721 calldata, /* nft */
TestItem20 calldata /* erc20*/
)
external
virtual
returns (
TestOrderPayload memory /*execution*/
)
{
_notImplemented();
}
/**
* @dev Get call parameters to execute an order selling an 1155 token for an ERC20.
* If `context.listOnChain` is true and marketplace does not support on-chain
* listing, this function must revert with NotImplemented.
* @ param context Order context, including the buyer and seller and whether the
* order should be listed on chain.
* @ param nft Address, ID and amount for ERC1155 token to be sold.
* @ param erc20 Address and amount for ERC20 to be received for nft.
*/
function getPayload_BuyOfferedERC1155WithERC20(
TestOrderContext calldata, /* context */
TestItem1155 calldata, /* nft */
TestItem20 calldata /* erc20 */
)
external
view
virtual
returns (
TestOrderPayload memory /* execution */
)
{
_notImplemented();
}
/**
* @dev Get call parameters to execute an order selling an ERC20 token for an ERC721.
* If `context.listOnChain` is true and marketplace does not support on-chain
* listing, this function must revert with NotImplemented.
* @ param context Order context, including the buyer and seller and whether the
* order should be listed on chain.
* @ param erc20 Address and amount for ERC20 to be sold.
* @ param nft Address and ID for 721 token to be received for ERC20.
*/
function getPayload_BuyOfferedERC20WithERC721(
TestOrderContext calldata, /* context */
TestItem20 calldata, /* erc20 */
TestItem721 calldata /* nft */
)
external
virtual
returns (
TestOrderPayload memory /* execution */
)
{
_notImplemented();
}
/**
* @dev Get call parameters to execute an order selling WETH for an ERC721.
* If `context.listOnChain` is true and marketplace does not support on-chain
* listing, this function must revert with NotImplemented.
* @ param context Order context, including the buyer and seller and whether the
* order should be listed on chain.
* @ param erc20 Address and amount of WETH to be sold.
* @ param nft Address and ID for 721 token to be received for WETH.
*/
function getPayload_BuyOfferedWETHWithERC721(
TestOrderContext calldata, /* context */
TestItem20 calldata, /* erc20 */
TestItem721 calldata /* nft */
)
external
virtual
returns (
TestOrderPayload memory /* execution */
)
{
_notImplemented();
}
function getPayload_BuyOfferedBETHWithERC721(
TestOrderContext calldata, /* context */
TestItem20 calldata, /* erc20 */
TestItem721 calldata /* nft */
)
external
virtual
returns (
TestOrderPayload memory /* execution */
)
{
_notImplemented();
}
/**
* @dev Get call parameters to execute an order selling an ERC20 token for an ERC1155.
* If `context.listOnChain` is true and marketplace does not support on-chain
* listing, this function must revert with NotImplemented.
* @ param context Order context, including the buyer and seller and whether the
* order should be listed on chain.
* @ param erc20 Address and amount for ERC20 to be sold.
* @ param nft Address, ID and amount for 1155 token to be received for ERC20.
*/
function getPayload_BuyOfferedERC20WithERC1155(
TestOrderContext calldata, /* context */
TestItem20 calldata, /* erc20 */
TestItem1155 calldata /* nft */
)
external
view
virtual
returns (
TestOrderPayload memory /* execution */
)
{
_notImplemented();
}
/**
* @dev Get call parameters to execute an order selling an ERC721 token for an ERC1155.
* If `context.listOnChain` is true and marketplace does not support on-chain
* listing, this function must revert with NotImplemented.
* @ param context Order context, including the buyer and seller and whether the
* order should be listed on chain.
* @ param sellNft Address and ID of 721 token to be sold.
* @ param buyNft Address, ID and amount of 1155 token to be received for ERC721.
*/
function getPayload_BuyOfferedERC721WithERC1155(
TestOrderContext calldata, /* context */
TestItem721 calldata, /* sellNft */
TestItem1155 calldata /* buyNft */
)
external
view
virtual
returns (
TestOrderPayload memory /* execution */
)
{
_notImplemented();
}
/**
* @dev Get call parameters to execute an order selling an ERC1155 token for an ERC721.
* If `context.listOnChain` is true and marketplace does not support on-chain
* listing, this function must revert with NotImplemented.
* @ param context Order context, including the buyer and seller and whether the
* order should be listed on chain.
* @ param sellNft Address and ID of 1155 token to be sold.
* @ param buyNft Address, ID and amount of 721 token to be received for ERC1155.
*/
function getPayload_BuyOfferedERC1155WithERC721(
TestOrderContext calldata, /* context */
TestItem1155 calldata, /* sellNft */
TestItem721 calldata /* buyNft */
)
external
view
virtual
returns (
TestOrderPayload memory /* execution */
)
{
_notImplemented();
}
/**
* @dev Get call parameters to execute an order selling a 721 token for Ether with one fee recipient.
* If `context.listOnChain` is true and marketplace does not support on-chain
* listing, this function must revert with NotImplemented.
* @ param context Order context, including the buyer and seller and whether the
* order should be listed on chain.
* @ param nft Address and ID for ERC721 token to be sold.
* @ param priceEthAmount Amount of Ether to be received for the NFT.
* @ param feeRecipient Address to send fee to.
* @ param feeEthAmount Amount of Ether to send for fee.
*/
function getPayload_BuyOfferedERC721WithEtherOneFeeRecipient(
TestOrderContext calldata, /* context */
TestItem721 memory, /* nft */
uint256, /* priceEthAmount */
address, /* feeRecipient */
uint256 /* feeEthAmount */
)
external
view
virtual
returns (
TestOrderPayload memory /* execution */
)
{
_notImplemented();
}
/**
* @dev Get call parameters to execute an order selling a 721 token for Ether with two fee recipients.
* If `context.listOnChain` is true and marketplace does not support on-chain
* listing, this function must revert with NotImplemented.
* @ param context Order context, including the buyer and seller and whether the
* order should be listed on chain.
* @ param nft Address and ID for ERC721 token to be sold.
* @ param priceEthAmount Amount of Ether to be received for the NFT.
* @ param feeRecipient1 Address to send first fee to.
* @ param feeEthAmount1 Amount of Ether to send for first fee.
* @ param feeRecipient2 Address to send second fee to.
* @ param feeEthAmount2 Amount of Ether to send for second fee.
*/
function getPayload_BuyOfferedERC721WithEtherTwoFeeRecipient(
TestOrderContext calldata, /* context */
TestItem721 memory, /* nft */
uint256, /* priceEthAmount */
address, /* feeRecipient1 */
uint256, /* feeEthAmount1 */
address, /* feeRecipient2 */
uint256 /* feeEthAmount2 */
)
external
view
virtual
returns (
TestOrderPayload memory /* execution */
)
{
_notImplemented();
}
/**
* @dev Get call parameters to execute an order selling many 721 tokens for Ether.
* If `context.listOnChain` is true and marketplace does not support on-chain
* listing, this function must revert with NotImplemented.
* @ param context Order context, including the buyer and seller and whether the
* order should be listed on chain.
* @ param nfts Array of Address and ID for ERC721 tokens to be sold.
* @ param ethAmount Amount of Ether to be received for the NFT.
*/
function getPayload_BuyOfferedManyERC721WithEther(
TestOrderContext calldata, /* context */
TestItem721[] calldata, /* nfts */
uint256 /* ethAmount */
)
external
virtual
returns (
TestOrderPayload memory /* execution */
)
{
_notImplemented();
}
/**
* @dev Get call parameters to execute an order "sweeping the floor" buy filling 10 distinct
* ERC-721->ETH orders at once. Same seller on each order. If the market does not support the
* order type, must revert with NotImplemented.
* @ param contexts Array of contexts for each order
* @ param nfts Array of NFTs for each order
* @ param ethAmounts Array of Ether emounts to be received for the NFTs in each order
*/
function getPayload_BuyOfferedManyERC721WithEtherDistinctOrders(
TestOrderContext[] calldata, /* contexts */
TestItem721[] calldata, /* nfts */
uint256[] calldata /* ethAmounts */
)
external
view
virtual
returns (
TestOrderPayload memory /* execution */
)
{
_notImplemented();
}
/**
* @dev Get call parameters to execute an order "sweeping the floor" buy filling 10 distinct
* ERC-721->ERC-20 orders at once. Same seller on each order. If the market does not support the
* order type, must revert with NotImplemented.
* @ param contexts Array of contexts for each order
* @ param erc20Address The erc20 address to use across orders
* @ param nfts Array of NFTs for each order
* @ param erc20Amounts Array of Erc20 amounts to be received for the NFTs in each order
*/
function getPayload_BuyOfferedManyERC721WithErc20DistinctOrders(
TestOrderContext[] calldata, /* contexts */
address, /* erc20Address */
TestItem721[] calldata, /* nfts */
uint256[] calldata /* erc20Amounts */
)
external
view
virtual
returns (
TestOrderPayload memory /* execution */
)
{
_notImplemented();
}
/**
* @dev Get call parameters to execute an order "sweeping the floor" buy filling 10 distinct
* ERC-721->WETH orders at once. Same seller on each order. If the market does not support the
* order type, must revert with NotImplemented.
* @ param contexts Array of contexts for each order
* @ param erc20Address The WETH address to use across orders
* @ param nfts Array of NFTs for each order
* @ param erc20Amounts Array of WETH amounts to be received for the NFTs in each order
*/
function getPayload_BuyOfferedManyERC721WithWETHDistinctOrders(
TestOrderContext[] calldata, /* contexts */
address, /* erc20Address */
TestItem721[] calldata, /* nfts */
uint256[] calldata /* erc20Amounts */
)
external
view
virtual
returns (
TestOrderPayload memory /* execution */
)
{
_notImplemented();
}
/**
* @dev Get call parameters to execute a match orders style execution. This execution
* involves arbitrary number of orders in the pattern A -> B -> C -> A. Where each arrow
* indicates an individual order. There orders are not fulfillable individually,
* however, they are when executed atomically.
* @ param contexts Array of contexts for each order
* @ param nfts Array of NFTs in the order A, B, C...
*/
function getPayload_MatchOrders_ABCA(
TestOrderContext[] calldata, /* contexts */
TestItem721[] calldata /* nfts */
)
external
view
virtual
returns (
TestOrderPayload memory /* execution */
)
{
_notImplemented();
}
/*//////////////////////////////////////////////////////////////
Helpers
//////////////////////////////////////////////////////////////*/
ITestRunner private _tester;
error NotImplemented();
/**
* @dev Revert if the type of requested order is impossible
* to execute for a marketplace.
*/
function _notImplemented() internal pure {
revert NotImplemented();
}
constructor() {
_tester = ITestRunner(msg.sender);
}
/**
* @dev Request a signature from the testing contract.
*/
function _sign(address signer, bytes32 digest)
internal
view
returns (
uint8,
bytes32,
bytes32
)
{
return _tester.signDigest(signer, digest);
}
}
interface ITestRunner {
function signDigest(address signer, bytes32 digest)
external
view
returns (
uint8,
bytes32,
bytes32
);
}