Superfluid Distributions

Superfluid
Superfluid Blog
Published in
4 min readMar 1, 2021

What are distributions in Superfluid?

Looking forward to highly scalable, one-to-many token distributions? Superfluid has got you covered.

  • Immediate. Assets are immediately deducted from the sender’s balance, and available in all the receivers wallets.
  • No withdrawals. Receivers can get tokens directly in their wallets, with no need for withdrawal transactions. Withdrawal can be enabled if necessary or desirable.
  • Fixed gas costs. You can distribute tokens to any amount of receivers with fixed gas costs.
  • Custom Proportions. Distributions don’t have to be equal. Each receiver can be assigned a specific amount of tokens, defined as his proportional share of each new distribution going forward.
  • Token wrapping. If you would like to send regular ERC20 tokens, you need to “upgrade” them to give them Superfluid functionalities similarly to wrapped ETH (wETH).

How does it work?

Superfluid is a smart contracts framework that adds functionalities to crypto tokens. We call these new functionalities agreements, they represent structured relationships between parties that last over time. All tokens that leverage Superfluid technology (SuperTokens) can use all available agreements.

In order to enable scalable distributions, we use one of these agreements called the Instant Distribution Agreement (IDA). This connects the wallet of one sender (which we call “Publisher”) with the wallets of many receivers (or “Subscribers”) via digital pipes across which assets can flow freely. Once these connections are properly established, the Publisher can send tokens to all Subscribers at a fixed gas cost.

To effectively set-up an IDA, a Publisher needs to assign units in this IDA to any number of receivers. These units give a receiver a right to a proportional amount of all future distributions, allowing any sort of granular allocations. In any future distributions, a receiver will get a number of tokens equal to the proportion of its units divided by the total units in existence. After assigning units to all Subscribers, publishers can start distributing assets.

Creating these digital pipes to each subscriber and assigning units to subscribers are on chain smart contract interactions that require gas. So using this technology only makes sense if you plan recurring distributions over time to the same users.

For example, our publisher Alice wants to distribute tokens to Bob, Carl and Dana. However, Carl and Data contributed more than Bob to Alice’s project so Alice sets to give them twice as many tokens. Alice decided to assign 100 units among participants, assigning 20 units to Bob, 40 to Carl and 40 to Diana. This means that each of them with receive 20%, 40% and 40% respectively of any token distribution Alice decides to trigger in the future. To do so Alice interacts on chain with an IDA smart contract, and has to pay gas for all the transactions she makes.

Distributed amounts are immediately allocated to the receivers. However, in order to receive any distributed assets directly in their wallets, receivers have to accept the units given to them by a publisher. This is a spam-prevention mechanism as a single wallet can only receive units from up to 255 IDA publishers.

Once receivers accept to be part of a distribution, the Publisher can distribute any amount of tokens that would appear directly in the receivers’ wallets without any need to withdraw.

Distributions have a fixed gas cost for Publishers (one single on chain contract interaction), and cost nothing for Subscribers. Once the set-up is done and units have been allocated, it doesn’t matter how many Subscribers there are, distributing tokens among them will always cost the same.

To continue our example, Alice now wants to send 10.000 tokens via her IDA. She triggers that distribution via an on chain smart contract interaction which has fixed gas cost. As soon as the transaction is confirmed, 2.000 tokens will be available in Bob’s wallet, 4.000 tokens will be available in Carl’s wallet and 4.000 tokens will be available in Diana’s wallet. Later on Alice triggers a second distribution of 5.000 tokens, which means an additional 1.000 tokens to Bob, 2.000 tokens to Carl and 2.000 tokens to Diana. Adding new participants will cost Alice an on chain transaction, as well as editing the units assigned to existing participants. Sending further distributions will also cost her one on chain transaction, but it will be a fixed gas cost independent from the number of receivers.

To recap, in order to distribute tokens as a Publisher you will have to:

  1. Upgrade the ERC20 tokens you want to distribute to superTokens via token wrapping;
  2. Create your custom IDA and assign units to each receiver 🚝➗
  3. Hit the Distribute button! 💸 💸

Build with Superfluid Distributions

Superfluid has been designed with developers in mind, you can learn how to build with Superfluid Distribution in our docs.

If you have any questions or issues when building with our code, hop in the Developers channel of our Discord and we’ll help you as much as we can!

--

--

Superfluid
Superfluid Blog

Building infrastructure to enable real-time finance