Skip to main content

ISablierLockup

Git Source

Inherits: ISablierLockupBase

Creates and manages Lockup streams with various distribution models.

Functions

MAX_COUNT

The maximum number of segments and tranches allowed in Dynamic and Tranched streams respectively.

This is initialized at construction time and cannot be changed later.

function MAX_COUNT() external view returns (uint256);

getCliffTime

Retrieves the stream's cliff time, which is a Unix timestamp. A value of zero means there is no cliff.

Reverts if streamId references a null stream or a non Lockup Linear stream.

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

Parameters

NameTypeDescription
streamIduint256The stream ID for the query.

getSegments

Retrieves the segments used to compose the dynamic distribution function.

Reverts if streamId references a null stream or a non Lockup Dynamic stream.

function getSegments(uint256 streamId) external view returns (LockupDynamic.Segment[] memory segments);

Parameters

NameTypeDescription
streamIduint256The stream ID for the query.

Returns

NameTypeDescription
segmentsLockupDynamic.Segment[]See the documentation in {DataTypes}.

getTranches

Retrieves the tranches used to compose the tranched distribution function.

Reverts if streamId references a null stream or a non Lockup Tranched stream.

function getTranches(uint256 streamId) external view returns (LockupTranched.Tranche[] memory tranches);

Parameters

NameTypeDescription
streamIduint256The stream ID for the query.

Returns

NameTypeDescription
tranchesLockupTranched.Tranche[]See the documentation in {DataTypes}.

getUnlockAmounts

Retrieves the unlock amounts used to compose the linear distribution function.

Reverts if streamId references a null stream or a non Lockup Linear stream.

function getUnlockAmounts(uint256 streamId) external view returns (LockupLinear.UnlockAmounts memory unlockAmounts);

Parameters

NameTypeDescription
streamIduint256The stream ID for the query.

Returns

NameTypeDescription
unlockAmountsLockupLinear.UnlockAmountsSee the documentation in {DataTypes}.

createWithDurationsLD

Creates a stream by setting the start time to block.timestamp, and the end time to the sum of block.timestamp and all specified time durations. The segment timestamps are derived from these durations. The stream is funded by msg.sender and is wrapped in an ERC-721 NFT.

Emits a {Transfer}, {CreateLockupDynamicStream} and {MetadataUpdate} event. Requirements:

  • All requirements in {createWithTimestampsLD} must be met for the calculated parameters.
function createWithDurationsLD(
Lockup.CreateWithDurations calldata params,
LockupDynamic.SegmentWithDuration[] calldata segmentsWithDuration
)
external
payable
returns (uint256 streamId);

Parameters

NameTypeDescription
paramsLockup.CreateWithDurationsStruct encapsulating the function parameters, which are documented in {DataTypes}.
segmentsWithDurationLockupDynamic.SegmentWithDuration[]Segments with durations used to compose the dynamic distribution function. Timestamps are calculated by starting from block.timestamp and adding each duration to the previous timestamp.

Returns

NameTypeDescription
streamIduint256The ID of the newly created stream.

createWithDurationsLL

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

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

  • All requirements in {createWithTimestampsLL} must be met for the calculated parameters.
function createWithDurationsLL(
Lockup.CreateWithDurations calldata params,
LockupLinear.UnlockAmounts calldata unlockAmounts,
LockupLinear.Durations calldata durations
)
external
payable
returns (uint256 streamId);

Parameters

NameTypeDescription
paramsLockup.CreateWithDurationsStruct encapsulating the function parameters, which are documented in {DataTypes}.
unlockAmountsLockupLinear.UnlockAmountsStruct encapsulating (i) the amount to unlock at the start time and (ii) the amount to unlock at the cliff time.
durationsLockupLinear.DurationsStruct encapsulating (i) cliff period duration and (ii) total stream duration, both in seconds.

Returns

NameTypeDescription
streamIduint256The ID of the newly created stream.

createWithDurationsLT

Creates a stream by setting the start time to block.timestamp, and the end time to the sum of block.timestamp and all specified time durations. The tranche timestamps are derived from these durations. The stream is funded by msg.sender and is wrapped in an ERC-721 NFT.

Emits a {Transfer}, {CreateLockupTrancheStream} and {MetadataUpdate} event. Requirements:

  • All requirements in {createWithTimestampsLT} must be met for the calculated parameters.
function createWithDurationsLT(
Lockup.CreateWithDurations calldata params,
LockupTranched.TrancheWithDuration[] calldata tranchesWithDuration
)
external
payable
returns (uint256 streamId);

Parameters

NameTypeDescription
paramsLockup.CreateWithDurationsStruct encapsulating the function parameters, which are documented in {DataTypes}.
tranchesWithDurationLockupTranched.TrancheWithDuration[]Tranches with durations used to compose the tranched distribution function. Timestamps are calculated by starting from block.timestamp and adding each duration to the previous timestamp.

Returns

NameTypeDescription
streamIduint256The ID of the newly created stream.

createWithTimestampsLD

Creates a stream with the provided segment timestamps, implying the end time from the last timestamp. The stream is funded by msg.sender and is wrapped in an ERC-721 NFT.

