NestDevelopers
Reference

Errors and recovery

Common program errors, their causes, and the appropriate recovery action.

Nest rejects an instruction when the supplied state or pricing does not satisfy the program constraints. Most of these errors should update the UI state rather than trigger an automatic retry loop.

RejectionMeaningSafe response
Protocol or market pausedAn administrator or emergency breaker disabled the actionDisable the action and refresh on-chain flags
Stale / invalid oraclePrice age, confidence, feed, signature, or instruction proof failedFetch a new payload and rebuild the whole transaction
Borrow LTV exceededMint or withdrawal would leave debt above the market's borrow limitReduce output, add collateral, or repay debt
Debt or deposit cap exceededA per-vault, market, or protocol cap would be crossedDisplay remaining capacity; do not retry unchanged
Insufficient collateral / token balanceWallet or vault cannot fund the requested raw amountRefresh balances and reduce the amount
Bad debt outstandingRisk-sensitive PSM or staking actions are temporarily unavailableDisable the action until on-chain bad debt is zero
Stake capacity exceededThe requested deposit would exceed supported staking capacityQuote a smaller stake from current state
Cooldown activePending unstake is not claimable yetShow the chain-derived unlock timestamp
Claim window expiredThe pending request can no longer receive nUSDCall cancel_expired_unstake to restore snUSD
Pending unstake already existsThe owner PDA already holds one requestComplete or recover it before making another
PSM outflow breaker / idle liquiditySwap-out exceeds the rolling limit or available USDCShow it as temporarily unavailable; do not bypass it

Preserve simulation logs

const simulation = await connection.simulateTransaction(transaction);
if (simulation.value.err) {
  const diagnostic = {
    error: simulation.value.err,
    logs: simulation.value.logs ?? [],
    unitsConsumed: simulation.value.unitsConsumed,
  };
  // Show a friendly mapped error to the user. Send this diagnostic only to a
  // redacted application logger; never attach wallet secrets or RPC URLs.
  throw new Error(JSON.stringify(diagnostic));
}

After a blockhash expires, rebuild and re-simulate from fresh account state. Do not only replace recentBlockhash: deadlines, balances, debt, oracle values, and output quotes may all have changed.

On this page