Skip to Content
EvmContract ReferenceISLAYRewardsV2

ISLAYRewardsV2

Interface for the SLAYRewardsV2 contract, which handles the distribution and claiming of rewards. In this context, a provider is an actor that distribute rewards (think rewards provider). This can be a service an operator, or any other entity that wants to distribute rewards.

Functions

getDistributionRoots

Returns the current and previous Merkle roots for a (provider,token) pair.

function getDistributionRoots(address provider, address token) external view returns (DistributionRoots memory);

Parameters

NameTypeDescription
provideraddressThe address of the provider (e.g. service or operator).
tokenaddressThe address of the token.

Returns

NameTypeDescription
<none>DistributionRootsDistributionRoots containing the previous and current Merkle roots.

getBalance

Returns the balance of a provider for a specific token.

function getBalance(address provider, address token) external view returns (uint256);

Parameters

NameTypeDescription
provideraddressThe address of the provider (e.g. service or operator).
tokenaddressThe address of the token.

Returns

NameTypeDescription
<none>uint256The balance of the provider for the specified token.

getClaimedRewards

Returns the total claimed rewards for a specific provider, token, and earner.

function getClaimedRewards(address provider, address token, address earner) external view returns (uint256);

Parameters

NameTypeDescription
provideraddressThe address of the provider (e.g. service or operator).
tokenaddressThe address of the token.
earneraddressThe address of the earner.

Returns

NameTypeDescription
<none>uint256The total amount of claimed rewards for the specified provider, token, and earner.

distributeRewards

Distributes rewards from a provider (service or operator) to earners using a Merkle tree. Although rewards are usually distributed by service or operator, anybody can distribute rewards. This is not limited to the service/operator itself to allow for flexibility in reward distribution.

Service needs to ensure proper allowance is made for the contract to transfer tokens. When the {amount} is 0, the function will essentially only update the Merkle root without any token transfer. This allows for patching of existing distributions.

function distributeRewards(address token, uint256 amount, bytes32 merkleRoot) external;

Parameters

NameTypeDescription
tokenaddressThe address of the token to distribute.
amountuint256The amount of tokens to distribute.
merkleRootbytes32The Merkle root of the distribution.

claimRewards

Claims rewards for an earner for a specific provider and token using merkle proof.

The function checks the Merkle proof, updates the claimed rewards and send the tokens to the recipient.

function claimRewards(ClaimableRewardProof calldata params) external;

Parameters

NameTypeDescription
paramsClaimableRewardProofThe parameters containing provider, token, amount, recipient, merkleRoot, proof, leafIndex, and totalLeaves.

Events

RewardsDistributed

Emitted when rewards are distributed by provider.

event RewardsDistributed(address indexed provider, address indexed token, uint256 amount, bytes32 indexed merkleRoot);

Parameters

NameTypeDescription
provideraddressThe address of the provider (service or operator) distributing rewards.
tokenaddressThe address of the token being distributed.
amountuint256The total amount of tokens distributed.
merkleRootbytes32The Merkle root of the distribution.

RewardsClaimed

Emitted when rewards are claimed by an earner.

event RewardsClaimed( address indexed provider, address indexed token, address indexed earner, address recipient, uint256 amount, bytes32 merkleRoot );

Parameters

NameTypeDescription
provideraddressThe address of the provider from which rewards are claimed.
tokenaddressThe address of the token being claimed.
earneraddressThe address of the earner claiming rewards.
recipientaddressThe address receiving the claimed rewards.
amountuint256The amount of tokens claimed.
merkleRootbytes32The Merkle root of the distribution from which the claim is made.

Errors

InvalidMerkleRoot

Error thrown when an invalid Merkle root is provided for a provider and token pair.

error InvalidMerkleRoot(address provider, address token, bytes32 merkleRoot);

AmountAlreadyClaimed

Error thrown when an earner attempts to claim an amount that has already been claimed.

error AmountAlreadyClaimed(address provider, address token, address earner, uint256 amount);

InvalidMerkleProof

Error thrown when an invalid Merkle proof is provided during reward claiming.

error InvalidMerkleProof();

InsufficientBalance

Error thrown when a provider has insufficient balance for a token to distribute rewards.

error InsufficientBalance(address provider, address token);

Structs

ClaimableRewardProof

Contains all the necessary information to verify and process a reward claim. This struct is used as an input parameter for the claimRewards function.

struct ClaimableRewardProof { address provider; address token; uint256 amount; address recipient; bytes32 merkleRoot; bytes32[] proof; uint32 leafIndex; uint32 totalLeaves; }

DistributionRoots

Stores the previous and current Merkle roots for a provider-token pair. This allows for a transition period where claims can be made against either root.

struct DistributionRoots { bytes32 prevRoot; bytes32 currentRoot; }
Last updated on