Swap
Last updated
Last updated
Understanding Slippage: Slippage refers to the difference between the expected price of a trade and the price at which the trade is executed.
Applying Slippage:
To apply slippage, request less amountOut
for the amountIn
you are swapping.
For example, to apply a 3% slippage tolerance:
Subtract 3% from the amountOut
value.
Use this adjusted amountOut
in your swap request.
Program Behavior:
The program checks if you are entitled to receive more tokenOut
than specified in the transaction.
If Yes:
Swap from Rune to BTC: The program will include the additional BTC you should receive in the transaction.
Swap from BTC to Rune: The program will hold the extra Rune you should have received. In your next call to the program, it will send you your corresponding portion.
Generates a PSBT for performing a swap between tokens in a pool.
/v0/pool/swap/psbt
The identifier of the pool.
^[0-9a-fA-F]+$
The amount of input token to swap.
^[1-9][0-9]*$
The amount of output token expected.
^[1-9][0-9]*$
The fee rate for the transaction (in sats per byte).
A boolean indicating whether to swap from token0 to token1.
A boolean indicating whether the swap is exact in.
The split rune PSBT in base64 format.
^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{4}|[A-Za-z0-9+/]{3}=|[A-Za-z0-9+/]{2}={2})$
The public key of the rune address of the user initiating the request.
^[0-9a-fA-F]+$
The public key of the bitcoin address of the user initiating the request. If the user doesn't have a bitcoin address, the runePubkey will be used
^[0-9a-fA-F]+$
The rune address of the user. It must be a taproot address. (P2TR). If no bitcoin address is provided, the rune address will be used for bitcoin too.
The bitcoin address of the user.
Generates a message hash for performing a swap, which the user should sign.
/v0/pool/swap/message
The signed PSBT in base64 format.
^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{4}|[A-Za-z0-9+/]{3}=|[A-Za-z0-9+/]{2}={2})$
The split rune PSBT in base64 format.
^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{4}|[A-Za-z0-9+/]{3}=|[A-Za-z0-9+/]{2}={2})$
The identifier of the pool.
^[0-9a-fA-F]+$
The amount of input token to swap.
^[1-9][0-9]*$
The amount of output token expected.
^[1-9][0-9]*$
The fee rate for the transaction (in sats per byte).
A boolean indicating whether to swap from token0 to token1.
A boolean indicating whether the swap is exact in.
The public key of the rune address of the user initiating the request.
^[0-9a-fA-F]+$
The public key of the bitcoin address of the user initiating the request. If the user doesn't have a bitcoin address, the runePubkey will be used
^[0-9a-fA-F]+$
The rune address of the user. It must be a taproot address. (P2TR). If no bitcoin address is provided, the rune address will be used for bitcoin too.
The bitcoin address of the user.
The pubkeys of the shards. Only applicable in the btc=>rune swap. (zeroToOne=false)
Finalizes the swap transaction by submitting the signed message and executing the swap on the network.
/v0/pool/swap
The signed PSBT in base64 format.
^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{4}|[A-Za-z0-9+/]{3}=|[A-Za-z0-9+/]{2}={2})$
The split rune PSBT in base64 format.
^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{4}|[A-Za-z0-9+/]{3}=|[A-Za-z0-9+/]{2}={2})$
The identifier of the pool.
^[0-9a-fA-F]+$
The amount of input token to swap.
^[1-9][0-9]*$
The amount of output token expected.
^[1-9][0-9]*$
The fee rate for the transaction (in sats per byte).
A boolean indicating whether to swap from token0 to token1.
A boolean indicating whether the swap is exact in.
The public key of the rune address of the user initiating the request.
^[0-9a-fA-F]+$
The public key of the bitcoin address of the user initiating the request. If the user doesn't have a bitcoin address, the runePubkey will be used
^[0-9a-fA-F]+$
The user's signature of the swap message.
^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{4}|[A-Za-z0-9+/]{3}=|[A-Za-z0-9+/]{2}={2})$
The rune address of the user. It must be a taproot address. (P2TR). If no bitcoin address is provided, the rune address will be used for bitcoin too.
The bitcoin address of the user.
The pubkeys of the shards. Only applicable in the btc=>rune swap. (zeroToOne=false)