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

feat: sablier fee on Airstreams claim #1038

Merged
merged 21 commits into from
Oct 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
c010a67
feat: receive ether in claim function
smol-ninja Sep 9, 2024
357e720
test: msg.value in claim function
smol-ninja Sep 9, 2024
d90bd2c
test: fix claim in fork tests
smol-ninja Sep 9, 2024
0f2985a
refactor: remove redundant receive function
smol-ninja Sep 9, 2024
d135b8b
test: withdrawFees in Factory and MerkleBase
smol-ninja Sep 10, 2024
6eefaf9
refactor: include merkleLockup address in WithdrawSablierFees event
smol-ninja Sep 10, 2024
3135886
test: withdraw-fees in fork tests
smol-ninja Sep 10, 2024
90ca9d0
chore: add BUSL license to factory contract
smol-ninja Sep 10, 2024
394cf27
refactor: rename sablierFee to defaultSablierFee in factory
smol-ninja Sep 11, 2024
a582341
feat: custom sablier fee
smol-ninja Sep 11, 2024
d019b8d
test(refactor): add a new user: campaignOwner in User struct
smol-ninja Sep 11, 2024
6ec1142
test: custom sablier fee for users
smol-ninja Sep 11, 2024
bc77b3c
style: fix import
smol-ninja Sep 11, 2024
2538668
style: lint code
smol-ninja Oct 11, 2024
9524069
refactor: add constructor to Adminable contract
smol-ninja Oct 12, 2024
155401c
docs: replace caller with msg.sender
smol-ninja Oct 16, 2024
cf0990e
small polishes
andreivladbrg Oct 23, 2024
ce35add
test: dry'ify vm.expectCall
smol-ninja Oct 24, 2024
37c7caf
feat: emit sablierFee in CreateMerkle events
smol-ninja Oct 24, 2024
72af0c3
test: move periphery related helpers to Periphery base contract
smol-ninja Oct 24, 2024
5b24e38
docs: remove redundant comment from constructors
smol-ninja Oct 24, 2024
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
2 changes: 1 addition & 1 deletion .lintstagedrc.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"*.{json,md,svg,yml}": "prettier --write"
"*.sol":
- "bun solhint --fix --noPrompt"
- "bun solhint {benchmark,precompiles,script,src,test}/**/*.sol --fix --noPrompt"
- "forge fmt"
21 changes: 10 additions & 11 deletions precompiles/Precompiles.sol
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,7 @@ contract Precompiles {
}

