@@ -43,7 +43,10 @@ contract EulerSwapHookTest is EulerSwapTestBase {
43
43
}
44
44
45
45
function test_SwapExactIn_withLpFee () public {
46
+ (uint112 r0 , uint112 r1 ,) = eulerSwap.getReserves ();
47
+
46
48
uint256 amountIn = 1e18 ;
49
+ uint256 amountInWithoutFee = amountIn * eulerSwap.feeMultiplier () / 1e18 ;
47
50
uint256 amountOut =
48
51
periphery.quoteExactInput (address (eulerSwap), address (assetTST), address (assetTST2), amountIn);
49
52
@@ -61,12 +64,26 @@ contract EulerSwapHookTest is EulerSwapTestBase {
61
64
62
65
assertEq (zeroForOne ? uint256 (- int256 (result.amount0 ())) : uint256 (- int256 (result.amount1 ())), amountIn);
63
66
assertEq (zeroForOne ? uint256 (int256 (result.amount1 ())) : uint256 (int256 (result.amount0 ())), amountOut);
67
+
68
+ // assert fees were not added to the reserves
69
+ (uint112 r0New , uint112 r1New ,) = eulerSwap.getReserves ();
70
+ if (zeroForOne) {
71
+ assertEq (r0New, r0 + amountInWithoutFee);
72
+ assertEq (r1New, r1 - amountOut);
73
+ } else {
74
+ // oneForZero, so the curve received asset1
75
+ assertEq (r0New, r0 - amountOut);
76
+ assertEq (r1New, r1 + amountInWithoutFee);
77
+ }
64
78
}
65
79
66
80
function test_SwapExactOut_withLpFee () public {
81
+ (uint112 r0 , uint112 r1 ,) = eulerSwap.getReserves ();
82
+
67
83
uint256 amountOut = 1e18 ;
68
84
uint256 amountIn =
69
85
periphery.quoteExactOutput (address (eulerSwap), address (assetTST), address (assetTST2), amountOut);
86
+ uint256 amountInWithoutFee = (amountIn * 1e18 ) / (2e18 - eulerSwap.feeMultiplier ());
70
87
71
88
assetTST.mint (anyone, amountIn);
72
89
@@ -82,6 +99,17 @@ contract EulerSwapHookTest is EulerSwapTestBase {
82
99
83
100
assertEq (zeroForOne ? uint256 (- int256 (result.amount0 ())) : uint256 (- int256 (result.amount1 ())), amountIn);
84
101
assertEq (zeroForOne ? uint256 (int256 (result.amount1 ())) : uint256 (int256 (result.amount0 ())), amountOut);
102
+
103
+ // assert fees were not added to the reserves
104
+ (uint112 r0New , uint112 r1New ,) = eulerSwap.getReserves ();
105
+ if (zeroForOne) {
106
+ assertEq (r0New, r0 + amountInWithoutFee, "A " );
107
+ assertEq (r1New, r1 - amountOut, "B " );
108
+ } else {
109
+ // oneForZero, so the curve received asset1
110
+ assertEq (r0New, r0 - amountOut, "C " );
111
+ assertEq (r1New, r1 + amountInWithoutFee, "D " );
112
+ }
85
113
}
86
114
87
115
function _swap (PoolKey memory key , bool zeroForOne , bool exactInput , uint256 amount ) internal {
0 commit comments