Query editor
/* pass 1: calc prices using mint and burn amounts */with glp_inflow as (selectevt_block_time,-- evt_tx_hash,usdgAmount / 1e18 as usd_in,mintAmount / 1e18 as shares_mintedfrom gmx_arbitrum.GlpManager_evt_AddLiquidity -- old GLP Manager contract: https://arbiscan.io/address/0x321f653eed006ad1c29d174e17d96351bde22649#codeunionselectevt_block_time,-- evt_tx_hash,usdgAmount / 1e18 as usd_in,mintAmount / 1e18 as shares_mintedfrom gmx_arbitrum.GlpManager_updated_evt_AddLiquidity -- new GLP Manager contract: https://arbiscan.io/address/0x3963FfC9dff443c2A94f21b129D429891E32ec18#code),glp_outflow as (selectevt_block_time,-- evt_tx_hash,usdgAmount / 1e18 as usd_out,glpAmount / 1e18 as shares_burnedfrom gmx_arbitrum.GlpManager_evt_RemoveLiquidity -- old GLP manager contractunionselectevt_block_time,usdgAmount / 1e18 as usd_out,glpAmount / 1e18 as shares_burnedfrom gmx_arbitrum.GlpManager_updated_evt_RemoveLiquidity -- new GLP manager contract),-- calc GLP buy and sell pricesglp_buy_prices_01 as (select evt_block_time as dttm, 'buy' as action, usd_in / shares_minted as price from glp_inflow),glp_sell_prices_01 as (select evt_block_time as dttm, 'sell' as action, usd_out / shares_burned as price from glp_outflow),/* pass 2: directly look up prices from the updated GLP managerpass 1 is still needed because pass 2 won't get data before 2023*/glp_buy_prices_02 as (select call_block_time as dttm, 'buy' as action, output_0 / 1e30 as pricefrom gmx_arbitrum.GlpManager_updated_call_getPricewhere call_success = true and _maximise = true -- _maximise = true implies buy price),glp_sell_prices_02 as (select call_block_time as dttm, 'sell' as action, output_0 / 1e30 as pricefrom gmx_arbitrum.GlpManager_updated_call_getPricewhere call_success = true and _maximise = false -- _maximise = false implies sell price),/* stack pass1 and pass2 price tables */glp_prices as (select * from glp_buy_prices_01unionselect * from glp_buy_prices_02unionselect * from glp_sell_prices_01union