Skip to content

Commit 101ec2a

Browse files
committed
code review comments
1 parent 4fb7a0e commit 101ec2a

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

contracts/UFragmentsPolicy.sol

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -379,17 +379,22 @@ contract UFragmentsPolicy is Ownable {
379379
// We limit the supply delta, based on recent supply history.
380380
if (rebasePercentage < 0) {
381381
int256 maxSupplyInHistory = currentSupply;
382-
for (uint8 i = 1; i < epochLookback && epoch > i; i++) {
383-
int256 epochSupply = supplyHistory[epoch - i].toInt256Safe();
382+
for (
383+
uint256 e = ((epoch > epochLookback) ? (epoch - epochLookback) : 0);
384+
e < epoch;
385+
e++
386+
) {
387+
int256 epochSupply = supplyHistory[e].toInt256Safe();
384388
if (epochSupply > maxSupplyInHistory) {
385389
maxSupplyInHistory = 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 = maxSupplyInHistory.mul(ONE.sub(tolerableDeclinePercentage)).div(
393+
ONE
394+
);
395+
if (newSupply < allowedMin) {
396+
newSupply = allowedMin;
397+
}
393398
}
394399

395400
return newSupply.sub(currentSupply);

0 commit comments

Comments
 (0)