Sandeshflow usdc dest
Updated 2022-11-23
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 sending_address as
(
select *,event_data:"from" as sender,event_data:"amount" as amount from flow.core.fact_events
where 1=1
-- and tx_id='b97a0df257483d6564917db5c8dab53c235cbf105e9e3a960bf5511f9deefe89'
and event_contract='A.b19436aae4d94622.FiatToken'
and event_type='TokensWithdrawn'
),
receiver_address as
(
select *,event_data:"to" as receiver from flow.core.fact_events
where 1=1
-- and tx_id='b97a0df257483d6564917db5c8dab53c235cbf105e9e3a960bf5511f9deefe89'
and event_contract='A.b19436aae4d94622.FiatToken'
and event_type='TokensDeposited'
),
flow_table as
(
select sa.*,ra.receiver from receiver_address ra inner join sending_address sa on ra.tx_id=sa.tx_id
),
flow_usdc as
(
select
block_height as block_id,
date_trunc('{{granularity}}',block_timestamp) as time,
tx_id as tx_hash,
sender as sender,
receiver as receiver,
'USDC' as currency,
cast(amount as float) as usd_amount,
case
when usd_amount < 1 and usd_amount > 0 then 'shrimp (0-1)'
when usd_amount < 10 and usd_amount >= 1 then 'crab (1-10)'
when usd_amount < 50 and usd_amount >= 10 then 'Octpus (10-50)'
when usd_amount < 100 and usd_amount >= 50 then 'Fish (50-100)'
when usd_amount < 500 and usd_amount >= 100 then 'Dolphins (100-500)'
Run a query to Download Data