Authorizations
Bearer authentication header of the form Bearer <token>
, where <token>
is your auth token.
Body
Swap execution details including assets, amounts, and authentication
Request body for executing a swap on an AMM pool.
Swaps allow users to exchange one asset for another through a liquidity pool. The swap is executed atomically and the result is returned immediately.
Public key of the user executing the swap. Must match the authenticated user's public key.
"02abcdef0123456789abcdef0123456789abcdef0123456789abcdef01234567"
LP public key of the pool to swap through. The pool must be active and have sufficient liquidity.
"03aabbccddeeff00112233445566778899aabbccddeeff00112233445566778899"
Public key of the asset being provided by the user. Must be one of the two assets in the selected pool.
"03bitcoinassetpubkey0000000000000000000000000000000000000000000000"
Public key of the asset the user wants to receive. Must be the other asset in the selected pool.
"03usdstablecoinpubkey111111111111111111111111111111111111111111111"
Amount of input asset to swap, in its smallest unit. Must be positive and within the pool's liquidity capacity.
x >= 0
100000000
Optional maximum slippage tolerance in basis points (BPS).
If set, can override min_amount_out
. 1 BPS = 0.01%, so 50 BPS = 0.5%.
x >= 0
50
Optional mininimum amount out If set to none, 0
x >= 0
100000000
Spark network transfer ID proving the deposit of input asset. Must be a valid, confirmed transfer to the pool's address.
"spark-transfer-uuid-or-hash-for-asset-in"
Unique nonce
for replay protection.
Each swap must use a unique nonce
that hasn't been used before.
"unique-swap-nonce-123"
Total integrator fee the user accepts to pay.
x >= 0
100
Integrator public key.
"03aabbccddeeff00112233445566778899aabbccddeeff00112233445566778899"
Hex-encoded secp256k1 signature of the request.
Must be signed by the private key corresponding to user_public_key
.
"3045022100a7e5d4f8b2c9a1e6f0d5b8c4a9e7f2d1c8b5a4e9f0d6c5b3a2e1d0c9b8a7f02201f2e3d4c5b6a7980e9f0a1b2c3d4e5f67889a0b1c2d3e4f5a6b7c8d9e0f1a2b3"
Response
Swap executed successfully
Clean response for a successfully executed swap operation
User-friendly request ID for tracking
"01HJZKFABCDEFGHJKLMNPQRSTVW"
Whether the swap was accepted or rejected
true
Amount received from the swap (populated if accepted)
x >= 0
"495000"
Fee paid for the swap (populated if accepted)
x >= 0
"5000"
Execution price as a string (populated if accepted)
"0.00495000"
Asset received by the user (populated if accepted)
"03usdstablecoinpubkey111111111111111111111111111111111111111111111"
Asset sent by the user (populated if accepted)
"03bitcoinassetpubkey0000000000000000000000000000000000000000000000"
Spark transfer ID for receiving asset (populated if accepted)
"spark-transfer-out-123"
User-friendly error message (populated if rejected)
"Insufficient liquidity in pool"
Refunded asset (populated if rejected)
"03bitcoinassetpubkey0000000000000000000000000000000000000000000000"
Refunded amount (populated if rejected)
x >= 0
"100000000"
Spark transfer ID for refund (populated if rejected)
"spark-transfer-refund-456"