degenbot.aave.analysis.orchestrator¶
I/O orchestration for Aave V3 position analysis.
A thin Python driver shell over the Rust degenbot-aave::analysis core
(ADR-005 three-layer architecture). The pure math (health-factor / LTV /
eMode / isolation / scaled-balance calc) lives in Rust; this module owns only
the I/O orchestration: resolve the DB path, fetch users / positions / prices
via Rust-backed readers, drive the per-user Rust analysis seam, and bucket the
results.
The former core.py (pure math + dataclasses) + protocols.py (typing
seams) were retired once the Rust core reached byte-identical parity (verified
by the §4.2 parity gate before deletion). The PositionAnalysisResult
bucket-sorter stays here (it’s trivial Python, not math).
Module Contents¶
- class degenbot.aave.analysis.orchestrator.DatabasePositionQuery(database_path: pathlib.Path)¶
PositionQuery backed by the Rust
_EnginePositionQueryreader.Routes every read through the PyO3 seam (ADR-005) over one explicit, file-backed database path.
- get_users_with_debt(market_id: int, limit: int | None = None) list[dict[str, Any]]¶
Get all users with debt positions in a market, as flat dicts.
- Returns:
The Rust-backed row dicts (address checksummed to match the price-map keys the analysis seam consumes).
- get_collateral_positions(user_id: int) list[dict[str, Any]]¶
Get collateral positions for a user, as flat dicts.
- Returns:
The Rust-backed row dicts (address checksummed).
- get_debt_positions(user_id: int) list[dict[str, Any]]¶
Get debt positions for a user, as flat dicts.
- Returns:
The Rust-backed row dicts (address checksummed).
- get_collateral_config_map(user_id: int) dict[int, bool]¶
Get map of asset_id to enabled status for a user.
- Returns:
The computed value.
- class degenbot.aave.analysis.orchestrator.OraclePriceFetcher(provider: degenbot.provider.AlloyProvider, oracle_address: degenbot._ffi.ChecksummedAddress)¶
PriceFetcher using the Aave oracle contract.
Delegating shell over the Rust
AavePriceOraclereader (thedegenbot-pricecore crate, ADR-005).getAssetPrice(address)eth_call+uint256decode run in Rust, with the same tolerant per-asset skip-on-error behavior.
- class degenbot.aave.analysis.orchestrator.PositionAnalysisResult¶
Result of analyzing positions for liquidation risk.
Bucket-sorter only (no math) — the per-user
UserPositionSummaryobjects (Rust-built via the analysis seam) are categorized by health factor into safe / at-risk / liquidatable lists.
- degenbot.aave.analysis.orchestrator.analyze_positions_for_market(database_path: pathlib.Path, market_id: int, health_factor_threshold: float = 1.1, limit: int | None = None, provider: degenbot.provider.AlloyProvider | None = None) PositionAnalysisResult¶
Analyze all users-with-debt in a market for liquidation risk.
Thin driver shell: fetches users + prices via Rust-backed readers, drives the per-user
analyze_aave_user_positionRust seam, and buckets the results. The pure math (HF / LTV / scaled-balance) lives in Rust (degenbot-aave::analysis).- Parameters:
database_path – File-backed SQLite database opened by the Rust reader.
market_id – The Aave V3 market id.
health_factor_threshold – The at-risk threshold (default 1.1).
limit – Optional cap on the number of users analyzed.
provider – Optional RPC provider for price fetching (when
None, prices are treated as 1 — faster, but HFs are relative).
- Returns:
The bucketed analysis result.