flyingfish2.0 Pear Base query copy
    Updated 2023-12-05
    -- forked from 2.0 Pear Base query @ https://flipsidecrypto.xyz/edit/queries/93f389be-fd48-4acf-a67c-b67c0d98384a

    /*
    0x885b5919 - Create Pear Trade (it has 2 CreateIncreasePosition)
    0xa3a73c09 - Add Collateral (it has 2 CreateIncreasePosition)
    0x40111b02 - Remove Collateral (It has 2 CreateDecreasePosition)
    0x5443c069 - Looks like a close position


    Pear Contracts:
    0x75f688604a58c720e7e4496139765498a2563c78 v0.5
    0x4641D73523ABeeB0F83206DFf5E658692FCB1964 v0.5.1
    0x1DDCa7eaec57d24561e3Ba9A5A0c043868127018 v0.5.5
    */
    with pear_opens AS (
    -- get all tx initiated from the Pear app
    -- contract address = '0x75f688604a58c720e7e4496139765498a2563c78'
    SELECT
    block_timestamp AS request_timestamp
    , origin_from_address
    , decoded_log:indexToken AS index_token
    -- , name
    -- , symbol
    , origin_function_signature
    , decoded_log:amountIn / pow(10, 6) AS request_collateral
    , decoded_log:isLong::boolean AS is_long
    , decoded_log:account AS new_pear_account
    , tx_hash AS request_tx_hash
    , decoded_log AS request_decoded_log
    FROM arbitrum.core.ez_decoded_event_logs
    -- LEFT JOIN arbitrum.core.dim_contracts on index_token = address
    WHERE 1 = 1
    --AND block_timestamp::date >= '2023-09-30' -- first Pear trade date
    AND block_timestamp > '2023-11-26' -- first v0.5.1 trade

    --AND origin_to_address = '0x75f688604a58c720e7e4496139765498a2563c78' -- Pear Contract Address
    Run a query to Download Data