Skip to main content

SablierV2ProxyTarget

Git Source

Inherits: ISablierV2ProxyTarget, OnlyDelegateCall, PRBProxyStorage

See the documentation in ISablierV2ProxyTarget.

Functions

batchCancelMultiple

Cancels multiple streams across different lockup contracts.

Notes:

  • All refunded assets are forwarded to the proxy owner.
  • It is assumed that assets includes all assets associated with the stream ids in batch. If any asset is missing, the refunded amount will be left in the proxy. Requirements:
  • Must be delegate called.
  • There must be at least one element in batch.
function batchCancelMultiple(
Batch.CancelMultiple[] calldata batch,
IERC20[] calldata assets
)
external
onlyDelegateCall;

Parameters

NameTypeDescription
batchBatch.CancelMultiple[]An array of structs, each encapsulating the lockup contract's address and the stream id to cancel.
assetsIERC20[]The contract addresses of the ERC-20 assets used for streaming.

burn

Mirror for {ISablierV2Lockup.burn}.

Must be delegate called.

function burn(ISablierV2Lockup lockup, uint256 streamId) external onlyDelegateCall;

cancel

Mirror for {ISablierV2Lockup.cancel}.

Must be delegate called.

function cancel(ISablierV2Lockup lockup, uint256 streamId) public onlyDelegateCall;

cancelMultiple

Mirror for {ISablierV2Lockup.cancelMultiple}.

Notes:

  • All refunded assets are forwarded to the proxy owner.
  • It is assumed that assets includes all assets associated with streamIds. If any asset is missing, the refunded amount will be left in the proxy. Requirements:
  • Must be delegate called.
function cancelMultiple(
ISablierV2Lockup lockup,
IERC20[] calldata assets,
uint256[] calldata streamIds
)
external
onlyDelegateCall;

Parameters

NameTypeDescription
lockupISablierV2LockupThe address of the lockup streaming contract.
assetsIERC20[]The contract addresses of the ERC-20 assets used for streaming.
streamIdsuint256[]The stream ids to cancel.

renounce

Mirror for {ISablierV2Lockup.renounce}.

Must be delegate called.

function renounce(ISablierV2Lockup lockup, uint256 streamId) external onlyDelegateCall;

withdraw

Mirror for {ISablierV2Lockup.withdraw}.

Must be delegate called.

function withdraw(ISablierV2Lockup lockup, uint256 streamId, address to, uint128 amount) external onlyDelegateCall;

withdrawMax

Mirror for {ISablierV2Lockup.withdrawMax}.

Must be delegate called.

function withdrawMax(ISablierV2Lockup lockup, uint256 streamId, address to) external onlyDelegateCall;

batchCreateWithDurations

Creates a batch of Lockup Linear streams using createWithDurations. Assets are transferred to the proxy via Permit2.

Requirements:

  • Must be delegate called.
  • There must be at least one element in batch.
  • All requirements from {ISablierV2LockupLinear.createWithDurations} must be met for each stream.
function batchCreateWithDurations(
ISablierV2LockupLinear lockupLinear,
IERC20 asset,
Batch.CreateWithDurations[] calldata batch,
Permit2Params calldata permit2Params
)
external
override
onlyDelegateCall
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}.
permit2ParamsPermit2ParamsA struct encapsulating the parameters needed for Permit2, most importantly the signature.

Returns

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

batchCreateWithRange

Creates a batch of Lockup Linear streams using createWithRange. Assets are transferred to the proxy via Permit2.

Requirements:

  • Must be delegate called.
  • There must be at least one element in batch.
  • All requirements from {ISablierV2LockupLinear.createWithRange} must be met for each stream.
function batchCreateWithRange(
ISablierV2LockupLinear lockupLinear,
IERC20 asset,
Batch.CreateWithRange[] calldata batch,
Permit2Params calldata permit2Params
)
external
override
onlyDelegateCall
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}.
permit2ParamsPermit2ParamsA struct encapsulating the parameters needed for Permit2, most importantly the signature.

Returns

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

cancelAndCreateWithDurations

Cancels a Lockup stream and creates a new Lockup Linear stream using createWithDurations. Assets are transferred to the proxy via Permit2.

Notes:

  • streamId can reference either a Lockup Linear or a Lockup Dynamic stream.
  • See {ISablierV2Lockup.cancel} and {ISablierV2LockupLinear.createWithDurations} for full documentation. Requirements:
  • Must be delegate called.
