LogoLogo
  • Overview
  • Learn
    • Lend
    • Borrow
    • Interest Rate
    • Liquidate
    • Flash Loans
    • NEPT Token
    • Risks
  • Develop
    • Contracts
      • Market
      • Interest Model
      • Token
      • Oracle
      • Querier
      • Flashloan Reciever
      • nToken
    • Token Addresses
  • User Guides
    • How to Lend on Neptune
    • How to Borrow on Neptune
    • How to Stake with the Neptune Validator
    • How to bridge TIA to Injective
  • Socials and Media
  • Audits
Powered by GitBook
On this page
  • How Liquidations Work
  • Race Conditions
  • Account Health Calculation
  • Partial Liquidations
  • Dynamic Liquidation Discounts
  • Target Account Health
  • NEPT Staking Account Health Modifier
  • Liquidation Process
  • nToken Rebasing
  • Best Practices
  1. Learn

Liquidate

Liquidations are a crucial risk management mechanism in the Neptune Protocol that helps maintain the overall health and solvency of the lending markets. When a borrower's account health falls below 1.0, their collateral becomes eligible for liquidation, allowing other users to repay a portion of their debt in exchange for their collateral at a discount.

How Liquidations Work

The liquidation process in Neptune follows these key steps:

  1. Monitor Account Health: A margin account health must stay above 1.0 to avoid liquidation

  2. Liquidation Trigger: When health drops below 1.0, the account becomes eligible for liquidation

  3. Liquidation Calculation: Liquidators queries the market to verify debts to repay

  4. Liquidator Action: Any user can act as a liquidator by repaying some of the borrower's debt

  5. Collateral Transfer: The liquidator receives discounted collateral in exchange for debt repayment

Race Conditions

The Neptune liquidation market is a first-come-first-serve implementation. Meaning when a liquidation opportunity becomes available, it is the liquidator who executes the transaction first who will capture the profits.

Account Health Calculation

A liquidator can monitor the Neptune market for accounts with low Account Health values that may soon be subject to liquidation. They can query the market and calculate the various margin Account Health values.

Account health is calculated using the following formula:

Account Health=Weighted Collateral ValueTotal Debt Value\text{Account Health} = \frac{\text{Weighted Collateral Value}}{\text{Total Debt Value}}Account Health=Total Debt ValueWeighted Collateral Value​

Where:

  • Weighted Collateral Value: Sum of all USD collateral values multiplied by their respective liquidation_LTV

  • Total Debt Value: Total USD value of all borrowed assets plus accrued interest

Partial Liquidations

A margin account can be either be fully or partially liquidated. A Partial liquidation means that only part of the accounts debt is repaid and collateral seized, where as a full liquidation pays back all the debt, seizes all of the collateral and closes the margin account.

If an account is to be fully or partially liquidated is determined by the partial_liquidation_threshold parameter set in the market contract. This parameter is set as a USD value, and any account with net collateral values below this value will be fully liquidated.

Dynamic Liquidation Discounts

When a margin account is subject to liquidation, its collateral is offered at a discount from the oracle price to incentivize third parties to participate in liquidations. Discounted collateral ensures a liquidator can capture a profitable trade in a timely manner.

Neptune innovates on the standard liquidation discounts by offering a dynamic discount range. This allows the protocol to set a min_discount and max_discount on each available collateral asset. The min_discount first becomes available when a margin account has an account health just below 1. As the account health grows further below 1, the applied discount grows until it reaches the max_discount value. The rate at which the discount grows is set by the dynamic_discount_width parameter set by the protocol.

In affect the dynamic discounts allow for reduced impact on a user's margin account position during a partial liquidation, and offers more opportunity for liquidators to make profitable trades when markets are more volatile, keeping Neptune markets solvent.

Discount=min discount+(max discount−min discount)×min⁡(1,1−Account Healthdynamic discount width)\text{Discount} = \text{min discount} + (\text{max discount} - \text{min discount}) \times \min(1, \frac{1 - \text{Account Health}}{\text{dynamic discount width}})Discount=min discount+(max discount−min discount)×min(1,dynamic discount width1−Account Health​)

