SablierLockupPriceGated
Inherits: ISablierLockupPriceGated, NoDelegateCall, SablierLockupState
Title: SablierLockupPriceGated
See the documentation in ISablierLockupPriceGated.
Functions
createWithTimestampsLPG
Creates a stream with the provided start time and end time. The stream is funded by msg.sender and is wrapped in an
ERC-721 NFT.
Emits a {Transfer}, {CreateLockupPriceGatedStream} and {MetadataUpdate} event. Notes:
- The recipient can withdraw the full deposited amount when either:
- The oracle price reaches or exceeds the target price, OR
- Current time is greater than or equal to the stream's end time.
- The sender can cancel the stream when price is less than target price AND end time is in the future.
- The function does not check if the provided oracle reports the price for the deposited token. It may be possible that stream creator has used a different token for the oracle. In such cases, integrators and recipients are requested to verify the oracle correctness on their own.
- The LPG model does not support a "createWithDuration" function because the SablierLockup contract is at the size limit. If the EVM contract size limit is increased in the future, this function will be added. Requirements:
- Must not be delegate called.
params.depositAmountmust be greater than zero.params.sendermust not be the zero address.params.recipientmust not be the zero address.params.timestamps.startmust not be zero.params.timestamps.startmust be less thanparams.timestamps.end.unlockParams.oraclemust implement Chainlink's {AggregatorV3Interface} interface.unlockParams.oraclemust return a non-zero value no greater than 36 when thedecimals()function is called.unlockParams.oraclemust return a positive price when thelatestRoundData()function is called.unlockParams.targetPricemust be greater than the current oracle price.msg.sendermust have allowed this contract to spend at leastparams.depositAmounttokens.params.tokenmust not be the native token.params.shape.lengthmust not be greater than 32 characters.
function createWithTimestampsLPG(
Lockup.CreateWithTimestamps calldata params,
LockupPriceGated.UnlockParams calldata unlockParams
)
external
payable
override
noDelegateCall
returns (uint256 streamId);
Parameters
| Name | Type | Description |
|---|---|---|
params | Lockup.CreateWithTimestamps | Struct encapsulating the function parameters, which are documented in {Lockup} type. |
unlockParams | LockupPriceGated.UnlockParams | Struct encapsulating the unlock parameters, documented in {LockupPriceGated}. |
Returns
| Name | Type | Description |
|---|---|---|
streamId | uint256 | The ID of the newly created stream. |
_createLPG
See the documentation for the user-facing functions that call this private function.
function _createLPG(
Lockup.CreateWithTimestamps calldata params,
LockupPriceGated.UnlockParams calldata unlockParams
)
private
returns (uint256 streamId);