Errors
The Owney SDK throws OwneyError instances for SDK-level failures. Convenience subclasses are provided for common cases, but all public SDK errors share the same code, optional details, and optional agentId fields.
OwneyError
class OwneyError extends Error {
readonly code: OwneyErrorCode;
readonly details?: Record<string, unknown>;
readonly agentId?: string;
}
When agentId is set, error.message is prefixed with both the error code and the agent, for example [AGENT_NOT_FOUND][agent:zyfai] ....
Convenience subclasses
| Class | Code | Notes |
|---|---|---|
AgentNotFoundError | AGENT_NOT_FOUND | Message: Unknown agent "<agentId>". Available agents: <agents> |
NotConnectedError | NOT_CONNECTED | Message: "Not connected. Call sdk.connect(provider) first." |
AgentChainIncompatibleError | AGENT_CHAIN_INCOMPATIBLE | Extra properties: incompatibleAgents, connectedChainId |
Error codes
type OwneyErrorCode =
| "NOT_CONNECTED"
| "NO_ACTIVE_CHAIN"
| "WALLET_NO_ACCOUNTS"
| "WALLET_ADDRESS_REQUIRED"
| "AGENT_NOT_FOUND"
| "AGENT_CHAIN_INCOMPATIBLE"
| "AGENT_EMPTY_LIST"
| "AGENT_DISABLED"
| "CHAIN_UNSUPPORTED"
| "CHAIN_NO_COMPATIBLE_AGENTS"
| "ASSET_UNSUPPORTED"
| "ASSET_NO_COMPATIBLE_AGENTS"
| "DEPOSIT_AMOUNT_BELOW_MINIMUM"
| "DEPOSIT_CALLBACK_REQUIRED"
| "DEPOSIT_CALLBACK_INVALID"
| "DEPOSIT_NO_PERMITTED_TOKENS"
| "WITHDRAW_NO_PERMITTED_TOKENS"
| "WITHDRAW_INSUFFICIENT_BALANCE"
| "WITHDRAW_ALL_FAILED"
| "WITHDRAW_PARTIAL_FAILURE"
| "WITHDRAW_SWAP_INCOMPLETE"
| "WITHDRAW_FAILED"
| "API_ROUTING_ERROR"
| "API_ROUTING_FAILED"
| "API_NO_AGENTS"
| "SPONSOR_REQUEST_FAILED"
| "PERMIT2_APPROVAL_REQUIRED"
| "SWAP_DISABLED"
| "SWAP_RATE_LIMITED"
| "SWAP_REQUEST_FAILED"
| "SWAP_QUOTE_FAILED"
| "SWAP_UNSUPPORTED_PAIR"
| "SWAP_APPROVAL_REQUIRED"
| "SWAP_BELOW_DEPOSIT_MINIMUM"
| "SWAP_DEPOSIT_PENDING"
| "SWAP_WALLET_PROMPT_TIMEOUT"
| "SWAP_INSUFFICIENT_GAS"
| "SWAP_NATIVE_UNSUPPORTED"
| "SWAP_ORDER_EXPIRED"
| "SWAP_ORDER_REFUNDED"
| "SWAP_ORDER_CANCELLED"
| "SWAP_ORDER_NOT_FOUND"
| "WITHDRAW_ARRIVAL_TIMEOUT"
| "WITHDRAW_SWAP_FAILED"
| "BALANCE_ALL_FAILED"
| "ALLOCATION_ALL_FAILED"
| "POOL_CATALOG_UNSUPPORTED"
| "POOL_SELECTION_UNSUPPORTED"
| "POOL_SELECTION_NOT_APPLIED"
| "POOL_SELECTION_RULE_LIMIT"
| "VALIDATION_INVALID_DAYS";
Swap errors
| Code | Meaning | Next step |
|---|---|---|
SWAP_DISABLED | Swapping is unavailable. | Keep the original asset and try again later. |
SWAP_RATE_LIMITED | Too many swap requests were made. | Retry after a delay. |
SWAP_REQUEST_FAILED | The swap request could not be completed. | Check details.outcome before retrying. |
SWAP_QUOTE_FAILED | A quote could not be created. | Change the amount or pair and request another quote. |
SWAP_UNSUPPORTED_PAIR | The selected assets or chains cannot be swapped. | Choose another pair. |
SWAP_APPROVAL_REQUIRED | The source token still needs approval. | Complete the approval and retry. |
SWAP_BELOW_DEPOSIT_MINIMUM | The minimum quoted output is below the agent minimum. | Increase the source amount. |
SWAP_DEPOSIT_PENDING | The swap completed, but the deposit did not. The target asset is in the wallet. | Call completePendingDeposit; do not swap again. |
SWAP_WALLET_PROMPT_TIMEOUT | The wallet did not answer the prompt and nothing was submitted. | Retry the operation. |
SWAP_INSUFFICIENT_GAS | The wallet cannot pay the required transaction gas. | Add the chain's native asset, then retry. |
SWAP_NATIVE_UNSUPPORTED | The selected native source asset cannot be prepared for this route. | Choose another source asset. |
SWAP_ORDER_EXPIRED | The submitted order expired. | Follow the reported order state while funds settle or return. |
SWAP_ORDER_REFUNDED | The submitted order was refunded. | Confirm the returned source balance. |
SWAP_ORDER_CANCELLED | The submitted order was cancelled. | Follow the reported order state while funds return. |
SWAP_ORDER_NOT_FOUND | The swap was not accepted. | Request a new quote and retry. |
WITHDRAW_SWAP_INCOMPLETE | The withdrawal could not safely continue into a swap. | Recheck or continue the saved withdrawal; do not withdraw again. |
WITHDRAW_ARRIVAL_TIMEOUT | The withdrawal did not arrive before the wait ended. | Check the original asset balance and withdrawal status. |
WITHDRAW_SWAP_FAILED | The withdrawal completed, but the swap did not. | The original asset remains in the wallet; do not repeat the withdrawal. |
See Swapping for the recovery flow.
Pool customization errors
| Code | Meaning |
|---|---|
POOL_CATALOG_UNSUPPORTED | The selected agent does not provide a pool catalogue. |
POOL_SELECTION_UNSUPPORTED | The selected agent cannot read or save pool selections. |
POOL_SELECTION_NOT_APPLIED | The saved selection could not be verified. Do not start the deposit. |
POOL_SELECTION_RULE_LIMIT | The selection cannot be stored because its rule limit has been reached. |
See Pool customization for the related methods.
Code reference
| Code | Meaning |
|---|---|
NOT_CONNECTED | Wallet-dependent method called before connect(). |
NO_ACTIVE_CHAIN | Method called before activateAgent(). |
WALLET_NO_ACCOUNTS | Provider returned no accounts during connect(). |
WALLET_ADDRESS_REQUIRED | Wallet address was missing during agent auth. |
AGENT_NOT_FOUND | Unknown agent ID was passed. |
AGENT_CHAIN_INCOMPATIBLE | One or more selected agents do not support the requested chain. |
AGENT_EMPTY_LIST | An empty agentId array was passed to activateAgent(). |
AGENT_DISABLED | A disabled agent was explicitly selected for activation or deposit. |
CHAIN_UNSUPPORTED | Chain ID is not in the supported list. |
CHAIN_NO_COMPATIBLE_AGENTS | No agents support the requested chain. |
ASSET_UNSUPPORTED | The selected agent does not support the asset on the active chain. |
ASSET_NO_COMPATIBLE_AGENTS | No agents support the asset on the active chain. |
DEPOSIT_AMOUNT_BELOW_MINIMUM | Deposit amount is below an agent minimum. |
DEPOSIT_CALLBACK_REQUIRED | A callback was required by an underlying deposit path but was not provided. |
DEPOSIT_CALLBACK_INVALID | depositCallback did not return a tx hash. |
DEPOSIT_NO_PERMITTED_TOKENS | No permitted deposit tokens were available. |
WITHDRAW_NO_PERMITTED_TOKENS | No permitted withdrawal tokens were available. |
WITHDRAW_INSUFFICIENT_BALANCE | Requested withdrawal exceeds total available balance. |
WITHDRAW_ALL_FAILED | All eligible agent withdrawals failed. |
WITHDRAW_PARTIAL_FAILURE | Some withdrawals succeeded, but the full requested amount could not be completed. |
WITHDRAW_FAILED | An underlying agent withdrawal attempt failed. |
API_ROUTING_ERROR | Routing API returned a non-OK HTTP status. |
API_ROUTING_FAILED | Routing API returned success: false. |
API_NO_AGENTS | The routing API returned no supported agents. |
SPONSOR_REQUEST_FAILED | Sponsored deposit request failed (network error or non-success sponsor API response). |
PERMIT2_APPROVAL_REQUIRED | A gasless WETH deposit needs a one-time Permit2 approval. Call approvePermit2 (the SDK also attempts this automatically). |
BALANCE_ALL_FAILED | All active-agent balance requests failed. |
ALLOCATION_ALL_FAILED | All active-agent allocation inputs failed. |
POOL_CATALOG_UNSUPPORTED | The selected agent does not provide a pool catalogue. |
POOL_SELECTION_UNSUPPORTED | The selected agent cannot read or save pool selections. |
POOL_SELECTION_NOT_APPLIED | The saved pool selection could not be verified. |
POOL_SELECTION_RULE_LIMIT | The pool selection cannot be stored because its rule limit has been reached. |
VALIDATION_INVALID_DAYS | An invalid APY lookback value was provided. |