Skip to main content

SuperTokenV1Library

Library for Token Centric Interface

The SuperTokenV1Library is a solidity library that allows you to interact with the Superfluid Protocol. It is a comprehensive library for Superfluid protocol. It includes all the functions that are required to interact with the Superfluid protocol. It includes functions for interacting with Money Streaming and Distributions. In order to have access to the library, you need to:

  • Import the library in your contract as such:

    import "@superfluid-finance/ethereum-contracts/contracts/apps/SuperTokenV1Library.sol";

  • Make sure that you include the using statement in your contract:

    using SuperTokenV1Library for ISuperToken;

Note 1

In the case of interacting with Native Super Tokens you should use using SuperTokenV1Library for ISETH; instead.

Note 2

It is important to "warm up" the cache and cache the host, cfa, gda before calling, this is only applicable to Foundry tests where the vm.expectRevert() will not work as expected. You must use vm.startPrank(account) instead of vm.prank when executing functions if the cache isn't "warmed up" yet. vm.prank impersonates the account only for the first call, which will be used for caching.

Fn flowX

function flowX(
contract ISuperToken token,
address receiverOrPool,
int96 flowRate
)
internal
returns (bool)

creates a flow to an account or to pool members. If the receiver is an account, it uses the CFA, if it's a pool it uses the GDA.

Parameters

NameTypeDescription
tokencontract ISuperTokenSuper token address
receiverOrPooladdressThe receiver (account) or pool
flowRateint96the flowRate to be set.

Return Values

NameTypeDescription
[0]boolA boolean value indicating whether the operation was successful.
Note that all the specifics of the underlying agreement used still apply.
E.g. if the GDA is used, the effective flowRate may differ from the selected one.

Fn transferX

function transferX(
contract ISuperToken token,
address receiverOrPool,
uint256 amount
)
internal
returns (bool)

transfers amount to an account or distributes it to pool members.

Parameters

NameTypeDescription
tokencontract ISuperTokenSuper token address
receiverOrPooladdressThe receiver (account) or pool
amountuint256the amount to be transferred/distributed

Return Values

NameTypeDescription
[0]boolA boolean value indicating whether the operation was successful.
Note in case of distribution, the effective amount may be smaller than requested.

Fn getFlowRate

function getFlowRate(
contract ISuperToken token,
address sender,
address receiverOrPool
)
internal
returns (int96 flowRate)

get flow rate between two accounts for given token

Parameters

NameTypeDescription
tokencontract ISuperTokenThe token used in flow
senderaddressThe sender of the flow
receiverOrPooladdressThe receiver or pool receiving or distributing the flow

Return Values

NameTypeDescription
flowRateint96The flow rate
Note: edge case: if a CFA stream is going to a pool, it will return 0.

Fn getFlowInfo

function getFlowInfo(
contract ISuperToken token,
address sender,
address receiverOrPool
)
internal
returns (uint256 lastUpdated, int96 flowRate, uint256 deposit, uint256 owedDeposit)

get flow info between an account and another account or pool for given token

Parameters

NameTypeDescription
tokencontract ISuperTokenThe token used in flow
senderaddressThe sender of the flow
receiverOrPooladdressThe receiver or pool receiving or distributing the flow

Return Values

NameTypeDescription
lastUpdateduint256Timestamp of flow creation or last flowrate change
flowRateint96The flow rate
deposituint256The amount of deposit the flow
owedDeposituint256The amount of owed deposit of the flow
Note: edge case: a CFA stream going to a pool will not be "seen".

Fn getNetFlowRate

function getNetFlowRate(
contract ISuperToken token,
address account
)
internal
returns (int96 flowRate)

get net flow rate for given account for given token (CFA + GDA)

Parameters

NameTypeDescription
tokencontract ISuperTokenSuper token address
accountaddressAccount to query

Return Values

NameTypeDescription
flowRateint96The net flow rate of the account

Fn getNetFlowInfo

function getNetFlowInfo(
contract ISuperToken token,
address account
)
internal
returns (uint256 lastUpdated, int96 flowRate, uint256 deposit, uint256 owedDeposit)

get the aggregated flow info of the account (CFA + GDA)

Parameters

NameTypeDescription
tokencontract ISuperTokenSuper token address
accountaddressAccount to query

Return Values

NameTypeDescription
lastUpdateduint256Timestamp of the last change of the net flow
flowRateint96The net flow rate of token for account
deposituint256The sum of all deposits for account's flows
owedDeposituint256The sum of all owed deposits for account's flows

Fn getBufferAmountByFlowRate

function getBufferAmountByFlowRate(
contract ISuperToken token,
int96 flowRate
)
internal
returns (uint256 bufferAmount)

calculate buffer needed for a CFA flow with the given flowrate (for GDA, see 2nd notice below)

Parameters

NameTypeDescription
tokencontract ISuperTokenThe token used in flow
flowRateint96The flowrate to calculate the needed buffer for

Return Values

NameTypeDescription
bufferAmountuint256The buffer amount based on flowRate, liquidationPeriod and minimum deposit

