How it works

AMM : Automated Market Maker

AMM (Automated Market Maker) is in charge of how the pricing of the token pairs are calculated. The main components of an AMM are the pricing algorithm, liquidity providers, token pairs, and traders.

CPMM(Constant Product Market Maker)

The Swap service of WEMIX.Fi determines the price of token pairs traded between users and liquidity pools via the CPMM algorithm. The CPMM algorithm keeps the product of the token quantities always at a constant. It determines the exchange rate of the token pair. The following equation represents the CPMM algorithm:

XY=kX * Y = k

In the above formula, X and Y denotes the quantity of tokens that make up the liquidity pool respectively, and k is the product of the two token quantities. For example, if the quantity of USDC and WEMIX$ supplied to the USDC-WEMIX$ pool is 1,000 and 5,000 respectively, (X = 1,000, Y = 5,000), k becomes 5,000,000.

The constant of the liquidity pool's k always remains fixed as a constant; if X or Y increases, the other must decrease to keep k as a fixed constant. Therefore, if X in the liquidity pool increases through a swap, Y must decrease to maintain the constant. As a result, if X increases then Y decreases and vice versa.

For example, assuming that 1,000 USDC and 5,000 WEMIX$ are supplied to the USDC-WEMIX$ pool respectively, the initial state of the pool can be expressed separately in the CPMM algorithm as shown below (assuming there is no transaction fee):

  • Pool status before Swap: X=1000X=1000, Y=5000Y=5000​, k=5000000k=5000000

If a user swaps 10 USDC, k must remain constant even if the values of x and y change, so the modified state of the pool depending on the transaction can be expressed as shown below:

  • Pool status after Swap: X=X+10=1010X'=X+10=1010​, Y=k / X=4950.50Y'=k \space / \space X'=4950.50, k=5000000k=5000000

As shown above, as X increases,Y decreases depending on the swap. 10 USDC is swapped for 49.5 WEMIX$, in which it is the quantity deducted from the initial quantity of Y to complete the swap.

Liquidity provider

For each swap transaction, the swap rate of the token pair will change; the less liquidity the pool has, the greater the swap rate of the token pair. For example, swapping 100 USDC in a pool of 1,000 USDC and 5,000 WEMIX$ will result in 454.55 WEMIX$, reducing the swap ratio of the token pair to 1:4.13.

USDC-WEMIX$ PoolBefore SwapAfter Swap

XX(USDC)

1,000.00

1,100.00

YY(WEMIX$)

5,000.00

4,545.45

kk

5,000,000.00

5,000,000.00

USDC : WEMIX$

1 : 5

1 : 4.13

On the other hand, swapping 100 USDC in a pool of 1,000,000 USDC and 5,000,000 WEMIX$ will result in 500 WEMIX$, with the swap ratio of the token pair being slightly reduced to 1:4.99.

USDC-WEMIX$ PoolBefore SwapAfter Swap

XX​(USDC)

1,000,000

1,000,100

YY​(WEMIX$)

5,000,000

4,999,500

kk

5,000,000,000,000

5,000,000,000,000

USDC : WEMIX$

1 : 5

1 : 4.99

Therefore abundant liquidity is essential for the stable operation of the swap service, and WEMIX.Fi encourages users to participate in the liquidity supply. Users can directly supply liquidity to the pool and earn profits in return; further details can be found in the pool section.

Price Impact

The swap rate changes when a swap from a liquidity pool occurs. The variation in which the swap rate fluctuates depending on the swap size, and the price impact shows the change in swap rate corresponding to the user's swap amount. This can be an important indicator to protect against losses when users make swaps. For example, assuming a pool of 1,000 USDC and 5,000 WEMIX$, the initial swap ratio between USDC and WEMIX$ is 1:5. When a user swaps 50 USDC, the swap rate of the two assets decreases by about 4%. However, if users provide more liquidity into the USDC-WEMIX$ pool, the swap rate can be restored. Therefore it is important for the user to always check the price impact to minimize losses during a swap as it changes in real-time depending on the swap size.

Slippage Rate

Once a swap is executed, it takes some time before the transaction actually takes place due to the nature of blockchains and the WEMIX Mainnet. The swap rate of a token pair can have a different outcome once the transaction is processed. On average, the swap rate upon transaction request and the swap rate during the actual transaction execution may differ by 0.5 to 1.0%, but it may vary by more than 5.0% depending on the swap size and market conditions.

Slippage rate stops processing transactions when the swap deviates from the set rate; it can be set by users to prevent loss of assets. Setting the slippage rate low can minimize asset loss, but the probability of the transaction being processed is lower depending on swap rate fluctuations. Losses may occur.

  • 0.1 ~ 0.4%: Low success rate. The set slippage rate is too low, and your transaction may not be successful.

  • 0.5 ~ 4.9%: Average success rate. The set slippage rate is average, but your transaction may not succeed depending on the market situation.

  • 1.1 ~ 4.9%: High success rate. The set slippage and transaction success rate are high, but there may be fluctuations in the transaction volume.

  • More than 5.0%: High risk of asset volatility. The set slippage rate is too high, and transaction volume may fluctuate significantly.