Conversation
…ts'; add 'Obligation' to 'ClaimCoverBadDebtResults' event
There was a problem hiding this comment.
Pull request overview
This PR updates the market contract’s liquidation eligibility logic to reserve N * min_collateral_value_cents (where N is the number of collateral positions with non-zero close_ltv_bps) when checking whether an obligation is liquidatable, aligning liquidation eligibility with the existing borrowing-capacity reservation logic.
Changes:
- Update
Obligation::liquidatehealth check to subtractN * compute_min_collateral_threshold_scaled()from close-LTV-scaled collateral value before comparing against debt. - Extend
compute_collateral_value_scaled_w_close_ltvsto also return the count of collateral positions with non-zeroclose_ltv_bps. - Emit
ClaimCoverBadDebtResultswithOption<Obligation>and add liquidation tests for sub-min-collateral and position-count scaling behavior.
Reviewed changes
Copilot reviewed 4 out of 17 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
contracts/market/src/obligation.rs |
Adjusts liquidation eligibility by reserving min-collateral value per close-LTV-eligible collateral position. |
contracts/market/src/events.rs |
Extends ClaimCoverBadDebtResults event payload to include Option<Obligation>. |
contracts/market/src/processors.rs |
Publishes updated ClaimCoverBadDebtResults event with None/Some(obligation) depending on whether the obligation was removed. |
tests/src/liquidate.rs |
Adds helper to set min_collateral_value_cents and introduces tests validating earlier liquidation for sub-min collateral and scaling with position count. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
khomiakmaxim
force-pushed
the
fix/make_liquidation_criterion_account_for_min_collateral_value_cents
branch
from
July 29, 2026 06:14
275d1df to
dfb34db
Compare
tiamo
deleted the
fix/make_liquidation_criterion_account_for_min_collateral_value_cents
branch
September 2, 2026 01:14
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Account for
min_collateral_value_centsin liquidation eligibilitySummary
The liquidation eligibility check (
Obligation::liquidate) previously compared debt against the raw close-LTV collateral value, ignoringmin_collateral_value_cents. This left a gap: a position whose collateral had drifted below the configured minimum could remain non-liquidatable while still being economically too small for a liquidator to bother with.The borrowing-capacity path already reserves
N * min_collateral_value_cents(whereNis the number of deposit positions), so the two sides were previously inconsistent.Changes
obligation.rs: The eligibility check now deductsN * min_collateral_thresholdfrom the close-LTV collateral value before comparing against debt, matching the borrowing-capacity formula.compute_collateral_value_scaled_w_close_ltvsnow also returns the count of positions with non-zeroclose_ltv_bps.market_manager/contract.rs: The market's admin signature is now required forqueue_in_market_upgrade, next to the manager's admin signature.cancel_market_upgradestill needs only the manager's admin, so a queued upgrade stays easier to withdraw than to raise.events.rs/processors.rs:ClaimCoverBadDebtResultsnow carries the resultingOption<Obligation>(Noneif the obligation was removed,Someotherwise).tests/src/liquidate.rs: Added tests covering the following scenarios:N=1healthy vsN=2liquidatable at equal total collateral/debt).Behavioral Impact
min_collateral_value_centsbecome liquidatable earlier (before closeLTV/liability factors insolvency).