Skip to content

Commit 74c88f7

Browse files
authored
Merge pull request #49 from KyberNetwork/update-selector
feat: update interaction selector
2 parents 6c0e85b + 5d1d0d6 commit 74c88f7

File tree

3 files changed

+76
-9
lines changed

3 files changed

+76
-9
lines changed

src/KSSmartIntentRouter.sol

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ import {KSSmartIntentRouterAccounting} from './KSSmartIntentRouterAccounting.sol
66
import {KSSmartIntentRouterNonces} from './KSSmartIntentRouterNonces.sol';
77

88
import {IKSSmartIntentRouter} from './interfaces/IKSSmartIntentRouter.sol';
9+
import {IKSAllowanceHub} from './interfaces/actions/IKSAllowanceHub.sol';
910
import {IKSSwapRouterV2} from './interfaces/actions/IKSSwapRouterV2.sol';
1011
import {IKSSwapRouterV3} from './interfaces/actions/IKSSwapRouterV3.sol';
1112
import {IKSZapRouter} from './interfaces/actions/IKSZapRouter.sol';
12-
1313
import {HookLibrary} from './libraries/HookLibrary.sol';
1414

1515
import {ActionData} from './types/ActionData.sol';
@@ -212,6 +212,7 @@ contract KSSmartIntentRouter is
212212
selector == IKSSwapRouterV2.swap.selector
213213
|| selector == IKSSwapRouterV2.swapSimpleMode.selector
214214
|| selector == IKSSwapRouterV3.swap.selector || selector == IKSZapRouter.zap.selector
215+
|| selector == IKSAllowanceHub.permitTransferAndExecute.selector
215216
) {
216217
return IKSGenericForwarder(address(0));
217218
}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/// @title IKSAllowanceHub
2+
pragma solidity ^0.8.0;
3+
4+
/// @notice Interface for the KSAllowanceHub
5+
interface IKSAllowanceHub {
6+
/**
7+
* @notice Parameters for collecting ERC20 tokens from `msg.sender`
8+
* @param token The address of the tokens to collect
9+
* @param targets The addresses to transfer the tokens to
10+
* @param amounts The amounts to transfer to each target
11+
* @param permitData The permit data for the tokens
12+
*/
13+
struct ERC20Params {
14+
address token;
15+
address[] targets;
16+
uint256[] amounts;
17+
bytes permitData;
18+
}
19+
20+
/**
21+
* @notice Parameters for collecting an ERC721 token from `msg.sender`
22+
* @param token The address of the token to collect
23+
* @param tokenId The token ID to collect
24+
* @param target The address to transfer the token to
25+
* @param permitData The permit data for the token
26+
*/
27+
struct ERC721Params {
28+
address token;
29+
uint256 tokenId;
30+
address target;
31+
bytes permitData;
32+
}
33+
34+
/**
35+
* @notice Parameters for calling a generic router
36+
* @param router The address of the router
37+
* @param value The value to send along with the call
38+
* @param data The data to call the generic router with
39+
*/
40+
struct GenericCall {
41+
address router;
42+
uint256 value;
43+
bytes data;
44+
}
45+
46+
/**
47+
* @notice Permits, transfers ERC20 and ERC721 tokens, executes generic calls
48+
* @param erc20Params The ERC20 tokens to transfer
49+
* @param erc721Params The ERC721 tokens to transfer
50+
* @param genericCalls The generic calls to execute
51+
* @return results The results of the generic calls
52+
* @return gasUsed The amount of gas used
53+
*/
54+
function permitTransferAndExecute(
55+
ERC20Params[] calldata erc20Params,
56+
ERC721Params[] calldata erc721Params,
57+
GenericCall[] calldata genericCalls
58+
) external payable returns (bytes[] memory results, uint256 gasUsed);
59+
}

src/interfaces/actions/IKSSwapRouterV3.sol

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,12 @@ interface IKSSwapRouterV3 {
99
/// @param targets The targets to transfer the input token to
1010
/// @param amounts The amounts to transfer to the targets
1111
struct InputTokenData {
12-
// length = 5 * 32: IERC20Permit, use ERC20 `transferFrom`
13-
// length = 6 * 32: IDaiLikePermit, use ERC20 `transferFrom`
14-
// length = 0: use ERC20 `transferFrom`
15-
// otherwise: use Permit2 `transferFrom`
12+
// Permit method selection:
13+
// length = 5 * 32: use ERC20 `permit`
14+
// length = 6 * 32: use DAI `permit`
15+
// Transfer method selection:
16+
// length == 0: use Permit2 `transferFrom`
17+
// length != 0: use ERC20 `transferFrom`
1618
bytes permitData;
1719
address[] feeRecipients;
1820
uint256[] fees;
@@ -31,32 +33,37 @@ interface IKSSwapRouterV3 {
3133
}
3234

3335
/// @notice Contains the parameters for a swap
34-
/// @param permit2Data The data to call permit2 with
3536
/// @param inputTokens The input tokens
36-
/// @param inputAmounts The input amounts
37+
/// @param inputAmounts The input amounts (only used for fee calculation)
3738
/// @param inputData The additional data for the input tokens
3839
/// @param outputTokens The output tokens
3940
/// @param outputData The additional data for the output tokens
41+
/// @param permit2Data The data to call permit2 with
4042
/// @param executor The executor to call
4143
/// @param executorData The data to pass to the executor
4244
/// @param recipient The recipient of the output tokens
45+
/// @param deadline The deadline for the swap
4346
/// @param clientData The client data
4447
struct SwapParams {
45-
bytes permit2Data;
4648
address[] inputTokens;
4749
uint256[] inputAmounts;
4850
InputTokenData[] inputData;
4951
address[] outputTokens;
5052
OutputTokenData[] outputData;
53+
bytes permit2Data;
5154
address executor;
5255
bytes executorData;
5356
address recipient;
57+
uint256 deadline;
5458
bytes clientData;
5559
}
5660

5761
/// @notice Entry point for swapping
5862
/// @param params The parameters for the swap
59-
function swap(SwapParams calldata params) external payable;
63+
function swap(SwapParams calldata params)
64+
external
65+
payable
66+
returns (uint256[] memory outputAmounts, uint256 gasUsed);
6067

6168
/// @notice Returns the address of who called the swap function
6269
function msgSender() external view returns (address);

0 commit comments

Comments
 (0)