Skip to main content

SablierV2LockupLinear

Git Source

Inherits: ISablierV2LockupLinear, SablierV2Lockup

See the documentation in ISablierV2LockupLinear.

State Variables

_cliffs

Cliff times mapped by stream IDs. This complements the _streams mapping in SablierV2Lockup.

mapping(uint256 id => uint40 cliff) internal _cliffs;

Functions

constructor

Emits a {TransferAdmin} event.

constructor(
address initialAdmin,
ISablierV2NFTDescriptor initialNFTDescriptor
)
ERC721("Sablier V2 Lockup Linear NFT", "SAB-V2-LOCKUP-LIN")
SablierV2Lockup(initialAdmin, initialNFTDescriptor);

Parameters

NameTypeDescription
initialAdminaddressThe address of the initial contract admin.
initialNFTDescriptorISablierV2NFTDescriptorThe address of the initial NFT descriptor.

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.

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

Parameters

NameTypeDescription
streamIduint256The stream ID for the query.

getStream

Retrieves the full stream details.

Reverts if streamId references a null stream.

function getStream(uint256 streamId)
external
view
override
notNull(streamId)
returns (LockupLinear.StreamLL memory stream);

Parameters

NameTypeDescription
streamIduint256The stream ID for the query.

Returns

NameTypeDescription
streamLockupLinear.StreamLLSee the documentation in {DataTypes}.

getTimestamps

Retrieves the stream's start, cliff and end timestamps.

Reverts if streamId references a null stream.

function getTimestamps(uint256 streamId)
external
view
override
notNull(streamId)
returns (LockupLinear.Timestamps memory timestamps);

Parameters

NameTypeDescription
streamIduint256The stream ID for the query.

Returns

NameTypeDescription
timestampsLockupLinear.TimestampsSee the documentation in {DataTypes}.

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 {Transfer} and {CreateLockupLinearStream} event. Requirements:

  • All requirements in {createWithTimestamps} must be met for the calculated parameters.
function createWithDurations(LockupLinear.CreateWithDurations calldata params)
external
override
noDelegateCall
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.

createWithTimestamps

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} and {CreateLockupLinearStream} 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, params.timestamps.cliff must be greater than params.timestamps.start and less than params.timestamps.end.
  • params.timestamps.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 createWithTimestamps(LockupLinear.CreateWithTimestamps calldata params)
external
override
noDelegateCall
returns (uint256 streamId);

Parameters

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

Returns

NameTypeDescription
streamIduint256The ID of the newly created stream.

_calculateStreamedAmount

Calculates the streamed amount of the stream without looking up the stream's status.

The distribution 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.
function _calculateStreamedAmount(uint256 streamId) internal view override returns (uint128);

_create

See the documentation for the user-facing functions that call this internal function.

function _create(LockupLinear.CreateWithTimestamps memory params) internal returns (uint256 streamId);