Swap API
Execute token swaps on prediction markets
Swap API
The Swap API provides imperative swap operations with route preview. Use this for a two-step process: first get a quote, then create the swap transaction.
Access
Methods
get_quote
Get a quote for a swap without creating a transaction.
Parameters
| Parameter | Type | Description |
|---|---|---|
input_mint | str | Mint address of the token to sell |
output_mint | str | Mint address of the token to buy |
amount | int | str | Amount to trade in base units |
slippage_bps | int | None | Slippage tolerance in basis points |
Example
create_swap
Create a swap transaction ready for signing.
Parameters
| Parameter | Type | Description |
|---|---|---|
input_mint | str | Mint address of the token to sell |
output_mint | str | Mint address of the token to buy |
amount | int | str | Amount to trade in base units |
slippage_bps | int | Slippage tolerance in basis points |
user_public_key | str | User's Solana public key |
wrap_unwrap_sol | bool | None | Whether to wrap/unwrap SOL automatically |
priority_fee | PriorityFeeConfig | None | Priority fee configuration |
Example
get_swap_instructions
Get swap instructions for custom transaction composition.