Emits a {Transfer}, {CreateLockupDynamicStream} and {MetadataUpdate} event. Notes:

  • As long as the segment timestamps are arranged in ascending order, it is not an error for some of them 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_BROKER_FEE.
  • params.timestamps.start must be greater than zero and less than the first segment's timestamp.
  • segments must have at least one segment, but not more than MAX_COUNT.
  • The segment timestamps must be arranged in ascending order.
  • params.timestamps.end must be equal to the last segment's timestamp.
  • The sum of the segment amounts must equal the deposit amount.
  • params.recipient must not be the zero address.
  • params.sender must not be the zero address.
  • msg.sender must have allowed this contract to spend at least params.totalAmount tokens.
  • params.shape.length must not be greater than 32 characters.
function createWithTimestampsLD(
Lockup.CreateWithTimestamps calldata params,
LockupDynamic.Segment[] calldata segments
)
external
payable
returns (uint256 streamId);

Parameters

NameTypeDescription
paramsLockup.CreateWithTimestampsStruct encapsulating the function parameters, which are documented in {DataTypes}.
segmentsLockupDynamic.Segment[]Segments used to compose the dynamic distribution function.

Returns

NameTypeDescription
streamIduint256The ID of the newly created stream.

createWithTimestampsLL

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

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

  • A cliff time of zero means there is no cliff.
  • 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_BROKER_FEE.
  • params.timestamps.start must be greater than zero and less than params.timestamps.end.
  • If set, cliffTime must be greater than params.timestamps.start and less than params.timestamps.end.
  • params.recipient must not be the zero address.
  • params.sender must not be the zero address.
  • The sum of params.unlockAmounts.start and params.unlockAmounts.cliff must be less than or equal to deposit amount.
  • If params.timestamps.cliff not set, the params.unlockAmounts.cliff must be zero.
  • msg.sender must have allowed this contract to spend at least params.totalAmount tokens.
  • params.shape.length must not be greater than 32 characters.
function createWithTimestampsLL(
Lockup.CreateWithTimestamps calldata params,
LockupLinear.UnlockAmounts calldata unlockAmounts,
uint40 cliffTime
)
external
payable
returns (uint256 streamId);

Parameters

NameTypeDescription
paramsLockup.CreateWithTimestampsStruct encapsulating the function parameters, which are documented in {DataTypes}.
unlockAmountsLockupLinear.UnlockAmountsStruct encapsulating (i) the amount to unlock at the start time and (ii) the amount to unlock at the cliff time.
cliffTimeuint40The Unix timestamp for the cliff period's end. A value of zero means there is no cliff.

Returns

NameTypeDescription
streamIduint256The ID of the newly created stream.

createWithTimestampsLT

Creates a stream with the provided tranche timestamps, implying the end time from the last timestamp. The stream is funded by msg.sender and is wrapped in an ERC-721 NFT.

Emits a {Transfer}, {CreateLockupTrancheStream} and {MetadataUpdate} event. Notes:

  • As long as the tranche timestamps are arranged in ascending order, it is not an error for some of them 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_BROKER_FEE.
  • params.timestamps.start must be greater than zero and less than the first tranche's timestamp.
  • tranches must have at least one tranche, but not more than MAX_COUNT.
  • The tranche timestamps must be arranged in ascending order.
  • params.timestamps.end must be equal to the last tranche's timestamp.
  • The sum of the tranche amounts must equal the deposit amount.
  • params.recipient must not be the zero address.
  • params.sender must not be the zero address.
  • msg.sender must have allowed this contract to spend at least params.totalAmount tokens.
  • params.shape.length must not be greater than 32 characters.
function createWithTimestampsLT(
Lockup.CreateWithTimestamps calldata params,
LockupTranched.Tranche[] calldata tranches
)
external
payable
returns (uint256 streamId);

Parameters

NameTypeDescription
paramsLockup.CreateWithTimestampsStruct encapsulating the function parameters, which are documented in {DataTypes}.
tranchesLockupTranched.Tranche[]Tranches used to compose the tranched distribution function.

Returns

NameTypeDescription
streamIduint256The ID of the newly created stream.

Events

CreateLockupDynamicStream

Emitted when a stream is created using Lockup dynamic model.

event CreateLockupDynamicStream(
uint256 indexed streamId, Lockup.CreateEventCommon commonParams, LockupDynamic.Segment[] segments
);

Parameters

NameTypeDescription
streamIduint256The ID of the newly created stream.
commonParamsLockup.CreateEventCommonCommon parameters emitted in Create events across all Lockup models.
segmentsLockupDynamic.Segment[]The segments the protocol uses to compose the dynamic distribution function.

CreateLockupLinearStream

Emitted when a stream is created using Lockup linear model.

event CreateLockupLinearStream(
uint256 indexed streamId,
Lockup.CreateEventCommon commonParams,
uint40 cliffTime,
LockupLinear.UnlockAmounts unlockAmounts
);

Parameters

NameTypeDescription
streamIduint256The ID of the newly created stream.
commonParamsLockup.CreateEventCommonCommon parameters emitted in Create events across all Lockup models.
cliffTimeuint40The Unix timestamp for the cliff period's end. A value of zero means there is no cliff.
unlockAmountsLockupLinear.UnlockAmountsStruct encapsulating (i) the amount to unlock at the start time and (ii) the amount to unlock at the cliff time.

CreateLockupTranchedStream

Emitted when a stream is created using Lockup tranched model.

event CreateLockupTranchedStream(
uint256 indexed streamId, Lockup.CreateEventCommon commonParams, LockupTranched.Tranche[] tranches
);

Parameters

NameTypeDescription
streamIduint256The ID of the newly created stream.
commonParamsLockup.CreateEventCommonCommon parameters emitted in Create events across all Lockup models.
tranchesLockupTranched.Tranche[]The tranches the protocol uses to compose the tranched distribution function.