Skip to content

💰 Abstractions / Policies

🎯 Purpose

The Policies folder defines the data contracts and interfaces for currency rules.

These types describe how limits and constraints are expressed. They do not enforce behaviour — enforcement is handled by composed services.


🧠 Usage Guidance

Policy abstractions are intended to:

  • Define data-only rule structures for currency constraints
  • Provide public seams for policy lookup and transfer rules
  • Keep rule definition separate from enforcement and mutation logic

🧩 What Lives Here

CapMode

  • Defines behaviour when a rule is violated:

  • Clamp — adjust to the boundary

  • Fail — reject the operation

CurrencyCapRule

  • Data-only representation of a currency rule
  • Defines:

  • minimum balance

  • maximum balance (0 = unbounded)
  • enforcement mode (CapMode)

ITransferPolicyProvider

  • Optional policy seam for transfer rules
  • Provides:

  • source-side rules (sender)

  • destination-side rules (receiver)
  • Returning false means no rule (unbounded)

⚠️ Important Notes

  • Policies are data + intent, not behaviour
  • These abstractions do not enforce rules by themselves
  • Enforcement depends on the composed service stack
  • Transfer rules may differ between source and destination
  • A max value of 0 means unbounded
  • Input normalization is implementation-defined

🧠 Usage Guidance

Mental model

  • Abstractions define rule shape
  • Implementations decide how rules are applied
  • Consumers should not assume enforcement is present

Enforcement is handled by:

  • Composed services (e.g., caps decorators)
  • Helper APIs (e.g., preview calculations)

🚫 Internal Use Only

This folder defines contracts only.

Do not:

  • Add enforcement logic
  • Introduce runtime dependencies
  • Depend on internal implementation details

🧹 Safe to Remove

This folder should not be removed if any policy-based behaviour is used.

Other systems may depend on these contracts when policy rules are composed.


  • PublicAPI / Helpers — policy-aware previews and transfer helpers
  • Abstractions / Primitives — shared types like CurrencyId
  • Internal — policy enforcement implementations (not public)