Skip to main content

SablierV2MerkleStreamer

Git Source

Inherits: ISablierV2MerkleStreamer Adminable

State Variables

ASSET

The streamed ERC-20 asset.

IERC20 public immutable override ASSET;

CANCELABLE

A flag indicating whether the streams can be canceled.

bool public immutable override CANCELABLE;

EXPIRATION

The cut-off point for the Merkle streamer, as a Unix timestamp. A value of zero means there is no expiration.

uint40 public immutable override EXPIRATION;

LOCKUP

The address of the {SablierV2Lockup} contract.

ISablierV2Lockup public immutable override LOCKUP;

MERKLE_ROOT

The root of the Merkle tree used to validate the claims.

bytes32 public immutable override MERKLE_ROOT;

TRANSFERABLE

A flag indicating whether the stream NFTs are transferable.

bool public immutable override TRANSFERABLE;

_claimedBitMap;

Packed booleans that record the history of claims.

BitMaps.BitMap internal _claimedBitMap;

We are using BitMaps OpenZeppelin's library.

User Facing Functions

constructor

Sets the immutable state variables.

constructor(
address initialAdmin,
IERC20 asset,
ISablierV2Lockup lockup,
bytes32 merkleRoot,
uint40 expiration,
bool cancelable,
bool transferable
);

hasClaimed

Returns a flag indicating whether a claim has been made for a given index. Uses a bitmap to save gas.

function hasClaimed(uint256 index) external returns (bool);

Parameters

NameTypeDescription
indexuint256The index of the recipient to check.

hasExpired

Returns a flag indicating whether the Merkle streamer has expired.

function hasExpired() external returns (bool);

clawback

Claws back the unclaimed tokens from the Merkle streamer.

Emits a {Clawback} event. Requirements:

  • msg.sender must be the contract admin.
  • The Merkle streamer must have expired.
function clawback(address to, uint128 amount) external;

Parameters

NameTypeDescription
toaddressThe address to receive the tokens.
amountuint128The amount of tokens to claw back.

Internal Functions

Validates the parameters of the claim function, which is implemented by child contracts.

function _checkClaim(uint256 index, bytes32 leaf, bytes32[] calldata merkleProof) internal view;