LogoLogo
  • 🌊Superfluid
  • Protocol Overview
    • πŸ’‘What is Superfluid?
    • πŸ“„In-Depth Overview
      • Super Tokens
      • Super Agreements
        • 🚰Money Streaming (CFA)
        • ✳️Distributions (IDA)
        • 🌊Streaming Distributions
      • Super Apps
      • Superfluid Host
    • 🧠Use Cases
      • Recurring Payments
      • DeFi
      • Social & Community
      • Gaming
    • πŸ“”Glossary of Terms
  • Developers
    • πŸƒQuickstart
    • πŸͺ™Super Tokens
      • Super Tokens - Solidity
      • Super Tokens - SDK Core
      • Super Tokens - Frontend Examples
      • Types of Super Tokens
      • Deploy a Super Token
        • Deploying a Wrapper Super Token
        • Deploying a Self Governed Super Token
        • Deploying a Pure Super Token
      • In-Depth
        • Tracking Super Token Balances
        • ERC777 in Super Tokens
      • Test Super Token Faucet
    • 🌊Money Streaming (CFA)
      • Solidity
        • Read Methods
          • getFlowInfo
          • getFlowRate
          • getNetFlowRate
        • Write Methods
          • createFlow
          • updateFlow
          • deleteFlow
          • With User Data
          • With Context
      • SDK Core
        • Read Methods
          • getFlow
          • getNetFlow
          • getAccountFlowInfo
        • Write Methods
          • createFlow
          • updateFlow
          • deleteFlow
      • Access Control List (ACL)
        • Solidity
          • createFlowFrom
          • updateFlowFrom
          • deleteFlowFrom
          • setFlowPermissions
          • setMaxFlowPermissions
          • revokeFlowPermissions
          • increaseFlowRateAllowanceWithPermissions
          • decreaseFlowRateAllowanceWithPermissions
          • getFlowPermissions
        • SDK Core
          • createFlowByOperator
          • updateFlowByOperator
          • deleteFlowByOperator
          • updateFlowOperatorPermissions
          • revokeFlowOperatorPermissions
          • increaseFlowRateAllowanceWithPermissions
          • getFlowOperatorData
      • Frontend Examples
      • More...
        • Flow Rate Time Frames
        • Building Batched Streams in Safe
        • Flow NFTs
    • ✳️Distributions (IDA)
      • IDA - Solidity
      • IDA - SDK Core
      • IDA - Frontend Examples
    • πŸ€–Super Apps
      • Super Apps in Depth
      • Super App Callbacks
        • Calling Agreements In Super Apps
      • User Data
        • NFT Billboard Example
      • SuperAppBaseFlow
      • Super App Examples
      • Super App Deployment Guide
    • 🧺Batch Calls
      • Batch Calls - SDK Core
      • Batch Calls - Frontend Examples
    • βš™οΈAutomations
      • Auto-Wrap
        • Dev Guide
      • Stream Scheduler
        • Dev Guide
      • Vesting Scheduler
        • Dev Guide
      • Stream Accounting API
        • Dev Guide
      • Automation Subgraphs
        • Stream Scheduler Subgraph
        • Vesting Scheduler Subgraph
        • Auto Wrap Subgraph
    • πŸ—οΈIntegration Guides
      • For Your Integration: The Basics
        • Supporting Super Tokens
        • Supporting Money Streams
        • Supporting Instant Distributions
      • Gating with Superfluid Subscriptions & Guild.xyz
      • Displaying Token Balances
      • Useful Queries for Your Integration
        • Instant Distribution Events
        • Money Streaming Events
        • Super Token Events
        • Other Helpful Queries
      • Constructing Links to The Superfluid Dashboard
    • πŸ”Superfluid Subscriptions
      • Superfluid Checkout Widget
      • Implementing Subscriptions in your App
    • SDK Core General
      • Initialization
      • Functionality
      • Getting Data
      • Resolver
      • Reference Docs
    • Solidity General
      • Calling Super Agreements
      • Libraries
      • Resolver
    • Testing Guide
      • Hardhat Testing
      • Foundry Testing
      • In-Depth
        • Hardhat Mainnet Fork Testing
        • Super App Testing on Mainnet Forks
    • Subgraph
    • Reference
      • Deploying The Framework
      • EVM Contracts
      • SDK Redux
      • Superfluid Console
      • Superfluid Protocol Addresses
    • Contract Addresses
  • Sentinels
    • πŸ₯…Liquidations & TOGA
    • πŸ€–Running a Sentinel
    • πŸ—ΊοΈSolvency Dashboard
  • Resources
    • 🌊Superfluid Wave Pool
    • πŸ“œSuperfluid on Ethereum Mainnet
    • πŸ’°Bounty Program
    • πŸ›‘οΈSecurity & Bug Bounties
    • πŸ’‘Project Ideas
    • πŸ—³οΈToken Dashboard Submission
    • πŸŽ₯Videos
    • Superfluid Deployment Guide
    • Learn about Ethereum
    • Code of Conduct
Powered by GitBook
On this page

Was this helpful?

  1. Developers
  2. Integration Guides
  3. For Your Integration: The Basics

Supporting Money Streams

Supporting Streams in Your Application

PreviousSupporting Super TokensNextSupporting Instant Distributions

Last updated 2 years ago

Was this helpful?

You can learn more about streaming .

When an account opens a money stream using the constant flow agreement, they need to define the receiver, the super token being streamed, and the flow rate of that stream. For example, in our sdk, it looks like this:

sf.cfaV1.createFlow({
	receiver: β€œ0x123…”,
	superToken: daix.address,
	flowRate: β€œ385802469135802” //equivalent to 1000 dai per month
});

πŸ’‘ Note that the flow rate is the number of tokens that the user will send per second to the receiver (denominated in wei: i.e. with 18 decimals)

When this stream is opened, 4 hours worth of that stream is held in escrow by the protocol. This is known as the stream’s buffer. The buffer is a mechanism to help keep Superfluid secure. With Superfluid streams, you don’t need to lock up the entire stream amount up front. You can learn more about why this works the way that it does , but it’s worth keeping that buffer amount in mind.

For example, as long as I have at least 4 hours worth of the stream in my balance, I can open the above stream at 1000/month. Having all 1k tokens in my wallet is unnecessary: I can keep them working in Aave or Compound, and then periodically top up my wallet balance.

An account can be sending and receiving an arbitrary number of streams at any given point in time. However, the thing that will likely matter for your integration is going to be an account’s net flow rate.

The netFlowRate is the total number of tokens being sent or received each second. Accounts will have different net flow rates for each token depending on their streaming activity. As we’ll see in the next section, this will be relevant for displaying a balance that is changing in real time. You can get the netFlowRate in three different ways:

1) Using the :

await sf.cfaV1.getNetFlow({
  superToken: string,
  account: string,
  providerOrSigner: ethers.providers.Provider | ethers.Signer
});

2) Using the Superfluid , using an entity such as accountTokenSnapshot

#this query will return the total netFlowRate for account "0xDCB..." and DAIx on Goerli
query MyQuery {
  accountTokenSnapshots(
    where: {account: "0xdcb45e4f6762c3d7c61a00e96fb94adb7cf27721", token: "0xf2d68898557ccb2cf4c10c3ef2b034b2a69dad00"}
  ) {
    token {
      name
      symbol
    }
    totalNetFlowRate
  }
}

Note that you can experiment with your own queries in the subgraph playground in the .

3) You can also get netFlowRate data in solidity by calling getNetFlow on the

πŸ—οΈ
here
here
SDK Core
subgraph
Superfluid console
CFA contract directly: