Error Codes#

Complete reference for all 44 Coalesce Finance program error codes, organized by category.

Error Code Categories Overview#

RangeCategoryDescription
0-4InitializationProtocol and market setup errors
5-9AuthorizationPermission and access control errors
10-16Account ValidationPDA and account ownership errors
17-20Input ValidationParameter and timestamp errors
21-27Balance/CapacityInsufficient funds and limits errors
28-35Market StateLifecycle and settlement errors
36-40Fee/WithdrawalFee collection and excess withdrawal errors
41-43OperationalRuntime, slippage, and haircut errors

Complete Error Reference#

Initialization Errors (0-4)#

CodeNameDescription
0AlreadyInitializedProtocolConfig already exists
1InvalidFeeRateFee rate exceeds 10,000 bps (100%)
2InvalidCapacitymax_total_supply is 0
3InvalidMaturityMaturity not in future (< now + 60s)
4MarketAlreadyExistsMarket PDA already initialized

Authorization Errors (5-9)#

CodeNameDescription
5UnauthorizedSigner lacks required authority
6NotWhitelistedBorrower not in whitelist
7BlacklistedAddress is on global blacklist
8ProtocolPausedProtocol is paused
9BorrowerHasActiveDebtCannot modify borrower with outstanding debt

Account Validation Errors (10-16)#

CodeNameDescription
10InvalidAddressRequired address is zero pubkey
11InvalidMintMint validation failed (wrong mint or decimals)
12InvalidVaultVault doesn't match market
13InvalidPDAAccount doesn't match derived PDA
14InvalidAccountOwnerAccount not owned by program
15InvalidTokenProgramWrong token program passed
16InvalidTokenAccountOwnerToken account owner mismatch

Input Validation Errors (17-20)#

CodeNameDescription
17ZeroAmountAmount parameter is 0
18ZeroScaledAmountScaled amount rounds to zero
19InvalidScaleFactorScale factor is 0 (invalid market state)
20InvalidTimestampTimestamp ordering violated

Balance/Capacity Errors (21-27)#

CodeNameDescription
21InsufficientBalanceToken account balance too low
22InsufficientScaledBalanceScaled amount exceeds balance
23NoBalanceLender has no scaled balance
24ZeroPayoutVault empty (no payout available)
25CapExceededDeposit exceeds max_total_supply
26BorrowAmountTooHighExceeds available vault funds
27GlobalCapacityExceededExceeds borrower's max_borrow_capacity

Market State Errors (28-35)#

CodeNameDescription
28MarketMaturedOperation not allowed after maturity
29NotMaturedWithdrawal before maturity
30NotSettledMarket not yet settled
31SettlementNotImprovedNew settlement factor not > current
32SettlementGracePeriodGrace period not elapsed before first settlement-triggering withdrawal or force-close (5 min)
33SettlementNotCompletesettlement_factor == 0
34PositionNotEmptyLender position cannot be closed
35RepaymentExceedsDebtRepayment exceeds current debt

Fee/Withdrawal Errors (36-40)#

CodeNameDescription
36NoFeesToCollectNo accrued protocol fees
37FeeCollectionDuringDistressFee collection blocked during distress
38LendersPendingWithdrawalsFee collection blocked (lenders pending)
39FeesNotCollectedProtocol fees not collected yet
40NoExcessToWithdrawNo excess funds in vault

Operational Errors (41-43)#

CodeNameDescription
41MathOverflowArithmetic overflow/underflow
42PayoutBelowMinimumPayout below slippage minimum
43NoHaircutToClaimLender has no haircut claim to recover

Common Scenarios#

Deposit Errors#

CodeNameWhen It Occurs
17ZeroAmountDeposit amount is 0
18ZeroScaledAmountDeposit too small (rounds to 0 shares)
25CapExceededDeposit would exceed max_total_supply
28MarketMaturedTrying to deposit after maturity

Withdrawal Errors#

CodeNameWhen It Occurs
23NoBalancePosition has zero shares
22InsufficientScaledBalanceWithdrawing more than owned
24ZeroPayoutVault is empty
29NotMaturedTrying to withdraw before maturity
32SettlementGracePeriodStill in 5-minute grace period before first settlement-triggering withdrawal or force-close
42PayoutBelowMinimumPayout less than specified minimum

Borrow Errors#

CodeNameWhen It Occurs
26BorrowAmountTooHighTrying to borrow more than vault holds
27GlobalCapacityExceededWould exceed borrower's whitelist capacity

Repay / RepayInterest Errors#

CodeNameWhen It Occurs
17ZeroAmountRepay/repay-interest amount is 0
11InvalidMintPayer token account mint does not match market mint
35RepaymentExceedsDebtRepay amount exceeds current principal debt (Repay only)
8ProtocolPausedProtocol is paused

Fee Collection Errors#

CodeNameWhen It Occurs
8ProtocolPausedProtocol is paused
36NoFeesToCollectNo fees have accrued
37FeeCollectionDuringDistressSettlement factor < WAD (market underfunded)
38LendersPendingWithdrawalsLenders still have pending withdrawals

User-Friendly Messages#

ErrorMessage
MarketMatured"This market has ended. You cannot deposit."
CapExceeded"This market is full. Try a smaller amount."
NotMatured"You can't withdraw yet. Wait until the maturity date."
SettlementGracePeriod"Please wait 5 minutes after maturity before the first settlement-triggering withdrawal or force-close."
ProtocolPaused"The protocol is temporarily paused."
PayoutBelowMinimum"Payout is below your specified minimum. Adjust slippage tolerance."

Handling Errors in Code#

import { parseCoalescefiError, CoalescefiErrorCode } from '@coalescefi/sdk';

try {
  await sendTransaction(tx);
} catch (error) {
  const programError = parseCoalescefiError(error);
  if (programError) {
    console.error(`Error: ${programError.codeName} (${programError.code})`);
    console.error(`Message: ${programError.message}`);
  }
}