rw2023$HADES POL emission
    Updated 2023-09-28
    -- forked from marqu / hsb - [p1p2] claimed HADES @ https://flipsidecrypto.xyz/marqu/q/2023-02-22-05-14-pm-QChPXl

    with

    bonding_phase as (

    select distinct

    signers[0] as wallet,
    signers[1] as bond_acc,
    case
    when block_timestamp < '2023-02-07' then 'Phase I'
    else 'Phase II'
    end as phase
    from solana.core.fact_events events
    inner join solana.core.fact_transactions txs
    using(block_timestamp, tx_id, succeeded)
    inner join lateral flatten (input => log_messages) f
    where succeeded
    and block_timestamp > '2023-02-02' -- p1 start
    and block_timestamp < '2023-02-17' -- p2 end
    and program_id = '8NvmvWEAw89HnE8Gjo4kHhbHy2PGyeuU9y9QJ1HKiLoR'
    and (f.value = 'Program log: Instruction: SellNftForBond'
    or f.value = 'Program log: Instruction: BuyBondWithSol') -- include all bond accs
    ),

    claiming_txs as (

    select

    block_timestamp,
    tx_id,
    signers[0] as wallet,
    bond_acc,
    phase,
    Run a query to Download Data