Query editor
-- BD/USDC basic-pool AERO emissions APR on Aerodrome BaseWITHparams AS (SELECT0xffdf1e3160b60c2e499fa25e51b5c192b9b15e3b AS pool,0x252d36f435582ecb01686448d21e8c9ea0b2ca65 AS bd,0x833589fcd6edb6e08f4c7c32d4f71b54bda02913 AS usdc,0x940181a94a35a4569e4529a3cdfb74e38fd98631 AS aero),clock AS (SELECTdate_trunc('day', now()) AS current_day),-- Find the gauge associated with the BD/USDC pool.gauge AS (SELECTmax_by(c.output_gauge, c.call_block_time) AS gaugeFROM aerodrome_base.GaugeFactory_call_createGauge cCROSS JOIN params pWHERE c.call_success = TRUEAND c._pool = p.pool),bounds AS (SELECTCAST(date_trunc('day', min(s.evt_block_time)) AS timestamp) AS first_dayFROM aerodrome_base.Pool_evt_Sync sCROSS JOIN params pWHERE s.contract_address = p.pool),days AS (SELECTd.dayFROM bounds bCROSS JOIN clock cCROSS JOIN UNNEST(sequence(b.first_day,CAST(c.current_day AS timestamp),interval '1' day)) AS d(day)),/* -------------------------------------------------------------------------POOL RESERVESUse the final Sync event from each day. AVG(reserves) would weight theresult according to the number of swaps/Sync events during that day.--------------------------------------------------------------------------- */sync_ranked AS (SELECTdate_trunc('day', s.evt_block_time) AS day,CAST(s.reserve0 AS double) / 1e18 AS bd_reserve,CAST(s.reserve1 AS double) / 1e6 AS usdc_reserve,row_number() OVER (