Skip to content

Commit 7829170

Browse files
committed
finish test harness for protocol fee params
1 parent 01c759d commit 7829170

File tree

4 files changed

+41
-13
lines changed

4 files changed

+41
-13
lines changed

test/Ctx.t.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ contract CtxTest is EulerSwapTestBase {
1414
}
1515

1616
function test_staticParamSize() public view {
17-
IEulerSwap.Params memory params = getEulerSwapParams(1e18, 1e18, 1e18, 1e18, 0.4e18, 0.85e18, 0);
17+
IEulerSwap.Params memory params = getEulerSwapParams(1e18, 1e18, 1e18, 1e18, 0.4e18, 0.85e18, 0, 0, address(0));
1818
assertEq(abi.encode(params).length, 384);
1919
}
2020
}

test/EulerSwapTestBase.t.sol

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -129,10 +129,24 @@ contract EulerSwapTestBase is EVaultTestBase {
129129
uint256 py,
130130
uint256 cx,
131131
uint256 cy
132+
) internal returns (EulerSwap) {
133+
return createEulerSwapFull(reserve0, reserve1, fee, px, py, cx, cy, 0, address(0));
134+
}
135+
136+
function createEulerSwapFull(
137+
uint112 reserve0,
138+
uint112 reserve1,
139+
uint256 fee,
140+
uint256 px,
141+
uint256 py,
142+
uint256 cx,
143+
uint256 cy,
144+
uint256 protocolFee,
145+
address protcoolFeeRecipient
132146
) internal returns (EulerSwap) {
133147
removeInstalledOperator();
134148

135-
IEulerSwap.Params memory params = getEulerSwapParams(reserve0, reserve1, px, py, cx, cy, fee);
149+
IEulerSwap.Params memory params = getEulerSwapParams(reserve0, reserve1, px, py, cx, cy, fee, protocolFee, protcoolFeeRecipient);
136150
IEulerSwap.InitialState memory initialState =
137151
IEulerSwap.InitialState({currReserve0: reserve0, currReserve1: reserve1});
138152

@@ -158,10 +172,24 @@ contract EulerSwapTestBase is EVaultTestBase {
158172
uint256 py,
159173
uint256 cx,
160174
uint256 cy
175+
) internal returns (EulerSwap) {
176+
return createEulerSwapHookFull(reserve0, reserve1, fee, px, py, cx, cy, 0, address(0));
177+
}
178+
179+
function createEulerSwapHookFull(
180+
uint112 reserve0,
181+
uint112 reserve1,
182+
uint256 fee,
183+
uint256 px,
184+
uint256 py,
185+
uint256 cx,
186+
uint256 cy,
187+
uint256 protocolFee,
188+
address protocolFeeRecipient
161189
) internal returns (EulerSwap) {
162190
removeInstalledOperator();
163191

164-
IEulerSwap.Params memory params = getEulerSwapParams(reserve0, reserve1, px, py, cx, cy, fee);
192+
IEulerSwap.Params memory params = getEulerSwapParams(reserve0, reserve1, px, py, cx, cy, fee, protocolFee, protocolFeeRecipient);
165193
IEulerSwap.InitialState memory initialState =
166194
IEulerSwap.InitialState({currReserve0: reserve0, currReserve1: reserve1});
167195

@@ -235,7 +263,9 @@ contract EulerSwapTestBase is EVaultTestBase {
235263
uint256 py,
236264
uint256 cx,
237265
uint256 cy,
238-
uint256 fee
266+
uint256 fee,
267+
uint256 protocolFee,
268+
address protocolFeeRecipient
239269
) internal view returns (EulerSwap.Params memory) {
240270
return IEulerSwap.Params({
241271
vault0: address(eTST),
@@ -248,8 +278,8 @@ contract EulerSwapTestBase is EVaultTestBase {
248278
concentrationX: cx,
249279
concentrationY: cy,
250280
fee: fee,
251-
protocolFee: 0,
252-
protocolFeeRecipient: address(0)
281+
protocolFee: protocolFee,
282+
protocolFeeRecipient: protocolFeeRecipient
253283
});
254284
}
255285

test/FactoryTest.t.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ contract FactoryTest is EulerSwapTestBase {
2828
view
2929
returns (IEulerSwap.Params memory poolParams, IEulerSwap.InitialState memory initialState)
3030
{
31-
poolParams = getEulerSwapParams(1e18, 1e18, 1e18, 1e18, 0.4e18, 0.85e18, 0);
31+
poolParams = getEulerSwapParams(1e18, 1e18, 1e18, 1e18, 0.4e18, 0.85e18, 0, 0, address(0));
3232
initialState = IEulerSwap.InitialState({currReserve0: 1e18, currReserve1: 1e18});
3333
}
3434

test/HookFees.t.sol

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -124,16 +124,14 @@ contract HookFeesTest is EulerSwapTestBase {
124124
}
125125

126126
function test_protocolFee() public {
127-
IEulerSwap.Params memory params = eulerSwap.getParams();
128-
vm.prank(params.eulerAccount);
129-
eulerSwapFactory.uninstallPool();
130-
131127
// set protocol fee to 10% of the LP fee
132-
eulerSwapFactory.setProtocolFee(0.1e18);
128+
uint256 protocolFee = 0.1e18;
129+
130+
eulerSwapFactory.setProtocolFee(protocolFee);
133131
eulerSwapFactory.setProtocolFeeRecipient(protocolFeeRecipient);
134132

135133
// set swap fee to 10 bips and activate the pool
136-
eulerSwap = createEulerSwapHook(60e18, 60e18, 0.001e18, 1e18, 1e18, 0.4e18, 0.85e18);
134+
eulerSwap = createEulerSwapHookFull(60e18, 60e18, 0.001e18, 1e18, 1e18, 0.4e18, 0.85e18, protocolFee, protocolFeeRecipient);
137135

138136
int256 origNav = getHolderNAV();
139137
(uint112 r0, uint112 r1,) = eulerSwap.getReserves();

0 commit comments

Comments
 (0)