Skip to content

Commit

Permalink
Merge pull request #148 from ryabykhms/fix/outdated-code-parts-lockup…
Browse files Browse the repository at this point in the history
…-linear

fix: code snippets
  • Loading branch information
smol-ninja authored May 10, 2024
2 parents 225c42e + 7c2079c commit 4a1d02e
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 5 additions & 6 deletions docs/contracts/v2/guides/create-stream/01-lockup-linear.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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({
Expand All @@ -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
Expand Down
13 changes: 7 additions & 6 deletions docs/contracts/v2/guides/create-stream/02-lockup-dynamic.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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);
}
```
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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:

Expand Down

0 comments on commit 4a1d02e

Please sign in to comment.