🔴 Priority: Critical
Difficulty: Hard
Estimated Effort: 3-4 days
Relevant Files: contracts/src/lib.rs, contracts/src/test.rs
Labels: enhancement, priority:critical, logic
Requirements
-
Remove Member Function
- Implement
pub fn remove_member(env: Env, member_to_remove: Address)
- Only the
Admin can call this function.
- It must remove the member from the
DataKey::Members vector.
-
Refund Logic
- If the member is removed mid-cycle (i.e., they have
HasContributedThisCycle == true but HasReceivedPayout == false), the contract must refund their current cycle contribution.
- Check if the member has contributed this cycle.
- If yes, read
ContributionAmount and execute a token_client.transfer() sending the amount back to member_to_remove.
- Clear
HasContributedThisCycle(member) and HasReceivedPayout(member) from persistent storage to free up ledger space.
-
Cycle State Integrity
- If a member is removed while a cycle is active (i.e.,
CycleMemberCount exists), the CycleMemberCount must be decremented by 1.
- This ensures that the next
payout() calculation (contribution_amount * cycle_member_count) remains mathematically correct for the reduced pool size.
- If the removal drops the member count to 0, clear
CycleMemberCount.
-
Constraints
- A member cannot be removed if they have already received a payout in the current cycle (this would mean they take the money and leave others at a loss).
- Panic with "Cannot remove member after payout" if
HasReceivedPayout == true.
-
Testing
- Unit test: Admin successfully removes a member who hasn't contributed yet.
- Unit test: Admin removes a member who has contributed, verify the refund is processed.
- Unit test: Admin attempts to remove a member who has received a payout (must panic).
- Unit test: Verify
CycleMemberCount adjusts correctly and subsequent payouts calculate the correct pool size.
- Target: >90% coverage on removal logic.
🔴 Priority: Critical
Difficulty: Hard
Estimated Effort: 3-4 days
Relevant Files:
contracts/src/lib.rs,contracts/src/test.rsLabels:
enhancement,priority:critical,logicRequirements
Remove Member Function
pub fn remove_member(env: Env, member_to_remove: Address)Admincan call this function.DataKey::Membersvector.Refund Logic
HasContributedThisCycle == truebutHasReceivedPayout == false), the contract must refund their current cycle contribution.ContributionAmountand execute atoken_client.transfer()sending the amount back tomember_to_remove.HasContributedThisCycle(member)andHasReceivedPayout(member)from persistent storage to free up ledger space.Cycle State Integrity
CycleMemberCountexists), theCycleMemberCountmust be decremented by 1.payout()calculation (contribution_amount * cycle_member_count) remains mathematically correct for the reduced pool size.CycleMemberCount.Constraints
HasReceivedPayout == true.Testing
CycleMemberCountadjusts correctly and subsequent payouts calculate the correct pool size.