Appearance
Architecture
System Overview
┌─────────────────────────────────────────────────────────┐
│ STARKNET │
│ ┌─────────────────────────────────────────────────┐ │
│ │ Rhadow Vault (Cairo) │ │
│ │ • ERC-4626 tokenized vault │ │
│ │ • Holds USDC + wBTC │ │
│ │ • Access control (Admin, Keeper, Strategist) │ │
│ │ • Upgradeable proxy │ │
│ └─────────────────────────────────────────────────┘ │
└─────────────────────────────────────────────────────────┘
│
│ Starknet RPC
▼
┌─────────────────────────────────────────────────────────┐
│ KEEPER (Python) │
│ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │
│ │ Vault Client │ │Extended Client│ │ AVNU Client │ │
│ │ (starknet-py)│ │ (REST API) │ │ (REST API) │ │
│ └──────────────┘ └──────────────┘ └──────────────┘ │
│ │ │
│ ┌─────────────────────────────────────────────────┐ │
│ │ Delta-Neutral Strategy Engine │ │
│ │ • State machine (IDLE/ACTIVE/REBALANCING) │ │
│ │ • Funding rate monitoring │ │
│ │ • Position management │ │
│ │ • Profit harvesting │ │
│ └─────────────────────────────────────────────────┘ │
└─────────────────────────────────────────────────────────┘
│
┌──────────────┴──────────────┐
▼ ▼
┌───────────────────────┐ ┌───────────────────────┐
│ Extended DEX │ │ AVNU │
│ • BTC perpetuals │ │ • DEX aggregator │
│ • Funding payments │ │ • wBTC ↔ USDC swaps │
│ • SNIP-12 signing │ │ • Multi-route │
└───────────────────────┘ └───────────────────────┘Components
Vault Contract (Cairo)
~1,300 lines of Cairo implementing:
| Component | Purpose |
|---|---|
| ERC-4626 | Tokenized vault standard |
| ERC-20 | Share token (rUSDC) |
| AccessControl | Role-based permissions |
| Pausable | Emergency stop |
| ReentrancyGuard | Attack prevention |
| Upgradeable | Proxy pattern |
Storage:
cairo
asset_token: USDC (bridged)
native_usdc_token: USDC (native)
wbtc_token: wBTC
trading_account: Keeper's account
allocated_margin: USDC on Extended
btc_price_usd: Price oracle
avnu_exchange: Swap routerKeeper Service (Python)
~4,600 lines of Python with:
| Module | Purpose |
|---|---|
main.py | Entry point, lifecycle |
strategy/delta_neutral.py | Core strategy logic |
vault/client.py | Starknet interactions |
extended/client.py | Perp DEX API |
extended/signer.py | SNIP-12 order signing |
dex/avnu.py | Swap aggregator |
api.py | Stats REST API |
API Server (FastAPI)
Exposes vault statistics:
| Endpoint | Description |
|---|---|
GET /health | Health check |
GET /stats | Vault TVL, APR, positions |
GET /user/{address} | User share balance and value |
Data Flow
Deposit:
User USDC → Vault → Mint rUSDC shares
↓
Keeper allocates:
• 50% → Buy wBTC (AVNU)
• 50% → Short margin (Extended)Yield:
Extended funding → Keeper margin account
↓
Keeper calls report(profit)
↓
Vault total_assets increases
↓
Share price increasesWithdraw:
User burns rUSDC → Vault checks liquidity
↓
If sufficient: Send USDC
If not: Keeper unwinds positionSecurity Model
Roles:
| Role | Permissions |
|---|---|
| Admin | Configuration, upgrades, roles |
| Keeper | Margin allocation, swaps, reporting |
| Strategist | Pause/unpause |
| User | Deposit, withdraw |
Safety:
- 1x leverage (no liquidation)
- 20% min liquidity buffer
- 24h stale threshold blocks withdrawals
- Reentrancy protection
- Pausable for emergencies
