@@ -73,11 +73,12 @@ contract Payer is
73
73
}
74
74
75
75
// keccak256(abi.encode(uint256(keccak256("xmtp.storage.Payer")) - 1)) & ~bytes32(uint256(0xff))
76
- bytes32 internal constant PayerStorageLocation = 0xd0335f337c570f3417b0f0d20340c88da711d60e810b5e9b3ecabe9ccfcdce5a ;
76
+ bytes32 internal constant PAYER_STORAGE_LOCATION = 0xd0335f337c570f3417b0f0d20340c88da711d60e810b5e9b3ecabe9ccfcdce5a ;
77
77
78
78
function _getPayerStorage () internal pure returns (PayerStorage storage $) {
79
+ // slither-disable-next-line assembly
79
80
assembly {
80
- $.slot := PayerStorageLocation
81
+ $.slot := PAYER_STORAGE_LOCATION
81
82
}
82
83
}
83
84
@@ -116,13 +117,13 @@ contract Payer is
116
117
117
118
/**
118
119
* @notice Initializes the contract with the deployer as admin.
119
- * @param _initialAdmin The address of the admin.
120
+ * @param initialAdmin The address of the admin.
120
121
* @dev There's a chicken-egg problem here with PayerReport and Distribution contracts.
121
122
* We need to deploy these contracts first, then set their addresses
122
123
* in the Payer contract.
123
124
*/
124
- function initialize (address _initialAdmin , address _usdcToken , address _nodesContract ) public initializer {
125
- if (_initialAdmin == address (0 ) || _usdcToken == address (0 ) || _nodesContract == address (0 )) {
125
+ function initialize (address initialAdmin , address usdcToken , address nodesContract ) public initializer {
126
+ if (initialAdmin == address (0 ) || usdcToken == address (0 ) || nodesContract == address (0 )) {
126
127
revert InvalidAddress ();
127
128
}
128
129
@@ -138,11 +139,11 @@ contract Payer is
138
139
$.maxTolerableDebtAmountMicroDollars = DEFAULT_MAX_TOLERABLE_DEBT_AMOUNT_MICRO_DOLLARS;
139
140
$.transferFeesPeriod = DEFAULT_MINIMUM_TRANSFER_FEES_PERIOD;
140
141
141
- _setUsdcTokenContract (_usdcToken );
142
- _setNodesContract (_nodesContract );
142
+ _setUsdcTokenContract (usdcToken );
143
+ _setNodesContract (nodesContract );
143
144
144
- require (_grantRole (DEFAULT_ADMIN_ROLE, _initialAdmin ), FailedToGrantRole (DEFAULT_ADMIN_ROLE, _initialAdmin ));
145
- require (_grantRole (ADMIN_ROLE, _initialAdmin ), FailedToGrantRole (ADMIN_ROLE, _initialAdmin ));
145
+ require (_grantRole (DEFAULT_ADMIN_ROLE, initialAdmin ), FailedToGrantRole (DEFAULT_ADMIN_ROLE, initialAdmin ));
146
+ require (_grantRole (ADMIN_ROLE, initialAdmin ), FailedToGrantRole (ADMIN_ROLE, initialAdmin ));
146
147
}
147
148
148
149
/* ============ Payers Management ============ */
@@ -394,7 +395,12 @@ contract Payer is
394
395
function transferFeesToDistribution () external whenNotPaused nonReentrant {
395
396
PayerStorage storage $ = _getPayerStorage ();
396
397
398
+ /// @dev slither marks this as a security issue because validators can modify block.timestamp.
399
+ /// However, in this scenario it's fine, as we'd just send fees a earlier than expected.
400
+ /// It would be a bigger issue if we'd rely on timestamp for randomness or calculations.
401
+ // slither-disable-next-line timestamp
397
402
require (block .timestamp - $.lastFeeTransferTimestamp >= $.transferFeesPeriod, InsufficientTimePassed ());
403
+
398
404
require ($.pendingFees > 0 , InsufficientAmount ());
399
405
400
406
uint256 feesToTransfer = $.pendingFees;
@@ -413,105 +419,104 @@ contract Payer is
413
419
/**
414
420
* @inheritdoc IPayer
415
421
*/
416
- function setDistributionContract (address _newDistributionContract ) external onlyRole (ADMIN_ROLE) {
417
- _setDistributionContract (_newDistributionContract );
422
+ function setDistributionContract (address newDistributionContract ) external onlyRole (ADMIN_ROLE) {
423
+ _setDistributionContract (newDistributionContract );
418
424
}
419
425
420
426
/**
421
427
* @inheritdoc IPayer
422
428
*/
423
- function setPayerReportContract (address _newPayerReportContract ) external onlyRole (ADMIN_ROLE) {
424
- _setPayerReportContract (_newPayerReportContract );
429
+ function setPayerReportContract (address newPayerReportContract ) external onlyRole (ADMIN_ROLE) {
430
+ _setPayerReportContract (newPayerReportContract );
425
431
}
426
432
427
433
/**
428
434
* @inheritdoc IPayer
429
435
*/
430
- function setNodesContract (address _newNodesContract ) external onlyRole (ADMIN_ROLE) {
431
- _setNodesContract (_newNodesContract );
436
+ function setNodesContract (address newNodesContract ) external onlyRole (ADMIN_ROLE) {
437
+ _setNodesContract (newNodesContract );
432
438
}
433
439
434
440
/**
435
441
* @inheritdoc IPayer
436
442
*/
437
- function setUsdcToken (address _newUsdcToken ) external onlyRole (ADMIN_ROLE) {
438
- _setUsdcTokenContract (_newUsdcToken );
443
+ function setUsdcToken (address newUsdcToken ) external onlyRole (ADMIN_ROLE) {
444
+ _setUsdcTokenContract (newUsdcToken );
439
445
}
440
446
441
447
/**
442
448
* @inheritdoc IPayer
443
449
*/
444
- function setMinimumDeposit (uint64 _newMinimumDeposit ) external onlyRole (ADMIN_ROLE) {
445
- require (_newMinimumDeposit > DEFAULT_MINIMUM_DEPOSIT_AMOUNT_MICRO_DOLLARS, InvalidMinimumDeposit ());
450
+ function setMinimumDeposit (uint64 newMinimumDeposit ) external onlyRole (ADMIN_ROLE) {
451
+ require (newMinimumDeposit > DEFAULT_MINIMUM_DEPOSIT_AMOUNT_MICRO_DOLLARS, InvalidMinimumDeposit ());
446
452
447
453
PayerStorage storage $ = _getPayerStorage ();
448
454
449
455
uint256 oldMinimumDeposit = $.minimumDepositAmountMicroDollars;
450
- $.minimumDepositAmountMicroDollars = _newMinimumDeposit ;
456
+ $.minimumDepositAmountMicroDollars = newMinimumDeposit ;
451
457
452
- emit MinimumDepositSet (oldMinimumDeposit, _newMinimumDeposit );
458
+ emit MinimumDepositSet (oldMinimumDeposit, newMinimumDeposit );
453
459
}
454
460
455
461
/**
456
462
* @inheritdoc IPayer
457
463
*/
458
- function setMinimumRegistrationAmount (uint64 _newMinimumRegistrationAmount ) external onlyRole (ADMIN_ROLE) {
464
+ function setMinimumRegistrationAmount (uint64 newMinimumRegistrationAmount ) external onlyRole (ADMIN_ROLE) {
459
465
require (
460
- _newMinimumRegistrationAmount > DEFAULT_MINIMUM_REGISTRATION_AMOUNT_MICRO_DOLLARS,
466
+ newMinimumRegistrationAmount > DEFAULT_MINIMUM_REGISTRATION_AMOUNT_MICRO_DOLLARS,
461
467
InvalidMinimumRegistrationAmount ()
462
468
);
463
469
464
470
PayerStorage storage $ = _getPayerStorage ();
465
471
466
472
uint256 oldMinimumRegistrationAmount = $.minimumRegistrationAmountMicroDollars;
467
- $.minimumRegistrationAmountMicroDollars = _newMinimumRegistrationAmount ;
473
+ $.minimumRegistrationAmountMicroDollars = newMinimumRegistrationAmount ;
468
474
469
- emit MinimumRegistrationAmountSet (oldMinimumRegistrationAmount, _newMinimumRegistrationAmount );
475
+ emit MinimumRegistrationAmountSet (oldMinimumRegistrationAmount, newMinimumRegistrationAmount );
470
476
}
471
477
472
478
/**
473
479
* @inheritdoc IPayer
474
480
*/
475
- function setWithdrawalLockPeriod (uint32 _newWithdrawalLockPeriod ) external onlyRole (ADMIN_ROLE) {
476
- require (_newWithdrawalLockPeriod >= ABSOLUTE_MINIMUM_WITHDRAWAL_LOCK_PERIOD, InvalidWithdrawalLockPeriod ());
481
+ function setWithdrawalLockPeriod (uint32 newWithdrawalLockPeriod ) external onlyRole (ADMIN_ROLE) {
482
+ require (newWithdrawalLockPeriod >= ABSOLUTE_MINIMUM_WITHDRAWAL_LOCK_PERIOD, InvalidWithdrawalLockPeriod ());
477
483
478
484
PayerStorage storage $ = _getPayerStorage ();
479
485
480
486
uint256 oldWithdrawalLockPeriod = $.withdrawalLockPeriod;
481
- $.withdrawalLockPeriod = _newWithdrawalLockPeriod ;
487
+ $.withdrawalLockPeriod = newWithdrawalLockPeriod ;
482
488
483
- emit WithdrawalLockPeriodSet (oldWithdrawalLockPeriod, _newWithdrawalLockPeriod );
489
+ emit WithdrawalLockPeriodSet (oldWithdrawalLockPeriod, newWithdrawalLockPeriod );
484
490
}
485
491
486
492
/**
487
493
* @inheritdoc IPayer
488
494
*/
489
- function setMaxTolerableDebtAmount (uint64 _newMaxTolerableDebtAmountMicroDollars ) external onlyRole (ADMIN_ROLE) {
490
- require (_newMaxTolerableDebtAmountMicroDollars > 0 , InvalidMaxTolerableDebtAmount ());
495
+ function setMaxTolerableDebtAmount (uint64 newMaxTolerableDebtAmountMicroDollars ) external onlyRole (ADMIN_ROLE) {
496
+ require (newMaxTolerableDebtAmountMicroDollars > 0 , InvalidMaxTolerableDebtAmount ());
491
497
492
498
PayerStorage storage $ = _getPayerStorage ();
493
499
494
500
uint64 oldMaxTolerableDebtAmount = $.maxTolerableDebtAmountMicroDollars;
495
- $.maxTolerableDebtAmountMicroDollars = _newMaxTolerableDebtAmountMicroDollars ;
501
+ $.maxTolerableDebtAmountMicroDollars = newMaxTolerableDebtAmountMicroDollars ;
496
502
497
- emit MaxTolerableDebtAmountSet (oldMaxTolerableDebtAmount, _newMaxTolerableDebtAmountMicroDollars );
503
+ emit MaxTolerableDebtAmountSet (oldMaxTolerableDebtAmount, newMaxTolerableDebtAmountMicroDollars );
498
504
}
499
505
500
506
/**
501
507
* @inheritdoc IPayer
502
508
*/
503
- function setTransferFeesPeriod (uint32 _newTransferFeesPeriod ) external onlyRole (ADMIN_ROLE) {
504
- require (_newTransferFeesPeriod >= ABSOLUTE_MINIMUM_TRANSFER_FEES_PERIOD, InvalidTransferFeesPeriod ());
509
+ function setTransferFeesPeriod (uint32 newTransferFeesPeriod ) external onlyRole (ADMIN_ROLE) {
510
+ require (newTransferFeesPeriod >= ABSOLUTE_MINIMUM_TRANSFER_FEES_PERIOD, InvalidTransferFeesPeriod ());
505
511
506
512
PayerStorage storage $ = _getPayerStorage ();
507
513
508
514
uint32 oldTransferFeesPeriod = $.transferFeesPeriod;
509
- $.transferFeesPeriod = _newTransferFeesPeriod ;
515
+ $.transferFeesPeriod = newTransferFeesPeriod ;
510
516
511
- emit TransferFeesPeriodSet (oldTransferFeesPeriod, _newTransferFeesPeriod );
517
+ emit TransferFeesPeriodSet (oldTransferFeesPeriod, newTransferFeesPeriod );
512
518
}
513
519
514
-
515
520
/**
516
521
* @inheritdoc IPayer
517
522
*/
0 commit comments