TheLaughingManVRTX Staking Totals FINAL
    Updated 2024-12-13
    -- forked from VRTX Staking Totals (updated contracts) @ https://flipsidecrypto.xyz/studio/queries/38f4e527-d13d-401b-a707-e6f240f8cdf8

    -- forked from VRTX Staking @ https://flipsidecrypto.xyz/studio/queries/efaed75a-c622-40cb-bf13-c162ebbcec5f

    with base as (
    with merge as (
    SELECT
    block_timestamp::date as ddate
    , stake_action as label
    , SUM ( CASE WHEN stake_action='stake' THEN AMOUNT_USD ELSE AMOUNT_USD *(-1) END) as amount_usd
    , SUM ( CASE WHEN stake_action='stake' THEN AMOUNT ELSE AMOUNT *(-1) END ) as amount_token
    from arbitrum.vertex.ez_staking_actions
    WHERE 1=1
    AND stake_action!='migrate-stake'
    AND symbol = 'VRTX'
    GROUP BY ddate, label
    -- UNION ALL
    -- --NEW Contract
    -- SELECT
    -- block_timestamp::date as ddate
    -- , CASE WHEN TO_ADDRESS = lower('0x6e89C20F182b1744405603958eC5E3fd93441cc4') THEN 'stake' ELSE 'withdraw/claim' END as label
    -- , SUM( CASE WHEN label='stake' THEN AMOUNT_USD ELSE AMOUNT_USD * (-1) END) as amount_usd
    -- , SUM( CASE WHEN label='stake' THEN AMOUNT ELSE AMOUNT* (-1) END) as amount_token
    -- from arbitrum.core.ez_token_transfers
    -- WHERE 1=1
    -- AND (
    -- TO_ADDRESS = lower('0x6e89C20F182b1744405603958eC5E3fd93441cc4')
    -- OR FROM_ADDRESS = lower('0x6e89C20F182b1744405603958eC5E3fd93441cc4')
    -- )
    -- --AND (from_address != lower('0x5Be754aD77766089c4284d914F0cC37E8E3F669A')) --auto migration crap?/previous stake contract
    -- AND contract_address = lower('0x95146881b86B3ee99e63705eC87AfE29Fcc044D9')
    -- GROUP BY 1, 2
    )
    SELECT
    QueryRunArchived: QueryRun has been archived