Skip to content

Commit

Permalink
refactor: rename Batch to BatchLockup (#322)
Browse files Browse the repository at this point in the history
* refactor: rename Batch to BatchLockup

* refactor: rename 'batchLockup' to 'batch'

---------

Co-authored-by: Paul Razvan Berg <[email protected]>
  • Loading branch information
smol-ninja and PaulRBerg authored Apr 12, 2024
1 parent 470aea1 commit 7c3ca60
Show file tree
Hide file tree
Showing 41 changed files with 411 additions and 355 deletions.
88 changes: 55 additions & 33 deletions .gas-snapshot
Original file line number Diff line number Diff line change
@@ -1,33 +1,55 @@
Claim_Integration_Test:test_Claim() (gas: 278641)
Claim_Integration_Test:test_RevertGiven_AlreadyClaimed() (gas: 266327)
Claim_Integration_Test:test_RevertGiven_CampaignExpired() (gas: 17745)
Claim_Integration_Test:test_RevertGiven_ProtocolFeeNotZero() (gas: 84510)
Clawback_Integration_Test:testFuzz_Clawback(address) (runs: 20, μ: 316725, ~: 316725)
Clawback_Integration_Test:testFuzz_Clawback_CampaignNotExpired(address) (runs: 20, μ: 88746, ~: 88746)
Clawback_Integration_Test:test_Clawback() (gas: 271907)
Clawback_Integration_Test:test_RevertGiven_CampaignNotExpired() (gas: 30429)
Constructor_MerkleStreamerLL_Integration_Test:test_Constructor() (gas: 1198502)
CreateMerkleStreamerLL_Integration_Test:testFuzz_CreateMerkleStreamerLL(address,uint40) (runs: 20, μ: 1126334, ~: 1126334)
CreateMerkleStreamerLL_Integration_Test:test_RevertGiven_AlreadyDeployed() (gas: 8937393460516730624)
CreateWithDeltas_Integration_Test:test_BatchCreateWithDeltas() (gas: 2070068)
CreateWithDurations_Integration_Test:test_BatchCreateWithDurations() (gas: 1333914)
CreateWithMilestones_Integration_Test:test_BatchCreateWithMilestones() (gas: 2063258)
CreateWithRange_Integration_Test:test_CreateWithRange() (gas: 1336083)
HasClaimed_Integration_Test:test_HasClaimed() (gas: 251704)
HasClaimed_Integration_Test:test_HasClaimed_IndexNotInTree() (gas: 7997)
HasClaimed_Integration_Test:test_HasClaimed_NotClaimed() (gas: 13254)
HasExpired_Integration_Test:test_HasExpired_ExpirationEqualToCurrentTime() (gas: 13957)
HasExpired_Integration_Test:test_HasExpired_ExpirationGreaterThanCurrentTime() (gas: 14051)
HasExpired_Integration_Test:test_HasExpired_ExpirationLessThanCurrentTime() (gas: 5746)
HasExpired_Integration_Test:test_HasExpired_ExpirationZero() (gas: 1068623)
MerkleBuilder_Test:testFuzz_ComputeLeaf(uint256,address,uint128) (runs: 20, μ: 1176, ~: 1176)
MerkleBuilder_Test:testFuzz_ComputeLeaves((uint256,address,uint128)[]) (runs: 20, μ: 328702, ~: 368679)
Precompiles_Test:test_DeployBatch() (gas: 2794084)
Precompiles_Test:test_DeployMerkleStreamerFactory() (gas: 3098051)
Precompiles_Test:test_DeployPeriphery() (gas: 5886439)
USDC_CreateWithMilestones_Batch_Fork_Test:testForkFuzz_CreateWithMilestones((uint128,address,address,uint128,uint40,(uint128,uint64,uint40)[])) (runs: 20, μ: 35758280, ~: 21718385)
USDC_CreateWithRange_Batch_Fork_Test:testForkFuzz_CreateWithRange((uint128,(uint40,uint40,uint40),address,address,uint128)) (runs: 20, μ: 1353143, ~: 1508161)
USDC_MerkleStreamerLL_Fork_Test:testForkFuzz_MerkleStreamerLL((address,uint40,(uint256,uint256,uint128)[],uint256)) (runs: 20, μ: 4504409, ~: 3860802)
USDT_CreateWithMilestones_Batch_Fork_Test:testForkFuzz_CreateWithMilestones((uint128,address,address,uint128,uint40,(uint128,uint64,uint40)[])) (runs: 20, μ: 35758280, ~: 21718385)
USDT_CreateWithRange_Batch_Fork_Test:testForkFuzz_CreateWithRange((uint128,(uint40,uint40,uint40),address,address,uint128)) (runs: 20, μ: 1353143, ~: 1508161)
USDT_MerkleStreamerLL_Fork_Test:testForkFuzz_MerkleStreamerLL((address,uint40,(uint256,uint256,uint128)[],uint256)) (runs: 20, μ: 4504409, ~: 3860802)
BaseScript_Test:test_ConstructCreate2Salt() (gas: 18701)
Claim_Integration_Test:test_Claim() (gas: 296792)
Claim_Integration_Test:test_Claim() (gas: 359541)
Claim_Integration_Test:test_Claim_CalculatedAmountsSumNotEqualClaimAmount() (gas: 1906979)
Claim_Integration_Test:test_RevertGiven_AlreadyClaimed() (gas: 274624)
Claim_Integration_Test:test_RevertGiven_AlreadyClaimed() (gas: 329502)
Claim_Integration_Test:test_RevertGiven_CampaignExpired() (gas: 17786)
Claim_Integration_Test:test_RevertGiven_CampaignExpired() (gas: 17811)
Clawback_Integration_Test:testFuzz_Clawback(address) (runs: 38, μ: 295825, ~: 295825)
Clawback_Integration_Test:testFuzz_Clawback(address) (runs: 38, μ: 350750, ~: 350750)
Clawback_Integration_Test:test_Clawback() (gas: 278339)
Clawback_Integration_Test:test_Clawback() (gas: 333264)
Clawback_Integration_Test:test_RevertGiven_CampaignNotExpired() (gas: 19523)
Clawback_Integration_Test:test_RevertGiven_CampaignNotExpired() (gas: 19523)
Constructor_MerkleLL_Integration_Test:test_Constructor() (gas: 1150963)
Constructor_MerkleLT_Integration_Test:test_Constructor() (gas: 1495600)
CreateMerkleLL_Integration_Test:testFuzz_CreateMerkleLL(address,uint40) (runs: 38, μ: 1122843, ~: 1123367)
CreateMerkleLL_Integration_Test:test_RevertGiven_CreatedAlready() (gas: 8937393460516730662)
CreateMerkleLT_Integration_Test:testFuzz_CreateMerkleLT(address,uint40) (runs: 38, μ: 1431123, ~: 1431123)
CreateMerkleLT_Integration_Test:test_RevertGiven_CreatedAlready() (gas: 8937393460516730766)
CreateWithDurationsLD_Integration_Test:test_BatchCreateWithDurations() (gas: 2021956)
CreateWithDurationsLL_Integration_Test:test_BatchCreateWithDurations() (gas: 1498705)
CreateWithDurationsLT_Integration_Test:test_BatchCreateWithDurations() (gas: 2007334)
CreateWithTimestampsLD_Integration_Test:test_BatchCreateWithTimestamps() (gas: 2005042)
CreateWithTimestampsLL_Integration_Test:test_BatchCreateWithTimestamps() (gas: 1497928)
CreateWithTimestampsLT_Integration_Test:test_BatchCreateWithTimestamps() (gas: 1991536)
HasClaimed_Integration_Test:test_HasClaimed() (gas: 263197)
HasClaimed_Integration_Test:test_HasClaimed() (gas: 318100)
HasClaimed_Integration_Test:test_HasClaimed_IndexNotInTree() (gas: 11174)
HasClaimed_Integration_Test:test_HasClaimed_IndexNotInTree() (gas: 11196)
HasClaimed_Integration_Test:test_HasClaimed_NotClaimed() (gas: 16409)
HasClaimed_Integration_Test:test_HasClaimed_NotClaimed() (gas: 16431)
HasExpired_Integration_Test:test_HasExpired_ExpirationEqualToBlockTimestamp() (gas: 14692)
HasExpired_Integration_Test:test_HasExpired_ExpirationEqualToBlockTimestamp() (gas: 14714)
HasExpired_Integration_Test:test_HasExpired_ExpirationGreaterThanBlockTimestamp() (gas: 14788)
HasExpired_Integration_Test:test_HasExpired_ExpirationGreaterThanBlockTimestamp() (gas: 14810)
HasExpired_Integration_Test:test_HasExpired_ExpirationLessThanBlockTimestamp() (gas: 8902)
HasExpired_Integration_Test:test_HasExpired_ExpirationLessThanBlockTimestamp() (gas: 8924)
HasExpired_Integration_Test:test_HasExpired_ExpirationZero() (gas: 1051899)
HasExpired_Integration_Test:test_HasExpired_ExpirationZero() (gas: 1343143)
MerkleBuilder_Test:testFuzz_ComputeLeaf(uint256,address,uint128) (runs: 38, μ: 4323, ~: 4323)
MerkleBuilder_Test:testFuzz_ComputeLeaves((uint256,address,uint128)[]) (runs: 38, μ: 366364, ~: 398189)
Precompiles_Test:test_DeployBatchLockup() (gas: 3323914)
Precompiles_Test:test_DeployMerkleLockupFactory() (gas: 6986949)
Precompiles_Test:test_DeployPeriphery() (gas: 10310682)
USDC_CreateWithTimestamps_LockupDynamic_BatchLockup_Fork_Test:testForkFuzz_CreateWithTimestampsLD((uint128,address,address,uint128,uint40,(uint128,uint64,uint40)[])) (runs: 38, μ: 34210026, ~: 30903106)
USDC_CreateWithTimestamps_LockupLinear_BatchLockup_Fork_Test:testForkFuzz_CreateWithTimestampsLL((uint128,(uint40,uint40,uint40),address,address,uint128)) (runs: 38, μ: 1592674, ~: 1502438)
USDC_CreateWithTimestamps_LockupTranched_BatchLockup_Fork_Test:testForkFuzz_CreateWithTimestampsLT((uint128,address,address,uint128,uint40,(uint128,uint40)[])) (runs: 36, μ: 24927469, ~: 23804750)
USDC_MerkleLL_Fork_Test:testForkFuzz_MerkleLL((address,uint40,(uint256,uint256,uint128)[],uint256)) (runs: 38, μ: 5247542, ~: 5027798)
USDC_MerkleLT_Fork_Test:testForkFuzz_MerkleLT((address,uint40,(uint256,uint256,uint128)[],uint256)) (runs: 38, μ: 5622048, ~: 5399736)
USDT_CreateWithTimestamps_LockupDynamic_BatchLockup_Fork_Test:testForkFuzz_CreateWithTimestampsLD((uint128,address,address,uint128,uint40,(uint128,uint64,uint40)[])) (runs: 38, μ: 30978443, ~: 21899958)
USDT_CreateWithTimestamps_LockupLinear_BatchLockup_Fork_Test:testForkFuzz_CreateWithTimestampsLL((uint128,(uint40,uint40,uint40),address,address,uint128)) (runs: 38, μ: 1953484, ~: 2211406)
USDT_CreateWithTimestamps_LockupTranched_BatchLockup_Fork_Test:testForkFuzz_CreateWithTimestampsLT((uint128,address,address,uint128,uint40,(uint128,uint40)[])) (runs: 38, μ: 27146173, ~: 17675525)
USDT_MerkleLL_Fork_Test:testForkFuzz_MerkleLL((address,uint40,(uint256,uint256,uint128)[],uint256)) (runs: 38, μ: 5214786, ~: 4997326)
USDT_MerkleLT_Fork_Test:testForkFuzz_MerkleLT((address,uint40,(uint256,uint256,uint128)[],uint256)) (runs: 38, μ: 5585576, ~: 5365241)
2 changes: 1 addition & 1 deletion foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
{ access = "read-write", path = "./cache" },
]
gas_reports = [
"SablierV2Batch",
"SablierV2BatchLockup",
"SablierV2MerkleLL",
"SablierV2MerkleLockupFactory",
"SablierV2MerkleLT",
Expand Down
30 changes: 16 additions & 14 deletions precompiles/Precompiles.sol

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion script/Base.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ contract BaseScript is Script, Sphinx {
/// Refer to https://github.com/sphinx-labs/sphinx/tree/main/docs.
///
/// CLI example:
/// bun sphinx propose script/DeployBatch.s.sol --networks testnets --sig "runSphinx()"
/// bun sphinx propose script/DeploybatchLockup.s.sol --networks testnets --sig "runSphinx()"
function configureSphinx() public override {
sphinxConfig.mainnets = ["arbitrum", "avalanche", "base", "bnb", "gnosis", "ethereum", "optimism", "polygon"];
sphinxConfig.orgId = vm.envOr({ name: "SPHINX_ORG_ID", defaultValue: TEST_MNEMONIC });
Expand Down
22 changes: 0 additions & 22 deletions script/DeployBatch.t.sol

This file was deleted.

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

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

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

contract DeployBatchLockup is BaseScript {
/// @dev Deploy via Forge.
function runBroadcast() public virtual broadcast returns (SablierV2BatchLockup batchLockup) {
batchLockup = _run();
}

/// @dev Deploy via Sphinx.
function runSphinx() public virtual sphinx returns (SablierV2BatchLockup batchLockup) {
batchLockup = _run();
}

function _run() internal returns (SablierV2BatchLockup batchLockup) {
batchLockup = new SablierV2BatchLockup();
}
}
25 changes: 0 additions & 25 deletions script/DeployDeterministicBatch.s.sol

This file was deleted.

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

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

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

/// @notice Deploys {SablierV2BatchLockup} at a deterministic address across chains.
/// @dev Reverts if the contract has already been deployed.
contract DeployDeterministicBatchLockup is BaseScript {
/// @dev Deploy via Forge.
function runBroadcast() public virtual broadcast returns (SablierV2BatchLockup batchLockup) {
batchLockup = _run();
}

/// @dev Deploy via Sphinx.
function runSphinx() public virtual sphinx returns (SablierV2BatchLockup batchLockup) {
batchLockup = _run();
}

function _run() internal returns (SablierV2BatchLockup batchLockup) {
bytes32 salt = constructCreate2Salt();
batchLockup = new SablierV2BatchLockup{ salt: salt }();
}
}
19 changes: 11 additions & 8 deletions script/DeployDeterministicPeriphery.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ pragma solidity >=0.8.22 <0.9.0;

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

import { SablierV2Batch } from "../src/SablierV2Batch.sol";
import { SablierV2BatchLockup } from "../src/SablierV2BatchLockup.sol";
import { SablierV2MerkleLockupFactory } from "../src/SablierV2MerkleLockupFactory.sol";

/// @notice Deploys all V2 Periphery contracts at deterministic addresses across chains, in the following order:
///
/// 1. {SablierV2Batch}
/// 1. {SablierV2BatchLockup}
/// 2. {SablierV2MerkleLockupFactory}
///
/// @dev Reverts if any contract has already been deployed.
Expand All @@ -18,24 +18,27 @@ contract DeployDeterministicPeriphery is BaseScript {
public
virtual
broadcast
returns (SablierV2Batch batch, SablierV2MerkleLockupFactory merkleLockupFactory)
returns (SablierV2BatchLockup batchLockup, SablierV2MerkleLockupFactory merkleLockupFactory)
{
(batch, merkleLockupFactory) = _run();
(batchLockup, merkleLockupFactory) = _run();
}

/// @dev Deploy via Sphinx.
function runSphinx()
public
virtual
sphinx
returns (SablierV2Batch batch, SablierV2MerkleLockupFactory merkleLockupFactory)
returns (SablierV2BatchLockup batchLockup, SablierV2MerkleLockupFactory merkleLockupFactory)
{
(batch, merkleLockupFactory) = _run();
(batchLockup, merkleLockupFactory) = _run();
}

function _run() internal returns (SablierV2Batch batch, SablierV2MerkleLockupFactory merkleLockupFactory) {
function _run()
internal
returns (SablierV2BatchLockup batchLockup, SablierV2MerkleLockupFactory merkleLockupFactory)
{
bytes32 salt = constructCreate2Salt();
batch = new SablierV2Batch{ salt: salt }();
batchLockup = new SablierV2BatchLockup{ salt: salt }();
merkleLockupFactory = new SablierV2MerkleLockupFactory{ salt: salt }();
}
}
19 changes: 11 additions & 8 deletions script/DeployPeriphery.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,35 +4,38 @@ pragma solidity >=0.8.22 <0.9.0;
import { BaseScript } from "./Base.s.sol";

import { SablierV2MerkleLockupFactory } from "../src/SablierV2MerkleLockupFactory.sol";
import { SablierV2Batch } from "../src/SablierV2Batch.sol";
import { SablierV2BatchLockup } from "../src/SablierV2BatchLockup.sol";

/// @notice Deploys all V2 Periphery contract in the following order:
///
/// 1. {SablierV2Batch}
/// 1. {SablierV2BatchLockup}
/// 2. {SablierV2MerkleLockupFactory}
contract DeployPeriphery is BaseScript {
/// @dev Deploy via Forge.
function runBroadcast()
public
virtual
broadcast
returns (SablierV2Batch batch, SablierV2MerkleLockupFactory merkleLockupFactory)
returns (SablierV2BatchLockup batchLockup, SablierV2MerkleLockupFactory merkleLockupFactory)
{
(batch, merkleLockupFactory) = _run();
(batchLockup, merkleLockupFactory) = _run();
}

/// @dev Deploy via Sphinx.
function runSphinx()
public
virtual
sphinx
returns (SablierV2Batch batch, SablierV2MerkleLockupFactory merkleLockupFactory)
returns (SablierV2BatchLockup batchLockup, SablierV2MerkleLockupFactory merkleLockupFactory)
{
(batch, merkleLockupFactory) = _run();
(batchLockup, merkleLockupFactory) = _run();
}

function _run() internal returns (SablierV2Batch batch, SablierV2MerkleLockupFactory merkleLockupFactory) {
batch = new SablierV2Batch();
function _run()
internal
returns (SablierV2BatchLockup batchLockup, SablierV2MerkleLockupFactory merkleLockupFactory)
{
batchLockup = new SablierV2BatchLockup();
merkleLockupFactory = new SablierV2MerkleLockupFactory();
}
}
14 changes: 7 additions & 7 deletions script/DeployProtocol.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { SablierV2NFTDescriptor } from "@sablier/v2-core/src/SablierV2NFTDescrip
import { BaseScript } from "./Base.s.sol";

import { SablierV2MerkleLockupFactory } from "../src/SablierV2MerkleLockupFactory.sol";
import { SablierV2Batch } from "../src/SablierV2Batch.sol";
import { SablierV2BatchLockup } from "../src/SablierV2BatchLockup.sol";

/// @notice Deploys the Sablier V2 Protocol.
contract DeployProtocol is BaseScript {
Expand All @@ -26,11 +26,11 @@ contract DeployProtocol is BaseScript {
SablierV2LockupLinear lockupLinear,
SablierV2LockupTranched lockupTranched,
SablierV2NFTDescriptor nftDescriptor,
SablierV2Batch batch,
SablierV2BatchLockup batchLockup,
SablierV2MerkleLockupFactory merkleLockupFactory
)
{
(lockupDynamic, lockupLinear, lockupTranched, nftDescriptor, batch, merkleLockupFactory) =
(lockupDynamic, lockupLinear, lockupTranched, nftDescriptor, batchLockup, merkleLockupFactory) =
_run(initialAdmin, maxSegmentCount, maxTrancheCount);
}

Expand All @@ -48,11 +48,11 @@ contract DeployProtocol is BaseScript {
SablierV2LockupLinear lockupLinear,
SablierV2LockupTranched lockupTranched,
SablierV2NFTDescriptor nftDescriptor,
SablierV2Batch batch,
SablierV2BatchLockup batchLockup,
SablierV2MerkleLockupFactory merkleLockupFactory
)
{
(lockupDynamic, lockupLinear, lockupTranched, nftDescriptor, batch, merkleLockupFactory) =
(lockupDynamic, lockupLinear, lockupTranched, nftDescriptor, batchLockup, merkleLockupFactory) =
_run(initialAdmin, maxSegmentCount, maxTrancheCount);
}

Expand All @@ -67,7 +67,7 @@ contract DeployProtocol is BaseScript {
SablierV2LockupLinear lockupLinear,
SablierV2LockupTranched lockupTranched,
SablierV2NFTDescriptor nftDescriptor,
SablierV2Batch batch,
SablierV2BatchLockup batchLockup,
SablierV2MerkleLockupFactory merkleLockupFactory
)
{
Expand All @@ -78,7 +78,7 @@ contract DeployProtocol is BaseScript {
lockupTranched = new SablierV2LockupTranched(initialAdmin, nftDescriptor, maxTrancheCount);

// Deploy V2 Periphery.
batch = new SablierV2Batch();
batchLockup = new SablierV2BatchLockup();
merkleLockupFactory = new SablierV2MerkleLockupFactory();
}
}
4 changes: 2 additions & 2 deletions shell/prepare-artifacts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ mkdir $artifacts \
FOUNDRY_PROFILE=optimized forge build

# Copy the production artifacts
cp out-optimized/SablierV2Batch.sol/SablierV2Batch.json $artifacts
cp out-optimized/SablierV2BatchLockup.sol/SablierV2BatchLockup.json $artifacts
cp out-optimized/SablierV2MerkleLL.sol/SablierV2MerkleLL.json $artifacts
cp out-optimized/SablierV2MerkleLockupFactory.sol/SablierV2MerkleLockupFactory.json $artifacts
cp out-optimized/SablierV2MerkleLT.sol/SablierV2MerkleLT.json $artifacts

interfaces=./artifacts/interfaces
cp out-optimized/ISablierV2Batch.sol/ISablierV2Batch.json $interfaces
cp out-optimized/ISablierV2BatchLockup.sol/ISablierV2BatchLockup.json $interfaces
cp out-optimized/ISablierV2MerkleLL.sol/ISablierV2MerkleLL.json $interfaces
cp out-optimized/ISablierV2MerkleLockupFactory.sol/ISablierV2MerkleLockupFactory.json $interfaces
cp out-optimized/ISablierV2MerkleLT.sol/ISablierV2MerkleLT.json $interfaces
Expand Down
Loading

0 comments on commit 7c3ca60

Please sign in to comment.