# Introduction (/docs) Reforge is an MEV-aware batch auction mechanism for DeFi liquidations. It replaces gas-war Priority Gas Auctions with economic efficiency-based scoring — selecting liquidators by **Net Economic Value** rather than who pays the highest gas bribe. ## Explore the Docs [#explore-the-docs] # Backend Architecture (/docs/architecture/backend) The Reforge backend is an event-driven microservices architecture built with **Node.js**, **TypeScript**, **Fastify**, **Redis**, and **PostgreSQL**. It continuously ingests on-chain events, computes liquidation opportunities, and orchestrates discrete auction lifecycles. *** ## Service Pipeline & Dataflow [#service-pipeline--dataflow] *** ## Core Backend Stack [#core-backend-stack] | Technology | Category | Purpose | | :--------------------------- | :---------------- | :-------------------------------------------------------------------------------------------------------------- | | **Fastify & TypeScript** | API Framework | Ultra-low latency HTTP API router with strict JSON schema validation and zero-overhead routing. | | **Redis & BullMQ** | Task Queue | High-throughput in-memory job queues managing parallel auction events, delayed jobs, and retries. | | **viem & WebSocket RPC** | Blockchain Client | Lightweight, type-safe EVM interaction library maintaining persistent WebSocket subscriptions to Anvil/Sepolia. | | **PostgreSQL & Drizzle ORM** | Data Persistence | Relational persistence for historical auctions, searcher telemetry, gas costs, and experimental metrics. | *** ## Codebase Directory Structure [#codebase-directory-structure] The backend source tree is organized into modular domain services: *** ## Detailed Service Responsibilities [#detailed-service-responsibilities] ### 1. Blockchain Listener (`block-listener.ts`) [#1-blockchain-listener-block-listenerts] Subscribes to new block headers via WebSocket RPC. Emits internal `block:new` events with gas base fee estimates and block timestamp data. ### 2. Opportunity Engine (`opportunity.service.ts`) [#2-opportunity-engine-opportunityservicets] Maintains an in-memory registry of open borrower positions. Upon receiving a new block or price oracle update, it recomputes health factors using the mathematical model: ``` HF = (Σ Collateral_i × Price_i × LiquidationThreshold_i) / (Σ Debt_j × Price_j) ``` If `HF < 1.00`, it dispatches a high-priority liquidation job to the BullMQ queue. ### 3. Auction Engine (`auction.service.ts` & `scoring.service.ts`) [#3-auction-engine-auctionservicets--scoringservicets] Orchestrates the lifecycle of discrete batch auctions: 1. **Auction Open:** Emits auction parameters and opens the bidding window (1–2 blocks). 2. **Bid Collection:** Collects sealed bids with liquidator routing parameters and slippage bounds. 3. **NEV Evaluation:** Scores all submissions according to Net Economic Value: ``` NEV = Gross Liquidation Value - Gas Cost - DEX Slippage Cost ``` 4. **Settlement:** Automatically submits the winning bid settlement transaction on-chain. # Frontend Views (/docs/architecture/frontend) The Reforge frontend is a modular, high-performance web application built with **Next.js 16**, **Tailwind CSS**, and **Fumadocs**. It delivers four dedicated interfaces tailored for observers, MEV liquidator searchers, and protocol researchers. *** ## Views Overview [#views-overview] *** ## 1. Protocol Dashboard (`/dashboard`) [#1-protocol-dashboard-dashboard] The **Protocol Dashboard** serves as the central command center for monitoring systemic risk, collateralization ratios, and global protocol health across all asset pools. ### Key Metrics Monitored [#key-metrics-monitored] | Metric | Category | Description | | :--------------------------- | :--------- | :------------------------------------------------------------------------------------------------------------------------- | | **Total Value Locked (TVL)** | Liquidity | Aggregate value of collateral deposited across all lending pools (ETH, WBTC, wstETH) priced via real-time Chainlink feeds. | | **Outstanding Debt** | Solvency | Total synthetic and stablecoin debt borrowed against active collateral positions (USDC, USDT, DAI). | | **Active Positions** | Risk | Total count of live borrower debt positions continuously scanned for solvency. | | **Liquidatable Positions** | Alert | Immediate alert counter showing all positions currently crossing the threshold where `HF < 1.00`. | | **Settled Volume** | Throughput | Cumulative dollar volume of liquidations settled deterministically through Reforge batch auctions. | | **Bad Debt Prevented** | Security | Total protocol insolvency prevented compared to baseline mempool congestion failure rates. | ### Protocol Solvency Telemetry [#protocol-solvency-telemetry] | Metric | Calculation / Source | Update Frequency | Purpose | | :---------------------------- | :------------------------------------------------- | :------------------ | :--------------------------------------------------- | | **Global Collateral Ratio** | `Total Collateral Value / Total Borrowed Debt` | Per block (12s) | Measures macro protocol solvency buffer. | | **At-Risk Debt (HF \< 1.05)** | Sum of debt for positions with `HF ∈ [1.00, 1.05)` | Real-time WebSocket | Early warning queue for incoming liquidation volume. | | **Protocol Recovery Rate** | `(Recovered Collateral / Defaulted Debt) × 100%` | Per settled auction | Evaluates liquidation execution efficiency. | | **Average Auction Duration** | Block timestamp delta (End - Start) | Historical indexer | Monitors batch clearance latency against volatility. | *** ## 2. Liquidation Marketplace (`/marketplace`) [#2-liquidation-marketplace-marketplace] The **Liquidation Marketplace** is a live feed of underwater loans where liquidators, automated searchers, and users can discover liquidation opportunities. ### Live Opportunities Explorer [#live-opportunities-explorer] A real-time reactive table displaying open auction events and eligible borrower positions: | Position ID | Collateral Asset | Debt Value | Health Factor | Est. Gross Profit | Auction Status | Action | | :-------------- | :--------------------- | :----------- | :------------ | :---------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | :------------ | | `0x7A29...b4F1` | 4.50 ETH ($13,500) | $9,200 USDC | **0.97** | **+$460.00** | 🟢 Bidding Open | Inspect / Bid | | `0x19E4...88c2` | 1.20 WBTC ($72,000) | $51,400 USDT | **0.94** | **+$2,570.00** | 🟡 1 Block Left | Place Bid | | `0x42B0...179A` | 18.00 wstETH ($61,200) | $44,800 USDC | **0.99** | **+$1,344.00** | 🔵 Calculating | View Details | *** ### Position Deep-Dive Inspector [#position-deep-dive-inspector] Selecting any position opens the comprehensive **Position Inspector Panel**, giving liquidators full transparency before committing capital.
Total Collateral 10.00 ETH ($30,000.00)
Total Borrowed Debt $21,400.00 USDC
Current Health Factor 0.941 (Liquidatable)
Liquidation Bonus Margin +5.00% ($1,070.00)
Auction Window Block #19,420,102 → #19,420,104
Competing Sealed Bids 4 Searchers Active
Scoring Metric Net Economic Value (NEV)
Settlement Mechanism Single Atomic Tx
Target AMM Venue Uniswap v3 (0.05% Pool)
Modeled Slippage Impact 0.12% ($25.68)
Base Gas Estimate 142,000 gas ($8.20)
Expected Net Value $1,036.12
*** ## 3. Liquidator Console (`/liquidator`) [#3-liquidator-console-liquidator] The **Liquidator Console** is an institutional execution workstation allowing searchers and bot operators to monitor their capital efficiency, active commitments, and realized P\&L.