the returned amount is exact only for the scenario where no flow exists before. In order to get the buffer delta for a delta flowrate, you need to get the buffer amount for the new total flowrate and subtract the previous buffer. That's because there's not always linear proportionality between flowrate and buffer. for GDA flows, the required buffer is typically slightly lower. That's due to an implementation detail (round-up "clipping" to 64 bit in the CFA). The return value of this method is thus to be considered not a precise value, but a lower bound for GDA flows.

Fn flow

function flow(
contract ISuperToken token,
address receiver,
int96 flowRate
)
internal
returns (bool)

Sets the given CFA flowrate between the caller and a given receiver. If there's no pre-existing flow and flowRate non-zero, a new flow is created. If there's an existing flow and flowRate non-zero, the flowRate of that flow is updated. If there's an existing flow and flowRate zero, the flow is deleted. If the existing and given flowRate are equal, no action is taken. On creation of a flow, a "buffer" amount is automatically detracted from the sender account's available balance. If the sender account is solvent when the flow is deleted, this buffer is redeemed to it.

Parameters

NameTypeDescription
tokencontract ISuperTokenSuper token address
receiveraddressThe receiver of the flow
flowRateint96The wanted flowrate in wad/second. Only positive values are valid here.

Return Values

NameTypeDescription
[0]boolbool

Fn flow (with User Data)

function flow(
contract ISuperToken token,
address receiver,
int96 flowRate,
bytes userData
)
internal
returns (bool)

Set CFA flowrate with userData

Parameters

NameTypeDescription
tokencontract ISuperTokenSuper token address
receiveraddressThe receiver of the flow
flowRateint96The wanted flowrate in wad/second. Only positive values are valid here.
userDatabytesThe userdata passed along with call

Return Values

NameTypeDescription
[0]boolbool

Fn createFlow

function createFlow(
contract ISuperToken token,
address receiver,
int96 flowRate
)
internal
returns (bool)

Create flow without userData

Parameters

NameTypeDescription
tokencontract ISuperTokenThe token used in flow
receiveraddressThe receiver of the flow
flowRateint96The desired flowRate

Fn createFlow (with User Data)

function createFlow(
contract ISuperToken token,
address receiver,
int96 flowRate,
bytes userData
)
internal
returns (bool)

Create flow with userData

Parameters

NameTypeDescription
tokencontract ISuperTokenThe token used in flow
receiveraddressThe receiver of the flow
flowRateint96The desired flowRate
userDatabytesThe userdata passed along with call

Fn updateFlow

function updateFlow(
contract ISuperToken token,
address receiver,
int96 flowRate
)
internal
returns (bool)

Update flow without userData

Parameters

NameTypeDescription
tokencontract ISuperTokenThe token used in flow
receiveraddressThe receiver of the flow
flowRateint96The desired flowRate

Fn updateFlow (with User Data)

function updateFlow(
contract ISuperToken token,
address receiver,
int96 flowRate,
bytes userData
)
internal
returns (bool)

Update flow with userData

Parameters

NameTypeDescription
tokencontract ISuperTokenThe token used in flow
receiveraddressThe receiver of the flow
flowRateint96The desired flowRate
userDatabytesThe userdata passed along with call

Fn deleteFlow

function deleteFlow(
contract ISuperToken token,
address sender,
address receiver
)
internal
returns (bool)

Delete flow without userData

Parameters

NameTypeDescription
tokencontract ISuperTokenThe token used in flow
senderaddressThe sender of the flow
receiveraddressThe receiver of the flow

Fn deleteFlow (with User Data)

function deleteFlow(
contract ISuperToken token,
address sender,
address receiver,
bytes userData
)
internal
returns (bool)

Delete flow with userData

Parameters

NameTypeDescription
tokencontract ISuperTokenThe token used in flow
senderaddressThe sender of the flow
receiveraddressThe receiver of the flow
userDatabytesThe userdata passed along with call

Fn flowFrom

function flowFrom(
contract ISuperToken token,
address sender,
address receiver,
int96 flowRate
)
internal
returns (bool)

Parameters

NameTypeDescription
tokencontract ISuperTokenSuper token address
senderaddressThe sender of the flow
receiveraddressThe receiver of the flow
flowRateint96The wanted flowRate in wad/second. Only positive values are valid here.

Return Values

NameTypeDescription
[0]boolbool

Like flow, but can be invoked by an account with flowOperator permissions on behalf of the sender account.

Fn flowFrom (with User Data)

function flowFrom(
contract ISuperToken token,
address sender,
address receiver,
int96 flowRate,
bytes userData
)
internal
returns (bool)

Parameters

NameTypeDescription
tokencontract ISuperTokenSuper token address
senderaddressThe sender of the flow
receiveraddressThe receiver of the flow
flowRateint96The wanted flowRate in wad/second. Only positive values are valid here.
userDatabytesThe userdata passed along with call

Return Values

NameTypeDescription
[0]boolbool

Like flowFrom, but takes userData

Fn setFlowPermissions

function setFlowPermissions(
contract ISuperToken token,
address flowOperator,
bool allowCreate,
bool allowUpdate,
bool allowDelete,
int96 flowRateAllowance
)
internal
returns (bool)

Update permissions for flow operator

Parameters

