Skip to content

Commit 8d10376

Browse files
committed
refactor
1 parent ee98e21 commit 8d10376

File tree

1 file changed

+10
-20
lines changed

1 file changed

+10
-20
lines changed

src/MaglevEulerSwap.sol

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,16 @@ contract MaglevEulerSwap is MaglevBase {
3232
}
3333

3434
function verify(uint256, uint256, uint256 newReserve0, uint256 newReserve1) internal view virtual override {
35-
require(
36-
verifyCurve(newReserve0, newReserve1, _px, _py, initialReserve0, initialReserve1, _cx, _cy), KNotSatisfied()
37-
);
35+
int256 delta = 0;
36+
37+
if (newReserve0 >= initialReserve0) {
38+
delta = int256(newReserve0) - int256(fy(newReserve1, _px, _py, initialReserve0, initialReserve1, _cx, _cy));
39+
} else {
40+
delta = int256(newReserve1) - int256(fx(newReserve0, _px, _py, initialReserve0, initialReserve1, _cx, _cy));
41+
}
42+
43+
// if delta is > zero, then point is above the curve
44+
require(delta >= 0 , KNotSatisfied());
3845
}
3946

4047
uint256 private constant roundingCompensation = 1.0000000000001e18;
@@ -156,21 +163,4 @@ contract MaglevEulerSwap is MaglevBase {
156163

157164
return (dx, dy);
158165
}
159-
160-
function verifyCurve(uint256 xt, uint256 yt, uint256 px, uint256 py, uint256 x0, uint256 y0, uint256 cx, uint256 cy)
161-
internal
162-
pure
163-
returns (bool)
164-
{
165-
int256 delta = 0;
166-
167-
if (xt >= x0) {
168-
delta = int256(xt) - int256(fy(yt, px, py, x0, y0, cx, cy));
169-
} else {
170-
delta = int256(yt) - int256(fx(xt, px, py, x0, y0, cx, cy));
171-
}
172-
173-
// if distance is > zero, then point is above the curve, and invariant passes
174-
return (delta >= 0);
175-
}
176166
}

0 commit comments

Comments
 (0)