-
Notifications
You must be signed in to change notification settings - Fork 7
/
ConfigHandlerFacet.sol
768 lines (693 loc) · 28.9 KB
/
ConfigHandlerFacet.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
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity 0.8.9;
import "../../domain/BosonConstants.sol";
import { IBosonConfigHandler } from "../../interfaces/handlers/IBosonConfigHandler.sol";
import { IAccessControlUpgradeable } from "../../interfaces/IAccessControlUpgradeable.sol";
import { DiamondLib } from "../../diamond/DiamondLib.sol";
import { ProtocolBase } from "../bases/ProtocolBase.sol";
import { ProtocolLib } from "../libs/ProtocolLib.sol";
import { EIP712Lib } from "../libs/EIP712Lib.sol";
/**
* @title ConfigHandlerFacet
*
* @notice Handles management and queries of various protocol-related settings
*/
contract ConfigHandlerFacet is IBosonConfigHandler, ProtocolBase {
/**
* @notice Initializes facet.
* This function is callable only once.
*
* @param _addresses - struct of Boson Protocol addresses (Boson Token (ERC-20) contract, treasury, and Voucher contract)
* @param _limits - struct with Boson Protocol limits
* @param _fees - struct of Boson Protocol fees
*/
function initialize(
ProtocolLib.ProtocolAddresses calldata _addresses,
ProtocolLib.ProtocolLimits calldata _limits,
ProtocolLib.ProtocolFees calldata _fees,
uint16 _buyerEscalationDepositPercentage
) public onlyUnInitialized(type(IBosonConfigHandler).interfaceId) {
// Register supported interfaces
DiamondLib.addSupportedInterface(type(IBosonConfigHandler).interfaceId);
// Initialize protocol config params
setTokenAddress(_addresses.token);
setTreasuryAddress(_addresses.treasury);
setVoucherBeaconAddress(_addresses.voucherBeacon);
setBeaconProxyAddress(_addresses.beaconProxy);
setProtocolFeePercentage(_fees.percentage);
setProtocolFeeFlatBoson(_fees.flatBoson);
setMaxExchangesPerBatch(_limits.maxExchangesPerBatch);
setMaxOffersPerGroup(_limits.maxOffersPerGroup);
setMaxTwinsPerBundle(_limits.maxTwinsPerBundle);
setMaxOffersPerBundle(_limits.maxOffersPerBundle);
setMaxOffersPerBatch(_limits.maxOffersPerBatch);
setMaxTokensPerWithdrawal(_limits.maxTokensPerWithdrawal);
setMaxFeesPerDisputeResolver(_limits.maxFeesPerDisputeResolver);
setMaxEscalationResponsePeriod(_limits.maxEscalationResponsePeriod);
setMaxDisputesPerBatch(_limits.maxDisputesPerBatch);
setMaxAllowedSellers(_limits.maxAllowedSellers);
setBuyerEscalationDepositPercentage(_buyerEscalationDepositPercentage);
setMaxTotalOfferFeePercentage(_limits.maxTotalOfferFeePercentage);
setMaxRoyaltyPecentage(_limits.maxRoyaltyPecentage);
setMaxResolutionPeriod(_limits.maxResolutionPeriod);
setMinFulfillmentPeriod(_limits.minFulfillmentPeriod);
// Initialize protocol counters
ProtocolLib.ProtocolCounters storage pc = protocolCounters();
pc.nextAccountId = 1;
pc.nextBundleId = 1;
pc.nextExchangeId = 1;
pc.nextGroupId = 1;
pc.nextOfferId = 1;
pc.nextTwinId = 1;
// Initialize reentrancyStatus
protocolStatus().reentrancyStatus = NOT_ENTERED;
// Initialize protocol meta-transaction config params
ProtocolLib.ProtocolMetaTxInfo storage pmti = protocolMetaTxInfo();
pmti.domainSeparator = EIP712Lib.buildDomainSeparator(PROTOCOL_NAME, PROTOCOL_VERSION);
pmti.cachedChainId = block.chainid;
}
/**
* @notice Sets the Boson Token (ERC-20 contract) address.
*
* Emits a TokenAddressChanged event.
*
* Reverts if _tokenAddress is the zero address
*
* @dev Caller must have ADMIN role.
*
* @param _tokenAddress - the Boson Token (ERC-20 contract) address
*/
function setTokenAddress(address payable _tokenAddress) public override onlyRole(ADMIN) nonReentrant {
require(_tokenAddress != address(0), INVALID_ADDRESS);
protocolAddresses().token = _tokenAddress;
emit TokenAddressChanged(_tokenAddress, msgSender());
}
/**
* @notice Gets the Boson Token (ERC-20 contract) address.
*
* @return the Boson Token (ERC-20 contract) address
*/
function getTokenAddress() external view override returns (address payable) {
return protocolAddresses().token;
}
/**
* @notice Sets the Boson Protocol multi-sig wallet address.
*
* Emits a TreasuryAddressChanged event.
*
* Reverts if _treasuryAddress is the zero address
*
* @dev Caller must have ADMIN role.
*
* @param _treasuryAddress - the the multi-sig wallet address
*/
function setTreasuryAddress(address payable _treasuryAddress) public override onlyRole(ADMIN) nonReentrant {
require(_treasuryAddress != address(0), INVALID_ADDRESS);
protocolAddresses().treasury = _treasuryAddress;
emit TreasuryAddressChanged(_treasuryAddress, msgSender());
}
/**
* @notice Gets the Boson Protocol multi-sig wallet address.
*
* @return the Boson Protocol multi-sig wallet address
*/
function getTreasuryAddress() external view override returns (address payable) {
return protocolAddresses().treasury;
}
/**
* @notice Sets the Boson Voucher beacon contract address.
*
* Emits a VoucherBeaconAddressChanged event.
*
* Reverts if _voucherBeaconAddress is the zero address
*
* @dev Caller must have ADMIN role.
*
* @param _voucherBeaconAddress - the Boson Voucher beacon contract address
*/
function setVoucherBeaconAddress(address _voucherBeaconAddress) public override onlyRole(ADMIN) nonReentrant {
require(_voucherBeaconAddress != address(0), INVALID_ADDRESS);
protocolAddresses().voucherBeacon = _voucherBeaconAddress;
emit VoucherBeaconAddressChanged(_voucherBeaconAddress, msgSender());
}
/**
* @notice Gets the Boson Voucher beacon contract address.
*
* @return the Boson Voucher beacon contract address
*/
function getVoucherBeaconAddress() external view override returns (address) {
return protocolAddresses().voucherBeacon;
}
/**
* @notice Sets the Boson Voucher reference proxy implementation address.
*
* Emits a BeaconProxyAddressChanged event.
*
* Reverts if _beaconProxyAddress is the zero address
*
* @dev Caller must have ADMIN role.
*
* @param _beaconProxyAddress - reference proxy implementation address
*/
function setBeaconProxyAddress(address _beaconProxyAddress) public override onlyRole(ADMIN) nonReentrant {
require(_beaconProxyAddress != address(0), INVALID_ADDRESS);
protocolAddresses().beaconProxy = _beaconProxyAddress;
emit BeaconProxyAddressChanged(_beaconProxyAddress, msgSender());
}
/**
* @notice Gets the beaconProxy address.
*
* @return the beaconProxy address
*/
function getBeaconProxyAddress() external view override returns (address) {
return protocolAddresses().beaconProxy;
}
/**
* @notice Sets the protocol fee percentage.
*
* Emits a ProtocolFeePercentageChanged event.
*
* Reverts if the _protocolFeePercentage is greater than 10000.
*
* @dev Caller must have ADMIN role.
*
* @param _protocolFeePercentage - the percentage that will be taken as a fee from the net of a Boson Protocol sale or auction (after royalties)
*
* N.B. Represent percentage value as an unsigned int by multiplying the percentage by 100:
* e.g, 1.75% = 175, 100% = 10000
*/
function setProtocolFeePercentage(uint16 _protocolFeePercentage) public override onlyRole(ADMIN) nonReentrant {
// Make sure percentage is less than 10000
require(_protocolFeePercentage <= 10000, FEE_PERCENTAGE_INVALID);
// Store fee percentage
protocolFees().percentage = _protocolFeePercentage;
// Notify watchers of state change
emit ProtocolFeePercentageChanged(_protocolFeePercentage, msgSender());
}
/**
* @notice Gets the protocol fee percentage.
*
* @return the protocol fee percentage
*/
function getProtocolFeePercentage() external view override returns (uint16) {
return protocolFees().percentage;
}
/**
* @notice Sets the flat protocol fee for exchanges in $BOSON.
*
* Emits a ProtocolFeeFlatBosonChanged event.
*
* @dev Caller must have ADMIN role.
*
* @param _protocolFeeFlatBoson - the flat fee taken for exchanges in $BOSON
*
*/
function setProtocolFeeFlatBoson(uint256 _protocolFeeFlatBoson) public override onlyRole(ADMIN) nonReentrant {
// Store fee percentage
protocolFees().flatBoson = _protocolFeeFlatBoson;
// Notify watchers of state change
emit ProtocolFeeFlatBosonChanged(_protocolFeeFlatBoson, msgSender());
}
/**
* @notice Getsthe flat protocol fee for exchanges in $BOSON.
*
* @return the flat fee taken for exchanges in $BOSON
*/
function getProtocolFeeFlatBoson() external view override returns (uint256) {
return protocolFees().flatBoson;
}
/**
* @notice Sets the maximum numbers of offers that can be added to a group in a single transaction.
*
* Emits a MaxOffersPerGroupChanged event.
*
* Reverts if the _maxOffersPerGroup is zero.
*
* @dev Caller must have ADMIN role.
*
* @param _maxOffersPerGroup - the maximum length of {BosonTypes.Group.offerIds}
*/
function setMaxOffersPerGroup(uint16 _maxOffersPerGroup) public override onlyRole(ADMIN) nonReentrant {
// Make sure _maxOffersPerGroup is greater than 0
checkNonZero(_maxOffersPerGroup);
protocolLimits().maxOffersPerGroup = _maxOffersPerGroup;
emit MaxOffersPerGroupChanged(_maxOffersPerGroup, msgSender());
}
/**
* @notice Gets the maximum numbers of offers that can be added to a group in a single transaction.
*
* @return the maximum numbers of offers that can be added to a group in a single transaction
*/
function getMaxOffersPerGroup() external view override returns (uint16) {
return protocolLimits().maxOffersPerGroup;
}
/**
* @notice Sets the maximum numbers of twins that can be added to a bundle in a single transaction.
*
* Emits a MaxTwinsPerBundleChanged event.
*
* Reverts if the _maxTwinsPerBundle is zero.
*
* @dev Caller must have ADMIN role.
*
* @param _maxTwinsPerBundle - the maximum length of {BosonTypes.Bundle.twinIds}
*/
function setMaxTwinsPerBundle(uint16 _maxTwinsPerBundle) public override onlyRole(ADMIN) nonReentrant {
// Make sure _maxTwinsPerBundle is greater than 0
checkNonZero(_maxTwinsPerBundle);
protocolLimits().maxTwinsPerBundle = _maxTwinsPerBundle;
emit MaxTwinsPerBundleChanged(_maxTwinsPerBundle, msgSender());
}
/**
* @notice Gets the maximum numbers of twins that can be added to a bundle in a single transaction.
*
* @return the maximum numbers of twins that can be added to a bundle in a single transaction.
*/
function getMaxTwinsPerBundle() external view override returns (uint16) {
return protocolLimits().maxTwinsPerBundle;
}
/**
* @notice Sets the maximum numbers of offers that can be added to a bundle in a single transaction.
*
* Emits a MaxOffersPerBundleChanged event.
*
* Reverts if the _maxOffersPerBundle is zero.
*
* @dev Caller must have ADMIN role.
*
* @param _maxOffersPerBundle - the maximum length of {BosonTypes.Bundle.offerIds}
*/
function setMaxOffersPerBundle(uint16 _maxOffersPerBundle) public override onlyRole(ADMIN) nonReentrant {
// Make sure _maxOffersPerBundle is greater than 0
checkNonZero(_maxOffersPerBundle);
protocolLimits().maxOffersPerBundle = _maxOffersPerBundle;
emit MaxOffersPerBundleChanged(_maxOffersPerBundle, msgSender());
}
/**
* @notice Gets the maximum numbers of offers that can be added to a bundle in a single transaction.
*
* @return the maximum numbers of offers that can be added to a bundle in a single transaction
*/
function getMaxOffersPerBundle() external view override returns (uint16) {
return protocolLimits().maxOffersPerBundle;
}
/**
* @notice Sets the maximum numbers of offers that can be created in a single transaction.
*
* Emits a MaxOffersPerBatchChanged event.
*
* Reverts if the _maxOffersPerBatch is zero.
*
* @dev Caller must have ADMIN role.
*
* @param _maxOffersPerBatch - the maximum length of {BosonTypes.Offer[]}
*/
function setMaxOffersPerBatch(uint16 _maxOffersPerBatch) public override onlyRole(ADMIN) nonReentrant {
// Make sure _maxOffersPerBatch is greater than 0
checkNonZero(_maxOffersPerBatch);
protocolLimits().maxOffersPerBatch = _maxOffersPerBatch;
emit MaxOffersPerBatchChanged(_maxOffersPerBatch, msgSender());
}
/**
* @notice Gets the maximum numbers of offers that can be created in a single transaction.
*
* @return the maximum numbers of offers that can be created in a single transaction
*/
function getMaxOffersPerBatch() external view override returns (uint16) {
return protocolLimits().maxOffersPerBatch;
}
/**
* @notice Sets the maximum numbers of tokens that can be withdrawn in a single transaction.
*
* Emits a MaxTokensPerWithdrawalChanged event.
*
* Reverts if the _maxTokensPerWithdrawal is zero.
*
* @dev Caller must have ADMIN role.
*
* @param _maxTokensPerWithdrawal - the maximum length of token list when calling {FundsHandlerFacet.withdraw}
*/
function setMaxTokensPerWithdrawal(uint16 _maxTokensPerWithdrawal) public override onlyRole(ADMIN) nonReentrant {
// Make sure _maxTokensPerWithdrawal is greater than 0
checkNonZero(_maxTokensPerWithdrawal);
protocolLimits().maxTokensPerWithdrawal = _maxTokensPerWithdrawal;
emit MaxTokensPerWithdrawalChanged(_maxTokensPerWithdrawal, msgSender());
}
/**
* @notice Gets the maximum numbers of tokens that can be withdrawn in a single transaction.
*
* @return the maximum length of token list when calling {FundsHandlerFacet.withdraw}
*/
function getMaxTokensPerWithdrawal() external view override returns (uint16) {
return protocolLimits().maxTokensPerWithdrawal;
}
/**
* @notice Sets the maximum number of dispute resolver fee structs that can be processed in a single transaction.
*
* Emits a MaxFeesPerDisputeResolverChanged event.
*
* Reverts if the _maxFeesPerDisputeResolver is zero.
*
* @dev Caller must have ADMIN role.
*
* @param _maxFeesPerDisputeResolver - the maximum length of dispute resolver fees list when calling {AccountHandlerFacet.createDisputeResolver} or {AccountHandlerFacet.updateDisputeResolver}
*/
function setMaxFeesPerDisputeResolver(uint16 _maxFeesPerDisputeResolver)
public
override
onlyRole(ADMIN)
nonReentrant
{
// Make sure _maxFeesPerDisputeResolver is greater than 0
checkNonZero(_maxFeesPerDisputeResolver);
protocolLimits().maxFeesPerDisputeResolver = _maxFeesPerDisputeResolver;
emit MaxFeesPerDisputeResolverChanged(_maxFeesPerDisputeResolver, msgSender());
}
/**
* @notice Gets the maximum number of dispute resolver fee structs that can be processed in a single transaction.
*
* @return the maximum number of dispute resolver fee structs that can be processed in a single transaction
*/
function getMaxFeesPerDisputeResolver() external view override returns (uint16) {
return protocolLimits().maxFeesPerDisputeResolver;
}
/**
* @notice Sets the maximum escalation response period a dispute resolver can specify.
*
* Emits a MaxEscalationResponsePeriodChanged event.
*
* Reverts if the _maxEscalationResponsePeriod is zero.
*
* @dev Caller must have ADMIN role.
*
* @param _maxEscalationResponsePeriod - the maximum escalation response period that a {BosonTypes.DisputeResolver} can specify
*/
function setMaxEscalationResponsePeriod(uint256 _maxEscalationResponsePeriod)
public
override
onlyRole(ADMIN)
nonReentrant
{
// Make sure _maxEscalationResponsePeriod is greater than 0
checkNonZero(_maxEscalationResponsePeriod);
protocolLimits().maxEscalationResponsePeriod = _maxEscalationResponsePeriod;
emit MaxEscalationResponsePeriodChanged(_maxEscalationResponsePeriod, msgSender());
}
/**
* @notice Gets the maximum escalation response period a dispute resolver can specify.
*
* @return the maximum escalation response period that a {BosonTypes.DisputeResolver} can specify
*/
function getMaxEscalationResponsePeriod() external view override returns (uint256) {
return protocolLimits().maxEscalationResponsePeriod;
}
/**
* @notice Sets the maximum number of disputes that can be expired in a single transaction.
*
* Emits a MaxDisputesPerBatchChanged event.
*
* @dev Caller must have ADMIN role.
*
* @param _maxDisputesPerBatch - the maximum number of disputes that can be expired
*/
function setMaxDisputesPerBatch(uint16 _maxDisputesPerBatch) public override onlyRole(ADMIN) nonReentrant {
// Make sure _maxDisputesPerBatch is greater than 0
checkNonZero(_maxDisputesPerBatch);
protocolLimits().maxDisputesPerBatch = _maxDisputesPerBatch;
emit MaxDisputesPerBatchChanged(_maxDisputesPerBatch, msgSender());
}
/**
* @notice Gets the maximum number of disputes that can be expired in a single transaction.
*
* @return the maximum number of disputes that can be expired
*/
function getMaxDisputesPerBatch() external view override returns (uint16) {
return protocolLimits().maxDisputesPerBatch;
}
/**
* @notice Sets the total offer fee percentage limit which will validate the sum of (Protocol Fee percentage + Agent Fee percentage) of an offer fee.
*
* Emits a MaxTotalOfferFeePercentageChanged event.
*
* Reverts if _maxTotalOfferFeePercentage is greater than 10000.
*
* @dev Caller must have ADMIN role.
*
* @param _maxTotalOfferFeePercentage - the maximum total offer fee percentage
*
* N.B. Represent percentage value as an unsigned int by multiplying the percentage by 100:
* e.g, 1.75% = 175, 100% = 10000
*/
function setMaxTotalOfferFeePercentage(uint16 _maxTotalOfferFeePercentage)
public
override
onlyRole(ADMIN)
nonReentrant
{
// Make sure percentage is less than 10000
require(_maxTotalOfferFeePercentage <= 10000, FEE_PERCENTAGE_INVALID);
// Store fee percentage
protocolLimits().maxTotalOfferFeePercentage = _maxTotalOfferFeePercentage;
// Notify watchers of state change
emit MaxTotalOfferFeePercentageChanged(_maxTotalOfferFeePercentage, msgSender());
}
/**
* @notice Gets the total offer fee percentage limit which will validate the sum of (Protocol Fee percentage + Agent Fee percentage) of an offer fee.
*
* @return the maximum total offer fee percentage
*/
function getMaxTotalOfferFeePercentage() external view override returns (uint16) {
return protocolLimits().maxTotalOfferFeePercentage;
}
/**
* @notice Sets the maximum royalty percentage that can be set by the seller.
*
* Emits a MaxRoyaltyPercentageChanged event.
*
* Reverts if:
* - The _maxRoyaltyPercentage is zero.
* - The _maxRoyaltyPecentage is greater than 10000.
*
* @dev Caller must have ADMIN role.
*
* @param _maxRoyaltyPecentage - the maximum royalty percentage
*
* N.B. Represent percentage value as an unsigned int by multiplying the percentage by 100:
* e.g, 1.75% = 175, 100% = 10000
*/
function setMaxRoyaltyPecentage(uint16 _maxRoyaltyPecentage) public override onlyRole(ADMIN) nonReentrant {
// Make sure percentage is greater than 0
checkNonZero(_maxRoyaltyPecentage);
// Make sure percentage is less than 10000
require(_maxRoyaltyPecentage <= 10000, FEE_PERCENTAGE_INVALID);
// Store fee percentage
protocolLimits().maxRoyaltyPecentage = _maxRoyaltyPecentage;
// Notify watchers of state change
emit MaxRoyaltyPercentageChanged(_maxRoyaltyPecentage, msgSender());
}
/**
* @notice Gets the maximum royalty percentage that can be set by the seller.
*
* @return the maximum royalty percentage
*/
function getMaxRoyaltyPecentage() external view override returns (uint16) {
return protocolLimits().maxRoyaltyPecentage;
}
/**
* @notice Sets the maximum number of seller ids that can be added to or removed from dispute resolver seller allow list in a single transaction.
*
* Emits a MaxAllowedSellersChanged event.
*
* Reverts if the _maxAllowedSellers is zero.
*
* @dev Caller must have ADMIN role.
*
* @param _maxAllowedSellers - the maximum number of seller ids that can be added or removed
*/
function setMaxAllowedSellers(uint16 _maxAllowedSellers) public override onlyRole(ADMIN) nonReentrant {
// Make sure _maxAllowedSellers greater than 0
checkNonZero(_maxAllowedSellers);
protocolLimits().maxAllowedSellers = _maxAllowedSellers;
emit MaxAllowedSellersChanged(_maxAllowedSellers, msgSender());
}
/**
* @notice Gets the maximum number of seller ids that can be added to or removed from dispute resolver seller allow list in a single transaction.
*
* @return the maximum number of seller ids that can be added or removed
*/
function getMaxAllowedSellers() external view override returns (uint16) {
return protocolLimits().maxAllowedSellers;
}
/**
* @notice Sets the buyer escalation fee percentage.
*
* Emits a BuyerEscalationFeePercentageChanged event.
*
* Reverts if the _buyerEscalationDepositPercentage is greater than 10000.
*
* @dev Caller must have ADMIN role.
*
* @param _buyerEscalationDepositPercentage - the percentage of the DR fee that will be charged to buyer if they want to escalate the dispute
*
* N.B. Represent percentage value as an unsigned int by multiplying the percentage by 100:
* e.g, 1.75% = 175, 100% = 10000
*/
function setBuyerEscalationDepositPercentage(uint16 _buyerEscalationDepositPercentage)
public
override
onlyRole(ADMIN)
nonReentrant
{
// Make sure percentage is less than 10000
require(_buyerEscalationDepositPercentage <= 10000, FEE_PERCENTAGE_INVALID);
// Store fee percentage
protocolLookups().buyerEscalationDepositPercentage = _buyerEscalationDepositPercentage;
// Notify watchers of state change
emit BuyerEscalationFeePercentageChanged(_buyerEscalationDepositPercentage, msgSender());
}
/**
* @notice Gets the buyer escalation fee percentage.
*
* @return the percentage of the DR fee that will be charged to buyer if they want to escalate the dispute
*/
function getBuyerEscalationDepositPercentage() external view override returns (uint16) {
return protocolLookups().buyerEscalationDepositPercentage;
}
/**
* @notice Sets the contract address for the given AuthTokenType.
*
* Emits an AuthTokenContractChanged event.
*
* Reverts if:
* - _authTokenType is None.
* - _authTokenContract is the zero address.
*
* @dev Caller must have ADMIN role.
*
* @param _authTokenType - the auth token type, as an Enum value
* @param _authTokenContract the address of the auth token contract (e.g. Lens or ENS contract address)
*/
function setAuthTokenContract(AuthTokenType _authTokenType, address _authTokenContract)
external
override
onlyRole(ADMIN)
nonReentrant
{
require(_authTokenType != AuthTokenType.None, INVALID_AUTH_TOKEN_TYPE);
require(_authTokenContract != address(0), INVALID_ADDRESS);
protocolLookups().authTokenContracts[_authTokenType] = _authTokenContract;
emit AuthTokenContractChanged(_authTokenType, _authTokenContract, msgSender());
}
/**
* @notice Gets the contract address for the given AuthTokenType.
*
* @param _authTokenType - the auth token type, as an Enum value
* @return the address of the auth token contract (e.g. Lens or ENS contract address) for the given AuthTokenType
*/
function getAuthTokenContract(AuthTokenType _authTokenType) external view returns (address) {
return protocolLookups().authTokenContracts[_authTokenType];
}
/**
* @notice Sets the maximum number of exchanges that can be created in a single transaction.
*
* Emits a MaxExchangesPerBatchChanged event.
*
* Reverts if the _maxExchangesPerBatch is zero.
*
* @dev Caller must have ADMIN role.
*
* @param _maxExchangesPerBatch - the maximum length of {BosonTypes.Exchange[]}
*/
function setMaxExchangesPerBatch(uint16 _maxExchangesPerBatch) public override onlyRole(ADMIN) nonReentrant {
// Make sure _maxExchangePerBatch is greater than 0
checkNonZero(_maxExchangesPerBatch);
protocolLimits().maxExchangesPerBatch = _maxExchangesPerBatch;
emit MaxExchangesPerBatchChanged(_maxExchangesPerBatch, msgSender());
}
/**
* @notice Gets the maximum number of exchanges that can be created in a single transaction.
*
* @return the maximum length of {BosonTypes.Exchange[]}
*/
function getMaxExchangesPerBatch() external view override returns (uint16) {
return protocolLimits().maxExchangesPerBatch;
}
/**
* @notice Sets the maximum resolution period a seller can specify.
*
* Emits a MaxResolutionPeriodChanged event.
*
* Reverts if the _maxResolutionPeriod is zero.
*
* @dev Caller must have ADMIN role.
*
* @param _maxResolutionPeriod - the maximum resolution period that a {BosonTypes.Seller} can specify
*/
function setMaxResolutionPeriod(uint256 _maxResolutionPeriod) public override onlyRole(ADMIN) nonReentrant {
// Make sure _maxResolutionPeriod is greater than 0
checkNonZero(_maxResolutionPeriod);
protocolLimits().maxResolutionPeriod = _maxResolutionPeriod;
emit MaxResolutionPeriodChanged(_maxResolutionPeriod, msgSender());
}
/**
* @notice Gets the maximum resolution period a seller can specify.
*
* @return the maximum resolution period that a {BosonTypes.Seller} can specify
*/
function getMaxResolutionPeriod() external view override returns (uint256) {
return protocolLimits().maxResolutionPeriod;
}
/**
* @notice Sets the minimum fulfillment period a seller can specify.
*
* Emits a MinFulfillmentPeriodChanged event.
*
* Reverts if the _minFulfillmentPeriod is zero.
*
* @param _minFulfillmentPeriod - the minimum resolution period that a {BosonTypes.Seller} can specify
*/
function setMinFulfillmentPeriod(uint256 _minFulfillmentPeriod) public override onlyRole(ADMIN) nonReentrant {
// Make sure _minFulfillmentPeriod is greater than 0
checkNonZero(_minFulfillmentPeriod);
protocolLimits().minFulfillmentPeriod = _minFulfillmentPeriod;
emit MinFulfillmentPeriodChanged(_minFulfillmentPeriod, msgSender());
}
/**
* @notice Gets the minimum fulfillment period a seller can specify.
*/
function getMinFulfillmentPeriod() external view override returns (uint256) {
return protocolLimits().minFulfillmentPeriod;
}
/**
* @notice Sets the access controller address.
*
* Emits an AccessControllerAddressChanged event.
*
* Reverts if _accessControllerAddress is the zero address
*
* @dev Caller must have ADMIN role.
*
* @param _accessControllerAddress - access controller address
*/
function setAccessControllerAddress(address _accessControllerAddress)
external
override
onlyRole(ADMIN)
nonReentrant
{
require(_accessControllerAddress != address(0), INVALID_ADDRESS);
DiamondLib.diamondStorage().accessController = IAccessControlUpgradeable(_accessControllerAddress);
emit AccessControllerAddressChanged(_accessControllerAddress, msgSender());
}
/**
* @notice Gets the access controller address.
*
* @return the access controller address
*/
function getAccessControllerAddress() external view returns (address) {
return address(DiamondLib.diamondStorage().accessController);
}
function checkNonZero(uint256 _value) internal pure {
require(_value != 0, VALUE_ZERO_NOT_ALLOWED);
}
}