purifBVT rewards over time for $100 of bero staked
    Updated 2025-01-30
    -- forked from Beradrome BGT @ https://flipsidecrypto.xyz/studio/queries/bd80cef6-848a-46eb-ada7-e7a1943bf902

    /*select sum((utils.udf_hex_to_int(substr(data,3,66))::int)/1e18) as amount from berachain.testnet.fact_event_logs
    where origin_function_signature='0xc00007b0'
    and contract_address=lower('0xbDa130737BDd9618301681329bF2e46A016ff9Ad')
    and topics[0]='0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef'*/

    with bero_staked as (
    select date_trunc('day',block_timestamp) as time, sum((utils.udf_hex_to_int(substr(data,3,66))::int)/1e18) as staked from berachain.testnet.fact_event_logs
    where topics[0]='0x9e71bc8eea02a63969f509818f2dafb9254532904319f9dbda79b67bd34a5f3d'
    and contract_address=lower('0xA0E4748E68b6d73234711197e96171B896B796f4')
    and concat('0x',substr(TOPICS[1], 27,64))=lower('{{address}}')
    group by 1
    ),
    bgt_claims as (
    select date_trunc('day',block_timestamp) as time, sum((utils.udf_hex_to_int(substr(data,3,66))::int)/1e18) as bgt_claimed from berachain.testnet.fact_event_logs
    where topics[0]='0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef'
    and ORIGIN_TO_ADDRESS=lower('0xA0E4748E68b6d73234711197e96171B896B796f4')
    and concat('0x',substr(TOPICS[2], 27,64))=lower('{{address}}')
    group by 1
    ),
    claim_bribes as (
    select date_trunc('day',block_timestamp) as time, sum((utils.udf_hex_to_int(substr(data,3,66))::int)/1e18) as bera_claimed from berachain.testnet.fact_event_logs
    where topics[0]='0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef'
    and ORIGIN_TO_ADDRESS=lower('0x1f9505Ae18755915DcD2a95f38c7560Cab149d9C')
    and concat('0x',substr(TOPICS[2], 27,64))=lower('{{address}}')
    group by 1
    ),
    multiplier as (
    select staked/2 as mult from bero_staked --roughly $100 worth of bero
    ),
    bera_price as (
    select value['address'] as token_address, value['price'] as usd_price from (
    select live.udf_api(
    'GET',
    'https://bartio.api.oogabooga.io/v1/prices',
    QueryRunArchived: QueryRun has been archived