Problem Statement
reward-pool::distribute_reward panics on amount <= 0. If a caller passes a too-large amount that exceeds the contract's balance, the token transfer reverts with token::Error. There's no defensive check, so a misconfigured caller could repeatedly hit the distribute_reward and incur transaction fees without the contract being able to fulfill. Also, REWARD_TOKEN_DECIMALS: u32 = 7 is declared but unused. There's no public getter for the token decimals, so off-chain callers can't pre-validate.
Why It Matters
- A misconfigured integration could trigger a denial-of-wallet pattern.
- Lack of fee/cost analysis means a maintenance burden.
Expected Outcome
- Add a
assert!(amount <= token.balance(contract), "Insufficient pool balance") check before transfer.
- Add a
token_decimals(env) -> u32 getter.
- Add a
pool_balance(env) -> i128 view function.
- Tests confirm the new getter and assertion.
Acceptance Criteria
- New getters work and emit no events.
- Insufficient-balance check prevents wasted fees.
Implementation Notes
- Tie
REWARD_TOKEN_DECIMALS to the network's actual USDC decimals (testnet=7, public=depends).
- Consider
assert_contract_balance_at_least(env, amount) helper.
Files / Modules Affected
contracts/reward-pool/src/lib.rs
contracts/reward-pool/src/test.rs
contracts/reward-pool/README.md
Dependencies
None.
Difficulty
Easy.
Estimated Effort
2 hours.
Suggested Labels
correctness, P2, reward-pool
Problem Statement
reward-pool::distribute_rewardpanics onamount <= 0. If a caller passes a too-large amount that exceeds the contract's balance, the token transfer reverts withtoken::Error. There's no defensive check, so a misconfigured caller could repeatedly hit thedistribute_rewardand incur transaction fees without the contract being able to fulfill. Also,REWARD_TOKEN_DECIMALS: u32 = 7is declared but unused. There's no public getter for the token decimals, so off-chain callers can't pre-validate.Why It Matters
Expected Outcome
assert!(amount <= token.balance(contract), "Insufficient pool balance")check before transfer.token_decimals(env) -> u32getter.pool_balance(env) -> i128view function.Acceptance Criteria
Implementation Notes
REWARD_TOKEN_DECIMALSto the network's actual USDC decimals (testnet=7, public=depends).assert_contract_balance_at_least(env, amount)helper.Files / Modules Affected
contracts/reward-pool/src/lib.rscontracts/reward-pool/src/test.rscontracts/reward-pool/README.mdDependencies
None.
Difficulty
Easy.
Estimated Effort
2 hours.
Suggested Labels
correctness,P2,reward-pool