NameTypeDescription
tokencontract ISuperTokenThe token used in flow
flowOperatoraddressThe address given flow permissions
allowCreateboolcreation permissions
allowUpdatebool
allowDeletebool
flowRateAllowanceint96The allowance provided to flowOperator

Fn setMaxFlowPermissions

function setMaxFlowPermissions(
contract ISuperToken token,
address flowOperator
)
internal
returns (bool)

Update permissions for flow operator - give operator max permissions

Parameters

NameTypeDescription
tokencontract ISuperTokenThe token used in flow
flowOperatoraddressThe address given flow permissions

Fn revokeFlowPermissions

function revokeFlowPermissions(
contract ISuperToken token,
address flowOperator
)
internal
returns (bool)

Update permissions for flow operator - revoke all permission

Parameters

NameTypeDescription
tokencontract ISuperTokenThe token used in flow
flowOperatoraddressThe address given flow permissions

Fn increaseFlowRateAllowance

function increaseFlowRateAllowance(
contract ISuperToken token,
address flowOperator,
int96 addedFlowRateAllowance
)
internal
returns (bool)

Increases the flow rate allowance for flow operator

Parameters

NameTypeDescription
tokencontract ISuperTokenThe token used in flow
flowOperatoraddressThe address whose flow rate allowance is increased
addedFlowRateAllowanceint96amount to increase allowance by

allowing userData to be a parameter here triggered stack too deep error

Fn increaseFlowRateAllowance (with User Data)

function increaseFlowRateAllowance(
contract ISuperToken token,
address flowOperator,
int96 addedFlowRateAllowance,
bytes userData
)
internal
returns (bool)

Increases the flow rate allowance for flow operator

Parameters

NameTypeDescription
tokencontract ISuperTokenThe token used in flow
flowOperatoraddressThe address whose flow rate allowance is increased
addedFlowRateAllowanceint96amount to increase allowance by
userDatabytesThe userdata passed along with call

allowing userData to be a parameter here triggered stack too deep error

Fn decreaseFlowRateAllowance

function decreaseFlowRateAllowance(
contract ISuperToken token,
address flowOperator,
int96 subtractedFlowRateAllowance
)
internal
returns (bool)

Decreases the flow rate allowance for flow operator

Parameters

NameTypeDescription
tokencontract ISuperTokenThe token used in flow
flowOperatoraddressThe address whose flow rate allowance is decreased
subtractedFlowRateAllowanceint96amount to decrease allowance by

allowing userData to be a parameter here triggered stack too deep error

Fn decreaseFlowRateAllowance (with User Data)

function decreaseFlowRateAllowance(
contract ISuperToken token,
address flowOperator,
int96 subtractedFlowRateAllowance,
bytes userData
)
internal
returns (bool)

Decreases the flow rate allowance for flow operator

Parameters

NameTypeDescription
tokencontract ISuperTokenThe token used in flow
flowOperatoraddressThe address whose flow rate allowance is decreased
subtractedFlowRateAllowanceint96amount to decrease allowance by
userDatabytesThe userdata passed along with call

allowing userData to be a parameter here triggered stack too deep error

Fn increaseFlowRateAllowanceWithPermissions

function increaseFlowRateAllowanceWithPermissions(
contract ISuperToken token,
address flowOperator,
uint8 permissionsToAdd,
int96 addedFlowRateAllowance
)
internal
returns (bool)

Increases the flow rate allowance for flow operator and adds the permissions

Parameters

NameTypeDescription
tokencontract ISuperTokenThe token used in flow
flowOperatoraddressThe address whose flow rate allowance is increased
permissionsToAdduint8The permissions to add for the flow operator
addedFlowRateAllowanceint96amount to increase allowance by

allowing userData to be a parameter here triggered stack too deep error

Fn increaseFlowRateAllowanceWithPermissions (with User Data)

function increaseFlowRateAllowanceWithPermissions(
contract ISuperToken token,
address flowOperator,
uint8 permissionsToAdd,
int96 addedFlowRateAllowance,
bytes userData
)
internal
returns (bool)

Increases the flow rate allowance for flow operator and adds the permissions

Parameters

NameTypeDescription
tokencontract ISuperTokenThe token used in flow
flowOperatoraddressThe address whose flow rate allowance is increased
permissionsToAdduint8The permissions to add for the flow operator
addedFlowRateAllowanceint96amount to increase allowance by
userDatabytesThe userdata passed along with call

allowing userData to be a parameter here triggered stack too deep error

Fn decreaseFlowRateAllowanceWithPermissions

function decreaseFlowRateAllowanceWithPermissions(
contract ISuperToken token,
address flowOperator,
uint8 permissionsToRemove,
int96 subtractedFlowRateAllowance
)
internal
returns (bool)

Decreases the flow rate allowance for flow operator and removes the permissions

Parameters

NameTypeDescription
tokencontract ISuperTokenThe token used in flow
flowOperatoraddressThe address whose flow rate allowance is subtracted
permissionsToRemoveuint8The permissions to remove for the flow operator
subtractedFlowRateAllowanceint96amount to subtract allowance by

allowing userData to be a parameter here triggered stack too deep error

Fn decreaseFlowRateAllowanceWithPermissions (with User Data)

