Skip to content

Add whitelist/allowlist mode to farming-pool for permissioned staking #38

Description

@prodbycorne

Overview

Some token issuers and airdrop programs require KYC or invite-only access. The farming-pool currently accepts stakes from any address. A whitelist mode would allow the admin to restrict lock_assets and stake to pre-approved addresses.

Design

Whitelist is opt-in — pools without a whitelist behave exactly as today (open access).

// DataKey additions
WhitelistEnabled,
Whitelisted(Address),
// Admin functions
pub fn enable_whitelist(env: Env) -> Result<(), PoolError>    // admin-only
pub fn disable_whitelist(env: Env) -> Result<(), PoolError>   // admin-only
pub fn add_to_whitelist(env: Env, user: Address) -> Result<(), PoolError>
pub fn remove_from_whitelist(env: Env, user: Address) -> Result<(), PoolError>
pub fn is_whitelisted(env: Env, user: Address) -> bool

Guard in stake and lock_assets

if whitelist_enabled(&env) && !is_user_whitelisted(&env, &user) {
    return Err(PoolError::NotWhitelisted);
}

Add NotWhitelisted = 15 to PoolError.

Batch Whitelist

For large airdrops, add a batch function:

pub fn batch_add_to_whitelist(env: Env, users: Vec<Address>) -> Result<(), PoolError>

Cap at 50 addresses per call to stay within Soroban instruction limits.

Storage Considerations

Whitelisted addresses are stored in persistent storage with TTL bumps. The TTL for whitelist entries should match user stake TTL so they do not expire while the user has active positions.

Acceptance Criteria

  • WhitelistEnabled and Whitelisted(Address) keys added to DataKey
  • All 5 admin whitelist functions implemented
  • stake and lock_assets check whitelist when enabled
  • Whitelist disabled by default (no behavior change on existing pools)
  • batch_add_to_whitelist capped at 50 addresses
  • NotWhitelisted error variant in PoolError
  • Tests: open pool, whitelist-enabled pool, user added and removed

Metadata

Metadata

Assignees

Labels

GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardOfficial CampaignCampaign: Official Campaignfarming-poolFarmingPool contractfeatureNew feature or capability

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions