feyikemi2024-06-24 01:51 AM
Updated 2024-06-24
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
29
30
31
32
33
34
35
36
›
⌄
WITH user_first_swap AS (
SELECT
from_address AS user,
MIN(DATE_TRUNC('day', block_timestamp)) AS first_swap_date
FROM thorchain.defi.fact_swaps
WHERE
block_timestamp::date >= '2024-01-01'
GROUP BY from_address
),
swap_data AS (
SELECT
DATE_TRUNC('day', block_timestamp) AS date,
CASE
WHEN affiliate_address IN ('t', 'T', 'thor160yye65pf9rzwrgqmtgav69n6zlsyfpgm9a7xk') THEN 'THORSwap'
WHEN affiliate_address IN ('wr', 'thor1a427q3v96psuj4fnughdw8glt5r7j38lj7rkp8') THEN 'THORWallet'
WHEN affiliate_address = 'tl' THEN 'TS Ledger'
WHEN affiliate_address = 'cb' THEN 'Team CoinBot'
WHEN affiliate_address = 'dx' THEN 'Asgardex'
WHEN affiliate_address = 'ss' THEN 'ShapeShift'
WHEN affiliate_address = 'xdf' THEN 'xDEFI'
WHEN affiliate_address = 'rg' THEN 'Rango'
WHEN affiliate_address = 'ej' THEN 'Edge Wallet'
WHEN affiliate_address = 'ds' THEN 'DefiSpot'
WHEN affiliate_address IN ('ti', 'te', 'tr', 'td') THEN 'TrustWallet'
WHEN affiliate_address IS NULL THEN 'No Affiliate'
END AS affiliate,
from_address AS user,
CASE
WHEN from_amount_usd IS NOT NULL THEN from_amount_usd
ELSE to_amount_usd
END AS swap_volume_usd
FROM thorchain.defi.fact_swaps
WHERE
Date >= '2024-01-01' AND Date < Current_Date
)
QueryRunArchived: QueryRun has been archived