📌 Description
collect_fees resets FeesAccrued to 0 and returns Error::NoFeesToCollect if the balance is already 0. There is no explicit regression test confirming the second consecutive collect_fees call for the same asset (immediately after a first successful collection, with no new settlements executed in between) correctly fails with Error::NoFeesToCollect rather than, say, returning 0 successfully or double-counting.
🧩 Requirements and context
- Add a regression test that executes a settlement to accrue fees, calls
collect_fees once successfully, then calls collect_fees again immediately for the same asset and asserts Error::NoFeesToCollect.
- Add a follow-up step: execute another settlement for the same asset after the first collection, and confirm a third
collect_fees call now succeeds and collects only the newly-accrued amount, not anything from before.
- Confirm
fees_collected events fire exactly once per successful collection, matching the accrued amount at that time.
🛠️ Suggested execution
- Add the test to
src/test.rs near existing collect_fees coverage.
- Assert both the
Result and the fees_accrued(asset) value after each step.
- No production code change expected — this closes a test-coverage gap on already-implemented behavior.
✅ Acceptance criteria
🔒 Security notes
Fee-collection double-counting or an incorrect success-on-empty result would misstate protocol revenue in an off-chain accounting reconciliation, a low-severity but real correctness concern for anything treating collect_fees's return value as ground truth.
📋 Guidelines
- Minimum 95% test coverage
- Clear documentation
- Timeframe: 96 hours
📌 Description
collect_feesresetsFeesAccruedto0and returnsError::NoFeesToCollectif the balance is already0. There is no explicit regression test confirming the second consecutivecollect_feescall for the same asset (immediately after a first successful collection, with no new settlements executed in between) correctly fails withError::NoFeesToCollectrather than, say, returning0successfully or double-counting.🧩 Requirements and context
collect_feesonce successfully, then callscollect_feesagain immediately for the same asset and assertsError::NoFeesToCollect.collect_feescall now succeeds and collects only the newly-accrued amount, not anything from before.fees_collectedevents fire exactly once per successful collection, matching the accrued amount at that time.🛠️ Suggested execution
src/test.rsnear existingcollect_feescoverage.Resultand thefees_accrued(asset)value after each step.✅ Acceptance criteria
collect_feescall with no new accrual fails withError::NoFeesToCollect.fees_collectedevents accurately reflect each successful collection's amount.🔒 Security notes
Fee-collection double-counting or an incorrect success-on-empty result would misstate protocol revenue in an off-chain accounting reconciliation, a low-severity but real correctness concern for anything treating
collect_fees's return value as ground truth.📋 Guidelines