Sandeshflow_usdc
    Updated 2022-11-22
    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,
    amount,
    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)'
    Run a query to Download Data