# ⚙️Inside SmarDex Algorithm

Overcoming Impermanent Loss: a novel approach to liquidity management

The key to understanding SmarDex's innovative approach to reducing lies in understanding how Automated Market Makers (AMMs) traditionally work

### AMMs and the 'K Constant' Equation

The core of many decentralized crypto exchanges (DEXs) revolves around Automated Market Makers (AMMs), which operate under a mathematical rule called the 'k constant' equation.

Imagine a 'Liquidity Pool' as a sizable pot of tokens. Within this pot, we have two distinct tokens, let's call them Token X and Token Y. The quantity of Token X multiplied by the quantity of Token Y consistently equals a value, known as 'k'. Regardless of how the quantities of Token X and Token Y fluctuate, their product remains 'constant', hence the term 'k constant'. Of course this is only valid during a swap, when any user add or remove liquidity to the protocol, the 'k constant' changes.

Consider this as a balance with Token X and Token Y on each side. When the quantity of Token X rises (and its price falls), the quantity of Token Y must decrease (and its price rises), and vice versa. This rule ensures the balance remains intact, meaning the product of Token X and Token Y quantities (i.e., the 'k' value) always stays the same.

**Impermanent Loss Simplified**

**Impermanent Loss Simplified**

What if the price of Token X or Y experiences a significant shift in the global market? The balance in our pool no longer mirrors the market, leading to a persistent imbalance. This creates what's referred to as 'Impermanent Loss' for the liquidity providers - those who originally deposited Token X and Y into the pool. The larger the price deviation, the more pronounced the Impermanent Loss becomes. In essence, liquidity providers would have been more profitable had they simply held onto their tokens, instead of depositing them into the pool.

Let's take an example for more clarity:

Suppose Alice deposits 1 ETH and 1000 USDT into a pool on a DEX. Since the token pair must have equivalent value, this means that the price of 1 ETH is 1000 USDT. At the same time, there are a total of 10 ETH and 10,000 USDT in the pool, with the remainder being provided by other liquidity providers such as Alice. This implies that Alice holds a stake equivalent to 10% of the pool. The total liquidity 'k' in this case is 100 000.

After some times, and the price of ETH increases to 4000 USDT, the total liquidity of the pool must remain constant. If 1 ETH is now worth 4000 USDT, this means that the ratio between the quantity of ETH and the quantity of USDT in the pool has changed due to adjustments made by the arbitragers. Let's suppose no liquidity was added, there are now 5 ETH and 20000 USDT in the pool (we can verify that 'k' remains unchanged, still at 100 000). Alice therefore decides to withdraw her funds and obtain her 10% share of the total pool, which amounts to 0.5 ETH and 2000 USDT, or a total of 4000 USDT.

It appears that she has made a nice profit. But what could have happened if she had not deposited her funds into the pool? She would have had 1 ETH and 1000 USDT, for a total of 5000 USDT. In fact, Alice would have been better off keeping her funds in her wallet rather than providing liquidity on a DEX because she has incurred an Impermanent Loss of 20%. Currently, DEXs attempt to address this loss by incentivizing liquidity providers through the collection of fees for each swap, but this is not always sufficient.

### Diving Into the Heart of SmarDex's Unique Algorithm

SmarDex takes a novel approach to liquidity management with the introduction of its** **, a reimagined version of traditional Liquidity Pools. Unlike conventional Liquidity Pools found on other DEXs, SmarDex's are powered by an autonomous algorithm, deeply rooted in mathematical principles, which enables them to self-manage and dynamically adapt to changing market conditions without the need for external intervention.

To understand this, let's take the example of Uniswap, where a Pool contains two types of tokens: let's say ETH (Token X) and USDT (Token Y). In this system, the product of the quantities of X and Y remains constant (X * Y = k). Imagine a Pool with 10 ETH and 18,000 USDT as our real reserves.

SmarDex introduces an innovative concept by creating **Fictive Reserves** from the existing real reserves. Specifically, for this example, it halves the real reserves to establish Fictive Reserves of 5 ETH and 9,000 USDT. This mechanism ensures that any transaction within the system has a more pronounced effect on prices than it would if based solely on the real reserves. Therefore, when a user exchanges 2 ETH, this transaction significantly amplifies the price impact within our calculations. As a result, the price of ETH in our system surges from $1,800 to $5,000, despite the actual real reserves being adjusted minimally, from 10 to 8 ETH and from 18,000 to 24,000 USDT.

This mechanism allows the SmarDex to minimize Impermanent Loss by adjusting prices more dynamically. When the price of ETH increases, the protocol can keep a part of the ETH to sell it at a higher price, and conversely, buy ETH at a low price when its value decreases, thanks to the manipulation of the Fictive Reserves. This strategy ensures that, regardless of market fluctuations, the is less exposed to Impermanent Loss compared to other competing DEXs.

Moreover, the protocol adjusts the Fictive Reserves based on buying and selling actions in the . If a user buys ETH at a high price, the protocol adapts its Fictive Reserves to encourage selling at this increased price, and vice versa. This has the effect of naturally balancing the over time, aiming for a 50-50 balance between ETH and USDT.

This unique system not only reduces Impermanent Loss but also offers the possibility of realizing Impermanent Gains when returning to the initial price, a feat that SmarDex achieves in 100% of cases through its sophisticated algorithms.

In summary, thanks to the innovative management of Fictive Reserves, SmarDex allows its to optimally adjust to market movements, offering increased protection against Impermanent Loss and the possibility of gains even in a fluctuating market. This unique approach places SmarDex at the forefront of decentralized exchanges, leveraging price variations for the benefit of Liquidity Providers.

#### If you are intrigued and wish to delve deeper into the SmarDex protocol, we cordially invite you to read our comprehensive Whitepaper.

Last updated