jackguyOpening Positions 2
    Updated 2022-06-27
    WITH tab1 as (
    SELECT DISTINCT tx_hash
    -- date_trunc('day', block_timestamp) as day,
    -- CASE WHEN ORIGIN_FUNCTION_SIGNATURE LIKE '0xded700a6' THEN 'increase_position'
    -- WHEN ORIGIN_FUNCTION_SIGNATURE LIKE '0x72ada4c5' THEN 'terminate' END as tx_type,
    -- count(DISTINCT ORIGIN_FROM_ADDRESS) as users,
    -- count(DISTINCT tx_hash) as transactions
    FROM polygon.core.fact_event_logs
    --WHERE contract_address LIKE lower('0x059d306A25c4cE8D7437D25743a8B94520536BD5')
    WHERE (ORIGIN_FUNCTION_SIGNATURE LIKE '0x6b29e1bd')
    --GROUP BY 1,2
    LIMIT 100
    -- 0xded700a6 increase
    -- 0x72ada4c5 as
    )

    SELECT
    date_trunc('minute', block_timestamp),
    address_name,
    raw_amount / CASE WHEN address_name LIKE 'hop protocol: usdc l2canonicalbridge' or address_name LIKE 'hop protocol: usdt l2canonicalbridge' THEN 1000000 ELSE 1000000000000000000 END
    from polygon.core.fact_token_transfers
    LEFT OUTER JOIN polygon.core.dim_labels
    ON address = contract_address
    WHERE tx_hash in (SELECT * from tab1)

    Run a query to Download Data