Where:

  • min_discount is the minimum discount applied when account health is just below 1.0

  • max_discount is the maximum possible discount that can be applied

  • Account Health is the current health ratio of the margin account

  • dynamic_discount_width is the protocol parameter that controls how quickly the discount scales (typically ~0.02)

The formula ensures the discount scales linearly from min to max as account health deteriorates, capped at the maximum discount.

Target Account Health

During a partial liquidation, the market calculates the required debt to be repaid to bring the account back to a targeted Account Health Value. This target value is set the protocol parameter target_liquidation_health. From this calculation the liquidator will be able to determine the amount of collateral that will be seized.

Target Repayment Amount=Total Debt Value×(1−Weighted Collateral ValueTotal Debt Value×Target Liquidation Health)\text{Target Repayment Amount} = \text{Total Debt Value} \times (1 - \frac{\text{Weighted Collateral Value}}{\text{Total Debt Value} \times \text{Target Liquidation Health}})Target Repayment Amount=Total Debt Value×(1−Total Debt Value×Target Liquidation HealthWeighted Collateral Value​)

Where:

  • Total Debt Value is the current total borrowed amount plus accrued interest

  • Weighted Collateral Value is the sum of all collateral values multiplied by their respective liquidation_LTV

  • Target Liquidation Health is the protocol parameter (typically > 1.0) representing the desired health ratio after liquidation

This formula calculates how much debt needs to be repaid to restore the account's health ratio to the target level.

NEPT Staking Account Health Modifier

Through the process of staking NEPT to the protocol in certain bonding pools, a user may allocate the value of their stake against one or multiple of their margin accounts. Doing this will award the margin account with a boosted Account Health value, providing the user with the benefit for greater risk management.

Liquidation Process

When an account becomes eligible for liquidation:

  1. Liquidation Request

    • System calculates repayable debt amounts

    • Identifies available collateral for liquidation

    • Determines collateral discounts

  2. Collateral Pricing

    • Collateral value is determined by oracle prices

    • Liquidators receive a discount on the collateral

    • Discount varies by asset

  3. Execution

    • Liquidator repays a portion of the borrower's debt

    • Receives discounted collateral in return

    • Transaction must complete atomically

nToken Rebasing

In an unlikely event that a liquidation would occur where a margin accounts collateral value is less than the outstanding debt, a liquidator would only repay an amount of debt which is equivalent to the collateral value. This would create a bad debt balance in the Neptune market as the margin account now has no collateral value to cover the outstanding debt.

When a bad debt situation occurs, to avoid a run on the bank scenario, the protocol rebases the redemption rate for the nToken of the market the bad debt is related to. The rebasing of the redemption rate now accurately reflects the available underlying principle of the target market, making the market solvent again.

After a rebasing event occurs, protocol governance or third parties can elect to inject more capital into the target market to bring the nToken redemption rate back to its original value.

New Redemption Rate=Total Available AssetsTotal nToken Supply=Total Lending Principal−Bad DebtTotal nToken Supply\text{New Redemption Rate} = \frac{\text{Total Available Assets}}{\text{Total nToken Supply}} = \frac{\text{Total Lending Principal} - \text{Bad Debt}}{\text{Total nToken Supply}}New Redemption Rate=Total nToken SupplyTotal Available Assets​=Total nToken SupplyTotal Lending Principal−Bad Debt​

Where:

  • Total Available Assets is the remaining assets after accounting for bad debt

  • Total Lending Principal is the original amount of assets in the lending pool

  • Bad Debt is the uncovered portion of defaulted loans

  • Total nToken Supply is the total supply of nTokens in circulation

Best Practices

For borrowers to avoid liquidation:

  1. Monitor Account Health: Regularly check account health metrics

  2. Maintain Buffer: Keep health ratio well above 1.0

  3. Risk Management: Use multiple collateral types to reduce volatility

  4. Quick Action: Add collateral or repay debt if health approaches 1.0

For liquidators:

  1. Monitor Opportunities: Watch for accounts near liquidation

  2. Gas Optimization: Prepare efficient liquidation transactions

  3. Price Impact: Consider market depth when liquidating large positions

PreviousInterest RateNextFlash Loans

Last updated 2 months ago

A liquidator may need to account for the a users stake positions when identifying at risk margin accounts. Read more about it in the doc.

NEPT Token