Skip to content

Commit

Permalink
refactor: remove merkle contracts (#1089)
Browse files Browse the repository at this point in the history
* refactor: remove merkle contracts

* docs: update license ens

* refactor: rebase from staging
  • Loading branch information
smol-ninja authored Nov 21, 2024
1 parent abdf8b3 commit f9d329c
Show file tree
Hide file tree
Showing 300 changed files with 557 additions and 6,769 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci-deep.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ jobs:
with:
foundry-fuzz-runs: ${{ fromJSON(inputs.forkFuzzRuns || '1000') }}
foundry-profile: "test-optimized"
match-path: "test/{core,periphery}fork/**/*.sol"
match-path: "test/fork/**/*.sol"
name: "Fork tests"

notify-on-failure:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci-fork.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
foundry-fuzz-runs: 100
foundry-profile: "test-optimized"
fuzz-seed: true
match-path: "test/{core,periphery}fork/**/*.sol"
match-path: "test/fork/**/*.sol"
name: "Fork tests"

test-utils:
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
with:
foundry-fuzz-runs: 2000
foundry-profile: "test-optimized"
match-path: "test/core/unit/**/*.sol"
match-path: "test/unit/**/*.sol"
name: "Unit tests"

test-integration:
Expand All @@ -42,15 +42,15 @@ jobs:
with:
foundry-fuzz-runs: 2000
foundry-profile: "test-optimized"
match-path: "test/{core,periphery}/integration/**/*.sol"
match-path: "test/integration/**/*.sol"
name: "Integration tests"

test-invariant:
needs: ["lint", "build"]
uses: "sablier-labs/reusable-workflows/.github/workflows/forge-test.yml@main"
with:
foundry-profile: "test-optimized"
match-path: "test/core/invariant/**/*.sol"
match-path: "test/invariant/**/*.sol"
name: "Invariant tests"

test-fork:
Expand All @@ -61,7 +61,7 @@ jobs:
with:
foundry-fuzz-runs: 20
foundry-profile: "test-optimized"
match-path: "test/{core,periphery}/fork/**/*.sol"
match-path: "test/fork/**/*.sol"
name: "Fork tests"

coverage:
Expand All @@ -70,4 +70,4 @@ jobs:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
uses: "sablier-labs/reusable-workflows/.github/workflows/forge-coverage.yml@main"
with:
match-path: "test/{core,periphery}/{integration,unit}/**/*.sol"
match-path: "test/{integration,unit}/**/*.sol"
2 changes: 1 addition & 1 deletion .github/workflows/generate-svg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:

- name: "Generate an NFT SVG using the user-provided parameters"
run: >-
forge script script/core/GenerateSVG.s.sol
forge script script/GenerateSVG.s.sol
--sig "run(uint256,string,string,uint256)"
"${{ fromJSON(inputs.progress || true) }}",
"${{ fromJSON(inputs.status || true) }}"
Expand Down
4 changes: 2 additions & 2 deletions LICENSE.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ Licensor: Sablier Labs Ltd

Licensed Work: Sablier Lockup The Licensed Work is (C) 2024 Sablier Labs Ltd

Additional Use Grant: Any uses listed and defined at v2-core-license-grants.sablier.eth
Additional Use Grant: Any uses listed and defined at license-grants.sablier.eth

Change Date: The earlier of 2028-07-03 or a date specified at v2-core-license-date.sablier.eth
Change Date: The earlier of 2028-07-03 or a date specified at license-date.sablier.eth

Change License: GNU General Public License v3.0 or later

Expand Down
6 changes: 4 additions & 2 deletions benchmark/BatchLockup.Gas.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ pragma solidity >=0.8.22;

import { ud2x18 } from "@prb/math/src/UD2x18.sol";

import { Lockup, LockupDynamic, LockupTranched } from "../src/core/types/DataTypes.sol";
import { BatchLockup } from "../src/periphery/types/DataTypes.sol";
import { Lockup, LockupDynamic, LockupTranched } from "../src//types/DataTypes.sol";
import { BatchLockup } from "../src//types/DataTypes.sol";
import { BatchLockupBuilder } from "../test/utils/BatchLockupBuilder.sol";

import { Benchmark_Test } from "./Benchmark.t.sol";
Expand Down Expand Up @@ -112,6 +112,7 @@ contract BatchLockup_Gas_Test is Benchmark_Test {
function gasCreateWithDurationsLL(uint256 batchSize) internal {
BatchLockup.CreateWithDurationsLL[] memory params = BatchLockupBuilder.fillBatch({
params: defaults.createWithDurationsBrokerNull(),
unlockAmounts: defaults.unlockAmounts(),
durations: defaults.durations(),
batchSize: batchSize
});
Expand All @@ -131,6 +132,7 @@ contract BatchLockup_Gas_Test is Benchmark_Test {
function gasCreateWithTimestampsLL(uint256 batchSize) internal {
BatchLockup.CreateWithTimestampsLL[] memory params = BatchLockupBuilder.fillBatch({
params: defaults.createWithTimestampsBrokerNull(),
unlockAmounts: defaults.unlockAmounts(),
cliffTime: defaults.CLIFF_TIME(),
batchSize: batchSize
});
Expand Down
4 changes: 3 additions & 1 deletion benchmark/Benchmark.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,9 @@ abstract contract Benchmark_Test is Base_Test {
function _createFewStreams() internal {
for (uint128 i = 0; i < 100; ++i) {
lockup.createWithTimestampsLD(defaults.createWithTimestamps(), defaults.segments());
lockup.createWithTimestampsLL(defaults.createWithTimestamps(), defaults.CLIFF_TIME());
lockup.createWithTimestampsLL(
defaults.createWithTimestamps(), defaults.unlockAmounts(), defaults.CLIFF_TIME()
);
lockup.createWithTimestampsLT(defaults.createWithTimestamps(), defaults.tranches());
}
}
Expand Down
2 changes: 1 addition & 1 deletion benchmark/LockupDynamic.Gas.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pragma solidity >=0.8.22;
import { ud2x18 } from "@prb/math/src/UD2x18.sol";
import { UD60x18, ud } from "@prb/math/src/UD60x18.sol";

import { Lockup, LockupDynamic } from "../src/core/types/DataTypes.sol";
import { Lockup, LockupDynamic } from "../src//types/DataTypes.sol";

import { Benchmark_Test } from "./Benchmark.t.sol";

Expand Down
15 changes: 10 additions & 5 deletions benchmark/LockupLinear.Gas.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ pragma solidity >=0.8.22;

import { ud } from "@prb/math/src/UD60x18.sol";

import { Lockup, LockupLinear } from "../src/core/types/DataTypes.sol";
import { Lockup, LockupLinear } from "../src//types/DataTypes.sol";

import { Benchmark_Test } from "./Benchmark.t.sol";

Expand Down Expand Up @@ -56,8 +56,11 @@ contract Lockup_Linear_Gas_Test is Benchmark_Test {
LockupLinear.Durations memory durations = defaults.durations();
durations.cliff = cliffDuration;

LockupLinear.UnlockAmounts memory unlockAmounts = defaults.unlockAmounts();
if (cliffDuration == 0) unlockAmounts.cliff = 0;

uint256 beforeGas = gasleft();
lockup.createWithDurationsLL(params, durations);
lockup.createWithDurationsLL(params, unlockAmounts, durations);
string memory gasUsed = vm.toString(beforeGas - gasleft());

string memory cliffSetOrNot = cliffDuration == 0 ? " (cliff not set)" : " (cliff set)";
Expand All @@ -73,7 +76,7 @@ contract Lockup_Linear_Gas_Test is Benchmark_Test {
params.totalAmount = _calculateTotalAmount(defaults.DEPOSIT_AMOUNT(), ud(0));

beforeGas = gasleft();
lockup.createWithDurationsLL(params, durations);
lockup.createWithDurationsLL(params, unlockAmounts, durations);
gasUsed = vm.toString(beforeGas - gasleft());

contentToAppend =
Expand All @@ -88,9 +91,11 @@ contract Lockup_Linear_Gas_Test is Benchmark_Test {
resetPrank({ msgSender: users.sender });

Lockup.CreateWithTimestamps memory params = defaults.createWithTimestamps();
LockupLinear.UnlockAmounts memory unlockAmounts = defaults.unlockAmounts();
if (cliffTime == 0) unlockAmounts.cliff = 0;

uint256 beforeGas = gasleft();
lockup.createWithTimestampsLL(params, cliffTime);
lockup.createWithTimestampsLL(params, unlockAmounts, cliffTime);
string memory gasUsed = vm.toString(beforeGas - gasleft());

string memory cliffSetOrNot = cliffTime == 0 ? " (cliff not set)" : " (cliff set)";
Expand All @@ -106,7 +111,7 @@ contract Lockup_Linear_Gas_Test is Benchmark_Test {
params.totalAmount = _calculateTotalAmount(defaults.DEPOSIT_AMOUNT(), ud(0));

beforeGas = gasleft();
lockup.createWithTimestampsLL(params, cliffTime);
lockup.createWithTimestampsLL(params, unlockAmounts, cliffTime);
gasUsed = vm.toString(beforeGas - gasleft());

contentToAppend =
Expand Down
2 changes: 1 addition & 1 deletion benchmark/LockupTranched.Gas.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ pragma solidity >=0.8.22;

import { UD60x18, ud } from "@prb/math/src/UD60x18.sol";

import { Lockup, LockupTranched } from "../src/core/types/DataTypes.sol";
import { Lockup, LockupTranched } from "../src//types/DataTypes.sol";

import { Benchmark_Test } from "./Benchmark.t.sol";

Expand Down
60 changes: 30 additions & 30 deletions benchmark/results/SablierBatchLockup.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,33 @@

| Function | Lockup Type | Segments/Tranches | Batch Size | Gas Usage |
| ------------------------ | --------------- | ----------------- | ---------- | --------- |
| `createWithDurationsLL` | Lockup Linear | N/A | 5 | 778232 |
| `createWithTimestampsLL` | Lockup Linear | N/A | 5 | 738090 |
| `createWithDurationsLD` | Lockup Dynamic | 24 | 5 | 4117172 |
| `createWithTimestampsLD` | Lockup Dynamic | 24 | 5 | 3887412 |
| `createWithDurationsLT` | Lockup Tranched | 24 | 5 | 3993178 |
| `createWithTimestampsLT` | Lockup Tranched | 24 | 5 | 3806069 |
| `createWithDurationsLL` | Lockup Linear | N/A | 10 | 1423058 |
| `createWithTimestampsLL` | Lockup Linear | N/A | 10 | 1425240 |
| `createWithDurationsLD` | Lockup Dynamic | 24 | 10 | 8189792 |
| `createWithTimestampsLD` | Lockup Dynamic | 24 | 10 | 7725792 |
| `createWithDurationsLT` | Lockup Tranched | 24 | 10 | 7934383 |
| `createWithTimestampsLT` | Lockup Tranched | 24 | 10 | 7563478 |
| `createWithDurationsLL` | Lockup Linear | N/A | 20 | 2795598 |
| `createWithTimestampsLL` | Lockup Linear | N/A | 20 | 2801161 |
| `createWithDurationsLD` | Lockup Dynamic | 24 | 20 | 16350772 |
| `createWithTimestampsLD` | Lockup Dynamic | 24 | 20 | 15407205 |
| `createWithDurationsLT` | Lockup Tranched | 24 | 20 | 15815419 |
| `createWithTimestampsLT` | Lockup Tranched | 24 | 20 | 15082887 |
| `createWithDurationsLL` | Lockup Linear | N/A | 30 | 4162811 |
| `createWithTimestampsLL` | Lockup Linear | N/A | 30 | 4181289 |
| `createWithDurationsLD` | Lockup Dynamic | 24 | 30 | 24549048 |
| `createWithTimestampsLD` | Lockup Dynamic | 24 | 30 | 23102525 |
| `createWithDurationsLT` | Lockup Tranched | 24 | 30 | 23696100 |
| `createWithTimestampsLT` | Lockup Tranched | 24 | 30 | 22616357 |
| `createWithDurationsLL` | Lockup Linear | N/A | 50 | 6903841 |
| `createWithTimestampsLL` | Lockup Linear | N/A | 50 | 6947495 |
| `createWithDurationsLD` | Lockup Dynamic | 12 | 50 | 24028066 |
| `createWithTimestampsLD` | Lockup Dynamic | 12 | 50 | 22808040 |
| `createWithDurationsLT` | Lockup Tranched | 12 | 50 | 23292554 |
| `createWithTimestampsLT` | Lockup Tranched | 12 | 50 | 22433243 |
| `createWithDurationsLL` | Lockup Linear | N/A | 5 | 903159 |
| `createWithTimestampsLL` | Lockup Linear | N/A | 5 | 861441 |
| `createWithDurationsLD` | Lockup Dynamic | 24 | 5 | 4120769 |
| `createWithTimestampsLD` | Lockup Dynamic | 24 | 5 | 3891095 |
| `createWithDurationsLT` | Lockup Tranched | 24 | 5 | 3996698 |
| `createWithTimestampsLT` | Lockup Tranched | 24 | 5 | 3809816 |
| `createWithDurationsLL` | Lockup Linear | N/A | 10 | 1673021 |
| `createWithTimestampsLL` | Lockup Linear | N/A | 10 | 1672189 |
| `createWithDurationsLD` | Lockup Dynamic | 24 | 10 | 8197426 |
| `createWithTimestampsLD` | Lockup Dynamic | 24 | 10 | 7733344 |
| `createWithDurationsLT` | Lockup Tranched | 24 | 10 | 7941453 |
| `createWithTimestampsLT` | Lockup Tranched | 24 | 10 | 7571162 |
| `createWithDurationsLL` | Lockup Linear | N/A | 20 | 3296857 |
| `createWithTimestampsLL` | Lockup Linear | N/A | 20 | 3295805 |
| `createWithDurationsLD` | Lockup Dynamic | 24 | 20 | 16367660 |
| `createWithTimestampsLD` | Lockup Dynamic | 24 | 20 | 15422847 |
| `createWithDurationsLT` | Lockup Tranched | 24 | 20 | 15829541 |
| `createWithTimestampsLT` | Lockup Tranched | 24 | 20 | 15098785 |
| `createWithDurationsLL` | Lockup Linear | N/A | 30 | 4918016 |
| `createWithTimestampsLL` | Lockup Linear | N/A | 30 | 4924864 |
| `createWithDurationsLD` | Lockup Dynamic | 24 | 30 | 24577948 |
| `createWithTimestampsLD` | Lockup Dynamic | 24 | 30 | 23127215 |
| `createWithDurationsLT` | Lockup Tranched | 24 | 30 | 23717265 |
| `createWithTimestampsLT` | Lockup Tranched | 24 | 30 | 22641404 |
| `createWithDurationsLL` | Lockup Linear | N/A | 50 | 8178730 |
| `createWithTimestampsLL` | Lockup Linear | N/A | 50 | 8190836 |
| `createWithDurationsLD` | Lockup Dynamic | 12 | 50 | 24075414 |
| `createWithTimestampsLD` | Lockup Dynamic | 12 | 50 | 22851294 |
| `createWithDurationsLT` | Lockup Tranched | 12 | 50 | 23330071 |
| `createWithTimestampsLT` | Lockup Tranched | 12 | 50 | 22477363 |
54 changes: 27 additions & 27 deletions benchmark/results/SablierLockup_Dynamic.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,30 @@

| Implementation | Gas Usage |
| ------------------------------------------------------------ | --------- |
| `burn` | 15759 |
| `cancel` | 68674 |
| `renounce` | 37726 |
| `createWithDurationsLD` (2 segments) (Broker fee set) | 210925 |
| `createWithDurationsLD` (2 segments) (Broker fee not set) | 194672 |
| `createWithTimestampsLD` (2 segments) (Broker fee set) | 191434 |
| `createWithTimestampsLD` (2 segments) (Broker fee not set) | 186483 |
| `withdraw` (2 segments) (After End Time) (by Recipient) | 19035 |
| `withdraw` (2 segments) (Before End Time) (by Recipient) | 28249 |
| `withdraw` (2 segments) (After End Time) (by Anyone) | 14291 |
| `withdraw` (2 segments) (Before End Time) (by Anyone) | 28305 |
| `createWithDurationsLD` (10 segments) (Broker fee set) | 418459 |
| `createWithDurationsLD` (10 segments) (Broker fee not set) | 413521 |
| `createWithTimestampsLD` (10 segments) (Broker fee set) | 398011 |
| `createWithTimestampsLD` (10 segments) (Broker fee not set) | 393076 |
| `withdraw` (10 segments) (After End Time) (by Recipient) | 14222 |
| `withdraw` (10 segments) (Before End Time) (by Recipient) | 35552 |
| `withdraw` (10 segments) (After End Time) (by Anyone) | 14299 |
| `withdraw` (10 segments) (Before End Time) (by Anyone) | 35608 |
| `createWithDurationsLD` (100 segments) (Broker fee set) | 2918719 |
| `createWithDurationsLD` (100 segments) (Broker fee not set) | 2914766 |
| `createWithTimestampsLD` (100 segments) (Broker fee set) | 2726237 |
| `createWithTimestampsLD` (100 segments) (Broker fee not set) | 2722308 |
| `withdraw` (100 segments) (After End Time) (by Recipient) | 14222 |
| `withdraw` (100 segments) (Before End Time) (by Recipient) | 118136 |
| `withdraw` (100 segments) (After End Time) (by Anyone) | 14278 |
| `withdraw` (100 segments) (Before End Time) (by Anyone) | 118192 |
| `burn` | 15791 |
| `cancel` | 65885 |
| `renounce` | 27466 |
| `createWithDurationsLD` (2 segments) (Broker fee set) | 211605 |
| `createWithDurationsLD` (2 segments) (Broker fee not set) | 195353 |
| `createWithTimestampsLD` (2 segments) (Broker fee set) | 192136 |
| `createWithTimestampsLD` (2 segments) (Broker fee not set) | 187185 |
| `withdraw` (2 segments) (After End Time) (by Recipient) | 19121 |
| `withdraw` (2 segments) (Before End Time) (by Recipient) | 28328 |
| `withdraw` (2 segments) (After End Time) (by Anyone) | 14377 |
| `withdraw` (2 segments) (Before End Time) (by Anyone) | 28384 |
| `createWithDurationsLD` (10 segments) (Broker fee set) | 419147 |
| `createWithDurationsLD` (10 segments) (Broker fee not set) | 414209 |
| `createWithTimestampsLD` (10 segments) (Broker fee set) | 398718 |
| `createWithTimestampsLD` (10 segments) (Broker fee not set) | 393783 |
| `withdraw` (10 segments) (After End Time) (by Recipient) | 14308 |
| `withdraw` (10 segments) (Before End Time) (by Recipient) | 35631 |
| `withdraw` (10 segments) (After End Time) (by Anyone) | 14385 |
| `withdraw` (10 segments) (Before End Time) (by Anyone) | 35687 |
| `createWithDurationsLD` (100 segments) (Broker fee set) | 2919492 |
| `createWithDurationsLD` (100 segments) (Broker fee not set) | 2915538 |
| `createWithTimestampsLD` (100 segments) (Broker fee set) | 2727003 |
| `createWithTimestampsLD` (100 segments) (Broker fee not set) | 2723074 |
| `withdraw` (100 segments) (After End Time) (by Recipient) | 14308 |
| `withdraw` (100 segments) (Before End Time) (by Recipient) | 118217 |
| `withdraw` (100 segments) (After End Time) (by Anyone) | 14364 |
| `withdraw` (100 segments) (Before End Time) (by Anyone) | 118273 |
Loading

0 comments on commit f9d329c

Please sign in to comment.