Skip to content

LiqOS: Auction-based Liquidity Market and Dynamic JIT auto-rebalancer is a Uniswap V4 Hook that enables LPs to earn more on swap fees by bidding for a chance to pre-commit liquidity for a large swap and creates a liquidity market for swappers built for the Uniswap V4 Hookathon.

Notifications You must be signed in to change notification settings

PaulElisha/Liq0S-Custom-UniV4-Router-For-Auction-based-Liquidity-Market-JIT

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LiqOS: Dynamic Auction-Based JIT Rebalancer Hook

License: MIT
Version: v1.0
Tests: ✅ Passing

Overview

“LiqOS: The liquidity layer of DeFi that rebuilds itself around every trade.”

LiqOS reimagines liquidity provision as an adaptive, self-healing system. By turning LP bid positions into real-time bidding instruments through its JIT auction system, it creates the first end-to-end operating system for on-chain market making—where every trade dynamically optimizes its own execution environment.

LPs compete in real-time auctions market to provide liquidity for large swaps—turning passive positions into active bidding strategies.


Motivation

  1. Institutional avoidance is a result of a lack of institutional grade liquidity not very available on-chain with tighter spreads and many rely on CEXES for large swaps.

  2. Capital inefficiency as idle liquidity sits in unprofitable ranges requiring active repositioning earning minimal fees and suffering from impermanent loss.

  3. Worse pricing is a result of excessive slippage on large swaps affecting traders.

  4. Actively reallocation of liquidity because they are not self-optimizing.

  5. Suboptimal Fee Capture: LPs earn just 12% average ROI despite taking on impermanent loss risk, while CEX market makers achieve 30-50% returns on similar capital.


Solution

  1. Uniswap V3 and V4 boosts of capital efficiency for LPs but capital is not fully efficient if they are not where they are most needed. This Hook dynamically adjust liquidity around large swaps.

  2. Prevents MEV front-running by ensuring atomic or same block transactions.

  3. Market makers are not fully automated without a dynamic liquidity management or rebalancer. It enables market making on demand by placing liquidity in areas of high surge without manual control from LPs.

  4. Adjusting liquidity positions for all kinds of simple and complex swaps while enabling passive yield for LPs.

  5. It does not require a separate liquidity manager contract. It fosters the utility of stale liquidity that could cause impermanent loss.


Uniqueness

  1. Liquidity Market - It acts as a market place for liquidity.
  • On-demand auction: Imagine Uber but for DeFi Liquidity.
  • Slash slippage for whale trades like CEX: Large trades on Uniswap today suffer more slippage than coinbase. Our Hook is dynamically concentrates liquidity around large swaps thereby cutting slippage.
  • We fix Uniswap V3’s biggest flaw: Uniswap V3 requires LP to manually and actively chase price movements. Our hook auto-rebalances liquidity mid-trade making V3 positions self-optimizing. Imagine Liquidity on auto-pilot.
  • We turn MEV into LP yield: Instead of frontrunning extracting valu, our auction lets LP profit from large swaps redirecting MEV to users who deserve it.
  • We are showcasing Hooks can redefine how markets work.
  1. Liquidity OS - A decentralized operating system for dynamic, self-optimizing liquidity markets where capital flows in real-time to where it’s most needed.
  • Zero latency JIT liquidity rebalancing.
  • Dynamic tick-spacing. It densifies liquidity around volatile zones.
  • We are not just building a hook, we are beta testing Uniswap’s future. V5 won’t need LPs for large swaps, it will be a liquidity bidding war.
  • Anti-fragile liquidity: Our hook auto-concentrates liquidity near price where markets panic.
  • Proxy for institutional adoption. Not your regular DeFi for deigns but an infrastructure.
  1. Liquidity market-on-demand.
  • CEX like spreads for large swaps on-chain: Our hook dynamically tightens spreads around large swaps, giving traders institutional-grade pricing without relying on order books.
  • Earn more doing less: Imagine Uber surge pricing for liquidity providers. They compete for high-fees opportunities.
  • Sticky liquidity, less fragmentation: Tighter spreads attracts more volume —> more fees —> more LPs —> deeper liquidity.

Impact

A. For LPs: Capital works smarter, not harder (deploy only when profitable).

B. For Traders: No more frontrun-filled, high-slippage swaps.

C. For DeFi: The missing infrastructure for truly efficient markets


Features

• Real-time liquidity rebalancing during large simple/complex swaps • Auction-driven JIT provisioning


How It Works

1. LP Bidding Phase

  • LPs call addLiquidity() to bid liquidity into a pool.
  • Bids are stored in an auction-style queue (bids[poolId]).

2. Large Swap Detection

  • The hook checks if a swap exceeds a liquidity threshold (e.g., >1% of pool reserves).
  • If triggered, it selects the best LP bid for the swap.

3. Atomic Execution

  • Pre-Swap: Removes the winning LP’s liquidity to reduce slippage.
  • Swap: Executes the trade at optimal tick range using (_getUsableTicks) and Uniswap v4’s core logic.
  • Post-Swap: Returns swap's BalanceDelta liquidity around the new price .

4. Settlement

  • Winning LPs earn swap fees.
  • Traders benefit from near-optimal pricing.

Why It’s Better

🔄 Solves Fragmentation

  • Unlike older JIT models, this hook does not require separate liquidity manager contracts, avoiding pool fragmentation.

📉 Handles Complex Swaps

  • Simulates multi-hop swaps via TrySwap for accurate price adjustments.

🔐 No Risky Approvals

  • Avoids infinite token approvals—uses Permit2-style security where applicable.

MEV-Resistant

  • All steps (bid selection, swap, rebalance) happen atomically in one TX.

Test Cases

Ran 3 tests for test/JITRebalancerHookTest.t.sol:JITRebalancerHookTest
[PASS] testAddLiquidity() (gas: 578392)
[PASS] testBeforeSwap() (gas: 1211477)
[PASS] testSwap() (gas: 1211090)
Suite result: ok. 3 passed; 0 failed; 0 skipped

Technical Stack

  • Uniswap v4 Hooks: Custom logic via beforeSwap/afterSwap.
  • Foundry: For testing and deployment (see Foundry Book).
  • Permit2: Secure token approvals (future integration).

Future Roadmap

  • NFT Position Delegation: Represent LP positions as NFTs for auto-rebalancing.
  • Deployment on Unichain: Deploy the Uniswap V4 Hook on Unichain.
  • Institutional Tools: Optimize for hedge funds and DAOs.

Quick Start

Build

forge build

Test

forge test

Deploy

forge script script/Deploy.s.sol --rpc-url <RPC_URL> --private-key <PK>

Join the Discussion


One-Liner:
"A dynamic liquidity layer where LPs compete in real-time auctions, swaps execute with CEX-like efficiency, and MEV becomes obsolete." 🚀

About

LiqOS: Auction-based Liquidity Market and Dynamic JIT auto-rebalancer is a Uniswap V4 Hook that enables LPs to earn more on swap fees by bidding for a chance to pre-commit liquidity for a large swap and creates a liquidity market for swappers built for the Uniswap V4 Hookathon.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published