DATE | Affiliates | AFFILIATE_FEE | AFFILIATE_FEE_WITH_RANK | BASE4_SUM | RANK | AFFILIATE_FEE_SUM | |
---|---|---|---|---|---|---|---|
1 | 2022-09-01 00:00:00.000 | THORSwap | 19198.943414976 | 1THORSwap | 1346668.14267842 | 1 | 1004519.36346791 |
2 | 2023-06-01 00:00:00.000 | THORSwap | 39350.382945013 | 1THORSwap | 1346668.14267842 | 1 | 1004519.36346791 |
3 | 2023-11-01 00:00:00.000 | THORSwap | 86122.613055633 | 1THORSwap | 1346668.14267842 | 1 | 1004519.36346791 |
4 | 2022-12-01 00:00:00.000 | THORSwap | 37415.264536324 | 1THORSwap | 1346668.14267842 | 1 | 1004519.36346791 |
5 | 2022-05-01 00:00:00.000 | THORSwap | 72787.176020505 | 1THORSwap | 1346668.14267842 | 1 | 1004519.36346791 |
6 | 2023-02-01 00:00:00.000 | THORSwap | 22716.550657155 | 1THORSwap | 1346668.14267842 | 1 | 1004519.36346791 |
7 | 2023-08-01 00:00:00.000 | THORSwap | 148326.136534055 | 1THORSwap | 1346668.14267842 | 1 | 1004519.36346791 |
8 | 2023-03-01 00:00:00.000 | THORSwap | 26272.080955188 | 1THORSwap | 1346668.14267842 | 1 | 1004519.36346791 |
9 | 2022-04-01 00:00:00.000 | THORSwap | 17478.923678235 | 1THORSwap | 1346668.14267842 | 1 | 1004519.36346791 |
10 | 2023-07-01 00:00:00.000 | THORSwap | 48308.096915926 | 1THORSwap | 1346668.14267842 | 1 | 1004519.36346791 |
11 | 2022-10-01 00:00:00.000 | THORSwap | 12585.157327668 | 1THORSwap | 1346668.14267842 | 1 | 1004519.36346791 |
12 | 2022-06-01 00:00:00.000 | THORSwap | 49487.460942598 | 1THORSwap | 1346668.14267842 | 1 | 1004519.36346791 |
13 | 2023-10-01 00:00:00.000 | THORSwap | 171008.669803221 | 1THORSwap | 1346668.14267842 | 1 | 1004519.36346791 |
14 | 2023-09-01 00:00:00.000 | THORSwap | 57296.142632609 | 1THORSwap | 1346668.14267842 | 1 | 1004519.36346791 |
15 | 2023-04-01 00:00:00.000 | THORSwap | 18048.217565525 | 1THORSwap | 1346668.14267842 | 1 | 1004519.36346791 |
16 | 2022-07-01 00:00:00.000 | THORSwap | 25452.407667185 | 1THORSwap | 1346668.14267842 | 1 | 1004519.36346791 |
17 | 2022-08-01 00:00:00.000 | THORSwap | 23660.05664728 | 1THORSwap | 1346668.14267842 | 1 | 1004519.36346791 |
18 | 2023-12-01 00:00:00.000 | THORSwap | 45171.843170861 | 1THORSwap | 1346668.14267842 | 1 | 1004519.36346791 |
19 | 2022-11-01 00:00:00.000 | THORSwap | 31336.036516769 | 1THORSwap | 1346668.14267842 | 1 | 1004519.36346791 |
20 | 2023-01-01 00:00:00.000 | THORSwap | 37412.85418458 | 1THORSwap | 1346668.14267842 | 1 | 1004519.36346791 |
shaunoffAffiliate Fee - RUNE copy
Updated 2025-03-19
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
›
⌄
-- forked from winnie-fs / Affiliate Fee - RUNE @ https://flipsidecrypto.xyz/winnie-fs/q/eBgZt8kUEw5J/affiliate-fee---rune
with base as (select tx_id,
date_trunc('{{granularity}}', block_timestamp) as date,
affiliate_address, affiliate_fee_basis_points,
split(from_asset, '-')[0] as from_assets,
case
when from_assets ilike '%/%' then split(from_assets, '/')[1]
else split(from_assets, '.')[1]
end as from_asset_names,
split(to_asset, '-')[0] as to_assets,
case
when to_assets ilike '%/%' then split(to_assets, '/')[1]
else split(to_assets, '.')[1]
end as to_asset_names,
concat(from_asset_names, ' -> ', to_asset_names) as assets,
case when assets ilike '%RUNE' then 2
else 1
end as numbering,
sum(from_amount_usd/rune_usd) as swap_volume
from thorchain.defi.fact_swaps
where date >= '{{start_date}}'
and date <= '{{end_date}}'--and tx_id = '902C27D4CDDF672D7E88F0CCBCB402ED1303827E90631320C849F5DD1294D5E3'
--and tx_id in (select tx_id from thorchain.defi.fact_swaps_events where memo ilike '%/%/%')
group by tx_id, date,
affiliate_address, affiliate_fee_basis_points,
from_asset, to_asset),
base2 as (select date,
tx_id,
affiliate_address, affiliate_fee_basis_points,
array_agg(distinct assets) within group (order by assets asc) as swap_direction, --merging 2 sep path to 1
sum(swap_volume) as swap_volume
from base
group by 1,2,3,4),
Last run: 20 days ago
...
274
31KB
23s