Skip to content

Commit 729be03

Browse files
committed
Added ClampWrapper to keep same API
1 parent 57cbfdd commit 729be03

2 files changed

Lines changed: 67 additions & 2 deletions

File tree

src/ClampWrapper.sol

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
// SPDX-License-Identifier: MIT
2+
pragma solidity ^0.8.0;
3+
4+
import "./ClampHelper.sol";
5+
6+
abstract contract ClampWrapper is ClampHelper {
7+
8+
/// @notice Clamps value to be between low and high, both inclusive
9+
function clampBetween(
10+
uint256 value,
11+
uint256 low,
12+
uint256 high
13+
) internal returns (uint256) {
14+
return clampBetween(value, low, high, true);
15+
}
16+
17+
/// @notice int256 version of clampBetween
18+
function clampBetween(
19+
int256 value,
20+
int256 low,
21+
int256 high
22+
) internal returns (int256) {
23+
return clampBetween(value, low, high, true);
24+
}
25+
26+
/// @notice clamps a to be less than b
27+
function clampLt(uint256 a, uint256 b) internal returns (uint256) {
28+
return clampLt(a, b);
29+
}
30+
31+
/// @notice int256 version of clampLt
32+
function clampLt(int256 a, int256 b) internal returns (int256) {
33+
return clampLt(a, b, true);
34+
}
35+
36+
/// @notice clamps a to be less than or equal to b
37+
function clampLte(uint256 a, uint256 b) internal returns (uint256) {
38+
return clampLte(a, b, true);
39+
}
40+
41+
/// @notice int256 version of clampLte
42+
function clampLte(int256 a, int256 b) internal returns (int256) {
43+
return clampLte(a, b, true);
44+
}
45+
46+
/// @notice clamps a to be greater than b
47+
function clampGt(uint256 a, uint256 b) internal returns (uint256) {
48+
return clampGt(a, b, true);
49+
}
50+
51+
/// @notice int256 version of clampGt
52+
function clampGt(int256 a, int256 b) internal returns (int256) {
53+
return clampGt(a, b, true);
54+
}
55+
56+
/// @notice clamps a to be greater than or equal to b
57+
function clampGte(uint256 a, uint256 b) internal returns (uint256) {
58+
return clampGte(a, b, true);
59+
}
60+
61+
/// @notice int256 version of clampGte
62+
function clampGte(int256 a, int256 b) internal returns (int256) {
63+
return clampGte(a, b, true);
64+
}
65+
}

src/FuzzBase.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ pragma solidity ^0.8.0;
44
import "./Logging.sol";
55
import "./Constants.sol";
66
import "./AssertHelper.sol";
7-
import "./ClampHelper.sol";
7+
import "./ClampWrapper.sol";
88

9-
abstract contract FuzzBase is AssertHelper, ClampHelper, Logging, Constants {}
9+
abstract contract FuzzBase is AssertHelper, ClampWrapper, Logging, Constants {}

0 commit comments

Comments
 (0)