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 can withdraw those tokens at any time.
- 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 one oracle, which uses Uniswap v3 TWAP to price assets.
- Tokens received by Swapper are held in the contract's balance until
flashis called. When
flashis 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.