Tx Doctor / Solana error library / Calculation exchange rate failed

Raydium AMM 31 (0x1f)0x1f

Solana error: Calculation exchange rate failed (0x1f)

The price calculation could not produce a number: either a reserve used in the division was zero, or the result overflowed the fixed-point type.

Why it happens

How to fix it

  1. Check both vault balances on chain. If either is zero the pool is unusable — route to another pool instead of retrying.
  2. Try a larger amount for dust-size swaps; the AMM needs the rate to survive integer rounding.
  3. Compare the pool account against a freshly fetched one; if reserves disagree with vault balances, the pool is broken.
  4. Pick a different venue for extreme-decimal pairs — thin custom pools are where this fires most.

What it looks like in the logs

Program 675kPX9MHTjS2zt1qfr1NYHuzeLXfQM9H24wFSUt1Mp8 failed: custom program error: 0x1f

RPC simulation:
  Transaction simulation failed: Error processing Instruction : custom program error: 0x1f

Wallet UI:
  "Transaction failed" — custom program error 0x1f (31)

One failure, three places it shows up: the raw transaction log, the RPC simulation error, and the wallet's short message. Match on the code, never on the wording.

The same number means something else on another program

Anchor assigns custom error codes by enum order starting at 6000, so this number is local to this program. The rows below show what the very same number means on the other programs.

Program0x1f = 31
Token-2022Mint required for this account to transfer tokens

What this means for your funds

Solana transactions are atomic: if any instruction fails, every state change in that transaction is reverted, so token balances end exactly where they started. The network fee is still charged, because validators did the work of executing and rejecting it. A failed transaction never moves your tokens to someone else.

Seeing this error right now? Paste your transaction signature and get the exact instruction, program and code that failed.

Diagnose my transaction

Related Solana errors

Position not empty — cannot close

Raydium CLMM 6003 (0x1773)

Both token amounts are zero

Raydium CLMM 6015 (0x177f)

Liquidity insufficient for withdrawal

Raydium CLMM 6016 (0x1780)

Not enough liquidity in this direction

Raydium CLMM 6036 (0x1794)

Invalid supply

Raydium AMM 19 (0x13)

Checked subtraction overflow

Raydium AMM 32 (0x20)