Spot Markets on Tsunami Exchange

Hi all! In this technical article we will try to explain how the Tsunami Exchange spot markets will be structured, why they are more efficient than any other spot markets on Waves, and how this will breathe new life into the arbitrage and trading processes within the ecosystem.
Attention, lots of words. Enjoy reading!


Spot trading is an essential feature for any exchange. By introducing spot trading, Tsunami can significantly increase its total trading volume and the amount of fees collected. This enhancement will attract more traders and bring greater value to liquidity providers and TSN token stakers.

Automated Market Makers (AMMs) have revolutionized decentralized exchanges by enabling seamless trading without the need for traditional order books. They have gained immense popularity due to their ability to provide liquidity through passive mechanisms.

Passive liquidity provision involves LPs depositing an equal value of two tokens into a liquidity pool, creating a balanced trading pair. As the market fluctuates, the pool's relative token values change, leading to potential impermanent loss for LPs.

One of the primary reasons LPs suffer from impermanent loss is the presence of arbitrage traders. These traders exploit the price imbalances between the liquidity pool and external markets. When the price of one token in the pool increases, arbitrageurs buy the undervalued token from the pool and sell it at a higher price in another market, aiming to profit from the price discrepancy. As a result, the LPs' shares in the pool become skewed, causing impermanent loss when the pool rebalances.

Uniswap v3 introduces a groundbreaking solution to address impermanent loss through the concept of concentrated liquidity. Unlike traditional AMMs, which rely on providing equal value of tokens, Uniswap v3 allows LPs to customize their liquidity provision by selecting specific price ranges known as liquidity positions. It is important to note that this approach requires active management of provided liquidity. LPs must constantly monitor the market and adjust their positions within specific price ranges, which can be time-consuming and burdensome.

Tsunami leverages Oracle technology to automatically concentrate liquidity around the current fair price of an asset, reaping the benefits of concentrated liquidity while not requiring active liquidity management. By incorporating Oracles, Tsunami ensures that the pricing of assets within the liquidity pool aligns more closely with the broader market, reducing price impact and slippage, while utilizing the same amount of liquidity. This improvement in pricing accuracy ultimately benefits both LPs and traders on the platform. Another notable improvement of Tsunami over the current models available in the Waves ecosystem is the elimination of impermanent loss (IL) through the ability for liquidity providers to provide liquidity single-sided. This advancement allows Tsunami to offer more competitive trading fees, attracting a substantial trading volume and resulting in a favorable APY for liquidity providers and TSN stakers.


The mechanics of Tsunami Spot trading are quite intricate and require a step-by-step explanation. Tsunami Spot consists of Markets and Vaults, with each Spot Market and Vault having a one-to-one relationship. Each Market is associated with a specific Asset. For example, for BTC, there will be a BTC Market and a BTC Vault.

Behind each Market, there is an underlying dvAMM (Decentralized Virtual Automated Market Maker). The dvAMM is a variation of the Constant Product Market Maker (CPMM) model pioneered by Uniswap. It is designed to concentrate liquidity around the fair price provided by the Oracle. A detailed description of the dvAMM will follow. The liquidity in the dvAMM is virtual and its amount is determined programmatically based on the liquidity present in the corresponding underlying Vault.

The dvAMM of each Market facilitates the trading of its underlying Asset to the Quote Asset. The Quote Asset represents one unit of value equal to one US Dollar. The Quote Asset is entirely virtual and serves solely for accounting purposes. In this document, this asset will be referred to as USD. Each trade on Tsunami Spot occurs by routing it through two markets: first, selling the source asset for USD on the source asset market, and then buying the target asset for USD on the target asset market. This approach ensures an extremely high level of capital efficiency for Tsunami Spot, as all liquidity for a specific Asset is available for trading with any other asset. It effectively consolidates all assets on Tsunami into a single large omni-pool, as opposed to a pair-based approach where liquidity is fragmented across multiple pairs. This consolidation reduces price impact for traders, resulting in a more favorable trading experience.

dvAMM in action

Let's dig into the dvAMM and its properties. dvAMM is derived from the traditional CP, but differs in a few important aspects.

Traditional CPMM is using the famous invariant x * y = k, where x is the reserve of asset A, y is a reserve of asset B, and k is the swap invariant. Price of an asset is determined as p = x/y.

For dvAMM instead of x and y we will use B and Q, where B is Base Asset Reserve (Base is an asset that is trading on Market), and Q is Quote Asset reserve (Quote asset is USD, described earlier).

Swap invariant is the same as in CPMM formula: Q * B = k.

