@@ -10,6 +10,7 @@ contract MaglevEulerSwap is MaglevBase {
10
10
uint256 public _py;
11
11
uint256 public _cx;
12
12
uint256 public _cy;
13
+ uint256 public _fee;
13
14
14
15
error KNotSatisfied ();
15
16
error ReservesZero ();
@@ -20,6 +21,7 @@ contract MaglevEulerSwap is MaglevBase {
20
21
uint256 py;
21
22
uint256 cx;
22
23
uint256 cy;
24
+ uint256 fee;
23
25
}
24
26
25
27
constructor (BaseParams memory baseParams , EulerSwapParams memory params ) MaglevBase (baseParams) {
@@ -31,8 +33,10 @@ contract MaglevEulerSwap is MaglevBase {
31
33
_py = params.py;
32
34
_cx = params.cx;
33
35
_cy = params.cy;
36
+ _fee = Math.max (params.fee, 1.0000000000001e18 ); // minimum fee required to compensate for rounding
34
37
}
35
38
39
+ // FIXME: how to charge fees?
36
40
function verify (uint256 , uint256 , uint256 newReserve0 , uint256 newReserve1 ) internal view virtual override {
37
41
int256 delta = 0 ;
38
42
@@ -42,12 +46,10 @@ contract MaglevEulerSwap is MaglevBase {
42
46
delta = int256 (newReserve1) - int256 (fx (newReserve0, _px, _py, initialReserve0, initialReserve1, _cx, _cy));
43
47
}
44
48
45
- // if delta is > zero, then point is above the curve
49
+ // if delta is >= zero, then point is on or above the curve
46
50
require (delta >= 0 , KNotSatisfied ());
47
51
}
48
52
49
- uint256 private constant roundingCompensation = 1.0000000000001e18 ;
50
-
51
53
function computeQuote (uint256 amount , bool exactIn , bool asset0IsInput )
52
54
internal
53
55
view
@@ -86,11 +88,11 @@ contract MaglevEulerSwap is MaglevBase {
86
88
if (exactIn) {
87
89
if (asset0IsInput) output = uint256 (- dy);
88
90
else output = uint256 (- dx);
89
- output = output * 1e18 / roundingCompensation ;
91
+ output = output * 1e18 / _fee ;
90
92
} else {
91
93
if (asset0IsInput) output = uint256 (dx);
92
94
else output = uint256 (dy);
93
- output = output * roundingCompensation / 1e18 ;
95
+ output = output * _fee / 1e18 ;
94
96
}
95
97
}
96
98
0 commit comments