Developers
Getting swap quotes
Convert amounts and read the minimum received.
Quotes take a raw input amount. Multiply the human amount by 10 to the power of the input token’s decimals; SOL has 9.
const lamports = BigInt(Math.round(0.25 * 1e9)).toString()
const { data: q } = await privy(
`/quote?inputMint=So11111111111111111111111111111111111111112&outputMint=EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v&amount=${lamports}&slippageBps=100`
)
const minUsdc = Number(q.minimumOutAmount) / 1e6
console.log(`You receive at least ${minUsdc} USDC`)slippageBps defaults to 1500 (15%) and accepts 10 to 5000. A NO_ROUTE error means no market exists for that pair and size; try a smaller amount.
