Query editor
-- WITH coll_size_usd_table0 AS (-- SELECT-- custody_collateral_key,-- sum(size_usd) as size_usd-- FROM (-- SELECT-- owner-- ,position_key-- ,case when position_side = 1 then 'long' else 'short' end as position_side-- ,custody_collateral_key-- ,custody_position_key-- ,sum((case when position_change = 'increase' then 1 else -1 end)*size_usd) as size_usd-- ,sum((case when position_change = 'increase' then 1 else -1 end)*collateral_usd - fee_usd) as collateral_usd-- ,sum(fee_usd/(collateral_usd/collateral_token)) as fee_notional-- ,sum(fee_usd) as fee_usd-- ,sum(liq_fee_usd) as liq_fee_usd-- ,(sum(size_usd*price_usd) filter (where position_change = 'increase'))-- /(sum(size_usd) filter (where position_change = 'increase')) as entry_price_usd --weighted average entry price of purchases only-- ,sum((case when pnl_direction=0 then -1 else 1 end)*pnl_usd) as pnl_usd --taken in the form of the collateral token-- FROM query_3338071-- where-- block_time <= TRY_CAST('2025-01-01 00:00:00' AS TIMESTAMP)-- and block_time >= (TRY_CAST('2025-01-01 00:00:00' AS TIMESTAMP) - interval '8' hour)-- GROUP BY 1,2,3,4,5-- ) s1-- where-- entry_price_usd is not null-- and size_usd > 0-- GROUP BY custody_collateral_key-- ),WITH coll_size_usd_table AS (SELECTposition_collateral_mint,sum(size_usd) as size_usdFROMquery_3343518WHEREentry_price_usd is not nulland size_usd > 0group by1)SELECTsol_coll_size_usd / (sol_balance * sol_price) as sol_utilization,eth_coll_size_usd / (eth_balance * eth_price) as eth_utilization,btc_coll_size_usd / (btc_balance * btc_price) as btc_utilizationFROM (select(selectsize_usdfrom coll_size_usd_tablewhereposition_collateral_mint = 'So11111111111111111111111111111111111111112') as sol_coll_size_usd,(selectsize_usdfrom coll_size_usd_table