BOB
  • πŸ‘‹BOB Stablecoin
  • BOB Info
    • πŸ—ΊοΈBOB Ecosystem
      • Mellow Protocol Vaults
    • 🦊MetaMask
      • Swap BOB with Metamask Swap
    • πŸ”BOB Swap
    • πŸ¦„Uniswap v3
    • πŸ™‹β€β™€οΈBOB FAQ
  • BOB CDP
    • ℹ️About
    • πŸ’‘Use Cases
    • πŸ‘¨β€πŸŽ€System actors
    • πŸ“šSystem configurations
    • 🏦Vault health
    • 🏘️User flow examples
    • πŸ‘¨β€πŸ’»Technical docs
      • Position valuation (technical)
      • Liquidations
      • Deployment addresses
      • Smart Contracts
        • NFTVaultRegistry
        • NFTVault
        • UniV3Oracle
        • ChainlinkOracle
        • DebtMinter
        • SurplusMinter
    • πŸ™‹β€β™‚οΈCDP FAQ
  • BOB DAO
    • πŸ§‘β€πŸ€β€πŸ§‘Governance
      • BOB DAO
      • Protocol Governance
        • GP 0: Increase SAFE membership
        • GP 1: Bob Swap beta testing infrastructure
        • GP 2: Upgrade Contracts to v1.0.0
        • GP 3: Enable Bob Swap for Public Use
        • GP 4: Increase Multisig & Upgrade BOB contract on all networks
        • GP 5: Enable Bob Swap on Ethereum Mainnet
        • GP 6: Upgrade zkBob to support direct deposits
        • GP 7: Increase Multi-chain Inventory and Update Bob Swap
        • GP 8: Extend pool limits for KYC'd users
        • GP 9: Deactivate Kyberswap inventory pairs [Emergency Measure]
        • GP 10: Reallocate previous Kyberswap inventory
        • GP 11: Add 24 hour timelock to BOB contract on Optimism
        • GP 12: Raise Polygon limits
        • GP 13: Launch BOB CDP
        • GP 14: Migrate BOB pool to USDC on Polygon
        • GP 15: KYB tiers on Optimism
        • GP 16: Remove excess inventory on Arbitrum and BNB Smart Chain
        • GP 17: Remove excess inventory on Optimism and Ethereum
        • GP 18: Remove excess inventory on Polygon
        • GP 19: Accrued Revenue Allocation
        • GP 20: Migrate BOB pool to USDC on Optimism
        • GP 21: BOB inventory reduction
    • πŸ“‹Inventory
      • Inventory Actions
  • BOB Resources
    • 🧩Visual Assets
    • ⛓️Links
Powered by GitBook
On this page
  • Liquidation conditions
  • Liquidation process
  • Liquidation economics
  • Liqudation bot
  • Liquidation example
  1. BOB CDP
  2. Technical docs

Liquidations

PreviousPosition valuation (technical)NextDeployment addresses

Last updated 1 year ago

Liquidation is a mechanism designed to protect the overall system health during a market downturn. It helps prevent the accumulation of bad debt within the protocol by forcefully closing user positions.

Liquidation conditions

Liquidation can only be triggered and executed by liquidators once the total vault debt, which includes the debt principal and accumulated stability fees, starts to exceed the collateral liquidation threshold.

In the user interface, this relationship between the total vault debt and liquidation threshold is represented as a health factor. Once it drops below 100%, the vault becomes subject to liquidation.

Liquidation process

The BOB CDP only supports full-sized position liquidation, meaning that a position can only be liquidated in full within a single transaction. Partial liquidations are not supported within the BOB CDP.

To perform a liquidation, a whitelisted liquidator should first identify the vault number that meets the liquidation conditions. The liquidation can then be triggered by calling the liquidate(uint256 vaultId) function on the main Vault contract, passing the liquidated vault ID as a single argument.

