Tx Doctor / Solana error library / Calculation exchange rate failed
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
- One side of the pool holds zero after a full drain or an initialisation that never funded the vault.
- The two mints have very different decimals and the amounts are extreme, so the intermediate product exceeds u128.
- Pool state is corrupt or was written by a fork with different math, so the reserve fields do not match the vaults.
- A dust-sized swap against a huge reserve floors to zero and the rate check rejects it.
How to fix it
- Check both vault balances on chain. If either is zero the pool is unusable — route to another pool instead of retrying.
- Try a larger amount for dust-size swaps; the AMM needs the rate to survive integer rounding.
- Compare the pool account against a freshly fetched one; if reserves disagree with vault balances, the pool is broken.
- 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.
| Program | 0x1f = 31 |
|---|---|
| Token-2022 | Mint 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 transactionRelated 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)