# rust-fintech > Use when building financial, trading, or payment systems in Rust. Covers money handling, financial calculations, rounding, decimal precision with rust_decimal and BigDecimal, currency newtypes, ledger, journal entry, reconciliation, idempotency, ACID transactions, regulatory compliance, immutable transaction records, audit trails, checked arithmetic, and double-entry patterns. - Author: peixotorms - Repository: peixotorms/odinlayer-skills - Version: 20260202221752 - Stars: 0 - Forks: 0 - Last Updated: 2026-02-07 - Source: https://github.com/peixotorms/odinlayer-skills - Web: https://mule.run/skillshub/@@peixotorms/odinlayer-skills~rust-fintech:20260202221752 --- --- name: rust-fintech description: Use when building financial, trading, or payment systems in Rust. Covers money handling, financial calculations, rounding, decimal precision with rust_decimal and BigDecimal, currency newtypes, ledger, journal entry, reconciliation, idempotency, ACID transactions, regulatory compliance, immutable transaction records, audit trails, checked arithmetic, and double-entry patterns. --- # FinTech Development ## Domain Constraints | Domain Rule | Design Constraint | Rust Implication | |-------------|-------------------|------------------| | Audit trail | Immutable records | Arc, no mutation | | Precision | No floating point | rust_decimal | | Consistency | Transaction boundaries | Clear ownership | | Compliance | Complete logging | Structured tracing | | Reproducibility | Deterministic execution | No race conditions | ## Critical Rules - **Never use f64 for money** — floating point loses precision. Use `rust_decimal::Decimal`. - **All transactions must be immutable and traceable** — regulatory compliance requires event sourcing. - **Money can't disappear or appear** — double-entry accounting with validated totals. ## Key Crates | Purpose | Crate | |---------|-------| | Decimal math | rust_decimal | | Date/time | chrono, time | | UUID | uuid | | Serialization | serde | | Validation | validator | ## Currency Type Pattern ```rust use rust_decimal::Decimal; #[derive(Clone, Debug, PartialEq)] pub struct Amount { value: Decimal, currency: Currency, } impl Amount { pub fn new(value: Decimal, currency: Currency) -> Self { Self { value, currency } } pub fn add(&self, other: &Amount) -> Result { if self.currency != other.currency { return Err(CurrencyMismatch); } Ok(Amount::new(self.value + other.value, self.currency)) } } ``` ## Design Patterns | Pattern | Purpose | Implementation | |---------|---------|----------------| | Currency newtype | Type safety | `struct Amount(Decimal);` | | Transaction | Atomic operations | Event sourcing | | Audit log | Traceability | Structured logging with trace IDs | | Ledger | Double-entry | Debit/credit balance | ## Common Mistakes | Mistake | Domain Violation | Fix | |---------|-----------------|-----| | Using f64 | Precision loss | rust_decimal | | Mutable transaction | Audit trail broken | Immutable + events | | String for amount | No validation | Validated newtype | | Silent overflow | Money disappears | Checked arithmetic |