CFAv1Forwarder
The CFAv1Forwarder contract is a Superfluid forwarder that implements the Constant Flow Agreement (CFA) related functions. It is a contract specifically made immutable in order to facilitate the interaction with Money Streaming through the Constant Flow Agreement (CFA).
This contract is optimized for interaction that would happen from outside the blockchain (off-chain). For more information on the best practices regarding this interaction, please refer to the Interact Off-Chain section of this documentation.
ABI
In order to interact with the CFAv1Forwarder
contract, you can use the following ABI:
Click here to show CFAv1Forwarder
ABI
[
{
"inputs": [
{
"internalType": "contract ISuperfluid",
"name": "host",
"type": "address"
}
],
"stateMutability": "nonpayable",
"type": "constructor"
},
{ "inputs": [], "name": "CFA_FWD_INVALID_FLOW_RATE", "type": "error" },
{
"inputs": [
{
"internalType": "contract ISuperToken",
"name": "token",
"type": "address"
},
{ "internalType": "address", "name": "sender", "type": "address" },
{ "internalType": "address", "name": "receiver", "type": "address" },
{ "internalType": "int96", "name": "flowrate", "type": "int96" },
{ "internalType": "bytes", "name": "userData", "type": "bytes" }
],
"name": "createFlow",
"outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "contract ISuperToken",
"name": "token",
"type": "address"
},
{ "internalType": "address", "name": "sender", "type": "address" },
{ "internalType": "address", "name": "receiver", "type": "address" },
{ "internalType": "bytes", "name": "userData", "type": "bytes" }
],
"name": "deleteFlow",
"outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "contract ISuperToken",
"name": "token",
"type": "address"
},
{ "internalType": "address", "name": "account", "type": "address" }
],
"name": "getAccountFlowInfo",
"outputs": [
{ "internalType": "uint256", "name": "lastUpdated", "type": "uint256" },
{ "internalType": "int96", "name": "flowrate", "type": "int96" },
{ "internalType": "uint256", "name": "deposit", "type": "uint256" },
{ "internalType": "uint256", "name": "owedDeposit", "type": "uint256" }
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "contract ISuperToken",
"name": "token",
"type": "address"
},
{ "internalType": "address", "name": "account", "type": "address" }
],
"name": "getAccountFlowrate",
"outputs": [
{ "internalType": "int96", "name": "flowrate", "type": "int96" }
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "contract ISuperToken",
"name": "token",
"type": "address"
},
{ "internalType": "int96", "name": "flowrate", "type": "int96" }
],
"name": "getBufferAmountByFlowrate",
"outputs": [
{ "internalType": "uint256", "name": "bufferAmount", "type": "uint256" }
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "contract ISuperToken",
"name": "token",
"type": "address"
},
{ "internalType": "address", "name": "sender", "type": "address" },
{ "internalType": "address", "name": "receiver", "type": "address" }
],
"name": "getFlowInfo",
"outputs": [
{ "internalType": "uint256", "name": "lastUpdated", "type": "uint256" },
{ "internalType": "int96", "name": "flowrate", "type": "int96" },
{ "internalType": "uint256", "name": "deposit", "type": "uint256" },
{ "internalType": "uint256", "name": "owedDeposit", "type": "uint256" }
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "contract ISuperToken",
"name": "token",
"type": "address"
},
{ "internalType": "address", "name": "sender", "type": "address" },
{ "internalType": "address", "name": "flowOperator", "type": "address" }
],
"name": "getFlowOperatorPermissions",
"outputs": [
{ "internalType": "uint8", "name": "permissions", "type": "uint8" },
{ "internalType": "int96", "name": "flowrateAllowance", "type": "int96" }
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "contract ISuperToken",
"name": "token",
"type": "address"
},
{ "internalType": "address", "name": "sender", "type": "address" },
{ "internalType": "address", "name": "receiver", "type": "address" }
],
"name": "getFlowrate",
"outputs": [
{ "internalType": "int96", "name": "flowrate", "type": "int96" }
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "contract ISuperToken",
"name": "token",
"type": "address"
},
{ "internalType": "address", "name": "flowOperator", "type": "address" }
],
"name": "grantPermissions",
"outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "contract ISuperToken",
"name": "token",
"type": "address"
},
{ "internalType": "address", "name": "flowOperator", "type": "address" }
],
"name": "revokePermissions",
"outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "contract ISuperToken",
"name": "token",
"type": "address"
},
{ "internalType": "address", "name": "receiver", "type": "address" },
{ "internalType": "int96", "name": "flowrate", "type": "int96" }
],
"name": "setFlowrate",
"outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "contract ISuperToken",
"name": "token",
"type": "address"
},
{ "internalType": "address", "name": "sender", "type": "address" },
{ "internalType": "address", "name": "receiver", "type": "address" },
{ "internalType": "int96", "name": "flowrate", "type": "int96" }
],
"name": "setFlowrateFrom",
"outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "contract ISuperToken",
"name": "token",
"type": "address"
},
{ "internalType": "address", "name": "sender", "type": "address" },
{ "internalType": "address", "name": "receiver", "type": "address" },
{ "internalType": "int96", "name": "flowrate", "type": "int96" },
{ "internalType": "bytes", "name": "userData", "type": "bytes" }
],
"name": "updateFlow",
"outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "contract ISuperToken",
"name": "token",
"type": "address"
},
{ "internalType": "address", "name": "flowOperator", "type": "address" },
{ "internalType": "uint8", "name": "permissions", "type": "uint8" },
{ "internalType": "int96", "name": "flowrateAllowance", "type": "int96" }
],
"name": "updateFlowOperatorPermissions",
"outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],
"stateMutability": "nonpayable",
"type": "function"
}
]
CFA_FWD_INVALID_FLOW_RATE
error CFA_FWD_INVALID_FLOW_RATE()
_cfa
contract IConstantFlowAgreementV1 _cfa
Fn constructor
function constructor(
contract ISuperfluid host
)
public
Parameters
Name | Type | Description |
---|---|---|
host | contract ISuperfluid |
Fn setFlowrate
Parameters
Name | Type | Description |
---|---|---|
token | contract ISuperToken | Super token address |
receiver | address | The receiver of the flow |
flowrate | int96 | The wanted flowrate in wad/second. Only positive values are valid here. |
Return Values
Name | Type | Description |
---|---|---|
[0] | bool | bool |
Sets the given flowrate between msg.sender 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.
Fn setFlowrateFrom
Parameters
Name | Type | Description |
---|---|---|
token | contract ISuperToken | Super token address |
sender | address | The sender of the flow |
receiver | address | The receiver of the flow |
flowrate | int96 | The wanted flowrate in wad/second. Only positive values are valid here. |
Return Values
Name | Type | Description |
---|---|---|
[0] | bool | bool |
Like setFlowrate
, but can be invoked by an account with flowOperator permissions
on behalf of the sender account.
Fn getFlowrate
Currently, only 0 or 1 flows can exist between 2 accounts. This may change in the future.
Parameters
Name | Type | Description |
---|---|---|
token | contract ISuperToken | Super token address |
sender | address | The sender of the flow |
receiver | address | The receiver of the flow |
Return Values
Name | Type | Description |
---|---|---|
flowrate | int96 | The flowrate from the sender to the receiver account. Returns 0 if no flow exists. |
Get the flowrate of the flow between 2 accounts if exists.
Fn getFlowInfo
Parameters
Name | Type | Description |
---|---|---|
token | contract ISuperToken | Super token address |
sender | address | The sender of the flow |
receiver | address | The receiver of the flow |
Return Values
Name | Type | Description |
---|---|---|
lastUpdated | uint256 | Timestamp of last update (flowrate change) or zero if no flow exists |
flowrate | int96 | Current flowrate of the flow or zero if no flow exists |
deposit | uint256 | Deposit amount locked as security buffer during the lifetime of the flow |
owedDeposit | uint256 | Extra deposit amount borrowed to a SuperApp receiver by the flow sender |
Get all available information about a flow (if exists).
If only the flowrate is needed, consider using getFlowrate
instead.
Fn getBufferAmountByFlowrate
function getBufferAmountByFlowrate(
contract ISuperToken token,
int96 flowrate
)
external
returns (uint256 bufferAmount)
Parameters
Name | Type | Description |
---|---|---|
token | contract ISuperToken | Super token address |
flowrate | int96 | The flowrate for which the buffer amount is calculated |
Return Values
Name | Type | Description |
---|---|---|
bufferAmount | uint256 | The buffer amount required for the given configuration. |
Get the buffer amount required for the given token and flowrate. This amount can vary based on the combination of token, flowrate and chain being queried. The result for a given set of parameters can change over time, because it depends on governance configurable protocol parameters. Changes of the required buffer amount affect only flows created or updated after the change.
Fn getAccountFlowrate
Parameters
Name | Type | Description |
---|---|---|
token | contract ISuperToken | Super token address |
account | address | Account to query |
Return Values
Name | Type | Description |
---|---|---|
flowrate | int96 | The net flowrate (aggregate incoming minus aggregate outgoing flowrate), can be negative. |
Get the net flowrate of an account.
Fn getAccountFlowInfo
Parameters
Name | Type | Description |
---|---|---|
token | contract ISuperToken | Super token address |
account | address | Account to query |
Return Values
Name | Type | Description |
---|---|---|
lastUpdated | uint256 | Timestamp of last update of a flow to or from the account (flowrate change) |
flowrate | int96 | Current net aggregate flowrate |
deposit | uint256 | Aggregate deposit amount currently locked as security buffer for outgoing flows |
owedDeposit | uint256 | Aggregate extra deposit amount currently borrowed to SuperApps receiving from this account |
Get aggregated flow information (if any exist) of an account.
If only the net flowrate is needed, consider using getAccountFlowrate
instead.
Fn createFlow
Parameters
Name | Type | Description |
---|---|---|
token | contract ISuperToken | Super token address |
sender | address | Sender address of the flow |
receiver | address | Receiver address of the flow |
flowrate | int96 | The flowrate in wad/second to be set initially |
userData | bytes | (optional) User data to be set. Should be set to zero if not needed. |
Return Values
Name | Type | Description |
---|---|---|
[0] | bool | bool |
Low-level wrapper of createFlow/createFlowByOperator.
If the address of msg.sender is not the same as the address of the sender
argument,
createFlowByOperator is used internally. In this case msg.sender needs to have permission to create flows
on behalf of the given sender account with sufficient flowRateAllowance.
Currently, only 1 flow can exist between 2 accounts, thus createFlow
will fail if one already exists.
Fn updateFlow
Parameters
Name | Type | Description |
---|---|---|
token | contract ISuperToken | Super token address |
sender | address | Sender address of the flow |
receiver | address | Receiver address of the flow |
flowrate | int96 | The flowrate in wad/second the flow should be updated to |
userData | bytes | (optional) User data to be set. Should be set to zero if not needed. |
Return Values
Name | Type | Description |
---|---|---|
[0] | bool | bool |
Low-level wrapper if updateFlow/updateFlowByOperator.
If the address of msg.sender doesn't match the address of the sender
argument,
updateFlowByOperator is invoked. In this case msg.sender needs to have permission to update flows
on behalf of the given sender account with sufficient flowRateAllowance.
Fn deleteFlow
Parameters
Name | Type | Description |
---|---|---|
token | contract ISuperToken | Super token address |
sender | address | Sender address of the flow |
receiver | address | Receiver address of the flow |
userData | bytes | (optional) User data to be set. Should be set to zero if not needed. |
Return Values
Name | Type | Description |
---|---|---|
[0] | bool | bool |
Low-level wrapper of deleteFlow/deleteFlowByOperator. If msg.sender isn't the same as sender address, msg.sender needs to have permission to delete flows on behalf of the given sender account.
Fn grantPermissions
Parameters
Name | Type | Description |
---|---|---|
token | contract ISuperToken | Super token address |
flowOperator | address | Account to which permissions are granted |
Return Values
Name | Type | Description |
---|---|---|
[0] | bool | bool |
Grants a flowOperator permission to create/update/delete flows on behalf of msg.sender. In order to restrict what a flowOperator can or can't do, the flowOperator account should be a contract implementing the desired restrictions.
Fn revokePermissions
Parameters
Name | Type | Description |
---|---|---|
token | contract ISuperToken | Super token address |
flowOperator | address | Account from which permissions are revoked |
Return Values
Name | Type | Description |
---|---|---|
[0] | bool | bool |
Revokes all permissions previously granted to a flowOperator by msg.sender. Revocation doesn't undo or reset flows previously created/updated by the flowOperator. In order to be sure about the state of flows at the time of revocation, you need to check that state either in the same transaction or after this transaction.
Fn updateFlowOperatorPermissions
Parameters
Name | Type | Description |
---|---|---|
token | contract ISuperToken | Super token address |
flowOperator | address | Account for which permissions are set on behalf of msg.sender |
permissions | uint8 | Bitmask for create/update/delete permission flags. See library FlowOperatorDefinitions |
flowrateAllowance | int96 | Max. flowrate in wad/second the operator can set for individual flows. |
Return Values
Name | Type | Description |
---|---|---|
[0] | bool | bool |
Low-level wrapper of IConstantFlowAgreementV1.updateFlowOperatorPermissions
flowrateAllowance does NOT restrict the net flowrate a flowOperator is able to set.
In order to restrict that, flowOperator needs to be a contract implementing the wanted limitations.
Fn getFlowOperatorPermissions
Parameters
Name | Type | Description |
---|---|---|
token | contract ISuperToken | Super token address |
sender | address | The account which (possiby) granted permissions |
flowOperator | address | Account to which (possibly) permissions were granted |
Return Values
Name | Type | Description |
---|---|---|
permissions | uint8 | A bitmask of the permissions currently granted (or not) by sender to flowOperator |
flowrateAllowance | int96 | Max. flowrate in wad/second the flowOperator can set for individual flows. |
Get the currently set permissions granted to the given flowOperator by the given sender account.
Fn _setFlowrateFrom
Parameters
Name | Type | Description |
---|---|---|
token | contract ISuperToken | |
sender | address | |
receiver | address | |
flowrate | int96 |
Fn _createFlow
Parameters
Name | Type | Description |
---|---|---|
token | contract ISuperToken | |
sender | address | |
receiver | address | |
flowrate | int96 | |
userData | bytes |
Fn _updateFlow
Parameters
Name | Type | Description |
---|---|---|
token | contract ISuperToken | |
sender | address | |
receiver | address | |
flowrate | int96 | |
userData | bytes |
Fn _deleteFlow
Parameters
Name | Type | Description |
---|---|---|
token | contract ISuperToken | |
sender | address | |
receiver | address | |
userData | bytes |
Fn _updateFlowOperatorPermissions
Parameters
Name | Type | Description |
---|---|---|
token | contract ISuperToken | |
flowOperator | address | |
permissions | uint8 | |
flowrateAllowance | int96 |