ISablierV2LockupDynamic
Inherits: ISablierV2Lockup
Creates and manages lockup streams with dynamic streaming functions.
Functions
MAX_SEGMENT_COUNT
The maximum number of segments allowed in a stream.
This is initialized at construction time and cannot be changed later.
function MAX_SEGMENT_COUNT() external view returns (uint256);
getRange
Retrieves the stream's range, a struct containing (i) the stream's start time and (ii) end time, both as Unix timestamps.
Reverts if streamId references a null stream.
function getRange(uint256 streamId) external view returns (LockupDynamic.Range memory range);
Parameters
| Name | Type | Description |
|---|---|---|
streamId | uint256 | The stream id for the query. |
getSegments
Retrieves the segments the protocol uses to compose the custom streaming curve.
Reverts if streamId references a null stream.
function getSegments(uint256 streamId) external view returns (LockupDynamic.Segment[] memory segments);
Parameters
| Name | Type | Description |
|---|---|---|
streamId | uint256 | The stream id for the query. |
getStream
Retrieves the stream entity.
Reverts if streamId references a null stream.
function getStream(uint256 streamId) external view returns (LockupDynamic.Stream memory stream);
Parameters
| Name | Type | Description |
|---|---|---|
streamId | uint256 | The 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:
Where:
- is the elapsed time divided by the total time in the current segment.
- is the current segment exponent.
- is the current segment amount.
- is the sum of all elapsed segments' amounts. 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
| Name | Type | Description |
|---|---|---|
streamId | uint256 | The stream id for the query. |
createWithDeltas
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 deltas. The segment milestones are derived from these deltas. The stream is funded by msg.sender
and is wrapped in an ERC-721 NFT.
Emits a {CreateLockupDynamicStream} and a {Transfer} event. Requirements:
- All requirements in {createWithMilestones} must be met for the calculated parameters.
function createWithDeltas(LockupDynamic.CreateWithDeltas calldata params) external returns (uint256 streamId);
Parameters
| Name | Type | Description |
|---|---|---|
params | LockupDynamic.CreateWithDeltas | Struct encapsulating the function parameters, which are documented in {DataTypes}. |
Returns
| Name | Type | Description |
|---|---|---|
streamId | uint256 | The id of the newly created stream. |
createWithMilestones
Creates a stream with the provided segment milestones, implying the end time from the last milestone. The stream is
funded by msg.sender and is wrapped in an ERC-721 NFT.
Emits a {CreateLockupDynamicStream} and a {Transfer} event. Notes:
- As long as the segment milestones 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.totalAmountmust be greater than zero.- If set,
params.broker.feemust not be greater thanMAX_FEE. params.segmentsmust have at least one segment, but not more thanMAX_SEGMENT_COUNT.params.startTimemust be less than the first segment's milestone.- The segment milestones must be arranged in ascending order.
- The last segment milestone (i.e. the stream's end time) must be in the future.
- The sum of the segment amounts must equal the deposit amount.
params.recipientmust not be the zero address.msg.sendermust have allowed this contract to spend at leastparams.totalAmountassets.
function createWithMilestones(LockupDynamic.CreateWithMilestones calldata params) external returns (uint256 streamId);
Parameters
| Name | Type | Description |
|---|---|---|
params | LockupDynamic.CreateWithMilestones | Struct encapsulating the function parameters, which are documented in {DataTypes}. |
Returns
| Name | Type | Description |
|---|---|---|
streamId | uint256 | The id of the newly created stream. |
Events
CreateLockupDynamicStream
Emitted when a stream is created.
event CreateLockupDynamicStream(
uint256 streamId,
address indexed funder,
address indexed sender,
address indexed recipient,
Lockup.CreateAmounts amounts,
IERC20 asset,
bool cancelable,
LockupDynamic.Segment[] segments,
LockupDynamic.Range range,
address broker
);