Architecture
Stormbit’s core is a modular lending engine. The LendingManager orchestrates the loan lifecycle, hooks inject custom logic at each step, and modules handle collateral custody. All option execution flows through the Insurance Layer (the on-chain leg of the options engine).
graph TD LM[LendingManager] --> IL[Insurance Layer] LM --> TL[Term Library] LM --> LL[Loan Library] LM --> H[Hooks] LM --> M[Modules] LM --> L[Liquidator]LendingManager, Central orchestrator. Entry points: termInitialize, termModifyPosition, loanInitialize, allocate, repay. Upgradeable via UUPS. Pausable.
Insurance Layer, The contract component behind the collar. Prices the option legs from LTV, term, and volatility; books the premium; routes hedge execution to external options venues; settles payoffs at maturity.
Hooks, Custom logic at lifecycle events. Implement IHooks to inject behavior at term creation, deposit, allocation, and repayment. Built-in: AaveV3 (idle yield), P2P (manual approval), Timelock (delayed execution).
Modules, Collateral validators. Implement ILoanModule to handle custom collateral types. Built-in: ERC20LTV (BTC/ETH with LTV validation), ERC721 (NFT collateral), Attestation (credential-based lending).
Liquidator, Dutch auction for defaulted loans. Price declines over time. First buyer wins.
Router, Batch operations in one transaction. Command pattern execution.
Oracle, Chainlink and Pyth price feeds. 18 decimal normalization. Staleness checks.
Build custom hooks or modules to extend the protocol:
- Building Hooks,
IHooksinterface and examples - Building Modules,
ILoanModuleinterface and examples - Contract Addresses, Deployed contracts per network