@@ -164,15 +164,14 @@ contract OperatorRewarder {
164164 _protocolStaking = protocolStaking_;
165165 _operatorStaking = operatorStaking_;
166166
167- // Set fee values directly without calling `setFee()` or `setMaxFee()`, which would snapshot
167+ // Since `feeBasisPoints()` is not initialized and thus null, calling `_setMaxFee` only sets
168+ // the max fee value without calling `_setFee` internally, so there is no need to define a
169+ // new `_setInitialMaxFee` as opposed to setting fees
170+ _setMaxFee (initialMaxFeeBasisPoints_);
171+
172+ // Set fee value directly without claiming fees, which would snapshot
168173 // `_lastClaimTotalAssetsPlusPaidRewards` via `claimFee()` with potentially stale pending rewards.
169- require (initialMaxFeeBasisPoints_ <= 10000 , InvalidBasisPoints (initialMaxFeeBasisPoints_));
170- require (
171- initialFeeBasisPoints_ <= initialMaxFeeBasisPoints_,
172- MaxBasisPointsExceeded (initialFeeBasisPoints_, initialMaxFeeBasisPoints_)
173- );
174- _maxFeeBasisPoints = initialMaxFeeBasisPoints_;
175- _feeBasisPoints = initialFeeBasisPoints_;
174+ _setInitialFee (initialFeeBasisPoints_);
176175 }
177176
178177 /**
@@ -200,9 +199,11 @@ contract OperatorRewarder {
200199 * @notice Claims rewards for a delegator. The caller must be authorized to claim rewards on
201200 * behalf of the delegator. By default, the caller is authorized to claim rewards on behalf of
202201 * themselves.
202+ * @dev It can only be called once the rewarder has started to avoid allowing anyone to drain
203+ * rewards generated by donations sent beforehand.
203204 * @param receiver The delegator's address that will receive the rewards.
204205 */
205- function claimRewards (address receiver ) public virtual onlyClaimer (receiver) {
206+ function claimRewards (address receiver ) public virtual whenStarted onlyClaimer (receiver) {
206207 uint256 earned_ = earned (receiver);
207208 if (earned_ > 0 ) {
208209 _rewardsPaid[receiver] += SafeCast.toInt256 (earned_);
@@ -496,6 +497,19 @@ contract OperatorRewarder {
496497 _feeBasisPoints = basisPoints;
497498 }
498499
500+ /**
501+ * @notice Sets the initial fee in basis points (1/100th of a percent) without claiming fees.
502+ * @param basisPoints Fee in basis points (cannot be greater than the maximum fee).
503+ */
504+ function _setInitialFee (uint16 basisPoints ) internal virtual {
505+ // The following statement also makes sure the basis points is not greater than 10000, as
506+ // the max fee basis points also follows this constraint.
507+ require (basisPoints <= maxFeeBasisPoints (), MaxBasisPointsExceeded (basisPoints, maxFeeBasisPoints ()));
508+
509+ emit FeeUpdated (feeBasisPoints (), basisPoints);
510+ _feeBasisPoints = basisPoints;
511+ }
512+
499513 /**
500514 * @notice Returns the total assets plus earned rewards plus paid rewards.
501515 * @dev This amount is computed as the sum of:
0 commit comments