Skip to content

Commit 0079aa4

Browse files
style: Adjustments
1 parent 20098ae commit 0079aa4

9 files changed

+81
-261
lines changed

.eslintignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
node_modules
22
artifacts
33
cache
4-
coverage
4+
coverage*
5+
gasReporterOutput.json
6+
typechain
7+
lib/ds-test

.prettierignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@ artifacts
33
cache
44
coverage*
55
gasReporterOutput.json
6+
typechain
7+
lib/ds-test

.solcover.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@ module.exports = {
22
silent: true,
33
measureStatementCoverage: true,
44
measureFunctionCoverage: true,
5-
skipFiles: [
6-
"interfaces",
7-
"test",
8-
"tokenStaking/OperatorControllerForRewards.sol",
9-
],
5+
skipFiles: ["interfaces", "test", "tokenStaking/OperatorControllerForRewards.sol"],
106
configureYulOptimizer: true,
117
};

contracts/FeeSharingSetter.sol

Lines changed: 25 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,7 @@ contract FeeSharingSetter is ReentrancyGuard, AccessControl {
5252
// Set of addresses that are staking only the fee sharing
5353
EnumerableSet.AddressSet private _feeStakingAddresses;
5454

55-
event ConversionToRewardToken(
56-
address indexed token,
57-
uint256 amountConverted,
58-
uint256 amountReceived
59-
);
55+
event ConversionToRewardToken(address indexed token, uint256 amountConverted, uint256 amountReceived);
6056
event FeeStakingAddressesAdded(address[] feeStakingAddresses);
6157
event FeeStakingAddressesRemoved(address[] feeStakingAddresses);
6258
event NewFeeSharingSystemOwner(address newOwner);
@@ -104,11 +100,7 @@ contract FeeSharingSetter is ReentrancyGuard, AccessControl {
104100
*/
105101
function updateRewards() external onlyRole(OPERATOR_ROLE) {
106102
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");
112104
}
113105

114106
// Adjust for this period
@@ -128,17 +120,11 @@ contract FeeSharingSetter is ReentrancyGuard, AccessControl {
128120

129121
// If there are eligible addresses for fee-sharing only, calculate their shares
130122
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));
137125

138126
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));
142128
totalAmountStaked += looksBalance;
143129
looksBalances[i] = looksBalance;
144130
}
@@ -148,14 +134,10 @@ contract FeeSharingSetter is ReentrancyGuard, AccessControl {
148134
uint256 adjustedReward = reward;
149135

150136
for (uint256 i = 0; i < numberAddressesForFeeStaking; i++) {
151-
uint256 amountToTransfer = (looksBalances[i] * reward) /
152-
totalAmountStaked;
137+
uint256 amountToTransfer = (looksBalances[i] * reward) / totalAmountStaked;
153138
if (amountToTransfer > 0) {
154139
adjustedReward -= amountToTransfer;
155-
rewardToken.safeTransfer(
156-
_feeStakingAddresses.at(i),
157-
amountToTransfer
158-
);
140+
rewardToken.safeTransfer(_feeStakingAddresses.at(i), amountToTransfer);
159141
}
160142
}
161143

@@ -177,35 +159,22 @@ contract FeeSharingSetter is ReentrancyGuard, AccessControl {
177159
* @param token address of the token to sell
178160
* @param additionalData additional data (e.g., slippage)
179161
*/
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");
192169

193170
uint256 amountToConvert = IERC20(token).balanceOf(address(this));
194171
require(amountToConvert != 0, "Convert: Amount to convert must be > 0");
195172

196173
// Adjust allowance for this transaction only
197-
IERC20(token).safeIncreaseAllowance(
198-
address(rewardConvertor),
199-
amountToConvert
200-
);
174+
IERC20(token).safeIncreaseAllowance(address(rewardConvertor), amountToConvert);
201175

202176
// 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);
209178

210179
emit ConversionToRewardToken(token, amountToConvert, amountReceived);
211180
}
@@ -214,15 +183,9 @@ contract FeeSharingSetter is ReentrancyGuard, AccessControl {
214183
* @notice Add staking addresses
215184
* @param _stakingAddresses array of addresses eligible for fee-sharing only
216185
*/
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) {
221187
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");
226189
_feeStakingAddresses.add(_stakingAddresses[i]);
227190
}
228191

@@ -233,15 +196,9 @@ contract FeeSharingSetter is ReentrancyGuard, AccessControl {
233196
* @notice Remove staking addresses
234197
* @param _stakingAddresses array of addresses eligible for fee-sharing only
235198
*/
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) {
240200
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");
245202
_feeStakingAddresses.remove(_stakingAddresses[i]);
246203
}
247204

@@ -252,10 +209,7 @@ contract FeeSharingSetter is ReentrancyGuard, AccessControl {
252209
* @notice Set new reward duration in blocks for next update
253210
* @param _newRewardDurationInBlocks number of blocks for new reward period
254211
*/
255-
function setNewRewardDurationInBlocks(uint256 _newRewardDurationInBlocks)
256-
external
257-
onlyRole(DEFAULT_ADMIN_ROLE)
258-
{
212+
function setNewRewardDurationInBlocks(uint256 _newRewardDurationInBlocks) external onlyRole(DEFAULT_ADMIN_ROLE) {
259213
require(
260214
(_newRewardDurationInBlocks <= MAX_REWARD_DURATION_IN_BLOCKS) &&
261215
(_newRewardDurationInBlocks >= MIN_REWARD_DURATION_IN_BLOCKS),
@@ -271,10 +225,7 @@ contract FeeSharingSetter is ReentrancyGuard, AccessControl {
271225
* @notice Set reward convertor contract
272226
* @param _rewardConvertor address of the reward convertor (set to null to deactivate)
273227
*/
274-
function setRewardConvertor(address _rewardConvertor)
275-
external
276-
onlyRole(DEFAULT_ADMIN_ROLE)
277-
{
228+
function setRewardConvertor(address _rewardConvertor) external onlyRole(DEFAULT_ADMIN_ROLE) {
278229
rewardConvertor = IRewardConvertor(_rewardConvertor);
279230

280231
emit NewRewardConvertor(_rewardConvertor);
@@ -284,14 +235,8 @@ contract FeeSharingSetter is ReentrancyGuard, AccessControl {
284235
* @notice Transfer ownership of fee sharing system
285236
* @param _newOwner address of the new owner
286237
*/
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");
295240
feeSharingSystem.transferOwnership(_newOwner);
296241

297242
emit NewFeeSharingSystemOwner(_newOwner);
@@ -300,11 +245,7 @@ contract FeeSharingSetter is ReentrancyGuard, AccessControl {
300245
/**
301246
* @notice See addresses eligible for fee-staking
302247
*/
303-
function viewFeeStakingAddresses()
304-
external
305-
view
306-
returns (address[] memory)
307-
{
248+
function viewFeeStakingAddresses() external view returns (address[] memory) {
308249
uint256 length = _feeStakingAddresses.length();
309250

310251
address[] memory feeStakingAddresses = new address[](length);

0 commit comments

Comments
 (0)