Repository navigation
feat(contracts): implement dynamic liquidation bonding curve and bad debt socialization [SC-062] - #1992
Open
Anekenonso wants to merge 1 commit into
Conversation
…debt socialization - Implement dynamic liquidation bonus curve in liquidation.rs scaling from 5% to 15% as health factor drops below 1.0 - Add protocol reserve fund management and bad debt socialization across reserves - Automatically socialize deficit when liquidating underwater positions with zero collateral - Add property-based fuzz tests verifying total protocol assets >= total liabilities Closes StellarDevHub#1859
|
@Anekenonso is attempting to deploy a commit to the Ayomide Adeniran's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
@Anekenonso Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
This branch has not been deployed
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.
Description
This PR implements [SC-062] Lending Pool Liquidation Incentive Bonding Curve & Bad Debt Socialization to eliminate delays in liquidating undercollateralized accounts during steep price declines and to safely socialize remaining deficits across protocol reserve funds when borrower collateral is depleted.
Key Changes
Dynamic Liquidation Bonus Bonding Curve (
contracts/lending_pool/src/liquidation.rs):dynamic_liquidation_bonus(hf_bps)anddynamic_seize_amount(repay, debt_price, coll_price, hf_bps).Protocol Reserves & Bad Debt Socialization (
contracts/lending_pool/src/lib.rs):Key::Reserves(token)and cumulative socialized debt underKey::TotalBadDebt(token).deposit_reserves,reserves_of, andtotal_bad_debtentry points.health_factorandcurrent_liquidation_bonusviews.liquidate(...): if a borrower position has zero collateral remaining after seizing (new_coll == 0) and outstanding debt remains (new_debt > 0), the deficit is absorbed by the protocol's reserve funds without touching user deposits.socialize_bad_debt(...)allowing bad debt write-off against reserves for positions that have already reached 0 collateral.Property-Based Fuzz Testing (
contracts/lending_pool/src/fuzz_lending_suite.rs&tests/fuzz_lending.rs):proptest!invariants verifying total protocol assets (collateral + available reserves) strictly exceed total debt liabilities across randomized parameter spaces.Verification
cargo fmt --check: Passed with 0 errors.cargo test --lib: 52 tests passed, 0 failed.Closes #1859