Repository navigation
feat(SC-007): 75% LTV cap, 8% liquidation discount, HF>=1.0 rejection + interest/liquidation modules - #1712
Open
esthertitilayo-dev wants to merge 1 commit into
Conversation
…StellarDevHub#1628) - Add contracts/lending_pool/src/interest.rs (spec key file): pure next_index / accrued_principal index math with unit tests; accrue and accrue_user now delegate to it - Add contracts/lending_pool/src/liquidation.rs (spec key file): pure seize_amount discount-bonus math with unit tests; liquidate delegates to it - AC1: borrow-at-exactly-75% allowed and 75.01% rejected (#6) under a pool configured with a hard 75% LTV cap (coll factor 7_500, HF boundary 10_000) - AC2: third-party liquidation seizes exactly repay x 1.08 with the 8% bonus (liq_bonus 800), asserted on a real SAC token for observable balances - AC3: liquidation rejected (#8) at health factor exactly 1.0 and when HF > 1 - Wire previously dead contracts/lending_pool/src/test.rs (fixes its broken LOCK reference to use the temporary RG_KEY guard), enabling 18 more tests
|
@esthertitilayo-dev 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. |
|
@esthertitilayo-dev 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.
Closes #1628
Summary
contracts/lending_pool/src/interest.rs(purenext_index/accrued_principalper-second compounding math, unit-tested) andcontracts/lending_pool/src/liquidation.rs(pureseize_amountliquidator-discount math, unit-tested).lib.rsaccrue,accrue_user, andliquidatenow delegate to them with identical arithmetic and typed-error mapping.borrow_at_exactly_75pct_ltv_is_allowed/borrow_above_75pct_ltv_is_rejected(#6) under a pool configured with a hard 75% cap (collateral factor7_500BPS per theadd_assetdoc "Max LTV in BPS", HF boundarymcr = 10_000→ effective cap = exactly 75%).liquidate_seizes_collateral_with_8pct_discountruns a real SAC token (so balances are observable, unlike the no-op MockToken): liquidator repays 1_000 of underwater debt and receives exactly 1_080 collateral (1_000 × 1.08,liq_bonus = 800BPS); borrower debt 20_000 → 19_000, collateral −1_080, pool balance reconciles to the unit.liquidate_rejected_when_health_factor_exactly_onebuilds a position at the exact boundary (adj_coll == req_coll == 15_000) andliquidate_rejected_when_position_is_healthyfor HF ≫ 1 — both revert withPositionHealthy(#8).contracts/lending_pool/src/test.rs(was never declared as a module and wouldn't compile — referenced a nonexistentLOCK); fixed it to use the temporaryRG_KEYguard, enabling 18 additional tests (deposit/repay/withdraw rejections, reentrancy, interest accrual, index-preservation).Test plan
cargo test -p lending-pool— 40 lib tests + 2 fuzz tests pass (was 17 + 2 before this PR).rustfmt --checkclean onlib.rs,interest.rs,liquidation.rs,test.rs.