Searcher Cockpit Telemetry

  • Connected Wallet: 0x94B...28aF (Mainnet / Sepolia)
  • Available Liquidity: $150,000.00 USDC
  • Active Capital in Transit: $32,400.00 USDC

Historical Performance Metrics

  • Auctions Won: 142 / 168 (84.5% Win Rate)
  • Total Net Profit: +$18,420.50
  • Total Gas Expended: $1,240.10 (vs. $9,800+ in baseline PGA)
  • Effective Net ROI: +14.85%
**Zero Gas Bribery Overhead:** Because Reforge awards settlements based on Net Economic Value rather than priority gas placement, searchers keep up to 90% of their gross profit instead of paying it to block proposers. *** ## 4. Research Laboratory (`/research`) [#4-research-laboratory-research] The **Research Laboratory** is the cornerstone academic interface of Reforge. It enables researchers to configure simulation scenarios, run comparative benchmarks between conventional first-come liquidations and MEV-aware batch auctions, and visualize empirical results. ### Interactive Experiment Configuration [#interactive-experiment-configuration]

Simulation Parameter Matrix

Liquidation Mechanism
Conventional PGA MEV-Aware Batch Auction
Competing Liquidators

10 Active Searcher Bots

Configurable between 2 to 100 automated agents
Network Gas Price

