Overview
The rate endpoint provides price quotes for token swaps before executing a transaction. Use this to show users the expected output amount and price impact when they’re ready to swap.Use Cases
- Pre-Swap Quotes: Get accurate pricing before executing a swap
- Slippage Calculation: Show users the minimum guaranteed output
- Price Impact Check: Validate that trade size is acceptable
SDK Examples
Response Fields
Field | Type | Description |
---|---|---|
amountIn | number | Input token amount |
amountOut | number | Expected output token amount |
minAmountOut | number | Minimum output after slippage |
currentPrice | number | Current market price |
executionPrice | number | Actual execution price |
priceImpact | number | Price impact as decimal (0.05 = 5%) |
fee | number | Trading fee |
platformFee | number | Platform fee in lamports |
platformFeeUI | number | Platform fee in SOL |
Example Response
Understanding Price Impact
Price impact shows how much your trade moves the market price:- < 1% - Excellent liquidity, proceed with confidence
- 1-5% - Acceptable for most trades
- > 5% - Consider splitting into smaller trades or increasing slippage
Validate Before Swap
Common Errors
Error | Description | Solution |
---|---|---|
Invalid or missing token address | Token address is invalid | Verify token addresses |
Invalid amount | Amount is not valid | Ensure amount is positive |
Invalid slippage tolerance | Slippage not between 0-100 | Set slippage 0-100 |
Unable to fetch pools | Cannot find liquidity | Token may lack active pools |
Next Steps
Query Parameters
The base token address
"So11111111111111111111111111111111111111112"
The quote token address
"4k3Dyjzvzp8eMZWUXbBCjEvwSkkk59S5iCNLY3QrkX6R"
The amount of the base token to convert (in native units, not lamports)
1
The maximum acceptable slippage percentage
0 <= x <= 100
10
Response
Successful rate quote
The amount of the source token used for the conversion
1
The amount of the destination token that would be received
9181.330823048
The minimum amount of the destination token after applying slippage
9089.517514818
The current market price for the token pair
9181.330823048
The actual price at which the trade would be executed
9089.517514818
The difference between market price and execution price as a fraction
0.0334641736518774
The trading fee charged for the transaction
0.01
The fee charged by the platform in lamports
9000000
The platform fee in SOL
0.009