-
Notifications
You must be signed in to change notification settings - Fork 127
/
Copy pathIPool.sol
63 lines (51 loc) · 3.33 KB
/
IPool.sol
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
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity >=0.5.0;
pragma experimental ABIEncoderV2;
/// @notice Trident pool interface.
interface IPool {
/// @notice Executes a swap from one token to another.
/// @dev The input tokens must've already been sent to the pool.
/// @param data ABI-encoded params that the pool requires.
/// @return finalAmountOut The amount of output tokens that were sent to the user.
function swap(bytes calldata data) external returns (uint256 finalAmountOut);
/// @notice Executes a swap from one token to another with a callback.
/// @dev This function allows borrowing the output tokens and sending the input tokens in the callback.
/// @param data ABI-encoded params that the pool requires.
/// @return finalAmountOut The amount of output tokens that were sent to the user.
function flashSwap(bytes calldata data) external returns (uint256 finalAmountOut);
/// @notice Mints liquidity tokens.
/// @param data ABI-encoded params that the pool requires.
/// @return liquidity The amount of liquidity tokens that were minted for the user.
function mint(bytes calldata data) external returns (uint256 liquidity);
/// @notice Burns liquidity tokens.
/// @dev The input LP tokens must've already been sent to the pool.
/// @param data ABI-encoded params that the pool requires.
/// @return withdrawnAmounts The amount of various output tokens that were sent to the user.
function burn(bytes calldata data) external returns (TokenAmount[] memory withdrawnAmounts);
/// @notice Burns liquidity tokens for a single output token.
/// @dev The input LP tokens must've already been sent to the pool.
/// @param data ABI-encoded params that the pool requires.
/// @return amountOut The amount of output tokens that were sent to the user.
function burnSingle(bytes calldata data) external returns (uint256 amountOut);
/// @return A unique identifier for the pool type.
function poolIdentifier() external pure returns (bytes32);
/// @return An array of tokens supported by the pool.
function getAssets() external view returns (address[] memory);
/// @notice Simulates a trade and returns the expected output.
/// @dev The pool does not need to include a trade simulator directly in itself - it can use a library.
/// @param data ABI-encoded params that the pool requires.
/// @return finalAmountOut The amount of output tokens that will be sent to the user if the trade is executed.
function getAmountOut(bytes calldata data) external view returns (uint256 finalAmountOut);
/// @notice Simulates a trade and returns the expected output.
/// @dev The pool does not need to include a trade simulator directly in itself - it can use a library.
/// @param data ABI-encoded params that the pool requires.
/// @return finalAmountIn The amount of input tokens that are required from the user if the trade is executed.
function getAmountIn(bytes calldata data) external view returns (uint256 finalAmountIn);
/// @dev This event must be emitted on all swaps.
event Swap(address indexed recipient, address indexed tokenIn, address indexed tokenOut, uint256 amountIn, uint256 amountOut);
/// @dev This struct frames output tokens for burns.
struct TokenAmount {
address token;
uint256 amount;
}
}