Query editor
with---------------------- NFT & Vault info--------------------nft_data as (selectevt_tx_hash as tx_hash, evt_block_time as block_time, evt_block_date as block_date, chain as blockchain, vault, "user" as "user", tokenId as nft_idfrom fluid_multichain.fluidvaultfactory_evt_newpositionmintedwhere tokenId = {{nft_id}}and chain = '{{blockchain}}'), nft_vault as (select n.nft_id, v.*from dune."0xfluid".result_fluid_vaults as vinner join nft_data as non v.address = n.vaultand v.blockchain = n.blockchain), timeline_nft as (select timestamp as dayfrom utils.dayswhere timestamp >= date_trunc('day', (select min(block_time) from nft_data)))----------------- Ref-token price-- USD → USDC (ethereum)-- ETH → WETH (ethereum)-- BTC → WBTC (ethereum)-- Prices are always sourced from ethereum mainnet — the ref asset is just a-- denomination for PnL, it doesn't need to live on the position's chain.---------------, ref_token_mapped as (selectcase '{{ref_token}}'when 'USD' then 0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48when 'ETH' then 0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2when 'BTC' then 0x2260fac5e5542a773aa44fbcfedf7c193bc2c599end as price_token, 'ethereum' as price_blockchain), ref_token_prices as (selectdate_trunc('day', p.minute) as day, approx_percentile(p.price, 0.5) as pricefrom prices.usd as pinner join ref_token_mapped as mon p.contract_address = m.price_tokenand p.blockchain = m.price_blockchain