CryptoIcicleThor-93.$THOR Staking Reward + APY - Daily
    Updated 2022-05-25
    -- $THOR Staking Reward + APY
    -- Payout 49.67 RUNE
    -- Grand Prize 149.01 RUNE
    -- Level Intermediate

    -- Q93. Since vTHOR and THOR Staking 2.0 was released in May, we’re interested in finding out more about how the community has embraced the staking rewards.
    -- Show the daily / weekly staking rewards and calculate the daily / weekly APR for $THOR stakers. How has it progressed since staking was introduced?

    WITH a AS (
    SELECT DISTINCT tx_id
    FROM ethereum.events_emitted
    WHERE block_timestamp >= '2022-05-04'
    AND contract_address = LOWER('0xa5f2211B9b8170F694421f2046281775E8468044')
    ), b AS (
    SELECT DISTINCT e.tx_id
    FROM ethereum.events_emitted e
    JOIN a ON a.tx_id = e.tx_id
    WHERE block_timestamp >= '2022-05-04'
    AND tx_to_address = LOWER('0x815c23eca83261b6ec689b60cc4a58b54bc24d8d')
    AND event_name = 'Deposit'
    ), c AS (
    SELECT DISTINCT e.tx_id
    FROM ethereum.events_emitted e
    JOIN b ON b.tx_id = e.tx_id
    WHERE block_timestamp >= '2022-05-04'
    AND tx_to_address = LOWER('0x815c23eca83261b6ec689b60cc4a58b54bc24d8d')
    AND event_name = 'DelegateVotesChanged'
    ),
    staking_txns as (
    SELECT block_timestamp::date AS date
    , CASE WHEN e.event_name = 'Transfer'
    AND contract_address = '0xa5f2211b9b8170f694421f2046281775e8468044'
    AND LENGTH(event_inputs:value::string) <= 25
    THEN CAST(event_inputs:value::string AS INT) * POWER(10, -18)
    ELSE 0 END AS thor_amt
    , *
    Run a query to Download Data