function decreaseFlowRateAllowanceWithPermissions(
contract ISuperToken token,
address flowOperator,
uint8 permissionsToRemove,
int96 subtractedFlowRateAllowance,
bytes userData
)
internal
returns (bool)

Decreases the flow rate allowance for flow operator and removes the permissions

Parameters

NameTypeDescription
tokencontract ISuperTokenThe token used in flow
flowOperatoraddressThe address whose flow rate allowance is subtracted
permissionsToRemoveuint8The permissions to remove for the flow operator
subtractedFlowRateAllowanceint96amount to subtract allowance by
userDatabytesThe userdata passed along with call

allowing userData to be a parameter here triggered stack too deep error

Fn createFlowFrom

function createFlowFrom(
contract ISuperToken token,
address sender,
address receiver,
int96 flowRate
)
internal
returns (bool)

Creates flow as an operator without userData

Parameters

NameTypeDescription
tokencontract ISuperTokenThe token to flow
senderaddressThe sender of the flow
receiveraddressThe receiver of the flow
flowRateint96The desired flowRate

Fn createFlowFrom (with User Data)

function createFlowFrom(
contract ISuperToken token,
address sender,
address receiver,
int96 flowRate,
bytes userData
)
internal
returns (bool)

Creates flow as an operator with userData

Parameters

NameTypeDescription
tokencontract ISuperTokenThe token to flow
senderaddressThe sender of the flow
receiveraddressThe receiver of the flow
flowRateint96The desired flowRate
userDatabytesThe user provided data

Fn updateFlowFrom

function updateFlowFrom(
contract ISuperToken token,
address sender,
address receiver,
int96 flowRate
)
internal
returns (bool)

Updates flow as an operator without userData

Parameters

NameTypeDescription
tokencontract ISuperTokenThe token to flow
senderaddressThe sender of the flow
receiveraddressThe receiver of the flow
flowRateint96The desired flowRate

Fn updateFlowFrom (with User Data)

function updateFlowFrom(
contract ISuperToken token,
address sender,
address receiver,
int96 flowRate,
bytes userData
)
internal
returns (bool)

Updates flow as an operator with userData

Parameters

NameTypeDescription
tokencontract ISuperTokenThe token to flow
senderaddressThe sender of the flow
receiveraddressThe receiver of the flow
flowRateint96The desired flowRate
userDatabytesThe user provided data

Fn deleteFlowFrom

function deleteFlowFrom(
contract ISuperToken token,
address sender,
address receiver
)
internal
returns (bool)

Deletes flow as an operator without userData

Parameters

NameTypeDescription
tokencontract ISuperTokenThe token to flow
senderaddressThe sender of the flow
receiveraddressThe receiver of the flow

Fn deleteFlowFrom (with User Data)

function deleteFlowFrom(
contract ISuperToken token,
address sender,
address receiver,
bytes userData
)
internal
returns (bool)

Deletes flow as an operator with userData

Parameters

NameTypeDescription
tokencontract ISuperTokenThe token to flow
senderaddressThe sender of the flow
receiveraddressThe receiver of the flow
userDatabytesThe user provided data

Fn createFlowWithCtx

function createFlowWithCtx(
contract ISuperToken token,
address receiver,
int96 flowRate,
bytes ctx
)
internal
returns (bytes newCtx)

Create flow with context and userData

Parameters

NameTypeDescription
tokencontract ISuperTokenThe token to flow
receiveraddressThe receiver of the flow
flowRateint96The desired flowRate
ctxbytesContext bytes (see ISuperfluid.sol for Context struct)

Return Values

NameTypeDescription
newCtxbytesThe updated context after the execution of the agreement function

Fn createFlowFromWithCtx

function createFlowFromWithCtx(
contract ISuperToken token,
address sender,
address receiver,
int96 flowRate,
bytes ctx
)
internal
returns (bytes newCtx)

Create flow by operator with context

Parameters

NameTypeDescription
tokencontract ISuperTokenThe token to flow
senderaddressThe sender of the flow
receiveraddressThe receiver of the flow
flowRateint96The desired flowRate
ctxbytesContext bytes (see ISuperfluid.sol for Context struct)

Return Values

NameTypeDescription
newCtxbytesThe updated context after the execution of the agreement function

Fn updateFlowWithCtx

function updateFlowWithCtx(
contract ISuperToken token,
address receiver,
int96 flowRate,
bytes ctx
)
internal
returns (bytes newCtx)

Update flow with context

Parameters

NameTypeDescription
tokencontract ISuperTokenThe token to flow
receiveraddressThe receiver of the flow
flowRateint96The desired flowRate
ctxbytesContext bytes (see ISuperfluid.sol for Context struct)

Return Values

NameTypeDescription
newCtxbytesThe updated context after the execution of the agreement function

Fn updateFlowFromWithCtx

function updateFlowFromWithCtx(
contract ISuperToken token,
address sender,
address receiver,
int96 flowRate,
bytes ctx
)
internal
returns (bytes newCtx)

Update flow by operator with context

Parameters

NameTypeDescription
tokencontract ISuperTokenThe token to flow
senderaddressThe receiver of the flow
receiveraddressThe receiver of the flow
flowRateint96The desired flowRate
ctxbytesContext bytes (see ISuperfluid.sol for Context struct)

