LEX-JUSTICIA

The only AMM that survives a crash. Crisis-proof market making on Sui DeepBook.

LEX-JUSTICIA

Created At

HackMoney 2026

Project Description

The Problem: The recent $900 billion market crash exposed a fatal flaw in DeFi: "Fair weather liquidty." When volatility spikes, traditional AMM liquidity providers flee, spreads widen by 100x (from 5 bps to 500+ bps), and traders face massive slippage exactly when they need to exit. Current protocols treat all LPs equally, creating a "race to the exit" that leaves markets barren during crises.

The Solution: LEX-JUSTICIA is crisis-proof market-making infrastructure built on Sui’s DeepBook. We replace the "mercenary liquidity" model with a Myersonian Tier System derived from Nobel Prize-winning mechanism design (Milionis et al., 2023). Instead of vague promises, Market Makers (MMs) stake DEEP tokens to lock into specific commitment levels enforced by smart contracts.

How It Works: Our protocol classifies liquidity into three mathematically optimized tiers:

  1. Martyrs: Stake 10,000 DEEP to guarantee tight spreads (<40bps) and high uptime during crises. In exchange, they receive priority routing and 0% fees.
  2. Citizens: Moderate commitments with partial fee discounts.
  3. Sovereigns: No stake, but lowest priority during congestion.

Using Virtual Value Functions, the protocol calculates an "Incentive-Compatible" reward curve. This makes honest reporting and steadfast liquidity the most profitable strategy, mathematically disincentivizing the "rug pull" behavior seen in traditional AMMs.

Sui & DeepBook Integration: We leverage Sui's Programmable Transaction Blocks (PTBs) to enable atomic "mint-and-stake" operations in a single signature—safety guarantees impossible on EVM chains. We use Move Shared Objects to allow concurrent scoring updates for thousands of MMs without improved verification latency.

The Impact: While traditional AMMs lose 85% of liquidity during a crash, LEX-JUSTICIA retains 70% of liquidity and keeps spreads 12.5x tighter. It is the first infrastructure that turns liquidity provision from a mercenary game into a credible, enforceable commitment.

How it's Made

Architecture & Tech Stack: We built LEX-JUSTICIA entirely on the Sui Network using Move smart contracts, leveraging DeepBook as our underlying liquidity engine. The frontend is Next.js 16 powered by the @mysten/dapp-kit and the latest Sui TypeScript SDK (v2.2.0).

DeepBook & Move Implementation: We implemented the groundbreaking research from Milionis, Moallemi, & Roughgarden (2023): "A Myersonian Framework for Optimal Liquidity Provision in AMMs" directly on-chain. We wrote four custom Move packages (~1,600 lines):

  1. myersonian.move: The brain. We implemented complex virtual value functions (from Myerson’s auction theory) using fixed-point arithmetic directly on-chain to calculate "Information Rent" and optimal rewards.
  2. moral_pool.move: The enforcer. It manages the staking of DEEP tokens and enforces slashes.
  3. crisis_oracle.move: A multi-trigger system that monitors on-chain volatility, liquidity depth, and spread widening to declare a "Crisis State."

Deployed Contracts:

  1. https://suiscan.xyz/testnet/object/0x99aff556148b6da9c15620554ad6290d5e2ba398aa43a51778e075b91580fec6/contracts
  2. https://suiscan.xyz/testnet/object/0x49f0854fe48729a80b7fb5b190216babb61e18bedf8fbc58f1f6acae5fdb7bd5/tx-blocks
  3. https://suiscan.xyz/testnet/object/0x73231afad4133b18746eee1fc0707d3c12579466afa4382ba1893dd3d371f7dc/tx-blocks
  4. https://suiscan.xyz/testnet/object/0x8644c47a75979c8886d8f8b9dc2a3cb200afb1e34281bc369bf2714734fbc885/tx-blocks

Sui Superpowers (Why we chose Sui):

Programmable Transaction Blocks (PTBs): This was a game-changer. We used PTBs to create "atomic commitment" flows. A Market Maker can mint DEEP tokens, approve the contract, and stake them into a Martyr tier all in a single transaction. On EVM, this is a distinct 3-step UX nightmare; on Sui, it is one atomic action.

Shared Objects for Concurrency: We designed the MyersianScoringEngine as a clear Shared Object. This is critical because, during a market crash, thousands of MMs need to update their spreads simultaneously. On a single-threaded chain, this creates a gas war that halts the chain (exactly when you need it most). On Sui, these updates execute in parallel.

Notable Hack / Challenge: Implementing the "Incentive Compatible" reward curve (Corollary 2.2 of the paper) required calculating integrals of the virtual value function. Doing robust calculus in Move's integer-only environment was tricky! We built a custom approximation engine in the myersonian module that creates a discrete step-function version of the curve, ensuring the math holds up without blowing up the gas budget.

Dashboard & Simulation: To demonstrate the "Counterfactual" (what would have happened), we built a deterministic 60-tick market simulator in the frontend that runs the exact same Move logic in TypeScript. This allows judges to see a side-by-side charted comparison of a standard UniV3-style pool vs. our LEX-JUSTICIA pool during a 40% price crash.

background image mobile

Join the mailing list

Get the latest news and updates