@@ -97,7 +97,10 @@ contract Distributor is UUPSHelper {
97
97
/// @dev If the mapping is empty, by default rewards will accrue on the user address
98
98
mapping (address => mapping (address => address )) public claimRecipient;
99
99
100
- uint256 [36 ] private __gap;
100
+ /// @notice Minimum fee amount to be paid for claiming
101
+ uint256 public singleClaimFeeInWei;
102
+
103
+ uint256 [35 ] private __gap;
101
104
102
105
/*//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
103
106
EVENTS
@@ -115,6 +118,7 @@ contract Distributor is UUPSHelper {
115
118
event OperatorToggled (address indexed user , address indexed operator , bool isWhitelisted );
116
119
event Recovered (address indexed token , address indexed to , uint256 amount );
117
120
event Revoked (); // With this event an indexer could maintain a table (timestamp, merkleRootUpdate)
121
+ event SingleClaimFeeInWeiUpdated (uint256 newValue );
118
122
event TreeUpdated (bytes32 merkleRoot , bytes32 ipfsHash , uint48 endOfDisputePeriod );
119
123
event TrustedToggled (address indexed eoa , bool trust );
120
124
event UpgradeabilityRevoked ();
@@ -129,6 +133,12 @@ contract Distributor is UUPSHelper {
129
133
_;
130
134
}
131
135
136
+ /// @notice Checks whether the `msg.sender` has the governor or the guardian role
137
+ modifier onlyGovernorOrGuardian () {
138
+ if (! accessControlManager.isGovernorOrGuardian (msg .sender )) revert Errors.NotGovernorOrGuardian ();
139
+ _;
140
+ }
141
+
132
142
/// @notice Checks whether the `msg.sender` is the `user` address or is a trusted address
133
143
modifier onlyTrustedOrUser (address user ) {
134
144
if (
@@ -190,6 +200,7 @@ contract Distributor is UUPSHelper {
190
200
uint256 [] calldata amounts ,
191
201
bytes32 [][] calldata proofs
192
202
) external {
203
+ if (singleClaimFeeInWei > 0 ) revert Errors.InvalidFee ();
193
204
address [] memory recipients = new address [](users.length );
194
205
bytes [] memory datas = new bytes [](users.length );
195
206
_claim (users, tokens, amounts, proofs, recipients, datas);
@@ -208,6 +219,34 @@ contract Distributor is UUPSHelper {
208
219
address [] calldata recipients ,
209
220
bytes [] memory datas
210
221
) external {
222
+ if (singleClaimFeeInWei > 0 ) revert Errors.InvalidFee ();
223
+ _claim (users, tokens, amounts, proofs, recipients, datas);
224
+ }
225
+
226
+ /// @notice Same as the function above but with the ability to pay a fee in ETH when claiming
227
+ function claimRewards (
228
+ address [] calldata users ,
229
+ address [] calldata tokens ,
230
+ uint256 [] calldata amounts ,
231
+ bytes32 [][] calldata proofs
232
+ ) external payable {
233
+ uint256 usersLength = users.length ;
234
+ if (msg .value < singleClaimFeeInWei * usersLength) revert Errors.InvalidFee ();
235
+ address [] memory recipients = new address [](usersLength);
236
+ bytes [] memory datas = new bytes [](usersLength);
237
+ _claim (users, tokens, amounts, proofs, recipients, datas);
238
+ }
239
+
240
+ /// @notice Same as the function above but with the ability to pay a fee in ETH when claiming
241
+ function claimRewardsWithRecipients (
242
+ address [] calldata users ,
243
+ address [] calldata tokens ,
244
+ uint256 [] calldata amounts ,
245
+ bytes32 [][] calldata proofs ,
246
+ address [] calldata recipients ,
247
+ bytes [] memory datas
248
+ ) external payable {
249
+ if (msg .value < singleClaimFeeInWei * users.length ) revert Errors.InvalidFee ();
211
250
_claim (users, tokens, amounts, proofs, recipients, datas);
212
251
}
213
252
@@ -345,6 +384,21 @@ contract Distributor is UUPSHelper {
345
384
emit DisputeAmountUpdated (_disputeAmount);
346
385
}
347
386
387
+ /// @notice Sets the minimum fee to claim a given reward token on Merkl
388
+ function updateSingleClaimFeeInWei (uint256 amount ) external onlyGovernor {
389
+ singleClaimFeeInWei = amount;
390
+ emit SingleClaimFeeInWeiUpdated (amount);
391
+ }
392
+
393
+ /// @notice Withdraws the ETH accumulated on the contract
394
+ function withdrawETH (address payable recipient ) external onlyGovernorOrGuardian {
395
+ uint256 balance = address (this ).balance;
396
+ if (balance > 0 ) {
397
+ (bool success , ) = recipient.call { value: balance }("" );
398
+ if (! success) revert Errors.InvalidParam ();
399
+ }
400
+ }
401
+
348
402
/*//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
349
403
INTERNAL HELPERS
350
404
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////*/
0 commit comments