[Feature] Streaming Swaps
Streaming Swaps
THORChain uses a new fee model for determining the number of swap fees paid in any given swap. This is called the slip-based model. It basically says the amount of fees you pay is relative to the trade's size vs. the pool's depth. This means that really large trades in shallow pools will pay large slip fees, while really small trades in deep pools pay very little (with no lower boundary).
By breaking up a trade into many smaller trades, the swapper ends up paying less in fees.
Here you can see the relationship between the number of swaps and savings on swap fees in this log scale chart. While these savings are generally quite static, they do shift somewhat against the swapper the larger the trade. This shift is actually quite small unless you're approaching a swap size that is the same size as the depth of the pool.
A streaming swap aims to utilize this concept and allows the network to break up a single swap into multiple swaps handled by the protocol itself. This would allow a larger-scale trader who opts to trade with a competitor (ie a centralization exchange) due to better price execution. In theory, THORChain could execute a $10 million dollar trade at a better price execution than Coinbase or Binance. THORChain can now capture those large traders without the need to capture more TVL, which helps THORChain to be more capital efficient. In addition, because each mini-swap causes less slippage, the pools would naturally have better price execution.
In addition, this feature would foster the growth of major features such as savers (less fees paid on entry/exit and users keep more of their yield), lending (less fees to open/close the loan), and limit orders (entry/exit to/from synths reduced). None of these features get their value proposition from the swaps that they cause, but from the service before/after the swaps.
How it works
A user submits a swap and specifies the number of swaps he/she would like the network to execute on their behalf, along with the frequency (ie every 10 blocks). This is similar to a TWAP trade. While the number of swaps has no limit, the mini-swap size does (more on this later). The total length of streaming swap (swaps * frequency
) cannot exceed 24hrs (mimir configured). The network would hold their source token (and target token) outside of the pools (in a staging area), and swaps every x blocks. The network has generally been against the idea of holding non-native assets outside of the pools due to economic security reasons, but since these funds are in-flight and are guaranteed to exit the system within a short period of time, it's safe to do so.
Once all swaps are executed and the streaming swap is completed, the target token is sent to the user (minus misc outbound fees).
Please Note: Each individual aims to respect the trade target given in the memo. If its unable, this "mini-swap" is skipped and would result in the user getting a partial refund, partial successful swap. This likely isn't an issue for like-for-like trades, such as BTC --> Synth BTC or BUSD --> USDC, as the price changes between the source and target tokens are generally the same.
Min swap size
A min swap size would be placed on the network for streaming swaps. This is the minimum size for each individual swap within a streaming swap to be allowed. This also puts a cap on the number of swaps in a streaming swap to be a limited number, and that limited number increases based on the size of the streaming swap (rather than something static for all swaps, irrespective to swap size). The min size would be relative to pool depth (more research is needed to establish this value in basis points). This would allow the network to be more friendly to large trades, while also keeping revenues up for small or medium-sized trades.
Additional notes
- This tool, while useful, wouldn't be used by everyone. Arb bots for example couldn't use this feature to correct the pool price. This means that the vast majority of trades on the network would NOT use this feature.
- Generally, cheaper swap fees create a security issue for THORChain. It makes it cheaper to price manipulate the pools (especially for lending). But since the swaps are spread out over a period of time and in smaller quantities, it's not an effective tool to make this type of attack.
- This feature can be used as a tool to improve the price execution of trades arbitrarily to stay competitive with any/all competitors (CEX or DEX).