SablierV2ProxyTarget
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 inbatch
. 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
Name | Type | Description |
---|---|---|
batch | Batch.CancelMultiple[] | An array of structs, each encapsulating the lockup contract's address and the stream id to cancel. |
assets | IERC20[] | 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 withstreamIds
. 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
Name | Type | Description |
---|---|---|
lockup | ISablierV2Lockup | The address of the lockup streaming contract. |
assets | IERC20[] | The contract addresses of the ERC-20 assets used for streaming. |
streamIds | uint256[] | 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
Name | Type | Description |
---|---|---|
lockupLinear | ISablierV2LockupLinear | The address of the SablierV2LockupLinear contract. |
asset | IERC20 | The contract address of the ERC-20 asset used for streaming. |
batch | Batch.CreateWithDurations[] | An array of structs, each encapsulating a subset of the parameters of {SablierV2LockupLinear.createWithDurations}. |
permit2Params | Permit2Params | A struct encapsulating the parameters needed for Permit2, most importantly the signature. |
Returns
Name | Type | Description |
---|---|---|
streamIds | uint256[] | 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
Name | Type | Description |
---|---|---|
lockupLinear | ISablierV2LockupLinear | The address of the SablierV2LockupLinear contract. |
asset | IERC20 | The contract address of the ERC-20 asset used for streaming. |
batch | Batch.CreateWithRange[] | An array of structs, each encapsulating a subset of the parameters of {SablierV2LockupLinear.createWithRange}. |
permit2Params | Permit2Params | A struct encapsulating the parameters needed for Permit2, most importantly the signature. |
Returns
Name | Type | Description |
---|---|---|
streamIds | uint256[] | 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
Name | Type | Description |
---|---|---|
lockup | ISablierV2Lockup | The address of the lockup streaming contract where the stream to cancel is. |
streamId | uint256 | The id of the stream to cancel. |
lockupLinear | ISablierV2LockupLinear | The address of the SablierV2LockupLinear contract to use for creating the new stream. |
createParams | LockupLinear.CreateWithDurations | |
permit2Params | Permit2Params | A struct encapsulating the parameters needed for Permit2, most importantly the signature. |
Returns
Name | Type | Description |
---|---|---|
newStreamId | uint256 | The 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
Name | Type | Description |
---|---|---|
lockup | ISablierV2Lockup | The address of the lockup streaming contract where the stream to cancel is. |
streamId | uint256 | The id of the stream to cancel. |
lockupLinear | ISablierV2LockupLinear | The address of the SablierV2LockupLinear contract to use for creating the new stream. |
createParams | LockupLinear.CreateWithRange | |
permit2Params | Permit2Params | A struct encapsulating the parameters needed for Permit2, most importantly the signature. |
Returns
Name | Type | Description |
---|---|---|
newStreamId | uint256 | The 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
Name | Type | Description |
---|---|---|
lockupLinear | ISablierV2LockupLinear | The address of the SablierV2LockupLinear contract. |
createParams | LockupLinear.CreateWithDurations | Struct encapsulating the function parameters, which are documented in V2 Core. |
permit2Params | Permit2Params | A struct encapsulating the parameters needed for Permit2, most importantly the signature. |
Returns
Name | Type | Description |
---|---|---|
streamId | uint256 | The 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
Name | Type | Description |
---|---|---|
lockupLinear | ISablierV2LockupLinear | The address of the SablierV2LockupLinear contract. |
createParams | LockupLinear.CreateWithRange | Struct encapsulating the function parameters, which are documented in V2 Core. |
permit2Params | Permit2Params | A struct encapsulating the parameters needed for Permit2, most importantly the signature. |
Returns
Name | Type | Description |
---|---|---|
streamId | uint256 | The 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 withmsg.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
Name | Type | Description |
---|---|---|
lockupLinear | ISablierV2LockupLinear | The address of the SablierV2LockupLinear contract. |
createParams | LockupLinear.CreateWithDurations | Struct 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 withmsg.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
Name | Type | Description |
---|---|---|
lockupLinear | ISablierV2LockupLinear | The address of the SablierV2LockupLinear contract. |
createParams | LockupLinear.CreateWithRange | Struct 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
Name | Type | Description |
---|---|---|
dynamic | ISablierV2LockupDynamic | |
asset | IERC20 | The contract address of the ERC-20 asset used for streaming. |
batch | Batch.CreateWithDeltas[] | An array of structs, each encapsulating a subset of the parameters of {SablierV2LockupDynamic.createWithDeltas}. |
permit2Params | Permit2Params | A struct encapsulating the parameters needed for Permit2, most importantly the signature. |
Returns
Name | Type | Description |
---|---|---|
streamIds | uint256[] | 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
Name | Type | Description |
---|---|---|
dynamic | ISablierV2LockupDynamic | |
asset | IERC20 | The contract address of the ERC-20 asset used for streaming. |
batch | Batch.CreateWithMilestones[] | An array of structs, each encapsulating a subset of the parameters of {SablierV2LockupDynamic.createWithMilestones}. |
permit2Params | Permit2Params | A struct encapsulating the parameters needed for Permit2, most importantly the signature. |
Returns
Name | Type | Description |
---|---|---|
streamIds | uint256[] | 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
Name | Type | Description |
---|---|---|
lockup | ISablierV2Lockup | The address of the lockup streaming contract where the stream to cancel is. |
streamId | uint256 | The id of the stream to cancel. |
dynamic | ISablierV2LockupDynamic | |
createParams | LockupDynamic.CreateWithDeltas | A struct encapsulating the create function parameters, which are documented in V2 Core. |
permit2Params | Permit2Params | A struct encapsulating the parameters needed for Permit2, most importantly the signature. |
Returns
Name | Type | Description |
---|---|---|
newStreamId | uint256 | The 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
Name | Type | Description |
---|---|---|
lockup | ISablierV2Lockup | The address of the lockup streaming contract where the stream to cancel is. |
streamId | uint256 | The id of the stream to cancel. |
dynamic | ISablierV2LockupDynamic | |
createParams | LockupDynamic.CreateWithMilestones | A struct encapsulating the create function parameters, which are documented in V2 Core. |
permit2Params | Permit2Params | A struct encapsulating the parameters needed for Permit2, most importantly the signature. |
Returns
Name | Type | Description |
---|---|---|
newStreamId | uint256 | The 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
Name | Type | Description |
---|---|---|
dynamic | ISablierV2LockupDynamic | |
createParams | LockupDynamic.CreateWithDeltas | A struct encapsulating the create function parameters, which are documented in V2 Core. |
permit2Params | Permit2Params | A struct encapsulating the parameters needed for Permit2, most importantly the signature. |
Returns
Name | Type | Description |
---|---|---|
streamId | uint256 | The 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
Name | Type | Description |
---|---|---|
dynamic | ISablierV2LockupDynamic | |
createParams | LockupDynamic.CreateWithMilestones | Struct encapsulating the function parameters, which are documented in V2 Core. |
permit2Params | Permit2Params | A struct encapsulating the parameters needed for Permit2, most importantly the signature. |
Returns
Name | Type | Description |
---|---|---|
streamId | uint256 | The 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 withmsg.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
Name | Type | Description |
---|---|---|
dynamic | ISablierV2LockupDynamic | |
createParams | LockupDynamic.CreateWithDeltas | Struct encapsulating the function parameters, which are documented in V2 Core. |
Returns
Name | Type | Description |
---|---|---|
streamId | uint256 | The 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 withmsg.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
Name | Type | Description |
---|---|---|
dynamic | ISablierV2LockupDynamic | |
createParams | LockupDynamic.CreateWithMilestones | Struct encapsulating the function parameters, which are documented in V2 Core. |
Returns
Name | Type | Description |
---|---|---|
streamId | uint256 | The 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;