spark_flashnet_executeSwap

This method is coming πŸ”œ

Use the spark_flashnet_executeSwap method to request a Flashnet swap directly from the user’s Spark wallet.

Your app provides the swap parameters (pool, assets, amount, slippage, etc.), and the wallet handles the full Flashnet swap process.

This abstracts all back-and-forth with Flashnet into a single request, making swaps simple and secure.

Parameters

Request parameters
Description

poolId

a string representing the Flashnet liquidity pool to use

assetInAddress

a string representing the address of the Spark asset being swapped in

assetOutAddress

a string representing the address of the Spark asset being swapped out

amountIn

a string representing the amount of input asset (in sats or smallest unit)

maxSlippageBps

Max slippage in basis points (e.g. 50 = 0.5%)

minAmountOut

ℹ️ Optional - a string representing the minimum acceptable output amount

totalIntegratorFeeRateBps

Fee (in basis points) your app requests for routing the swap. ⚠️To activate your app fee, you must be an approved Xverse partner. If you’re not approved, Xverse will ignore this value and apply its own default fee instead. πŸš€ Contact Xverse to become a partner and activate your app fee.

integratorPublicKey

Public key where your integrator fees should be sent. ⚠️ Only partner-approved (whitelisted) keys are accepted. If you pass a non-partner key, Xverse will replace it with its own. πŸš€ Contact Xverse to become a partner and get your key whitelisted.

userPublicKey

a string which must match the connected user's Spark public key

nonce

ℹ️ Optional - a string representing a unique swap nonce

Example

What spark_flashnet_executeSwap does

When called, this method:

  1. Shows the user a confirmation screen with the swap details (pool, asset in/out, amount, fees, slippage).

  2. On confirmation, the wallet:

    • Initiates the Spark transfer and authenticates your user with a Flashnet JWT

    • Generates the swap intent

    • Signs with the user’s Spark key

    • Submits to Flashnet

    • Returns the result (success or rejection)

  3. Displays a progress screen while the steps complete.

  4. Returns the swap result to the dApp.

Responses

The method returns a Promise that resolves to the SparkFlashnetSwapResultobject

βœ… Success

❌ Failure

Last updated