Skip to main content

ISablierV2Lockup

Git Source

Inherits: ISablierV2Base, IERC721Metadata

Common logic between all Sablier V2 lockup streaming contracts.

Functions

getAsset

Retrieves the address of the ERC-20 asset used for streaming.

Reverts if streamId references a null stream.

function getAsset(uint256 streamId) external view returns (IERC20 asset);

Parameters

NameTypeDescription
streamIduint256The stream id for the query.

getDepositedAmount

Retrieves the amount deposited in the stream, denoted in units of the asset's decimals.

Reverts if streamId references a null stream.

function getDepositedAmount(uint256 streamId) external view returns (uint128 depositedAmount);

Parameters

NameTypeDescription
streamIduint256The stream id for the query.

getEndTime

Retrieves the stream's end time, which is a Unix timestamp.

Reverts if streamId references a null stream.

function getEndTime(uint256 streamId) external view returns (uint40 endTime);

Parameters

NameTypeDescription
streamIduint256The stream id for the query.

getRecipient

Retrieves the stream's recipient.

Reverts if the NFT has been burned.

function getRecipient(uint256 streamId) external view returns (address recipient);

Parameters

NameTypeDescription
streamIduint256The stream id for the query.

getRefundedAmount

Retrieves the amount refunded to the sender after a cancellation, denoted in units of the asset's decimals. This amount is always zero unless the stream was canceled.

Reverts if streamId references a null stream.

function getRefundedAmount(uint256 streamId) external view returns (uint128 refundedAmount);

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.

getStartTime

Retrieves the stream's start time, which is a Unix timestamp.

Reverts if streamId references a null stream.

function getStartTime(uint256 streamId) external view returns (uint40 startTime);

Parameters

NameTypeDescription
streamIduint256The stream id for the query.

getWithdrawnAmount

Retrieves the amount withdrawn from the stream, denoted in units of the asset's decimals.

Reverts if streamId references a null stream.

function getWithdrawnAmount(uint256 streamId) external view returns (uint128 withdrawnAmount);

Parameters

NameTypeDescription
streamIduint256The stream id for the query.

isCancelable

Retrieves a flag indicating whether the stream can be canceled. When the stream is cold, this flag is always false.

Reverts if streamId references a null stream.

function isCancelable(uint256 streamId) external view returns (bool result);

Parameters

NameTypeDescription
streamIduint256The stream id for the query.

isCold

Retrieves a flag indicating whether the stream is cold, i.e. settled, canceled, or depleted.

Reverts if streamId references a null stream.

function isCold(uint256 streamId) external view returns (bool result);

Parameters

NameTypeDescription
streamIduint256The stream id for the query.

isDepleted

Retrieves a flag indicating whether the stream is depleted.

Reverts if streamId references a null stream.

