saeedmzn[Ambient finance] - overtime
Updated 2025-03-04
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 prices as (
select date , symbol , price_usd
from $query('4dc7abc7-bc8e-4784-818a-c4a444a6d2c5')
),
ambient_txns as (
select tx_hash
from swell.core.fact_event_logs
where contract_address = '0xaaaaaaaa82812f0a1f274016514ba2ca933bf24d'
),
indexes as (
select tx_hash ,
min (event_index) min_index,
max (event_index) max_index
from swell.core.ez_decoded_event_logs join ambient_txns using (tx_hash)
group by 1
),
one_index as (
select block_timestamp::date date ,
tx_hash ,
ORIGIN_FROM_ADDRESS trader ,
c.SYMBOL token_in ,
decoded_log:"value" /pow(10,DECIMALS) amount_in ,
amount_in * price_usd amount_in_usd ,
null token_out ,
null amount_out ,
null amount_out_usd
from swell.core.ez_decoded_event_logs join indexes using (tx_hash)
join swell.core.dim_contracts c on ADDRESS = CONTRACT_ADDRESS
join prices p on (p.symbol = c.symbol and block_timestamp::date = p.date )
where max_index = min_index
),
swapped_event as (
with raw_swap as (
select block_timestamp::date date ,
tx_hash ,
QueryRunArchived: QueryRun has been archived