Superfluid: Programmable Cashflows

2022-02-21 • Pruitt Martin

GM everyone and welcome back to the Blockchain at Georgia Tech newsletter. This week I will be diving into Superfluid, a project that has been around since 2020 but recently released an exciting new update to their protocol regarding NFTs. Superfluid specializes in programmable cashflows using smart contract agreements, which enables the possibility for real-time finance. Programming cashflows is something that has excited people since the beginning of Ethereum and Superfluid is working to make this a reality with their innovative SuperTokens and cash “streams”.

This is a long post as I compiled a ton of information from so many great resources and blog posts. Be sure to check out the sources at the bottom!

Intro to Superfluid

At its core, Superfluid is a smart contract framework built on Ethereum. With a single on-chain transaction Superfluid allows you to create a “stream” that sends money continuously to another wallet or even an NFT. Superfluid was originally designed to enable real-time money streaming and reward distributions, but its framework is incredibly flexible and developer-friendly so the possibilities of programmable cashflows are endless.

As previously mentioned, a Superfluid stream is simply a continuous flow of tokens (money) from one wallet to another. What makes streams so cool is that the flow of money happens every second and requires only 1 transaction to the blockchain. That means no continuous gas fees to move money and there is no set end date on the stream.

So for example, say I agree to send 1000 DAI per month in a constant stream to a developer. Every second a tiny amount of DAI flows from my wallet to their wallet so that at the end of the month they will have 1000 DAI. This flow will continue until my wallet is empty or I cancel the stream with another transaction.

How it Works

Superfluid enables all of this through a smart contract framework that adds functionalities to crypto tokens. Since you cannot create streams with regular ERC-20, Superfluid “upgrades” them into SuperTokens. In the Superfluid ecosystem, these functionalities are called agreements, which is their way of representing financial relationships between parties. This is a similar relationship to wrapping your ETH into WETH.

Overall the Superfluid ecosystem operates through a single host contract with multiple agreement contracts. The main agreement for streaming is called the Constant Flow Agreement (CFA). This is the agreement that connects the two wallets and allows for peer-to-peer money flows.

Constant Flow Agreements have several unique traits:

  • Streams of money are perpetual and invariable over time. However, the stream value can be edited with an additional transaction.
  • The agreement allows users to have inflows and outflows from the same account. This creates a net flow which is basically the difference between their inflows and outflows
  • There is no limit to the number of flows an account can handle. A user can theoretically call infinite Constant Flow Agreements with the only limitation being how much gas they can pay upfront.

From a technical standpoint, a CFA is described by three parameters: Sender, Receiver, and FlowRate. The Sender and Receiver parameters are self-explanatory, but the FlowRate is defined as the amount of tokens sent per second. The FlowRate varies based on the size of the stream and the time periods which it is set to be paid out (weekly, monthly, etc). Another great feature of Superfluid streams is that you don’t need the full amount of capital upfront.

For example, an employee for a DAO is promised $10,000 a month, which is paid out second by second in a stream. The DAO would only be required to put up 4 hours of capital to start the stream. As the DAO receives inflows to its wallet the salary outflows to all employees happen in real-time. If the DAO’s overall token balance hits 0, then the streams are closed. This process is incredibly capital efficient for the DAO as they are able to start making salary payments without the need to save a large lump sum.

This concept, known as just-in-time liquidity, works on both ends as well. In the previous example, the DAO could pay salaries with capital just as it came in. The receiver of a cash stream can actually use the capital immediately as it flows into the wallet each second. So as the employee receives their salary, they can actually create multiple outgoing streams to pay for things like rent, subscriptions, or even investments. What was before a very capital inefficient system with lump-sum payments, the Superfluid framework creates the most capital efficient networks imaginable. Liquidity can finally flow freely.

The other major agreement that Superfluid created is the Instant Distribution Agreement (IDA). An IDA is an efficient method for transferring funds to several predefined recipients in a single transaction.

Instant Distribution Agreements also have several unique traits:

  • They can only send money in one direction. Unlike a CFA, the 2 parties’ wallets are not connected and money can not be streamed back and forth.
  • A user can deposit any quantity of tokens to a smart contract and the money is distributed money to multiple users at a time with a fixed gas price. This amount can also be based on a proportional amount of shares so that certain recipients receive more than others.