function isDepleted(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.

isWarm

Retrieves a flag indicating whether the stream is warm, i.e. either pending or streaming.

Reverts if streamId references a null stream.

function isWarm(uint256 streamId) external view returns (bool result);

Parameters

NameTypeDescription
streamIduint256The stream id for the query.

nextStreamId

Counter for stream ids, used in the create functions.

function nextStreamId() external view returns (uint256);

refundableAmountOf

Calculates the amount that the sender would be refunded if the stream were canceled, denoted in units of the asset's decimals.

Reverts if streamId references a null stream.

function refundableAmountOf(uint256 streamId) external view returns (uint128 refundableAmount);

Parameters

NameTypeDescription
streamIduint256The stream id for the query.

statusOf

Retrieves the stream's status.

function statusOf(uint256 streamId) external view returns (Lockup.Status status);

Parameters

NameTypeDescription
streamIduint256The stream id for the query.

streamedAmountOf

Calculates the amount streamed to the recipient, denoted in units of the asset's decimals.

Reverts if streamId references a null stream.

function streamedAmountOf(uint256 streamId) external view returns (uint128 streamedAmount);

Parameters

NameTypeDescription
streamIduint256The stream id for the query.

wasCanceled

Retrieves a flag indicating whether the stream was canceled.

Reverts if streamId references a null stream.

function wasCanceled(uint256 streamId) external view returns (bool result);

Parameters

NameTypeDescription
streamIduint256The stream id for the query.

withdrawableAmountOf

Calculates the amount that the recipient can withdraw from the stream, denoted in units of the asset's decimals.

Reverts if streamId references a null stream.

function withdrawableAmountOf(uint256 streamId) external view returns (uint128 withdrawableAmount);

Parameters

NameTypeDescription
streamIduint256The stream id for the query.

burn

Burns the NFT associated with the stream.

Emits a {Transfer} event. Requirements:

  • Must not be delegate called.
  • streamId must reference a depleted stream.
  • The NFT must exist.
  • msg.sender must be either the NFT owner or an approved third party.
function burn(uint256 streamId) external;

Parameters

NameTypeDescription
streamIduint256The id of the stream NFT to burn.

cancel

Cancels the stream and refunds any remaining assets to the sender.

Emits a {CancelLockupStream} event and a {Transfer} event. Notes:

  • If there any assets left for the recipient to withdraw, the stream is marked as canceled. Otherwise, the stream is marked as depleted.
  • This function attempts to invoke a hook on either the sender or the recipient, depending on who msg.sender is, and if the resolved address is a contract. Requirements:
  • Must not be delegate called.
  • The stream must be warm and cancelable.
  • msg.sender must be either the stream's sender or the stream's recipient (i.e. the NFT owner).
function cancel(uint256 streamId) external;

Parameters

NameTypeDescription
streamIduint256The id of the stream to cancel.

cancelMultiple

Cancels multiple streams and refunds any remaining assets to the sender.

Emits multiple {CancelLockupStream} and {Transfer} events. Notes:

  • Refer to the notes in {cancel}. Requirements:
  • All requirements from {cancel} must be met for each stream.
function cancelMultiple(uint256[] calldata streamIds) external;

Parameters

NameTypeDescription
streamIdsuint256[]The ids of the streams to cancel.

renounce

Removes the right of the stream's sender to cancel the stream.

Emits a {RenounceLockupStream} event. Notes:

  • This is an irreversible operation.
  • This function attempts to invoke a hook on the stream's recipient, provided that the recipient is a contract. Requirements:
  • Must not be delegate called.
  • streamId must reference a warm stream.
  • msg.sender must be the stream's sender.
  • The stream must be cancelable.
function renounce(uint256 streamId) external;

Parameters

NameTypeDescription
streamIduint256The id of the stream to renounce.

setNFTDescriptor

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

Emits a {SetNFTDescriptor} event. Notes:

  • Does not revert if the NFT descriptor is the same. Requirements:
  • msg.sender must be the contract admin.
function setNFTDescriptor(ISablierV2NFTDescriptor newNFTDescriptor) external;

Parameters

NameTypeDescription
newNFTDescriptorISablierV2NFTDescriptorThe address of the new NFT descriptor contract.

withdraw

Withdraws the provided amount of assets from the stream to the to address.

Emits a {WithdrawFromLockupStream} and a {Transfer} event. Notes:

  • This function attempts to invoke a hook on the stream's recipient, provided that the recipient is a contract and msg.sender is either the sender or an approved operator. Requirements:
  • Must not be delegate called.
  • streamId must not reference a null, pending, or depleted stream.
  • msg.sender must be the stream's sender, the stream's recipient or an approved third party.
  • to must be the recipient if msg.sender is the stream's sender.
  • to must not be the zero address.
  • amount must be greater than zero and must not exceed the withdrawable amount.
function withdraw(uint256 streamId, address to, uint128 amount) external;

Parameters

NameTypeDescription
streamIduint256The id of the stream to withdraw from.
toaddressThe address that receives the withdrawn assets.
amountuint128The amount to withdraw, denoted in units of the asset's decimals.

withdrawMax

Withdraws the maximum withdrawable amount from the stream to the to address.

Emits a {WithdrawFromLockupStream} and a {Transfer} event. Notes:

  • Refer to the notes in {withdraw}. Requirements:
  • Refer to the requirements in {withdraw}.
function withdrawMax(uint256 streamId, address to) external;

Parameters

NameTypeDescription
streamIduint256The id of the stream to withdraw from.
toaddressThe address that receives the withdrawn assets.

withdrawMultiple

Withdraws assets from streams to the provided address to.

Emits multiple {WithdrawFromLockupStream} and {Transfer} events. Notes:

  • This function attempts to call a hook on the recipient of each stream, unless msg.sender is the recipient. Requirements:
  • All requirements from {withdraw} must be met for each stream.
  • There must be an equal number of streamIds and amounts.
function withdrawMultiple(uint256[] calldata streamIds, address to, uint128[] calldata amounts) external;

Parameters

NameTypeDescription
streamIdsuint256[]The ids of the streams to withdraw from.
toaddressThe address that receives the withdrawn assets.
amountsuint128[]The amounts to withdraw, denoted in units of the asset's decimals.

Events

CancelLockupStream

Emitted when a stream is canceled.

event CancelLockupStream(
uint256 indexed streamId,
address indexed sender,
address indexed recipient,
uint128 senderAmount,
uint128 recipientAmount
);

RenounceLockupStream

Emitted when a sender gives up the right to cancel a stream.

event RenounceLockupStream(uint256 indexed streamId);

SetNFTDescriptor

Emitted when the admin sets a new NFT descriptor contract.

event SetNFTDescriptor(
address indexed admin, ISablierV2NFTDescriptor oldNFTDescriptor, ISablierV2NFTDescriptor newNFTDescriptor
);

WithdrawFromLockupStream

Emitted when assets are withdrawn from a stream.

event WithdrawFromLockupStream(uint256 indexed streamId, address indexed to, uint128 amount);