Architecture Philosophy
Borrow Recovery is built as a frontend-only application with no backend infrastructure:- No backend signer - All signatures happen in your connected wallet
- No database - All data is read directly from blockchain
- No paymaster - Users pay their own gas fees
- No hosted service dependencies - Works completely decentralized
High-Level Architecture
The system consists of three core components:Key Components
1. Wallet Derivation
The app derives deterministic ZeroDev Kernel v3.3 smart account addresses from:- Your connected EOA address
- A wallet index (0, 1, 2, …)
- Deterministic CREATE2 deployment
The derivation logic is in
lib/kernel/deriveKernelAddress.ts and uses ZeroDev SDK constants.2. Position Reading
The app reads blockchain state directly using:- Public RPC endpoints (no API keys required)
- Smart contract view functions
- Multi-chain support (Ethereum, Base, Arbitrum, BNB)
- Aave V3: Reads collateral, debt, and health factor from Pool contracts
- Morpho Blue: Reads position shares and collateral from market contracts
3. UserOperation Submission
Rescue actions (repay, withdraw, transfer) are executed via ERC-4337:- Construct UserOperation with calldata for target protocol
- Estimate gas using bundler RPC
- Sign UserOp hash with connected wallet
- Submit to bundler for execution
lib/accountAbstraction/submitUserOpV07.ts.
Project Structure
Multi-Chain Support
The app supports loan recovery across:- Ethereum (Chain ID: 1)
- Base (Chain ID: 8453)
- Arbitrum (Chain ID: 42161)
- BNB Chain (Chain ID: 56)
- RPC endpoints
- Aave V3 contract addresses
- Morpho Blue contract addresses
- Block explorer URLs
lib/chains.ts for full configuration details.
Security Model
The app never asks for or stores private keys. All signing happens in your connected wallet.
- Non-custodial: Users maintain full control of keys
- Transparent: All transactions are shown before signing
- Deterministic: Address derivation is reproducible
- Open source: All code is auditable
Next Steps
Kernel Accounts
Learn about ZeroDev Kernel v3.3 smart accounts
Account Abstraction
Understand ERC-4337 UserOperations
Protocol Integration
Explore Aave and Morpho integrations