> For the complete documentation index, see [llms.txt](https://docs.aperture.finance/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.aperture.finance/docs/legacy-products/terra-classic-delta-neutral-strategy-retired/constant-product-amm.md).

# Constant-product AMM

Terraswap and Astroport are automated market-maker (AMM) protocols implemented with smart contracts on the Terra blockchain.  An AMM enables a decentralized on-chain exchange for the various assets involved in Terra ecosystem.  For more details regarding these protocols, please refer to:

* Terraswap documentation: <https://docs.terraswap.io>.
* Astroport documentation: <https://docs.astroport.fi/astroport/astroport/astro-pools/constant-product-pools#how-constant-product-pools-work>.

The delta-neutral strategy uses constant-product AMMs offered by Terraswap and Astroport, to trade between UST and cw20 tokens, including mAsset, MIR and SPEC in the following situations:

* **mAsset -> UST (Terraswap):** When mAsset short position is opened or increased (at delta-neutral position open and reinvestment events), the minted mAsset is swapped for UST by Mirror's smart contract; at rebalance events, moving from a net long state back to the neutral state;
* **UST -> mAsset (Terraswap):** At rebalance events, moving from a net short state back to the neutral state;
* **MIR -> UST (Terraswap or Astroport):** At reinvestment events, the Aperture delta-neutral smart contract swaps MIR reward for UST via Terraswap or Astroport, whichever provides the better rate;
* **SPEC -> UST (Terraswap, or potentially Astroport in the future):** At reinvestment events, the Aperture delta-neutral smart contract swaps SPEC reward for UST via Terraswap; at this time there is no SPEC-UST liquidity pool on Astroport, but the Aperture delta-neutral contract is already implemented to check for such a pool on Astroport.  As a result, when the SPEC-UST Astroport pool is created and provides a better rate than Terraswap, SPEC swaps will automatically be routed to Astroport.

To learn about the mechanism of a constant-product AMM, please refer to <https://docs.terraswap.io/docs/introduction/mechanism/>.
