spark_flashnet_addLiquidity
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
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
{
"accepted": true,
"assetAAmountUsed": "100000000",
"assetBAmountUsed": "50000",
"lpTokensMinted": "12340000",
"requestId": "01HJZKFABCDEFGHJKLMNPQRSTVW"
}
Rejection
{
"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)
{
"accepted": true,
"assetAAmountUsed": "95000000",
"assetBAmountUsed": "50000",
"lpTokensMinted": "11500000",
"refund": {
"assetAAmount": "5000000",
"assetATransferId": "750g8600-g49d-62f6-c938-668877660002"
},
"requestId": "01HJZKFABCDEFGHJKLMNPQRSTVW"
}
Last updated