All together the CFAs, IDAs, other Superfluid agreements, and static balance of your wallet create what is known as a “Real-Time Balance”. Your real-time balance is the amount of money available in your wallet. This number adjusts automatically based on your incoming and outgoing streams.

Lastly, Superfluid allows for the customization streams through Super Apps. Super Apps are a type of smart contract that can manage agreement calls and react to any changes. Companies that use Super Apps can write their own logic and behavior to help tailor money streams to their specific needs.

At this point, we have covered the major agreements in the Superfluid framework, but in order for the entire ecosystem to function properly accounts sending money must remain solvent.

So what happens when the liquidity doesn’t arrive just in time?

Streams are considered solvent when each party is in good standing, the sender’s balance is above 0, and the recipient receives the money flow as expected.

To increase the likelihood of everyone remaining solvent, Superfluid has created buffers. In order to open a stream, senders must lock a small portion of tokens as a deposit (buffer). This deposit is taken out of the sender’s balance but is returned when the stream is closed. However, if the stream ends because the user’s wallet runs out of tokens, then the deposit is taken. This creates an incentive for users to close streams as it is the responsibility of the sender to end a stream.

Deposits are calculated based on the flow rate of the stream and require you to lock up 4 hours of value. So creating a stream that is 1000 DAI a day vs 7000 DAI a week will require the same buffer amount. While these steams are effectively the same, in terms of capital efficiency, it would be more advantageous to create streams with longer time frames and lower flow rates by the second.

When the sender’s balance hits zero, the stream is considered critical and the buffer is used to continue to pay the stream. When the buffer is depleted the stream is considered insolvent. Superfluid employs what is known as Patricians and Pirates to help keep streams from becoming insolvent. Once a stream becomes critical, Patricians close the stream and receive the remaining buffer as a reward. If a stream goes insolvent then a Pirate can close it and take the reward while Patricians are penalized for missing the critical stream. This creates a system where Patricians are incentivized to close critical streams as fast as possible and Pirates are essential in keeping Patricians in check. If you want to learn more about Superfluid’s liquidation system, learn more here.

The Rise of Real-Time Finance

Now that you understand how Superfluid works, let's dive into what makes the protocol so powerful and exciting. Programmable cashflows create the possibility for what is known as real-time finance and networked cash flows. Both of these concepts are getting a lot of people excited and it marks a huge innovation in terms of moving value. Kyle Samani from Multicoin Capital says it represents the largest step forwards for value transfer “since the advent of Bitcoin”.

Real-Time Finance by Liam Cobb

But before diving into those two ideas, it is important to understand one of the core principles of finance: time value of money (TVM). TVM is the concept that a sum of money is worth more right now than it will be at some future date. For example, $100 is more valuable to me today on February 21st, 2022 than it will be on February 21st, 2023. This is due to its earnings potential as I can grow my $100 to $110 through investments. So in short, a delayed investment is an opportunity lost.

By moving assets automatically and by the second, real-time finance allows businesses and investors to make the most of the TVM principle. Rather than having to wait for a monthly paycheck, workers whose salaries are paid out in real-time can make payments sooner and take advantage of dollar-cost averaging (DCA) into investments.

So while enabling single-sided money streams or instant distribution agreements are innovative, the true power of the Superfluid framework lies in its ability to create real-time networked cash flows. Individuals can now create a network of autonomous money that connects across multiple assets without extreme gas consumption and it's all in real-time. For instance, a savvy web3 employee can receive a stream of 200 USDC a day from a DAO as payment for work. The money streamed to their wallet can be instantly streamed out to pay for other services or investments. 50 USDC can be directed towards their monthly web3 subscriptions, $100 goes to a savings wallet, and the remaining $50 is instantly invested into an ETH-USDC liquidity pool on SushiSwap to start earning yield.

The best part, this is already possible with projects like Ricochet. Superfluid is keenly aware that the value of its protocol is very dependent on its network effects. This is why they were very intentional in creating a suite of developer-friendly tools and participate in so many hackathons. The modular element of their smart contract framework encourages developers to develop new projects using the Superfluid token standard. And like most applications on the internet, as more users begin using streaming for their payments, the greater the network effects of Superfluid’s ecosystem.

SuperFlubick by FLOC

