sparklespark_flashnet_addLiquidity

circle-info

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