Skip to main content

SablierMerkleFactory

Git Source

Inherits: ISablierMerkleFactory, Adminable

See the documentation in ISablierMerkleFactory.

State Variables

defaultFee

Retrieves the default fee charged for claiming an airdrop.

The fee is denominated in the native token of the chain, e.g., ETH for Ethereum Mainnet.

uint256 public override defaultFee;

_customFees

A mapping of custom fees mapped by campaign creator addresses.

mapping(address campaignCreator => MerkleFactory.CustomFee customFee) private _customFees;

Functions

constructor

constructor(address initialAdmin) Adminable(initialAdmin);

Parameters

NameTypeDescription
initialAdminaddressThe address of the initial contract admin.

getCustomFee

Retrieves the custom fee struct for the provided campaign creator.

The fee is denominated in the native token of the chain, e.g., ETH for Ethereum Mainnet.

function getCustomFee(address campaignCreator) external view override returns (MerkleFactory.CustomFee memory);

Parameters

NameTypeDescription
campaignCreatoraddressThe address of the campaign creator.

getFee

Retrieves the fee for the provided campaign creator, using the default fee if no custom fee is set.

The fee is denominated in the native token of the chain, e.g., ETH for Ethereum Mainnet.

function getFee(address campaignCreator) external view returns (uint256);

Parameters

NameTypeDescription
campaignCreatoraddressThe address of the campaign creator.

isPercentagesSum100

Verifies if the sum of percentages in tranches equals 100%, i.e., 1e18.

This is a helper function for the frontend. It is not used anywhere in the contracts.

function isPercentagesSum100(MerkleLT.TrancheWithPercentage[] calldata tranches)
external
pure
override
returns (bool result);

Parameters

NameTypeDescription
tranchesMerkleLT.TrancheWithPercentage[]The tranches with their respective unlock percentages.

Returns

NameTypeDescription
resultboolTrue if the sum of percentages equals 100%, otherwise false.

collectFees

Collects the fees accrued in the merkleBase contract, and transfers them to the factory admin.

Emits a {CollectFees} event. Notes:

  • If the admin is a contract, it must be able to receive native token payments, e.g., ETH for Ethereum Mainnet.
function collectFees(ISablierMerkleBase merkleBase) external override;

Parameters

NameTypeDescription
merkleBaseISablierMerkleBaseThe address of the Merkle contract where the fees are collected from.

createMerkleInstant

Creates a new MerkleInstant campaign for instant distribution of tokens.

Emits a {CreateMerkleInstant} event. Notes:

  • The MerkleInstant contract is created with CREATE2.
  • The immutable fee will be set to the default value unless a custom fee is set.
function createMerkleInstant(
MerkleBase.ConstructorParams memory baseParams,
uint256 aggregateAmount,
uint256 recipientCount
)
external
override
returns (ISablierMerkleInstant merkleInstant);

Parameters

NameTypeDescription
baseParamsMerkleBase.ConstructorParamsStruct encapsulating the SablierMerkleBase parameters, which are documented in {DataTypes}.
aggregateAmountuint256The total amount of ERC-20 tokens to be distributed to all recipients.
recipientCountuint256The total number of recipients who are eligible to claim.

Returns

NameTypeDescription
merkleInstantISablierMerkleInstantThe address of the newly created MerkleInstant contract.

createMerkleLL

Creates a new Merkle Lockup campaign with a Lockup Linear distribution.

Emits a {CreateMerkleLL} event. Notes:

  • The MerkleLL contract is created with CREATE2.
  • The immutable fee will be set to the default value unless a custom fee is set.
function createMerkleLL(
MerkleBase.ConstructorParams memory baseParams,
ISablierLockup lockup,
bool cancelable,
bool transferable,
MerkleLL.Schedule memory schedule,
uint256 aggregateAmount,
uint256 recipientCount
)
external
override
returns (ISablierMerkleLL merkleLL);

Parameters

