@@ -236,7 +236,7 @@ contract UFragmentsPolicy is Ownable {
236236 /**
237237 * @notice Sets the parameters which control rebase circuit breaker.
238238 * @param epochLookback_ The number of rebase epochs to look back.
239- * @param tolerableDeclinePercentage_ The maximum supply decline percentage which is allowed
239+ * @param tolerableDeclinePercentage_ The supply decline percentage which is allowed
240240 * within the defined look back period.
241241 */
242242 function setRebaseCircuitBreakerParameters (
@@ -377,19 +377,15 @@ contract UFragmentsPolicy is Ownable {
377377
378378 // When supply is decreasing:
379379 // We limit the supply delta, based on recent supply history.
380- if (rebasePercentage < 0 ) {
381- int256 maxSupply = currentSupply;
382- for (
383- uint256 e = ((epoch > epochLookback) ? (epoch - epochLookback) : 0 );
384- e < epoch;
385- e++
386- ) {
387- int256 epochSupply = supplyHistory[e].toInt256Safe ();
388- if (epochSupply > maxSupply) {
389- maxSupply = epochSupply;
390- }
380+ if (rebasePercentage < 0 && epoch > epochLookback) {
381+ int256 allowedMin = supplyHistory[epoch - epochLookback]
382+ .toInt256Safe ()
383+ .mul (ONE.sub (tolerableDeclinePercentage))
384+ .div (ONE);
385+ if (allowedMin > currentSupply) {
386+ // NOTE: Allowed minimum supply can only be at most the current supply.
387+ allowedMin = currentSupply;
391388 }
392- int256 allowedMin = maxSupply.mul (ONE.sub (tolerableDeclinePercentage)).div (ONE);
393389 if (newSupply < allowedMin) {
394390 newSupply = allowedMin;
395391 }
0 commit comments