DCA distribution fails when ATM cash exceeds total tracked client balances #1
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
When the physical cash in the ATM machine exceeds the sum of all tracked client balances in satmachineadmin, DCA distributions fail for all clients.
Example from logs (2025-12-31)
Result: All 4 client payments refused because each allocation exceeds their actual balance.
Root Cause
In
transaction_processor.py:calculate_distribution_amounts():client_balance / total_confirmed_depositsThe proportion calculation assumes
total_confirmed_deposits >= transaction_fiat_amount, which is false when there are "orphan funds" in the machine.Orphan Funds Sources
Current Behavior
Proposed Solutions
Option 1: Cap allocations to remaining balance (Recommended)
Each client receives sats equivalent to their full remaining balance, orphan funds go to a designated wallet or stay in source.
Option 2: Proportional scaling
Scale down all allocations proportionally so total distributed equals total tracked balances, not transaction amount.
Option 3: Require manual reconciliation
Refuse to process transactions when out of sync, alert admin for manual intervention.
Acceptance Criteria
Fixed in commit
545a028on main.The sync mismatch detection now caps each client's allocation to their remaining fiat balance equivalent in sats. Orphan sats are tracked and logged for reconciliation.