SablierFlowBase
Inherits: Adminable, ISablierFlowBase, ERC721
See the documentation in ISablierFlowBase.
State Variables
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.
UD60x18 public constant override MAX_FEE = UD60x18.wrap(0.1e18);
aggregateBalance
Retrieves the sum of balances of all streams.
mapping(IERC20 token => uint256 amount) public override aggregateBalance;
nextStreamId
Counter for stream ids.
uint256 public override nextStreamId;
nftDescriptor
Contract that generates the non-fungible token URI.
IFlowNFTDescriptor public override nftDescriptor;
protocolFee
Protocol fee for the provided ERC-20 token, denoted as a fixed-point percentage where 1e18 is 100%.
mapping(IERC20 token => UD60x18 fee) public override protocolFee;
protocolRevenue
Protocol revenue accrued for the provided ERC-20 token, denoted in token's decimals.
mapping(IERC20 token => uint128 revenue) public override protocolRevenue;
_streams
Sablier Flow streams mapped by unsigned integers.
mapping(uint256 id => Flow.Stream stream) internal _streams;
Functions
constructor
Emits a {TransferAdmin} event.
constructor(address initialAdmin, IFlowNFTDescriptor initialNFTDescriptor);
Parameters
Name | Type | Description |
---|---|---|
initialAdmin | address | The address of the initial contract admin. |
initialNFTDescriptor | IFlowNFTDescriptor | The address of the initial NFT descriptor. |
notNull
Checks that streamId
does not reference a null stream.
modifier notNull(uint256 streamId);
notPaused
Checks that streamId
does not reference a paused stream.
modifier notPaused(uint256 streamId);
notVoided
modifier notVoided(uint256 streamId);
onlySender
Checks the msg.sender
is the stream's sender.
modifier onlySender(uint256 streamId);
updateMetadata
Emits an ERC-4906 event to trigger an update of the NFT metadata.
modifier updateMetadata(uint256 streamId);
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 override notNull(streamId) 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 override notNull(streamId) 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 override notNull(streamId) 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 override notNull(streamId) 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 override notNull(streamId) 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 override notNull(streamId) 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 override notNull(streamId) 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 override notNull(streamId) 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 override notNull(streamId) 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 override notNull(streamId) 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 override 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 override notNull(streamId) 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 override notNull(streamId) returns (bool result);
Parameters
Name | Type | Description |
---|---|---|
streamId | uint256 | The stream ID for the query. |
tokenURI
See {IERC721Metadata-tokenURI}.
function tokenURI(uint256 streamId) public view override(IERC721Metadata, ERC721) returns (string memory uri);
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 override onlyAdmin;
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. |