Description
Accrual today uses bps math, accumulating rounding dust on each report. Switch the internal accrual index to e18 fixed-point and only collapse to integer on claim, eliminating cumulative dust within typical period counts.
Requirements and context
- Must be secure, tested, and documented
- Should be efficient and easy to review
- Relevant code:
Revora-Contracts/src/lib.rs, Revora-Contracts/src/payout_test.rs
- Conversion to/from e18 must use
checked_mul and checked_div consistently
Suggested execution
- Fork the repo and create a branch
git checkout -b feat/e18-accrual-fixed-point
- Implement changes
- Replace
acc_per_share_bps with acc_per_share_e18
- Update report_revenue index update and claim settlement
- Add invariant: collapsing all holders' e18 owed sums equals reported revenue
- Validate security and correctness assumptions
Test and commit
- Run tests
- Cover edge cases
- 10_000 sequential 1-unit reports must not accumulate >1 unit of dust per holder
- Include test output and security notes
Example commit message
feat: switch accrual to e18 fixed-point for tighter rounding
Guidelines
- Minimum 95 percent test coverage
- Clear documentation
- Timeframe: 96 hours
Description
Accrual today uses bps math, accumulating rounding dust on each report. Switch the internal accrual index to e18 fixed-point and only collapse to integer on claim, eliminating cumulative dust within typical period counts.
Requirements and context
Revora-Contracts/src/lib.rs,Revora-Contracts/src/payout_test.rschecked_mulandchecked_divconsistentlySuggested execution
git checkout -b feat/e18-accrual-fixed-pointacc_per_share_bpswithacc_per_share_e18Test and commit
cargo test --allExample commit message
feat: switch accrual to e18 fixed-point for tighter roundingGuidelines