Multipartite2022-07-02 BNB/BUSD balances
Updated 2022-07-02Copy Reference Fork
99
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
›
⌄
WITH
cointype AS
(SELECT 'BNB/BUSD-BD1' AS coin),
tos AS
(
SELECT block_timestamp, block_id, to_address AS address, amount_e8 AS balance_change
FROM thorchain.transfer_events, cointype
WHERE asset = coin
),
froms AS
(
SELECT block_timestamp, block_id, from_address AS address, -1 * amount_e8 AS balance_change
FROM thorchain.transfer_events, cointype
WHERE asset = coin
)
SELECT address, POWER(10,-8) * SUM(balance_change) AS current_balance
FROM (
(SELECT * FROM tos)
UNION ALL
(SELECT * FROM froms)
)
WHERE address NOT IN ('thor1v8ppstuf6e3x0r4glqc68d5jqcs2tf38cg2q6y', 'thor1g98cy3n9mmjrpn0sxmn63lztelera37n8n67c0')
-- Minter and Pool modules.
GROUP BY address
ORDER BY current_balance DESC
Run a query to Download Data