> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/mezo-org/documentation/llms.txt
> Use this file to discover all available pages before exploring further.

# Mezo Pools

> Developer guide for integrating with Mezo Pools, enabling token swaps and liquidity provision using optimized pool mechanics

Mezo Pools enable users to swap tokens and provide liquidity using optimized pool mechanics. Pools currently supports selected liquidity pools and curated integrations, with plans to open up permissionless access in the future.

<Note>
  This documentation is a rough overview. More technical details will be added over the coming days.
</Note>

## How Pools Work

* **Pool Factory:** Deployed by the Mezo team (not permissionless yet)

### Supported Pools

\| Pool | Address |
\|------|---------||
\| MUSD/BTC | `0x52e604c44417233b6CcEDDDc0d640A405Caacefb` |
\| MUSD/mUSDC | `0xEd812AEc0Fecc8fD882Ac3eccC43f3aA80A6c356` |
\| MUSD/mUSDT | `0x10906a9E9215939561597b4C8e4b98F93c02031A` |

### Pool Mechanics

* **Pool Logic:** Aerodrome-style AMM (either constant-product or stable-curve depending on pair)
* **Swap Fees:** Set per pool (e.g. 0.05%, 0.3%)
* **Liquidity Farming:** Fee accrual enabled; reward distributions planned later

## How Swaps Work

**Router Contract:** `0x16A76d3cd3C1e3CE843C6680d6B37E9116b5C706`

### Swap Flow

<Steps>
  <Step title="Approve token to router">
    User approves token to router contract
  </Step>

  <Step title="Call router swap function">
    Call router's `swapExactTokensForTokens(...)` with path array
  </Step>

  <Step title="Receive output token">
    Output token is returned to wallet
  </Step>
</Steps>

### Key Features

* **Slippage Control:** Provided on frontend or via parameters in the contract call
* **No Oracles Needed:** Prices derived from pool reserves directly

## Contract Addresses

### Core Contracts

\| Name | Address |
\|------|---------||
\| Router | `0x16A76d3cd3C1e3CE843C6680d6B37E9116b5C706` |
\| PoolFactory | `0x83FE469C636C4081b87bA5b3Ae9991c6Ed104248` |
\| MUSD/BTC Pool | `0x52e604c44417233b6CcEDDDc0d640A405Caacefb` |
\| MUSD/mUSDC Pool | `0xEd812AEc0Fecc8fD882Ac3eccC43f3aA80A6c356` |
\| MUSD/mUSDT Pool | `0x10906a9E9215939561597b4C8e4b98F93c02031A` |

### Mainnet Contracts

<CodeGroup>
  ```text Core Contracts theme={null}
  Router: 0x16A76d3cd3C1e3CE843C6680d6B37E9116b5C706
  PoolFactory: 0x83FE469C636C4081b87bA5b3Ae9991c6Ed104248
  ```

  ```text Pool Contracts theme={null}
  MUSD/BTC Pool: 0x52e604c44417233b6CcEDDDc0d640A405Caacefb
  MUSD/mUSDC Pool: 0xEd812AEc0Fecc8fD882Ac3eccC43f3aA80A6c356
  MUSD/mUSDT Pool: 0x10906a9E9215939561597b4C8e4b98F93c02031A
  ```

  ```text Governance Contracts theme={null}
  VeBTC: 0x7D807e9CE1ef73048FEe9A4214e75e894ea25914
  VeBTCVoter: 0x3A4a6919F70e5b0aA32401747C471eCfe2322C1b
  VeBTCRewardsDistributor: 0x535E01F948458E0b64F9dB2A01Da6F32E240140f
  VeBTCEpochGovernor: 0x1494102fa1b240c3844f02e0810002125fb5F054
  ChainFeeSplitter: 0xcb79aE130b0777993263D0cdb7890e6D9baBE117
  ```
</CodeGroup>

### Testnet Contracts

