@@ -207,21 +207,15 @@ contract ReservoirPriceOracle is IPriceOracle, Owned(msg.sender), ReentrancyGuar
207
207
view
208
208
returns (uint256 rReward )
209
209
{
210
- // SAFETY: this mul will not overflow as 0 < `aRewardThreshold` <= `Constants.BP_SCALE`, as checked by `setRoute`
211
- uint256 lRewardThresholdWAD;
212
- unchecked {
213
- lRewardThresholdWAD = aRewardThreshold * Constants.WAD / Constants.BP_SCALE;
214
- }
215
-
216
210
uint256 lPercentDiff = aPrevPrice.calcPercentageDiff (aNewPrice);
217
211
218
212
// SAFETY: this mul will not overflow even in extreme cases of `block.basefee`.
219
213
unchecked {
220
- if (lPercentDiff < lRewardThresholdWAD ) {
214
+ if (lPercentDiff < aRewardThreshold ) {
221
215
return 0 ;
222
216
}
223
217
// payout max reward
224
- else if (lPercentDiff >= lRewardThresholdWAD * MAX_REWARD_MULTIPLIER) {
218
+ else if (lPercentDiff >= aRewardThreshold * MAX_REWARD_MULTIPLIER) {
225
219
// N.B. Revisit this whenever deployment on a new chain is needed
226
220
//
227
221
// we use `block.basefee` instead of `ArbGasInfo::getMinimumGasPrice()`
@@ -230,7 +224,8 @@ contract ReservoirPriceOracle is IPriceOracle, Owned(msg.sender), ReentrancyGuar
230
224
// congestion
231
225
rReward = block .basefee * rewardGasAmount * MAX_REWARD_MULTIPLIER;
232
226
} else {
233
- rReward = block .basefee * rewardGasAmount * lPercentDiff / lRewardThresholdWAD; // denominator is never 0
227
+ // denominator is never 0 as checked by `setRoute`
228
+ rReward = block .basefee * rewardGasAmount * lPercentDiff / aRewardThreshold;
234
229
}
235
230
}
236
231
}
@@ -300,7 +295,7 @@ contract ReservoirPriceOracle is IPriceOracle, Owned(msg.sender), ReentrancyGuar
300
295
301
296
// Calculate the storage slot for this intermediate segment and read it to see if there is an existing
302
297
// route. If there isn't an existing route, we create one as well.
303
- function _checkAndPopulateIntermediateRoute (address aTokenA , address aTokenB , uint16 aBpMaxReward ) private {
298
+ function _checkAndPopulateIntermediateRoute (address aTokenA , address aTokenB , uint64 aBpMaxReward ) private {
304
299
(address lToken0 , address lToken1 ) = Utils.sortTokens (aTokenA, aTokenB);
305
300
306
301
bytes32 lSlot = Utils.calculateSlot (lToken0, lToken1);
@@ -312,9 +307,9 @@ contract ReservoirPriceOracle is IPriceOracle, Owned(msg.sender), ReentrancyGuar
312
307
address [] memory lIntermediateRoute = new address [](2 );
313
308
lIntermediateRoute[0 ] = lToken0;
314
309
lIntermediateRoute[1 ] = lToken1;
315
- uint16 [] memory asd = new uint16 [](1 );
316
- asd [0 ] = aBpMaxReward;
317
- setRoute (lToken0, lToken1, lIntermediateRoute, asd );
310
+ uint64 [] memory lRewardThreshold = new uint64 [](1 );
311
+ lRewardThreshold [0 ] = aBpMaxReward;
312
+ setRoute (lToken0, lToken1, lIntermediateRoute, lRewardThreshold );
318
313
}
319
314
}
320
315
@@ -488,7 +483,7 @@ contract ReservoirPriceOracle is IPriceOracle, Owned(msg.sender), ReentrancyGuar
488
483
/// @param aToken1 Address of the higher token.
489
484
/// @param aRoute Path with which the price between aToken0 and aToken1 should be derived.
490
485
/// @param aRewardThresholds Array of basis points at and beyond which a reward is applicable for a price update.
491
- function setRoute (address aToken0 , address aToken1 , address [] memory aRoute , uint16 [] memory aRewardThresholds )
486
+ function setRoute (address aToken0 , address aToken1 , address [] memory aRoute , uint64 [] memory aRewardThresholds )
492
487
public
493
488
onlyOwner
494
489
{
@@ -511,7 +506,7 @@ contract ReservoirPriceOracle is IPriceOracle, Owned(msg.sender), ReentrancyGuar
511
506
512
507
uint256 lRewardThreshold = aRewardThresholds[0 ];
513
508
require (
514
- lRewardThreshold <= Constants.BP_SCALE && lRewardThreshold != 0 , OracleErrors.InvalidRewardThreshold ()
509
+ lRewardThreshold <= Constants.WAD && lRewardThreshold != 0 , OracleErrors.InvalidRewardThreshold ()
515
510
);
516
511
517
512
bytes32 lData = RoutesLib.packSimplePrice (lDiff, 0 , lRewardThreshold);
0 commit comments