However, to determine the price and additional coefficient q is used, so p = q*Q/B. Coefficient q is to adjust AMM curve to current fair price.

Additionally, dvAMM is trading parameter S which is the cumulative amount of Base Asset swapped. Whenever someone buys Base Asset from AMM S is increased by this amount, and vice versa for selling. This way S allows to always keep track of asset B imbalance. Now we can go towards the mechanics of dvAMM.

Swapping Base for Quote

Swapping Quote for Base

Determining q when fair price changes

To summarize the above, dvAMM is an AMM that is characterized by:

  • Providing liquidity around a fair price;

  • Automatically adjusting the curve to a fair price;

  • Having a built-in incentive to balance the price towards a fair price:

    • When too much base asset is bought, the price for it is higher, so it's profitable to sell it;

    • When too much base asset is sold, the price for it is lower, so it's profitable to buy it.

Vault in Action

Let's delve into the mechanics of the Vault. The Vault serves as a repository where liquidity providers (LPs) can deposit their actual assets. When an asset is deposited into the Vault, it is exchanged for LP Tokens based on the current rate. The rate effectively represents the "price" of the LP token, indicating how many LP tokens the LP will receive for their Base asset and how much they will get back. The initial rate is set to 1. The rate increases over time as the Vault accumulates fees.

The Vault keeps track of four crucial parameters:

  1. lpBalance: the amount of issued LP tokens.

  2. balance: the total value of assets deposited into the Vault by LPs, including collected fees (positive value).

  3. excess: the imbalance of the Vault. Excess is reduced when fees are deducted from the Vault or increased when funds are deposited into the Vault. It can be either positive or negative. It's important to note that excess is only affected by swaps and not by providing or withdrawing liquidity.

  4. rate: the rate at which LP tokens are issued or burned. The initial rate is 1.

When an LP provides liquidity to the Vault, they receive LP tokens in an amount equal to LP = B/rate. Conversely, when an LP withdraws liquidity from the Vault, they receive Base assets in an amount equal to B = LP * rate.

Since the rate constantly increases, it is evident that LPs can receive the same or a greater amount of assets than they initially provided.

When the Vault receives a fee, the rate is recalculated as rate' = rate + fee/lpBalance, and the balance is updated as balance' = balance + fee.

During a swap, if an amount B of funds is withdrawn from the Vault, the excess is reduced by B. Similarly, if an amount B of funds is deposited into the Vault, the excess is increased by B. This way, the actual balance of the token is computed as actualBalance = balance + excess (note that the excess can be negative).

In other words, the balance represents the obligation the Vault holds to LPs, while the actualBalance represents the actual amount of tokens held by the Vault.

The Vault also has a configurable parameter called utilizationRate, which determines the allowable range of imbalance. For instance, at a utilizationRate of 50%, it means that 0.5 * balance < actualBalance < 1.5 * balance, or more generally, utilizationRate * balance < balance < (1 + utilizationRate) * balance. Swaps that result in an actualBalance outside this range will be rejected.

Liquidity Amplification (Projection)

Now, let's integrate the Market (dvAMM) and Vault mechanics. As astute readers may have noticed, the parameters S and excess in the dvAMM are closely related. Whenever the excess increases or decreases, the corresponding AMM's price moves in a way that incentivizes arbitrage to bring it closer to the fair price, reducing the absolute value of the excess. This relationship proves to be convenient.

Now, let's determine the amount of virtual liquidity in the dvAMM relative to its vault. To achieve this, we introduce an additional parameter in the dvAMM called maxPriceSpread. The maxPriceSpread determines the allowable range within which the dvAMM provides liquidity. It's reasonable to assume a value around 4.5% for volatile assets and 0.5% for stablecoins, although this value can vary per market.

If the dvAMM provides liquidity at the maximum shift of maxPriceSpread and the actual available liquidity to withdraw/add is utilizationRate * balance, it should project this liquidity within the maxPriceSpread range.

Swap Process and Fees

Now that everything is in place, we can describe the actual swap prices. To swap an amount DeltaA of asset A for asset B, the swap router first determines the markets for A and B. Then, it swaps the DeltaA amount of asset A for an equivalent amount DeltaU of USD, and subsequently swaps the DeltaU amount of USD for a quantity DeltaB of asset B.

Before the dB amount of asset B is passed to the trader, the fee computation process is conducted. Instead of using a flat fee, Tsunami employs a dynamic fee model to further incentivize the restoration of equilibrium in the AMMs and Vault, while extracting additional value from traders by addressing any imbalance increase.

