MLDZMNpools
Updated 2024-01-11
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 pools as (select
*
from external.defillama.dim_pools
where chain = 'NEAR'
and PROTOCOL = 'ref-finance'
),
price_tab as ( select
timestamp::date as date,
a.symbol,
b.token_contract,
decimals,
avg(PRICE_USD) as avg_price
from near.price.fact_prices a join near.core.dim_token_labels b on a.token_contract = b.token_contract
where timestamp::date >= '2023-01-01'
group by 1,2,3,4),
tb1 as ( select
block_timestamp,
tx_hash,
trader,
(amount_in)*b.avg_price as volume_in,
token_out,
token_in ,
token_in_contract,
TOKEN_OUT_CONTRACT,
(amount_out)*c.avg_price as volume_out,
concat(token_in,'->',token_out) as pair,
POOL_ID
from near.defi.ez_dex_swaps a
left join price_tab b on a.block_timestamp::date = b.date
and a.token_in_contract = b.token_contract
left join price_tab c on a.TOKEN_OUT_CONTRACT = c.token_contract
QueryRunArchived: QueryRun has been archived