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:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user