Flash Swaps

Savmswap flash swaps enable you to withdraw up to the full reserves of any ERC20 token on Savmswap and execute arbitrary logic without any upfront cost. By the end of the transaction, you must either:

Pay for the withdrawn ERC20 tokens with the corresponding pair tokens.

Return the withdrawn ERC20 tokens along with a small fee.

Flash swaps are incredibly valuable as they eliminate the need for upfront capital and simplify multi-step transactions involving Savmswap.

Examples

Capital-Free Arbitrage

A key application for flash swaps is capital-free arbitrage. Savmswap's design aims to incentivize arbitrageurs to align the Savmswap price with the fair market price. Traditionally, arbitrage has required significant capital, but flash swaps remove this barrier, democratizing the process.

Imagine a scenario where buying 1 BTC on Savmswap costs 200 DAI, determined by calling getAmountIn with 1 BTC as the specified output. On another platform, 1 BTC might be worth 220 DAI, offering a risk-free profit of 20 DAI to someone with 200 DAI. Flash swaps make this profit accessible to anyone who can afford the gas fees, regardless of their available capital.

Withdrawing BTC from Savmswap

The first step is to optimistically withdraw 1 BTC from Savmswap via a flash swap, using it as capital for arbitrage. We assume that:

● 1 BTC is the optimal trade for maximum profit.

● The price hasn't changed on Savmswap or the other platform since our calculation.

Trade at External Venue

After obtaining 1 BTC from Savmswap, you trade it for 220 DAI on another platform. To settle with Savmswap, you need 200 DAI (as calculated by getAmountIn), leaving you with a profit of 20 DAI.

Instant Leverage

Flash swaps can also be used to efficiently leverage up using lending protocols alongside Savmswap.

Using Savmswap for the DAI-to-BTC component streamlines this process. Flash swaps allow for the upfront withdrawal of the full BTC amount. For example, for 2x leverage against a 3 BTC principal, you could flash swap 3 BTC and deposit 6 BTC into Maker, minting 800 DAI. Mint the amount needed to cover the flash swap (e.g., 605 DAI), and the rest acts as a buffer against price fluctuations.

Last updated