Skip to content

Commit 02e0b45

Browse files
committed
add docs for solvers in README
1 parent 1f73f5c commit 02e0b45

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

README.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,36 @@ On networks where Uniswap v4 is deployed, EulerSwap is deployed using a factory
150150

151151
The `script` folder contains scripts for deploying pools, as well as executing test trades on them. See the dedicated [README](./script/README.md)
152152

153+
## For Solvers
154+
155+
### Swaps
156+
157+
There are two ways to swap directly on EulerSwap: via a Uniswap V4 hook or by calling the pool’s [swap](https://github.com/euler-xyz/euler-swap/blob/1f73f5cb07f2e64e8c9815076749574b1b54e204/src/interfaces/IEulerSwap.sol#L65) function, which has the same ABI and behaviour as Uniswap V2 pools.
158+
159+
Additionally, the `EulerSwapPeriphery` contract provides helper functions: [swapExactIn](https://github.com/euler-xyz/euler-swap/blob/1f73f5cb07f2e64e8c9815076749574b1b54e204/src/interfaces/IEulerSwapPeriphery.sol#L8) and [swapExactOut](https://github.com/euler-xyz/euler-swap/blob/1f73f5cb07f2e64e8c9815076749574b1b54e204/src/interfaces/IEulerSwapPeriphery.sol#L21)
160+
161+
### Quotes
162+
163+
EulerSwap pools expose the [computeQuote](https://github.com/euler-xyz/euler-swap/blob/1f73f5cb07f2e64e8c9815076749574b1b54e204/src/interfaces/IEulerSwap.sol#L53) function for quoting both exact input and exact output trades. The function will revert if there is insufficient liquidity for the requested amount or if the pool has been decommissioned. If the function returns a quote, it means the trade is executable based on the pool’s current state (assuming the pool is operational—see the **Creating and Decommissioning Pools** section).
164+
165+
The `EulerSwapPeriphery` contract also provides the [quoteExactInput](https://github.com/euler-xyz/euler-swap/blob/1f73f5cb07f2e64e8c9815076749574b1b54e204/src/interfaces/IEulerSwapPeriphery.sol#L32) and [quoteExactOutput](https://github.com/euler-xyz/euler-swap/blob/1f73f5cb07f2e64e8c9815076749574b1b54e204/src/interfaces/IEulerSwapPeriphery.sol#L38) helper functions
166+
167+
### Liquidity
168+
169+
Unlike traditional AMMs, EulerSwap pools do not hold token reserves directly. Instead, liquidity is provided just-in-time from the underlying Euler lending vaults. The amount that can be deposited to or withdrawn from the lending vaults depends on the current state of the EulerSwap account and various factors, such as supply and borrow caps, vault utilization, etc. This means there may be limits at any given moment on how much can be sold or bought in a trade.
170+
171+
These limits are directional, resulting in four distinct parameters: input and output limits for trades in each direction. The [getLimits](https://github.com/euler-xyz/euler-swap/blob/1f73f5cb07f2e64e8c9815076749574b1b54e204/src/interfaces/IEulerSwap.sol#L59) function can be used to fetch the current liquidity limits available for swapping and is also available via `EulerSwapPeriphery`.
172+
173+
Note that these limits are enforced by the quoting functions, which will revert if a trade exceeds them.
174+
175+
### Creating and Decomissioning Pools
176+
177+
The EulerSwap pools are created by the `EulerSwapFactory` contract, which emits a [PoolDeployed](https://github.com/euler-xyz/euler-swap/blob/1f73f5cb07f2e64e8c9815076749574b1b54e204/src/EulerSwapFactory.sol#L32) event and provides functions to list existing instances.
178+
179+
Pools can also be uninstalled by LPs, for example during rebalancing, in which case the factory emits a [PoolUninstalled](https://github.com/euler-xyz/euler-swap/blob/1f73f5cb07f2e64e8c9815076749574b1b54e204/src/EulerSwapFactory.sol#L34) event.
180+
181+
However, note that EulerSwap instances are installed on top of regular accounts within the Euler lending platform—they do not control these accounts. This means an LP can abandon an EulerSwap instance simply by withdrawing their position from the lending vaults. In such cases, the factory has no indication that the pool is no longer operational, but quoting functions will start reverting. If a pool continually fails to return quotes, it should likely be blacklisted.
182+
153183
## Safety
154184

155185
This software is experimental and is provided "as is" and "as available".

0 commit comments

Comments
 (0)