Swapper

Split diagram

Swapper is a payable smart contract that converts all incoming tokens into a single output token. When ETH and ERC20s are received by a Swapper, they're automatically swapped into the output token according to the oracle's clearing price and the swapper's discount. If the oracle is unable to determine a clearing price (i.e., it doesn't support tokens it has received), the Swapper's owner must handle those tokens manually (e.g. swap or withdraw via execCalls; the former is enabled for some token-pairs by our UI).

⚠️

Swappers without owners will not be able to recover tokens received that aren't supported by their oracle. Be very careful when using immutable Swappers!

How it works

  • Each Swapper is a payable smart contract with a beneficiary, output token (ETH or any ERC20), oracle, discount, and owner. The oracle is modular so be careful to use a secure oracle with sensible settings for your desired behavior. You can use whatever oracle contract you'd like. Splits currently offers two oracles: Uniswap v3 TWAP and Chainlink.
  • Tokens received by Swapper are held in the contract's balance until flash is called. When flash is called, the caller sends the expected amount (as determined by the oracle and discount) to the beneficiary in exchange for the balance in Swapper. This means the caller is trading with Swapper directly, earning the balance in exchange for sending the expected value to the beneficiary.
  • Each Swapper can be owned, which means the owner has full control of the deployment. The owner may change the beneficiary or oracle, pause the contract, and execute arbitrary transactions at their will. We recommend removing the owner or making it a multisig if Swapper is being used in any trustless setting.

Addresses

Ethereum – 1
Base – 8453
Optimism – 10
Polygon – 137
Arbitrum – 42161