Skip to main content

ISablierFlowBase

Git Source

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

NameTypeDescription
tokenIERC20The 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

NameTypeDescription
streamIduint256The 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

NameTypeDescription
streamIduint256The 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

NameTypeDescription
streamIduint256The 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

NameTypeDescription
streamIduint256The stream ID for the query.

getSnapshotDebtScaled

Retrieves the snapshot debt of the stream, denoted as a fixed-point number where 1e18 is 1 token.

Reverts if streamId references a null stream.

function getSnapshotDebtScaled(uint256 streamId) external view returns (uint256 snapshotDebtScaled);

Parameters

NameTypeDescription
streamIduint256The 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

NameTypeDescription
streamIduint256The 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

NameTypeDescription
streamIduint256The 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

NameTypeDescription
streamIduint256The 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

NameTypeDescription
streamIduint256The 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

NameTypeDescription
streamIduint256The 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

NameTypeDescription
streamIduint256The 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

NameTypeDescription
streamIduint256The 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

NameTypeDescription
streamIduint256The stream ID for the query.

nextStreamId

Counter for stream ids.

function nextStreamId() external view returns (uint256);

Returns

NameTypeDescription
<none>uint256The 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 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

NameTypeDescription
tokenIERC20The contract address of the ERC-20 token for which to claim protocol revenue.
toaddressThe address to send the protocol revenue.

recover

Recover the surplus amount of tokens.

Emits 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

NameTypeDescription
tokenIERC20The contract address of the ERC-20 token to recover for.
toaddressThe address to send the surplus amount.

setNFTDescriptor

Sets a new NFT descriptor contract, which produces the URI describing the Sablier stream NFTs.

Emits SetNFTDescriptor and {BatchMetadataUpdate} events. 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

NameTypeDescription
newNFTDescriptorIFlowNFTDescriptorThe 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 SetProtocolFee and {BatchMetadataUpdate} events. 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 than MAX_FEE.
function setProtocolFee(IERC20 token, UD60x18 newProtocolFee) external;

Parameters

NameTypeDescription
tokenIERC20The contract address of the ERC-20 token to update the fee for.
newProtocolFeeUD60x18The 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

NameTypeDescription
adminaddressThe address of the contract admin.
tokenIERC20The address of the ERC-20 token the protocol revenue has been collected for.
toaddressThe address the protocol revenue has been sent to.
revenueuint128The 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

NameTypeDescription
adminaddressThe address of the contract admin.
tokenIERC20The address of the ERC-20 token the surplus amount has been recovered for.
toaddressThe address the surplus amount has been sent to.
surplusuint256The 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

NameTypeDescription
adminaddressThe address of the contract admin.
oldNFTDescriptorIFlowNFTDescriptorThe address of the old NFT descriptor contract.
newNFTDescriptorIFlowNFTDescriptorThe 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

NameTypeDescription
adminaddressThe address of the contract admin.
tokenIERC20The address of the ERC-20 token the new protocol fee has been set for.
oldProtocolFeeUD60x18The old protocol fee, denoted as a fixed-point percentage.
newProtocolFeeUD60x18The new protocol fee, denoted as a fixed-point percentage.