Skip to main content

Helpers

Git Source

Library with helper functions needed across the Sablier V2 contracts.

Functions

checkAndCalculateFees

Checks that neither fee is greater than maxFee, and then calculates the protocol fee amount, the broker fee amount, and the deposit amount from the total amount.

function checkAndCalculateFees(
uint128 totalAmount,
UD60x18 protocolFee,
UD60x18 brokerFee,
UD60x18 maxFee
)
internal
pure
returns (Lockup.CreateAmounts memory amounts);

checkCreateWithMilestones

Checks the parameters of the {SablierV2LockupDynamic-_createWithMilestones} function.

function checkCreateWithMilestones(
uint128 depositAmount,
LockupDynamic.Segment[] memory segments,
uint256 maxSegmentCount,
uint40 startTime
)
internal
view;

checkCreateWithRange

Checks the parameters of the SablierV2LockupLinear-_createWithRange function.

function checkCreateWithRange(uint128 depositAmount, LockupLinear.Range memory range) internal view;

checkDeltasAndCalculateMilestones

Checks that the segment array counts match, and then adjusts the segments by calculating the milestones.

function checkDeltasAndCalculateMilestones(LockupDynamic.SegmentWithDelta[] memory segments)
internal
view
returns (LockupDynamic.Segment[] memory segmentsWithMilestones);

_checkSegments

Checks that:

  1. The first milestone is strictly greater than the start time.
  2. The milestones are ordered chronologically.
  3. There are no duplicate milestones.
  4. The deposit amount is equal to the sum of all segment amounts.
function _checkSegments(
LockupDynamic.Segment[] memory segments,
uint128 depositAmount,
uint40 startTime
)
private
view;