Matching Transaction
Last updated
Last updated
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.
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.
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.
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.