Afonso_Diazrainbow-i2
Updated 2023-02-24
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
t1 as (
select
block_timestamp,
regexp_replace(substring(logs[0], 1, charindex(' wrap.near for', logs[0])), '[^0-9]', '')/pow(10, 24) as amount_near,
regexp_replace(substring(substring(logs[0], charindex('for', logs[0]), 100), 1, charindex('dac', substring(logs[0], charindex('for', logs[0]), 100))-2), '[^0-9]', '')/pow(10,6) as amount_usdt
from near.core.fact_receipts
where
logs[0] like 'Swapped % wrap.near for % dac17f958d2ee523a2206206994597c13d831ec7.factory.bridge.near'
),
t2 as (
select
hour::date as day,
token_address,
avg(price) as price_usd
from ethereum.core.fact_hourly_token_prices
group by 1, 2
union
select
block_timestamp::date as day,
null as token_address,
avg(amount_usdt / amount_near) as price_usd
from t1
group by 1, 2
),
t3 as (
select
block_timestamp,
tx_hash,
(parse_json(trim(args))):amount as token_amount
from near.core.fact_actions_events_function_call
where 1 = 1
Run a query to Download Data