Return Values

NameTypeDescription
newCtxbytesThe updated context after the execution of the agreement function

Fn deleteFlowWithCtx

function deleteFlowWithCtx(
contract ISuperToken token,
address sender,
address receiver,
bytes ctx
)
internal
returns (bytes newCtx)

Delete flow with context

Parameters

NameTypeDescription
tokencontract ISuperTokenThe token to flow
senderaddressThe sender of the flow
receiveraddressThe receiver of the flow
ctxbytesContext bytes (see ISuperfluid.sol for Context struct)

Return Values

NameTypeDescription
newCtxbytesThe updated context after the execution of the agreement function

Fn deleteFlowFromWithCtx

function deleteFlowFromWithCtx(
contract ISuperToken token,
address sender,
address receiver,
bytes ctx
)
internal
returns (bytes newCtx)

Delete flow by operator with context

Parameters

NameTypeDescription
tokencontract ISuperTokenThe token to flow
senderaddressThe sender of the flow
receiveraddressThe receiver of the flow
ctxbytesContext bytes (see ISuperfluid.sol for Context struct)

Return Values

NameTypeDescription
newCtxbytesThe updated context after the execution of the agreement function

Fn setFlowPermissionsWithCtx

function setFlowPermissionsWithCtx(
contract ISuperToken token,
address flowOperator,
bool allowCreate,
bool allowUpdate,
bool allowDelete,
int96 flowRateAllowance,
bytes ctx
)
internal
returns (bytes newCtx)

Update permissions for flow operator in callback

Parameters

NameTypeDescription
tokencontract ISuperTokenThe token used in flow
flowOperatoraddressThe address given flow permissions
allowCreateboolcreation permissions
allowUpdatebool
allowDeletebool
flowRateAllowanceint96The allowance provided to flowOperator
ctxbytesContext bytes (see ISuperfluid.sol for Context struct)

Return Values

NameTypeDescription
newCtxbytesThe updated context after the execution of the agreement function

allowing userData to be a parameter here triggered stack too deep error

Fn setMaxFlowPermissionsWithCtx

function setMaxFlowPermissionsWithCtx(
contract ISuperToken token,
address flowOperator,
bytes ctx
)
internal
returns (bytes newCtx)

Update permissions for flow operator - give operator max permissions

Parameters

NameTypeDescription
tokencontract ISuperTokenThe token used in flow
flowOperatoraddressThe address given flow permissions
ctxbytesContext bytes (see ISuperfluid.sol for Context struct)

Return Values

NameTypeDescription
newCtxbytesThe updated context after the execution of the agreement function

Fn revokeFlowPermissionsWithCtx

function revokeFlowPermissionsWithCtx(
contract ISuperToken token,
address flowOperator,
bytes ctx
)
internal
returns (bytes newCtx)

Update permissions for flow operator - revoke all permission

Parameters

NameTypeDescription
tokencontract ISuperTokenThe token used in flow
flowOperatoraddressThe address given flow permissions
ctxbytesContext bytes (see ISuperfluid.sol for Context struct)

Return Values

NameTypeDescription
newCtxbytesThe updated context after the execution of the agreement function

Fn getCFAFlowRate

function getCFAFlowRate(
contract ISuperToken token,
address sender,
address receiver
)
internal
returns (int96 flowRate)

get CFA flow rate between two accounts for given token

Parameters

NameTypeDescription
tokencontract ISuperTokenThe token used in flow
senderaddressThe sender of the flow
receiveraddressThe receiver of the flow

Return Values

NameTypeDescription
flowRateint96The flow rate

Fn getCFAFlowInfo

function getCFAFlowInfo(
contract ISuperToken token,
address sender,
address receiver
)
internal
returns (uint256 lastUpdated, int96 flowRate, uint256 deposit, uint256 owedDeposit)

get CFA flow info between two accounts for given token

Parameters

NameTypeDescription
tokencontract ISuperTokenThe token used in flow
senderaddressThe sender of the flow
receiveraddressThe receiver of the flow

Return Values

NameTypeDescription
lastUpdateduint256Timestamp of flow creation or last flowrate change
flowRateint96The flow rate
deposituint256The amount of deposit the flow
owedDeposituint256The amount of owed deposit of the flow

Fn getCFANetFlowRate

function getCFANetFlowRate(
contract ISuperToken token,
address account
)
internal
returns (int96 flowRate)

get CFA net flow rate for given account for given token

Parameters

NameTypeDescription
tokencontract ISuperTokenSuper token address
accountaddressAccount to query

Return Values

NameTypeDescription
flowRateint96The net flow rate of the account

Fn getCFANetFlowInfo

function getCFANetFlowInfo(
contract ISuperToken token,
address account
)
internal
returns (uint256 lastUpdated, int96 flowRate, uint256 deposit, uint256 owedDeposit)

get the aggregated CFA flow info of the account

Parameters

NameTypeDescription
tokencontract ISuperTokenSuper token address
accountaddressAccount to query

Return Values

NameTypeDescription
lastUpdateduint256Timestamp of the last change of the net flow
flowRateint96The net flow rate of token for account
deposituint256The sum of all deposits for account's flows
owedDeposituint256The sum of all owed deposits for account's flows

