Skip to content

[CLOB-084] Align SDK preview arithmetic and prevent fragmentation rounding gains #960

Closed

Description

@IbrahimIjai

Phase 4 — Atomic settlement, fees, and accounting

Source: Backlog item #54 — Specify and implement deterministic trade rounding and dust handling (part 2/2)
Depends on: #881, #882, #940, #957, #958, #959

Objective

Integer prices, token decimals, ticks, and lots can create fractional quote amounts conceptually. The protocol must define one deterministic rounding rule that never makes the exchange insolvent or gives away value through inconsistent maker/taker calculations.

Scope

  • Ensure SDK quote previews use identical arithmetic.
  • Avoid per-fill rounding paths that can be gamed by order fragmentation.

Acceptance criteria

  • Contract and SDK produce identical amounts for published test vectors.
  • Repeated small fills cannot create more value than one equivalent large fill beyond documented dust bounds.

Implementation guidance

  • Make economic state changes atomically with book mutations; no fill is complete unless balances, fees, liabilities, and order state agree.
  • Use checked integer arithmetic and one canonical rounding implementation across contract tests and SDKs.

Definition of done

Implementation, positive and negative-path tests, updated public docs/types where behavior changes, no new unbounded iteration, and the full verification gate in AGENTS.md passing. Matching/storage/resource changes update benchmark evidence once the benchmark harness exists.

Activity

  1. habeebullahabubakar61-debug commented on Oct 19, 2026

    @habeebullahabubakar61-debug

    @habeebullahabubakar61-debug has applied to work on this issue as part of the Stellar Wave Program's 10th wave.

    Hello maintenance, kindly give me issues plz I will fix it for you

    ℹ️ Repo Maintainers: To accept this application, review their application or assign @habeebullahabubakar61-debug to this issue.

  2. Oluwato2004 commented on Oct 19, 2026

    @Oluwato2004

    @Oluwato2004 has applied to work on this issue as part of the Stellar Wave Program's 10th wave.

    Hello, I’m interested in working on this issue and would appreciate being assigned to it. Thank you.

    ℹ️ Repo Maintainers: To accept this application, review their application or assign @Oluwato2004 to this issue.

  3. medunrebecca-dot commented on Oct 20, 2026

    @medunrebecca-dot
    Contributor

    @medunrebecca-dot has applied to work on this issue as part of the Stellar Wave Program's 10th wave.

    Hello, I would like to work on this issue

    ℹ️ Repo Maintainers: To accept this application, review their application or assign @medunrebecca-dot to this issue.

  4. drips-wave commented on Oct 20, 2026

    @drips-wave

    Congratulations, @medunrebecca-dot! 🎉 Your application was accepted by the repo's maintainers, and the issue is due on October 22, 2026.

    🧑‍💻 @medunrebecca-dot: Please resolve the issue such that the repo's maintainers have enough time to review your contribution before the due date. You'll earn Points for completing the issue on-time, which will make you eligible for a share of the Stellar Wave Program's reward pool.

    Warning

    When opening a PR, please link it to this issue to ensure it gets tracked accurately. Points are awarded when this issue is marked as completed by the maintainer.

    🤠 Repo maintainers: Please keep an eye on the contributor's progress and review their work before the due date. You can manage this issue, including adjusting its complexity and points, here.

    🌊 Happy Wave 🌊

  5. grantfox-oss commented on Oct 21, 2026

    @grantfox-oss

    🎉 This issue has been marked as completed on GrantFox!

    @medunrebecca-dot's PR #1100 was approved and merged by @IbrahimIjai.

    🏆 @medunrebecca-dot: You earned 35 FoxPoints for this contribution! Your current tier: Explorer (519 total points). Track your full progress on GrantFox.

    👏 Great work, @medunrebecca-dot! Keep contributing to SO4-Markets.

  6. drips-wave commented on Oct 21, 2026

    @drips-wave

    This issue has been completed by @medunrebecca-dot as part of the Stellar Wave Program's 10th Wave 🥳

    😎 @medunrebecca-dot: You earned 200 Points for completing this issue! Once the Wave's rewards are finalized, you'll be eligible for a percentage of the Wave's reward pool based on the percentage of total points you've earned. Learn more here. You can also Leave a review to share your experience working on this issue.

    🧑‍💻 Repo maintainers: How'd the contributor do? Leave a review to share your experience working with them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions