Skip to content

[HARD][SOROBAN ACCOUNTING] Prevent partial-refund rounding from preserving excess units #166

Description

@Obiajulu-gif

Summary

Partial refunds floor the proportional units removed on every call. Repeating small refunds can recover principal while retaining more units than the remaining investment economically supports.

Repository evidence

  • contracts/chainmove-pool/src/lib.rs computes refund_units = amount * position.units / position.invested with integer division.
  • The floored result is subtracted independently on each partial refund, with no carried remainder or post-refund ratio invariant.

Scope

  • Define an exact post-refund unit entitlement or carry deterministic rounding remainder.
  • Enforce pool/position unit-to-principal invariants after every refund.
  • Document minimum refundable granularity and terminal dust handling.

Acceptance criteria

  • Splitting one refund into many calls cannot preserve extra units versus an equivalent single refund.
  • A full refund always removes all remaining units.
  • Pool funded units equal the sum of position units under tested transition sequences.

Tests

  • Property tests comparing one-shot and partitioned refunds across awkward ratios.
  • Dust, final refund, overflow, and interleaved funding/refund tests.

Non-goals

  • Changing initial funding allocation policy.

Metadata

Metadata

Assignees

Labels

GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardThird CampaignCampaign: Third Campaign

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions