File tree Expand file tree Collapse file tree 1 file changed +13
-10
lines changed Expand file tree Collapse file tree 1 file changed +13
-10
lines changed Original file line number Diff line number Diff line change @@ -378,18 +378,21 @@ contract UFragmentsPolicy is Ownable {
378378 // When supply is decreasing:
379379 // We limit the supply delta, based on recent supply history.
380380 if (rebasePercentage < 0 ) {
381- int256 maxSupplyInHistory = currentSupply;
382- for (uint8 i = 1 ; i < epochLookback && epoch > i; i++ ) {
383- int256 epochSupply = supplyHistory[epoch - i].toInt256Safe ();
384- if (epochSupply > maxSupplyInHistory) {
385- maxSupplyInHistory = epochSupply;
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;
386390 }
387391 }
388- int256 allowedSupplyMinimum = maxSupplyInHistory
389- .mul (ONE.sub (tolerableDeclinePercentage))
390- .div (ONE);
391- newSupply = (newSupply > allowedSupplyMinimum) ? newSupply : allowedSupplyMinimum;
392- require (newSupply <= currentSupply);
392+ int256 allowedMin = maxSupply.mul (ONE.sub (tolerableDeclinePercentage)).div (ONE);
393+ if (newSupply < allowedMin) {
394+ newSupply = allowedMin;
395+ }
393396 }
394397
395398 return newSupply.sub (currentSupply);
You can’t perform that action at this time.
0 commit comments