/// @notice Deploys all Core contracts.
function deployCore(
address initialAdmin
)
function deployCore(address initialAdmin)
public
returns (
ILockupNFTDescriptor nftDescriptor,
Expand Down Expand Up @@ -213,8 +211,8 @@ contract Precompiles {
}

/// @notice Deploys {SablierMerkleFactory} from precompiled bytecode.
function deployMerkleFactory() public returns (ISablierMerkleFactory factory) {
bytes memory creationBytecode = BYTECODE_MERKLE_FACTORY;
function deployMerkleFactory(address initialAdmin) public returns (ISablierMerkleFactory factory) {
bytes memory creationBytecode = bytes.concat(BYTECODE_MERKLE_FACTORY, abi.encode(initialAdmin));
assembly {
factory := create(0, add(creationBytecode, 0x20), mload(creationBytecode))
}
Expand All @@ -225,9 +223,12 @@ contract Precompiles {
///
/// 1. {SablierBatchLockup}
/// 2. {SablierMerkleFactory}
function deployPeriphery() public returns (ISablierBatchLockup batchLockup, ISablierMerkleFactory merkleFactory) {
function deployPeriphery(address initialAdmin)
public
returns (ISablierBatchLockup batchLockup, ISablierMerkleFactory merkleFactory)
{
batchLockup = deployBatchLockup();
merkleFactory = deployMerkleFactory();
merkleFactory = deployMerkleFactory(initialAdmin);
}

/// @notice Deploys the entire Lockup Protocol from precompiled bytecode.
Expand All @@ -238,9 +239,7 @@ contract Precompiles {
/// 4. {SablierLockupTranched}
/// 5. {SablierBatchLockup}
/// 6. {SablierMerkleFactory}
function deployProtocol(
address initialAdmin
)
function deployProtocol(address initialAdmin)
public
returns (
ILockupNFTDescriptor nftDescriptor,
Expand All @@ -255,6 +254,6 @@ contract Precompiles {
(nftDescriptor, lockupDynamic, lockupLinear, lockupTranched) = deployCore(initialAdmin);

// Deploy Periphery.
(batchLockup, merkleFactory) = deployPeriphery();
(batchLockup, merkleFactory) = deployPeriphery(initialAdmin);
}
}
4 changes: 2 additions & 2 deletions script/periphery/DeployDeterministicPeriphery.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ import { BaseScript } from "../Base.s.sol";
/// @dev Reverts if any contract has already been deployed.
contract DeployDeterministicPeriphery is BaseScript {
/// @dev Deploy via Forge.
function run()
function run(address initialAdmin)
public
virtual
broadcast
returns (SablierBatchLockup batchLockup, SablierMerkleFactory merkleFactory)
{
bytes32 salt = constructCreate2Salt();
batchLockup = new SablierBatchLockup{ salt: salt }();
merkleFactory = new SablierMerkleFactory{ salt: salt }();
merkleFactory = new SablierMerkleFactory{ salt: salt }(initialAdmin);
}
}
4 changes: 2 additions & 2 deletions script/periphery/DeployMerkleFactory.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { BaseScript } from "../Base.s.sol";

contract DeployMerkleFactory is BaseScript {
/// @dev Deploy via Forge.
function run() public virtual broadcast returns (SablierMerkleFactory merkleFactory) {
merkleFactory = new SablierMerkleFactory();
function run(address initialAdmin) public virtual broadcast returns (SablierMerkleFactory merkleFactory) {
merkleFactory = new SablierMerkleFactory(initialAdmin);
}
}
4 changes: 2 additions & 2 deletions script/periphery/DeployPeriphery.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ import { BaseScript } from "./../Base.s.sol";
/// 2. {SablierMerkleFactory}
contract DeployPeriphery is BaseScript {
/// @dev Deploy via Forge.
function run()
function run(address initialAdmin)
public
virtual
broadcast
returns (SablierBatchLockup batchLockup, SablierMerkleFactory merkleFactory)
{
batchLockup = new SablierBatchLockup();
merkleFactory = new SablierMerkleFactory();
merkleFactory = new SablierMerkleFactory(initialAdmin);
}
}
4 changes: 2 additions & 2 deletions script/protocol/DeployDeterministicProtocol.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import { LockupNFTDescriptor } from "../../src/core/LockupNFTDescriptor.sol";
import { SablierLockupDynamic } from "../../src/core/SablierLockupDynamic.sol";
import { SablierLockupLinear } from "../../src/core/SablierLockupLinear.sol";
import { SablierLockupTranched } from "../../src/core/SablierLockupTranched.sol";
import { SablierMerkleFactory } from "../../src/periphery/SablierMerkleFactory.sol";
import { SablierBatchLockup } from "../../src/periphery/SablierBatchLockup.sol";
import { SablierMerkleFactory } from "../../src/periphery/SablierMerkleFactory.sol";

import { DeploymentLogger } from "./DeploymentLogger.s.sol";

Expand Down Expand Up @@ -72,7 +72,7 @@ contract DeployDeterministicProtocol is DeploymentLogger("deterministic") {

// Deploy Periphery.
batchLockup = new SablierBatchLockup{ salt: salt }();
merkleLockupFactory = new SablierMerkleFactory{ salt: salt }();
merkleLockupFactory = new SablierMerkleFactory{ salt: salt }(initialAdmin);

appendToFileDeployedAddresses(
address(lockupDynamic),
Expand Down
4 changes: 2 additions & 2 deletions script/protocol/DeployProtocol.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import { LockupNFTDescriptor } from "../../src/core/LockupNFTDescriptor.sol";
import { SablierLockupDynamic } from "../../src/core/SablierLockupDynamic.sol";
import { SablierLockupLinear } from "../../src/core/SablierLockupLinear.sol";
import { SablierLockupTranched } from "../../src/core/SablierLockupTranched.sol";
import { SablierMerkleFactory } from "../../src/periphery/SablierMerkleFactory.sol";
import { SablierBatchLockup } from "../../src/periphery/SablierBatchLockup.sol";
import { SablierMerkleFactory } from "../../src/periphery/SablierMerkleFactory.sol";

import { DeploymentLogger } from "./DeploymentLogger.s.sol";

Expand Down Expand Up @@ -65,7 +65,7 @@ contract DeployProtocol is DeploymentLogger("non_deterministic") {
lockupLinear = new SablierLockupLinear(initialAdmin, nftDescriptor);
lockupTranched = new SablierLockupTranched(initialAdmin, nftDescriptor, trancheCountMap[block.chainid]);
batchLockup = new SablierBatchLockup();
merkleLockupFactory = new SablierMerkleFactory();
merkleLockupFactory = new SablierMerkleFactory(initialAdmin);

appendToFileDeployedAddresses(
address(lockupDynamic),
Expand Down
1 change: 0 additions & 1 deletion script/protocol/DeploymentLogger.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
pragma solidity >=0.8.22 <0.9.0;

import { Strings } from "@openzeppelin/contracts/utils/Strings.sol";
import { stdJson } from "forge-std/src/StdJson.sol";

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

Expand Down
1 change: 0 additions & 1 deletion src/core/SablierLockupDynamic.sol
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ contract SablierLockupDynamic is
CONSTRUCTOR
//////////////////////////////////////////////////////////////////////////*/

/// @dev Emits a {TransferAdmin} event.
/// @param initialAdmin The address of the initial contract admin.
/// @param initialNFTDescriptor The address of the NFT descriptor contract.
/// @param maxSegmentCount The maximum number of segments allowed in a stream.
Expand Down
1 change: 0 additions & 1 deletion src/core/SablierLockupLinear.sol
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ contract SablierLockupLinear is
CONSTRUCTOR
//////////////////////////////////////////////////////////////////////////*/

/// @dev Emits a {TransferAdmin} event.
/// @param initialAdmin The address of the initial contract admin.
/// @param initialNFTDescriptor The address of the initial NFT descriptor.
constructor(
Expand Down
1 change: 0 additions & 1 deletion src/core/SablierLockupTranched.sol
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ contract SablierLockupTranched is
CONSTRUCTOR
//////////////////////////////////////////////////////////////////////////*/

/// @dev Emits a {TransferAdmin} event.
/// @param initialAdmin The address of the initial contract admin.
/// @param initialNFTDescriptor The address of the NFT descriptor contract.
/// @param maxTrancheCount The maximum number of tranches allowed in a stream.
Expand Down
11 changes: 11 additions & 0 deletions src/core/abstracts/Adminable.sol
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,17 @@ abstract contract Adminable is IAdminable {
_;
}

/*//////////////////////////////////////////////////////////////////////////
CONSTRUCTOR
//////////////////////////////////////////////////////////////////////////*/

/// @dev Emits a {TransferAdmin} event.
/// @param initialAdmin The address of the initial admin.
constructor(address initialAdmin) {
admin = initialAdmin;
emit TransferAdmin({ oldAdmin: address(0), newAdmin: initialAdmin });
}

/*//////////////////////////////////////////////////////////////////////////
USER-FACING NON-CONSTANT FUNCTIONS
//////////////////////////////////////////////////////////////////////////*/
Expand Down
5 changes: 1 addition & 4 deletions src/core/abstracts/SablierLockup.sol
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,10 @@ abstract contract SablierLockup is
CONSTRUCTOR
//////////////////////////////////////////////////////////////////////////*/

/// @dev Emits a {TransferAdmin} event.
/// @param initialAdmin The address of the initial contract admin.
smol-ninja marked this conversation as resolved.
Show resolved Hide resolved
/// @param initialNFTDescriptor The address of the initial NFT descriptor.
constructor(address initialAdmin, ILockupNFTDescriptor initialNFTDescriptor) {
admin = initialAdmin;
constructor(address initialAdmin, ILockupNFTDescriptor initialNFTDescriptor) Adminable(initialAdmin) {
nftDescriptor = initialNFTDescriptor;
emit TransferAdmin({ oldAdmin: address(0), newAdmin: initialAdmin });
}

/*//////////////////////////////////////////////////////////////////////////
Expand Down
Loading
Loading