@@ -52,11 +52,7 @@ contract FeeSharingSetter is ReentrancyGuard, AccessControl {
52
52
// Set of addresses that are staking only the fee sharing
53
53
EnumerableSet.AddressSet private _feeStakingAddresses;
54
54
55
- event ConversionToRewardToken (
56
- address indexed token ,
57
- uint256 amountConverted ,
58
- uint256 amountReceived
59
- );
55
+ event ConversionToRewardToken (address indexed token , uint256 amountConverted , uint256 amountReceived );
60
56
event FeeStakingAddressesAdded (address [] feeStakingAddresses );
61
57
event FeeStakingAddressesRemoved (address [] feeStakingAddresses );
62
58
event NewFeeSharingSystemOwner (address newOwner );
@@ -104,11 +100,7 @@ contract FeeSharingSetter is ReentrancyGuard, AccessControl {
104
100
*/
105
101
function updateRewards () external onlyRole (OPERATOR_ROLE) {
106
102
if (lastRewardDistributionBlock > 0 ) {
107
- require (
108
- block .number >
109
- (rewardDurationInBlocks + lastRewardDistributionBlock),
110
- "Reward: Too early to add "
111
- );
103
+ require (block .number > (rewardDurationInBlocks + lastRewardDistributionBlock), "Reward: Too early to add " );
112
104
}
113
105
114
106
// Adjust for this period
@@ -128,17 +120,11 @@ contract FeeSharingSetter is ReentrancyGuard, AccessControl {
128
120
129
121
// If there are eligible addresses for fee-sharing only, calculate their shares
130
122
if (numberAddressesForFeeStaking > 0 ) {
131
- uint256 [] memory looksBalances = new uint256 [](
132
- numberAddressesForFeeStaking
133
- );
134
- (uint256 totalAmountStaked , ) = tokenDistributor.userInfo (
135
- address (feeSharingSystem)
136
- );
123
+ uint256 [] memory looksBalances = new uint256 [](numberAddressesForFeeStaking);
124
+ (uint256 totalAmountStaked , ) = tokenDistributor.userInfo (address (feeSharingSystem));
137
125
138
126
for (uint256 i = 0 ; i < numberAddressesForFeeStaking; i++ ) {
139
- uint256 looksBalance = looksRareToken.balanceOf (
140
- _feeStakingAddresses.at (i)
141
- );
127
+ uint256 looksBalance = looksRareToken.balanceOf (_feeStakingAddresses.at (i));
142
128
totalAmountStaked += looksBalance;
143
129
looksBalances[i] = looksBalance;
144
130
}
@@ -148,14 +134,10 @@ contract FeeSharingSetter is ReentrancyGuard, AccessControl {
148
134
uint256 adjustedReward = reward;
149
135
150
136
for (uint256 i = 0 ; i < numberAddressesForFeeStaking; i++ ) {
151
- uint256 amountToTransfer = (looksBalances[i] * reward) /
152
- totalAmountStaked;
137
+ uint256 amountToTransfer = (looksBalances[i] * reward) / totalAmountStaked;
153
138
if (amountToTransfer > 0 ) {
154
139
adjustedReward -= amountToTransfer;
155
- rewardToken.safeTransfer (
156
- _feeStakingAddresses.at (i),
157
- amountToTransfer
158
- );
140
+ rewardToken.safeTransfer (_feeStakingAddresses.at (i), amountToTransfer);
159
141
}
160
142
}
161
143
@@ -177,35 +159,22 @@ contract FeeSharingSetter is ReentrancyGuard, AccessControl {
177
159
* @param token address of the token to sell
178
160
* @param additionalData additional data (e.g., slippage)
179
161
*/
180
- function convertCurrencyToRewardToken (
181
- address token ,
182
- bytes calldata additionalData
183
- ) external nonReentrant onlyRole (OPERATOR_ROLE) {
184
- require (
185
- address (rewardConvertor) != address (0 ),
186
- "Convert: RewardConvertor not set "
187
- );
188
- require (
189
- token != address (rewardToken),
190
- "Convert: Cannot be reward token "
191
- );
162
+ function convertCurrencyToRewardToken (address token , bytes calldata additionalData )
163
+ external
164
+ nonReentrant
165
+ onlyRole (OPERATOR_ROLE)
166
+ {
167
+ require (address (rewardConvertor) != address (0 ), "Convert: RewardConvertor not set " );
168
+ require (token != address (rewardToken), "Convert: Cannot be reward token " );
192
169
193
170
uint256 amountToConvert = IERC20 (token).balanceOf (address (this ));
194
171
require (amountToConvert != 0 , "Convert: Amount to convert must be > 0 " );
195
172
196
173
// Adjust allowance for this transaction only
197
- IERC20 (token).safeIncreaseAllowance (
198
- address (rewardConvertor),
199
- amountToConvert
200
- );
174
+ IERC20 (token).safeIncreaseAllowance (address (rewardConvertor), amountToConvert);
201
175
202
176
// Exchange token to reward token
203
- uint256 amountReceived = rewardConvertor.convert (
204
- token,
205
- address (rewardToken),
206
- amountToConvert,
207
- additionalData
208
- );
177
+ uint256 amountReceived = rewardConvertor.convert (token, address (rewardToken), amountToConvert, additionalData);
209
178
210
179
emit ConversionToRewardToken (token, amountToConvert, amountReceived);
211
180
}
@@ -214,15 +183,9 @@ contract FeeSharingSetter is ReentrancyGuard, AccessControl {
214
183
* @notice Add staking addresses
215
184
* @param _stakingAddresses array of addresses eligible for fee-sharing only
216
185
*/
217
- function addFeeStakingAddresses (address [] calldata _stakingAddresses )
218
- external
219
- onlyRole (DEFAULT_ADMIN_ROLE)
220
- {
186
+ function addFeeStakingAddresses (address [] calldata _stakingAddresses ) external onlyRole (DEFAULT_ADMIN_ROLE) {
221
187
for (uint256 i = 0 ; i < _stakingAddresses.length ; i++ ) {
222
- require (
223
- ! _feeStakingAddresses.contains (_stakingAddresses[i]),
224
- "Owner: Address already registered "
225
- );
188
+ require (! _feeStakingAddresses.contains (_stakingAddresses[i]), "Owner: Address already registered " );
226
189
_feeStakingAddresses.add (_stakingAddresses[i]);
227
190
}
228
191
@@ -233,15 +196,9 @@ contract FeeSharingSetter is ReentrancyGuard, AccessControl {
233
196
* @notice Remove staking addresses
234
197
* @param _stakingAddresses array of addresses eligible for fee-sharing only
235
198
*/
236
- function removeFeeStakingAddresses (address [] calldata _stakingAddresses )
237
- external
238
- onlyRole (DEFAULT_ADMIN_ROLE)
239
- {
199
+ function removeFeeStakingAddresses (address [] calldata _stakingAddresses ) external onlyRole (DEFAULT_ADMIN_ROLE) {
240
200
for (uint256 i = 0 ; i < _stakingAddresses.length ; i++ ) {
241
- require (
242
- _feeStakingAddresses.contains (_stakingAddresses[i]),
243
- "Owner: Address not registered "
244
- );
201
+ require (_feeStakingAddresses.contains (_stakingAddresses[i]), "Owner: Address not registered " );
245
202
_feeStakingAddresses.remove (_stakingAddresses[i]);
246
203
}
247
204
@@ -252,10 +209,7 @@ contract FeeSharingSetter is ReentrancyGuard, AccessControl {
252
209
* @notice Set new reward duration in blocks for next update
253
210
* @param _newRewardDurationInBlocks number of blocks for new reward period
254
211
*/
255
- function setNewRewardDurationInBlocks (uint256 _newRewardDurationInBlocks )
256
- external
257
- onlyRole (DEFAULT_ADMIN_ROLE)
258
- {
212
+ function setNewRewardDurationInBlocks (uint256 _newRewardDurationInBlocks ) external onlyRole (DEFAULT_ADMIN_ROLE) {
259
213
require (
260
214
(_newRewardDurationInBlocks <= MAX_REWARD_DURATION_IN_BLOCKS) &&
261
215
(_newRewardDurationInBlocks >= MIN_REWARD_DURATION_IN_BLOCKS),
@@ -271,10 +225,7 @@ contract FeeSharingSetter is ReentrancyGuard, AccessControl {
271
225
* @notice Set reward convertor contract
272
226
* @param _rewardConvertor address of the reward convertor (set to null to deactivate)
273
227
*/
274
- function setRewardConvertor (address _rewardConvertor )
275
- external
276
- onlyRole (DEFAULT_ADMIN_ROLE)
277
- {
228
+ function setRewardConvertor (address _rewardConvertor ) external onlyRole (DEFAULT_ADMIN_ROLE) {
278
229
rewardConvertor = IRewardConvertor (_rewardConvertor);
279
230
280
231
emit NewRewardConvertor (_rewardConvertor);
@@ -284,14 +235,8 @@ contract FeeSharingSetter is ReentrancyGuard, AccessControl {
284
235
* @notice Transfer ownership of fee sharing system
285
236
* @param _newOwner address of the new owner
286
237
*/
287
- function transferOwnershipOfFeeSharingSystem (address _newOwner )
288
- external
289
- onlyRole (DEFAULT_ADMIN_ROLE)
290
- {
291
- require (
292
- _newOwner != address (0 ),
293
- "Owner: New owner cannot be null address "
294
- );
238
+ function transferOwnershipOfFeeSharingSystem (address _newOwner ) external onlyRole (DEFAULT_ADMIN_ROLE) {
239
+ require (_newOwner != address (0 ), "Owner: New owner cannot be null address " );
295
240
feeSharingSystem.transferOwnership (_newOwner);
296
241
297
242
emit NewFeeSharingSystemOwner (_newOwner);
@@ -300,11 +245,7 @@ contract FeeSharingSetter is ReentrancyGuard, AccessControl {
300
245
/**
301
246
* @notice See addresses eligible for fee-staking
302
247
*/
303
- function viewFeeStakingAddresses ()
304
- external
305
- view
306
- returns (address [] memory )
307
- {
248
+ function viewFeeStakingAddresses () external view returns (address [] memory ) {
308
249
uint256 length = _feeStakingAddresses.length ();
309
250
310
251
address [] memory feeStakingAddresses = new address [](length);
0 commit comments