-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathIRouter.sol
More file actions
113 lines (104 loc) · 4.41 KB
/
IRouter.sol
File metadata and controls
113 lines (104 loc) · 4.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.8.0;
pragma abicoder v2;
import '../callback/ISwapCallback.sol';
/// @notice Functions for swapping tokens via KyberSwap v2
/// - Support swap with exact input or exact output
/// - Support swap with a price limit
/// - Support swap within a single pool and between multiple pools
interface IRouter is ISwapCallback {
/// @dev Params for swapping exact input amount
/// @param tokenIn the token to swap
/// @param tokenOut the token to receive
/// @param fee the pool's fee
/// @param recipient address to receive tokenOut
/// @param deadline time that the transaction will be expired
/// @param amountIn the tokenIn amount to swap
/// @param amountOutMinimum the minimum receive amount
/// @param limitSqrtP the price limit, if reached, stop swapping
struct ExactInputSingleParams {
address tokenIn;
address tokenOut;
uint24 fee;
address recipient;
uint256 deadline;
uint256 amountIn;
uint256 minAmountOut;
uint160 limitSqrtP;
}
/// @notice Swaps `amountIn` of one token for as much as possible of another token
/// @param params The parameters necessary for the swap, encoded as `ExactInputSingleParams` in calldata
/// @return amountOut The amount of the received token
function swapExactInputSingle(ExactInputSingleParams calldata params)
external
payable
returns (uint256 amountOut);
/// @dev Params for swapping exact input using multiple pools
/// @param path the encoded path to swap from tokenIn to tokenOut
/// If the swap is from token0 -> token1 -> token2, then path is encoded as [token0, fee01, token1, fee12, token2]
/// @param recipient address to receive tokenOut
/// @param deadline time that the transaction will be expired
/// @param amountIn the tokenIn amount to swap
/// @param amountOutMinimum the minimum receive amount
struct ExactInputParams {
bytes path;
address recipient;
uint256 deadline;
uint256 amountIn;
uint256 minAmountOut;
}
/// @notice Swaps `amountIn` of one token for as much as possible of another along the specified path
/// @param params The parameters necessary for the multi-hop swap, encoded as `ExactInputParams` in calldata
/// @return amountOut The amount of the received token
function swapExactInput(ExactInputParams calldata params)
external
payable
returns (uint256 amountOut);
/// @dev Params for swapping exact output amount
/// @param tokenIn the token to swap
/// @param tokenOut the token to receive
/// @param fee the pool's fee
/// @param recipient address to receive tokenOut
/// @param deadline time that the transaction will be expired
/// @param amountOut the tokenOut amount of tokenOut
/// @param amountInMaximum the minimum input amount
/// @param limitSqrtP the price limit, if reached, stop swapping
struct ExactOutputSingleParams {
address tokenIn;
address tokenOut;
uint24 fee;
address recipient;
uint256 deadline;
uint256 amountOut;
uint256 maxAmountIn;
uint160 limitSqrtP;
}
/// @notice Swaps as little as possible of one token for `amountOut` of another token
/// @param params The parameters necessary for the swap, encoded as `ExactOutputSingleParams` in calldata
/// @return amountIn The amount of the input token
function swapExactOutputSingle(ExactOutputSingleParams calldata params)
external
payable
returns (uint256 amountIn);
/// @dev Params for swapping exact output using multiple pools
/// @param path the encoded path to swap from tokenIn to tokenOut
/// If the swap is from token0 -> token1 -> token2, then path is encoded as [token2, fee12, token1, fee01, token0]
/// @param recipient address to receive tokenOut
/// @param deadline time that the transaction will be expired
/// @param amountOut the tokenOut amount of tokenOut
/// @param amountInMaximum the minimum input amount
struct ExactOutputParams {
bytes path;
address recipient;
uint256 deadline;
uint256 amountOut;
uint256 maxAmountIn;
}
/// @notice Swaps as little as possible of one token for `amountOut` of another along the specified path (reversed)
/// @param params The parameters necessary for the multi-hop swap, encoded as `ExactOutputParams` in calldata
/// @return amountIn The amount of the input token
function swapExactOutput(ExactOutputParams calldata params)
external
payable
returns (uint256 amountIn);
}