SocioCryptostatistics per action
    Updated 2023-01-04
    -- For this query this dashboard is used as a base: https://app.flipsidecrypto.com/dashboard/dot-dot-whos-there-pDyf0Q

    WITH price AS (
    SELECT block_timestamp::date as date,
    from_currency as token,
    median ((to_amount/pow(10,to_decimal))/(from_amount/pow(10,from_decimal))) as USDPrice
    FROM osmosis.core.fact_swaps
    WHERE to_currency IN ('ibc/D189335C6E4A68B513C10AB227BF1C1D38C746766278BA3EEB4FB14124F1D858') --USDC
    AND to_amount > 0 AND from_amount > 0 AND tx_status = 'SUCCEEDED'
    AND from_currency IN ('ibc/3FF92D26B407FD61AE95D975712A7C319CDE28DE4D80BDC9978D935932B991D7') --DOT
    GROUP BY date,token)


    SELECT action,
    count(distinct tx_id) as LP_Count,
    count(distinct liquidity_provider_address) as LPers_Count,
    sum(amount/pow(10,decimal)) as Total_Volume_dot,
    sum(amount*usdprice/pow(10,decimal)) as Total_Volume,
    avg(amount*usdprice/pow(10,decimal)) as Average_Volume
    FROM osmosis.core.fact_liquidity_provider_actions t1
    JOIN price t2
    ON t1.block_Timestamp::Date = t2.date AND t1.currency = t2.token
    WHERE pool_id [0] = '773'
    AND action IN ('pool_joined','pool_exited')
    AND tx_status = 'SUCCEEDED'
    AND date_trunc('day',block_timestamp) <=CURRENT_DATE-1
    GROUP BY action

    Run a query to Download Data