> For the complete documentation index, see [llms.txt](https://docs.covenant.finance/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.covenant.finance/protocol-mechanism/latent-swap-amm.md).

# The Latent Swap AMM

The Latent Swap is Covenant's automated market maker. It clears swaps among Yield Coins, Leverage Coins, and the underlying Base Asset within a Covenant Market, and it sets the implied funding rate continuously as a function of the market's loan-to-value (LTV).

## The mechanism

Traditional AMMs (like Uniswap) require both sides of a trading pair to be deposited as liquidity. The Latent Swap is different: the protocol itself controls all of the Yield Coins, Leverage Coins, and Base Asset collateral in a Covenant Market. That allows it to define a swap invariant that reflects the balance between Yield Coins and Leverage Coins against the collateral pool, rather than requiring external LPs.

The Latent Swap is designed to:

* allow continuous swaps among Yield Coins, Leverage Coins, and Base Assets;
* tie swap prices directly to the market's LTV and therefore to the implied funding rate;
* ensure that leverage becomes progressively cheaper as LTV rises (drawing in more leverage seekers) and progressively more expensive as LTV falls (drawing in more lenders), so the market clears continuously.

## The invariant

The Latent Swap invariant is a concave curve defined over the values of Leverage Coins, Yield Coins, and the Base Asset:

<p align="center"><span class="math">\left(L/\sqrt{P_a} -V_Y\right)\left(L\sqrt{P_b} - V_L \right)=L^2</span>,</p>

<p align="center"><span class="math">L=\frac{\sqrt{P_aP_b}}{\sqrt{P_b}-\sqrt{P_a}}V_B</span></p>

Where:

* $$V\_Y$$ = NAV (notional) of **Yield Coins**;
* $$V\_L$$ = NAV of **Leverage Coins**;
* $$V\_B$$ = NAV of the **Base Asset** collateral pool;
* $$P\_a, P\_b$$ = price band parameters that concentrate liquidity within a defined range.

The Latent Swap AMM clears each tranche at a market price relative to its NAV. The Yield Coin trades at a discount to NAV (its discount *is* the implied funding rate); the Leverage Coin's price relative to its NAV moves with leverage demand. The price band parameters `Pa` and `Pb` are fixed at market deployment and define the range over which the Yield Coin price can move; they concentrate liquidity within that range and bound the implied funding rate at the corresponding extremes.

## Value conservation

The invariant is **homogeneous of degree one**: scaling both tranche positions and the collateral pool by the same factor leaves the curve unchanged (each side scales identically). A direct consequence — Euler's identity for a degree-one homogeneous function — is that the **market values of the two tranches always sum to the collateral value**, at every LTV and not only at Neutral LTV:

<p align="center"><span class="math">V_B = p_Y\,V_Y + p_L\,V_L</span></p>

where $$p\_Y$$ and $$p\_L$$ are each tranche's market price relative to its NAV (the prices the AMM sets above). In words: the Latent Swap never creates or destroys value; it only re-divides a fixed collateral pool between the senior and junior claims as LTV moves. The clean NAV identity $$V\_B = V\_Y + V\_L$$ on the [How tranching works](/protocol-mechanism/how-does-covenant-work.md) page is the special case at Neutral LTV, where $$p\_Y = p\_L = 1$$.

This is a solvency property by construction: because the curve can only partition the collateral — never inflate the sum of the claims against it — a Covenant Market is fully backed at every point on the curve, with no path by which the AMM itself manufactures an uncovered claim.

## LTV is the input variable

Covenant defines the loan-to-value of a market as Yield Coin NAV divided by Base Asset NAV:

$$
LTV = \frac{V\_Y}{V\_B}
$$

Effective leverage on the Leverage Coin is `1 / (1 - LTV)`. The Latent Swap AMM prices Yield Coins and Leverage Coins as a continuous function of LTV, so changes in LTV move tranche prices and the implied funding rate together.

## Self-balancing

The Latent Swap invariant makes Covenant Markets self-balancing without external rebalancing or governance:

* **When LTV falls** (high Leverage Coin demand, low Yield Coin supply), Yield Coin prices fall, the implied rate rises, and new lenders are drawn in, pushing LTV back up.
* **When LTV rises** (low Leverage Coin demand, abundant Yield Coin supply), Yield Coin prices rise, the implied rate compresses, lender appetite cools, and Leverage Coin demand returns, pushing LTV back down.

The diagram below illustrates this for the [80/20 Concentrated](/markets/market-types/80-20-concentrated.md) market type (`Neutral LTV = 80%`, `Pa = 0.97`, `Pb = 1.00`, `D = 3 month perpetual`, Neutral rate \~4%). The left curve shows the implied funding rate as a function of market LTV; the right curve shows the Yield Coin's discount price against NAV at the same LTV.

<figure><img src="/files/lzHRtU1EI1eWUu3JGJh0" alt=""><figcaption><p>Funding rate and Yield Coin discount price as a function of LTV, for the 80/20 Concentrated market type.</p></figcaption></figure>

## What the AMM does and does not do

The Latent Swap AMM does:

* clear single-tranche swaps (Base Asset to Yield Coin, Base Asset to Leverage Coin, and the reverses), with slippage that scales with trade size and tranche-side imbalance;
* set the implied funding rate continuously via the Yield Coin price (`r = -ln(P / D)`, see [Perpetual Debt](/protocol-mechanism/perpetual-debt.md));
* enforce risk repricing as LTV moves, with no external trigger or curator action required.

The Latent Swap AMM does not:

* hold external LP deposits or pay LP fees in the conventional sense (junior holders capture the swap fee stream, see [Risks and mitigations](/protocol-mechanism/risks-and-mitigations.md));
* require a stablecoin liquidity pool to function;
* trigger per-position liquidations.

## Pair-mint and pair-redeem

In addition to the AMM swap path, both tranches can be created or destroyed as a matched pair against fresh Base Asset collateral. A pair-mint deposits the Base Asset and produces matched notional in Yield Coin and Leverage Coin without touching the AMM curve, so there is no slippage. A pair-redeem burns matched notional and returns the Base Asset on the same terms. This is the cleanest path for a holder of both tranches to enter or exit a market without paying the swap spread.
