spark_flashnet_addLiquidity

This method is coming πŸ”œ

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

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

Rejection

Partial Success (with refund)

Last updated