To determine the fee, we first compute the individual cost of imbalance for each Vault. The imbalance shift for each vault is calculated as follows:

Note that if imbUsd is positive, the imbalance for a Vault is increasing, and if imbUsd is negative, the imbalance for a Vault is decreasing.

Now we can compute the relative imbalance change overall for a swap as:

A negative relative imbalance indicates an improvement in the overall health of the system, while a positive relative imbalance indicates a deterioration.

In the case of a negative imbalance, traders are awarded a fee rebate, which is computed as:

This dynamic fee system provides additional incentives for traders and arbitragers to maintain the system's health and minimize Vault imbalances while allowing for a relatively low base fee.

Example swap

Let's finally put some numbers in to look and feel how the formulas above work. Let's trade some ETH for USDT. We will compare Tsunami approach and CPMM approach. Liquidity pools will be the same - 10 ETH / 15000 USDT, both AMM balanced with $1500 being fair price for ETH.

Let's trade 1 ETH for USDT.

CPMM approach

For CPMM match is very straight forward:

LP will earn $4.09

Notice a huge price impact of almost $150.

Tsunami approach

For Tsunami let's set Vault and Market parameters as following:

For Both Markets: maxUtilizationRate = 0.5

For ETH: maxPriceSpread = 0.035 (3.5%)

For USDT: maxPriceSpread = 0.005 (0.5%)

Let's compute Q and B for both markets, assume q = 1

Now let's compute the fee. Base fee is 0.3%, max rebate is 3%. Assuming Vaults were balanced, the imbalances are the following:

1500 USD (ETH Vault)

1487.723 USD (USDT Vault)

So cumulative imbalance is 2987.723, and total liquidity in Vauts is 10 * 1500 + 15000 = 30000. So tax = 0.03 * 2987.723 / 30000 = 0.002987723. So actual fee = 0.003 + 0.002987723 = 0.005987723.

With 1.099% fee, user will get 1487.723 - 1487.723 * 0.005987723 = 1478.814
LP will earn 1487.723 * 0.005987723 = 8.908

Let's compare the results between CPMM and Tsunami Model:

CPMM: trader execution price (with fees) is 1359.55 (9.36% loss against ideal trade), LP earned: $4.09

Tsunami: trader execution price (with fees) is 1478.814 (1.412% loss against ideal trade), LP earned: $8.908

Note how everyone profits: LP got more fees and trader got much better execution cost. Note, that trade on Tsunami is executed with 6.6 times less price impact.

Limitations and Risks

The model described above offers significant advantages for traders and liquidity providers, including:

  • Single-sided liquidity provision

  • Elimination of impermanent loss

  • Very high capital efficiency (x5 - x25) compared to benchmark CPMM

  • Lower swap fees

However, it also comes with certain limitations and risks:

  • Only highly liquid assets can be traded, as Oracle prices should not be easily manipulated.

  • Liquidity providers may not be able to fully withdraw their positions due to temporary Vault imbalances.

The latter limitation, however, can be mitigated by introducing a burn/swap mechanism. Burn swapping involves virtually exchanging LP tokens of a Vault with a negative excess to the rate * LP base asset, performing a swap to an asset with a positive excess, and burning the LP tokens in the process. This mechanism provides LPs with a guaranteed way to exit their positions at any time, albeit incurring swap fees for a portion of their position.


In conclusion, the new AMM model presented in this article offers several advantages for traders and liquidity providers. By combining the concept of separated Vaults and the dvAMMs, it enables single-sided liquidity provision, eliminates impermanent loss, and achieves high capital efficiency, outperforming benchmark Constant Product Market Maker (CPMM) models by a factor of 10 to 100.

Moreover, the dynamic fee system implemented in the Tsunami protocol incentivizes traders and arbitrageurs to actively work towards maintaining liquidity equilibrium. This fee model considers the individual imbalances of each Vault, providing fee rebates for participants, keeping the system healthy and minimizing imbalances while still maintaining low base fees.

Overall, the new AMM model and dynamic fee system presented in this article provide a promising framework for new generation of decentralized exchanges. By addressing key issues such as impermanent loss and capital efficiency, while introducing mechanisms to incentivize equilibrium and reward active participation, this model offers enhanced opportunities for traders and liquidity providers.

Thank you for reading this article to the end. If you still have questions, don't hesitate to contact our community chats!
Your Tsunami Team 🌊

Twitter | Chat | News | Discord

Subscribe to Tsunami Exchange
Receive the latest updates directly to your inbox.
Mint this entry as an NFT to add it to your collection.
This entry has been permanently stored onchain and signed by its creator.