Fn getFlowPermissions

function getFlowPermissions(
contract ISuperToken token,
address sender,
address flowOperator
)
internal
returns (bool allowCreate, bool allowUpdate, bool allowDelete, int96 flowRateAllowance)

get existing CFA flow permissions

Parameters

NameTypeDescription
tokencontract ISuperTokenThe token used in flow
senderaddresssender of a flow
flowOperatoraddressthe address we are checking permissions of for sender & token

Return Values

NameTypeDescription
allowCreateboolis true if the flowOperator can create flows
allowUpdateboolis true if the flowOperator can update flows
allowDeleteboolis true if the flowOperator can delete flows
flowRateAllowanceint96The flow rate allowance the flowOperator is granted (only goes down)

Fn createPool

function createPool(
contract ISuperToken token,
address admin,
struct PoolConfig poolConfig
)
internal
returns (contract ISuperfluidPool pool)

Creates a new Superfluid Pool.

Parameters

NameTypeDescription
tokencontract ISuperTokenThe Super Token address.
adminaddressThe pool admin address.
poolConfigstruct PoolConfigThe pool configuration (see PoolConfig in IGeneralDistributionAgreementV1.sol)

Return Values

NameTypeDescription
poolcontract ISuperfluidPoolThe address of the deployed Superfluid Pool

Fn createPool

function createPool(
contract ISuperToken token,
address admin
)
internal
returns (contract ISuperfluidPool pool)

Creates a new Superfluid Pool with default PoolConfig: units not transferrable, allow multi-distributors

Parameters

NameTypeDescription
tokencontract ISuperTokenThe Super Token address.
adminaddressThe pool admin address.

Return Values

NameTypeDescription
poolcontract ISuperfluidPoolThe address of the deployed Superfluid Pool

Fn createPool

function createPool(
contract ISuperToken token
)
internal
returns (contract ISuperfluidPool pool)

Creates a new Superfluid Pool with default PoolConfig and the caller set as admin

Parameters

NameTypeDescription
tokencontract ISuperToken

Return Values

NameTypeDescription
poolcontract ISuperfluidPoolThe address of the deployed Superfluid Pool

Fn claimAll

function claimAll(
contract ISuperToken token,
contract ISuperfluidPool pool,
address memberAddress
)
internal
returns (bool)

Claims all tokens from the pool.

Parameters

NameTypeDescription
tokencontract ISuperTokenThe Super Token address.
poolcontract ISuperfluidPoolThe Superfluid Pool to claim from.
memberAddressaddressThe address of the member to claim for.

Return Values

NameTypeDescription
[0]boolA boolean value indicating whether the claim was successful.

Fn claimAll (with User Data)

function claimAll(
contract ISuperToken token,
contract ISuperfluidPool pool,
address memberAddress,
bytes userData
)
internal
returns (bool)

Claims all tokens from the pool.

Parameters

NameTypeDescription
tokencontract ISuperTokenThe Super Token address.
poolcontract ISuperfluidPoolThe Superfluid Pool to claim from.
memberAddressaddressThe address of the member to claim for.
userDatabytesUser-specific data.

Return Values

NameTypeDescription
[0]boolA boolean value indicating whether the claim was successful.

Fn connectPool

function connectPool(
contract ISuperToken token,
contract ISuperfluidPool pool
)
internal
returns (bool)

Connects a pool member to pool.

Parameters

NameTypeDescription
tokencontract ISuperTokenThe Super Token address.
poolcontract ISuperfluidPoolThe Superfluid Pool to connect.

Return Values

NameTypeDescription
[0]boolA boolean value indicating whether the connection was successful.

Fn connectPool (with User Data)

function connectPool(
contract ISuperToken token,
contract ISuperfluidPool pool,
bytes userData
)
internal
returns (bool)

Connects a pool member to pool.

Parameters

NameTypeDescription
tokencontract ISuperTokenThe Super Token address.
poolcontract ISuperfluidPoolThe Superfluid Pool to connect.
userDatabytesUser-specific data.

Return Values

NameTypeDescription
[0]boolA boolean value indicating whether the connection was successful.

Fn disconnectPool

function disconnectPool(
contract ISuperToken token,
contract ISuperfluidPool pool
)
internal
returns (bool)

Disconnects a pool member from pool.

Parameters

NameTypeDescription
tokencontract ISuperTokenThe Super Token address.
poolcontract ISuperfluidPoolThe Superfluid Pool to disconnect.

Return Values

NameTypeDescription
[0]boolA boolean value indicating whether the disconnection was successful.

Fn disconnectPool (with User Data)

function disconnectPool(
contract ISuperToken token,
contract ISuperfluidPool pool,
bytes userData
)
internal
returns (bool)

Disconnects a pool member from pool.

Parameters

NameTypeDescription
tokencontract ISuperTokenThe Super Token address.
poolcontract ISuperfluidPoolThe Superfluid Pool to disconnect.
userDatabytesUser-specific data.

Return Values

NameTypeDescription
[0]boolA boolean value indicating whether the disconnection was successful.

Fn distribute

function distribute(
contract ISuperToken token,
contract ISuperfluidPool pool,
uint256 requestedAmount
)
internal
returns (bool)

