hackquest logo

Aurion

Aurion is a non-custodial credit meta-layer for DeFi. It sits above existing money markets Aave and Compound, and introduces a unified credit identity, cross-protocol risk aggregation, and more.

ビデオ

プロジェクト画像 1

テックスタック

React
Web3
Solidity
Rust
Ethers

説明


markdown

# Aurion Protocol — Project Details

## What Aurion Is

Aurion is a non-custodial credit meta-layer for DeFi. It sits above existing money markets Aave and Compound,  and introduces a unified credit identity, cross-protocol risk aggregation, and delegated credit infrastructure. Rather than replacing existing protocols, Aurion coordinates them.

**The core insight:** liquidity provision and credit risk underwriting are two separate jobs. Aave and Compound conflate them. Aurion separates them, letting liquidity providers keep doing what they do best, while introducing a new class of Credit Providers who specialize in absorbing credit risk in exchange for fees.

---

## The Problem

**1. Fragmented Identity**
A user with $100k on Aave and $50k on Compound is treated as two separate users by both protocols. There is no portfolio-level credit recognition. Capital efficiency suffers because each protocol independently requires overcollateralization.

**2. No Credit Market**
Every liquidity provider on Aave or Compound implicitly absorbs credit risk they cannot price, hedge, or trade. Aurion creates an explicit credit market, a separate class of participants (Credit Providers) who earn fees specifically for absorbing that risk.

**3. Reactive Risk Management**
Existing protocols only react after a position becomes undercollateralized. Aurion introduces proactive risk controls: credit scores based on on-chain history, volatility-adjusted utilization tracking, and pre-emptive credit recall mechanisms.

---

## How It Works

### Borrow Flow

```
1. User supplies collateral on MockAavePool or MockCToken
   (Aurion never custodies — assets stay in the underlying protocol)

2. User requests borrow through CreditRouter
   → Router checks aggregate LTV across both protocols
   → Router validates credit score tier
   → Router checks delegated credit backing

3. Router executes on underlying protocol via adapter
   → AaveAdapter.borrow() or CompoundAdapter.borrow()

4. Router records per-protocol debt in CreditManager
   → recordAaveBorrow() or recordCompoundBorrow()

5. CreditManager calls Stylus engine to recompute score
   → Score updates reflect cross-protocol activity immediately
```

### Delegated Credit Flow

```
Credit Provider deposits USDC → CreditPool
CreditPool.delegateCredit(user, amount)
→ CreditManager.setDelegatedCredit(user, amount)
→ User's credit limit increases by delegated amount
→ Provider earns fees from credit utilization
```

### Liquidation Waterfall

```
Position becomes unhealthy (HF < 1.0)
→ Liquidator calls CreditRouter.liquidate()
→ Router repays debt using liquidator's funds
→ Router claims collateral + bonus from InsurancePool
→ CreditManager.onLiquidation() freezes the account
→ Liquidation penalty applied to credit score (-100 pts)
```

---

## Arbitrum Stylus — Credit Score Engine

The credit scoring system is the most computationally intensive part of Aurion. Rather than implementing it in Solidity (expensive for iterative math), it is written in **Rust and compiled to WASM** via Arbitrum Stylus.

### Why Stylus

Stylus contracts run in a WASM VM alongside the EVM on Arbitrum. For math-heavy workloads, weighted averages, multi-slope curve calculations, volatility measurements. WASM is 10–100x cheaper than the EVM. The Stylus contract is called from `CreditManager.sol` through a standard Solidity interface. From the perspective of the rest of the protocol, it is just another contract call.

### Score Components

The engine computes eight components from raw user metrics passed by `CreditManager`:

**Positive components (max 800 pts)**

| Component | Range | Logic |
|---|---|---|
| Account Age | 0–150 | Linear from 0 to 180 days, then capped |
| Health Factor | 0–250 | Tiered: HF≥2.0→250, ≥1.5→200, ≥1.2→150, ≥1.0→100 |
| Repayment History | 0–200 | 10 pts per repayment, capped at 20 repayments |
| Delegated Credit | 0–100 | Linear up to $10,000 USDC delegated |
| Cross-Protocol Bonus | 0–100 | +100 if active on both Aave AND Compound, +40 if one |

**Penalty components (max −550 pts)**