DCA investments and automated cashflows are just scratching the surface of the revolutionary possibilities of real-time finance. If consumers can use real-time finance to reduce credit obligations, inefficient capital locked up from short-term lending such as, merchant cash advances, payday loans, and consumer credit card debt can be reduced and better utilized. However, today’s world economy is built on credit, lump-sum payments, and cash flow management. Many large companies and banks operate and make a profit through short-term lending and by employing strategies to delay cash outflows. Breaking down the existing financial framework to implement real-time finance will be difficult and comes with several risks. The technical and structural barriers as well as the risks to both individuals and big companies is something our newsletter hopes to explore in the future but is enough information to be an entirely new post.

In conclusion though, as networked cash flows grow exponentially they will unlock an unimaginable amount of liquidity. At its core, greater capital efficiency means more money today for individuals and businesses. And as shown through the Time Value of Money; money is always worth more today than tomorrow.

While a lot of the possibilities and benefits of real-time finance are still in their infancy, Superfluid is already being used for several real-world applications. The most common one is being an infrastructure tool for DAOs and simplifying payroll.

DAO Infrastructure

Making sure your employees or contributors get paid is critical for an organization, but managing payroll is an incredibly difficult task for companies. Payroll software can be expensive for small organizations with some plans costing $12 per person per month. Large companies have entire divisions in HR dedicated to handling payroll. These are operational costs that can add up very quickly and become time-consuming. Managing payroll is especially challenging for DAOs given their dispersed operations. DAOs are often looking to scale fast with contributors providing work on an inconsistent basis. These variables make managing a DAO even more difficult and serve as a distraction for core teams looking to launch a product or build a community.

Superfluid recognized this pain point for DAO admins and designed streams to help reduce the friction in managing DAO payroll. Teams can set up Superfluid streams to contributors that will provide compensation in real-time. These streams can be edited or stopped at any time if the contributor decides to start working part-time or is only contracted for a specific task. Streaming salaries in real-time ensures that contributors are paid fairly and more efficiently based on the time they give to the project. As a DAO admin, this helps reduce the overhead and weekly or monthly effort that you had to waste on payroll management.

4 Key Benefits of using Superfluid for DAOs highlighted from Superfluid’s blog:

  1. Less Effort
    Superfluid allows for salaries to be streamed on an annual or monthly basis. These funds are then moved over time without the need for multiple transactions. So rather than paying a monthly fee to pay employees, DAOs can pay a one-time fee to open a stream.
  2. No more overhead
    Set the amount of funds and transfer once. No more monthly overhead and payroll transactions from a complicated cold wallet.
  3. Reduced complexity
    Superfluid allows for a stream to be sent to as many wallets as you want directly from a Gnosis Safe. This means a DAO can pay their entire payroll through one multi-sig wallet.
  4. Pay in real-time
    Contributors get paid in real-time as they complete work and they can use these funds immediately. This makes it easier for DAO contributors to manage their own costs and creates greater liquidity to potentially invest back into the DAO or other projects.

Streaming salaries is already a reality as several organizations and DAOs are using Superfluid to manage payroll. MakerDAO Growth, Delphi Digital, Connext, and QiDao are some of the first pioneers to incorporate real-time finance and streaming into their operations.

NFT Streaming

Streaming to NFTs is one of the newer applications enabled by Superfluid, but it will arguably play the most pivotal role in real-time finance. The most obvious use case; NFT renting, has been a tricky problem for many developers and there are several projects working on creating the best market solution (Superfluid has actually created an ERC-721 extension proposal to add an Admin role to create a superuser for a specific token id). Superfluid has designed streams so that if an NFT is sold, the stream automatically is redirected to the new owner. This reduces the number of manual transactions needed to set up a stream and the friction involved in renting an NFT.

Some examples of NFT streaming:

  • Renting Property: Virtual property or land in projects like the Sandbox can be rented as a stream and when sold the stream automatically redirects to a new owner if the land is sold. Taken a step further, if a landowner in Sandbox has built a very popular attraction they could set a visiting rate that is streamed from the visitors depending on how long they stay.
  • Advertisements and NFT Billboards: If you own a digital billboard in a popular metaverse you could set up a streaming auction for the right to display adverts on it. You would receive the proceeds from the highest streaming bidder in real-time. And Vice-versa, say you own a very valuable NFT like a Bored Ape or a Fidenza piece. The owners of these pieces can place the artwork on consignment to a digital art gallery and receive their payment in a stream based on how long the piece is displayed.
  • FluidNFT: Created at NFTHack 2022, FluidNFT created a demo that showed how the numerical values of an NFT’s metadata can be streamed from one NFT to another. For example, in a play-to-earn game where characters are NFTs, one user may heal another user’s health using streaming. Using streaming to actually change the metadata of an NFT opens up the possibility for real-time breeding concepts in games or evolving NFTs.

