degenbot.exceptions¶
Exception classes for degenbot.
degenbot.exceptions is the single documented import home for every
FFI-raised exception. The FFI-raised types (the PoolRegistrationError
fairly, the verifier errors) are direct aliases
of the degenbot._ffi pyclasses — never Python subclasses: Rust raises
the pyclass instances, so except / isinstance matching requires the
exact same class object. The identity contract is pinned by
tests/ffi/test_companion_alias_identity.py.
Submodules¶
Package Contents¶
- class degenbot.exceptions.ArbCalculationError¶
Bases:
ArbitrageErrorRaised when an arbitrage calculation fails.
- class degenbot.exceptions.ArbitrageError¶
Bases:
degenbot.exceptions.base.DegenbotErrorException raised inside arbitrage helpers.
- class degenbot.exceptions.DirectionResolutionError¶
Bases:
ArbitrageErrorA discovered path’s hop directions could not be resolved to a closed token cycle.
The pathfinder contract guarantees every yielded path starts and ends at one of the requested boundary tokens ({WETH, native}), so a failure here is an invariant violation between the DB subgraph edges and the constructed pool objects (e.g. a pool built with different token0/token1 than the subgraph edge used) — a bug, not a skippable condition.
- class degenbot.exceptions.DuplicatePoolError(*, pool: str)¶
Bases:
PathRejectedErrorThe same pool appears more than once in the path.
A degenerate, non-executable cycle. V2/V3 pools are keyed by address; V4 pools by
pool_idhex.poolis the duplicated pool’s identity key.- pool¶
- class degenbot.exceptions.HopCountExceededError(*, hop_count: int, max_hops: int)¶
Bases:
PathRejectedErrorThe path exceeds the configured maximum hop count.
- hop_count¶
- max_hops¶
- class degenbot.exceptions.HopCountInsufficientError(*, hop_count: int, min_hops: int)¶
Bases:
PathRejectedErrorThe path is below the configured minimum hop count.
- hop_count¶
- min_hops¶
- class degenbot.exceptions.IncompatiblePoolInvariant¶
Bases:
ArbitrageErrorRaised when a pool’s invariant type is not supported for.
arbitrage path construction (e.g. Aerodrome stable pools).
- class degenbot.exceptions.InsufficientLiquidityError(*, liquidity: int, min_liquidity: int)¶
Bases:
PathRejectedErrorA pool’s liquidity proxy is below the configured minimum.
liquidityis the value returned by the caller-suppliedliquidity_ofextractor (the library does not encode pool-type-specific liquidity math).- liquidity¶
- min_liquidity¶
- class degenbot.exceptions.InvalidForwardAmount¶
Bases:
ArbitrageErrorInvalidForwardAmount class.
- class degenbot.exceptions.InvalidSwapPathError¶
Bases:
ArbitrageErrorRaised in arbitrage helper constructors when the provided path is invalid.
- class degenbot.exceptions.NoLiquidity¶
Bases:
ArbitrageErrorRaised if a pool has no liquidity for the requested operation.
- class degenbot.exceptions.NoSolverSolution(message: str = 'Solver failed to converge on a solution.')¶
Bases:
ArbitrageErrorNoSolverSolution class.
- message = 'Solver failed to converge on a solution.'¶
- class degenbot.exceptions.OptimizationError(message: str, *, iterations: int = 0, method: str | None = None)¶
Bases:
ArbitrageErrorRaised when a solver fails to find a profitable solution,.
fails to converge, or receives invalid inputs.
- message¶
- iterations = 0¶
- method = None¶
- class degenbot.exceptions.PathRejectedError¶
Bases:
ArbitrageErrorA path candidate was rejected by a path-composition policy predicate.
Policy rejection is distinct from the Rust core’s pool admission floor (
HookedPoolRejectedError/DynamicFeePoolRejectedError, which subclassValueError). Policy rejects by deployment rule (token denylist/allowlist, hop-count, min-liquidity, duplicate-pool); admission rejects by correctness floor. Callers classify by type so the two hierarchies (ArbitrageErrorvsValueError) stay separable.
- class degenbot.exceptions.RateOfExchangeBelowMinimum(rate: fractions.Fraction)¶
Bases:
ArbitrageErrorThe rate of exchange for the path is below the minimum.
- rate¶
- class degenbot.exceptions.TokenDenylistedError(*, token: str)¶
Bases:
PathRejectedErrorAn intermediate or profit token is not permitted by the policy.
Covers both denylist membership and allowlist absence.
tokenis the checksummed offending token address.- token¶
- class degenbot.exceptions.Unprofitable¶
Bases:
ArbitrageErrorUnprofitable class.
- exception degenbot.exceptions.DegenbotError(*, message: str | None = None)¶
Bases:
ExceptionBase exception used as the parent class for all exceptions raised by this package.
Calling code should catch DegenbotError and derived classes separately before general exceptions, e.g.:
``` try:
degenbot.some_function()
- except SpecificDegenbotError:
… # handle a specific exception
- except DegenbotError:
… # handle non-specific degenbot exception
- except Exception:
… # handle exceptions raised by 3rd party dependencies or Python built-ins
An optional string-formatted message may be attached to the exception and retrieved by accessing the .message attribute.
- exception degenbot.exceptions.DegenbotTypeError(*, message: str | None = None)¶
Bases:
DegenbotErrorDegenbotTypeError error.
- exception degenbot.exceptions.DegenbotValueError(*, message: str | None = None)¶
Bases:
DegenbotErrorDegenbotValueError error.
- exception degenbot.exceptions.AnvilError(method: str, error: str)¶
Bases:
degenbot.exceptions.base.DegenbotErrorRaised on errors resulting from failed calls to Anvil via JSON-RPC.
This exception is specifically for errors that occur when making RPC calls to an Anvil instance, such as invalid method calls, parameter errors, or other Anvil-specific failures.
- method¶
- error¶
- exception degenbot.exceptions.BackupExists(path: pathlib.Path)¶
Bases:
degenbot.exceptions.base.DegenbotErrorRaised by degenbot database backup if a file exists at the target path.
- path¶
- exception degenbot.exceptions.Erc20TokenError(*, message: str | None = None)¶
Bases:
degenbot.exceptions.base.DegenbotErrorException raised inside ERC-20 token helpers.
- exception degenbot.exceptions.NoPriceOracle¶
Bases:
Erc20TokenErrorRaised when .price is called on a token without a price oracle.
- class degenbot.exceptions.AddressMismatch¶
Bases:
LiquidityPoolErrorThe expected pool address does not match the provided address.
- class degenbot.exceptions.BrokenPool¶
Bases:
LiquidityPoolErrorBrokenPool class.
- class degenbot.exceptions.CurveError¶
Bases:
degenbot.exceptions.base.DegenbotErrorBase exception for Curve pool errors.
- class degenbot.exceptions.EVMRevertError(error: str | None = None)¶
Bases:
degenbot.exceptions.base.DegenbotErrorRaised when a simulated EVM contract operation would revert.
- error = None¶
- class degenbot.exceptions.ExternalUpdateError¶
Bases:
LiquidityPoolErrorRaised when an external update does not pass sanity checks.
- class degenbot.exceptions.HookedPoolResult(amount_in: int, amount_out: int, hooks: set[degenbot.uniswap.v4_liquidity_pool.Hooks])¶
Bases:
PossibleInaccurateResultRaised when a V4 pool has active hooks that may mutate the swap result.
The pool’s
beforeSwap/afterSwaphooks can modify amounts or revert, so the pure-math result may differ from what the contract returns. The set of conflicting hooks is available on thehooksattribute.- hooks¶
- class degenbot.exceptions.IncompleteSwap(amount_in: int, amount_out: int)¶
Bases:
LiquidityPoolErrorRaised if a swap calculation would not consume the input or deliver the requested output.
- amount_in¶
- amount_out¶
- class degenbot.exceptions.InvalidSwapInputAmount¶
Bases:
LiquidityPoolErrorInvalidSwapInputAmount class.
- class degenbot.exceptions.InvalidUint256¶
Bases:
EVMRevertErrorInvalidUint256 class.
- class degenbot.exceptions.LateUpdateError¶
Bases:
LiquidityPoolErrorRaised when an automatic update is attempted at a block prior to the last recorded update.
- class degenbot.exceptions.LiquidityMapWordMissing(word: int)¶
Bases:
LiquidityPoolErrorA word bitmap is not included in the liquidity map.
- word¶
- class degenbot.exceptions.LiquidityPoolError¶
Bases:
degenbot.exceptions.base.DegenbotErrorException raised inside liquidity pool helpers.
- class degenbot.exceptions.MissingCurveData(pool_address: str, data_type: str, message: str)¶
Bases:
CurveErrorRaised when on-chain data is needed but no fetcher is available.
- pool_address¶
- data_type¶
- class degenbot.exceptions.NoPoolStateAvailable(block: degenbot.types.aliases.BlockNumber)¶
Bases:
LiquidityPoolErrorRaised when a previous pool state is not available.
This can occur, e.g. if a pool was created in a block at or after a re-organization.
- class degenbot.exceptions.PoolCreationFailed¶
Bases:
TrackerErrorPoolCreationFailed class.
- class degenbot.exceptions.PoolNotAssociated(pool_address: str)¶
Bases:
TrackerErrorRaised by a pool tracker if a requested pool address is not associated with the DEX.
- class degenbot.exceptions.PossibleInaccurateResult(amount_in: int, amount_out: int, *, message: str)¶
Bases:
LiquidityPoolErrorRaised when a swap calculation may not match the on-chain result.
The computed
amount_inandamount_outare available on the exception so callers can inspect or use the approximate values after explicitly catching this exception.Subclasses add domain-specific context (hooks, stale rates, etc.).
- amount_in¶
- amount_out¶
- class degenbot.exceptions.StaleRateResult(amount_in: int, amount_out: int)¶
Bases:
PossibleInaccurateResultRaised when a Balancer ComposableStablePool’s rate cache is stale.
ComposableStablePools with time-varying rates (e.g. bb-a-* yield tokens) cache rates in
_tokenRateCachesand refresh them before each swap via_beforeSwapJoinExit(). Without a liveBalancerRateProvider, the pool uses construction-time rates that become stale as blocks pass. The computed amounts are available but may not match on-chain execution.
- class degenbot.exceptions.TrackerAlreadyInitialized¶
Bases:
TrackerErrorRaised by a pool tracker if a caller attempts to create from a known factory address.
- class degenbot.exceptions.TrackerError¶
Bases:
degenbot.exceptions.base.DegenbotErrorException raised inside pool tracker helpers.
- class degenbot.exceptions.UnknownPool(pool: degenbot.types.chain.ChecksummedAddress)¶
Bases:
LiquidityPoolErrorRaised when an update is provided for a pool not in the snapshot.
Such updates can lead to inconsistent state because the pool state prior to the update is unknown.
- class degenbot.exceptions.UnknownPoolId(pool_id: bytes | str)¶
Bases:
LiquidityPoolErrorRaised when an update is provided for a pool ID not in the snapshot.
Such updates can lead to inconsistent state because the pool state prior to the update is unknown.
- class degenbot.exceptions.ContractLogicError(message: str = '')¶
Bases:
RpcErrorAn
eth_callexecution revert reported by the provider.The degenbot-owned equivalent of
web3.exceptions.ContractLogicError. Raised at the provider adapter seam (seedegenbot.provider.alloy_errors.alloy_revert_error()) so probe sites catch one type regardless of backend.Constructed with a positional revert message (mirroring the web3 type’s constructor) so call sites can write
ContractLogicError("... reverted") `` and ``str(exc)returns that message.- message = None¶
- class degenbot.exceptions.RpcError¶
Bases:
degenbot.exceptions.base.DegenbotErrorBase for provider/RPC-layer failures.
The degenbot-owned equivalent of
web3.exceptions.Web3Exception: the broad base a caller can catch to mean “an RPC call failed for some reason.” Probe sites catch this instead of backend-specific native types, so they remain backend-agnostic.