Fix/q96 decoding precision [WIP don't merge]#72
Conversation
📝 WalkthroughWalkthroughProtocol price and maker tick bounds are widened to approximately ChangesProtocol bounds and maker validation
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/convert.rs (1)
182-194: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winAdd a mixed integer-and-fractional Q96 regression test.
Current tests exercise
Q96,Q96 / 2, and integral multiples, but not the new reconstruction path with both components present. AddQ96 + Q96 / 2and assert1.5.Proposed test
#[test] fn price_x96_combines_integer_and_fractional_components() { let price = price_x96_to_f64(Q96 + Q96 / U256::from(2u64)).unwrap(); assert!((price - 1.5).abs() < Q96_PRECISION); }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/convert.rs` around lines 182 - 194, Add a regression test for the price_x96_to_f64 conversion that passes Q96 + Q96 / U256::from(2u64) and verifies the result is approximately 1.5 using the existing Q96_PRECISION tolerance. Name the test price_x96_combines_integer_and_fractional_components alongside the current conversion tests.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@src/convert.rs`:
- Around line 182-194: Add a regression test for the price_x96_to_f64 conversion
that passes Q96 + Q96 / U256::from(2u64) and verifies the result is
approximately 1.5 using the existing Q96_PRECISION tolerance. Name the test
price_x96_combines_integer_and_fractional_components alongside the current
conversion tests.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 34d56beb-7cf8-4ce0-ad12-e2ca503e17aa
📒 Files selected for processing (4)
src/client/trades.rssrc/constants.rssrc/convert.rssrc/math/tick.rs
Summary by CodeRabbit