Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor project and contracts to SablierFlow #120

Merged
merged 3 commits into from
May 24, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
## Sablier V2 Open-Ended
## Sablier Flow
andreivladbrg marked this conversation as resolved.
Show resolved Hide resolved

This repository contains the smart contracts for the EOES (EVM open-ended streams) concept. By open-ended, we mean that
the streams have no fixed duration and no deposit amount at stream creation. This concept is primarily beneficial for
salaries and not for vesting or airdrops, where lockups are more appropriate.
This repository contains the smart contracts for "flow" streams. By flow, we mean that the streams have no fixed
duration and no deposit amount at stream creation. This concept is primarily beneficial for salaries and not for vesting
or airdrops, where lockups are more appropriate.

### Motivation

Expand Down Expand Up @@ -36,14 +36,14 @@ As mentioned above, the creation and deposit operations are distinct. This means
stream is created, and deposits are made afterward. However, a `createAndDeposit` function is implemented to maintain
the same user experience.

Since the streams are open-ended, we don't have a start time nor an end time, instead we have a time reference
Since the streams are flow, we don't have a start time nor an end time, instead we have a time reference
(`lastTimeUpdate`) which will be set to `block.timestamp` at the creation of the stream. There are several actions that
will update this time reference:

- when a withdrawal is made

- `lastTimeUpdate` will be set to the given `time` parameter passed in the function, you can see why this parameter is
needed in the explantion from [this PR](https://github.com/sablier-labs/v2-open-ended/pull/4)
needed in the explantion from [this PR](https://github.com/sablier-labs/flow/pull/4)

- when the rate per second is changed
- `lastTimeUpdate` will be set to `block.timestamp`, this time update is required in the `_adjustRatePerSecond`
Expand Down Expand Up @@ -120,7 +120,7 @@ time to get that 10 per day "streamed", using the 18 decimals format would delay

$\ 0.000115740740740740 \times (oneDayInSeconds + 1 second) = 10.000115740740677000 \$

Currently, I don't think it's possible to address this precision problem entirely, given the nature of open-endedness.
Currently, I don't think it's possible to address this precision problem entirely.

### Technical decisions

Expand Down Expand Up @@ -155,7 +155,7 @@ _bal = sum of deposits - sum of withdrawals_

_sum of withdrawn amounts ≤ sum of deposits_

_sum of stream balances normalized to asset decimals ≤ asset.balanceOf(SablierV2OpenEnded)_
_sum of stream balances normalized to asset decimals ≤ asset.balanceOf(SablierFlow)_

_ltu ≤ now_

Expand Down
2 changes: 1 addition & 1 deletion foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
[doc]
ignore = ["**/*.t.sol"]
out = "docs"
repository = "https://github.com/sablier-labs/v2-open-ended"
repository = "https://github.com/sablier-labs/v2-flow"
andreivladbrg marked this conversation as resolved.
Show resolved Hide resolved

[fmt]
bracket_spacing = true
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"name": "@sablier/v2-open-ended",
"description": "Open ended smart contracts of the Sablier V2 token streaming protocol",
"name": "@sablier/flow",
"description": "Flow smart contracts of the Sablier token distribution protocol",
"license": "BUSL-1.1",
"version": "1.0.0",
"author": {
"name": "Sablier Labs Ltd",
"url": "https://sablier.com"
},
"bugs": {
"url": "https://github.com/sablier-labs/v2-open-ended/issues"
"url": "https://github.com/sablier-labs/flow/issues"
},
"dependencies": {
"@openzeppelin/contracts": "5.0.2",
Expand Down
14 changes: 7 additions & 7 deletions precompiles/Precompiles.sol

Large diffs are not rendered by default.

14 changes: 14 additions & 0 deletions script/DeployDeterministicFlow.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity >=0.8.22 <0.9.0;

import { SablierFlow } from "src/SablierFlow.sol";

import { BaseScript } from "./Base.s.sol";

/// @notice Deploys {SablierFlow} at a deterministic address across chains.
/// @dev Reverts if the contract has already been deployed.
contract DeployDeterministicFlow is BaseScript {
function run() public broadcast returns (SablierFlow flow) {
flow = new SablierFlow{ salt: constructCreate2Salt() }();
}
}
14 changes: 0 additions & 14 deletions script/DeployDeterministicOpenEnded.s.sol

This file was deleted.

13 changes: 13 additions & 0 deletions script/DeployFlow.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity >=0.8.22 <0.9.0;

import { SablierFlow } from "src/SablierFlow.sol";

import { BaseScript } from "./Base.s.sol";

/// @notice Deploys {SablierFlow}.
contract DeployFlow is BaseScript {
function run() public broadcast returns (SablierFlow flow) {
flow = new SablierFlow();
}
}
13 changes: 0 additions & 13 deletions script/DeployOpenEnded.s.sol

This file was deleted.

6 changes: 3 additions & 3 deletions shell/prepare-artifacts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ mkdir $artifacts \
FOUNDRY_PROFILE=optimized forge build

# Copy the production artifacts
cp out-optimized/SablierV2OpenEnded.sol/SablierV2OpenEnded.json $artifacts
cp out-optimized/SablierFlow.sol/SablierFlow.json $artifacts

interfaces=./artifacts/interfaces
cp out-optimized/ISablierV2OpenEnded.sol/ISablierV2OpenEnded.json $interfaces
cp out-optimized/ISablierV2OpenEndedState.sol/ISablierV2OpenEndedState.json $interfaces
cp out-optimized/ISablierFlow.sol/ISablierFlow.json $interfaces
cp out-optimized/ISablierFlowState.sol/ISablierFlowState.json $interfaces

erc20=./artifacts/interfaces/erc20
cp out-optimized/IERC20.sol/IERC20.json $erc20
Expand Down
4 changes: 2 additions & 2 deletions shell/update-precompiles.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ set -euo pipefail
FOUNDRY_PROFILE=optimized forge build

# Retrieve the raw bytecodes, removing the "0x" prefix
open_ended=$(cat out-optimized/SablierV2OpenEnded.sol/SablierV2OpenEnded.json | jq -r '.bytecode.object' | cut -c 3-)
flow=$(cat out-optimized/SablierFlow.sol/SablierFlow.json | jq -r '.bytecode.object' | cut -c 3-)

precompiles_path="precompiles/Precompiles.sol"
if [ ! -f $precompiles_path ]; then
Expand All @@ -21,7 +21,7 @@ if [ ! -f $precompiles_path ]; then
fi

# Replace the current bytecodes
sd "(BYTECODE_OPEN_ENDED =)[^;]+;" "\$1 hex\"$open_ended\";" $precompiles_path
sd "(BYTECODE_FLOW =)[^;]+;" "\$1 hex\"$flow\";" $precompiles_path

# Reformat the code with Forge
forge fmt $precompiles_path
Loading