freemartianLock Time copy
    Updated 2025-01-09
    -- forked from Lock Time @ https://flipsidecrypto.xyz/studio/queries/aa351060-521e-4424-b47b-607174db1c33


    with
    prices AS(
    SELECT
    hour,
    price,
    symbol,
    ROW_NUMBER() OVER (ORDER BY hour DESC) AS row_num
    FROM base.price.ez_prices_hourly
    WHERE symbol ilike 'PRIME'
    AND hour::date = current_date
    qualify row_num = 1
    ),

    deposits AS(
    SELECT
    block_timestamp,
    tx_hash,
    decoded_log:amount/pow(10,18) as amount,
    decoded_log:user as user,
    to_timestamp(decoded_log:createdTimestamp) as createdTimestamp,
    to_timestamp(decoded_log:endTimestamp) as endTimestamp,
    DATEDIFF(DAY, createdTimestamp, endTimestamp) AS difference_in_days,
    decoded_log:depositIndex as depositIndex,
    decoded_log,
    event_name
    FROM base.core.ez_decoded_event_logs
    WHERE origin_function_signature = '0xf104489f'
    AND block_timestamp::date >= '2024-06-01'
    AND origin_to_address = '0xfa980ced6895ac314e7de34ef1bfae90a5add21b'
    AND contract_address = '0x75a44a70ccb0e886e25084be14bd45af57915451'
    -- and decoded_log:depositIndex IS NOT NULL
    and decoded_log:depositIndex = 0
    ),
    Auto-refreshes every 1 hour
    QueryRunArchived: QueryRun has been archived