function cancelAndCreateWithDurations(
ISablierV2Lockup lockup,
uint256 streamId,
ISablierV2LockupLinear lockupLinear,
LockupLinear.CreateWithDurations calldata createParams,
Permit2Params calldata permit2Params
)
external
override
onlyDelegateCall
returns (uint256 newStreamId);

Parameters

NameTypeDescription
lockupISablierV2LockupThe address of the lockup streaming contract where the stream to cancel is.
streamIduint256The id of the stream to cancel.
lockupLinearISablierV2LockupLinearThe address of the SablierV2LockupLinear contract to use for creating the new stream.
createParamsLockupLinear.CreateWithDurations
permit2ParamsPermit2ParamsA struct encapsulating the parameters needed for Permit2, most importantly the signature.

Returns

NameTypeDescription
newStreamIduint256The id of the newly created stream.

cancelAndCreateWithRange

Cancels a Lockup stream and creates a new Lockup Linear stream using createWithRange. Assets are transferred to the proxy via Permit2.

Notes:

  • streamId can reference either a Lockup Linear or a Lockup Dynamic stream.
  • See {ISablierV2Lockup.cancel} and {ISablierV2LockupLinear.createWithRange} for full documentation. Requirements:
  • Must be delegate called.
function cancelAndCreateWithRange(
ISablierV2Lockup lockup,
uint256 streamId,
ISablierV2LockupLinear lockupLinear,
LockupLinear.CreateWithRange calldata createParams,
Permit2Params calldata permit2Params
)
external
override
onlyDelegateCall
returns (uint256 newStreamId);

Parameters

NameTypeDescription
lockupISablierV2LockupThe address of the lockup streaming contract where the stream to cancel is.
streamIduint256The id of the stream to cancel.
lockupLinearISablierV2LockupLinearThe address of the SablierV2LockupLinear contract to use for creating the new stream.
createParamsLockupLinear.CreateWithRange
permit2ParamsPermit2ParamsA struct encapsulating the parameters needed for Permit2, most importantly the signature.

Returns

NameTypeDescription
newStreamIduint256The id of the newly created stream.

createWithDurations

Mirror for {SablierV2LockupLinear.createWithDurations}. Assets are transferred to the proxy via Permit2.

Must be delegate called.

function createWithDurations(
ISablierV2LockupLinear lockupLinear,
LockupLinear.CreateWithDurations calldata createParams,
Permit2Params calldata permit2Params
)
public
override
onlyDelegateCall
returns (uint256 streamId);

Parameters

NameTypeDescription
lockupLinearISablierV2LockupLinearThe address of the SablierV2LockupLinear contract.
createParamsLockupLinear.CreateWithDurationsStruct encapsulating the function parameters, which are documented in V2 Core.
permit2ParamsPermit2ParamsA struct encapsulating the parameters needed for Permit2, most importantly the signature.

Returns

NameTypeDescription
streamIduint256The id of the newly created stream.

createWithRange

Mirror for {SablierV2LockupLinear.createWithRange}. Assets are transferred to the proxy via Permit2.

Must be delegate called.

function createWithRange(
ISablierV2LockupLinear lockupLinear,
LockupLinear.CreateWithRange calldata createParams,
Permit2Params calldata permit2Params
)
public
override
onlyDelegateCall
returns (uint256 streamId);

Parameters

NameTypeDescription
lockupLinearISablierV2LockupLinearThe address of the SablierV2LockupLinear contract.
createParamsLockupLinear.CreateWithRangeStruct encapsulating the function parameters, which are documented in V2 Core.
permit2ParamsPermit2ParamsA struct encapsulating the parameters needed for Permit2, most importantly the signature.

Returns

NameTypeDescription
streamIduint256The id of the newly created stream.

wrapAndCreateWithDurations

Wraps the native asset payment in ERC-20 form and creates a Lockup Linear stream using createWithDurations.

Notes:

  • createParams.totalAmount is overwritten with msg.value.
  • See {ISablierV2LockupLinear.createWithDurations} for full documentation. Requirements:
  • Must be delegate called.
  • The ERC-20 amount credited by the wrapper contract must be equal to msg.value.
function wrapAndCreateWithDurations(
ISablierV2LockupLinear lockupLinear,
LockupLinear.CreateWithDurations memory createParams
)
external
payable
override
onlyDelegateCall
returns (uint256 streamId);

