Query editor
/*@title: Morpho V2 - Markets Data@description: Provides an overview of Morpho markets@author: Steakhouse Financial@references:1) https://morpho.blockanalitica.com/ethereum/markets2) https://legacy.morpho.org/market?id={MARKET_ID_HERE}&network=mainnet3) V1 query: https://dune.com/queries/3957276@data validation:1) check shares for ethereum/base markets: etherscan/basescan -> 0xBBBBBbbBBb9cC5e90e3b3Af64bdAF62C37EEFFCb -> market({ID})@definitions:- Assets: amount of the underlying token (asset) that the contract holds (ie: USDC)- Shares: tokens issued by the market to represent a user’s proportional ownership of the underlying assets- Share Price: conversion rate between shares & assets that increases over time as interest accruesgives how many underlying tokens (eg: USDT) correspond to 1 share@translation to Lending Markets query:supply share price -> supply indexborrow share price -> borrow index@dev: amounts are not tracked because they don't include the accrued interest, so we use shares and share price instead to get to the current borrow & supply amounts@version:- 1.0 - 2025-02-26 - Initial version- 2.0 - 2025-03-25 - Add new projection- 3.0 - 2025-03-26 - Fix negative supply/borrow rate-> Refactor code with definition on CTEs.- 4.0 - 2025-03-27 - Refactor code (separate CTEs for each section)-> Add more comments per section-> Tidy up CTEs- 5.0 - 2025-04-06 - Refactor names for columns and commas- 6.0 - 2025-04-15 - Remove CTEs relating to tracking, assigning, and collecting markets-> Add comments for share price precision rounding- 7.0 - 2025-04-22 - Add hardcoded values for protocol as 'morpho' and instance as 'main' and version 1- 8.0 - 2025-05-04 - Change dt to creation_dt-> Remove usage of token_info dataset- 9.0 - 2025-06-06 - Add temp filter for chains- 10.0 - 2025-06-08 - Merge new query for share interpolations- 11.0 - 2025-07-15 - Use Mat view of Morpho markets query- 12.0 - 2025-11-05 - Use accounting_price_usd in coalesce for token_price-> Update end stage of interpolation- 13.0 - 2026-02-02 - Update ending interpolation for borrow share price*/-- ***************************************************************************-- ******************* MARKETS *******************-- ***************************************************************************with markets as (-- List of Morpho Markets assigned to it's collateral and loan tokens.SELECT creation_dt, CAST(SUBSTRING(creation_ts, 1, 16) AS TIMESTAMP) as creation_ts, market_id, blockchain, loan_address, loan_symbol, loan_decimals, coll_address, coll_symbol, coll_decimals, lltv, market_symbol as market_name, instance