Staking ProtocoleligibilityFacetsstakersEligibilitywhitelistedStakers

WhitelistedStakersFacetStorage

This library manages the storage and logic for applying role-based participation eligibility configurations for staking campaigns. It also handles eligibility checks during user interactions with these campaigns.

This implementation is designed to configure multiple eligible roles for any staking campaign.

CampaignNotOnCreationStateForSetting

error CampaignNotOnCreationStateForSetting(uint256 campaignId)

Thrown when a targeted campaign is not "On Creation" state, which is required at configurations.

StakerEligibleRolesAbsent

error StakerEligibleRolesAbsent(uint256 campaignId)

Thrown when trying to set eligibility without specifying eligible roles for campaign's stakers.

NotEligibleForCampaignParticipation

error NotEligibleForCampaignParticipation(uint256 campaignId, address ineligibleAccount)

Thrown when an account without the required role attempts to participate on a staking campaign.

STORAGE_SLOT

bytes32 STORAGE_SLOT

Unique identifier for the storage slot where the Layout struct is stored.

Layout

Struct for managing participation eligibility configuration details for staking campaigns.

struct Layout {
  mapping(uint256 => bytes32[]) eligibleRolesPerCampaign;
  mapping(uint256 => bool) isCampaignScoped;
}

layout

function layout() internal pure returns (struct WhitelistedStakersFacetStorage.Layout l)

Retrieves a reference to the Layout struct stored at the slot specified by STORAGE_SLOT unique identifier.

setCampaignStakersEligibility

function setCampaignStakersEligibility(struct WhitelistedStakersFacetStorage.Layout l, uint256 campaignId, bytes campaignStakersEligibilityData) internal returns (bytes32[], bool)

Setter function for configuring role-based eligibility criteria for participation in the specified staking campaign.

_Setter functions are executed during the creation process of campaigns (see CampaignCreationSkeleton.sol).


NOTE:

  • If isCampaignScoped == false, any user will be able to participate in the specified campaign, provided they are granted a role contained within the ABI-encoded eligibleRoles array via grantRole() or grantRoleMultiple(). Thus checks for eligible roles will be performed platform-wide.

  • If isCampaignScoped == true, any user will be able to participate in the specified campaign, provided they are granted a role contained within the ABI-encoded eligibleRoles array via grantRoleForId() or grantRoleMultipleForId() for the specified campaignId. Thus checks for eligible roles will be performed campaign-wide.

  • See AccessControlStakingFacet.sol for information about role-based access control. ----------------------------------------------------------------------------------------------------------------_

Parameters

NameTypeDescription
lstruct WhitelistedStakersFacetStorage.LayoutA reference to the Layout struct in storage.
campaignIduint256The unique identifier of the targeted staking campaign.
campaignStakersEligibilityDatabytesThe ABI-encoded data containing the following: - eligibleRoles: A bytes32 array with the roles eligible for participating in the campaign. - isCampaignScoped: A boolean flag indicating whether eligibleRoles should be campaign-wide specific (true) or platform-wide specific (false).

checkStakersEligibility

function checkStakersEligibility(struct WhitelistedStakersFacetStorage.Layout l, uint256 campaignId, address account) internal view

Checks whether the specified account is eligible to participate in the given campaign.

_Reverts if account is not eligible to participate in the campaign.

IMPORTANT: Depending on the configuration for campaignId, eligibility checks will be performed either platform-wide or campaign-wide (see setCampaignStakersEligibility())._

Parameters

NameTypeDescription
lstruct WhitelistedStakersFacetStorage.LayoutA reference to the Layout struct in storage.
campaignIduint256The unique identifier of the targeted staking campaign.
accountaddressThe address of the account to check.

On this page