The Vault contract will check the liquidation conditions of the selected vault, repay the necessary amount of BOB tokens from the liquidator's balance (ensure the necessary BOB allowance is set up beforehand), and transfer the liquidated vault's NFT collateral to the caller.

The total repayment amount is calculated using the following formula:

R=max(D,Cβˆ—(1βˆ’Fliq))R=max(D, C * (1 - F_{liq}))R=max(D,Cβˆ—(1βˆ’Fliq​))

Where:

  • DDD - total vault debt, including debt pricipal and accumulated stability fees

  • CCC - total collateral value, C=βˆ‘ci=βˆ‘px(ax+fx)+py(ay+fy)C = \sum{c_i} = \sum{p_x(a_x + f_x) + p_y(a_y + f_y)}C=βˆ‘ci​=βˆ‘px​(ax​+fx​)+py​(ay​+fy​) from Position valuation (technical)

  • FliqF_{liq}Fliq​ - current liquidation premium -

The liquidator is then free to do anything with the obtained collateral: keep it as is, redeem it for underlying assets, sell or auction underlying assets for BOB.

It is also possible to implement liquidations atomically, turning it into a MEV opportunity. In this case, the collateral should be redeemed and sold in a single atomic transaction. This method requires more engineering resources and increases bot complexity but simplifies the liquidation profitability calculation and removes capital requirements in favor of BOB flash loans.

The canonical BOB CDP liquidation bot implements such an atomic approach - Liqudation bot

Liquidation economics

If the obtained liquidation premium exceeds all required gas costs, AMM fees and slippage, and price oracles discrepancies, then the entire process can be considered strictly profitable for the liquidator.

Liqudation bot

Liquidation example

Liquidator used the following control flow throughout this transaction for successful liquidation (used contract addresses are available at Deployment addresses):

  1. Calculate the total repayment amount - ~118.60 BOB

  2. Take out a BOB flash loan through the flash minter contract for a slightly greater amount - ~118.64 BOB

  3. Trigger the liquidation by calling the liquidate function on the main Vault contract

    1. The Vault contract burns the debt principal of ~95.68 BOB

    2. The Vault contract collects remaining stability fees and a 5% liquidation fee, totaling ~6.12 BOB

    3. The Vault contract records the repaid remainder of ~16.81 BOB as tokens owed to and claimable by the vault #14 owner

    4. The Vault contract transfers Uniswap V3 NFT collateral to the liquidator contract

  4. Redeems Uniswap V3 NFT #919697 (BOB/WMATIC 0.05%) for the underlying 200 WMATIC + 0 BOB

  5. Sell 198 WMATIC through 1inch for ~121.31 BOB

  6. Repay the BOB flash loan of ~118.64 BOB using the funds obtained during the collateral sell-off

  7. Observe the profit of ~2.7 BOB + 2 WMATIC

As the maximum position size is limited by , the maximum liquidation size is also limited to roughly the same amount.

There is no hard limit on the lower limit for the position and liquidation size, but each collateral should be valued at least , which makes smaller liquidations extremely unlikely.

During a successful liquidation process, the liquidator essentially obtains user collateral at a discount equal to the liquidation premium and then has the opportunity to sell it for a profit.

The canonical BOB CDP liquidation implementation can be seen on the zkBob . Currently, only whitelisted actors, starting with the BOB Core Team as the first liquidator, can participate in the liquidation process. The requirements for liquidator whitelisting will be lifted as the protocol becomes more mature.

If you would like to participate in the liquidation process or develop your own liquidation bot implementation, reach out to us in .

Here is an example transaction demonstrating the successful liquidation of CDP vault #14 -

πŸ‘¨β€πŸ’»
GitHub
Discord
https://polygonscan.com/tx/0x905af1d70f40cc11deb4dd66234a55e9a9b26ffd8beafb76965b5402805f5df2
Liquidation premium (3%)
Maximum debt per vault (100,000 BOB)
Minimum single NFT collateral (100 BOB)
Liquidation premium (3%)