50 Gwei (Base: 35, Priority: 15)

Simulates normal vs. congested mempool conditions
Collateral Shock Volatility

5.0% Flash Drop

Geometric Brownian motion with jump-diffusion events
*** ### Comparative Benchmark Results [#comparative-benchmark-results] Simulated execution across 1,000 synthetic liquidation events demonstrates substantial economic advantages: | Performance Metric | Conventional PGA | Reforge Batch Auction | Variance | Economic Impact | | :------------------------- | :--------------- | :-------------------- | :-------------------------------------------------------------- | :---------------------------------------------------------- | | **Gas Cost / Liquidation** | **$142.00** | **$61.00** | -57.0% | Massive reduction in network congestion and wasted compute. | | **Liquidator Net Profit** | **$321.00** | **$402.00** | +25.2% | Liquidators retain value instead of paying block proposers. | | **Borrower Loss** | **$718.00** | **$531.00** | -26.0% | Borrowers preserve substantially more leftover equity. | | **Settlement Latency** | **1.8 blocks** | **2.1 blocks** | +0.3 blocks | Acceptable micro-delay safely offset by protocol buffers. | | **Protocol Debt Recovery** | **96.2%** | **97.1%** | +0.9% | Higher debt clearance rate with lower bad debt risk. | *** ## Technical Specifications [#technical-specifications] For in-depth architectural component designs, interface schemas, and state management models, explore the living specifications: # System Overview (/docs/architecture) Reforge is organized into four interconnected layers spanning on-chain protocols, real-time backend coordination services, user/liquidator web applications, and an empirical simulation lab. *** ## High-Level Architecture Flow [#high-level-architecture-flow] *** ## Architectural Layers [#architectural-layers] *** ## Core System Responsibilities [#core-system-responsibilities] | System Layer | Primary Technologies | Core Responsibilities | | :-------------------- | :---------------------------------------- | :--------------------------------------------------------------------------------------------------------------------------------- | | **Smart Contracts** | Solidity 0.8+, Foundry, OpenZeppelin | Custodies collateral, manages lending accounting, opens discrete batch auctions, and settles liquidation payouts atomically. | | **Backend Services** | Node.js, TypeScript, Fastify, viem, Redis | Monitors blocks via WebSocket, detects underwater accounts ($HF \< 1.0$), computes Net Economic Value scores, and dispatches jobs. | | **Frontend Views** | Next.js 16, Tailwind CSS, Fumadocs | Provides user dashboard, liquidator bidding console, protocol telemetry, and interactive research simulator. | | **Research Pipeline** | Python, NumPy, Pandas, Matplotlib | Orchestrates Monte Carlo market shocks, models gas wars vs. batch auctions, and generates empirical comparison figures. | # Smart Contract Architecture (/docs/architecture/smart-contracts) The smart contract layer forms the foundational financial system of Reforge. Written in **Solidity 0.8+** and tested with **Foundry**, these contracts handle collateral custody, loan accounting, price oracle ingestion, discrete batch auctions, and AMM swaps. *** ## Contract Directory Structure [#contract-directory-structure] *** ## Core Protocol Contracts [#core-protocol-contracts] | Contract | Role | Core Responsibility | | :--------------------------- | :------------------ | :------------------------------------------------------------------------------------------------------------------------- | | **`LendingPool.sol`** | Liquidity Hub | Manages user deposits, collateral locking, debt borrowing, repayments, and position balances. | | **`LiquidationAuction.sol`** | Auction Coordinator | Central research mechanism: coordinates discrete batch auction windows, collects bids, and executes atomic settlements. | | **`LiquidationManager.sol`** | Eligibility & Math | Evaluates account eligibility, computes maximum liquidatable debt ceilings, and calculates collateral transfer quantities. | | **`PriceOracle.sol`** | Pricing Feed | Dual-mode pricing oracle supporting real-time Chainlink feeds as well as programmatic price shocks for simulations. | | **`MockDEX.sol`** | AMM Simulation | Simulates constant-product AMM liquidity pools with configurable slippage curves and price impact models. | | **`HealthFactor.sol`** | Math Library | Shared mathematical library implementing standardized precision-safe Health Factor calculations. | *** ## Contract Interfaces & Function Signatures [#contract-interfaces--function-signatures] ```solidity interface ILendingPool { function deposit(address asset, uint256 amount) external returns (uint256); function withdraw(address asset, uint256 amount) external returns (uint256); function borrow(address asset, uint256 amount) external returns (uint256); function repay(address asset, uint256 amount) external returns (uint256); function getAccountData(address user) external view returns ( uint256 totalCollateralETH, uint256 totalDebtETH, uint256 availableBorrowsETH, uint256 currentLiquidationThreshold, uint256 ltv, uint256 healthFactor ); } ``` ```solidity interface ILiquidationAuction { function openAuction(address borrower, uint256 debtToCover) external returns (bytes32 auctionId); function submitBid(bytes32 auctionId, uint256 minCollateralOut, bytes calldata routeData) external; function closeAuction(bytes32 auctionId) external; function settleAuction(bytes32 auctionId) external returns (address winner, uint256 bonusAwarded); } ``` ```solidity interface ILiquidationManager { function isLiquidatable(address borrower) external view returns (bool); function calculateCollateralToLiquidate( address borrower, address debtAsset, uint256 debtToCover ) external view returns (uint256 collateralAmount, uint256 liquidationBonus); } ``` ```solidity interface IPriceOracle { function getAssetPrice(address asset) external view returns (uint256); function setAssetPrice(address asset, uint256 price) external; // Simulation mode function setDropPercentage(address asset, uint256 dropBps) external; // Flash crash shock } ``` *** ## DEX Liquidation & Price Impact Flow [#dex-liquidation--price-impact-flow] When liquidators seize collateral during high-volatility events, collateral must be immediately liquidated into debt assets (e.g., ETH $\to$ USDC) on an AMM. Reforge explicitly models this DEX slippage in Net Economic Value scoring: # Overall Tech Stack (/docs/architecture/tech-stack) The Reforge platform leverages modern, industry-standard tooling across every layer of the architecture, optimized for developer velocity, type safety, deterministic testing, and high-performance event processing. *** *** ## Detailed Technology Breakdown [#detailed-technology-breakdown] ### 1. Smart Contract & Blockchain Layer [#1-smart-contract--blockchain-layer] | Technology | Version / Tool | Category | Role & Purpose | | :------------------ | :--------------- | :-------- | :---------------------------------------------------------------------------------------- | | **Solidity** | `^0.8.24` | Language | Core smart contract development with custom errors and transient storage support. | | **Foundry** | `forge` / `cast` | Toolchain | High-speed compilation, fuzzing, differential testing, and contract deployment. | | **Anvil** | Local Node | Testing | Fast local Ethereum node with programmable RPC state manipulation and flash loan mocking. | | **OpenZeppelin** | `v5.0` | Libraries | Standard ERC-20, SafeERC20, ReentrancyGuard, and Ownable implementations. | | **Sepolia Testnet** | Ethereum L1 | Network | Public testnet deployment venue for end-to-end multi-agent auction trials. | *** ### 2. Backend Infrastructure & Real-Time Pipeline [#2-backend-infrastructure--real-time-pipeline] | Technology | Version / Tool | Category | Role & Purpose | | :----------------- | :------------- | :------------ | :-------------------------------------------------------------------------------------- | | **Node.js** | `v22 LTS` | Runtime | High-performance asynchronous execution runtime. | | **TypeScript** | `v5.x` | Language | Strict end-to-end typing across data schemas, API contracts, and RPC calls. | | **Fastify** | `v4.x` | Web Framework | Low-overhead HTTP REST API server with built-in JSON schema validation. | | **viem** | `v2.x` | Web3 Client | Modular, lightweight Ethereum client maintaining persistent WebSocket subscriptions. | | **Redis & BullMQ** | `v7.x` | Message Queue | In-memory job queue managing high-priority liquidation discovery and auction timers. | | **PostgreSQL** | `v16` | Database | Persistent relational storage for historical auctions, bids, and simulated experiments. | *** ### 3. Frontend & User Interfaces [#3-frontend--user-interfaces] | Technology | Version / Tool | Category | Role & Purpose | | :--------------- | :------------- | :--------------- | :-------------------------------------------------------------------------------------- | | **Next.js** | `16.3.0` | Framework | React 19 App Router framework with Turbopack compilation and SSR/SSG. | | **Tailwind CSS** | `v4.0` | Styling | Modern utility-first CSS engine with dark/light mode CSS variables. | | **Fumadocs** | `v16.x` | Documentation | High-performance MDX documentation engine with search, TOC, and Mermaid diagrams. | | **wagmi & viem** | Latest | Web3 React Hooks | React hooks for Ethereum wallet connection, EIP-712 signing, and contract interactions. | | **Lucide Icons** | Latest | Icons | Clean, consistent SVG icon set utilized throughout the UI. | *** ### 4. Research & Scientific Modeling [#4-research--scientific-modeling] | Technology | Category | Role & Purpose | | :------------------------- | :--------------- | :------------------------------------------------------------------------------------ | | **Python 3.12** | Core Language | Data science, statistical modeling, and simulation execution environment. | | **NumPy & SciPy** | Computation | Vectorized numerical modeling of borrower health factors and price trajectories. | | **Pandas** | Data Analysis | Tabular data manipulation for large-scale multi-run auction benchmark logs. | | **Matplotlib & Seaborn** | Visualization | Publication-quality chart generation for liquidation latency vs. bad debt trade-offs. | | **scikit-learn / XGBoost** | Machine Learning | Optional predictive models for estimating optimal auction window lengths. | # DeFi Fundamentals (/docs/getting-started/defi-fundamentals) Decentralized Finance (DeFi) lending protocols allow users to borrow assets against cryptocurrency collateral without intermediaries or credit checks. Understanding these fundamental mechanics is essential to understanding why conventional liquidation systems fail under network congestion. *** ## Core Terminology [#core-terminology] | Term | Definition | Role in Reforge | | :------------------------ | :------------------------------------------------------------------------------- | :----------------------------------------------------- | | **Collateral (ETH)** | Volatile crypto asset deposited into a lending pool to back a loan. | Seized and sold during liquidation to cover debt. | | **Debt Asset (USDC)** | Fiat-pegged stablecoin ($1.00 USD) borrowed by the user. | Repaid by the liquidator during liquidation. | | **Overcollateralization** | The requirement that collateral value strictly exceeds borrowed value. | Provides a safety buffer against market price drops. | | **Liquidation** | The programmatic sale of collateral to repay bad debt when loan health degrades. | The core process Reforge redesigns via batch auctions. | | **Liquidation Bonus** | A predetermined discount (e.g. 5%) given to liquidators on seized collateral. | The profit incentive driving liquidator competition. | | **Gas Fee** | Network transaction fee paid to blockchain validators for execution priority. | Currently wasted in Priority Gas Auctions (PGAs). | *** ## How DeFi Lending Works [#how-defi-lending-works] In traditional finance, loans require credit scores and legal recourse. In DeFi, loans are completely trustless and secured through **overcollateralization**. ### The Overcollateralization Safety Margin [#the-overcollateralization-safety-margin] Because cryptocurrencies like ETH are volatile, protocols require borrowers to deposit more collateral than the value of debt they borrow. ``` Collateral: 10 ETH @ $3,000/ETH = $30,000 Borrowed: $20,000 USDC LTV Ratio: $20,000 / $30,000 = 66.7% Threshold: 75.0% Status: ✅ Safe (Healthy buffer) ``` ``` ETH Price drops to $2,800: Collateral: 10 ETH @ $2,800/ETH = $28,000 Borrowed: $20,000 USDC LTV Ratio: $20,000 / $28,000 = 71.4% Threshold: 75.0% Status: ⚠️ Warning (Approaching liquidation threshold) ``` ``` ETH Price drops to $2,600: Collateral: 10 ETH @ $2,600/ETH = $26,000 Borrowed: $20,000 USDC LTV Ratio: $20,000 / $26,000 = 76.9% Threshold: 75.0% Status: 🚨 Liquidatable (Immediate liquidation trigger) ``` **Why liquidation is critical:** If the price of ETH falls below the debt value ($20,000) and the borrower walks away, the protocol incurs **bad debt** and lenders lose their funds. Liquidation must occur before this point. *** ## The Anatomy of a Liquidation [#the-anatomy-of-a-liquidation] When a loan crosses the liquidation threshold, the protocol allows third-party actors (**Liquidators**, typically automated bots) to step in. ### Numerical Walkthrough [#numerical-walkthrough] #### 1. Position Breaches Threshold [#1-position-breaches-threshold] * **Collateral:** $26,000 ETH (10 ETH) * **Debt:** $20,000 USDC * **LTV Ratio:** 76.9% (exceeds 75% max threshold) #### 2. Liquidator Repays Partial Debt [#2-liquidator-repays-partial-debt] * The liquidator calls the smart contract and pays off **$10,000 USDC** of the borrower's debt. * Remaining Debt: `$20,000 - $10,000 = $10,000 USDC`. #### 3. Protocol Awards Discounted Collateral [#3-protocol-awards-discounted-collateral] * The protocol calculates collateral repayment equal to the debt paid plus a **5% liquidation bonus**: `$10,000 + $500 = $10,500 worth of ETH`. * Liquidator receives **$10,500 in ETH** for spending $10,000 in USDC (Gross Profit = **$500**). #### 4. Restored Health State [#4-restored-health-state] * **New Collateral:** `$26,000 - $10,500 = $15,500 ETH`. * **New Debt:** `$10,000 USDC`. * **New LTV Ratio:** `$10,000 / $15,500 = 64.5%` (well below 75% threshold, restoring safety). *** ## Next Up: The Structural Flaw [#next-up-the-structural-flaw] While this mechanism protects the protocol from bad debt in theory, in practice it sparks aggressive bot competition. # Overview (/docs/getting-started) Welcome to the **Getting Started** section of Reforge. This section establishes the economic and technical foundations behind decentralized lending, demonstrates why conventional first-come liquidations fail under MEV competition, and outlines Reforge's batch auction solution. *** ## The Learning Journey [#the-learning-journey] *** ## Core Topics in this Section [#core-topics-in-this-section] # Our Solution (/docs/getting-started/our-solution) Reforge addresses the structural failure of Priority Gas Auctions by replacing latency-driven mempool races with a **discrete, time-windowed Batch Auction**. Instead of rewarding whichever bot pays the largest gas bribe to a validator, Reforge evaluates competing bids on **Net Economic Value** and executes exactly one optimal liquidation per unhealthy position. *** ## Core Contribution [#core-contribution] ### Working Title [#working-title] **"A MEV-Aware Batch Auction Mechanism for DeFi Liquidations: Reducing Gas Competition and Collateral Loss"** **Primary Contribution:**\ Design, implementation, and empirical evaluation of an end-to-end MEV-aware liquidation mechanism that explicitly accounts for liquidation profitability, transaction costs, competition, auction latency, and borrower/protocol outcomes. *** ## Mechanism Overview: From Race to Batch Auction [#mechanism-overview-from-race-to-batch-auction] *** ## The Scoring Function: Net Economic Value [#the-scoring-function-net-economic-value] Conventional protocols accept the first valid transaction. Reforge scores all bids submitted during the auction window using an objective economic metric: ``` Net Economic Value = Gross Liquidation Value − Gas Cost − DEX/Slippage Cost ``` | Bidder | Gross Value | Gas Expenditure | DEX Slippage Impact | Net Economic Value | Rank / Decision | | :--------------- | :---------- | :-------------------------- | :---------------------- | :----------------- | :-------------- | | **Liquidator A** | $1,000 | $200 (High gas war) | $80 (High impact) | **$720** | ❌ 3rd Place | | **Liquidator B** | $1,000 | **$60 (Efficient routing)** | **$40 (Optimized AMM)** | **$900** | 🏆 **Winner** | | **Liquidator C** | $1,000 | $120 (Moderate gas) | $20 (Low impact) | **$860** | ❌ 2nd Place | Even if Liquidator A attempts to frontrun by offering $200 in gas fees, **the protocol ignores transaction priority**. Because Liquidator B routes trades with lower slippage and minimal gas overhead, it generates **$900 in true economic value** vs. Liquidator A's $720. Liquidator B is awarded the liquidation. *** ## Tripartite Alignment: Balancing All Three Stakeholders [#tripartite-alignment-balancing-all-three-stakeholders] A sustainable liquidation mechanism must align incentives across the three primary participants: | Stakeholder | Conventional System (PGA) | Reforge MEV-Aware Batch Auction | | :------------- | :------------------------------------------------------------------ | :--------------------------------------------------------------------- | | **Borrower** | Suffers fixed, aggressive collateral penalties (5-10%). | Maximizes preserved equity by reducing unnecessary discounts. | | **Protocol** | Transactions fail during mempool congestion; bad debt piles up. | Guaranteed single-transaction settlement with deterministic inclusion. | | **Liquidator** | Surrenders 70-90% of gross margin to block proposers in gas bribes. | Retains profits based on execution and routing efficiency. | *** ## The Critical Research Trade-Off [#the-critical-research-trade-off] Every architectural decision carries trade-offs. Introducing a batch auction window requires careful scientific evaluation. ### The Auction Latency Problem [#the-auction-latency-problem] In a conventional system, liquidation is immediate (next block). In Reforge, the auction window introduces a **1–2 block delay**. During this 1–2 block window, if the collateral price experiences an extreme flash crash, the position could become underwater before settlement. ### The Central Research Question [#the-central-research-question] > **Does the significant reduction in MEV gas waste and collateral loss outweigh the marginal risk introduced by auction latency?** Our empirical research platform and simulation engine (`/docs/research`) are designed specifically to answer this question across historical and synthetic stress-test market conditions. *** ## Explore Next [#explore-next] # The Problem (/docs/getting-started/problem-statement) In conventional DeFi lending protocols (such as Aave, Compound, and MakerDAO), liquidation is designed around a **first-come, first-served** model. When a position becomes unhealthy, whoever submits the first valid liquidation transaction captures the profit. This design inadvertently triggers intense **Maximal Extractable Value (MEV)** competition that damages borrowers, protocols, and the wider blockchain network. *** ## The Health Factor Metric [#the-health-factor-metric] Lending protocols standardize position health using a single composite formula: ``` Health Factor (HF) = (Collateral Value × Liquidation Threshold) / Debt Value ``` * **$HF > 1.0$**: The position is healthy and adequately collateralized. * **$HF \< 1.0$**: The position has breached the risk threshold and is immediately liquidatable by any network participant. ### Example Scenario [#example-scenario] ``` Collateral: 10 ETH @ $3,000/ETH = $30,000 Liquidation Threshold: 80% (0.8) Borrowed Debt: $20,000 USDC HF = ($30,000 × 0.8) / $20,000 = 1.20 (Healthy) ``` If ETH price plunges from **$3,000 to $2,300**: ``` New Collateral Value = $23,000 New HF = ($23,000 × 0.8) / $20,000 = 0.92 (Liquidatable!) ``` *** ## The Core Failure: Priority Gas Auctions (PGAs) [#the-core-failure-priority-gas-auctions-pgas] When $HF \< 1.0$, multiple automated searcher bots detect the exact same opportunity simultaneously. Because only the **first** transaction gets included, bots enter a **Priority Gas Auction (PGA)**. ### The Misalignment of Incentives [#the-misalignment-of-incentives] In a PGA, the winner is determined by **who can pay the highest bribe to the block validator**, not who executes the liquidation most economically for the borrower or protocol. | Participant | Gross Incentive | Gas Bid Paid | DEX Slippage | Net Liquidator Profit | Value Transferred to Validator | | :----------------- | :-------------- | :------------------ | :----------- | :----------------------- | :----------------------------- | | **Bot A** | $500 | $40 (20 gwei) | $20 | $440 (Failed / Replaced) | $0 | | **Bot B (Winner)** | $500 | **$220 (140 gwei)** | $30 | **$250** | **$220** | | **Bot C** | $500 | $150 (90 gwei) | $25 | $325 (Failed / Replaced) | $0 | ``` Gross Liquidation Bonus: $500.00 (Extracted from Borrower) ---------------------------------------------------------- - Paid in Gas Bribes: $220.00 (Transferred to Block Validator) - DEX Slippage & Fees: $30.00 (Slippage on Collateral Dump) ========================================================== = Net Liquidator Profit: $250.00 (Only 50% of incentive retained!) ``` *** ## Systemic Negative Externalities [#systemic-negative-externalities] | Problem / Externality | Mechanism & Impact | | :---------------------------------------- | :----------------------------------------------------------------------------------------------------------------------------------------- | | **1. Massive Economic Gas Waste** | Liquidators surrender up to 70–90% of their gross margin in gas wars, directing capital away from DeFi utility and into validator pockets. | | **2. Excessive Borrower Collateral Loss** | Borrowers suffer fixed 5–10% penalties regardless of whether market conditions require such heavy discounts to achieve liquidity. | | **3. Cascading DEX Price Crashes** | Liquidators dump seized collateral rapidly on AMMs to lock in profits, causing localized slippage and triggering secondary liquidations. | | **4. Consensus Instability** | High MEV rewards create incentives for time-bandit attacks, transaction reordering, block reorganizations, and validator timing games. | *** ## The Central Research Questions [#the-central-research-questions] ### Research Question 1 [#research-question-1] **Does competitive MEV extraction make DeFi liquidation unnecessarily expensive and amplify the economic damage suffered by borrowers?** ### Research Question 2 [#research-question-2] **Can the liquidation mechanism be redesigned so that competition is based on economic efficiency rather than a race to submit the highest-priority gas bribe?** *** ## Next Up: Academic Literature & Our Solution [#next-up-academic-literature--our-solution] # Contributing (/docs/guides/contributing) ## Spec-First Rule [#spec-first-rule] TODO ## Branch Naming [#branch-naming] TODO ## PR Process [#pr-process] TODO ## Code Review [#code-review] TODO ## Status [#status] Draft # Deploying Contracts (/docs/guides/deploying-contracts) ## Prerequisites [#prerequisites] TODO ## Local Deployment (Anvil) [#local-deployment-anvil] TODO ## Testnet Deployment (Sepolia) [#testnet-deployment-sepolia] TODO ## Verify on Etherscan [#verify-on-etherscan] TODO ## Status [#status] Draft # Local Development (/docs/guides/local-development) ## Prerequisites [#prerequisites] TODO ## Clone & Install [#clone--install] TODO ## Start Anvil (Local Chain) [#start-anvil-local-chain] TODO ## Deploy Contracts [#deploy-contracts] TODO ## Start Backend [#start-backend] TODO ## Start Frontend [#start-frontend] TODO ## Verify [#verify] TODO ## Status [#status] Draft # Running Simulations (/docs/guides/running-simulations) ## Prerequisites [#prerequisites] TODO ## Configuration [#configuration] TODO ## Running a Simulation [#running-a-simulation] TODO ## Interpreting Results [#interpreting-results] TODO ## Status [#status] Draft # Overview (/docs/resources) This section serves as the repository for all non-markdown project artifacts—including academic paper drafts, technical presentations (PPT/Keynote), architecture slide decks, and external references. *** ## Quick Navigation [#quick-navigation] *** ## How to Manage Documents in this Project [#how-to-manage-documents-in-this-project] We recommend a hybrid management workflow depending on the file type and update frequency: ### 1. Local Files (`public/documents/`) [#1-local-files-publicdocuments] For finalized PDFs, whitepapers, and exported slide decks: * Place files in `public/documents/.pdf` * Reference them directly in MDX using `/documents/.pdf` * **Benefits:** Offline access, version-controlled with the repository, fast loading. ### 2. Live Cloud Decks (Google Slides / Pitch.com) [#2-live-cloud-decks-google-slides--pitchcom] For working presentations that your team updates regularly: * Keep the master deck in Google Slides or Pitch * Embed the view-only iframe into `content/docs/resources/slide-decks.mdx` * **Benefits:** No need to re-export or recommit files after every minor edit. *** ## Document Inventory [#document-inventory] | Title | Type | Format | Location | Status | | :------------------------------------ | :----------- | :------------------ | :------------------------------------------------- | :------------ | | **MEV-Aware DeFi Liquidation System** | Review Paper | PDF (220 KB) | `/documents/MEV_Aware_DeFi_Liquidation_System.pdf` | ✅ `Available` | | **System Architecture Walkthrough** | Presentation | Slides / PDF | `/documents/architecture-deck.pdf` | `Planned` | | **MEV Batch Auction Pitch Deck** | Slide Deck | Google Slides / PPT | Cloud Link | `In Progress` | | **Empirical Simulation Benchmarks** | Data Report | PDF | `/documents/simulation-report.pdf` | `Pending` | # Research & Review Papers (/docs/resources/papers) This page hosts official academic papers, technical whitepapers, and review preprints produced by the Reforge research team. *** ## 1. MEV-Aware DeFi Liquidation System (Review & Research Draft) [#1-mev-aware-defi-liquidation-system-review--research-draft] ### Document Information [#document-information] * **Title:** *MEV-Aware DeFi Liquidation System* * **File:** `MEV_Aware_DeFi_Liquidation_System.pdf` (220 KB) * **Status:** Review Paper Draft (2026) ### Abstract [#abstract] Decentralized lending protocols rely on liquidation mechanisms to maintain protocol solvency. However, conventional first-come, first-served liquidations trigger intense Priority Gas Auctions (PGAs) among automated searchers, transferring significant economic value to block proposers and forcing borrowers to surrender excessive collateral discounts. Reforge proposes an end-to-end MEV-aware batch auction liquidation mechanism that aggregates competing bids within discrete block windows and selects winning liquidators based on **Net Economic Value** (Gross Liquidation Value minus Gas and Slippage Costs). ### Downloads & Repositories [#downloads--repositories] *** ## In-Browser Document Preview [#in-browser-document-preview] You can read and interact with the uploaded review paper directly below: