Query editor
withveBAL as (selectdate_trunc('day',call_block_time) as day,output_0/1e18 as total_veBAL_supplyfrombalancer_ethereum.veBAL_call_totalSupply--order by date_trunc('day',call_block_time) desc),price AS (SELECT AVG(price) AS price,contract_address AS tokenAddress,DATE(minute) AS block_dateFROM prices.usdWHERE contract_address = 0xba100000625a3754423978a60c9317c58a424e3dAND minute > cast('2022-05-01 00:00' as timestamp)GROUP BY DATE(minute), contract_address),votes as (selectdate_trunc('week',end_date) as week,sum(vote) as weekly_votefrom balancer_ethereum.vebal_votesgroup by 1order by week desc--limit 5),joigned as (SELECTday,total_veBAL_supply AS total_vebal,weekly_voteFROM veBAL, votes--left join votes w on w.weekly _vote = v.vebal--GROUP BY 1,3),vote_rate as (selectday,total_vebal,weekly_vote,weekly_vote/total_vebal as pctfrom joignedorder by day desc)-- dolper AS (SELECTv.day,(p.price * 122000 / (v.total_veBAL_supply * j.pct)) AS emmission_per_veBALFROMveBAL vleft join price p on v.day = p.block_dateleft join vote_rate j on v.day = j.daygroup by 1, 2order by v.day desc