Skip to main content

Segments

Definition

A Lockup Dynamic stream can be composed out of multiple segments, which are separate partitions with different streaming amount and rates. The protocol uses these segments to enable custom streaming curves, which power exponential streams, cliff streams, etc.

A segment is a struct with three fields:

  • Amount (a uint128): the amount of assets to be streamed in this segment, denoted in units of the asset's decimals.
  • Exponent (a UD2x18): the exponent of this segment, denoted as a fixed-point number.
  • Milestone (a uint40): the Unix timestamp indicating this segment's end.

Each segment has its own streaming function:

f(x)=xexpcsa+Σ(esa)f(x) = x^{exp} * csa + \Sigma(esa)

Where:

  • xx is the elapsed time divided by the total time in the current segment.
  • expexp is the current segment exponent.
  • csacsa is the current segment amount.
  • Σ(esa)\Sigma(esa) is the sum of all elapsed segments' amounts.
info

Segments can be used to represent any monotonic increasing function.

Requirements

  • The sum of all segment amounts must equal the deposit amount.
  • There is a limit to how many segments there can be in a stream, which is due to the block gas limit. If the limit didn't exist and someone created a stream with an excessively large number of segments, the transaction would simply revert as it wouldn't fit within a block.
  • The milestones must be sorted in ascending order. It's not possible for the i-1th milestone to be greater than ith milestone (given we are dealing with increasing monotonic functions).