Context & Problem Statement
The platform currently applies a uniform fee BPS across all escrow transactions. Different commercial invoicing sectors (e.g. factoring, reverse factoring, government contracts, standard trade credit) operate on vastly different margin profiles and risk parameters, necessitating distinct platform fee schedules per invoice category.
This issue implements an InvoiceCategory enum, persistent category fee storage, admin configuration methods, and dynamic fee lookups during escrow creation.
Architectural Motivation & Technical Requirements
- In
contracts/invoice-escrow/src/types.rs:
- Define
InvoiceCategory enum: Standard, Factoring, Reverse, Government.
- Define
CategoryFeeSchedule { fee_bps: u32 }.
- Add
category: InvoiceCategory to EscrowData.
- Add
StorageKey::CategoryFee(InvoiceCategory).
- In
contracts/invoice-escrow/src/lib.rs:
- Implement
set_category_fee(env, admin, category: InvoiceCategory, fee_bps: u32) (admin only, bounds 0..=10000).
- Update
create_escrow to accept category: Option<InvoiceCategory> (defaulting to Standard).
- Retrieve and apply the corresponding category fee rate during fee deduction.
- In
contracts/invoice-escrow/src/test.rs:
- Test fee lookups for each category.
- Test default fallback when no category fee is configured.
- Test boundary validation (0 BPS and 10000 BPS max).
- Test unauthorized configuration attempts.
Acceptance Criteria
Target Branch: dev
Estimated Effort: 5–12 hours | Delivery: 3–5 days
Difficulty: Medium
Context & Problem Statement
The platform currently applies a uniform fee BPS across all escrow transactions. Different commercial invoicing sectors (e.g. factoring, reverse factoring, government contracts, standard trade credit) operate on vastly different margin profiles and risk parameters, necessitating distinct platform fee schedules per invoice category.
This issue implements an
InvoiceCategoryenum, persistent category fee storage, admin configuration methods, and dynamic fee lookups during escrow creation.Architectural Motivation & Technical Requirements
contracts/invoice-escrow/src/types.rs:InvoiceCategoryenum:Standard,Factoring,Reverse,Government.CategoryFeeSchedule { fee_bps: u32 }.category: InvoiceCategorytoEscrowData.StorageKey::CategoryFee(InvoiceCategory).contracts/invoice-escrow/src/lib.rs:set_category_fee(env, admin, category: InvoiceCategory, fee_bps: u32)(admin only, bounds 0..=10000).create_escrowto acceptcategory: Option<InvoiceCategory>(defaulting toStandard).contracts/invoice-escrow/src/test.rs:Acceptance Criteria
create_escrowcalculates fees based on category rate.cargo test -p invoice-escrowpasses cleanly.Target Branch:
devEstimated Effort: 5–12 hours | Delivery: 3–5 days
Difficulty: Medium