nautechsystems/nautilus_trader · error · anyhow::Error

Persisted swap account does not match execution client accou

Error message

Persisted swap account does not match execution client account

What it means

restore_swap_plan (crates/adapters/blockchain/src/execution/client.rs:853) checks the persisted intent's account_id equals self.core.account_id - the execution client's own account. A mismatch means the active swap intent was recorded for a different execution account than the client now running; reconciliation refuses because this client is not the account that owns the on-chain wallet state and order flow. This prevents one account's client from adopting and completing another account's in-flight swap.

Source

Thrown at crates/adapters/blockchain/src/execution/client.rs:853

            intent
                .instrument_id
                .as_deref()
                .ok_or_else(|| anyhow::anyhow!("Persisted swap intent has no instrument ID"))?,
        )?;
        anyhow::ensure!(
            order.instrument_id() == instrument_id,
            "Persisted swap instrument {instrument_id} does not match restored order instrument {}",
            order.instrument_id()
        );
        anyhow::ensure!(
            intent.trader_id.as_deref() == Some(order.trader_id().as_str()),
            "Persisted swap trader does not match restored order"
        );
        anyhow::ensure!(
            intent.strategy_id.as_deref() == Some(order.strategy_id().as_str()),
            "Persisted swap strategy does not match restored order"
        );
        anyhow::ensure!(
            intent.account_id.as_deref() == Some(self.core.account_id.as_str()),
            "Persisted swap account does not match execution client account"
        );

        let pool = self.resolve_pool(&instrument_id)?;
        let pool_address = Address::from_str(
            intent
                .pool_address
                .as_deref()
                .ok_or_else(|| anyhow::anyhow!("Persisted swap intent has no pool address"))?,
        )?;
        anyhow::ensure!(
            pool.address == pool_address,
            "Persisted pool {pool_address} does not match restored pool {}",
            pool.address
        );
        let amount_in = U256::from_str(
            intent

View on GitHub (pinned to 2114cf6f76)

Solutions

  1. Run the client whose account_id matches the intent's recorded account so it can legitimately reconcile.
  2. Or verify the intent's transaction on-chain and mark it resolved so other accounts can connect cleanly.
  3. Give each execution account its own durable store or ensure intents are drained before re-keying accounts.
  4. Check for config drift between environments sharing the database.
Defensive patterns

Strategy: try-catch

Validate before calling

-- Pre-flight: active intents recorded for a different execution account
SELECT id, account_id, status
FROM execution_intent
WHERE status IN ('prepared', 'signed', 'submitted');
-- compare account_id against the account the client will boot with

Type guard

fn is_account_mismatch(e: &anyhow::Error) -> bool {
    e.to_string().contains("Persisted swap account does not match execution client account")
}

Try / catch

if let Err(e) = client.connect().await {
    if is_account_mismatch(&e) {
        // this client is not the intent's owner: boot the matching account or resolve the intent
        log::error!("active intent belongs to another execution account: {e}");
    }
    return Err(e);
}

Prevention

When it happens

Trigger: The execution client's account_id configuration changed while an intent persisted under the old account is still active; two client configurations (e.g. test and prod accounts) share one Postgres store and the wrong one reconciles the other's intent.

Common situations: Switching wallet/account configuration without draining active intents; shared durable stores across multiple trading accounts.

Related errors


AI-assisted analysis of nautechsystems/nautilus_trader@2114cf6f76 (2026-08-21). Data as JSON: /api/errors/777df2cfb4e1d9da. Report an issue: GitHub.