-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathIUlyssesRouter.sol
106 lines (95 loc) · 9.06 KB
/
IUlyssesRouter.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
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
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import {UlyssesFactory} from "../factories/UlyssesFactory.sol";
/**
* @title Ulysses Router - Handles routing of transactions in the Ulysses AMM
* @author Maia DAO (https://github.com/Maia-DAO)
* @notice This contract routes and adds/removes liquidity from Ulysses Pools
* deployed by the Ulysses Factory, it allows users to set maximum slippage.
* ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣠⠞⠉⢀⣶⠞⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠑⠢⣝⣦⠀⠀⠀⠀⠀⠀⠀⠀⠀
* ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣠⠞⠁⠀⢠⣿⠋⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠻⣷⡀⠀⠀⠀⠀⠀⠀⠀
* ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⡴⠞⠁⠀⠀⢠⣿⠃⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠠⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠘⢷⡄⠀⠀⠀⠀⠀⠀
* ⠀⠀⠀⠀⠀⠀⠀⠀⢀⡴⠋⠀⠀⠀⠀⢀⣿⠃⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠹⣆⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⢻⡄⠀⠀⠀⠀⠀
* ⠀⠀⠀⠀⠀⠀⠀⠀⣸⠁⢀⡴⠃⠀⠀⣼⠇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠘⣷⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢧⡀⠀⠀⢻⡄⠀⠀⠀⠀
* ⠀⠀⠀⠀⠀⠀⠀⢰⡏⢠⠞⠀⠀⠀⢠⡟⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡄⠀⠀⠀⢹⣆⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠙⣄⠀⠀⢳⠀⠀⠀⠀
* ⠀⠀⠀⠀⠀⠀⠀⣼⣱⠋⠀⠀⠀⠀⠸⠀⠀⢀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⢰⠀⠀⠀⣿⡄⠀⠀⠀⠀⠀⠐⠦⡀⠀⠀⠀⠀⠀⠀⠀⠸⣧⠀⠸⡇⠀⠀⠀
* ⠀⠀⠀⠀⠀⠀⠀⣿⠇⠀⠀⠀⠀⠀⠀⠀⢀⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣸⡇⢸⠀⠀⠀⣿⣷⣄⠀⠀⠀⠀⠀⠀⠈⢦⡀⠀⠀⠀⠀⠀⠀⠸⣧⢀⣇⠀⠀⠀
* ⠀⠀⠀⠀⠀⠀⢸⠯⠀⠀⠀⠀⠀⠀⠀⠀⣼⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣇⠈⡇⠀⠀⢻⡀⠙⠷⣄⠀⠀⠀⠀⠀⠀⠹⣦⠀⠀⠀⠀⠀⠀⣿⣿⣿⡆⠀⠀
* ⠀⠀⠀⠀⠀⢠⡟⠀⠀⠀⢀⡄⠀⠀⠀⢠⡏⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣽⠇⢻⡄⡇⠀⠀⢸⣷⡀⠀⠈⠳⢄⠀⠀⠀⠀⠀⠘⣆⠀⠀⠀⠀⠀⢨⣿⣿⣇⠀⠀
* ⠀⠀⠀⠀⠀⡞⠀⠀⠀⢀⡞⠀⠀⠀⠀⣾⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⠀⣿⠀⠘⣇⡇⠀⠀⢸⡌⠻⣷⣤⡀⠀⠉⠀⠀⠀⠀⠀⠘⣧⠀⠀⠀⠀⣿⣿⣿⣿⡀⠀
* ⠀⠀⠀⠀⣼⠁⠀⠀⠀⣼⠃⠀⠀⠀⢠⣧⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⡇⣰⡟⠀⠀⢹⡇⠀⠀⣼⠇⠀⠸⣍⠉⠙⠶⢤⣀⡀⠀⠀⠀⠘⡆⠀⠀⢠⣿⣿⣿⣿⡇⠀
* ⠀⠀⠀⢰⣣⠃⢰⠁⢀⡇⠀⠀⠀⠀⢸⣽⠀⢠⠃⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣼⢠⠏⡇⠀⠀⠸⡇⠀⠀⢻⠀⠀⠀⠈⢿⡲⢄⠀⠀⠈⣄⠀⠀⠀⠸⡆⠀⢸⣿⣿⣿⣿⡇⠀
* ⠀⠀⢠⣧⡟⠀⡼⠀⢸⠀⠀⠀⠀⠀⣿⡿⡄⢸⠀⠀⠀⠀⠀⢸⠀⠀⠀⠀⢀⣏⡟⢰⠇⠀⠀⢰⠇⠀⢰⣾⠀⠀⠀⠀⠀⢸⣟⣦⣄⠀⠈⠻⣧⣄⠀⠹⠀⢸⣿⣿⣿⣿⣿⠀
* ⠀⠰⡫⢻⠁⢰⡇⠀⡞⠀⢠⠂⢀⠀⡿⠀⡇⠘⡆⠀⠀⠀⠀⠘⣆⠀⠀⠀⢸⡿⠀⣾⠀⠀⠀⢸⢀⠀⣼⣾⠀⠀⠀⠀⠀⠀⠻⣌⠙⠿⣦⡀⠘⢿⣦⠀⠀⢸⣿⣿⣿⣿⣿⠀
* ⠀⠀⠀⣼⠀⣾⠃⢰⡇⠀⡞⠀⢸⠀⡇⠀⢻⡄⡇⠀⠀⠀⠀⠀⢻⠀⠀⠀⣿⠁⠀⡏⠀⠀⠀⣸⡎⢠⡏⢏⡆⠀⠀⠀⠀⠀⠀⠙⢯⡶⣄⡈⠒⠀⠹⣧⠀⢻⣿⣿⣿⣿⣿⠀
* ⠀⠀⠀⡇⢰⣿⠀⣼⡇⢠⡇⠀⢸⡄⡇⠀⠀⢻⣻⡀⠰⡀⠀⠀⠈⣇⠀⢸⡟⠓⢺⠓⠶⠦⢤⣿⢁⣾⣀⣈⣻⡀⠀⠀⠀⠀⠀⠀⠈⢿⡑⠛⠷⣤⠀⠘⠄⠀⢻⣿⣿⣿⣿⠀
* ⠀⠀⠀⡇⡾⢯⠀⣿⡇⢸⡇⠀⢸⣇⡧⠤⠤⠒⠻⣇⠀⢳⡀⠀⠀⠸⡆⢸⠁⠀⡞⠀⠀⠀⣸⢇⠞⠁⠀⠀⠈⠳⠄⠀⠀⠀⠀⠀⠀⢀⣽⣍⢓⣮⣷⣄⡀⠀⠀⠻⣿⣿⡇⠀
* ⠀⠀⠀⣇⡇⢸⠀⡿⣇⢸⣧⠀⢸⢿⣳⠀⣀⣀⡀⠙⣦⠈⣷⡄⠀⠀⠹⣼⠀⣰⠃⠀⠔⢺⣏⣉⣩⣽⣂⣀⠀⠀⠀⠀⠀⠀⠀⠀⣠⠊⣤⣾⠛⢁⣴⣮⣷⠀⠀⠀⠯⠿⡇⠀
* ⠀⠀⠀⢹⡇⠘⣧⣧⣹⣜⢿⠀⣾⣀⢻⣷⣭⣭⣍⣑⠊⢧⡘⡟⢦⡀⠀⠹⡤⠃⠀⢀⣀⣬⡿⢿⣿⣿⣿⣿⣿⣶⣶⣤⣤⠀⠀⢰⢇⡾⠉⣠⠞⠛⡏⠹⣽⡇⠀⠀⠀⠀⣿⠀
* ⠀⠀⠀⠀⢳⡼⠋⣻⣿⠉⠻⣇⣿⡿⣿⡟⢻⠿⣿⣿⣿⣭⡳⣿⣄⠙⢾⣦⡹⣄⠀⠀⠀⠀⠀⠀⣥⣼⠛⣿⣿⣿⣿⣹⠏⠀⢀⣿⡞⠀⣼⢛⢷⠀⡇⠀⢸⡇⠀⢰⠀⢧⢸⠀
* ⠀⠀⠀⠀⣼⠁⣰⢃⡇⡰⠀⢹⣾⡿⡌⠳⠀⢰⣿⣟⣿⡿⡅⠀⠉⠁⠀⠈⠉⠺⠧⠀⠀⠀⠀⠀⠘⢯⣋⣉⡉⣹⠓⠃⠀⠀⢸⠞⠀⠀⣝⢁⡾⠀⠁⢀⡾⠁⠀⠘⠀⠸⣾⠀
* ⠀⠀⠀⡸⠁⣰⠃⢸⣧⠇⠀⢸⠀⠙⢿⣆⠀⠀⠉⠳⠤⠤⠃⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠙⠛⠛⠋⠀⠀⠀⠀⢼⠀⠀⣀⣼⡿⠀⠀⣠⡞⠀⠀⠀⠀⡇⠀⢹⠀
* ⠀⠀⣰⠇⣴⠃⠀⣼⡞⠀⠀⢸⠀⠀⠀⢻⡄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠘⠀⠰⠿⠝⠋⣡⣾⠋⠀⠀⠀⠀⠀⡇⠀⢸⠀
* ⠀⢀⡿⣴⠋⠀⠀⣿⠃⠀⠀⣿⡀⠀⠀⠀⣷⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⣠⣴⣾⡿⠃⠀⠀⠀⠀⠀⠀⡇⠀⠀⡇
* ⠀⢸⣴⠇⠀⠀⢰⠇⠀⠀⢰⠿⡇⠀⡀⠀⢸⣇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣰⣿⡿⠋⡇⣿⠀⠀⢀⠀⠀⠀⠀⠀⡇⠀⠀⢱
* ⢠⣏⠏⠀⠀⢀⡞⠀⠀⢠⡞⠀⡇⢸⠀⠀⠀⢿⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣼⡿⣿⡇⣸⡹⢻⠀⠀⡸⠀⠀⠀⠀⠀⡇⠀⠀⠘
* ⢸⢻⠀⠀⠀⡾⠀⠀⠀⣾⠃⢠⡇⣼⠀⠀⠀⠘⣷⡀⠀⠀⠀⠀⠀⠀⠀⢀⣀⡤⠴⠶⣄⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢠⣾⠋⠀⣸⣧⣏⡇⢸⠀⢀⡇⠀⠀⠀⠀⠀⡇⠀⠀⠀
* ⡾⡸⠀⠀⣼⠁⠀⠀⣸⡟⠀⣾⣇⡟⠀⠀⠀⠀⢻⡷⣄⠀⣴⠒⠒⠒⠚⠛⠥⠤⠤⢤⣜⣯⢧⠀⠀⠀⠀⠀⠀⠀⣰⠋⠀⠀⠀⣿⠉⣽⢧⢸⠇⢸⠁⠀⠀⠀⠀⠀⡇⢀⠁⠀
* ⠀⡇⠀⣰⠁⠀⠀⣼⠃⡇⢀⣇⣿⠁⠀⠀⠀⠀⢀⠇⢺⣿⠃⠀⠈⠑⠒⠲⠦⠤⣤⣀⠸⡈⢻⡀⠀⠀⠀⢀⣠⠞⠁⠀⠀⠀⠀⢻⡷⠃⠘⣿⣆⡏⠀⠀⠀⠀⠀⠀⡇⠘⠀⢀
* ⠀⡇⣠⠇⠀⠀⣴⠁⢀⣇⡼⣿⠃⠀⠀⠀⠀⢀⡞⠀⣼⡏⠀⠀⠀⣀⠀⠀⠀⠀⠀⠈⢧⢷⡼⠁⠀⣀⣶⡟⠁⠀⠀⠀⠀⠀⢠⠞⠁⠀⠀⠘⣿⠃⠀⠀⠀⠀⠀⠀⡇⠀⠀⠜
* ⠀⣧⠋⠀⠀⣼⣷⣾⣍⣁⠀⠁⠀⠀⠀⢀⡤⠏⢀⣴⣿⠁⠀⠀⠀⠀⠙⠓⠲⠤⣄⠀⢸⣼⣣⣴⣾⠿⠋⠀⠀⠀⠀⠀⢀⡴⠋⠀⠀⠀⠀⢰⡇⠀⠀⠀⠀⠀⠀⠀⢁⣀⣼⡤
* ⠀⠃⠀⢀⡾⡉⠀⠀⢹⣏⠛⠶⢤⣴⣾⣯⣤⡶⢿⣿⠃⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⣇⢀⣿⣿⠟⠁⠀⠀⠀⠀⠀⣀⡴⠟⠁⠀⠀⠀⠀⢀⣾⠀⠀⠀⠀⠀⠀⠀⠀⡿⠀⠀⠀
*/
interface IUlyssesRouter {
/*//////////////////////////////////////////////////////////////
STRUCTS
//////////////////////////////////////////////////////////////*/
/**
* @notice A route for a swap
* @param from The index of the pool to swap from
* @param to The index of the pool to swap to
*/
struct Route {
uint128 from;
uint128 to;
}
/*//////////////////////////////////////////////////////////////
EXTERNAL FUNCTIONS
//////////////////////////////////////////////////////////////*/
/**
* @notice Returns the Ulysses Factory address
* @return ulyssesFactory The Ulysses Factory address
*/
function ulyssesFactory() external view returns (UlyssesFactory);
/**
* @notice Adds liquidity to a pool
* @param amount The amount of tokens to add
* @param minOutput The minimum amount of LP tokens to receive
* @param poolId The pool to add liquidity to
* @return lpReceived amount of LP tokens received
*/
function addLiquidity(uint256 amount, uint256 minOutput, uint256 poolId) external returns (uint256);
/**
* @notice Removes liquidity from a pool
* @param amount The amount of LP tokens to remove
* @param minOutput The minimum amount of tokens to receive
* @param poolId The pool to remove liquidity from
* @return tokensReceived amount of tokens received
*/
function removeLiquidity(uint256 amount, uint256 minOutput, uint256 poolId) external returns (uint256);
/**
* @notice Swaps tokens from one pool to another
* @param amount The amount of tokens to swap
* @param minOutput The minimum amount of tokens to receive
* @param routes The routes to take for the swap to occur
* @return tokensReceived amount of tokens received
*/
function swap(uint256 amount, uint256 minOutput, Route[] calldata routes) external returns (uint256);
/*//////////////////////////////////////////////////////////////
ERRORS
//////////////////////////////////////////////////////////////*/
/// @notice Thrown when the output amount is less than the minimum output amount
error OutputTooLow();
/// @notice Thrown when the Ulysses pool is not recognized
error UnrecognizedUlyssesLP();
}