spark_flashnet_removeLiquidity
Use the spark_flashnet_removeLiquidity
method to request liquidity removal from a Flashnet pool.
Your app specifies the pool and the LP tokens to burn. The wallet shows the user a transaction review screen with the expected assets they will receive, and upon confirmation, executes the removal on Flashnet.
Example
import { request } from "sats-connect";
try {
const response = await request("spark_flashnet_removeLiquidity", {
poolId: "03aabbccddeeff00112233445566778899aabbccddeeff00112233445566778899",
lpTokensToRemove: "12340000", // amount of LP tokens in smallest units
userPublicKey: "03abcdef0123456789abcdef0123456789abcdef0123456789abcdef01234567",
nonce: "remove-liquidity-nonce-789"
});
if ("result" in response) {
console.log("Liquidity removal result:", response.result);
} else {
console.error("Remove liquidity failed:", response.error.message);
}
} catch (error) {
console.error("Unexpected error:", error);
}
Parameters
poolId
(string, required) — ID of the Flashnet pool.lpTokensToRemove
(string, required) — Amount of LP tokens to burn (in smallest unit).userPublicKey
(string, required) — Public key of the user removing liquidity. Must match their Spark wallet.nonce
(string, required) — Unique nonce to prevent replay attacks.
What spark_flashnet_removeLiquidity
does
spark_flashnet_removeLiquidity
doesWhen called, the wallet:
Shows the user a transaction review screen with pool info, LP tokens to burn, and expected asset withdrawals.
On approval, signs the request with the user’s Spark key.
Submits the removal to Flashnet.
Returns the result of the operation (success or error).
Response
The method returns a Promise that resolves to a SparkFlashnetRemoveLiquidityResult
object:
✅ Success
{
"accepted": true,
"assetAWithdrawn": "100000000",
"assetBWithdrawn": "50000",
"assetATransferId": "spark-transfer-a-789",
"assetBTransferId": "spark-transfer-b-012",
"requestId": "01HJZKFABCDEFGHJKLMNPQRSTVW"
}
⚠️ Failure
{
"accepted": false,
"error": "Insufficient LP token balance",
"requestId": "01HJZKFABCDEFGHJKLMNPQRSTVW"
}
Last updated