adriaparcerisasNet $THOR Staked
    Updated 2024-12-19
    WITH
    prices as (
    SELECT
    trunc(block_timestamp,'month') as date,
    avg(asset_usd) as price
    from thorchain.price.fact_prices
    where block_timestamp>=trunc(current_date,'month')
    and pool_name = 'ETH.THOR-0XA5F2211B9B8170F694421F2046281775E8468044'
    group by 1
    ),
    table1 AS (
    SELECT DISTINCT tx_hash
    FROM ethereum.core.fact_decoded_event_logs
    WHERE block_timestamp >= '2022-05-01'
    AND contract_address = LOWER('0xa5f2211B9b8170F694421f2046281775E8468044')
    --LIMIT 1000
    ),
    table2 AS (
    SELECT DISTINCT e.tx_hash
    FROM ethereum.core.fact_decoded_event_logs e
    JOIN table1 a ON a.tx_hash = e.tx_hash
    WHERE e.block_timestamp >= '2022-05-01'
    AND decoded_log:to = LOWER('0x815c23eca83261b6ec689b60cc4a58b54bc24d8d')
    AND event_name = 'Transfer'
    ), --select * from table2
    table3 AS (
    SELECT DISTINCT e.tx_hash
    FROM ethereum.core.fact_decoded_event_logs e
    JOIN table2 b ON b.tx_hash = e.tx_hash
    WHERE e.block_timestamp >= '2022-05-01'
    and event_name = 'DelegateVotesChanged'
    ), --select * from table3
    table4 as (
    SELECT block_timestamp as times,
    CASE WHEN e.event_name = 'Transfer'
    AND contract_address = '0xa5f2211b9b8170f694421f2046281775e8468044'
    QueryRunArchived: QueryRun has been archived