Skip to main content

ISablierV2LockupLinear

Git Source

Inherits: ISablierV2Lockup

Creates and manages lockup streams with a linear streaming function.

Functions

getCliffTime

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

Reverts if streamId references a null stream.

function getCliffTime(uint256 streamId) external view returns (uint40 cliffTime);

Parameters

NameTypeDescription
streamIduint256The stream id for the query.

getRange

Retrieves the range of the stream, a struct containing (i) the stream's start time, (ii) cliff time, and (iii) end time, all as Unix timestamps.

Reverts if streamId references a null stream.

function getRange(uint256 streamId) external view returns (LockupLinear.Range memory range);

Parameters

NameTypeDescription
streamIduint256The stream id for the query.

getStream

Retrieves the stream entity.

Reverts if streamId references a null stream.

function getStream(uint256 streamId) external view returns (LockupLinear.Stream memory stream);

Parameters

NameTypeDescription
streamIduint256The stream id for the query.

streamedAmountOf

Calculates the amount streamed to the recipient, denoted in units of the asset's decimals. When the stream is warm, the streaming function is:

f(x)=xd+cf(x) = x * d + c

Where:

  • xx is the elapsed time divided by the stream's total duration.
  • dd is the deposited amount.
  • cc is the cliff amount. Upon cancellation of the stream, the amount streamed is calculated as the difference between the deposited amount and the refunded amount. Ultimately, when the stream becomes depleted, the streamed amount is equivalent to the total amount withdrawn.

Reverts if streamId references a null stream.

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

Parameters

NameTypeDescription
streamIduint256The stream id for the query.

createWithDurations

Creates a stream by setting the start time to block.timestamp, and the end time to the sum of block.timestamp and params.durations.total. The stream is funded by msg.sender` and is wrapped in an ERC-721 NFT.

Emits a {CreateLockupLinearStream} and a {Transfer} event. Requirements:

  • All requirements in {createWithRange} must be met for the calculated parameters.
function createWithDurations(LockupLinear.CreateWithDurations calldata params) external returns (uint256 streamId);

Parameters

NameTypeDescription
paramsLockupLinear.CreateWithDurationsStruct encapsulating the function parameters, which are documented in {DataTypes}.

Returns

NameTypeDescription
streamIduint256The id of the newly created stream.

createWithRange

Creates a stream with the provided start time and end time as the range. The stream is funded by msg.sender and is wrapped in an ERC-721 NFT.

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

  • As long as the times are ordered, it is not an error for the start or the cliff time to be in the past. Requirements:
  • Must not be delegate called.
  • params.totalAmount must be greater than zero.
  • If set, params.broker.fee must not be greater than MAX_FEE.
  • params.range.start must be less than or equal to params.range.cliff.
  • params.range.cliff must be less than params.range.end.
  • params.range.end must be in the future.
  • params.recipient must not be the zero address.
  • msg.sender must have allowed this contract to spend at least params.totalAmount assets.
function createWithRange(LockupLinear.CreateWithRange calldata params) external returns (uint256 streamId);

Parameters

NameTypeDescription
paramsLockupLinear.CreateWithRangeStruct encapsulating the function parameters, which are documented in {DataTypes}.

Returns

NameTypeDescription
streamIduint256The id of the newly created stream.

Events

CreateLockupLinearStream

Emitted when a stream is created.

event CreateLockupLinearStream(
uint256 streamId,
address indexed funder,
address indexed sender,
address indexed recipient,
Lockup.CreateAmounts amounts,
IERC20 asset,
bool cancelable,
LockupLinear.Range range,
address broker
);