Inspiration

Managing Bitcoin collateral on DeFi lending protocols is powerful but intimidating. Users must manually calculate loan-to-value ratios, monitor liquidation risks in real-time, and execute complex multi-step transactions—all while navigating desktop-only interfaces with constant wallet popups. We saw friends get liquidated during BTC volatility because they didn't rebalance fast enough. We built Aurion to be the AI autopilot that makes Bitcoin lending safe, simple, and accessible—turning "I want safe yield on my BTC" into executable, guardrail-protected plans in seconds.

What it does

Aurion is an AI-powered safety layer for Bitcoin lending on Starknet's Vesu protocol. It offers three core experiences:

  1. Yield Wizard: Choose Conservative/Balanced/Aggressive risk profiles. Aurion instantly computes safe borrow/repay actions to hit your target LTV, shows exact calldata with fee estimates, and executes multicalls in one tap.

  2. AI Agent: Chat in natural language ("rebalance to 55% and borrow $100") and get context-aware plans grounded in your live collateral and debt. Powered by Vercel AI SDK with custom DeFi tools.

  3. Guardian Mode (concept): On-chain LTV caps via Cairo hooks that prevent risky actions before liquidation. Users set a maximum threshold; the contract auto-rejects borrows that would breach it.

Key features: Real-time position health with Pragma oracles, transparent fee previews, mobile-ready responsive UI, wallet persistence across pages (Argent X/Braavos), and config-free setup via .env.local.

How we built it

Technology Stack:

  • Frontend Framework: Next.js 15 with App Router for modern React server/client components and optimized routing
  • Blockchain SDK: starknet.js v8 for contract interactions and @starknet-react/core for wallet connectivity
  • AI Integration: Vercel AI SDK for streaming chat responses and custom tool execution
  • Styling: Tailwind CSS with custom glassmorphism design system for modern, mobile-first UI
  • Oracles: Pragma API for real-time BTC/USDC price feeds with RedStone as fallback
  • Wallet Support: Argent X and Braavos connectors with auto-detection

Architecture & Implementation:

We built Aurion as a full-stack Next.js application with three main layers:

1. User Interface Layer:

  • Created four core pages: Dashboard (position overview), Wizard (strategy-based planning), Agent (AI chat), and Settings (configuration)
  • Designed reusable components for wallet connection, health visualization, action buttons, and transaction preview modals
  • Implemented responsive layouts that work seamlessly on desktop and mobile
  • Added real-time position polling that updates every 30 seconds with fresh oracle data

2. Blockchain Integration Layer:

  • Built multicall builders for all Vesu pool operations: approve, deposit, borrow, repay, and withdraw
  • Implemented position reading logic that fetches collateral and debt from Vesu's pool contract
  • Created decimal-aware conversion utilities to handle BTC (8 decimals) and USDC (6 decimals) precisely
  • Added fee estimation pipeline that simulates transactions before execution
  • Integrated Pragma oracle API with caching and staleness validation

3. AI Planning Layer:

  • Developed custom AI tools using Vercel AI SDK that understand DeFi concepts like LTV, collateral, and debt
  • Created strategy presets (Conservative 45%/60%, Balanced 55%/65%, Aggressive 60%/70%) that map to safe target/cap LTV pairs
  • Built a planning algorithm that computes optimal borrow/repay amounts to reach target LTV while respecting caps
  • Implemented natural language parsing that converts user goals like "rebalance to 55%" into executable action plans
  • Grounded AI responses in live blockchain state by passing current position data as context

Configuration & Deployment:

  • Set up environment-based configuration system with mainnet addresses for Re7 xBTC pool, WBTC, and USDC
  • Implemented localStorage overrides for power users who want to test custom pools
  • Added configuration validation with helpful banners when addresses are missing
  • Ensured wallet state persists across page navigation using React context and Next.js Link components

