Skip to main content
Swaps enable users to instantly trade between assets in a pool. Users can use the SDK to both simulate the outcome of a swap before executing it, and to execute the swap.

Simulating a Swap

Always simulate a swap before executing to check the expected output and slippage:

Executing a Swap

After simulating, execute the swap with slippage protection:

Advanced Swap Examples

Note on integrator fees:
  • If you set integratorFeeRateBps up to 30 BPS, none of the integrator fee is shared with Flashnet
  • If you set integratorFeeRateBps above 30 BPS, 30% of the integrator fee is shared with Flashnet
All host and integrator fees are assessed and distributed in Asset B only. Displayed amountOut values from the API are post‑fee.

Token-to-Token Swap

Bitcoin-to-Token Swap

Swap with Price Checks

Error Handling

The SDK provides typed errors with automatic fund recovery. See Error Handling for the complete guide.

Next Steps