Sbhn_NPUntitled Query
    Updated 2023-01-28
    --credit : https://app.flipsidecrypto.com/velocity/queries/cd1e5fe1-fdc0-4fed-be9e-3713a415505c
    with new_users as (
    select
    tx_sender as wallet_address,
    min(block_timestamp)::date as creation_date
    from terra.core.fact_transactions
    group by wallet_address
    ),
    new_user_list as (
    select
    wallet_address,
    creation_date
    from new_users
    ),
    transfer_luna_from_user as (
    select
    date_trunc('day',block_timestamp) as day,
    sender as address,
    - (sum(amount))/1e6 as amount
    from terra.core.ez_transfers
    where currency = 'uluna'
    and tx_succeeded = true
    and block_timestamp>= '2023-01-07' and block_timestamp <= '2023-01-21'
    group by day, address
    ),
    transfer_luna_to_user as (
    select
    date_trunc('day',block_timestamp) as day,
    receiver as address,
    (sum(amount))/1e6 as amount
    from terra.core.ez_transfers
    where currency = 'uluna'
    and tx_succeeded = true
    and block_timestamp>= '2023-01-07' and block_timestamp <= '2023-01-21'
    group by day, address
    ),
    Run a query to Download Data