@@ -32,9 +32,16 @@ contract MaglevEulerSwap is MaglevBase {
32
32
}
33
33
34
34
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 ());
38
45
}
39
46
40
47
uint256 private constant roundingCompensation = 1.0000000000001e18 ;
@@ -156,21 +163,4 @@ contract MaglevEulerSwap is MaglevBase {
156
163
157
164
return (dx, dy);
158
165
}
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
- }
176
166
}
0 commit comments