# 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 target 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.

## 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 shows the relationship between Yield Coin price (and implied APY) and market LTV for a sample market with `Pa = 0.9`, `Pb = 1.1`, debt duration of three months, and a target APY of 5%.

<figure><img src="/files/rErlVCOb3KY61ymZTSMq" alt=""><figcaption><p>Yield Coin price and implied APY as a function of market LTV.</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.


---

# 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.covenant.finance/protocol-mechanism/latent-swap-amm.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.
