📊Sample Dashboard
This page will help you understand and create a dashboard using the Top Ledger platform.
Introduction
Top Ledger allows Web3 growth, analytics & data science teams to create powerful dashboards from decoded solana program data. Our backend infra pulls in raw data from the Solana blockchain and labels and indexes them into different tables on a daily basis.
Let’s take an example of a project called ‘Project X’. Project X is a major DeFi project on Solana. We will calculate some important metrics for Project X and add them in a dashboard.
Sample SQL Query
with cte_markets as (
select
pd.input_accounts.market,
pd.input_accounts.baseMint,
pd.input_accounts.quoteMint,
ts_base.symbol as baseMintName,
ts_quote.symbol as quoteMintName,
ts_quote.decimals
from phoenix.parsed pd
join token.solana_token ts_base on ts_base.address = pd.input_accounts.baseMint
join token.solana_token ts_quote on ts_quote.address = pd.input_accounts.quoteMint
where 1=1
and pd.instruction_type = 'InitializeMarket'
)
,
market_names as (
select
market,
baseMint,
quoteMint,
baseMintName || ' - ' || quoteMintName as marketName,
decimals
from cte_markets
)
select block_date,market, marketName, trades, sum(trades) over(order by block_date) as cum_trades
from
(
select block_date,market, marketName, count(distinct tx_id) as trades
from phoenix.parsed as p
cross join unnest(args.market_events) as market_event
join market_names as m on p.args.header_fields.header.market = m.market
where 1=1
and instruction_type = 'Log'
and market_event = 'FillSummary'
and p.args.header_fields.header.market = '{{market}}'
and market_event.fields.total_quote_lots_filled > 0
group by 1,2,3
) as a
order by 1 desc
Trades
We will start with calculating number of trades on daily basis and weekly top five pools based on number of trades. The below widget shows total number of trades for project X.

Also, in the widgets shown below you can see Trade trends along with weekly top 5 pools based on the number of trades for the project. On 11th Dec there was a spike in user activity which could be related to some internal or external event.
It also shows all time top 5 pools based on number of trades.

Let's go through the SQL code for the widgets you have seen so far. The query runs on parsed table available in the TL platform.
We need to begin with extracting and organizing market details, such as base and quote tokens. Subsequently, it concatenates token names for clarity. Then we calculates daily trading volumes and fees for each market, considering the associated token decimals. These daily metrics are further converted into USD values based on token prices.
The data is then aggregated on a weekly basis, summing up trades, volume, and fees. Finally, the markets are ranked weekly by trading volume in USD, and the top 5 markets are selected and displayed. This comprehensive analysis offers a snapshot of the most active markets on Solana, providing valuable insights into their weekly performance.
Trade Volume and Fees
Now let’s calculate how much trade volume Project X is making. We will check the total volume and fees for trades per day and cumulative amount of the two metrics. We can infer a lot of insights by relating this metric with real world events and can measure the impact.

Here, we see 6 widgets. 1) Total trade volume, 2) daily trade volume, 3) cumulative trade volume, 4) total trade fees, 5) daily fees for trades, and 6)cumulative fees for trades. We can infer that the volume of fees is quite high and which in a way is a sign of good health and profits for the liquidity provider and for the projectX.
Here we starts with extracting and processing data related to ProjectX markets. It involves several common table expressions (CTEs) to organize and aggregate the information. Then it calculates daily trade metrics, including the number of trades, daily volume, and daily fees in both native and USD denominations. Additionally, it computes cumulative metrics over time, providing a comprehensive view of market activity. The query draws data from various tables, such as phoenix.parsed, token.solana_token, and tl_solana.prices, utilizing their relationships to derive meaningful insights into ProjectX market performance.
Market Analysis
As many platforms wants, here we will add some key metrics regarding specific markets provided to users by the ProjectX. This includes total number of trades, trade volume, fees generated, users participated in a particular market. As shown in the widget below are the numbers for SOL-USDC market on the ProjectX.

Let’s go through the SQL code for how to calculate volume for Project X.
Once again we will start with extracting and processing data related to ProjectX markets. It begins by identifying markets and their associated details, including base and quote tokens. Subsequently, it calculates daily trading volumes and fees for each market, converting them into USD based on token prices. The final result provides a comprehensive summary of daily and cumulative trading metrics for the specified markets, offering insights into market activity over time.
Here is the link to the detailed dashboard for your reference -
Last updated