Skip to content

Use deterministic fair rounding for pool units - #209

Merged
Obiajulu-gif merged 2 commits into
Chainmove:mainfrom
prissca:agent/issue-170-fair-unit-rounding
Aug 19, 2026
Merged

Use deterministic fair rounding for pool units#209
Obiajulu-gif merged 2 commits into
Chainmove:mainfrom
prissca:agent/issue-170-fair-unit-rounding

Conversation

@prissca

@prissca prissca commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

What changed

  • allocate units from cumulative pool entitlement instead of flooring each contribution independently
  • carry fractional value through the cumulative numerator and remove the final-funder remainder windfall
  • reject below-granularity investments with an explicit contract error
  • emit allocation evidence with awarded units and the post-allocation remainder numerator
  • add awkward-ratio, ordering-bound, cap, and minimum-granularity tests

Rounding policy

At every transition the pool entitlement is floor(total invested × total units / target). Individual orders may differ by at most one indivisible unit, while a fully funded pool always sums exactly to the unit cap.

Validation

  • Rust sources parse successfully with rustfmt
  • contract tests could not link on this machine because the MSVC link.exe build tool is not installed

Closes #170

@prissca
prissca marked this pull request as ready for review August 18, 2026 12:42
@prissca

prissca commented Aug 18, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the contribution! Merging this now as part of a maintainer PR sweep.

@Obiajulu-gif

Copy link
Copy Markdown
Collaborator

Hi! This PR currently has a merge conflict with the base branch and can't be merged as-is. Could you please rebase/merge main into your branch and resolve the conflicts? Thanks!

1 similar comment
@Obiajulu-gif

Copy link
Copy Markdown
Collaborator

Hi! This PR currently has a merge conflict with the base branch and can't be merged as-is. Could you please rebase/merge main into your branch and resolve the conflicts? Thanks!

@Obiajulu-gif

Copy link
Copy Markdown
Collaborator

Thanks for this PR! It currently has merge conflicts against main and can't be merged as-is. Could you rebase/merge main into your branch and resolve the conflicts? I'll take another look once it's conflict-free.

…p CI fixes

# Conflicts:
#	contracts/chainmove-pool/src/lib.rs
@Obiajulu-gif
Obiajulu-gif merged commit ffc82dc into Chainmove:main Aug 19, 2026
2 checks passed
BigDella pushed a commit to BigDella/Chain-move that referenced this pull request Aug 20, 2026
…e#209)

Resolves a second ContractError discriminant collision: main added
InvestmentTooSmall = 15 (from Chainmove#209, merged after our previous sync), which
collided with the governance module's error range that also started at 15.
Shifts the governance variants to start at 16 (GovernanceAlreadyInitialized
through StaleProposal = 26). governance.rs references variants by name only,
so no other changes are needed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[HARD][SOROBAN ACCOUNTING] Use deterministic fair rounding when allocating pool units

2 participants