In this post we will outline what the CowSwapper does, what the trust assumptions are, and how it works under the hood.
The CowSwapper enables trustless, MEV-protected ERC20-to-ERC20 swaps, while assets remain deployed as collateral inside an Arcadia Account. It can be used for compounding staked positions, auto-repaying debt, stop losses and much more!
Let's first quickly go over the existing Arcadia automations: the Compounder and Rebalancer.
Both are for managing DEX liquidity positions and the names are self-explanatory: the Compounder adds fees collected in the underlying tokens of the pool to the position, while the Rebalancer changes the range of the liquidity position.
They are triggered by an external initiator, but can be trustless. The smart contracts enforce that the pool is not manipulated, that swaps are executed without extracting assets or excessive slippage, and that a minimum amount of liquidity is minted after the compound or rebalance.
Both the Rebalancer and Compounder can do trustless swaps, since they rely on information from the pool itself. They are however limited to the two tokens of the DEX pool; the same mechanism cannot be generalised to swap between any two ERC20 tokens. For many use cases we need to swap to and from third tokens as well. Staking rewards are often paid in a third token (e.g. OP, ARB, AERO). Taking profit might mean swapping yield into a stablecoin. Repaying debt requires converting into the borrowed asset.
For these third-token swaps we still want the same guarantees: trustless execution, minimal slippage, and protection against MEV.
One approach would be to rely on price oracles to calculate minimum output amounts on-chain. But this only works for token pairs where oracles are already configured — it does not generalise to any-to-any token swaps.
The solution is an integration with CoW Protocol. The initiator still triggers the swap, but the actual execution is delegated to CoW Protocol's batch auction. Solvers compete to offer the best price, and the winning solver settles the trade. This guarantees competitive rates while providing MEV protection, since CoW Protocol settles trades off-chain in batches rather than exposing them to the public mempool.
Additionally, CoW Protocol allows users to execute arbitrary logic before or after the swap. This means that swaps can happen within Arcadia Flash Actions: assets can be swapped while they continue to serve as collateral. Nothing needs to be withdrawn by the Account Owner first, no debt needs to be repaid first. One token leaves and the second token enters in a single transaction, and the Account's health is never at risk.
Combining CoW Protocol swaps with Arcadia Flash Actions unlocks a number of cool features.
The following use cases are being rolled out in the short term:
In the medium term, we'll use CoW for even more use cases!