πDEX ecosystem on Solana
This guide will assist you in creating a dashboard on the Top Ledger platform, which displays a variety of key metrics for the DEX ecosystem on Solana.
Letβs calculate some important metrics for the DEX ecosystem and add them in a dashboard.
Swap Transaction
We will start with calculating daily swap transactions on Solana. The chart below shows the daily swap transactions for entire DEX ecosystem.

Now, let's go through the SQL code used to create these metrics. The query runs on the dex_trades table available in the Top Ledger platform.
Since the dex_trades table contains all the swap transactions that have happened in the DEX ecosystem, we just need to count the number of transactions on a daily basis. Then, in the second part of the query, we need to aggregate the daily transactions over the entire period to get the cumulative number of transactions since 2023.
Swap Volume
Now, let's consider the example of swap volume, i.e., how we are going to compute it. The charts below show the daily swap volume for various DEX programs and the cumulative swap volume.

The SQL code below begins by assigning various program addresses to their respective names and selecting other fields such as block_date, base_amount, quote_amount, base_mint, quote_mint, etc. It then calculate the swap amounts on a daily basis, grouped by the program through which the swap happened.
Then, the daily swap amount in multiple tokens needs to be converted to USD, which is accomplished using the price table (tl_solana.prices). Once that is done, we need to sum the amounts in USD over the specified period to calculate the cumulative swap amount in USD.
Active Wallets
Active wallets are a crucial metric for any dApp in Web3. More wallets imply higher usage of the dApp by users, which also means more revenue opportunities for the dApp in terms of fees and other charges, making any dApp more viable and profitable.

Let's go through the SQL code to learn how to calculate active wallets for the DEX ecosystem.
To count active wallets over time, we can use the Rank function to count a wallet only once for the entire period, regardless of the number of swaps performed using the same wallet. Thereafter, we need to sum all the unique wallets that have ever performed a trade. And that's it; we have the total number of active wallets.
Here is the detailed dashboard for your reference.
Last updated