<CodeGroup>
  ```text Core Contracts theme={null}
  Router: 0x9a1ff7FE3a0F69959A3fBa1F1e5ee18e1A9CD7E9
  PoolFactory: 0x4947243CC818b627A5D06d14C4eCe7398A23Ce1A
  ```

  ```text Pool Contracts theme={null}
  MUSD/BTC Pool: 0xd16A5Df82120ED8D626a1a15232bFcE2366d6AA9
  MUSD/mUSDC Pool: 0x525F049A4494dA0a6c87E3C4df55f9929765Dc3e
  MUSD/mUSDT Pool: 0x27414B76CF00E24ed087adb56E26bAeEEe93494e
  ```

  ```text Governance Contracts theme={null}
  VeBTC: 0xB63fcCd03521Cf21907627bd7fA465C129479231
  VeBTCVoter: 0x72F8dd7F44fFa19E45955aa20A5486E8EB255738
  VeBTCRewardsDistributor: 0x10B0E7b3411F4A38ca2F6BB697aA28D607924729
  VeBTCEpochGovernor: 0x12fda93041aD8aB6d133aE4d038b5159033d937a
  ChainFeeSplitter: 0x63aD4D014246eaD52408dF3BC8F046107cbf6065
  ```
</CodeGroup>

## Integration Examples

### Executing a Token Swap

```typescript theme={null}
import { ethers } from 'ethers';

const ROUTER_ADDRESS = '0x16A76d3cd3C1e3CE843C6680d6B37E9116b5C706';

async function executeSwap(
  provider: ethers.Provider,
  signer: ethers.Signer,
  tokenIn: string,
  tokenOut: string,
  amountIn: bigint,
  minAmountOut: bigint
) {
  // Connect to router contract
  const router = new ethers.Contract(ROUTER_ADDRESS, ROUTER_ABI, signer);
  
  // Approve token spending
  const tokenContract = new ethers.Contract(tokenIn, ERC20_ABI, signer);
  const approveTx = await tokenContract.approve(ROUTER_ADDRESS, amountIn);
  await approveTx.wait();
  
  // Execute swap
  const deadline = Math.floor(Date.now() / 1000) + 60 * 20; // 20 minutes
  const path = [tokenIn, tokenOut];
  
  const swapTx = await router.swapExactTokensForTokens(
    amountIn,
    minAmountOut,
    path,
    await signer.getAddress(),
    deadline
  );
  
  await swapTx.wait();
}
```

### Adding Liquidity to a Pool

```typescript theme={null}
async function addLiquidityToPool(
  signer: ethers.Signer,
  tokenA: string,
  tokenB: string,
  amountA: bigint,
  amountB: bigint,
  minAmountA: bigint,
  minAmountB: bigint
) {
  const router = new ethers.Contract(ROUTER_ADDRESS, ROUTER_ABI, signer);
  
  // Approve both tokens
  const tokenAContract = new ethers.Contract(tokenA, ERC20_ABI, signer);
  const tokenBContract = new ethers.Contract(tokenB, ERC20_ABI, signer);
  
  await (await tokenAContract.approve(ROUTER_ADDRESS, amountA)).wait();
  await (await tokenBContract.approve(ROUTER_ADDRESS, amountB)).wait();
  
  // Add liquidity
  const deadline = Math.floor(Date.now() / 1000) + 60 * 20;
  
  const tx = await router.addLiquidity(
    tokenA,
    tokenB,
    amountA,
    amountB,
    minAmountA,
    minAmountB,
    await signer.getAddress(),
    deadline
  );
  
  await tx.wait();
}
```

## Router Function Parameters

<ParamField path="amountIn" type="uint256" required>
  The exact amount of input tokens to swap
</ParamField>

<ParamField path="minAmountOut" type="uint256" required>
  The minimum amount of output tokens to receive (slippage protection)
</ParamField>

<ParamField path="path" type="address[]" required>
  Array of token addresses representing the swap path
</ParamField>

<ParamField path="to" type="address" required>
  Recipient address for the output tokens
</ParamField>

<ParamField path="deadline" type="uint256" required>
  Unix timestamp after which the transaction will revert
</ParamField>

## Best Practices

<Note>
  **Slippage Protection**: Always calculate and set appropriate `minAmountOut` values to protect against unfavorable price movements during transaction execution.
</Note>

<Note>
  **Deadline Management**: Set reasonable deadline values (typically 10-20 minutes) to prevent transactions from executing at stale prices.
</Note>

<Note>
  **Gas Optimization**: Batch approval and swap transactions when possible to reduce gas costs.
</Note>
