Swaps
Swaps are a cornerstone of advanced position management in Euler. They enable users to move seamlessly between assets, manage leverage, rebalance portfolios, and automate complex strategies—all within the protocol's modular, composable architecture. Understanding swaps is key to unlocking the full power of Euler's advanced features, especially when combined with concepts like sub-accounts, hooks, and operators.
Modularity and Trust Boundaries
Euler's architecture is built for flexibility and security. Core protocol logic is kept minimal and immutable, while advanced features like swaps are handled by periphery contracts. This separation allows for rapid innovation and integration with new DeFi primitives, without compromising the protocol's safety.
- Swapper is intentionally untrusted: it can be replaced, customized, or even bypassed. It simply executes swaps as instructed, with no protocol-level assumptions about its behavior.
- SwapVerifier is trusted and audited: it enforces the outcome of swaps, ensuring that slippage and price impact limits are respected. Only after verification are assets deposited or debts repaid.
Why Swapper is Untrusted
The Swapper contract is a black box from the protocol's perspective. Anyone can interact with it, and it has no access control. This means:
- Users are free to use any swapper implementation, including their own.
- The protocol does not rely on the Swapper for security—only on the SwapVerifier.
- All critical checks (amounts received, debts repaid) are enforced by SwapVerifier, which must always follow Swapper in an EVC batch.
Composing Swaps in EVC Batches
Swaps are most powerful when composed with other actions in an EVC batch. This enables atomic, gas-efficient workflows such as:
- Borrow → Swap → Deposit (open leverage)
- Withdraw → Swap → Repay (close/rebalance)