Centuari Labs
  • Welcome to the Official Documentation of Centuari V1
  • Getting Started
    • Quickstart
    • Problems
  • Solutions
  • Primitive Lending
    • Flash Loan
    • Oracle
    • Liquidation
  • Currator
  • Basics
    • CLOB(deCentralized Lending Order Book)
    • Matching Transaction
    • Bond Token
    • Vault
  • Uncollateralized
    • Restaking
    • Underwriting
    • Assets Standardization
    • Slashing Mechanism
  • Resources
    • Contracts
    • Community
    • Further Update
  • Conclusion
    • Conclusion
Powered by GitBook
On this page
  • 📖 Liquidation Mechanism in Centuari Protocol
  • 📌 Liquidation Execution Flow
  • 📊 Example Liquidation Scenario
  • ✨ Key Advantages of This Design
  • 📌 Summary
  1. Primitive Lending

Liquidation

PreviousOracleNextCurrator

Last updated 26 days ago

📖 Liquidation Mechanism in Centuari Protocol

In the Centuari protocol, the liquidation mechanism serves as a risk management tool to maintain the health of the lending system. It allows third-party liquidators to close borrower positions under specific conditions:

  • The loan has passed its maturity date, or

  • The borrower's position has fallen below the required health factor.

Liquidators repay the borrower’s outstanding debt and, in return, receive the borrower’s collateral as compensation.


📌 Liquidation Execution Flow

The liquidate() function handles the liquidation process through the following steps:


📌 1️⃣ Validation of Borrower and Conditions

Before proceeding, the function validates:

  • That the borrower’s address is not zero.

  • That the borrower’s position is eligible for liquidation:

    • The maturity date has passed (if a maturity is set), or

    • The borrower's health factor is below the allowed threshold.

Example:

if (user == address(0)) revert CentuariErrorsLib.InvalidUser();
if ((block.timestamp < config.maturity && config.maturity != 0) 
    || _isHealthy(config.id(), rate, user)) {
    revert CentuariErrorsLib.LiquidationNotAllowed();
}

📌 2️⃣ Fetch Borrower Position Data

The protocol retrieves the borrower’s current position data from the corresponding DataStore contract based on the market configuration:

Example:

IDataStore dataStore = IDataStore(dataStores[config.id()]);

uint256 totalBorrowShares = CentuariDSLib.getTotalBorrowShares(dataStore, rate);
uint256 totalBorrowAssets = CentuariDSLib.getTotalBorrowAssets(dataStore, rate);
uint256 userBorrowShares = CentuariDSLib.getUserBorrowShares(dataStore, rate, user);
uint256 userCollateral = CentuariDSLib.getUserCollateral(dataStore, rate, user);

📌 3️⃣ Calculate Borrower’s Outstanding Debt

Since Centuari employs share-based accounting (similar to ERC-4626 vault mechanisms), the borrower’s debt is computed proportionally based on their borrow shares relative to the total borrow shares.

Example:

uint256 debt = (userBorrowShares * totalBorrowAssets) / totalBorrowShares;

📌 4️⃣ Update the DataStore Records

Once the borrower’s debt is determined:

  • The system subtracts the borrower’s shares and corresponding assets from the total pool.

  • The borrower’s loan shares and collateral positions are reset to zero.


📌 5️⃣ Asset Transfers

The liquidation involves two on-chain asset transfers:

  • The liquidator transfers loan tokens (e.g., USDC) equivalent to the borrower’s debt to the protocol.

  • The liquidator receives the borrower’s collateral (e.g., WBTC) in return.

Example:

IERC20(dataStore.getAddress(CentuariDSLib.LOAN_TOKEN_ADDRESS))
    .safeTransferFrom(msg.sender, address(this), debt);

IERC20(dataStore.getAddress(CentuariDSLib.COLLATERAL_TOKEN_ADDRESS))
    .safeTransfer(msg.sender, userCollateral);

📌 6️⃣ Emit Liquidation Event

The contract emits an event to log the liquidation for transparency, analytics, and indexing by off-chain services (e.g. The Graph, Etherscan).

Example:

CentuariEventsLib.Liquidate(
    config.id(),
    msg.sender,
    rate,
    user,
    userBorrowShares,
    userCollateral
);

📊 Example Liquidation Scenario

Assumptions:

  • Borrower A has taken a loan of 500 USDC, using 1 WBTC as collateral.

  • Borrower A holds 5 borrow shares out of 50 total shares in the pool.

  • Total outstanding debt in the pool is 5000 USDC.

Debt Calculation:

debt = (5 / 50) * 5000 = 500 USDC

Liquidation Process:

  • The liquidator transfers 500 USDC to the contract.

  • The liquidator receives 1 WBTC as collateral.


✨ Key Advantages of This Design

✅ Open Liquidation System: Anyone can act as a liquidator and claim collateral from unhealthy positions. ✅ Share-Based Accounting: Scalable and dynamic, ensuring fair debt and collateral calculations. ✅ Event Logging: Transparent on-chain event emission enables robust tracking and off-chain integrations. ✅ Market-Specific Configurations: Liquidation eligibility and parameters are determined per-market basis.


📌 Summary

The Centuari protocol’s liquidation mechanism is designed to:

  • Secure the protocol against bad debt

  • Maintain lending pool health

  • Reward third-party liquidators

  • Protect the interests of other lenders in the pool

It operates through a secure, event-driven, share-based system that balances flexibility and protocol integrity.

Contract related: ,

liquidation
interface
Liquidation flow