flyingfishd - Daily Stats
    Updated 2023-10-18
    with raw_data AS (
    SELECT
    block_timestamp
    , origin_from_address AS wallet
    , decoded_log:indexToken AS index_token
    , name
    , symbol
    , decoded_log:amountIn / pow(10, 6) AS pos_size
    , decoded_log:sizeDelta / pow(10, 30) AS open_size
    , open_size / pos_size AS leverage
    , decoded_log:isLong::boolean AS is_long
    , decoded_log:executionFee / pow(10, 18) AS execution_fee
    , tx_hash
    FROM arbitrum.core.ez_decoded_event_logs
    LEFT JOIN arbitrum.core.dim_contracts on index_token = address
    -- WHERE block_timestamp::date > current_date - 2
    WHERE block_timestamp > '2023-08-30'
    AND origin_to_address = '0x75f688604a58c720e7e4496139765498a2563c78' -- Pear Contract Address
    AND event_name = 'CreateIncreasePosition'
    AND tx_status = 'SUCCESS'
    ORDER BY event_index
    )
    SELECT
    date_trunc(week, block_timestamp) AS date
    , symbol
    , count(DISTINCT wallet) AS pear_users
    , count(DISTINCT tx_hash) AS pear_trades
    , sum(pos_size) AS collateral
    FROM raw_data
    GROUP BY all
    ORDER BY date, collateral DESC


    Run a query to Download Data