> For the complete documentation index, see [llms.txt](https://docs.mento.org/mento-v3/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.mento.org/mento-v3/build/mento-sdk/guides/liquidity.md).

# Liquidity Management

The Mento SDK v3 lets you **add liquidity**, **remove liquidity**, and **zap in/out** for **FPMM pools**. You get transaction parameters to send with any viem wallet client.

***

## Create the client

```typescript
import { Mento, ChainId, deadlineFromMinutes } from '@mento-protocol/mento-sdk'
import { parseUnits } from 'viem'

const mento = await Mento.create(ChainId.CELO)
```

***

## Add liquidity (two tokens)

Add both sides of a pool in the desired ratio. You need the pool address, token addresses, amounts, recipient, and owner:

```typescript
const addTx = await mento.liquidity.buildAddLiquidityTransaction(
  poolAddress,
  tokenA,
  amountA,
  tokenB,
  amountB,
  recipient,
  owner,
  { slippageTolerance: 0.5, deadline: deadlineFromMinutes(5) }
)
```

Send the returned transaction(s) with your viem wallet (approval first if present, then the add-liquidity tx).

***

## Zap in (single token → LP)

Deposit a **single token** and the SDK splits it into the two pool assets according to a **split ratio** (e.g. 0.5 = 50/50):

```typescript
const zapTx = await mento.liquidity.buildZapInTransaction(
  poolAddress,
  tokenIn,
  amountIn,
  0.5,   // split ratio (e.g. 50/50)
  recipient,
  owner,
  { slippageTolerance: 0.5, deadline: deadlineFromMinutes(5) }
)
```

Use this when users want to provide liquidity with one token only.

***

## Zap out (LP → single token)

Remove liquidity and receive a **single token** (the other side is swapped internally). Build the transaction with the pool, LP amount, desired output token, and options:

```typescript
const zapOutTx = await mento.liquidity.buildZapOutTransaction(
  poolAddress,
  lpAmount,
  tokenOut,
  recipient,
  owner,
  { slippageTolerance: 0.5, deadline: deadlineFromMinutes(5) }
)
```

***

## Remove liquidity (LP → two tokens)

Standard removal: burn LP and receive both pool tokens in proportion to the pool’s reserves. Use the SDK’s remove-liquidity builder (method name may be `buildRemoveLiquidityTransaction` or similar—check the package exports) with pool address, LP amount, recipient, owner, and slippage/deadline.

***

## LP token balance

Read a user’s LP token balance for a given pool:

```typescript
const balance = await mento.liquidity.getLPTokenBalance(poolAddress, owner)
```

Use this to show users their position size or to build remove/zap-out amounts.

***

## Summary

| Operation                   | Service method                                          |
| --------------------------- | ------------------------------------------------------- |
| Add liquidity (two tokens)  | `mento.liquidity.buildAddLiquidityTransaction(...)`     |
| Zap in (single token → LP)  | `mento.liquidity.buildZapInTransaction(...)`            |
| Zap out (LP → single token) | `mento.liquidity.buildZapOutTransaction(...)`           |
| LP balance                  | `mento.liquidity.getLPTokenBalance(poolAddress, owner)` |

All builders return transaction params (and optional approval) for you to send with a viem wallet. Use **slippage tolerance** and **deadline** to protect users. Runnable examples: [mento-sdk-examples](https://github.com/mento-protocol/mento-sdk-examples).


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.mento.org/mento-v3/build/mento-sdk/guides/liquidity.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
