Skip to content

Feature/escrow maturity gate#64

Merged
mikewheeleer merged 8 commits intoLiquifact:mainfrom
shaaibu7:feature/escrow-maturity-gate
Mar 27, 2026
Merged

Feature/escrow maturity gate#64
mikewheeleer merged 8 commits intoLiquifact:mainfrom
shaaibu7:feature/escrow-maturity-gate

Conversation

@shaaibu7
Copy link
Copy Markdown
Contributor

feat(escrow): implement maturity gate for settlement

Blocks settle() from executing before the invoice maturity timestamp,
preventing premature settlement and protecting investor yield obligations.

Changes

  • escrow/src/lib.rs — added env.ledger().timestamp() >= maturity
    check in settle() with a clear panic message; expanded module-level
    and field-level doc comments explaining the security model
  • escrow/src/test.rs — rewrote test suite (17 tests) covering all
    maturity gate paths: exact boundary, one second before, one day after,
    timestamp=0 with maturity>0, and zero-maturity (no time lock)
  • README.md — added Maturity gate section with truth table and note
    on why env.ledger().timestamp() is a trustless clock

Security note

env.ledger().timestamp() is set by Stellar network consensus and cannot
be manipulated by the contract caller, making it safe as a time gate.

closes #6

Add ledger timestamp check in settle(). The current ledger time must be
>= escrow.maturity before status can advance to settled (2).

Security note: env.ledger().timestamp() is the canonical on-chain clock
and cannot be spoofed by the contract caller.
- Refactor helpers into setup() to reduce boilerplate
- Fix existing settle tests to advance ledger to >= maturity
- Add edge cases: exact boundary, one second before, one day after,
  timestamp=0 with maturity>0, and zero-maturity (no time lock)
- All 17 tests pass with zero warnings
Add 'Maturity gate' section explaining the two settle() guards:
- funding status check
- ledger timestamp >= maturity check

Include a truth table of all time/status combinations and a note
on the security property of env.ledger().timestamp().
- Expand module-level doc to describe the maturity gate security model
- Annotate InvoiceEscrow::maturity with timestamp semantics and the
  zero-maturity escape hatch
- Expand settle() doc comment with security rationale for using
  env.ledger().timestamp() as the trusted clock
@drips-wave
Copy link
Copy Markdown

drips-wave bot commented Mar 24, 2026

@shaaibu7 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@mikewheeleer
Copy link
Copy Markdown
Contributor

resolve the conflicts

@shaaibu7
Copy link
Copy Markdown
Contributor Author

conflict resolved

@mikewheeleer mikewheeleer merged commit 06b2b46 into Liquifact:main Mar 27, 2026
1 check 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.

Enforce Maturity Time in Settlement

2 participants