selectQuote
Pick the best simulated quote from a set of in-flight quote+simulation promises. This is useful when you want to stream quotes and simulations concurrently and only commit to the best result once enough data is available.
Example
Params
quotes
Array<Promise<SimulatedQuote>>
A list of promises each resolving to a simulated quote. These can be created via the prepareQuotes function.
strategy
QuoteSelectionStrategy
Strategy used to pick a winning quote.
| Strategy | Waits for All | Selection Criteria | Best For |
|---|---|---|---|
bestPrice | ✓ | Highest simulated output | Price optimization |
estimatedGas | ✓ | Lowest simulated gas used | Gas efficiency |
fastest | ✗ | First success | Speed/latency |
priority | ✗ | Provider order | Fallback chains |
| Custom | Depends | Your logic | Special requirements |
type QuoteSelectionFn = (
quotes: Array<Promise<SimulatedQuote>>
) => Promise<SuccessfulSimulatedQuote | null>Returns
Promise<SuccessfulSimulatedQuote | null>
A promise for a single simulated quote that offers the best outcome depending on the strategy.