Query editor
with purchases as (selectsum(amount_usd) / sum(token_bought_amount) as avg_buy_price, sum(amount_usd) as total_amount_bought, token_bought_symbolfrom uniswap.tradeswhere taker = {{wallet address}} -- 0xf13d1a51fd57ce43c9b61b29b253aff1aaa9b659group by token_bought_symbollimit 10),higher_price as (selectamount_usd / token_bought_amount as higher_pfrom uniswap.tradeswhere token_bought_symbol = 'HIGHER'and amount_usd is not nullorder by block_time DESClimit 1),degen_price as (selectamount_usd / token_bought_amount as degen_pfrom uniswap.tradeswhere token_bought_symbol = 'DEGEN'and amount_usd is not nullorder by block_time DESClimit 1)select*, casewhen token_bought_symbol = 'DEGEN' then ((degen_p - avg_buy_price) / avg_buy_price) * total_amount_boughtelse ((higher_p - avg_buy_price) / avg_buy_price) * total_amount_boughtend as current_plfrom purchasesleft join higher_price on 1=1left join degen_price on 1=1