Parameters

NameTypeDescription
lockupLinearISablierV2LockupLinearThe address of the SablierV2LockupLinear contract.
createParamsLockupLinear.CreateWithDurationsStruct encapsulating the function parameters, which are documented in V2 Core.

wrapAndCreateWithRange

Wraps the native asset payment in ERC-20 form and creates a Lockup Linear stream using createWithRange.

Notes:

  • createParams.totalAmount is overwritten with msg.value.
  • See {ISablierV2LockupLinear.createWithRange} for full documentation. Requirements:
  • Must be delegate called.
  • The ERC-20 amount credited by the wrapper contract must be equal to msg.value.
function wrapAndCreateWithRange(
ISablierV2LockupLinear lockupLinear,
LockupLinear.CreateWithRange memory createParams
)
external
payable
override
onlyDelegateCall
returns (uint256 streamId);

Parameters

NameTypeDescription
lockupLinearISablierV2LockupLinearThe address of the SablierV2LockupLinear contract.
createParamsLockupLinear.CreateWithRangeStruct encapsulating the function parameters, which are documented in V2 Core.

batchCreateWithDeltas

Creates a batch of Lockup Dynamic streams using createWithDeltas. Assets are transferred to the proxy via Permit2.

Requirements:

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

Parameters

NameTypeDescription
dynamicISablierV2LockupDynamic
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}.
permit2ParamsPermit2ParamsA struct encapsulating the parameters needed for Permit2, most importantly the signature.

Returns

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

batchCreateWithMilestones

Creates a batch of Lockup Dynamic streams using createWithMilestones. Assets are transferred to the proxy via Permit2.

Requirements:

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

Parameters

NameTypeDescription
dynamicISablierV2LockupDynamic
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}.
permit2ParamsPermit2ParamsA struct encapsulating the parameters needed for Permit2, most importantly the signature.

Returns

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

cancelAndCreateWithDeltas

Cancels a Lockup stream and creates a new Lockup Dynamic stream using createWithDeltas. Assets are transferred to the proxy via Permit2.

Notes:

  • streamId can reference either a Lockup Linear or a Lockup Dynamic stream.
  • See {ISablierV2Lockup.cancel} and {ISablierV2LockupDynamic.createWithDeltas} for full documentation. Requirements:
  • Must be delegate called.
function cancelAndCreateWithDeltas(
ISablierV2Lockup lockup,
uint256 streamId,
ISablierV2LockupDynamic dynamic,
LockupDynamic.CreateWithDeltas calldata createParams,
Permit2Params calldata permit2Params
)
external
override
onlyDelegateCall
returns (uint256 newStreamId);

Parameters

NameTypeDescription
lockupISablierV2LockupThe address of the lockup streaming contract where the stream to cancel is.
streamIduint256The id of the stream to cancel.
dynamicISablierV2LockupDynamic
createParamsLockupDynamic.CreateWithDeltasA struct encapsulating the create function parameters, which are documented in V2 Core.
permit2ParamsPermit2ParamsA struct encapsulating the parameters needed for Permit2, most importantly the signature.

Returns

NameTypeDescription
newStreamIduint256The id of the newly created stream.

cancelAndCreateWithMilestones

Cancels a Lockup stream and creates a new Lockup Dynamic stream using createWithMilestones. Assets are transferred to the proxy via Permit2.

Notes:

  • streamId can reference either a Lockup Linear or a Lockup Dynamic stream.
  • See {ISablierV2Lockup.cancel} and {ISablierV2LockupDynamic.createWithMilestones} for full documentation. Requirements:
  • Must be delegate called.
function cancelAndCreateWithMilestones(
ISablierV2Lockup lockup,
uint256 streamId,
ISablierV2LockupDynamic dynamic,
LockupDynamic.CreateWithMilestones calldata createParams,
Permit2Params calldata permit2Params
)
external
override
onlyDelegateCall
returns (uint256 newStreamId);

Parameters

NameTypeDescription
lockupISablierV2LockupThe address of the lockup streaming contract where the stream to cancel is.
streamIduint256The id of the stream to cancel.
dynamicISablierV2LockupDynamic
createParamsLockupDynamic.CreateWithMilestonesA struct encapsulating the create function parameters, which are documented in V2 Core.
permit2ParamsPermit2ParamsA struct encapsulating the parameters needed for Permit2, most importantly the signature.

Returns

