Query editor
Select '<a href="https://arbiscan.io/address/' || CAST(user AS VARCHAR) || '" target="_blank">' || CONCAT('👤 ', COALESCE(ens.name, CAST(user as VARCHAR))) || '</a>' as "User",TRUNCATE(sum(round(pnlUsd,2))) as pnl, -- Premiums Received Minus Premiums Spent (Plus Exercise Proceeds Once Settled)TRUNCATE(sum(round(deployed,2))) as deployed, -- Total SpentFORMAT('%s%%',ROUND(sum(pnlUsd)/sum(deployed)*100))as percent, --pnl/deployedROUND(sum(pnlUsd)/sum(deployed)*100) as percentRank, --percent for desc order onlysum(round(usdValue,2)) as notional, -- usd val of options traded (contracts * strike)count(DISTINCT pool) as products, -- Total Products Tradedsum(trades) as trades, -- total tradesmax(maxOpen) as lastTrade -- last trade timeFROM(selectuser,pool,poolName,maturity,min(block_time) FILTER (where Type = 'Trade') as minOpen,max(block_time) FILTER (where Type = 'Trade') as maxOpen,max(block_time) FILTER (where Type = 'Settle') as maxSettle,count(user) FILTER (where Type = 'Trade') as trades,sum(round(pnlUsd,2)) as pnlUsd,sum(round(abs(deployed),2)) as deployed,sum(round(usdValue,2)) as usdValueFROM(select user, pool, poolName, maturity, block_time, pnlUsd, usdValueBase as "usdValue", 'Trade' as "Type", pnlUsd as deployedFROM dune.premia.result_v3_ref_trade_master -- query_3251869 -- Normal TradesWHERE maturity > TIMESTAMP '2024-07-22 08:00' and isBuy = 1-- AND block_time > TIMESTAMP '2023-12-08 08:00' --Trade Date Week 1 Start-- AND block_time < TIMESTAMP '2023-12-15 08:00' --Trade Date Week 1 EndUNIONselect user, pool, poolName, maturity, block_time, pnlUsd, usdValueBase as "usdValue", 'Trade' as "Type", usdValueBase-pnlUsd as deployedFROM dune.premia.result_v3_ref_trade_master -- query_3251869 -- Normal TradesWHERE maturity > TIMESTAMP '2024-07-22 08:00' and isBuy = 0-- AND block_time > TIMESTAMP '2023-12-08 08:00' --Trade Date Week 1 Start-- AND block_time < TIMESTAMP '2023-12-15 08:00' --Trade Date Week 1 EndUNIONselect user, pool, poolName, maturity, block_time, pnlUsd, usdValue, 'Settle' as "Type", 0 as deployedFROM dune.premia.result_pools_exercise_settle_v2 -- query_3261931 --Exercise & SettleWHERE maturity > TIMESTAMP '2024-07-22 08:00'-- AND block_time > TIMESTAMP '2023-12-08 08:00' --Settle Date Week 1 Start-- AND block_time < TIMESTAMP '2023-12-18 00:00' --Settle Date Week 1 EndUNIONselect provider, pool, poolName, maturity, block_time, pnlUsd, usdValueBase as "usdValue", 'Trade' as "Type", usdValueBase-pnlUsd as deployedFROM dune.premia.result_v3_ref_trade_master -- query_3251869 -- Orderbook Sellswhere invSource = 'orderbook' and maturity > TIMESTAMP '2024-07-22 08:00' and isBuy = 1-- AND block_time > TIMESTAMP '2023-12-08 08:00' --Trade Date Week 1 Start-- AND block_time < TIMESTAMP '2023-12-15 08:00' --Trade Date Week 1 EndUNIONselect provider, pool, poolName, maturity, block_time, (pnlUsd*-1) as pnlUsd, usdValueBase as "usdValue", 'Trade' as "Type", pnlUsd as deployedFROM dune.premia.result_v3_ref_trade_master -- query_3251869 -- Orderbook Buyswhere invSource = 'orderbook' and maturity > TIMESTAMP '2024-07-22 08:00' and isBuy = 0-- AND block_time > TIMESTAMP '2023-12-08 08:00' --Trade Date Week 1 Start-- AND block_time < TIMESTAMP '2023-12-15 08:00' --Trade Date Week 1 End)WHERE maturity > TIMESTAMP '2024-07-22 08:00' -- Only Maturities after trade comp begingroup by 1,2,3,4) aLEFT JOIN ens.reverse_latest ens on ens.address = a.user-- WHERE minOpen > TIMESTAMP '2023-12-08 00:00' -- Exclude positions opened before trade comp