Are you an LLM? Read llms.txt for a summary of the docs, or llms-full.txt for the full context.
Skip to content

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.

StrategyWaits for AllSelection CriteriaBest For
bestPriceHighest simulated outputPrice optimization
estimatedGasLowest simulated gas usedGas efficiency
fastestFirst successSpeed/latency
priorityProvider orderFallback chains
CustomDependsYour logicSpecial requirements
Custom
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.