Query editor
with mapping as ( -- list of slp jettons and underlying assetsselect 'NOT-SLP' as asset,upper('0:2ab634cfcbdbe3b97503691e0780c3d07c9069210a2b24b991ba4f9941b453f9') as slp_address,upper('0:2f956143c461769579baef2e32cc2d7bc18283f40d20bb03e432cd603ac33ffc') as underlying_assetunion allselect 'USDT-SLP' as asset,upper('0:aea78c710ae94270dc263a870cf47b4360f53cc5ed38e3db502e9e9afb904b11') as slp_address,upper('0:b113a994b5024a16719f69139328eb759596c38a25f59028b146fecdc3621dfe') as underlying_assetunion allselect 'TON-SLP' as asset,upper('0:8d636010dd90d8c0902ac7f9f397d8bd5e177f131ee2cca24ce894f15d19ceea') as slp_address,upper('TON') as underlying_asset), mints as ( -- get all mints eventselect trace_id, je.amount as slp_amount, block_date, mapping.* from ton.jetton_events jejoin mapping on je.jetton_master = mapping.slp_addresswhereblock_date = cast('2025-01-28' as timestamp) and type = 'mint'and not tx_aborted), deposits as ( -- each mint has deposit-- jettons assetsselect mints.*, je.amount as underlying_asset_amount from ton.jetton_events jejoin mints on mints.block_date = je.block_date and je.trace_id = mints.trace_idand je.jetton_master = mints.underlying_asset and not tx_aborted and mints.underlying_asset != 'TON'union all-- special version for native TON - let's take the first message (contains TON to be deposited + ~0.4 for gas fees) minus the last one (contains excesses)select mints.*, min_by(value, created_lt) - max_by(value, created_lt) as underlying_asset_amount from ton.messages Mjoin mints on mints.block_date = M.block_date and M.trace_id = mints.trace_idand mints.underlying_asset = 'TON'group by 1, 2, 3, 4, 5, 6)select block_date, asset, slp_address, underlying_asset, cast(cast(1.0 as double) * sum(underlying_asset_amount) / sum(slp_amount) as double) as pricefrom depositsgroup by 1, 2, 3, 4