Query editor
with date_range as (select cast(timestamp as date) as dayfrom utils.dayswhere timestamp >= current_date - interval '90' dayand timestamp <= current_timestamp),raw_events as (selectdate as day,timestamp_ms,event_index,json_extract_scalar(event_json, '$.coin_type.name') as token,try_cast(json_extract_scalar(event_json, '$.available_amount.value') as double) as available_amount,try_cast(json_extract_scalar(event_json, '$.supply_amount.value') as double) as supply_amount,try_cast(json_extract_scalar(event_json, '$.borrowed_amount.value') as double) as borrowed_amount,try_cast(json_extract_scalar(event_json, '$.available_amount_usd_estimate.value') as double) as available_amount_usd,try_cast(json_extract_scalar(event_json, '$.supply_amount_usd_estimate.value') as double) as supply_amount_usd,try_cast(json_extract_scalar(event_json, '$.borrowed_amount_usd_estimate.value') as double) as borrowed_amount_usd,try_cast(json_extract_scalar(event_json, '$.supply_apr.value') as double) as supply_apr,try_cast(json_extract_scalar(event_json, '$.borrow_apr.value') as double) as borrow_aprfrom sui.eventswhere date >= current_date - interval '90' dayand event_type = '0xf95b06141ed4a174f239417323bde3f209b972f5930d8521ea38a52aff3a6ddf::reserve::ReserveAssetDataEvent'and json_extract_scalar(event_json, '$.coin_type.name') != '76cb819b01abed502bee8a702b4c2d547532c12f25001c9dea795a5e631c26f1::fud::FUD'),ranked_events as (select*,row_number() over (partition by day, tokenorder by timestamp_ms desc, event_index desc) as rnfrom raw_events),daily_events as (select *from ranked_eventswhere rn = 1),token_labels as (select *from (values('0000000000000000000000000000000000000000000000000000000000000002::sui::SUI', 'SUI'),('83556891f4a0f233ce7b05cfe7f957d4020492a34f5405b2cb9377d060bef4bf::spring_sui::SPRING_SUI', 'sSUI'),('dba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7::usdc::USDC', 'USDC'),('375f70cf2ae4c00bf37117d0c85a2c71545e6ee05c4a5c7d282cd66a4504b068::usdt::USDT', 'USDT'),('c060006111016b8a020ad5b33834984a437aaa7d3c74c18e09a95d48aceab08c::coin::COIN', 'wUSDT'),('5d4b302506645c37ff133b98c4b50a5ae14841659738d6d733d59d0d217a93bf::coin::COIN', 'wUSDC'),('d0e89b2af5e4910726fbcd8b8dd37bb79b29e5f83f7491bca830e94f7f226d29::eth::ETH', 'ETH'),('aafb102dd0902f5055cadecd687fb5b71ca82ef0e0285d90afde828ec58ca96b::btc::BTC', 'BTC'),('0041f9f9344cac094454cd574e333c4fdb132d7bcc9379bcd4aab485b2a63942::wbtc::WBTC', 'WBTC'),('876a4b7bce8aeaef60464c11f4026903e9afacab79b9b142686158aa86560b50::xbtc::XBTC', 'XBTC'),('3e8e9423d80e1774a7ca128fccd8bf5f1f7753be658c5e645929037f7c819040::lbtc::LBTC', 'LBTC'),('2053d08c1e2bd02791056171aab0fd12bd7cd7efad2ab8f6b9c8902f14df2ff2::ausd::AUSD', 'AUSD'),('356a26eb9e012a68958082340d4c4116e7f55615cf27affcff209cf0ae544f59::wal::WAL', 'WAL'),