Query editor
withrates as (SELECTcall_account_arguments[1] as account_mint, to_base58(bytearray_substring(call_data,1+1+1,32)) as authority, bytearray_to_bigint(bytearray_reverse(bytearray_substring(call_data,1+1+32+1,32))) as rate, call_tx_id, date_trunc('day',call_block_time) as start_dateFROM spl_token_2022_solana.spl_token_2022_call_interestBearingMintExtensionWHERE bytearray_substring(call_data,1+1,1) = 0x00UNION ALLSELECTcall_account_arguments[1] as account_mint, call_account_arguments[2] as authority, bytearray_to_bigint(bytearray_reverse(bytearray_substring(call_data,1+1+1,32))) as rate, call_tx_id, date_trunc('day',call_block_time) as start_dateFROM spl_token_2022_solana.spl_token_2022_call_interestBearingMintExtensionWHERE bytearray_substring(call_data,1+1,1) = 0x01), rates_filled as (SELECTaccount_mint, authority, cast(rate as double) as rate, call_tx_id, start_date, COALESCE(lead(start_date, 1) OVER (PARTITION BY account_mint ORDER BY start_date asc),date_trunc('day',now())) as end_date --get end_date from the next start, or use todayFROM rates), rates_weighted as (SELECTaccount_mint, authority, rate as rate_basis, rate/10000 as rate_percent --basis points, start_date, end_date, cast(date_diff('day',start_date,end_date) as double) as period, cast(date_diff('day',start_date,end_date) as double)/365 as period_weight, (EXP(rate/10000 * (date_diff('day',start_date,end_date) / 365.0)) - 1) AS period_return, call_tx_idFROM rates_filled r-- QA-- WHERE account_mint = 'F1w67RBi8ttBJe2KVxvjXoy3K2Nxe1kwtur3MU8HRU9M')-- SELECT-- *-- FROM rates_weighted--TODO: join top related outer programSELECTget_href(get_chain_explorer('solana') || '/account/' || account_mint, COALESCE('✅ ' || tk.symbol,substring(account_mint,1,10) || '...')) as mint_linked, account_mint, min(start_date) as init_date, sum(period) as days_old, count(*) as rate_changes