NameTypeDescription
newStreamIduint256The id of the newly created stream.

createWithDeltas

Mirror for {SablierV2LockupDynamic.createWithDeltas}. Assets are transferred to the proxy via Permit2.

Must be delegate called.

function createWithDeltas(
ISablierV2LockupDynamic dynamic,
LockupDynamic.CreateWithDeltas calldata createParams,
Permit2Params calldata permit2Params
)
public
override
onlyDelegateCall
returns (uint256 streamId);

Parameters

NameTypeDescription
dynamicISablierV2LockupDynamic
createParamsLockupDynamic.CreateWithDeltasA struct encapsulating the create function parameters, which are documented in V2 Core.
permit2ParamsPermit2ParamsA struct encapsulating the parameters needed for Permit2, most importantly the signature.

Returns

NameTypeDescription
streamIduint256The id of the newly created stream.

createWithMilestones

Mirror for {SablierV2LockupDynamic.createWithMilestones}. Assets are transferred to the proxy via Permit2.

Must be delegate called.

function createWithMilestones(
ISablierV2LockupDynamic dynamic,
LockupDynamic.CreateWithMilestones calldata createParams,
Permit2Params calldata permit2Params
)
public
override
onlyDelegateCall
returns (uint256 streamId);

Parameters

NameTypeDescription
dynamicISablierV2LockupDynamic
createParamsLockupDynamic.CreateWithMilestonesStruct encapsulating the function parameters, which are documented in V2 Core.
permit2ParamsPermit2ParamsA struct encapsulating the parameters needed for Permit2, most importantly the signature.

Returns

NameTypeDescription
streamIduint256The id of the newly created stream.

wrapAndCreateWithDeltas

Wraps the native asset payment in ERC-20 form and creates a Lockup Dynamic stream using createWithDeltas.

Notes:

  • createParams.totalAmount is overwritten with msg.value.
  • See {ISablierV2LockupDynamic.createWithDeltas} for full documentation. Requirements:
  • Must be delegate called.
  • The ERC-20 amount credited by the wrapper contract must be equal to msg.value.
function wrapAndCreateWithDeltas(
ISablierV2LockupDynamic dynamic,
LockupDynamic.CreateWithDeltas memory createParams
)
external
payable
override
onlyDelegateCall
returns (uint256 streamId);

Parameters

NameTypeDescription
dynamicISablierV2LockupDynamic
createParamsLockupDynamic.CreateWithDeltasStruct encapsulating the function parameters, which are documented in V2 Core.

Returns

NameTypeDescription
streamIduint256The id of the newly created stream.

wrapAndCreateWithMilestones

Wraps the native asset payment in ERC-20 form and creates a Lockup Dynamic stream using createWithMilestones.

Notes:

  • createParams.totalAmount is overwritten with msg.value.
  • See {ISablierV2LockupDynamic.createWithMilestones} for full documentation. Requirements:
  • Must be delegate called.
  • The ERC-20 amount credited by the wrapper contract must be equal to msg.value.
function wrapAndCreateWithMilestones(
ISablierV2LockupDynamic dynamic,
LockupDynamic.CreateWithMilestones memory createParams
)
external
payable
override
onlyDelegateCall
returns (uint256 streamId);

Parameters

NameTypeDescription
dynamicISablierV2LockupDynamic
createParamsLockupDynamic.CreateWithMilestonesStruct encapsulating the function parameters, which are documented in V2 Core.

Returns

NameTypeDescription
streamIduint256The id of the newly created stream.

_approve

Helper function to approve a Sablier contract to spend funds from the proxy. 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;

_getBalances

Helper function to retrieve the proxy's balance for the provided assets.

function _getBalances(IERC20[] calldata assets) internal view returns (uint256[] memory initialBalances);

_postMultipleCancellations

Shared logic between cancelMultiple and batchCancelMultiple.

function _postMultipleCancellations(uint256[] memory initialBalances, IERC20[] calldata assets) internal;

_safeWrap

Safely wraps the native asset payment in ERC-20 form, checking that the credit amount is greater than or equal to msg.value.

function _safeWrap(IERC20 asset) internal;

_transferAndApprove

Helper function to transfer funds from the proxy owner to the proxy using Permit2 and, if needed, approve the Sablier contract to spend funds from the proxy.

function _transferAndApprove(
address sablierContract,
IERC20 asset,
uint160 amount,
Permit2Params calldata permit2Params
)
internal;