Overview
lock_assets and stake only validate amount > 0. A user can stake 1 stroop (the minimum Stellar token unit) and create a storage entry with negligible economic value. Dust positions:
- Waste on-chain storage (each position costs ledger entry fees)
- Clutter off-chain indexer queries
- Enable griefing attacks where many accounts create 1-unit stakes to bloat factory pool records
Fix
Add a min_stake_amount parameter to initialize and enforce it in lock_assets and stake:
// types.rs — add to DataKey
MinStakeAmount,
// initialize signature change
pub fn initialize(
env: Env,
admin: Address,
stake_token: Address,
global_multiplier: u32,
credit_rate: i128,
min_lock_period: u32,
min_stake_amount: i128, // new parameter
) -> Result<(), PoolError>
// lock_assets and stake — add guard
let min = env.storage().instance()
.get::<DataKey, i128>(&DataKey::MinStakeAmount)
.unwrap_or(1);
if amount < min {
return Err(PoolError::BelowMinimumStake);
}
Add BelowMinimumStake = 14 to PoolError.
Also add an admin function to update the minimum:
pub fn set_min_stake_amount(env: Env, amount: i128) -> Result<(), PoolError>
Acceptance Criteria
Overview
lock_assetsandstakeonly validateamount > 0. A user can stake 1 stroop (the minimum Stellar token unit) and create a storage entry with negligible economic value. Dust positions:Fix
Add a
min_stake_amountparameter toinitializeand enforce it inlock_assetsandstake:Add
BelowMinimumStake = 14toPoolError.Also add an admin function to update the minimum:
Acceptance Criteria
min_stake_amountparameter added toinitializeDataKey::MinStakeAmountadded to storage schemalock_assetsandstakereject amounts below minimum withBelowMinimumStakeset_min_stake_amountadmin function addedget_min_stake_amountpublic getter added