Skip to content

feat(contracts): round penalties in protocol favour and enforce parti… - #2125

Merged
1nonlypiece merged 2 commits into
Commitlabs-Org:masterfrom
probablyABug:feat/2094-penalty-math-and-minimum-partials
Oct 24, 2026
Merged

1nonlypiece merged 2 commits into
Commitlabs-Org:masterfrom
probablyABug:feat/2094-penalty-math-and-minimum-partials

Conversation

@probablyABug

Copy link
Copy Markdown
Contributor

…al withdrawal minimums

Closes #2094

  • Add shared penalty_for(amount, penalty_bps) helper using ceiling division ceil(amount * bps / 10_000) with checked arithmetic and clamping.
  • Replace duplicate inline penalty computations in
    efund_partial, execute_refund, and
    esolve_dispute with penalty_for.
  • Enforce MIN_PARTIAL_WITHDRAWAL (10_000_000 stroops / 1 XLM) and MIN_REMAINING_PRINCIPAL (10_000_000 stroops / 1 XLM) on
    efund_partial, returning Error::BelowMinimum = 18 unless remaining is 0.
  • Update contracts/README.md with entrypoints, configuration surface, error table, and a dedicated 'Penalty math' section.
  • Add test suite in contracts/escrow/src/test_penalty_math.rs covering unit cases, property-based tests, integration minimums/balances, and slicing regression tests.

Description

Please include a summary of the changes and the related issue. List any dependencies that are required for this change.

Closes # (issue number)

Type of Change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update

Checklist

Please review the Developer Guide before checking the items below:

  • My code follows the code style and standards of this project (strict TypeScript, components/functions/constants naming conventions).
  • I have performed a self-review of my code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have updated or added documentation where relevant (DEVELOPER_GUIDE.md, README.md, or inline files).
  • I have added unit/integration tests that prove my fix is effective or that my feature works.
  • Any new or modified logic has at least 95% test coverage (verified via pnpm run test:coverage or npm run test:coverage).
  • I have ran the project linter (pnpm lint or npm run lint) and fixed all error diagnostics.
  • I have verified that this change fits within the 96-hour campaign timeframe for contributor assignments.
  • I have attached screenshots/videos showing the before and after states for any visual or UI changes.

Visual Changes (if applicable)

Please add screenshots, screen recordings, or GIFs showcasing the user interface changes.

Join the Discussion

Need help or want to chat? Join our CommitLabs Discord server.

…al withdrawal minimums

Closes Commitlabs-Org#2094

- Add shared penalty_for(amount, penalty_bps) helper using ceiling division
  ceil(amount * bps / 10_000) with checked arithmetic and clamping.
- Replace duplicate inline penalty computations in 
efund_partial,
  execute_refund, and 
esolve_dispute with penalty_for.
- Enforce MIN_PARTIAL_WITHDRAWAL (10_000_000 stroops / 1 XLM) and
  MIN_REMAINING_PRINCIPAL (10_000_000 stroops / 1 XLM) on 
efund_partial,
  returning Error::BelowMinimum = 18 unless remaining is 0.
- Update contracts/README.md with entrypoints, configuration surface, error
  table, and a dedicated 'Penalty math' section.
- Add test suite in contracts/escrow/src/test_penalty_math.rs covering unit
  cases, property-based tests, integration minimums/balances, and slicing
  regression tests.
@vercel

vercel Bot commented Oct 24, 2026

Copy link
Copy Markdown

@Stephan-Thomas is attempting to deploy a commit to the 1nonly's projects Team on Vercel.

A member of the Team first needs to authorize it.

…olve conflicts

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@1nonlypiece
1nonlypiece merged commit aedf61f into Commitlabs-Org:master Oct 24, 2026
3 of 6 checks passed
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.

[contracts] Round early-exit penalties in the protocol's favour and enforce minimum partial-withdrawal sizes

3 participants