| Component | Range | Logic |
|---|---|---|
| Volatility Discount | 0–100 | Penalises >10% utilization swing over 7 days |
| Utilization Penalty | 0–150 | Linear penalty for >50% utilization, max at 100% |
| Liquidation Penalty | 0–300 | 100 pts per liquidation event, capped at 3 |

**Final score = clamp(positives − penalties, 0, 1000)**

### Additional Stylus Functions

The engine also exposes rate model calculations used by the mock pools:

- `borrowRateBps()` — two-slope variable rate model (same math as Aave)
- `supplyRateBps()` — supply rate accounting for reserve factor
- `aggregateHealthFactor()` — weighted HF across Aave + Compound positions with different liquidation thresholds

### Graceful Degradation

`CreditManager` has a fallback credit scoring path. If the Stylus engine is not yet deployed (e.g. during initial testnet setup), it falls back to a simplified on-chain Solidity calculation using the original 6-component model. Once the Stylus engine is wired via `setScoreEngine()`, all subsequent calls route to it automatically.

---

## Mock Pools

Because Aave V3 and Compound V3 do not have official deployments on Arbitrum Sepolia, Aurion deploys realistic mock pools that mirror the exact ABIs of the real protocols.

### MockAavePool

Mirrors Aave V3's interface exactly:

- `supply(asset, amount, onBehalfOf, referralCode)` — deposit collateral
- `withdraw(asset, amount, to)` — withdraw collateral
- `borrow(asset, amount, interestRateMode, referralCode, onBehalfOf)` — borrow
- `repay(asset, amount, interestRateMode, onBehalfOf)` — repay
- `getUserAccountData(user)` — returns collateral, debt, available borrows, LTV, health factor
- `getRatesFormatted()` — returns borrowAPY, supplyAPY, utilBps for the frontend

**Interest Rate Model — Two Slope:**
```
if utilization <= optimal (80%):
  rate = base + (utilization / optimal) × slope1

if utilization > optimal:
  rate = base + slope1 + ((utilization - optimal) / (1 - optimal)) × slope2
```
Default params: base=0%, slope1=4%, slope2=75%, optimal=80%, reserve factor=10%.

Interest compounds into `liquidityIndex` and `variableBorrowIndex` on every interaction, exactly as Aave does.

### MockCToken (Compound V2)

Mirrors Compound V2's cToken interface:

- `mint(amount)` — supply USDC, receive cToken shares
- `redeem(cTokens)` / `redeemUnderlying(amount)` — withdraw
- `borrow(amount)` — borrow against cToken collateral
- `repayBorrow(amount)` — repay (called by adapter)
- `getAccountSnapshot(user)` — returns cToken balance, borrow balance, exchange rate
- `getRatesFormatted()` — returns borrowAPY, supplyAPY, utilBps
- `underlying()` — returns USDC address (required by adapter)

**Interest Rate Model — JumpRateModel:**
```
if utilization <= kink (80%):
  rate = base + utilization × multiplier

if utilization > kink:
  rate = base + kink × multiplier + (utilization - kink) × jumpMultiplier
```
Default params matching Compound USDC: multiplier=5%/yr, jumpMultiplier=109%/yr, kink=80%, reserve factor=10%.

Interest accrues into the exchange rate — cToken holders automatically earn interest as the rate grows.

### Mock Aave and Compound pool

The mock pools are not placeholders, they implement the actual mathematical models used by Aave and Compound in production. The `AaveAdapter` and `CompoundAdapter` use the exact same function signatures against the mocks as they would against mainnet contracts. Swapping from mock to mainnet requires only changing the address in the adapter constructor.

---

## Frontend

The frontend is a React 18 application using Tailwind CSS and Ethers.js v6. Navigation is handled via a custom `currentPage` state (no React Router) to keep the app as a single-page layout with a persistent sidebar.

### Pool Pages

**Markets (`/markets`)** — Market selector showing both mock pools with live stats and a link to the credit score dashboard.

**AavePool (`/aave-pool`)** — Full supply/withdraw/borrow/repay interface for MockAavePool. Shows live APY, utilization bar, health factor with color coding, and MAX button. Every action feeds the credit score.

**CompoundPool (`/compound-pool`)** — Same interface for MockCToken. Shows cUSDC balance, exchange rate, collateral factor, and JumpRateModel rates.

