Query editor
-- Blackhole DEX (Algebra CL) on Avalanche: Hourly Emissions APY + Fee APY + TVL-- BLACK token: 0x40dedf55455641d39931623942bafa9974951881 (BZBLACK, 18 decimals)-- GaugeManager (DistributeReward emitter): 0xe9a9a87345067d4b70b031dd731f41d9c0893bd6-- AlgebraFactory: 0x512eb749541B7cf294be882D636218c84a5e9E5FWITH-- CL pools from AlgebraFactory (both standard and custom)v3_pools AS (SELECT token0, token1, pool AS pool_addressFROM blackhole_avalanche_c.algebrafactory_evt_poolUNIONSELECT token0, token1, pool AS pool_addressFROM blackhole_avalanche_c.algebrafactory_evt_custompool),-- Gauge -> Pool mapping (DISTINCT to deduplicate repeated view calls)gauge_pool AS (SELECT DISTINCT _0 AS pool_address, output_0 AS gauge_addressFROM blackhole_avalanche_c.gaugemanager_call_gaugesWHERE output_0 != 0x0000000000000000000000000000000000000000),-- Latest fee per pool from fee-change events (in ppm, same as Uniswap V3)pool_fee AS (SELECT contract_address AS pool_address,LAST_VALUE(fee) OVER (PARTITION BY contract_addressORDER BY evt_block_timeROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS fee_ppmFROM blackhole_avalanche_c.algebrapool_evt_feeQUALIFY ROW_NUMBER() OVER (PARTITION BY contract_address ORDER BY evt_block_time DESC) = 1),token_info AS (SELECT contract_address AS address, symbol, decimalsFROM tokens.erc20 WHERE blockchain = 'avalanche_c'),-- DistributeReward events → epoch-level emissions per gaugedistribute_events AS (SELECTCAST(date_trunc('week', evt_block_time + INTERVAL '4' DAY) AS TIMESTAMP) - INTERVAL '4' DAY AS epoch_ts,gauge AS gauge_address,CAST(amount AS DOUBLE) / 1e18 AS black_emittedFROM blackhole_avalanche_c.gaugemanager_evt_distributereward),pool_epoch_emissions AS (SELECT gp.pool_address, de.epoch_ts,SUM(de.black_emitted) AS black_emitted,SUM(de.black_emitted) / 7.0 AS black_per_dayFROM distribute_events deJOIN gauge_pool gp ON gp.gauge_address = de.gauge_addressGROUP BY 1, 2),latest_pool_emissions AS (SELECT pool_address, black_emitted, black_per_day, epoch_ts