From 7c2079ccc5485d68ce0e325ecc03fcec59bc1666 Mon Sep 17 00:00:00 2001 From: Maxim Ryabykh Date: Fri, 10 May 2024 11:33:40 +0300 Subject: [PATCH] fix: incorrect code snippets, links, descriptions for create stream and batch create streams subsections --- .../01-batch-linear-streams.mdx | 7 +++---- .../02-batch-dynamic-streams.mdx | 8 ++++---- .../v2/guides/create-stream/01-lockup-linear.mdx | 11 +++++------ .../v2/guides/create-stream/02-lockup-dynamic.mdx | 13 +++++++------ 4 files changed, 19 insertions(+), 20 deletions(-) diff --git a/docs/contracts/v2/guides/batch-create-streams/01-batch-linear-streams.mdx b/docs/contracts/v2/guides/batch-create-streams/01-batch-linear-streams.mdx index a2b0d84b..70ea4937 100644 --- a/docs/contracts/v2/guides/batch-create-streams/01-batch-linear-streams.mdx +++ b/docs/contracts/v2/guides/batch-create-streams/01-batch-linear-streams.mdx @@ -35,12 +35,11 @@ pragma solidity >=0.8.19; Now, import the relevant symbols from `@sablier/v2-core` and `@sablier/v2-periphery`: ```solidity +import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; +import { ud60x18 } from "@prb/math/src/UD60x18.sol"; import { ISablierV2LockupLinear } from "@sablier/v2-core/src/interfaces/ISablierV2LockupLinear.sol"; -import { Broker, LockupLinear } from "@sablier/v2-core/src/types/LockupLinear.sol"; -import { ud60x18 } from "@sablier/v2-core/src/types/Math.sol"; -import { IERC20 } from "@sablier/v2-core/src/types/Tokens.sol"; import { ISablierV2Batch } from "@sablier/v2-periphery/src/interfaces/ISablierV2Batch.sol"; -import { Batch} from "@sablier/v2-periphery/src/types/DataTypes.sol"; +import { Batch, Broker, LockupLinear } from "@sablier/v2-periphery/src/types/DataTypes.sol"; ``` Create a contract called `BatchLockupLinearStreamCreator`, and declare a constant `DAI` of type `IERC20`, a constant diff --git a/docs/contracts/v2/guides/batch-create-streams/02-batch-dynamic-streams.mdx b/docs/contracts/v2/guides/batch-create-streams/02-batch-dynamic-streams.mdx index 0f12dae0..5dc53328 100644 --- a/docs/contracts/v2/guides/batch-create-streams/02-batch-dynamic-streams.mdx +++ b/docs/contracts/v2/guides/batch-create-streams/02-batch-dynamic-streams.mdx @@ -35,12 +35,12 @@ pragma solidity >=0.8.19; Now, import the relevant symbols from `@sablier/v2-core` and `@sablier/v2-periphery`: ```solidity +import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; +import { ud2x18 } from "@prb/math/src/UD2x18.sol"; +import { ud60x18 } from "@prb/math/src/UD60x18.sol"; import { ISablierV2LockupDynamic } from "@sablier/v2-core/src/interfaces/ISablierV2LockupDynamic.sol"; -import { Broker, LockupDynamic } from "@sablier/v2-core/src/types/LockupDynamic.sol"; -import { ud60x18 } from "@sablier/v2-core/src/types/Math.sol"; -import { IERC20 } from "@sablier/v2-core/src/types/Tokens.sol"; import { ISablierV2Batch } from "@sablier/v2-periphery/src/interfaces/ISablierV2Batch.sol"; -import { Batch} from "@sablier/v2-periphery/src/types/DataTypes.sol"; +import { Batch, Broker, LockupDynamic } from "@sablier/v2-periphery/src/types/DataTypes.sol"; ``` Create a contract called `BatchLockupDynamicStreamCreator`, and declare a constant `DAI` of type `IERC20`, a constant diff --git a/docs/contracts/v2/guides/create-stream/01-lockup-linear.mdx b/docs/contracts/v2/guides/create-stream/01-lockup-linear.mdx index 3c070529..b43e757c 100644 --- a/docs/contracts/v2/guides/create-stream/01-lockup-linear.mdx +++ b/docs/contracts/v2/guides/create-stream/01-lockup-linear.mdx @@ -41,10 +41,10 @@ pragma solidity >=0.8.19; Import the relevant symbols from `@sablier/v2-core`: ```solidity +import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; +import { ud60x18 } from "@prb/math/src/UD60x18.sol"; import { ISablierV2LockupLinear } from "@sablier/v2-core/src/interfaces/ISablierV2LockupLinear.sol"; import { Broker, LockupLinear } from "@sablier/v2-core/src/types/DataTypes.sol"; -import { ud60x18 } from "@sablier/v2-core/src/types/Math.sol"; -import { IERC20 } from "@sablier/v2-core/src/types/Tokens.sol"; ``` Create a contract called `LockupLinearStreamCreator`, and declare a constant `DAI` of type `IERC20` and a constant @@ -102,7 +102,7 @@ For more guidance on how to approve and transfer ERC-20 assets, see ## Parameters Sablier uses structs to encode the parameters of its create functions. The struct associated with `createWithDurations` -is [`LockupLinear.CreateWithDurations`](/contracts/v2/reference/core/types/library.LockupLinear), and it can be +is [`LockupLinear.CreateWithDurations`](/contracts/v2/reference/core/types/library.LockupLinear#createwithdurations), and it can be initialized like this: ```solidity @@ -127,8 +127,7 @@ Let's review each parameter in detail. ### Durations -Struct that encapsulates (i) the start time of the stream, (ii) the cliff time of the stream, and (iii) the end time of -the stream, all as Unix timestamps. +Struct containing (i) cliff period duration and (ii) total stream duration, both in seconds. ```solidity params.durations = LockupLinear.Durations({ @@ -143,7 +142,7 @@ With all parameters set, we can now call the `createWithDurations` function, and stream to a variable: ```solidity -streamId = lockupLinear.createWithDurations(params); +streamId = LOCKUP_LINEAR.createWithDurations(params); ``` ## The complete Lockup Linear stream creator contract diff --git a/docs/contracts/v2/guides/create-stream/02-lockup-dynamic.mdx b/docs/contracts/v2/guides/create-stream/02-lockup-dynamic.mdx index 2bb52b87..84879cc2 100644 --- a/docs/contracts/v2/guides/create-stream/02-lockup-dynamic.mdx +++ b/docs/contracts/v2/guides/create-stream/02-lockup-dynamic.mdx @@ -41,10 +41,11 @@ pragma solidity >=0.8.19; Import the relevant symbols from `@sablier/v2-core`: ```solidity +import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; +import { ud2x18 } from "@prb/math/src/UD2x18.sol"; +import { ud60x18 } from "@prb/math/src/UD60x18.sol"; import { ISablierV2LockupDynamic } from "@sablier/v2-core/src/interfaces/ISablierV2LockupDynamic.sol"; import { Broker, LockupDynamic } from "@sablier/v2-core/src/types/DataTypes.sol"; -import { ud2x18, ud60x18 } from "@sablier/v2-core/src/types/Math.sol"; -import { IERC20 } from "@sablier/v2-core/src/types/Tokens.sol"; ``` Create a contract called `LockupDynamicStreamCreator`, and declare a constant `DAI` of type `IERC20` and a constant @@ -53,7 +54,7 @@ Create a contract called `LockupDynamicStreamCreator`, and declare a constant `D ```solidity contract LockupDynamicStreamCreator { IERC20 public constant DAI = IERC20(0x6B175474E89094C44Da98b954EedeAC495271d0F); - ISablierV2LockupDynamic public constant LOCKUP_Dynamic = + ISablierV2LockupDynamic public constant LOCKUP_DYNAMIC = ISablierV2LockupDynamic(0x7CC7e125d83A581ff438608490Cc0f7bDff79127); } ``` @@ -109,7 +110,7 @@ For more guidance on how to approve and transfer ERC-20 assets, see ## Parameters Sablier uses structs to encode the parameters of its create functions. The struct associated with `createWithDurations` -is [`LockupDynamic.CreateWithMilestones`](/contracts/v2/reference/core/types/library.LockupDynamic), and it can be +is [`LockupDynamic.CreateWithMilestones`](/contracts/v2/reference/core/types/library.LockupDynamic#createwithmilestones), and it can be initialized like this: ```solidity @@ -139,7 +140,7 @@ The Unix timestamp for when the stream will start. In this example, the start time is set to 100 seconds into the future: ```solidity -params.startTime = block.timestamp + 100 seconds; +params.startTime = uint40(block.timestamp + 100 seconds); ``` ### Segments @@ -150,7 +151,7 @@ exposition of segments, see the [Segments](/concepts/protocol/segments) guide. The term "milestones" in the function `createWithMilestones` refers to the splitting of the stream into several distinct segments, with each segment characterized by a specific amount, exponent, and milestone. These segments are supplied to the function in the form of an array containing -[`LockupDynamic.Segment`](/contracts/v2/reference/core/types/library.LockupDynamic) structs. +[`LockupDynamic.Segment`](/contracts/v2/reference/core/types/library.LockupDynamic#segment) structs. Let's define two dummy segments: