Skip to main content

SablierV2Batch

Git Source

Inherits: ISablierV2Batch

See the documentation in ISablierV2Batch.

Functions

createWithDurations

Creates a batch of Lockup Linear streams using createWithDurations.

Requirements:

  • There must be at least one element in batch.
  • All requirements from {ISablierV2LockupLinear.createWithDurations} must be met for each stream.
function createWithDurations(
ISablierV2LockupLinear lockupLinear,
IERC20 asset,
Batch.CreateWithDurations[] calldata batch
)
external
override
returns (uint256[] memory streamIds);

Parameters

NameTypeDescription
lockupLinearISablierV2LockupLinearThe address of the SablierV2LockupLinear contract.
assetIERC20The contract address of the ERC-20 asset used for streaming.
batchBatch.CreateWithDurations[]An array of structs, each encapsulating a subset of the parameters of {SablierV2LockupLinear.createWithDurations}.

Returns

NameTypeDescription
streamIdsuint256[]The ids of the newly created streams.

createWithRange

Creates a batch of Lockup Linear streams using createWithRange.

Requirements:

  • There must be at least one element in batch.
  • All requirements from {ISablierV2LockupLinear.createWithRange} must be met for each stream.
function createWithRange(
ISablierV2LockupLinear lockupLinear,
IERC20 asset,
Batch.CreateWithRange[] calldata batch
)
external
override
returns (uint256[] memory streamIds);

Parameters

NameTypeDescription
lockupLinearISablierV2LockupLinearThe address of the SablierV2LockupLinear contract.
assetIERC20The contract address of the ERC-20 asset used for streaming.
batchBatch.CreateWithRange[]An array of structs, each encapsulating a subset of the parameters of {SablierV2LockupLinear.createWithRange}.

Returns

NameTypeDescription
streamIdsuint256[]The ids of the newly created streams.

createWithDeltas

Creates a batch of Lockup Dynamic streams using createWithDeltas.

Requirements:

  • There must be at least one element in batch.
  • All requirements from {ISablierV2LockupDynamic.createWithDeltas} must be met for each stream.
function createWithDeltas(
ISablierV2LockupDynamic lockupDynamic,
IERC20 asset,
Batch.CreateWithDeltas[] calldata batch
)
external
override
returns (uint256[] memory streamIds);

Parameters

NameTypeDescription
lockupDynamicISablierV2LockupDynamicThe address of the SablierV2LockupDynamic contract.
assetIERC20The contract address of the ERC-20 asset used for streaming.
batchBatch.CreateWithDeltas[]An array of structs, each encapsulating a subset of the parameters of {SablierV2LockupDynamic.createWithDeltas}.

Returns

NameTypeDescription
streamIdsuint256[]The ids of the newly created streams.

createWithMilestones

Creates a batch of Lockup Dynamic streams using createWithMilestones.

Requirements:

  • There must be at least one element in batch.
  • All requirements from {ISablierV2LockupDynamic.createWithMilestones} must be met for each stream.
function createWithMilestones(
ISablierV2LockupDynamic lockupDynamic,
IERC20 asset,
Batch.CreateWithMilestones[] calldata batch
)
external
override
returns (uint256[] memory streamIds);

Parameters

NameTypeDescription
lockupDynamicISablierV2LockupDynamicThe address of the SablierV2LockupDynamic contract.
assetIERC20The contract address of the ERC-20 asset used for streaming.
batchBatch.CreateWithMilestones[]An array of structs, each encapsulating a subset of the parameters of {SablierV2LockupDynamic.createWithMilestones}.

Returns

NameTypeDescription
streamIdsuint256[]The ids of the newly created streams.

_approve

Helper function to approve a Sablier contract to spend funds from the batch. If the current allowance is insufficient, this function approves Sablier to spend the exact amount. The {SafeERC20.forceApprove} function is used to handle special ERC-20 assets (e.g. USDT) that require the current allowance to be zero before setting it to a non-zero value.

function _approve(address sablierContract, IERC20 asset, uint256 amount) internal;

_handleTransfer

Helper function to transfer assets from the caller to the batch contract and approve the Sablier contract.

function _handleTransfer(address sablierContract, IERC20 asset, uint256 amount) internal;