**Credit Score Dashboard** — Live view of the 8-component Stylus score breakdown, tier badge, progress to next tier, protocol activity badges, and a "How to improve" checklist.

### Key Hooks

**`useMarketPool(getPoolContract)`** — Unified hook for both pools. Uses `safeCall` to gracefully handle differences between pool ABIs — tries Aave functions first, falls back to Compound equivalents. Handles approval → tx → confirmation → refetch automatically.

**`useCreditScore(creditManagerAddress, userAddress)`** — Batches all credit reads in a single `useReadContracts` call. Polls every 15 seconds. Returns formatted tier metadata, score color, progress to next tier, and cross-protocol activity flags.

**`useDashboard()`** — Reads the full `userMetrics` tuple from `CreditManager` in one call. Returns debt, limit, health factor, credit score, risk tier, and account history.

---

## Contract Security Design

### Access Control
- `CreditRouter` is the sole entry point for all state-changing credit operations
- `CreditManager` accepts calls only from `router` (via `onlyRouter`) or `router + pool` (via `onlyRouterOrPool`)
- One-time setter pattern for critical addresses (`AlreadySet` guard)
- Zero-address guards on all constructors and setters

### State Integrity
- Per-protocol debt tracking (`aaveDebt`, `compoundDebt`) is updated atomically with `_totalDebt` — they cannot diverge
- Utilization snapshots taken every 7 days for volatility calculation — no oracle dependency
- Liquidation auto-freezes the account; admin `unfreeze()` is available via router for review

### Fallback Safety
- If Stylus engine reverts or is not deployed, `creditScore()` falls back to on-chain Solidity math
- This means a Stylus outage cannot brick the protocol — borrows continue with the simpler score

---

## Deployment Details

### Foundry Configuration
```toml
[profile.default]
src = "contracts"
test = "test"
out = "out"
libs = ["lib"]
solc_version = "0.8.20"
via_ir = true          # Required: CreditManager exceeds EVM stack depth without IR
optimizer = true
optimizer_runs = 200
fs_permissions = [{ access = "write", path = "./deployments" }]
```

`via_ir = true` is required because `CreditManager` with all score components exceeds the EVM's 16-slot stack limit when compiled via the legacy code generator. The IR pipeline resolves this.

### Deploy Order
The deploy script follows a careful ordering to handle circular dependencies:

```
1. TestUSDC + TokenFaucet
2. CreditOracle + LiquidationController
3. CreditRouter (manager=0, insurancePool=0 initially)
4. CreditManager → router.setCreditManager()
5. InsurancePool → router.setInsurancePool()
6. CreditPool → router.setCreditPool() (also calls manager.setPool())
7. MockAavePool + MockCToken (seeded with 5M USDC each)
8. AaveAdapter + CompoundAdapter
9. Stylus engine wire
```

---

## Current Status

| Item | Status |
|---|---|
| Core contracts | ✅ Complete |
| Mock Aave pool (variable rate) | ✅ Complete |
| Mock Compound pool (JumpRateModel) | ✅ Complete |
| AaveAdapter + CompoundAdapter (borrow + repay) | ✅ Complete |
| Stylus CreditScoreEngine (Rust/WASM) | ✅ Written, pending deployment |
| Arbitrum Sepolia deployment | ✅ Live |
| Frontend pool UIs | ✅ Complete |
| Credit score dashboard | ✅ Complete |
| Stylus engine wired on-chain | 🔄 Pending `cargo stylus deploy` |
| Real Aave/Compound mainnet integration | 🔄 Phase 2 |
| Security audit | 🔄 Planned |


ハッカソンの進行状況

We were able to make changes to the contract by deploying stylus to help with the heavy calculation to get the right credit delegation for each user. Also we were able to deploy a new router and manager address. We also replicate a sample Aave and Compound protocol (since they dont have testnet on Arbitrum ), so users can test how Aurion actually works without waiting on Aave or Compound testnet. We rebuilt our landing page to flow with the new stylus deployed.

資金調達の状況

We are yet to raise any Fund But we are interested in raising fund through public ICO

チームリーダー
AAliyu Aliyu
プロジェクトリンク
エコシステムをデプロイ
Arbitrum OneArbitrum One
業界
DeFi