Tries to distribute requestedAmount amount of token from from to pool.

Parameters

NameTypeDescription
tokencontract ISuperTokenThe Super Token address.
poolcontract ISuperfluidPoolThe Superfluid Pool address.
requestedAmountuint256The amount of tokens to distribute.

Return Values

NameTypeDescription
[0]boolA boolean value indicating whether the distribution was successful.

Fn distribute (with User Data)

function distribute(
contract ISuperToken token,
address from,
contract ISuperfluidPool pool,
uint256 requestedAmount,
bytes userData
)
internal
returns (bool)

Tries to distribute requestedAmount amount of token from from to pool.

Parameters

NameTypeDescription
tokencontract ISuperTokenThe Super Token address.
fromaddressThe address from which to distribute tokens.
poolcontract ISuperfluidPoolThe Superfluid Pool address.
requestedAmountuint256The amount of tokens to distribute.
userDatabytesUser-specific data.

Return Values

NameTypeDescription
[0]boolA boolean value indicating whether the distribution was successful.

Fn distributeFlow

function distributeFlow(
contract ISuperToken token,
contract ISuperfluidPool pool,
int96 requestedFlowRate
)
internal
returns (bool)

Tries to distribute flow at requestedFlowRate of token from from to pool.

Parameters

NameTypeDescription
tokencontract ISuperTokenThe Super Token address.
poolcontract ISuperfluidPoolThe Superfluid Pool address.
requestedFlowRateint96The flow rate of tokens to distribute.

Return Values

NameTypeDescription
[0]boolA boolean value indicating whether the distribution was successful.

Fn distributeFlow (with User Data)

function distributeFlow(
contract ISuperToken token,
address from,
contract ISuperfluidPool pool,
int96 requestedFlowRate,
bytes userData
)
internal
returns (bool)

Tries to distribute flow at requestedFlowRate of token from from to pool.

Parameters

NameTypeDescription
tokencontract ISuperTokenThe Super Token address.
fromaddressThe address from which to distribute tokens.
poolcontract ISuperfluidPoolThe Superfluid Pool address.
requestedFlowRateint96The flow rate of tokens to distribute.
userDatabytesUser-specific data.

Return Values

NameTypeDescription
[0]boolA boolean value indicating whether the distribution was successful.

Fn claimAllWithCtx

function claimAllWithCtx(
contract ISuperToken token,
contract ISuperfluidPool pool,
address memberAddress,
bytes ctx
)
internal
returns (bytes newCtx)

Claims all tokens from the pool.

Parameters

NameTypeDescription
tokencontract ISuperTokenThe Super Token address.
poolcontract ISuperfluidPoolThe Superfluid Pool to claim from.
memberAddressaddressThe address of the member to claim for.
ctxbytesContext bytes (see ISuperfluid.sol for Context struct)

Return Values

NameTypeDescription
newCtxbytesThe updated context after the execution of the agreement function

Fn connectPoolWithCtx

function connectPoolWithCtx(
contract ISuperToken token,
contract ISuperfluidPool pool,
bytes ctx
)
internal
returns (bytes newCtx)

Connects a pool member to pool.

Parameters

NameTypeDescription
tokencontract ISuperTokenThe Super Token address.
poolcontract ISuperfluidPoolThe Superfluid Pool to connect.
ctxbytesContext bytes (see ISuperfluid.sol for Context struct)

Return Values

NameTypeDescription
newCtxbytesThe updated context after the execution of the agreement function

Fn disconnectPoolWithCtx

function disconnectPoolWithCtx(
contract ISuperToken token,
contract ISuperfluidPool pool,
bytes ctx
)
internal
returns (bytes newCtx)

Disconnects a pool member from pool.

Parameters

NameTypeDescription
tokencontract ISuperTokenThe Super Token address.
poolcontract ISuperfluidPoolThe Superfluid Pool to disconnect.
ctxbytesContext bytes (see ISuperfluid.sol for Context struct)

Return Values

NameTypeDescription
newCtxbytesThe updated context after the execution of the agreement function

Fn distributeWithCtx

function distributeWithCtx(
contract ISuperToken token,
address from,
contract ISuperfluidPool pool,
uint256 requestedAmount,
bytes ctx
)
internal
returns (bytes newCtx)

Tries to distribute requestedAmount amount of token from from to pool.

Parameters

NameTypeDescription
tokencontract ISuperTokenThe Super Token address.
fromaddressThe address from which to distribute tokens.
poolcontract ISuperfluidPoolThe Superfluid Pool address.
requestedAmountuint256The amount of tokens to distribute.
ctxbytesContext bytes (see ISuperfluid.sol for Context struct)

Return Values

NameTypeDescription
newCtxbytesThe updated context after the execution of the agreement function

Fn distributeFlowWithCtx

function distributeFlowWithCtx(
contract ISuperToken token,
address from,
contract ISuperfluidPool pool,
int96 requestedFlowRate,
bytes ctx
)
internal
returns (bytes newCtx)

Tries to distribute flow at requestedFlowRate of token from from to pool.

Parameters

