> For the complete documentation index, see [llms.txt](https://docs.aqua.network/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.aqua.network/developers/code-examples/deposit-liquidity.md).

# Deposit liquidity

Deposit tokens into a pool and receive pool share tokens in return. The SDK discovers the pool, orders the tokens, derives the minted-shares guard from a simulation of your exact deposit, and returns what actually happened on-chain.

{% hint style="info" %}
This page uses the [official SDKs](/developers/integrating-with-aquarius.md#official-sdks). For the raw router signature — `deposit(user, tokens, pool_index, desired_amounts, min_shares)` — and other languages, see [Aquarius Soroban Functions](https://github.com/AquariusDeFi/gitbook-docs/tree/master/developers/aquarius-soroban-functions.md).
{% endhint %}

### 1. Set up the client

The account needs a balance of every token it deposits. Everything below works identically on [testnet](/developers/testing-on-testnet.md) with `network="testnet"` and the testnet AQUA issuer.

{% tabs %}
{% tab title="Python" %}

```python
from stellar_sdk import Keypair
from aquarius import AquariusClient, Asset, XLM

AQUA = Asset.classic("AQUA", "GBNZILSTVQZ4R7IKQDGHYGY2QXL5QOFJYQMXPKWRRM5PAV7Y4M67AQUA")

aqua = AquariusClient(network="mainnet", signer=Keypair.from_secret("S..."))
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
import { Keypair } from "@stellar/stellar-sdk";
import { AquariusClient, Asset, XLM } from "@aquariusdefi/sdk";

const AQUA = Asset.classic("AQUA", "GBNZILSTVQZ4R7IKQDGHYGY2QXL5QOFJYQMXPKWRRM5PAV7Y4M67AQUA");

const aqua = new AquariusClient({ network: "mainnet", signer: Keypair.fromSecret("S...") });
```

{% endtab %}
{% endtabs %}

### 2. Find the pool

A pair can have several pools — different types and fee tiers. `pools_for_pair` returns all of them, sorted by type and fee:

{% tabs %}
{% tab title="Python" %}

```python
pools = aqua.pools_for_pair(XLM, AQUA)
# [Pool(type='volatile', fee_bps=10, ...), Pool(type='volatile', fee_bps=30, ...), ...]

pool = next(p for p in pools if p.type == "volatile" and p.fee_bps == 30)
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const pools = await aqua.pools.forPair(XLM, AQUA);
// [Pool { type: 'volatile', feeBps: 10, ... }, Pool { type: 'volatile', feeBps: 30, ... }, ...]

const pool = pools.find(p => p.type === "volatile" && p.feeBps === 30);
```

{% endtab %}
{% endtabs %}

### 3. Deposit

Amounts are keyed by asset, in base units (stroops); the SDK handles the contract's token ordering. Volatile pools take the two tokens at the current reserve ratio — anything beyond that ratio stays in your account:

{% tabs %}
{% tab title="Python" %}

```python
result = pool.deposit({XLM: 50_0000000, AQUA: 2500_0000000}, slippage=0.01)

print(f"deposited: {result.amounts}")   # base units actually taken, in sorted-token order
print(f"shares minted: {result.shares}")
print(f"transaction: {result.tx_hash}")
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const result = await pool.deposit({
  amounts: [[XLM, 50_0000000n], [AQUA, 2500_0000000n]],
  slippage: 0.01,
});

console.log(`deposited: ${result.amounts}`);   // base units actually taken, in sorted-token order
console.log(`shares minted: ${result.shares}`);
console.log(`transaction: ${result.txHash}`);
```

{% endtab %}
{% endtabs %}

The `slippage` guard works like a swap's: the SDK simulates your exact deposit, takes the estimated shares, and submits with a minimum reduced by `slippage` (default 1%). If pool state moves past that guard between simulation and inclusion, the transaction fails with a `SlippageError` instead of minting fewer shares than you saw.

{% hint style="warning" %}
`deposit` refuses concentrated pools: a router deposit into one silently opens a **full-range position**, which is rarely what a liquidity provider wants. Manage concentrated positions through the pool contract — see [Concentrated liquidity](/developers/concentrated-liquidity.md).
{% endhint %}

### Next steps

* [Withdraw liquidity](/developers/code-examples/withdraw-liquidity.md) — burn the shares for the underlying tokens.
* [Claim LP rewards](/developers/code-examples/claim-lp-rewards.md) — collect the AQUA the position accrues.
* [Get pools info](/developers/code-examples/get-pools-info.md) — reserves, share totals, and positions, no signer required.
