This proposal, upon acceptance, will upload the StreamSwap contract to the Osmosis Zone blockchain.
# Abstract
StreamSwap is a protocol for time-based token swaps. In simple words, in an AMM pool, token swaps happen instantly. With StreamSwap, tokens are streamed and swapped over a fixed period of time.
# Mechanism (short overview)
- StreamSwap swaps require users to create Streams and lock a fixed number of tokens (T1) and swap them for an accepted token (T2) over a fixed-period of time (t) - T1 is added by the Streamer (stream creator) and can NOT be added or removed at any point in time until the end of the Streaming Phase (t) - T2 is the token that subscribers can add or remove at any point in time - Bootstrapping Phase — The duration from the stream creation until stream start time is the Bootstrapping Phase. This is when subscribers can use T2 to subscribe. During this phase, no swapping happens. - Streaming Phase — The duration from the stream start time to the stream end time is the stream duration (t) during which streaming starts & tokens are swapped. - T1 is streamed to subscribers that subscribed with T2. T2 is streamed to the user the locked T1. Both tokens can be redeemed only at the end of the stream. - The swaps do NOT happen instantly and take place linearly over the duration of the entire stream. - A constant number of T1 are streamed as they are locked and T2 are streamed based on the total time remaining and total unspent T2 tokens - At the end of the Streaming Phase, subscribers can redeem T1 based on their total contribution of T2 and the time at which they subscribed to the stream. - Price Discovery — The final price of locked T1 is determined by the total T2 received by the end of the stream.
# Mechanism (in detail)
The mechanism enables communities/DAOs/builders to swap tokens at any stage of a project’s lifecycle — before, during or after the token launch. Of the many use cases, the first use case being explored and focused on is the StreamSwap Protocol for community-driven token launches.
## 1) About
StreamSwap is the protocol for time-based token swaps on Osmosis. It is developed using CosmWasm smart contracts and will be going through the governance process similar to other smart contract deployments on Osmosis Zone.
The protocol is built for token swaps and StreamSwap is being utilized initially for community-driven token launches as it enables fair price discovery for the token being streamed.
## 2) Stream Creation
DAOs/Communities/Users can create Streams by:
- locking tokens to stream out (say, FLIX) - setting a token to stream in (say, OSMO) - setting the stream start time and stream end time
## 3) Phases of a stream
Streams have two phases:
- Bootstrapping Phase - Streaming Phase
## 4) Deposits and Withdrawals - Tokens being streamed out (FLIX in this case), are locked during the stream and can NOT be added or removed until the end of the stream. - After the stream ends, subscribers can redeem the token being streamed out (FLIX) based on the shares that they receive for the token streamed in - Tokens being streamed in (OSMO in this case), can be deposited or withdrawn at any point in time during the stream, giving subscribers the freedom to exit as they see fit.
## 5) Phase 1 — Bootstrapping Phase - Bootstrapping Phase is the period from the “stream creation” time to the “stream start” time. - Subscribers can subscribe to the stream by depositing tokens being streamed in (OSMO) and receive shares proportionately. No swaps occur during this phase as the streaming does not start.
## 6) Phase 2 — Streaming Phase In the Streaming phase, tokens start getting swapped and are streamed at each other. - Tokens being streamed out (FLIX) and tokens being streamed in (OSMO) are swapped over the duration of the stream. - During the Streaming Phase, tokens being streamed in (OSMO) are spent when they are swapped. Spent tokens can not be withdrawn but unspent tokens can be withdrawn.
## 7) Price Discovery - The final price of the tokens being streamed out (FLIX in this case) is determined by the total tokens streamed in (OSMO) during the Streaming Phase; enabling fair and transparent community-driven price discovery.
## 8) Token Distribution Once the Streaming Phase ends, subscribers can redeem the tokens streamed out (FLIX) while the tokens that were streamed in (OSMO) are transferred to the stream creator's treasury (as configured during the Stream creation).
## 9) Advantages when compared to the LBPv1 - Capital Efficiency — No collateral token required - Participation Protection — No tokens are released/delivered before the Streaming Phase ends and hence, there is no way for folks to dump their tokens while the streaming happens (which is a major difference when compared to LBPs) - MEV — MEV will not affect participation, as tokens swaps do NOT happen instantly - Can’t time your participation right? DCA into a stream by subscribing to it right in the Bootstrapping Phase.
OmniFlix is the first project launching via StreamSwap and there are more in the pipeline. If you are keen on using StreamSwap for your token launch you can reach out to us on Twitter or Telegram