Add SwapParams.wait_for_all_submits to restore all-routes signature collection
v4.0.11 switched the fast-submit (`wait_tx_confirmed = false`) result loop from `wait_for_all_submitted` to `wait_for_first_submitted`. The new function returns as soon as one SWQOS route's HTTP submit completes and drains whatever signatures are in `ResultCollector.results` at that moment — slower routes' signatures arrive after the caller has returned. This is correct for fire-and-forget low-latency submits, but breaks callers that do their own on-chain confirmation against a pinned durable nonce. Only one of the submitted txs can land (nonce is consumed by whichever lands first), but the caller has no way of knowing in advance which route it will be. Their post-submit logic feeds every returned signature to `getSignatureStatuses` to find the landed one — with only the fastest HTTP responder returned (often not the one that lands), the landed tx isn't in the polled set. Adds an opt-in `SwapParams.wait_for_all_submits: bool` (default false, plumbed through `TradeBuyParams` / `TradeSellParams`). When true and `wait_tx_confirmed = false`, `execute_parallel` uses `wait_for_all_submitted` (still in the codebase, was `#[allow(dead_code)]`) so every submitted signature is returned. Zero behaviour change for current users.
This commit is contained in:
@@ -362,6 +362,11 @@ pub struct TradeBuyParams {
|
||||
pub address_lookup_table_account: Option<AddressLookupTableAccount>,
|
||||
/// Whether to wait for transaction confirmation before returning
|
||||
pub wait_tx_confirmed: bool,
|
||||
/// Fast-submit only (`wait_tx_confirmed = false`): when true, wait for every
|
||||
/// SWQOS route's HTTP submit response so all submitted signatures are
|
||||
/// returned. Set to true when confirming externally against a pinned
|
||||
/// durable nonce; defaults to false. See `SwapParams.wait_for_all_submits`.
|
||||
pub wait_for_all_submits: bool,
|
||||
/// Whether to create input token associated token account
|
||||
pub create_input_token_ata: bool,
|
||||
/// Whether to close input token associated token account after trade
|
||||
@@ -414,6 +419,11 @@ pub struct TradeSellParams {
|
||||
pub address_lookup_table_account: Option<AddressLookupTableAccount>,
|
||||
/// Whether to wait for transaction confirmation before returning
|
||||
pub wait_tx_confirmed: bool,
|
||||
/// Fast-submit only (`wait_tx_confirmed = false`): when true, wait for every
|
||||
/// SWQOS route's HTTP submit response so all submitted signatures are
|
||||
/// returned. Set to true when confirming externally against a pinned
|
||||
/// durable nonce; defaults to false. See `SwapParams.wait_for_all_submits`.
|
||||
pub wait_for_all_submits: bool,
|
||||
/// Whether to create output token associated token account
|
||||
pub create_output_token_ata: bool,
|
||||
/// Whether to close output token associated token account after trade
|
||||
@@ -868,6 +878,7 @@ impl TradingClient {
|
||||
gas_fee_strategy: params.gas_fee_strategy,
|
||||
simulate: params.simulate,
|
||||
log_enabled: self.log_enabled,
|
||||
wait_for_all_submits: params.wait_for_all_submits,
|
||||
use_dedicated_sender_threads: self.use_dedicated_sender_threads,
|
||||
sender_thread_cores: self.sender_thread_cores.clone(),
|
||||
max_sender_concurrency: self.max_sender_concurrency,
|
||||
@@ -983,6 +994,7 @@ impl TradingClient {
|
||||
gas_fee_strategy: params.gas_fee_strategy,
|
||||
simulate: params.simulate,
|
||||
log_enabled: self.log_enabled,
|
||||
wait_for_all_submits: params.wait_for_all_submits,
|
||||
use_dedicated_sender_threads: self.use_dedicated_sender_threads,
|
||||
sender_thread_cores: self.sender_thread_cores.clone(),
|
||||
max_sender_concurrency: self.max_sender_concurrency,
|
||||
|
||||
Reference in New Issue
Block a user