Swapper
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.
How it works
- Each Swapper is a payable smart contract with a beneficiary, output token (ETH or any ERC20), oracle, 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 one oracle, which uses Uniswap v3 TWAP to price assets.
- Tokens received by Swapper are held in the contract's balance until
flash
is called. Whenflash
is called, the caller sends the expected amount (as determined by the oracle) 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