TelesagesUser Stats
Updated 2023-12-30
999
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
29
30
31
32
33
34
35
36
›
⌄
WITH buys AS (
SELECT b.tx_hash, t.from_address AS user, b.token_in, b.token_out,
b.amount_in, b.amount_out - sum(l.decoded_log:amount) / POW(10, 18) AS amount_out
FROM ethereum.defi.ez_dex_swaps b
JOIN ethereum.core.fact_transactions t ON b.tx_hash = t.tx_hash
JOIN ethereum.core.ez_decoded_event_logs l ON l.tx_hash = b.tx_hash
AND l.topics[0] = '0xa1d9cc4f656b5806a40d32111d5b01fe6cdabb816c7c2596acbd42e94efed360'
AND l.decoded_log:from = '0x866e32c6870e6b11425a05cc06b82ee53b0b2fb4'
WHERE b.contract_address = '0x866e32c6870e6b11425a05cc06b82ee53b0b2fb4'
AND b.token_out = '0xfffb3adcf82f6d282a6378bb6767d06e286844c1'
GROUP BY b.tx_hash, user, b.token_in, b.token_out, b.amount_in, b.amount_out
),
sells AS (
SELECT b.tx_hash, t.from_address AS user, b.token_in, b.token_out,
b.amount_in + sum(l.decoded_log:amount) / POW(10, 18) AS amount_in, b.amount_out
FROM ethereum.defi.ez_dex_swaps b
JOIN ethereum.core.fact_transactions t ON b.tx_hash = t.tx_hash
JOIN ethereum.core.ez_decoded_event_logs l ON l.tx_hash = b.tx_hash
AND l.topics[0] = '0xeebbd6732d7979cccfcb383171bc8f012879a3ad56ebe489d4ba6317e158e5a1'
AND l.decoded_log:from = user
WHERE b.contract_address = '0x866e32c6870e6b11425a05cc06b82ee53b0b2fb4'
AND b.token_in = '0xfffb3adcf82f6d282a6378bb6767d06e286844c1'
GROUP BY b.tx_hash, user, b.token_in, b.token_out, b.amount_in, b.amount_out
),
sage_trades AS (
SELECT * FROM buys
UNION
SELECT * FROM sells
),
sage_users AS (
SELECT DISTINCT to_address AS user
FROM ethereum.core.ez_token_transfers
WHERE contract_address = '0xfffb3adcf82f6d282a6378bb6767d06e286844c1'
),
final_balances AS (
SELECT u.user, NVL(IFF(b.current_bal < 0.1, 0, b.current_bal), 0) AS final_balance
QueryRunArchived: QueryRun has been archived