ISablierFlowBase
Inherits: IERC4906, IERC721Metadata, IAdminable
Base contract that includes state variables (storage and constants) for the SablierFlow contract, their respective getters, helpful modifiers, and helper functions.
This contract also includes admin control functions.
Functions
MAX_FEE
Retrieves the maximum fee that can be charged by the broker and the protocol, denoted as a fixed-point percentage where 1e18 is 100%.
This value is hard coded as a constant.
function MAX_FEE() external view returns (UD60x18 fee);
aggregateBalance
Retrieves the sum of balances of all streams.
function aggregateBalance(IERC20 token) external view returns (uint256);
Parameters
Name | Type | Description |
---|---|---|
token | IERC20 | The ERC-20 token for the query. |
getBalance
Retrieves the balance of the stream, i.e. the total deposited amounts subtracted by the total withdrawn amounts, denoted in token's decimals.
Reverts if streamId
references a null stream.
function getBalance(uint256 streamId) external view returns (uint128 balance);
Parameters
Name | Type | Description |
---|---|---|
streamId | uint256 | The stream ID for the query. |
getRatePerSecond
Retrieves the rate per second of the stream, denoted as a fixed-point number where 1e18 is 1 token per second.
Reverts if streamId
references a null stream.
function getRatePerSecond(uint256 streamId) external view returns (UD21x18 ratePerSecond);
Parameters
Name | Type | Description |
---|---|---|
streamId | uint256 | The ID of the stream to make the query for. |
getRecipient
Retrieves the stream's recipient.
Reverts if streamId
references a null stream.
function getRecipient(uint256 streamId) external view returns (address recipient);
Parameters
Name | Type | Description |
---|---|---|
streamId | uint256 | The stream ID for the query. |
getSender
Retrieves the stream's sender.
Reverts if streamId
references a null stream.
function getSender(uint256 streamId) external view returns (address sender);
Parameters
Name | Type | Description |
---|---|---|
streamId | uint256 | The stream ID for the query. |
getSnapshotDebt
Retrieves the snapshot debt of the stream, denoted in token's decimals.
Reverts if streamId
references a null stream.
function getSnapshotDebt(uint256 streamId) external view returns (uint256 snapshotDebt);
Parameters
Name | Type | Description |
---|---|---|
streamId | uint256 | The stream ID for the query. |
getSnapshotTime
Retrieves the snapshot time of the stream, which is a Unix timestamp.
Reverts if streamId
references a null stream.
function getSnapshotTime(uint256 streamId) external view returns (uint40 snapshotTime);
Parameters
Name | Type | Description |
---|---|---|
streamId | uint256 | The ID of the stream to make the query for. |
getStream
Retrieves the stream entity.
Reverts if streamId
references a null stream.
function getStream(uint256 streamId) external view returns (Flow.Stream memory stream);
Parameters
Name | Type | Description |
---|---|---|
streamId | uint256 | The stream ID for the query. |
getToken
Retrieves the token of the stream.
Reverts if streamId
references a null stream.
function getToken(uint256 streamId) external view returns (IERC20 token);
Parameters
Name | Type | Description |
---|---|---|
streamId | uint256 | The ID of the stream to make the query for. |
getTokenDecimals
Retrieves the token decimals of the stream.
Reverts if streamId
references a null stream.
function getTokenDecimals(uint256 streamId) external view returns (uint8 tokenDecimals);
Parameters
Name | Type | Description |
---|---|---|
streamId | uint256 | The ID of the stream to make the query for. |
isPaused
Returns whether a stream is paused.
Reverts if streamId
references a null stream.
function isPaused(uint256 streamId) external view returns (bool result);
Parameters
Name | Type | Description |
---|---|---|
streamId | uint256 | The stream ID for the query. |
isStream
Retrieves a flag indicating whether the stream exists.
Does not revert if streamId
references a null stream.
function isStream(uint256 streamId) external view returns (bool result);
Parameters
Name | Type | Description |
---|---|---|
streamId | uint256 | The stream ID for the query. |
isTransferable
Retrieves a flag indicating whether the stream NFT is transferable.
Reverts if streamId
references a null stream.
function isTransferable(uint256 streamId) external view returns (bool result);
Parameters
Name | Type | Description |
---|---|---|
streamId | uint256 | The stream ID for the query. |
isVoided
Retrieves a flag indicating whether the stream is voided.
Reverts if streamId
references a null stream.
function isVoided(uint256 streamId) external view returns (bool result);
Parameters
Name | Type | Description |
---|---|---|
streamId | uint256 | The stream ID for the query. |
nextStreamId
Counter for stream ids.
function nextStreamId() external view returns (uint256);
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | The next stream ID. |
nftDescriptor
Contract that generates the non-fungible token URI.
function nftDescriptor() external view returns (IFlowNFTDescriptor);
protocolFee
Protocol fee for the provided ERC-20 token, denoted as a fixed-point percentage where 1e18 is 100%.
function protocolFee(IERC20 token) external view returns (UD60x18);
protocolRevenue
Protocol revenue accrued for the provided ERC-20 token, denoted in token's decimals.
function protocolRevenue(IERC20 token) external view returns (uint128);
collectProtocolRevenue
Collect the protocol revenue accrued for the provided ERC-20 token.
Emits a CollectProtocolRevenue event. Requirements:
msg.sender
must be the contract admin.- The accrued protocol revenue must be greater than zero.
function collectProtocolRevenue(IERC20 token, address to) external;
Parameters
Name | Type | Description |
---|---|---|
token | IERC20 | The contract address of the ERC-20 token for which to claim protocol revenue. |
to | address | The address to send the protocol revenue. |
recover
Recover the surplus amount of tokens.
Emits a Recover event. Notes:
- The surplus amount is defined as the difference between the total balance of the contract for the provided ERC-20 token and the sum of balances of all streams created using the same ERC-20 token. Requirements:
msg.sender
must be the contract admin.- The surplus amount must be greater than zero.
function recover(IERC20 token, address to) external;
Parameters
Name | Type | Description |
---|---|---|
token | IERC20 | The contract address of the ERC-20 token to recover for. |
to | address | The address to send the surplus amount. |
setNFTDescriptor
Sets a new NFT descriptor contract, which produces the URI describing the Sablier stream NFTs.
Emits a SetNFTDescriptor and {BatchMetadataUpdate} event. Notes:
- Does not revert if the NFT descriptor is the same. Requirements:
msg.sender
must be the contract admin.
function setNFTDescriptor(IFlowNFTDescriptor newNFTDescriptor) external;
Parameters
Name | Type | Description |
---|---|---|
newNFTDescriptor | IFlowNFTDescriptor | The address of the new NFT descriptor contract. |
setProtocolFee
Sets a new protocol fee that will be charged on all the withdrawals from streams created with the provided ERC-20 token.
Emits a SetProtocolFee event. Notes:
- Does not revert if the fee is the same.
- It can be zero. Requirements:
msg.sender
must be the contract admin.newProtocolFee
must not be greater thanMAX_FEE
.
function setProtocolFee(IERC20 token, UD60x18 newProtocolFee) external;
Parameters
Name | Type | Description |
---|---|---|
token | IERC20 | The contract address of the ERC-20 token to update the fee for. |
newProtocolFee | UD60x18 | The new protocol fee, denoted as a fixed-point percentage where 1e18 is 100%. |
Events
CollectProtocolRevenue
Emitted when the contract admin collects protocol revenue accrued.
event CollectProtocolRevenue(address indexed admin, IERC20 indexed token, address to, uint128 revenue);
Parameters
Name | Type | Description |
---|---|---|
admin | address | The address of the contract admin. |
token | IERC20 | The address of the ERC-20 token the protocol revenue has been collected for. |
to | address | The address the protocol revenue has been sent to. |
revenue | uint128 | The amount of protocol revenue collected. |
Recover
Emitted when the contract admin recovers the surplus amount of token.
event Recover(address indexed admin, IERC20 indexed token, address to, uint256 surplus);
Parameters
Name | Type | Description |
---|---|---|
admin | address | The address of the contract admin. |
token | IERC20 | The address of the ERC-20 token the surplus amount has been recovered for. |
to | address | The address the surplus amount has been sent to. |
surplus | uint256 | The amount of surplus tokens recovered. |
SetNFTDescriptor
Emitted when the contract admin sets a new NFT descriptor contract.
event SetNFTDescriptor(address indexed admin, IFlowNFTDescriptor oldNFTDescriptor, IFlowNFTDescriptor newNFTDescriptor);
Parameters
Name | Type | Description |
---|---|---|
admin | address | The address of the contract admin. |
oldNFTDescriptor | IFlowNFTDescriptor | The address of the old NFT descriptor contract. |
newNFTDescriptor | IFlowNFTDescriptor | The address of the new NFT descriptor contract. |
SetProtocolFee
Emitted when the contract admin sets a new protocol fee for the provided ERC-20 token.
event SetProtocolFee(address indexed admin, IERC20 indexed token, UD60x18 oldProtocolFee, UD60x18 newProtocolFee);
Parameters
Name | Type | Description |
---|---|---|
admin | address | The address of the contract admin. |
token | IERC20 | The address of the ERC-20 token the new protocol fee has been set for. |
oldProtocolFee | UD60x18 | The old protocol fee, denoted as a fixed-point percentage. |
newProtocolFee | UD60x18 | The new protocol fee, denoted as a fixed-point percentage. |