NameTypeDescription
tokencontract ISuperTokenThe Super Token address.
fromaddressThe address from which to distribute tokens.
poolcontract ISuperfluidPoolThe Superfluid Pool address.
requestedFlowRateint96The flow rate of tokens to distribute.
ctxbytesContext bytes (see ISuperfluid.sol for Context struct)

Return Values

NameTypeDescription
newCtxbytesThe updated context after the execution of the agreement function

Fn getGDAFlowRate

function getGDAFlowRate(
contract ISuperToken token,
address distributor,
contract ISuperfluidPool pool
)
internal
returns (int96 flowRate)

get flowrate between a distributor and pool for given token

Parameters

NameTypeDescription
tokencontract ISuperTokenThe token used in flow
distributoraddressThe ditributor of the flow
poolcontract ISuperfluidPoolThe GDA pool

Return Values

NameTypeDescription
flowRateint96The flow rate

Fn getFlowDistributionFlowRate

function getFlowDistributionFlowRate(
contract ISuperToken token,
address from,
contract ISuperfluidPool to
)
internal
returns (int96)

Parameters

NameTypeDescription
tokencontract ISuperToken
fromaddress
tocontract ISuperfluidPool

alias of getGDAFlowRate

Fn getGDAFlowInfo

function getGDAFlowInfo(
contract ISuperToken token,
address distributor,
contract ISuperfluidPool pool
)
internal
returns (uint256 lastUpdated, int96 flowRate, uint256 deposit)

get flow info of a distributor to a pool for given token

Parameters

NameTypeDescription
tokencontract ISuperTokenThe token used in flow
distributoraddressThe ditributor of the flow
poolcontract ISuperfluidPoolThe GDA pool

Return Values

NameTypeDescription
lastUpdateduint256Timestamp of flow creation or last flowrate change
flowRateint96The flow rate
deposituint256The amount of deposit the flow

Fn getGDANetFlowRate

function getGDANetFlowRate(
contract ISuperToken token,
address account
)
internal
returns (int96 flowRate)

get GDA net flow rate for given account for given token

Parameters

NameTypeDescription
tokencontract ISuperTokenSuper token address
accountaddressAccount to query

Return Values

NameTypeDescription
flowRateint96The net flow rate of the account

Fn getGDANetFlowInfo

function getGDANetFlowInfo(
contract ISuperToken token,
address account
)
internal
returns (uint256 lastUpdated, int96 flowRate, uint256 deposit, uint256 owedDeposit)

get the aggregated GDA flow info of the account

Parameters

NameTypeDescription
tokencontract ISuperTokenSuper token address
accountaddressAccount to query

Return Values

NameTypeDescription
lastUpdateduint256Timestamp of the last change of the net flow
flowRateint96The net flow rate of token for account
deposituint256The sum of all deposits for account's flows
owedDeposituint256The sum of all owed deposits for account's flows

Fn getPoolAdjustmentFlowRate

function getPoolAdjustmentFlowRate(
contract ISuperToken token,
contract ISuperfluidPool pool
)
internal
returns (int96 poolAdjustmentFlowRate)

get the adjustment flow rate for a pool

Parameters

NameTypeDescription
tokencontract ISuperTokenSuper token address
poolcontract ISuperfluidPoolThe pool to query

Return Values

NameTypeDescription
poolAdjustmentFlowRateint96The adjustment flow rate of the pool

Fn getTotalAmountReceivedByMember

function getTotalAmountReceivedByMember(
contract ISuperToken token,
contract ISuperfluidPool pool,
address memberAddr
)
internal
returns (uint256 totalAmountReceived)

Get the total amount of tokens received by a member via instant and flowing distributions

Parameters

NameTypeDescription
tokencontract ISuperTokenSuper token address
poolcontract ISuperfluidPoolThe pool to query
memberAddraddressThe member to query

Return Values

NameTypeDescription
totalAmountReceiveduint256The total amount received by the member

Fn getTotalAmountReceivedFromPool

function getTotalAmountReceivedFromPool(
contract ISuperToken token,
contract ISuperfluidPool pool,
address memberAddr
)
internal
returns (uint256 totalAmountReceived)

Parameters

NameTypeDescription
tokencontract ISuperToken
poolcontract ISuperfluidPool
memberAddraddress

alias for getTotalAmountReceivedByMember

Fn estimateFlowDistributionActualFlowRate

function estimateFlowDistributionActualFlowRate(
contract ISuperToken token,
address from,
contract ISuperfluidPool to,
int96 requestedFlowRate
)
internal
returns (int96 actualFlowRate, int96 totalDistributionFlowRate)

Parameters

NameTypeDescription
tokencontract ISuperToken
fromaddress
tocontract ISuperfluidPool
requestedFlowRateint96

Fn estimateDistributionActualAmount

function estimateDistributionActualAmount(
contract ISuperToken token,
address from,
contract ISuperfluidPool to,
uint256 requestedAmount
)
internal
returns (uint256 actualAmount)

Parameters

NameTypeDescription
tokencontract ISuperToken
fromaddress
tocontract ISuperfluidPool
requestedAmountuint256

Fn isMemberConnected

function isMemberConnected(
contract ISuperToken token,
address pool,
address member
)
internal
returns (bool)

Parameters

NameTypeDescription
tokencontract ISuperToken
pooladdress
memberaddress