maybeyonaseth_rem_opyn_positions
    Updated 2022-09-18
    with
    sqth_price as (
    select
    date(block_timestamp) as date,
    avg(price_1_0) as opyn_price_eth
    from ethereum.uniswapv3.ez_pool_stats
    where pool_address = '0x82c427adfdf2d245ec51d8046b41c4ee87f0d29c'
    group by 1
    ),
    shorts as (
    select
    block_timestamp,
    tx_hash,
    regexp_substr_all(SUBSTR(DATA, 3, len(DATA)), '.{64}') AS segmented_data,
    '0x'|| substr(segmented_data[0],25) as user,
    ethereum.public.udf_hex_to_int(segmented_data[1])/pow(10,18) as amount,
    ethereum.public.udf_hex_to_int(segmented_data[2]) as vault
    from ethereum.core.fact_event_logs
    where contract_address = '0x64187ae08781b09368e6253f9e94951243a493d5'
    and topics[0] = '0xb19fa182730a088464dad0e9e0badeb470d0d8d937d854f5caf15c6ad1992c36'
    ),
    longs as (
    select
    block_timestamp,
    tx_hash,
    origin_from_address as user,
    event_inputs:value/pow(10,18) as amount
    from ethereum.core.fact_event_logs
    where contract_address = '0xf1b99e3e573a1a9c5e6b2ce818b617f0e664e86b'
    and event_name = 'Transfer'
    and event_inputs:from::string = '0x82c427adfdf2d245ec51d8046b41c4ee87f0d29c' -- uniswap pool
    ),
    positions as (
    select
    block_timestamp,
    tx_hash,
    Run a query to Download Data