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
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_assetsandstaketo pre-approved addresses.Design
Whitelist is opt-in — pools without a whitelist behave exactly as today (open access).
Guard in stake and lock_assets
Add
NotWhitelisted = 15toPoolError.Batch Whitelist
For large airdrops, add a batch function:
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
WhitelistEnabledandWhitelisted(Address)keys added toDataKeystakeandlock_assetscheck whitelist when enabledbatch_add_to_whitelistcapped at 50 addressesNotWhitelistederror variant inPoolError