Reforge
Architecture

Smart Contract Architecture

Core EVM protocols, Foundry contracts, batch auction mechanisms, and lending accounting

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

LendingPool.sol
LiquidationAuction.sol
LiquidationManager.sol
PriceOracle.sol
MockDEX.sol
MockERC20.sol
ILendingPool.sol
ILiquidationAuction.sol
IPriceOracle.sol
HealthFactor.sol

Core Protocol Contracts

ContractRoleCore Responsibility
LendingPool.solLiquidity HubManages user deposits, collateral locking, debt borrowing, repayments, and position balances.
LiquidationAuction.solAuction CoordinatorCentral research mechanism: coordinates discrete batch auction windows, collects bids, and executes atomic settlements.
LiquidationManager.solEligibility & MathEvaluates account eligibility, computes maximum liquidatable debt ceilings, and calculates collateral transfer quantities.
PriceOracle.solPricing FeedDual-mode pricing oracle supporting real-time Chainlink feeds as well as programmatic price shocks for simulations.
MockDEX.solAMM SimulationSimulates constant-product AMM liquidity pools with configurable slippage curves and price impact models.
HealthFactor.solMath LibraryShared mathematical library implementing standardized precision-safe Health Factor calculations.

Contract Interfaces & Function Signatures

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
    );
}

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:

Rendering diagram...

On this page