TerraSwap is THE DEX for Terra's ecosystem at the time of writing, where Terra users pool their coins and tokens to earn an annual interest based on the trading volume of the pools. The commission for each of these pools is fixed at 0.3% of the trading volume, the fees collected are then theoretically distributed among the liquidity providers (it actually increases the value of each share instead of distributing it directly). Here we will discuss how are TerraSwap pools performing and which pool is the most lucrative.

Calculations

The method of calculation is the most important part of discussions involving APRs, we wouldn't want to lose loads of potential rewards because of miscalculations now, would we?

Although it's the most boring part, let's start with the methods to calculate the APRs of the pools. In theory, the APR can be calculated by getting the (commission amount / total value locked of the pool) * 365 * 100%. To derive this equation, we must imagine that the pool is solely owned by a single address and all the commission fees are given to a single address, which means the yield per day from the pool divided by the value of the pool is the % return per day, multiplied by 365 days then we get the APR.

This equation is true even when in fact the pools are never solely owned by a single provider because the commission fee is distributed equally among the liquidity providers based on the % of their share in the pool. So, if a trade's fee is 100 UST and you own 1% of the liquidity pool, then you will get 1 UST. This also means that the APR is not affected by the % share of the addresses.

Secondly, to simplify calculations, the APR is calculated based on the USD value of the pools and the trade fees. This way, we can accurately compare the APRs of each of the pools.

Based on this method, we are able to find out the top 5 APR for the current date.

Screenshot_11.png

Now let's verify this on using https://alpac4.com/TerraSwapDashboard, where most people refer to as a guide to pooling.

Screenshot_13.png

What's this? A very different set of results is displayed on alpac4. Who's in the wrong here? To find out, some verifications had been carried out for alpac4's data. Firstly, the 24h volumes of LOTA-UST, bETH-UST, and LUNA-UST are found out. These 3 pairs are used cause of their UST pairing, and the 24h Volume for alpac4 is based on UST. The SQL below had been checked to contain all the transactions in a 24 hour period.

SELECT
  	CASE
  		WHEN event_attributes:contract_address = 'terra1tndcaqxkpc5ce9qee5ggqf430mr2z3pefe5wj6' THEN 'LUNA-UST'
  		WHEN event_attributes:to = 'terra1pn20mcwnmeyxf68vpt3cyel3n57qm9mp289jta' OR event_attributes:from = 'terra1pn20mcwnmeyxf68vpt3cyel3n57qm9mp289jta' THEN 'LOTA-UST'
  		WHEN event_attributes:to = 'terra1c0afrdc5253tkp5wt7rxhuj42xwyf2lcre0s7c' OR event_attributes:from = 'terra1c0afrdc5253tkp5wt7rxhuj42xwyf2lcre0s7c' THEN 'bETH-UST'
  		ELSE 'UNKNOWN'
  	END as pair,
  	MIN(block_timestamp) as start_time,
	SUM(CASE event_attributes:ask_asset 
  		WHEN 'uusd' THEN event_attributes:ask_amount
  		ELSE event_attributes:offer_amount
  		END) / 1e6 as ust_volume
FROM
	terra.msg_events
WHERE
	tx_status = 'SUCCEEDED'
	AND event_attributes:ask_asset IS NOT NULL
	AND event_attributes:offer_asset IS NOT NULL
	AND event_type = 'from_contract'
  	AND block_timestamp >= CURRENT_TIMESTAMP - interval'24 hours'
  	AND (event_attributes:contract_address = 'terra1tndcaqxkpc5ce9qee5ggqf430mr2z3pefe5wj6' OR event_attributes:to IN ('terra1pn20mcwnmeyxf68vpt3cyel3n57qm9mp289jta', 'terra1c0afrdc5253tkp5wt7rxhuj42xwyf2lcre0s7c') OR event_attributes:from IN ('terra1pn20mcwnmeyxf68vpt3cyel3n57qm9mp289jta', 'terra1c0afrdc5253tkp5wt7rxhuj42xwyf2lcre0s7c'))
GROUP BY 1

Screenshot_15.png

The results show that the UST volumes are vastly different from the data displayed in alpac4, leading me to believe that alpac4 is not displaying true values.

What's more is that one of alpac4's APR shows negative APR, which shouldn't be possible considering that fees can only be added to the pool, never deducted. Yes, you can suffer from impermanent loss, but never negative APR. In short, you will only lose if the impermanent loss is greater than the APR. Furthermore, how can one go into debt by depositing into liquidity pools? 😅

Screenshot_16.png

With all that said, I guess there are no other ways to verify the accuracy of my data, although it should be accurate enough.

APR Analysis

The graphs below show the top 5 TerraSwap pools based on APR. From the graphs, we can see that although some pools show very high APR, e.g. LOTA-UST pool, the actual commission gained is very low, thus the APR is only accurate for small liquidity providers (since the larger the pool the less commission gained per share). Among the ones that consistently hit the top 5 APR, only the LUNA-UST and bLUNA-LUNA pair have significant commission gained per day.

Screenshot_17.png