theericstonezapper example
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
›
⌄
-- let's write a query to find the biggest buyer of
-- $MEME today across all dexes
with topbuyer as (
select distinct first_value(origin_from_address) OVER (order by totalvol desc)
as address FROM
(select origin_from_address,
sum(amount_out) as totalvol
from ethereum.core.ez_dex_swaps
where block_timestamp > current_date - 1
and origin_from_address NOT IN (select address from ethereum.core.dim_labels)
and token_out = '{{tokenaddress}}'
group by origin_from_address
)
),
-- now it is simple to grab their latest holdings for
-- a given address via zapper
holdings as (
select livequery.live.udf_api(
concat(
'https://api.zapper.xyz/z/v2/balances/tokens?addresses[]=',
(select address from topbuyer)
)
) as response
),
networks as (
select value as network,
row_number() OVER ( order by (select NULL) ) as rn
from
holdings,
lateral flatten (input => response:data, recursive => true )
having key = 'network'
),
tokvalues as (
select
Run a query to Download Data