Problem
Different code paths can round amounts differently, causing preview values to disagree with executed deposits or withdrawals at boundary values.
Objective
Deliver a production-quality improvement to fee, share conversion, and preview/execution calculations that creates measurable value for correctness, security, reliability, performance, or maintainability.
Implementation scope
- Introduce one documented decimal and rounding policy used by preview, validation, and execution.
- Define fee caps, minimum units, and behavior for zero, near-limit, and unsupported precision inputs.
- Return enough metadata for clients to explain rounding without exposing internal implementation details.
Acceptance criteria
- Preview and execution produce the same canonical result for identical inputs.
- No calculation overflows or silently loses value at supported boundaries.
- Fee and rounding behavior is covered by shared fixtures.
Required validation
- Boundary, property-based, and API contract tests comparing preview and execution results.
- Existing tests and CI remain passing.
- Add regression coverage for the original failure mode.
- Do not weaken, delete, or skip unrelated tests to obtain a green build.
PR quality bar
- Keep the PR focused on this issue and explain design tradeoffs.
- Include test evidence, compatibility impact, and migration or rollout notes where relevant.
- Avoid typo-only, documentation-only, cosmetic-only, or unrelated refactor submissions.
Out of scope
- Broad rewrites not required by the acceptance criteria.
- Changes to unrelated services, contracts, or user flows.
Problem
Different code paths can round amounts differently, causing preview values to disagree with executed deposits or withdrawals at boundary values.
Objective
Deliver a production-quality improvement to fee, share conversion, and preview/execution calculations that creates measurable value for correctness, security, reliability, performance, or maintainability.
Implementation scope
Acceptance criteria
Required validation
PR quality bar
Out of scope