Add deposit totals API endpoint

GET /api/deposits/totals returns fiat deposited per exchange per currency
from bank_to_exchange events, aggregated via SQL.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-08 12:32:05 +01:00
co-authored by Claude Opus 4.6
parent 5874952115
commit 0446d928e6
3 changed files with 16 additions and 1 deletions
+10
View File
@@ -125,6 +125,16 @@ LEFT JOIN wallets tw ON tw.id = e.to_wallet_id
WHERE e.from_wallet_id = :wallet-id OR e.to_wallet_id = :wallet-id
ORDER BY e.occurred_at DESC
-- :name get-deposit-totals :? :*
-- :doc Total fiat deposited per exchange per currency from bank_to_exchange events
SELECT tw.name AS exchange, e.fiat_currency AS currency,
SUM(e.fiat_amount) AS total
FROM events e
JOIN wallets tw ON tw.id = e.to_wallet_id
WHERE e.event_type = 'bank_to_exchange'
GROUP BY tw.name, e.fiat_currency
ORDER BY tw.name, e.fiat_currency
-- :name get-wallet-balances :? :*
-- :doc Compute sats balance per wallet from events
SELECT w.id, w.name,