Key Technical Decisions:

  • Used client-side rendering for wallet-dependent components to avoid SSR hydration issues
  • Implemented mount-gating for wallet connectors since browser extensions only exist client-side
  • Added approval calls before repay/deposit operations to ensure smooth multicall execution
  • Built LTV trajectory preview showing before/after state to help users understand risk impact
  • Created price caching layer to handle oracle API timeouts gracefully

Development Process: We started with the core position reading and display, then added the Wizard flow with strategy presets, followed by AI agent integration, and finally polished the UX with fee transparency, error handling, and mobile responsiveness. Throughout, we prioritized user safety by always showing exact calldata, fees, and LTV impact before any transaction execution.

How we built it

Technology Stack:

  • Frontend Framework: Next.js 15 with App Router for modern React server/client components and optimized routing
  • Blockchain SDK: starknet.js v8 for contract interactions and @starknet-react/core for wallet connectivity
  • AI Integration: Vercel AI SDK for streaming chat responses and custom tool execution
  • Styling: Tailwind CSS with custom glassmorphism design system for modern, mobile-first UI
  • Oracles: Pragma API for real-time BTC/USDC price feeds with RedStone as fallback
  • Wallet Support: Argent X and Braavos connectors with auto-detection

Architecture & Implementation:

We built Aurion as a full-stack Next.js application with three main layers:

1. User Interface Layer:

  • Created four core pages: Dashboard (position overview), Wizard (strategy-based planning), Agent (AI chat), and Settings (configuration)
  • Designed reusable components for wallet connection, health visualization, action buttons, and transaction preview modals
  • Implemented responsive layouts that work seamlessly on desktop and mobile
  • Added real-time position polling that updates every 30 seconds with fresh oracle data

2. Blockchain Integration Layer:

  • Built multicall builders for all Vesu pool operations: approve, deposit, borrow, repay, and withdraw
  • Implemented position reading logic that fetches collateral and debt from Vesu's pool contract
  • Created decimal-aware conversion utilities to handle BTC (8 decimals) and USDC (6 decimals) precisely
  • Added fee estimation pipeline that simulates transactions before execution
  • Integrated Pragma oracle API with caching and staleness validation

3. AI Planning Layer:

  • Developed custom AI tools using Vercel AI SDK that understand DeFi concepts like LTV, collateral, and debt
  • Created strategy presets (Conservative 45%/60%, Balanced 55%/65%, Aggressive 60%/70%) that map to safe target/cap LTV pairs
  • Built a planning algorithm that computes optimal borrow/repay amounts to reach target LTV while respecting caps
  • Implemented natural language parsing that converts user goals like "rebalance to 55%" into executable action plans
  • Grounded AI responses in live blockchain state by passing current position data as context

Configuration & Deployment:

  • Set up environment-based configuration system with mainnet addresses for Re7 xBTC pool, WBTC, and USDC
  • Implemented localStorage overrides for power users who want to test custom pools
  • Added configuration validation with helpful banners when addresses are missing
  • Ensured wallet state persists across page navigation using React context and Next.js Link components

Key Technical Decisions:

  • Used client-side rendering for wallet-dependent components to avoid SSR hydration issues
  • Implemented mount-gating for wallet connectors since browser extensions only exist client-side
  • Added approval calls before repay/deposit operations to ensure smooth multicall execution
  • Built LTV trajectory preview showing before/after state to help users understand risk impact
  • Created price caching layer to handle oracle API timeouts gracefully

Development Process: We started with the core position reading and display, then added the Wizard flow with strategy presets, followed by AI agent integration, and finally polished the UX with fee transparency, error handling, and mobile responsiveness. Throughout, we prioritized user safety by always showing exact calldata, fees, and LTV impact before any transaction execution.

