# Concepts

Unlike Uniswap or other constant product AMMs, Stabull is a *proactive AMM*. Instead of waiting for arbitrageurs to align prices with other sources of liquidity, the Stabull AMM dynamically concentrates liquidity around an off chain FX oracle to provide lower slippage. This lends itself naturally to FX and RWA's where the majority of price discovery occurs off chain. As well as providing price improvement for traders and relieving peg pressure for token issuers, this model greatly reduces impermanent loss for LP's, because their liquidity is dynamically recentered around the oracle price, without leaking profit to arbitrageurs.

## Pool

A Stabull pool (or pair) is a smart contract which manages a reserve of two fiat-backed, [ERC-20](https://eips.ethereum.org/EIPS/eip-20) stablecoins. There are two main operations a user can perform on a Stabull pool...

* Liquidity Providers (LPs) can deposit & withdraw [liquidity](https://docs.stabull.finance/amm/liquidity "mention") from pools, changing the total reserves of the two tokens.&#x20;
* Traders can [swap](https://docs.stabull.finance/amm/swap "mention") between the two tokens, changing the proportion of token reserves.

*At launch, Stabull pools are deployed on Ethereum and Polygon, and quoted in USDC. See* [contracts](https://docs.stabull.finance/amm/contracts "mention") *for smart contract addresses and the currently deployed pools. See* [stablecoins](https://docs.stabull.finance/stablecoins "mention") *for more information on the non-USD stablecoins that each pool contains.*&#x20;

## Invariant

An invariant is a mathematical property or relationship that remains unchanged under a set of operations. In the context of a decentralised exchange, the invariant defines the relationship between the balances of pool tokens and parameters, that remains unchanged after swapping, deposits or withdrawals. The Stabull invariant is a hybrid of constant product and constant sum invariant, resulting in a flattened curve when visualised with token balances on each axis.&#x20;

<figure><img src="https://3912201459-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqKBa92wmsQoWnuHOatYu%2Fuploads%2Fbv2eyATuEQPs38SgRdim%2FStabull%20Curve%20(2).png?alt=media&#x26;token=34c64cf7-0916-484f-8ef9-1042c318fd81" alt=""><figcaption></figcaption></figure>

## Dynamic Pricing & Spread

Stabull pools dynamically adjusts swap pricing based on the balance of reserves in the pool relative to the oracle rate. This mechanism ensures that the pool remains efficient and closely tracks the external FX market.<br>

* **Swaps that rebalance the pool are rewarded** (*incentivised*).
* **Swaps that imbalance the pool are penalised** (*disincentivised*).

Example: the NZDS/USDC pool is 68% NZDS (abundant) & 32% USDC (scarce).&#x20;

<table><thead><tr><th width="123"></th><th width="261.5">details</th><th width="195.5">example</th><th>result</th></tr></thead><tbody><tr><td>rebalancing swap</td><td>adds the scarce asset &#x26; removes the abundant asset </td><td>swap NZDS for USDC</td><td>rewarded with part of the spread</td></tr><tr><td>unbalancing swap</td><td>adds the abundant asset &#x26; removes the scarce asset</td><td>swap USDC for NZDS</td><td>penalised with a higher spread</td></tr></tbody></table>

This dynamic pricing mechanism encourages users to rebalance the pool while discouraging swaps that exacerbate imbalances. Instead of viewing the pool as "unbalanced," it is more accurate to describe it as having a temporary deviation from the oracle rate (e.g., Stabull NZDS/USDC price ≠ NZD/USD FX price).

### Events that affect a pool

<table><thead><tr><th width="157">Event</th><th width="259">Affect</th><th>Invariant</th></tr></thead><tbody><tr><td>Deposit or Withdrawal</td><td>the total reserves change. the proportion of reserves (and the swap price) remain the same. </td><td>the invariant ensures that deposits &#x26; withdrawals can only be made in the same proportion as the current pool reserves.</td></tr><tr><td>Swap</td><td>the proportion of reserves, and therefore the swap price changes.</td><td>the invariant ensures that a swap cannot reduce the total reserves, although the spread collected on each swap will slightly increase total reserves.</td></tr><tr><td>Oracle Update</td><td>liquidity is dynamically shifted around the oracle price. the swap price changes.</td><td>The oracle price is used to determine token proportions, slippage and halt boundary's. </td></tr></tbody></table>

## Oracles

The oracle rate for each pool is determined by two oracle price feeds. One for each token in the pool:

* the base oracle is the price of the fiat currency in USD e.g. TRY/USD
* the quote oracle is the price of the quote stablecoin in USD e.g. USDC/USD

At present, oracles are supplied by [Chainlink Data Feeds](https://data.chain.link/feeds?categories=Fiat).


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.stabull.finance/amm/concepts.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