NameTypeDescription
baseParamsMerkleBase.ConstructorParamsStruct encapsulating the SablierMerkleBase parameters, which are documented in {DataTypes}.
lockupISablierLockupThe address of the SablierLockup contract.
cancelableboolIndicates if the stream will be cancelable after claiming.
transferableboolIndicates if the stream will be transferable after claiming.
scheduleMerkleLL.ScheduleStruct encapsulating the unlocks schedule, which are documented in {DataTypes}.
aggregateAmountuint256The total amount of ERC-20 tokens to be distributed to all recipients.
recipientCountuint256The total number of recipients who are eligible to claim.

Returns

NameTypeDescription
merkleLLISablierMerkleLLThe address of the newly created Merkle Lockup contract.

createMerkleLT

Creates a new Merkle Lockup campaign with a Lockup Tranched distribution.

Emits a {CreateMerkleLT} event. Notes:

  • The MerkleLT contract is created with CREATE2.
  • The immutable fee will be set to the default value unless a custom fee is set.
function createMerkleLT(
MerkleBase.ConstructorParams memory baseParams,
ISablierLockup lockup,
bool cancelable,
bool transferable,
uint40 streamStartTime,
MerkleLT.TrancheWithPercentage[] memory tranchesWithPercentages,
uint256 aggregateAmount,
uint256 recipientCount
)
external
override
returns (ISablierMerkleLT merkleLT);

Parameters

NameTypeDescription
baseParamsMerkleBase.ConstructorParamsStruct encapsulating the SablierMerkleBase parameters, which are documented in {DataTypes}.
lockupISablierLockupThe address of the SablierLockup contract.
cancelableboolIndicates if the stream will be cancelable after claiming.
transferableboolIndicates if the stream will be transferable after claiming.
streamStartTimeuint40The start time of the streams created through {SablierMerkleBase.claim}.
tranchesWithPercentagesMerkleLT.TrancheWithPercentage[]The tranches with their respective unlock percentages.
aggregateAmountuint256The total amount of ERC-20 tokens to be distributed to all recipients.
recipientCountuint256The total number of recipients who are eligible to claim.

Returns

NameTypeDescription
merkleLTISablierMerkleLTThe address of the newly created Merkle Lockup contract.

resetCustomFee

Resets the custom fee for the provided campaign creator to the default fee.

Emits a {ResetCustomFee} event. Notes:

  • The default fee will only be applied to future campaigns. Requirements:
  • msg.sender must be the admin.
function resetCustomFee(address campaignCreator) external override onlyAdmin;

Parameters

NameTypeDescription
campaignCreatoraddressThe user for whom the fee is reset for.

setCustomFee

Sets a custom fee for the provided campaign creator.

Emits a {SetCustomFee} event. Notes:

  • The new fee will only be applied to future campaigns. Requirements:
  • msg.sender must be the admin.
function setCustomFee(address campaignCreator, uint256 newFee) external override onlyAdmin;

Parameters

NameTypeDescription
campaignCreatoraddressThe user for whom the fee is set.
newFeeuint256The new fee to be set.

setDefaultFee

Sets the default fee to be applied when claiming airdrops.

Emits a {SetDefaultFee} event. Notes:

  • The new default fee will only be applied to the future campaigns and will not affect the ones already deployed. Requirements:
  • msg.sender must be the admin.
function setDefaultFee(uint256 defaultFee_) external override onlyAdmin;

Parameters

NameTypeDescription
defaultFee_uint256

_getFee

Retrieves the fee for the provided campaign creator, using the default fee if no custom fee is set.

function _getFee(address campaignCreator) private view returns (uint256);

_deployMerkleLT

Deploys a new MerkleLT contract with CREATE2.

We need a separate function to prevent the stack too deep error.

function _deployMerkleLT(
MerkleBase.ConstructorParams memory baseParams,
ISablierLockup lockup,
bool cancelable,
bool transferable,
uint40 streamStartTime,
MerkleLT.TrancheWithPercentage[] memory tranchesWithPercentages
)
private
returns (ISablierMerkleLT merkleLT);