spark_flashnet_createCPPool

This method is coming πŸ”œ

Use the spark_flashnet_createCPPool method to request the creation of a Constant Product (CP) liquidity pool on Flashnet directly from the user’s Spark wallet.

The dApp provides the pool parameters (assets, fees, namespace, etc.), and the wallet handles the signing and submission to Flashnet.


πŸ“¦ Example

import { request } from "sats-connect";

try {
  const response = await request("spark_flashnet_createCPPool", {
    assetAAddress: "0338d6978bd3163d1547f9ddb8b215d1c163bc7b4a552e559b89057f5449ba69de",
    assetBAddress: "020202020202020202020202020202020202020202020202020202020202020202",
    hostNamespace: "my-cool-exchange",
    lpFeeRateBps: 300, // 3.00% LP fee
    totalHostFeeRateBps: 200, // 2.00% host fee
    poolOwnerPublicKey: "03b06b7c3e39bf922be19b7ad5f19554bb7991cae585ed2e3374d51213ff4eeb3c",
    nonce: "550e8400-e29b-41d4-a716-446655440000"
  });

  if ("result" in response) {
    console.log("Pool created, requestId:", response.result.requestId);
  } else {
    console.error("Pool creation failed:", response.error.message);
  }
} catch (error) {
  console.error("Unexpected error:", error);
}

πŸ“€ Parameters

Field
Type
Required
Description

assetAAddress

string

βœ…

Address of the first asset in the pool

assetBAddress

string

βœ…

Address of the second asset in the pool

hostNamespace

string

βœ…

Unique namespace for the pool (e.g. exchange name)

lpFeeRateBps

number

βœ…

Liquidity provider fee in basis points (e.g. 300 = 3.00%)

totalHostFeeRateBps

number

βœ…

Host fee in basis points (e.g. 200 = 2.00%)

poolOwnerPublicKey

string

βœ…

Public key of the pool owner

nonce

string

optional

Unique request identifier. If omitted, the wallet generates one.


βœ… Responses

  • Success (202 Accepted)

{
  "requestId": "01HJZKFABCDEFGHJKLMNPQRSTVW"
}
  • Failure

    • 400 Bad Request if the request is invalid

    • 401 Unauthorized if authentication fails

    • 500 Internal Server Error if something goes wrong internally

Last updated