Under the Hood: Streaming Swaps

THORChain University
3 min readJul 11, 2023

In THORChain, large swaps (relative to pool depths) have been historically known to incur large slippage. For example, at time of writing, a 50 BTC swap to ETH incurs up to 36% slippage:

Swappers have often chosen to manually break up their swaps, for example, into 100 individual swaps of 0.5 BTC each, and thus limit the maximum slippage to 2.3% each:

However, in this case, the user has to manually send 100 separate on-chain inbound transactions, and receive 100 separate on-chain outbound transactions… and thus, pay 100 times the on-chain gas fees!

ENTER STREAMING SWAPS

THORChain’s streaming swap option solves this issue by allowing a user to send a single inbound tx (with single inbound gas fee), having it internally split into multiple swaps, and then reconsolidated into one on-chain outbound tx (with single outbound gas fee). In our example above, then the user would send 50 BTC (with a single inbound gas fee), leave it to THORChain Streaming Swaps to internally split one swap into 100 swaps, then consolidate all the outbounds into one single ETH on-chain outbound transaction (again, paying a single outbound gas fee).

Users are free to select the number of swaps and the number of THORChain blocks between each swap; bounded by a minimum slippage of 5 bps (or 0.05%), configurable via Mimir. Streaming a swap from an L1 asset will be capped to a maximum of 24 hours to complete the swap, while swapping from a Synth will be capped to a maximum of 1 year. (Note: there will not be a cancellation option for an ongoing swap).

In essence, the large swap is “streamed” across multiple blocks, and that is why this feature is named as a “Streaming Swap”. With this mechanism, there must be a multi-block time component in play, since, if each of the individual swaps were executed within the same block, there would not be any time for arbers to rebalance the pool between each swap, and users would progressively receive lesser quality rates for each subsequent swap. This would not be much different than the “single large swap” scenario.

Users are therefore sacrificing time for a swap completion with better price execution, thus enjoying a larger swap output. Impatient users can still elect to reduce the time component, but will experience a poorer price execution.

Check the below infographics for a deeper look at how the transaction memo work for normal swaps vs streaming swaps:

Credit: PaperX & THORSwap Finance, https://twitter.com/THORSwap/status/1682414917499117569

Feel free to hop into the TC University Discord to chat about this, or any other THORChain questions that you may have.

Explore THORChain: Website, X, Telegram, Developer Discord.

Explore Maya Protocol, the first friendly fork of THORChain: Website, X, Discord, Telegram.

Decentralized, permissionless, non-custodial, trust-minimized, open-sourced, economic-secured, non-wrapped, native-to-native cross-chain swaps, savings and soon, lending!

--

--

THORChain University

THORChain University aims to educate communtiy users on how to optimally engage with the @THORChain Network