Skip to main content

Lockup

Git Source

Namespace for the structs used in both SablierV2LockupLinear and SablierV2LockupDynamic.

Structs

Amounts

Struct encapsulating the deposit, withdrawn, and refunded amounts, both denoted in units of the asset's decimals.

Because the deposited and the withdrawn amount are often read together, declaring them in the same slot saves gas.

struct Amounts {
uint128 deposited;
uint128 withdrawn;
uint128 refunded;
}

Properties

NameTypeDescription
depositeduint128The initial amount deposited in the stream, net of broker fee.
withdrawnuint128The cumulative amount withdrawn from the stream.
refundeduint128The amount refunded to the sender. Unless the stream was canceled, this is always zero.

CreateAmounts

Struct encapsulating the deposit amount and the broker fee amount, both denoted in units of the asset's decimals.

struct CreateAmounts {
uint128 deposit;
uint128 brokerFee;
}

Properties

NameTypeDescription
deposituint128The amount to deposit in the stream.
brokerFeeuint128The broker fee amount.

Stream

A common data structure to be stored in all SablierV2Lockup models.

The fields are arranged like this to save gas via tight variable packing.

struct Stream {
address sender;
uint40 startTime;
uint40 endTime;
bool isCancelable;
bool wasCanceled;
IERC20 asset;
bool isDepleted;
bool isStream;
bool isTransferable;
Lockup.Amounts amounts;
}

Properties

NameTypeDescription
senderaddressThe address distributing the assets, with the ability to cancel the stream.
startTimeuint40The Unix timestamp indicating the stream's start.
endTimeuint40The Unix timestamp indicating the stream's end.
isCancelableboolBoolean indicating if the stream is cancelable.
wasCanceledboolBoolean indicating if the stream was canceled.
assetIERC20The contract address of the ERC-20 asset to be distributed.
isDepletedboolBoolean indicating if the stream is depleted.
isStreamboolBoolean indicating if the struct entity exists.
isTransferableboolBoolean indicating if the stream NFT is transferable.
amountsLockup.AmountsStruct containing the deposit, withdrawn, and refunded amounts, both denoted in units of the asset's decimals.

Enums

Status

Enum representing the different statuses of a stream.

Notes:

  • PENDING Stream created but not started; assets are in a pending state.

  • STREAMING Active stream where assets are currently being streamed.

  • SETTLED All assets have been streamed; recipient is due to withdraw them.

  • CANCELED Canceled stream; remaining assets await recipient's withdrawal.

  • DEPLETED Depleted stream; all assets have been withdrawn and/or refunded.

enum Status {
PENDING,
STREAMING,
SETTLED,
CANCELED,
DEPLETED
}