Skip to content

Commit 027ea6d

Browse files
committed
Minor changes
1 parent 94be5f0 commit 027ea6d

3 files changed

Lines changed: 7 additions & 5 deletions

File tree

src/BeamState.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ contract BeamState {
178178
}
179179

180180
function setMaxChange(address rateLimits_, uint256 value) external roleAuth {
181-
require(value == 0 || value >= WAD, "BeamState/maxChange-below-1x");
181+
require(value == 0 || value >= WAD, "BeamState/invalid-maxChange");
182182
maxChange[rateLimits_] = value;
183183
emit SetMaxChange(rateLimits_, value);
184184
}

src/Configurator.sol

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,15 +102,17 @@ contract Configurator {
102102
uint256 maxChange = beamState.getMaxChange(rateLimits);
103103

104104
// Ceiling is the max of (current * maxChange) and default
105+
// Avoids overflow when current maxAmount is type(uint256).max and guarantees decreases are always possible even when maxChange is 0
105106
require(
106107
maxAmount <= defMaxAmount ||
107-
maxAmount <= current.maxAmount || // avoid overflow when current maxAmount is type(uint256).max
108+
maxAmount <= current.maxAmount ||
108109
maxAmount <= current.maxAmount * maxChange / WAD,
109110
"Configurator/exceeds-max-amount"
110111
);
112+
// Avoids overflow for a hypothetical case where current slope is type(uint256).max
111113
require(
112114
slope <= defSlope ||
113-
slope <= current.slope || // avoid overflow for an hypothetical case where current slope is type(uint256).max
115+
slope <= current.slope ||
114116
slope <= current.slope * maxChange / WAD,
115117
"Configurator/exceeds-max-slope"
116118
);

test/BeamState.t.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -325,8 +325,8 @@ contract BeamStateTest is DssTest {
325325
assertEq(beamState.maxChange(TARGET1), 0, "maxChange should be cleared");
326326
}
327327

328-
function testSetMaxChangeBelowWad() public {
329-
vm.expectRevert("BeamState/maxChange-below-1x");
328+
function testSetMaxChangeInvalidValue() public {
329+
vm.expectRevert("BeamState/invalid-maxChange");
330330
beamState.setMaxChange(TARGET1, WAD - 1);
331331
}
332332

0 commit comments

Comments
 (0)