Error reference
Every error the program can return, from errors.rs, with the usual cause and what to do. Anchor numbers custom errors from 6000 in declaration order.
| Code | Name | Message | Usual cause | What to do |
|---|---|---|---|---|
| 6000 | MathOverflow | Arithmetic overflow or an accounting total would go negative | An amount far beyond any real balance | Use realistic amounts |
| 6001 | ProgramUpgradeable | The program must be immutable (no upgrade authority) before the protocol starts | initialize sent while an upgrade authority exists | Make the program immutable first |
| 6002 | CollateralNotListed | This collateral mint is not listed | create_branch with a mint other than jitoSOL or mSOL | Only listed collateral has a branch |
| 6003 | WrongRateSource | Rate source account does not match the listed one for this collateral | Wrong stake pool or Marinade state passed | Pass the listed rate source |
| 6004 | InvalidRateSource | Rate source account data could not be read | Corrupted or wrong account | Pass the listed rate source |
| 6005 | InvalidOracleAccount | Oracle account has the wrong owner or layout | Wrong Pyth or Switchboard account | Use the feed accounts from Integration |
| 6006 | OracleStale | Pyth or Switchboard price is missing or stale: new borrowing is paused | A feed older than 120 s, or a wide Pyth confidence | Retry once the feed updates; redemptions still work |
| 6007 | OracleDisagreement | Pyth and Switchboard disagree beyond the allowed deviation: new borrowing is paused | Feeds more than 2% apart | Retry later; redemptions still work |
| 6008 | OracleUnavailable | No fresh oracle price is available | Both feeds stale | Wait for a feed update |
| 6009 | InvalidBucket | Rate bucket index out of range | Index 246 or above | Use 0 to 245 |
| 6010 | ZeroAmount | Amount must be greater than zero | Zero passed | Pass a positive amount |
| 6011 | DebtBelowMinimum | Trove debt would fall below the minimum | Debt under 200 PAR | Borrow at least 200 PAR |
| 6012 | BelowMinimumCollateralRatio | Collateral ratio would fall below 120% | Too much debt or too little collateral | Add collateral or borrow less |
| 6013 | DebtCeilingExceeded | Branch debt would exceed the scheduled debt ceiling | The branch is at its current ceiling | Wait for the next doubling or use the other branch |
| 6014 | WrongBranch | Account belongs to a different branch | A trove, bucket or deposit from another collateral | Derive accounts from the same branch |
| 6015 | TroveNotActive | Trove is not active | Adjusting a redeemed-out or liquidated trove | Use close_trove to collect what is left |
| 6016 | RepayTooLarge | Repayment exceeds what can be repaid without closing the trove | Repay would drop debt under 200 PAR | Use close_trove to repay everything |
| 6017 | InsufficientCollateral | Not enough collateral in the trove | Withdrawing more than the trove holds | Withdraw less |
| 6018 | SameRate | New rate equals the current rate | set_rate to the current bucket | Pick a different bucket |
| 6019 | TroveHealthy | Trove collateral ratio is not below 120% | Liquidating a safe trove | Nothing to do |
| 6020 | NothingToAbsorb | Nothing can absorb this liquidation: the stability pool is short and no other trove exists | Last trove of a branch with an empty pool | Fill the pool first |
| 6021 | WrongRedemptionOrder | Redemption must start from the lowest-rate non-empty bucket | A stale bucket list | Rebuild the list from the bitmap |
| 6022 | TroveNotInBucket | Trove does not belong to the bucket listed before it | Trove moved buckets | Rebuild the list |
| 6023 | InvalidRedemptionAccount | Redemption account is neither a bucket nor a trove of this branch | Foreign account in the list | Pass only buckets and troves |
| 6024 | RedemptionFeeTooHigh | Redemption fee exceeds the caller's maximum | Base rate rose after a burst of redemptions | Raise max_fee_bps or wait for it to decay |
| 6025 | InsufficientPar | PAR balance does not cover the requested redemption | Asking for more than you hold | Redeem less |
| 6026 | NothingRedeemed | Nothing was redeemed | Every listed trove was skipped | Rebuild the list |
| 6027 | InvalidParAccount | Token account does not hold PAR for this owner | Wrong token account | Pass the owner's PAR account |
| 6028 | DepositNotEmpty | Deposit still holds PAR | close_deposit on a live deposit | Withdraw everything first |
Decoding an error
import { AnchorError } from "@coral-xyz/anchor"
try {
await program.methods.borrow(new BN(1_000_000)).accounts(accounts).rpc()
} catch (e) {
if (e instanceof AnchorError) {
console.log(e.error.errorCode.code, e.error.errorMessage) // "OracleDisagreement", "Pyth and Switchboard disagree ..."
}
}