# spark\_flashnet\_addLiquidity

{% hint style="info" %}
This method is coming :soon:
{% endhint %}

Use the `spark_flashnet_addLiquidity` method to request a Flashnet liquidity provision directly from the user’s Spark wallet.

Your app provides the pool and asset parameters (asset A/B amounts, minimum amounts, etc.), and the wallet handles the full process:

* Initiates the Spark transfers for both assets
* Generates and signs the liquidity intent
* Submits to Flashnet
* Returns the result (success, partial acceptance, or rejection)

This abstracts all complexity into a **single request**, making liquidity provision simple and secure.

***

## 📦 Example

```ts
import { request } from "sats-connect";

try {
  const response = await request("spark_flashnet_addLiquidity", {
    poolId: "03aabbccddeeff00112233445566778899aabbccddeeff00112233445566778899",
    assetAAmountToAdd: "100000000", // sats or smallest units
    assetAMinAmountIn: "95000000",
    assetBAmountToAdd: "50000",
    assetBMinAmountIn: "45000",
    userPublicKey: "03abcdef0123456789abcdef0123456789abcdef0123456789abcdef01234567",
    nonce: "add-liquidity-1702934567890"
  });

  if ("result" in response) {
    console.log("Liquidity result:", response.result);
  } else {
    console.error("Add liquidity failed:", response.error.message);
  }
} catch (error) {
  console.error("Unexpected error:", error);
}
```

***

## 📤 Parameters

| Field               | Type     | Required | Description                                           |
| ------------------- | -------- | -------- | ----------------------------------------------------- |
| `poolId`            | `string` | ✅        | Flashnet pool to add liquidity to                     |
| `assetAAmountToAdd` | `string` | ✅        | Amount of asset A to add (in smallest unit)           |
| `assetAMinAmountIn` | `string` | ✅        | Minimum asset A amount required (slippage protection) |
| `assetBAmountToAdd` | `string` | ✅        | Amount of asset B to add                              |
| `assetBMinAmountIn` | `string` | ✅        | Minimum asset B amount required (slippage protection) |
| `userPublicKey`     | `string` | ✅        | Must match the wallet’s Spark account                 |
| `nonce`             | `string` | optional | Unique nonce. If omitted, wallet generates one        |

***

## ✅ Responses

The method returns a `Promise` resolving to a `SparkFlashnetAddLiquidityResult`.

**Full Success**

```json
{
  "accepted": true,
  "assetAAmountUsed": "100000000",
  "assetBAmountUsed": "50000",
  "lpTokensMinted": "12340000",
  "requestId": "01HJZKFABCDEFGHJKLMNPQRSTVW"
}
```

**Rejection**

```json
{
  "accepted": false,
  "error": "Pool is not accepting liquidity",
  "refund": {
    "assetAAmount": "100000000",
    "assetATransferId": "850h9700-h50e-73g7-d049-779988770003",
    "assetBAmount": "50000",
    "assetBTransferId": "950i0800-i61f-84h8-e150-880099880004"
  },
  "requestId": "01HJZKFABCDEFGHJKLMNPQRSTVW"
}
```

**Partial Success (with refund)**

```json
{
  "accepted": true,
  "assetAAmountUsed": "95000000",
  "assetBAmountUsed": "50000",
  "lpTokensMinted": "11500000",
  "refund": {
    "assetAAmount": "5000000",
    "assetATransferId": "750g8600-g49d-62f6-c938-668877660002"
  },
  "requestId": "01HJZKFABCDEFGHJKLMNPQRSTVW"
}
```
