market.prices().
You need a market people can already trade, collateral (to buy) or shares (to sell), and the token for a named answer. If the quote cannot fill the full size, swap the capped amount, not the original number.
withinRange: false). If it capped you, swap quote.amountIn, not the original number.
Quote again right before you send — mids from the indexer can be stale.