If you are curious about other NFT streaming possibilities or other programmable cashflow ideas, check out Superfluid’s Ideas Billboard to explore projects being built on their ecosystem.

How to Start Streaming

Looking to create your very first money stream?

First head to the Superfluid Dashboard and connect your MetaMask.

If you connect through one of the Ethereum test networks (Kovan, Ropsten, Goerli), Superfluid will give you tokens to practice creating streams. Remember these are test networks so the money isn’t real.

Once you have some funds in your account follow these steps:

  1. Wrap your ERC-20 tokens, such as USDC, into SuperTokens. USDC → USDCx
  2. Then to start a stream click send and enter the address of the recipient
  3. Enter the flow rate of the stream
  4. You will have to pay a small buffer to set up the stream and then click confirm
  5. Pay the 1-time gas fee and you’re done!

It is really that simple to get started with Superfluid and if you get stuck at any point they have tutorials ready to answer questions.

If you’re a developer looking to integrate streams into your project I recommend reading the Superfluid Docs to learn more about all of the possible agreements and functionalities.

What’s next for Superfluid

On December 15th, 2021, Superfluid announced that their protocol would be adding capabilities for the Optimism and Arbitrum networks. Adding to the existing polygon and gnosis networks will make digital streaming much more accessible for Ethereum projects. Developers can already access the Optimism and Arbitrum testnets from the Superfluid dashboard so they can begin building applications for those networks.

Superfluid also just released v2 of the Superfluid Console built with their newly released SDK-Redux. Console v2 makes it easier for developers to explore Superfluid Data, has faster loading times, and best of all its entirely open source.

Finally, Superfluid participates in a ton of web3 and crypto hackathons and often gives out cash prizes. If you’re looking for experience building projects in web3, Superfluid is a great ecosystem to start! To stay up to date with Superfluid join their Discord and follow them on Twitter.

Blockchain @ Georgia Tech Socials

If you enjoyed this deep dive stay up to date with Blockchain at Georgia Tech’s upcoming events and posts by following us on Twitter and LinkedIn!

Sources and Additional Resources

Artwork Included in Post

Real-Time Finance by Liam Cobb - OpenSea

SuperFlubick by FLOC - OpenSea

Streaming

https://medium.com/superfluid-blog/superfluid-streams-5cc5141dd8a7

https://docs.superfluid.finance/superfluid/sentinels/liquidations-and-toga

NFTs

https://twitter.com/Superfluid_HQ/status/1490391635783467011

https://www.youtube.com/watch?v=EBxTQ2ShpyI

https://showcase.ethglobal.com/nfthack2022

https://showcase.ethglobal.com/nfthack2022/fluidnfts

https://showcase.ethglobal.com/nfthack2022/super-fractionalizer

https://medium.com/superfluid-blog/superfluid-beta-launch-nft-auction-fa7a33035657

Web3 Guilds

https://medium.com/superfluid-blog/web3-guilds-the-rebirth-of-organized-work-e9c1a139ad29

DAO Management

https://medium.com/superfluid-blog/4-ways-superfluid-removes-friction-for-dao-admin-7d095bd937b6

Real-Time Finance

https://medium.com/superfluid-blog/the-real-world-benefits-of-salary-streaming-584d94688f84

https://multicoin.capital/2021/07/13/networked-cash-flows/

http://ricochet.exchange/

Docs

https://docs.superfluid.finance/superfluid/

Github

https://github.com/superfluid-finance/protocol-monorepo

9M Raise in July 2021

https://twitter.com/Superfluid_HQ/status/1414937101745983491?s=20

February 8th, 2022 Exploit Post-Mortem

https://twitter.com/Superfluid_HQ/status/1491200753335246849

Other

https://medium.com/superfluid-blog

https://medium.com/superfluid-blog/superfluid-is-coming-to-optimism-and-arbitrum-aca1f29a208c

https://medium.com/superfluid-blog/superfluid-console-v2-enters-beta-7caa68855b02

https://fintechruminations.com/2021/12/19/2032-financial-tales-from-planet-earth/

https://twitter.com/adamscochran/status/1449767476129009672

https://eips.ethereum.org/EIPS/eip-777