Skip to content

Commit 53271cb

Browse files
committed
fix: add even stricter checks in fInverse() fuzz test
1 parent e093dee commit 53271cb

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

test/CurveLib.t.sol

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ contract CurveLibTest is EulerSwapTestBase {
3737
// Params
3838
px = 1e18;
3939
py = bound(py, 1, 1e36);
40-
x0 = bound(x0, 1e2, 1e28);
40+
x0 = bound(x0, 1, 1e28);
4141
y0 = bound(y0, 0, 1e28);
4242
cx = bound(cx, 1, 1e18);
4343
cy = bound(cy, 1, 1e18);
@@ -63,9 +63,7 @@ contract CurveLibTest is EulerSwapTestBase {
6363
protocolFeeRecipient: address(0)
6464
});
6565

66-
// Note without -2 in the max bound, f() sometimes fails when x gets too close to centre.
67-
// Note small x values lead to large y-values, which causes problems for both f() and fInverse(), so we cap it here
68-
x = bound(x, 1e2 - 3, x0 - 3);
66+
x = bound(x, 1, x0);
6967

7068
uint256 y = CurveLib.f(x, px, py, x0, y0, cx);
7169
console.log("y ", y);
@@ -83,7 +81,9 @@ contract CurveLibTest is EulerSwapTestBase {
8381

8482
if (x < type(uint112).max && y < type(uint112).max) {
8583
assert(CurveLib.verify(p, xCalc, y));
86-
assert(int256(xCalc) - int256(xBin) <= 3 || int256(yCalc) - int256(yBin) <= 3); // suspect this is 2 wei error in fInverse() + 1 wei error in f()
84+
console.log("Invariant passed");
85+
assert(xCalc - xBin <= 3 || y - yCalc <= 3); // suspect this is 2 wei error in fInverse() + 1 wei error in f()
86+
console.log("Margin error passed");
8787
}
8888
}
8989

0 commit comments

Comments
 (0)