@@ -61,10 +61,51 @@ contract EulerSwapTest is MaglevTestBase {
61
61
62
62
t2.transfer (address (maglev), q);
63
63
if (dir) maglev.swap (amount - 2 , 0 , address (this ), "" ); // - 2 due to rounding
64
-
65
64
else maglev.swap (0 , amount - 2 , address (this ), "" );
66
65
67
66
uint256 q2 = maglev.quoteExactInput (address (t1), address (t2), amount);
68
67
assertApproxEqAbs (q, q2, 0.00000001e18 );
69
68
}
69
+
70
+ function test_fuzzParams (uint256 amount , uint256 amount2 , uint256 px , uint256 py , uint256 cx , uint256 cy , bool dir ) public {
71
+ amount = bound (amount, 0.1e18 , 25e18 );
72
+ amount2 = bound (amount2, 0.1e18 , 25e18 );
73
+ px = bound (px, 1e18 , 1e18 );
74
+ py = bound (py, 1e18 , 1e18 );
75
+ cx = bound (cx, 0.01e18 , 0.99e18 );
76
+ cy = bound (cy, 0.01e18 , 0.99e18 );
77
+
78
+ int256 origNav = getHolderNAV ();
79
+
80
+ vm.prank (owner);
81
+ maglev.setEulerSwapParams (Maglev.EulerSwapParams ({
82
+ px: px,
83
+ py: py,
84
+ cx: cx,
85
+ cy: cy
86
+ }));
87
+
88
+ TestERC20 t1;
89
+ TestERC20 t2;
90
+ if (dir) (t1, t2) = (assetTST, assetTST2);
91
+ else (t1, t2) = (assetTST2, assetTST);
92
+
93
+ t1.mint (address (this ), amount);
94
+ uint256 q = maglev.quoteExactInput (address (t1), address (t2), amount);
95
+
96
+ t1.transfer (address (maglev), amount);
97
+ if (dir) maglev.swap (0 , q, address (this ), "" );
98
+ else maglev.swap (q, 0 , address (this ), "" );
99
+ assertEq (t2.balanceOf (address (this )), q);
100
+
101
+ t2.mint (address (this ), amount2);
102
+ uint256 q2 = maglev.quoteExactInput (address (t2), address (t1), amount2);
103
+
104
+ t2.transfer (address (maglev), amount2);
105
+ if (dir) maglev.swap (q2, 0 , address (this ), "" );
106
+ else maglev.swap (0 , q2, address (this ), "" );
107
+ assertEq (t1.balanceOf (address (this )), q2);
108
+
109
+ assertGe (getHolderNAV (), origNav);
110
+ }
70
111
}
0 commit comments