Challenges we ran into

  1. Hydration errors: Wallet connectors detected differently on server vs client (extensions only exist in browser). Fixed by adding a mounted state gate in [WalletConnect] to prevent SSR mismatch.

  2. Wallet disconnects on navigation: Using <a href> caused full page reloads, losing React context. Switched to Next.js <Link> for client-side navigation; wallet now persists across all pages.

  3. Transaction simulation failures: Borrowing without collateral or with wrong ABI/POOL_ID caused estimateInvokeFee to fail. Added preview guards, proper approval sequencing, and better error messages. Still finalizing exact Vesu pool ABI alignment for mainnet execution.

  4. Decimal precision: Converting USD amounts to token units (BTC has 8 decimals, USDC has 6) required careful bigint math with rounding direction (up for repay/deposit, down for borrow/withdraw) to avoid dust or overflow.

  5. Oracle reliability: Pragma API occasionally times out. Implemented localStorage caching with staleness checks and graceful fallback to last-known prices.

Accomplishments that we're proud of

  • End-to-end working flow: Connect wallet → choose strategy → preview calldata with fees → execute multicalls on Starknet mainnet.
  • AI grounded in live data: Agent chat uses real collateral/debt from user's position to compute safe plans, not generic responses.
  • Transparent UX: Every action shows before/after LTV, exact fee in STRK, and call breakdown. No hidden surprises.
  • Mobile-ready design: Fully responsive with modern glassmorphism UI, works on phone browsers (session keys integration ready for next phase).
  • Resilient architecture: Oracle caching, hydration fixes, wallet state persistence, error boundaries—built to handle real-world edge cases.

What we learned

  • SSR/client boundaries matter: Wallet extensions, localStorage, and browser APIs need careful mount-gating to avoid hydration mismatches in Next.js App Router.
  • Blockchain UX is hard: Users need to see fees, understand LTV impact, and trust the app won't liquidate them. Transparency and guardrails are non-negotiable.
  • AI + DeFi = powerful combo: Vercel AI SDK's tool system lets us ground LLM responses in real blockchain state, turning vague goals into executable plans.
  • Oracle integration is critical: Price freshness, caching, and fallback strategies are essential for production DeFi apps. Can't rely on single-source oracles.
  • Decimal math is unforgiving: Off-by-one errors in uint256 conversions or rounding can cause reverts or dust. Always test with real token decimals.
  • Wallet diversity: Argent X and Braavos behave differently (connector IDs, account switching). Need explicit UX for each.

What's next for Aurion

Short-term (post-hackathon):

  • Guardian Mode Cairo hook: Deploy on-chain LTV enforcement that auto-rejects risky borrows and triggers repayments when approaching liquidation threshold.
  • Session keys integration: Use Cartridge Controller for popup-free mobile multicalls. Approve once, execute 10 actions smoothly.
  • ABI hardening: Finalize Vesu pool ABI/POOL_ID alignment and test full deposit→borrow→repay→withdraw cycles on mainnet with real funds.
  • Enhanced AI tools: Add "what-if" scenarios ("what if BTC drops 10%?"), proactive alerts, and yield optimization suggestions.

Medium-term (3-6 months):

  • Multi-pool support: Extend beyond Re7 xBTC to other Vesu pools (ETH, STRK collateral).
  • Mobile PWA: Installable app with offline support, push notifications for LTV alerts.
  • Advanced strategies: Auto-rebalancing, DCA into positions, yield compounding.
  • Analytics dashboard: Historical LTV charts, APY tracking, liquidation buffer visualization.

Long-term (6-12 months):

  • Cross-chain expansion: Bring Aurion to Arbitrum, Base, and other L2s with similar lending protocols.
  • Institutional features: API access, programmatic position management, multi-sig support.
  • Fiat on-ramps: Direct BTC deposits via partners like Ramp/Transak.
  • Community governance: DAO for strategy presets, fee parameters, and Guardian Mode thresholds.

Vision: Aurion becomes the default interface for safe Bitcoin lending across all chains—where AI, guardrails, and mobile UX make DeFi accessible to everyone, not just power users.

Built With

Share this project:

Updates