Skip to content

Commit 0f79a36

Browse files
committed
fix: change fee and event naming
1 parent e212248 commit 0f79a36

10 files changed

+42
-49
lines changed

src/interfaces/IKSSmartIntentRouter.sol

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -64,23 +64,14 @@ interface IKSSmartIntentRouter {
6464
event ExtraData(bytes32 indexed intentHash, bytes extraData);
6565

6666
/// @notice Emitted when the fee is collected before execution
67-
event CollectFeeBeforeExecution(
67+
event RecordVolumeAndFees(
6868
address indexed token,
6969
address indexed protocolRecipient,
7070
address indexed partnerRecipient,
71+
bool beforeExecution,
7172
uint256 totalAmount,
72-
uint256 protocolFee,
73-
uint256 partnerFee
74-
);
75-
76-
/// @notice Emitted when the fee is collected after execution
77-
event CollectFeeAfterExecution(
78-
address indexed token,
79-
address indexed protocolRecipient,
80-
address indexed partnerRecipient,
81-
uint256 totalAmount,
82-
uint256 protocolFee,
83-
uint256 partnerFee
73+
uint256 protocolFeeAmount,
74+
uint256 partnerFeeAmount
8475
);
8576

8677
enum IntentStatus {

src/types/ERC20Data.sol

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -61,17 +61,17 @@ library ERC20DataLibrary {
6161
}
6262

6363
address protocolRecipient = feeInfo.protocolRecipient();
64-
(uint256 protocolFee, uint256 partnerFee) = feeInfo.computeFee(fee);
64+
(uint256 protocolFeeAmount, uint256 partnerFeeAmount) = feeInfo.computeFees(fee);
6565

6666
if (feeInfo.feeMode()) {
6767
token.safeTransferFrom(mainAddress, protocolRecipient, fee);
6868
} else {
69-
token.safeTransferFrom(mainAddress, protocolRecipient, protocolFee);
70-
token.safeTransferFrom(mainAddress, partnerRecipient, partnerFee);
69+
token.safeTransferFrom(mainAddress, protocolRecipient, protocolFeeAmount);
70+
token.safeTransferFrom(mainAddress, partnerRecipient, partnerFeeAmount);
7171
}
7272

73-
emit IKSSmartIntentRouter.CollectFeeBeforeExecution(
74-
token, protocolRecipient, partnerRecipient, amount, protocolFee, partnerFee
73+
emit IKSSmartIntentRouter.RecordVolumeAndFees(
74+
token, protocolRecipient, partnerRecipient, true, amount, protocolFeeAmount, partnerFeeAmount
7575
);
7676
}
7777

@@ -83,17 +83,17 @@ library ERC20DataLibrary {
8383
address partnerRecipient
8484
) internal {
8585
address protocolRecipient = feeInfo.protocolRecipient();
86-
(uint256 protocolFee, uint256 partnerFee) = feeInfo.computeFee(fee);
86+
(uint256 protocolFeeAmount, uint256 partnerFeeAmount) = feeInfo.computeFees(fee);
8787

8888
if (feeInfo.feeMode()) {
8989
token.safeTransfer(protocolRecipient, fee);
9090
} else {
91-
token.safeTransfer(protocolRecipient, protocolFee);
92-
token.safeTransfer(partnerRecipient, partnerFee);
91+
token.safeTransfer(protocolRecipient, protocolFeeAmount);
92+
token.safeTransfer(partnerRecipient, partnerFeeAmount);
9393
}
9494

95-
emit IKSSmartIntentRouter.CollectFeeAfterExecution(
96-
token, protocolRecipient, partnerRecipient, amount, protocolFee, partnerFee
95+
emit IKSSmartIntentRouter.RecordVolumeAndFees(
96+
token, protocolRecipient, partnerRecipient, false, amount, protocolFeeAmount, partnerFeeAmount
9797
);
9898
}
9999

src/types/FeeInfo.sol

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ import '../libraries/BitMask.sol';
66
/**
77
* @notice FeeInfo is packed version of solidity structure.
88
*
9-
* Layout: 1 bit feeMode | 24 bits protocolBps
9+
* Layout: 1 bit feeMode | 24 bits protocolFee | 160 bits protocolRecipient
1010
*/
1111
type FeeInfo is uint256;
1212

1313
struct FeeInfoBuildParams {
1414
bool feeMode;
15-
uint24 protocolBps;
15+
uint24 protocolFee;
1616
address protocolRecipient;
1717
}
1818

@@ -31,9 +31,9 @@ library FeeInfoLibrary {
3131
}
3232
}
3333

34-
function protocolBps(FeeInfo self) internal pure returns (uint24 _protocolBps) {
34+
function protocolFee(FeeInfo self) internal pure returns (uint24 _protocolFee) {
3535
assembly ("memory-safe") {
36-
_protocolBps := and(shr(PROTOCOL_BPS_OFFSET, self), MASK_24_BITS)
36+
_protocolFee := and(shr(PROTOCOL_BPS_OFFSET, self), MASK_24_BITS)
3737
}
3838
}
3939

@@ -43,25 +43,25 @@ library FeeInfoLibrary {
4343
}
4444
}
4545

46-
function computeFee(FeeInfo self, uint256 totalAmount)
46+
function computeFees(FeeInfo self, uint256 totalAmount)
4747
internal
4848
pure
49-
returns (uint256 protocolFee, uint256 partnerFee)
49+
returns (uint256 protocolFeeAmount, uint256 partnerFeeAmount)
5050
{
5151
unchecked {
52-
protocolFee = totalAmount * self.protocolBps() / FEE_DENOMINATOR;
53-
partnerFee = totalAmount - protocolFee;
52+
protocolFeeAmount = totalAmount * self.protocolFee() / FEE_DENOMINATOR;
53+
partnerFeeAmount = totalAmount - protocolFeeAmount;
5454
}
5555
}
5656

5757
function build(FeeInfoBuildParams memory params) internal pure returns (FeeInfo feeInfo) {
5858
bool _feeMode = params.feeMode;
59-
uint24 _protocolBps = params.protocolBps;
59+
uint24 _protocolFee = params.protocolFee;
6060
address _protocolRecipient = params.protocolRecipient;
6161

6262
assembly ("memory-safe") {
6363
feeInfo := or(feeInfo, shl(FEE_MODE_OFFSET, _feeMode))
64-
feeInfo := or(feeInfo, shl(PROTOCOL_BPS_OFFSET, _protocolBps))
64+
feeInfo := or(feeInfo, shl(PROTOCOL_BPS_OFFSET, _protocolFee))
6565
feeInfo := or(feeInfo, _protocolRecipient)
6666
}
6767
}

test/ConditionalSwap.t.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,7 @@ contract ConditionalSwapTest is BaseTest {
464464
erc721Ids: new uint256[](0),
465465
feeInfo: FeeInfoBuildParams({
466466
feeMode: false,
467-
protocolBps: 1e6,
467+
protocolFee: 1e6,
468468
protocolRecipient: protocolRecipient
469469
}).build(),
470470
partnerRecipient: partnerRecipient,
@@ -563,7 +563,7 @@ contract ConditionalSwapTest is BaseTest {
563563
erc721Ids: new uint256[](0),
564564
feeInfo: FeeInfoBuildParams({
565565
feeMode: false,
566-
protocolBps: 1e6,
566+
protocolFee: 1e6,
567567
protocolRecipient: protocolRecipient
568568
}).build(),
569569
partnerRecipient: partnerRecipient,

test/MockAction.t.sol

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -404,27 +404,29 @@ contract MockActionTest is BaseTest {
404404

405405
FeeInfo feeInfo = FeeInfoBuildParams({
406406
feeMode: seed % 2 == 0,
407-
protocolBps: uint24(bound(seed, 0, 1e6)),
407+
protocolFee: uint24(bound(seed, 0, 1e6)),
408408
protocolRecipient: protocolRecipient
409409
}).build();
410410

411-
(uint256 protocolFeeBefore, uint256 partnerFeeBefore) = feeInfo.computeFee(feesBefore[0]);
411+
(uint256 protocolFeeBefore, uint256 partnerFeeBefore) = feeInfo.computeFees(feesBefore[0]);
412412
vm.expectEmit(true, true, true, true);
413-
emit IKSSmartIntentRouter.CollectFeeBeforeExecution(
413+
emit IKSSmartIntentRouter.RecordVolumeAndFees(
414414
address(erc20Mock),
415415
protocolRecipient,
416416
partnerRecipient,
417+
true,
417418
actionData.erc20Amounts[0],
418419
protocolFeeBefore,
419420
partnerFeeBefore
420421
);
421422

422-
(uint256 protocolFeeAfter, uint256 partnerFeeAfter) = feeInfo.computeFee(feesAfter[0]);
423+
(uint256 protocolFeeAfter, uint256 partnerFeeAfter) = feeInfo.computeFees(feesAfter[0]);
423424
vm.expectEmit(true, true, true, true);
424-
emit IKSSmartIntentRouter.CollectFeeAfterExecution(
425+
emit IKSSmartIntentRouter.RecordVolumeAndFees(
425426
address(erc20Mock),
426427
protocolRecipient,
427428
partnerRecipient,
429+
false,
428430
amounts[0] + feesAfter[0],
429431
protocolFeeAfter,
430432
partnerFeeAfter
@@ -513,7 +515,7 @@ contract MockActionTest is BaseTest {
513515

514516
FeeInfo feeInfo = FeeInfoBuildParams({
515517
feeMode: seed % 2 == 0,
516-
protocolBps: uint24(bound(seed, 0, 1e6)),
518+
protocolFee: uint24(bound(seed, 0, 1e6)),
517519
protocolRecipient: protocolRecipient
518520
}).build();
519521

test/RemoveLiquidityPancakeV4CL.t.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ contract RemoveLiquidityPancakeV4CLTest is BaseTest {
235235
erc721Ids: [uint256(0)].toMemoryArray(),
236236
feeInfo: FeeInfoBuildParams({
237237
feeMode: false,
238-
protocolBps: 1e6,
238+
protocolFee: 1e6,
239239
protocolRecipient: protocolRecipient
240240
}).build(),
241241
partnerRecipient: partnerRecipient,
@@ -503,7 +503,7 @@ contract RemoveLiquidityPancakeV4CLTest is BaseTest {
503503
erc721Ids: [uint256(0)].toMemoryArray(),
504504
feeInfo: FeeInfoBuildParams({
505505
feeMode: false,
506-
protocolBps: 1e6,
506+
protocolFee: 1e6,
507507
protocolRecipient: protocolRecipient
508508
}).build(),
509509
partnerRecipient: partnerRecipient,

test/RemoveLiquidityUniswapV3.t.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ contract RemoveLiquidityUniswapV3Test is BaseTest {
282282
erc721Ids: [uint256(0)].toMemoryArray(),
283283
feeInfo: FeeInfoBuildParams({
284284
feeMode: false,
285-
protocolBps: 1e6,
285+
protocolFee: 1e6,
286286
protocolRecipient: protocolRecipient
287287
}).build(),
288288
partnerRecipient: partnerRecipient,
@@ -608,7 +608,7 @@ contract RemoveLiquidityUniswapV3Test is BaseTest {
608608
erc721Ids: [uint256(0)].toMemoryArray(),
609609
feeInfo: FeeInfoBuildParams({
610610
feeMode: false,
611-
protocolBps: 1e6,
611+
protocolFee: 1e6,
612612
protocolRecipient: protocolRecipient
613613
}).build(),
614614
partnerRecipient: partnerRecipient,

test/RemoveLiquidityUniswapV4.t.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ contract RemoveLiquidityUniswapV4Test is BaseTest {
322322
erc721Ids: [uint256(0)].toMemoryArray(),
323323
feeInfo: FeeInfoBuildParams({
324324
feeMode: false,
325-
protocolBps: 1e6,
325+
protocolFee: 1e6,
326326
protocolRecipient: protocolRecipient
327327
}).build(),
328328
partnerRecipient: partnerRecipient,
@@ -742,7 +742,7 @@ contract RemoveLiquidityUniswapV4Test is BaseTest {
742742
erc721Ids: [uint256(0)].toMemoryArray(),
743743
feeInfo: FeeInfoBuildParams({
744744
feeMode: false,
745-
protocolBps: 1e6,
745+
protocolFee: 1e6,
746746
protocolRecipient: protocolRecipient
747747
}).build(),
748748
partnerRecipient: partnerRecipient,

test/ZapOutUniswapV2.t.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ contract ZapOutUniswapV2Test is BaseTest {
144144
erc721Ids: new uint256[](0),
145145
feeInfo: FeeInfoBuildParams({
146146
feeMode: false,
147-
protocolBps: 1e6,
147+
protocolFee: 1e6,
148148
protocolRecipient: protocolRecipient
149149
}).build(),
150150
partnerRecipient: partnerRecipient,

test/ZapOutUniswapV3.t.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ contract ZapOutUniswapV3Test is BaseTest {
132132
erc721Ids: [uint256(0)].toMemoryArray(),
133133
feeInfo: FeeInfoBuildParams({
134134
feeMode: false,
135-
protocolBps: 1e6,
135+
protocolFee: 1e6,
136136
protocolRecipient: protocolRecipient
137137
}).build(),
138138
partnerRecipient: partnerRecipient,

0 commit comments

Comments
 (0)