Salehariesmarkets_deposit_total
    Updated 2024-01-20
    with lst_all as (
    with lst_token as (
    select
    tx_hash
    ,split(split( EVENT_TYPE,'>')[0],'DepositEvent<') [1] as token
    from aptos.core.fact_events
    -- where tx_hash='0x533697027069f0df862bba16ddf11229cd89e6529d8d7a6dc30d1f44527ce44a'
    -- where EVENT_ADDRESS='0x9770fa9c725cbd97eb50b2be5f7416efdfd1f1554beb0750d4dae4c64e860da3'
    -- and EVENT_RESOURCE= 'DepositEvent<0x1'
    -- and EVENT_RESOURCE ilike 'DepositEvent%'
    )
    select
    block_timestamp::date as date
    ,a.tx_hash
    ,EVENT_DATA:user_addr as wallet
    ,EVENT_DATA:collateral_amount/1e8 as amount
    ,token
    from aptos.core.fact_events a
    join lst_token t on a.tx_hash = t.tx_hash
    -- where a.tx_hash='0x533697027069f0df862bba16ddf11229cd89e6529d8d7a6dc30d1f44527ce44a'
    where event_address='0x9770fa9c725cbd97eb50b2be5f7416efdfd1f1554beb0750d4dae4c64e860da3'
    -- and EVENT_RESOURCE='SyncProfileDepositEvent'
    and SUCCESS=true
    and tx_type='user_transaction'
    )
    select
    token
    ,symbol
    ,count(DISTINCT tx_hash) as TXS
    -- count(DISTINCT tx_hash)
    -- ,count(DISTINCT wallet)
    ,sum(amount)
    from lst_all
    join aptos.price.ez_asset_metadata on TOKEN_ADDRESS =lower(token)
    group by 1,2

    QueryRunArchived: QueryRun has been archived