Skip to content

[CT-11] Add platform fee deduction to escrow contract #919

@mftee

Description

@mftee

Problem

The escrow contract releases 100% of the held funds to the carrier on delivery confirmation. There is no mechanism to deduct a platform service fee before release. Without this, the platform has no on-chain revenue model and must rely entirely on off-chain accounting.

Proposed Solution

Create a fee-aware escrow contract inside contracts/package/escrow-with-fees/ that automatically deducts a configurable platform fee from the release amount and routes it to a treasury address.

Note: All work must be done inside the contracts/package/ directory. Do not modify any existing contract files outside this folder.

Acceptance Criteria

  • platform_fee_bps: u32 (basis points) set at contract initialization (e.g., 250 = 2.5%)
  • Fee is deducted from the escrow amount on release_funds, not on fund_escrow
  • Fee is transferred to the platform_treasury: Address set at initialization
  • Carrier receives funded_amount - fee; treasury receives fee
  • Full refunds (on cancellation) return the full funded amount to the shipper — no fee on refunds
  • A ReleaseWithFee event emits { carrier_amount, fee_amount, treasury_address }
  • platform_fee_bps is updatable by admin; an update event is emitted on change
  • Unit tests verify fee math for 1%, 2.5%, and 0% fee rates

Metadata

Metadata

Assignees

Labels

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