Centuari Labs
  • Welcome to the Official Documentation of Centuari V1
  • Getting Started
    • Quickstart
    • Use Cases
    • Road Map
  • Primitive Lending
    • Flash Loan
    • Oracle
    • Liquidation
  • Using Centuari
    • CLOB Lending Protocol
      • Matching Transaction
    • Unified Pool
    • Centuari Bond Token
    • Curator
  • Uncollateralized
  • Resources
    • Contracts
    • Community
  • Conclusion
    • Conclusion
    • Security
Powered by GitBook
On this page
  1. Using Centuari
  2. CLOB Lending Protocol

Matching Transaction

PreviousCLOB Lending ProtocolNextUnified Pool

Last updated 20 days ago

CtrlK
  • 📖 Centuari Protocol
  • 📌 Overview
  • 📌 Core Concepts
  • ⚙️ Order Matching Engine in Centuari CLOB

📖 Centuari Protocol


📌 Overview

Centuari’s Central Limit Order Book (CLOB) module is designed to facilitate a decentralized, permissionless, and configurable matching engine between lenders and borrowers within isolated lending markets. Each market is uniquely identified by a MarketConfig struct and associated with a dedicated DataStore contract, ensuring market data segregation and flexibility.


📌 Core Concepts

Concept
Description

Order

A user-submitted request to lend or borrow a specific amount at a defined interest rate.

Side

Indicates whether the order is a LEND or BORROW.

Matchmaking

Process of pairing orders with complementary sides and compatible rates/amounts.

MarketConfig

Defines the loan asset, collateral asset, maturity date, and market-specific parameters.


⚙️ Order Matching Engine in Centuari CLOB

Centuari’s CLOB is powered by an on-chain matching engine implemented in CentuariCLOBOrderProcessorLib.sol, which handles dynamic interaction between lender and borrower orders based on the offered interest rate.

The core function, findMatchOrder, is responsible for:

  • Iterating over opposite-side orders at a given rate.

  • Matching orders from different traders.

  • Executing borrowing or lending via the Centuari core protocol.

  • Updating the order book and removing fully filled or invalid orders.

This ensures deterministic matching behavior and enables on-chain fixed-rate lending without relying on centralized intermediaries.

✅ Key Features

  • Rate-based Matching Logic: Matching occurs across interest rates, not token prices. Borrowers get the lowest available rate; lenders receive the highest available rate at the time of execution.

  • Dual-Sided Order Matching: Both lender and borrower orders are stored and iterated as linked lists in a dual-side rate tree (LEND and BORROW).

  • Group-Based Matching: Orders are grouped in OrderGroups to allow partial matching, with each match updating the group’s remaining amount and status (PARTIALLY_FILLED, FILLED).

  • Time-Defined Maturities: Matching results in a loan with a deterministic maturity date, calculated as the current block timestamp plus the market-defined duration (in days).

  • Gas-Efficient Queue Management: Orders are added or removed from the queue and tree structure efficiently, with unused rates automatically pruned from the CLOB tree.