@@ -3,45 +3,50 @@ pragma solidity >=0.8.22;
33
44import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol " ;
55import { ud60x18 } from "@prb/math/src/UD60x18.sol " ;
6- import { ISablierV2LockupLinear } from "@sablier/v2-core /src/interfaces/ISablierV2LockupLinear .sol " ;
7- import { Broker, LockupLinear } from "@sablier/v2-core /src/types/DataTypes.sol " ;
6+ import { ISablierLockup } from "@sablier/lockup /src/interfaces/ISablierLockup .sol " ;
7+ import { Broker, Lockup, LockupLinear } from "@sablier/lockup /src/types/DataTypes.sol " ;
88
99/// @title LockupStreamCreator
10- /// @dev This contract allows users to create Sablier lockup streams using the Lockup Linear contract.
10+ /// @dev This contract allows users to create Sablier lockup streams using the Lockup contract.
1111contract LockupStreamCreator {
1212 IERC20 public constant DAI = IERC20 (0x68194a729C2450ad26072b3D33ADaCbcef39D574 );
13- ISablierV2LockupLinear public immutable LOCKUP;
1413
15- constructor (ISablierV2LockupLinear lockup ) {
16- LOCKUP = lockup;
17- }
14+ // Get the latest deployment address from the docs: https://docs.sablier.com/guides/lockup/deployments
15+ ISablierLockup public constant LOCKUP = ISablierLockup (0xC2Da366fD67423b500cDF4712BdB41d0995b0794 );
1816
1917 /// @dev Before calling this function, the user must first approve this contract to spend the tokens from the user's
2018 /// address.
21- function createLockupLinearStream (uint256 totalAmount ) external returns (uint256 streamId ) {
19+ function createLinearStream (uint256 totalAmount ) external returns (uint256 streamId ) {
2220 // Transfer the provided amount of DAI tokens to this contract
2321 DAI.transferFrom (msg .sender , address (this ), totalAmount);
2422
2523 // Approve the Lockup contract to spend DAI
2624 DAI.approve (address (LOCKUP), totalAmount);
2725
2826 // Declare the params struct
29- LockupLinear.CreateWithDurations memory params;
27+ Lockup.CreateWithDurations memory params;
28+
29+ // Declare the umlockAmounts and durations structs
30+ LockupLinear.UnlockAmounts memory unlockAmounts = LockupLinear.UnlockAmounts ({
31+ start: 1e18 , // The amount to unlock at the start of the stream.
32+ cliff: 10e18 // The amount to unlock after cliff period.
33+ });
34+ LockupLinear.Durations memory durations = LockupLinear.Durations ({
35+ cliff: 4 weeks, // Cliff tokens will be unlocked after 4 weeks
36+ total: 52 weeks // Setting a total duration of ~1 year
37+ });
3038
3139 // Declare the function parameters
3240 params.sender = msg .sender ; // The sender will be able to cancel the stream
33- params.recipient = address (0xcafe ); // The recipient of the streamed assets
34- params.totalAmount = uint128 (totalAmount); // Total amount is the amount inclusive of all fees
35- params.asset = DAI; // The streaming asset
41+ params.recipient = address (0xcafe ); // The recipient of the streamed tokens
42+ params.totalAmount = uint128 (totalAmount); // Total amount includes unlock amounts as well as the fees, if any
43+ params.token = DAI; // The streaming token
3644 params.cancelable = true ; // Whether the stream will be cancelable or not
3745 params.transferable = true ; // Whether the stream will be transferable or not
38- params.durations = LockupLinear.Durations ({
39- cliff: 4 weeks, // Assets will be unlocked only after 4 weeks
40- total: 52 weeks // Setting a total duration of ~1 year
41- });
46+ params.shape = "cliff linear " ; // Optional parameter for the shape of the stream
4247 params.broker = Broker (address (0 ), ud60x18 (0 )); // Optional parameter for charging a fee
4348
44- // Create the lockup stream using a function that sets the start time to `block.timestamp`
45- streamId = LOCKUP.createWithDurations (params);
49+ // Create the lockup linear stream using a function that sets the start time to `block.timestamp`
50+ streamId = LOCKUP.createWithDurationsLL (params, unlockAmounts, durations );
4651 }
4752}
0 commit comments