Skip to content

[CT-04] Implement Escrow Refund Amount Calculator with cancellation policy in Rust #1021

@devwums

Description

@devwums

Problem

Refund conditions for cancelled bookings are not codified in the contract layer. Refund calculations happen ad hoc on the backend with no on-chain enforceability.

Proposed Solution

Create contracts/cntr/escrow_refund.rs implementing pub fn calculate_refund_amount(booking_amount_stroops: i128, cancellation_hours_before_start: u64) -> i128. Refund rules: 100% refund if cancelled 48h or more before start, 50% refund if 24–47h before, 0% refund if less than 24h before. Integer arithmetic only — no floating point. All implementation must live inside contracts/cntr/.

Acceptance Criteria

  • File at contracts/cntr/escrow_refund.rs
  • Returns booking_amount_stroops for cancellations at or beyond 48 hours
  • Returns booking_amount_stroops / 2 (integer division) for 24–47 hours
  • Returns 0 for less than 24 hours
  • At least 6 unit tests including exact boundary values (24h and 48h)
  • No floating-point arithmetic
  • Compiles with cargo test

Metadata

Metadata

Assignees

Labels

Stellar WaveIssues in the Stellar wave program

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions