Building on Superfluid

Superfluid
Superfluid Blog
Published in
3 min readOct 1, 2020

Superfluid was built with developers in mind. Every piece of our protocol is built with the constant question: “How easily can you build on it?”

As a protocol we worked hard to have a broad design space, enabling all sorts of apps to be built using these new primitives.There are three ways you can integrate with Superfluid.

  • You could also create a contract to send and/or receive streams. Superfluid tokens are standard ERC20/ERC777 tokens, so you can use your normal development patterns!

But… Let’s imagine the contract you built is receiving streams from a third party. If their stream stops, there’s no way for your contract to know!

The SuperApp framework fixes this.

Include our callbacks in your contract, and they will be triggered automatically when a stream is created, updated, or deleted, allowing you to easily keep track of everything!

Composing streams

Using the App Framework, you can compose streams together, creating new functionalities and interesting use cases. Let’s see some examples!

Cashflow NFT

An NFT that is used to receive streams of tokens from any number of users, and sends it on to the NFT owner.

On top of the normal NFT functionality, it has a couple of differences:

  • The NFT contract is a SuperApp. When a stream is received/updated/deleted, it updates the consolidated quantity of the reward stream
  • When the ownership is transferred, the contract must cancel the previous stream and open a reward stream to the new owner

DCA — Dollar Cost Averaging

Users send a stream of $DAI towards a contract. Periodically, someone converts the accumulated $DAI to $ETH and distributes it to all the streamers.

The distribution is done through Superfluid’s Instant Distribution Agreement. It allows a publisher to distribute rewards to all subscribers through one on-chain transaction. The amount received by each user depends on the amount of units they are given by the publisher.

The DCA contract is a SuperApp. It receives incoming streams in $DAI, and is also the publisher of an IDA in $ETH. When an incoming $DAI stream is received/updated/deleted, the SuperApp must update that user’s corresponding units of the IDA.

Reward Distribution $RIGHTS Token

An ERC-20 token that entitles it’s holders to receive rewards in a different token. For example, by holding $RIGHTS, you are airdropped $DOLLAR rewards.

We can wrap ERC-20 functions around the IDA, linking units with the balanceOf() function, and adapting the transfer() functions to update the unit allocation of each user.

By doing this, the Superfluid functionalities are abstracted from the user, who can simply transfer $RIGHTS, and always receives $DOLLARS!

These are just examples, we can’t wait to learn what you want to build! Join our Discord server and tell us what cool ideas you came up with.

--

--

Superfluid
Superfluid Blog

Building infrastructure to enable real-time finance