-
Notifications
You must be signed in to change notification settings - Fork 7
/
RCFull.sol
644 lines (412 loc) · 17.6 KB
/
RCFull.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
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.7;
// Just a handy file to copy/paste into remix
interface IRCFactory {
function createMarket(
uint32 _mode,
string memory _ipfsHash,
string memory _slug,
uint32[] memory _timestamps,
string[] memory _tokenURIs,
address _artistAddress,
address _affiliateAddress,
address[] memory _cardAffiliateAddresses,
string calldata _realitioQuestion,
uint256 _sponsorship
) external returns (address);
function mintCopyOfNFT(address _user, uint256 _tokenId) external;
// view functions
function nfthub() external view returns (address);
function ipfsHash(address) external view returns (string memory);
function slugToAddress(string memory) external view returns (address);
function addressToSlug(address) external view returns (string memory);
function marketInfoResults() external view returns (uint256);
function treasury() external view returns (address);
function orderbook() external view returns (address);
function leaderboard() external view returns (address);
function realitio() external view returns (address);
function getAllMarkets(IRCMarket.Mode _mode)
external
view
returns (address[] memory);
function getMostRecentMarket(IRCMarket.Mode _mode)
external
view
returns (address);
function referenceContractAddress() external view returns (address);
function referenceContractVersion() external view returns (uint256);
function sponsorshipRequired() external view returns (uint256);
function advancedWarning() external view returns (uint32);
function maximumDuration() external view returns (uint32);
function minimumDuration() external view returns (uint32);
function marketCreationGovernorsOnly() external view returns (bool);
function approvedAffiliatesOnly() external view returns (bool);
function approvedArtistsOnly() external view returns (bool);
function arbitrator() external view returns (address);
function timeout() external view returns (uint32);
function cardLimit() external view returns (uint256);
function getPotDistribution() external view returns (uint256[5] memory);
function minimumPriceIncreasePercent() external view returns (uint256);
function nftsToAward() external view returns (uint256);
function isMarketApproved(address) external view returns (bool);
function marketPausedDefaultState() external view returns (bool);
function mintMarketNFT(uint256 _card) external;
function getOracleSettings()
external
view
returns (
IRealitio oracle,
address arbitratorAddress,
uint32 _timeout
);
// only Governors
function changeMarketApproval(address _market) external;
function addArtist(address _newArtist) external;
function removeArtist(address _oldArtist) external;
function addAffiliate(address _newAffiliate) external;
function removeAffiliate(address _oldAffiliate) external;
// only Owner
function setMarketPausedDefaultState(bool _state) external;
function setTimeout(uint32 _newTimeout) external;
function setMaxRentIterations(uint256 _rentLimit, uint256 _rentLimitLocking)
external;
function setArbitrator(address _newAddress) external;
function setRealitioAddress(address _newAddress) external;
function maxRentIterations() external view returns (uint256);
function maxRentIterationsToLockMarket() external view returns (uint256);
function setCardLimit(uint256 _cardLimit) external;
function setMinimumPriceIncreasePercent(uint256 _percentIncrease) external;
function setNumberOfNFTsToAward(uint256 _NFTsToAward) external;
function updateTokenURI(
address _market,
uint256 _cardId,
string calldata _newTokenURI,
string calldata _newCopyTokenURI
) external;
function setPotDistribution(
uint256 _artistCut,
uint256 _winnerCut,
uint256 _creatorCut,
uint256 _affiliateCut,
uint256 _cardAffiliateCut
) external;
function changeMarketCreationGovernorsOnly() external;
function changeApprovedArtistsOnly() external;
function changeApprovedAffiliatesOnly() external;
function setSponsorshipRequired(uint256 _amount) external;
function setMarketTimeRestrictions(
uint32 _newAdvancedWarning,
uint32 _newMinimumDuration,
uint32 _newMaximumDuration
) external;
function setMarketInfoResults(uint256 _results) external;
// only UberOwner
function setReferenceContractAddress(address _newAddress) external;
function setOrderbookAddress(IRCOrderbook _newAddress) external;
function setLeaderboardAddress(IRCLeaderboard _newAddress) external;
function setNftHubAddress(IRCNftHubL2 _newAddress) external;
}
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
interface IRCTreasury {
function setTokenAddress(address _newToken) external;
function grantRole(string memory role, address account) external;
function grantRole(bytes32, address) external;
function revokeRole(string memory role, address account) external;
function revokeRole(bytes32, address) external;
function collectRentUser(address _user, uint256 _timeToCollectTo)
external
returns (uint256 newTimeLastCollectedOnForeclosure);
function topupMarketBalance(uint256 _amount) external;
function assessForeclosure(address _user) external;
// view functions
function foreclosureTimeUser(
address _user,
uint256 _newBid,
uint256 _timeOfNewBid
) external view returns (uint256);
function bridgeAddress() external view returns (address);
function checkPermission(bytes32, address) external view returns (bool);
function erc20() external view returns (IERC20);
function factory() external view returns (IRCFactory);
function orderbook() external view returns (IRCOrderbook);
function leaderboard() external view returns (IRCLeaderboard);
function isForeclosed(address) external view returns (bool);
function userTotalBids(address) external view returns (uint256);
function userDeposit(address) external view returns (uint256);
function totalDeposits() external view returns (uint256);
function marketPot(address) external view returns (uint256);
function totalMarketPots() external view returns (uint256);
function marketBalance() external view returns (uint256);
function marketBalanceTopup() external view returns (uint256);
function minRentalDayDivisor() external view returns (uint256);
function maxContractBalance() external view returns (uint256);
function globalPause() external view returns (bool);
function addMarket(address _market, bool paused) external;
function marketPaused(address) external view returns (bool);
function batchWhitelist(address[] calldata _users, bool add) external;
function marketWhitelistCheck(address _user) external returns (bool);
function lockMarketPaused(address _market) external view returns (bool);
function setBridgeAddress(address _newAddress) external;
function setOrderbookAddress(address _newAddress) external;
function setLeaderboardAddress(address _newAddress) external;
function setFactoryAddress(address _newFactory) external;
function deposit(uint256 _amount, address _user) external returns (bool);
function withdrawDeposit(uint256 _amount, bool _localWithdrawal) external;
function checkSponsorship(address sender, uint256 _amount) external view;
//only orderbook
function increaseBidRate(address _user, uint256 _price) external;
function decreaseBidRate(address _user, uint256 _price) external;
function updateRentalRate(
address _oldOwner,
address _newOwner,
uint256 _oldPrice,
uint256 _newPrice,
uint256 _timeOwnershipChanged
) external;
// only owner
function setMinRental(uint256 _newDivisor) external;
function setMaxContractBalance(uint256) external;
function changeGlobalPause() external;
function changePauseMarket(address _market, bool _paused) external;
function toggleWhitelist() external;
// only factory
function unPauseMarket(address _market) external;
// only markets
function payRent(uint256) external returns (uint256);
function payout(address, uint256) external returns (bool);
function refundUser(address _user, uint256 _refund) external;
function sponsor(address _sponsor, uint256 _amount) external;
function updateLastRentalTime(address) external;
}
interface IRCMarket {
enum States {
CLOSED,
OPEN,
LOCKED,
WITHDRAW
}
enum Mode {
CLASSIC,
WINNER_TAKES_ALL,
SAFE_MODE
}
function getWinnerFromOracle() external;
function setAmicableResolution(uint256 _winningOutcome) external;
function lockMarket() external;
function claimCard(uint256 _card) external;
function rentAllCards(uint256 _maxSumOfPrices) external;
function newRental(
uint256 _newPrice,
uint256 _timeHeldLimit,
address _startingPosition,
uint256 _card
) external;
function updateTimeHeldLimit(uint256 _timeHeldLimit, uint256 _card)
external;
function collectRent(uint256 _cardId) external returns (bool);
function exitAll() external;
function exit(uint256) external;
function sponsor(address _sponsor, uint256 _amount) external;
function sponsor(uint256 _amount) external;
function circuitBreaker() external;
// payouts
function withdraw() external;
function payArtist() external;
function payMarketCreator() external;
function payAffiliate() external;
function payCardAffiliate(uint256) external;
// view functions
function nfthub() external view returns (IRCNftHubL2);
function treasury() external view returns (IRCTreasury);
function factory() external view returns (IRCFactory);
function leaderboard() external view returns (IRCLeaderboard);
function orderbook() external view returns (IRCOrderbook);
function realitio() external view returns (IRealitio);
function mode() external view returns (Mode);
function isMarket() external view returns (bool);
function numberOfCards() external view returns (uint256);
function nftsToAward() external view returns (uint256);
function ownerOf(uint256 tokenId) external view returns (address);
function state() external view returns (States);
function getTokenId(uint256 _card) external view returns (uint256 _tokenId);
function cardAccountingIndex() external view returns (uint256);
function accountingComplete() external view returns (bool);
// prices, deposits, rent
function rentCollectedPerUser(address) external view returns (uint256);
function rentCollectedPerUserPerCard(address, uint256)
external
view
returns (uint256);
function totalRentCollected() external view returns (uint256);
function exitedTimestamp(address) external view returns (uint256);
//parameters
function minimumPriceIncreasePercent() external view returns (uint256);
function minRentalDayDivisor() external view returns (uint256);
function maxRentIterations() external view returns (uint256);
// time
function timeHeld(uint256 _card, address _user)
external
view
returns (uint256);
function timeLastCollected(uint256 _card) external view returns (uint256);
function longestOwner(uint256 _card) external view returns (address);
function marketOpeningTime() external view returns (uint32);
function marketLockingTime() external view returns (uint32);
function oracleResolutionTime() external view returns (uint32);
// payout settings
function winningOutcome() external view returns (uint256);
function userAlreadyWithdrawn(address) external view returns (bool);
function artistAddress() external view returns (address);
function artistCut() external view returns (uint256);
function artistPaid() external view returns (bool);
function affiliateAddress() external view returns (address);
function affiliateCut() external view returns (uint256);
function affiliatePaid() external view returns (bool);
function winnerCut() external view returns (uint256);
function marketCreatorAddress() external view returns (address);
function creatorCut() external view returns (uint256);
function creatorPaid() external view returns (bool);
function cardAffiliateAddresses(uint256) external view returns (address);
function cardAffiliateCut() external view returns (uint256);
// oracle
function questionId() external view returns (bytes32);
function arbitrator() external view returns (address);
function timeout() external view returns (uint32);
function isFinalized() external view returns (bool);
// setup
function initialize(
Mode _mode,
uint32[] calldata _timestamps,
uint256 _numberOfCards,
address _artistAddress,
address _affiliateAddress,
address[] calldata _cardAffiliateAddresses,
address _marketCreatorAddress,
string calldata _realitioQuestion,
uint256 _nftsToAward
) external;
function transferCard(
address _oldOwner,
address _newOwner,
uint256 _token,
uint256 _price,
uint256 _timeLimit
) external;
}
interface IRCOrderbook {
struct Bid {
address market;
address next;
address prev;
uint64 card;
uint128 price;
uint64 timeHeldLimit;
}
function index(
address _market,
address _user,
uint256 _token
) external view returns (uint256);
function ownerOf(address, uint256) external view returns (address);
function closedMarkets(uint256) external view returns (address);
function userClosedMarketIndex(address) external view returns (uint256);
function treasury() external view returns (IRCTreasury);
function maxSearchIterations() external view returns (uint256);
function maxDeletions() external view returns (uint256);
function cleaningLoops() external view returns (uint256);
function marketCloseLimit() external view returns (uint256);
function nonce() external view returns (uint256);
function cleanWastePile() external;
function getBid(
address _market,
address _user,
uint256 _card
) external view returns (Bid memory);
function setTreasuryAddress(address _newTreasury) external;
function addBidToOrderbook(
address _user,
uint256 _token,
uint256 _price,
uint256 _timeHeldLimit,
address _prevUserAddress
) external;
function removeBidFromOrderbook(address _user, uint256 _token) external;
function closeMarket() external returns (bool);
function findNewOwner(uint256 _token, uint256 _timeOwnershipChanged)
external;
function getBidValue(address _user, uint256 _token)
external
view
returns (uint256);
function getTimeHeldlimit(address _user, uint256 _token)
external
returns (uint256);
function bidExists(
address _user,
address _market,
uint256 _card
) external view returns (bool);
function setTimeHeldlimit(
address _user,
uint256 _token,
uint256 _timeHeldLimit
) external;
function removeUserFromOrderbook(address _user) external;
function removeOldBids(address _user) external;
function reduceTimeHeldLimit(
address _user,
uint256 _token,
uint256 _timeToReduce
) external;
function setDeletionLimit(uint256 _deletionLimit) external;
function setCleaningLimit(uint256 _cleaningLimit) external;
function setSearchLimit(uint256 _searchLimit) external;
function setMarketCloseLimit(uint256 _marketCloseLimit) external;
}
interface IRCLeaderboard {
function treasury() external view returns (IRCTreasury);
function market() external view returns (IRCMarket);
function NFTsToAward(address _market) external view returns (uint256);
function updateLeaderboard(
address _user,
uint256 _card,
uint256 _timeHeld
) external;
function claimNFT(address _user, uint256 _card) external;
}
interface IRealitio {
function askQuestion(
uint256 template_id,
string calldata question,
address arbitrator,
uint32 timeout,
uint32 opening_ts,
uint256 nonce
) external payable returns (bytes32);
function resultFor(bytes32 question_id) external view returns (bytes32);
function isFinalized(bytes32 question_id) external view returns (bool);
function getContentHash(bytes32 question_id)
external
view
returns (bytes32);
}
interface IRCNftHubL2 {
function marketTracker(uint256) external view returns (address);
function ownerOf(uint256) external view returns (address);
function tokenURI(uint256) external view returns (string memory);
function addMarket(address) external;
function totalSupply() external view returns (uint256 nftCount);
function mint(
address,
uint256,
string calldata
) external;
function transferNft(
address,
address,
uint256
) external;
function deposit(address user, bytes calldata depositData) external;
function withdraw(uint256 tokenId) external;
function withdrawWithMetadata(uint256 tokenId) external;
}