> For the complete documentation index, see [llms.txt](https://docs.silverswap.io/spiritswap-v3/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.silverswap.io/spiritswap-v3/v2-core-features/liquidity/balanced-amm-v2.1.md).

# Balanced AMM (V2.1)

First of all, SpiritSwap would like to give credit to the team at [Balancer](https://balancer.fi/) for architecting this supreme piece of technology.  SpiritSwap aims to curate the best bits of DeFi available and house them in a central hub that supports the SpiritSwap ecosystem, this portion of innovation was a must have for our V2 hybrid model.  <br>

{% hint style="info" %}
A balanced AMM utilizes both weighted math to facilitate swaps within "weighted pools" and stable math for swaps within "stable pools".&#x20;
{% endhint %}

### Weighted Math

\
\
The purpose of weighted math is to facilitate swaps across a wide variety of asset types, irrespective of their price correlation. In this scenario price of assets are resolved by three factors

* Balances within pools&#x20;
* Weights within pools&#x20;
* The volume of tokens being swapped

The weighted math formula used by Balancer is a iteration of the $$x\*y=k$$ CPF (Constant Product Formula) \
\
The iteration accounts for cases where by $$n \geq2$$ (number of tokens within the pool are greater than two) thus allow for index style pools, while accounting for the fact that the weights of these tokens are not your standard 50/50 allocation like the traditional vAMM. \
\
The desired weight of value attributed to each token is maintained while the price of each asset changes by virtue of trades made within the pool by arbitrageurs, if effect rebalancing the pool.&#x20;

&#x20;                                                     <img src="/files/cg591BUzMjNlcQFTDBJf" alt="" data-size="original">

### Stable Math&#x20;

\
The stable math equation is quite complex and utilized for asset classes that are required to remain at a trade value parity (i.e. as close to peg with one an other that the market will allow). With the employment of stable math these pools are expected to allow the facilitation of trades, for these asset classes, without the trader experiencing high slippage on larger volume trades.  \
\
\
For a greater level of insight as to how the invariant is determined in this formula, we recommend referencing the original [Balancer documentation](https://dev.balancer.fi/resources/pool-math/stable-math).&#x20;
