dwellonchainOrderly - Total Deposit and Withdraw copy
    Updated 2023-09-13
    -- forked from Yousefi_1994 / Orderly - Total Deposit and Withdraw @ https://flipsidecrypto.xyz/Yousefi_1994/q/OzAksnL5B8UZ/orderly---total-deposit-and-withdraw

    with token_list as (
    (
    select
    distinct actions['predecessor_id']::string as token_contract
    from near.core.fact_receipts
    where receiver_id = 'asset-manager.orderly-network.near'
    and actions['receipt']['Action']['actions'][0]['FunctionCall']['method_name']::string = 'ft_on_transfer'
    and object_keys(status_value)[0]::string != 'Failure'
    and block_timestamp::date >= '2022-09-13'
    and block_timestamp::date <= current_date - 1
    )
    union
    (
    select 'wrap.near'::string as token_contract
    )
    ),
    tokens_details as (
    select
    case
    when token_contract = 'a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48.factory.bridge.near' then 'USDC'
    when token_contract = 'aurora' then 'ETH'
    when token_contract = 'wrap.near' then 'NEAR'
    else symbol
    end as token_symbol,
    token_contract,
    decimals
    from near.core.dim_token_labels
    where token_contract in (select token_contract from token_list)
    group by 1, 2, 3
    ),
    deposit_tokens as (
    select
    tx_hash,
    block_timestamp,
    Run a query to Download Data