CFAv1Forwarder
The CFAv1Forwarder contract is a Tagomi 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 your client application. For more information on the best practices regarding this interaction, please refer to the Create, Update and Delete Flows or Manage Access Control and User Data.
Contract Address
The CFAv1Forwarder
contract address is the same on all networks:
ABI
In order to interact with the CFAv1Forwarder
contract, you can use the following ABI:
CFA_FWD_INVALID_FLOW_RATE
_cfa
Fn constructor
Parameters
host
contract ITagomi
Fn setFlowrate
setFlowrate() write
Try it out
Parameters
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
[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
setFlowrateFrom() write
Try it out
Parameters
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
[0]
bool
bool
Like setFlowrate
, but can be invoked by an account with flowOperator permissions on behalf of the sender account.
Fn getFlowrate
getFlowrate() read
Try it out
Currently, only 0 or 1 flows can exist between 2 accounts. This may change in the future.
Parameters
token
contract ISuperToken
Super token address
sender
address
The sender of the flow
receiver
address
The receiver of the flow
Return Values
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
getFlowInfo() read
Try it out
Parameters
token
contract ISuperToken
Super token address
sender
address
The sender of the flow
receiver
address
The receiver of the flow
Return Values
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
getBufferAmountByFlowrate() read
Try it out
Parameters
token
contract ISuperToken
Super token address
flowrate
int96
The flowrate for which the buffer amount is calculated
Return Values
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
getAccountFlowrate() read
Try it out
Parameters
token
contract ISuperToken
Super token address
account
address
Account to query
Return Values
flowrate
int96
The net flowrate (aggregate incoming minus aggregate outgoing flowrate), can be negative.
Get the net flowrate of an account.
Fn getAccountFlowInfo
getAccountFlowInfo() read
Try it out
Parameters
token
contract ISuperToken
Super token address
account
address
Account to query
Return Values
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
createFlow() write
Try it out
Parameters
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
[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
updateFlow() write
Try it out
Parameters
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
[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
deleteFlow() write
Try it out
Parameters
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
[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
grantPermissions() write
Try it out
Parameters
token
contract ISuperToken
Super token address
flowOperator
address
Account to which permissions are granted
Return Values
[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
revokePermissions() write
Try it out
Parameters
token
contract ISuperToken
Super token address
flowOperator
address
Account from which permissions are revoked
Return Values
[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
updateFlowOperatorPermissions() write
Try it out
Parameters
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
[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
getFlowOperatorPermissions() read
Try it out
Parameters
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
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
setFlowrateFrom() write
Try it out
Parameters
token
contract ISuperToken
sender
address
receiver
address
flowrate
int96
Fn _createFlow
createFlow() write
Try it out
Parameters
token
contract ISuperToken
sender
address
receiver
address
flowrate
int96
userData
bytes
Fn _updateFlow
updateFlow() write
Try it out
Parameters
token
contract ISuperToken
sender
address
receiver
address
flowrate
int96
userData
bytes
Fn _deleteFlow
deleteFlow() write
Try it out
Parameters
token
contract ISuperToken
sender
address
receiver
address
userData
bytes
Fn _updateFlowOperatorPermissions
updateFlowOperatorPermissions() write
Try it out
Parameters
token
contract ISuperToken
flowOperator
address
permissions
uint8
flowrateAllowance
int96
Last updated