Skip to content

Commit 9287ae4

Browse files
committed
docs
1 parent b166555 commit 9287ae4

File tree

3 files changed

+19
-125
lines changed

3 files changed

+19
-125
lines changed

README.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ forge doc --serve --port 4000
5050

5151
## Deployment Addresses
5252

53-
On networks where Uniswap v4 is deployed, EulerSwap is deployed using a factory variant that creates Uniswap v4 hook compatible instances. Elsewhere, the original 'OG' version of EulerSwap factory is deployed. The deployed addresses can be found in [Contract Addresses](https://docs.euler.finance/developers/contract-addresses) section of Euler docs. To check which version is deployed, call `poolManager` on the EulerSwap implementation contract (`eulerSwapV1Implementation`). If it returns zero-address then 'OG' version is deployed.
53+
Deployed addresses can be found in [Contract Addresses](https://docs.euler.finance/developers/contract-addresses) section of Euler docs.
5454

5555
## Getting Started
5656

@@ -80,11 +80,13 @@ Note that these limits are enforced by the quoting functions, which will revert
8080

8181
### Creating and Decomissioning Pools
8282

83-
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.
83+
EulerSwap pools are created by the `EulerSwapFactory` contract, which emits a `PoolDeployed` event and provides functions to list existing instances.
8484

85-
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.
85+
Afterwards, pools can optionally be registered in the `EulerSwapRegistry` contract, which advertises them as ready for swapping. Doing so may require the posting of a small validity bond.
8686

87-
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 or swap simulations will start reverting. If a pool continually fails to return quotes or reverts in simulation, it should likely be blacklisted.
87+
Note that EulerSwap instances are installed on top of regular accounts within the Euler lending platform. This means an LP can abandon an EulerSwap instance simply by withdrawing their position from the lending vaults. In such cases, the registry has no indication that the pool is no longer operational, but quoting functions or swap simulations will start reverting. If a pool is misconfigured and unable to fulfil swaps it is claiming via its `getLimits()` function, the bond may be forfeit and the misconfigured pool removed from the registry.
88+
89+
When a pool is decomissioned, it is recommended to remove from the registry in order to recover the validity bond.
8890

8991
## Safety
9092

docs/architecture.md

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,37 +15,42 @@ Swapping can be performed by invoking the EulerSwap instance, either through a U
1515
EulerSwap is split into the following main contracts:
1616

1717
* `EulerSwap`: Contract that is installed as an EVC operator by liquidity providers, and is also invoked by swappers in order to execute a swap.
18-
* `UniswapHook`: The functions required so that the EulerSwap instance can function as a Uniswap4 hook.
19-
* `EulerSwapFactory`: Factory contract for creating `EulerSwap` instances and for querying existing instances.
20-
* `EulerSwapPeriphery`: This is a wrapper contract for quoting and performing swaps, while handling approvals, slippage, etc.
18+
* `UniswapHook`: Internal contract implementing the functionality for EulerSwap instances to function as a Uniswap4 hook.
19+
* `EulerSwapManagement`: Internal contract that implements management functionality for EulerSwap instances to reduce code size. `EulerSwap` uses delegatecall to this contract.
20+
* `EulerSwapBase`: Internal base class used to share functionality between `EulerSwap` and `EulerSwapManagement`
21+
* `EulerSwapFactory`: Factory contract for creating `EulerSwap` instances.
22+
* `EulerSwapRegistry`: Registry contract for advertising `EulerSwap` instances that are available for swapping.
23+
* `EulerSwapPeriphery`: Wrapper contract for quoting and performing swaps, while handling approvals, slippage, etc.
24+
* `EulerSwapProtocolFeeConfig`: A contract queried to determine the protocol fee in effect for a given swap.
2125

2226
The above contracts depend on libraries:
2327

2428
* `CtxLib`: Allows access to the `EulerSwap` context: Structured storage and the instance parameters
2529
* `FundsLib`: Moving tokens: approvals and transfers in/out
2630
* `CurveLib`: Mathematical routines for calculating the EulerSwap curve
2731
* `QuoteLib`: Computing quotes. This involves invoking the logic from `CurveLib`, as well as taking into account other limitations such as vault utilisation, supply caps, etc.
32+
* `SwapLib`: Routines for actually performing swaps
2833

2934
And some utilities:
3035

3136
* `MetaProxyDeployer`: Deploys EIP-3448-style proxies.
32-
* `ProtocolFee`: The factory stores protocol fee parameters that will affect subsequently created `EulerSwap` instances. These can be changed by an owner.
3337

3438
## Operational flow
3539

3640
The following steps outline how an EulerSwap operator is created and configured:
3741

3842
1. Deposit initial liquidity into one or both of the underlying credit vaults to enable swaps.
39-
1. Choose the desired pool parameters (`IEulerSwap.Params` struct). The `protocolFee` and `protocolFeeRecipient` must be read from the factory.
43+
1. Choose the desired pool parameters (`IEulerSwap.StaticParams` and `IEulerSwap.DynamicParams` structs)
4044
1. [Mine](https://docs.uniswap.org/contracts/v4/guides/hooks/hook-deployment#hook-miner) a salt such that the predicted address of the `EulerSwap` instance will be deployed with the correct flags.
4145
1. Install the above address as an EVC operator, ensuring that any previous `EulerSwap` operators are uninstalled.
4246
1. Invoke `deployPool()` on the EulerSwap factory.
47+
1. Optional: Register the pool in the EulerSwapRegistry.
4348

4449
## Metaproxies
4550

4651
Each `EulerSwap` instance is a lightweight proxy, roughly modelled after [EIP-3448](https://eips.ethereum.org/EIPS/eip-3448). The only difference is that EIP-3448 appends the length of the metadata, whereas we don't, since it is a fixed size.
4752

48-
When an `EulerSwap` instance is created, the `IEulerSwap.Params` struct is ABI encoded and provided as the proxy metadata. This is provided to the implementation contract as trailing calldata via `delegatecall`. This allows the parameters to be accessed cheaply when servicing a swap, compared to if they had to be read from storage.
53+
When an `EulerSwap` instance is created, the `IEulerSwap.StaticParams` struct is ABI encoded and provided as the proxy metadata. This is provided to the implementation contract as trailing calldata via `delegatecall`. This allows the parameters to be accessed cheaply when servicing a swap, compared to if they had to be read from storage.
4954

5055
## Curve Parameters
5156

@@ -78,7 +83,7 @@ Note that there may be a race condition when removing one swap operator and inst
7883

7984
Swapping fees are charged by requiring the swapper to pay slightly more of the input token than is required by the curve parameters. This extra amount is simply directly deposited into the vaults on behalf of the EulerSwap account. This means that it has the effect of increasing the account's NAV, but does not change the shape of the curve itself. The curve is always static, per EulerSwap instance.
8085

81-
When an EulerSwap instance is created, a **protocol fee** parameter may be installed by the factory. This portion of the collected fees are routed to a protocol fee recipient. An administrator of the factory can change the the protocol fee and recipient for future created EulerSwap instances, although previously created instances will not be updated retroactively.
86+
When a swap is performed, the `EulerSwapProtocolFeeConfig` contract is queried to determine the protocol fee in effect. This proportion of the LP fees are instead sent to a protocol fee recipient chosen by the Euler DAO. This proportion cannot exceed 15%.
8287

8388

8489
## Reserve desynchronisation
@@ -103,7 +108,7 @@ Although the virtual reserves specify a hard limit for swaps, there may be other
103108
* The vaults have supply and/or borrow caps
104109
* The operator may have been uninstalled
105110

106-
There is a function `getLimits` that can take these into account. This function itself is an upper-bound and the values it returns may not be swappable either, in particular if the curve shape does not allow it. However, it makes a best effort and this function can be used to rapidly exclude pools that are definitely unable to service a given size swap.
111+
There is a function `getLimits` that can take these into account. This function is intended to return quotes that are swappable, but under some conditions may not be, if the pool is configured with larger reserves than the underlying Euler account's liquidity can handle. In these cases, the pool is eligible from being removed from the Registry.
107112

108113

109114
## Swapper Security

docs/interfaces.md

Lines changed: 0 additions & 113 deletions
This file was deleted.

0 commit comments

Comments
 (0)