Repository navigation
fix(core): emit pool adjust event, align fuzz invariants, regenerate architecture docs, and preserve zero health factor (#2244, #2251, #2252, #2307) - #2336
Merged
K1NGD4VID merged 2 commits intoNov 23, 2026
Conversation
LabsCrypt#2307 - LabsCrypt#2244: [quality] Emit OutstandingAdjusted event from adjust_outstanding in lending pool - LabsCrypt#2251: [quality] Rewrite fuzz_invariants.md against v2 share-based accounting and sync fuzz docs - LabsCrypt#2252: [quality] Regenerate ARCHITECTURE.md contract data model, communication flow, and access control; add CI doc sync check - LabsCrypt#2307: [quality] Fix || in normalizeLiquidatableLoan swallowing zero health factors
Malware detection scan flagged this pull requestThe scan found 4 indicator(s) in the PR diff. This PR is blocked until a maintainer reviews the flagged files.
This is an automated triage signal; maintainers must verify whether the finding is malicious or intentional. |
| } | ||
|
|
||
| return !hasError; | ||
| } |
2 tasks
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.
Summary
This pull request addresses and resolves four interrelated issues across the smart contract lending pool, fuzz testing invariant documentation, architecture reference documentation & CI contract synchronization, and frontend liquidation normalization:
adjust_outstandingso indexers can trackTotalOutstanding#2244:[quality] Emit an event from adjust_outstanding so indexers can track TotalOutstandingfuzz_invariants.mdagainst the v2 share-based accounting #2251:[quality] Rewrite fuzz_invariants.md against the v2 share-based accounting[quality] Regenerate ARCHITECTURE.md contract data model and access-control sections from code||innormalizeLiquidatableLoanswallowing zero health factors #2307:[quality] Fix || in normalizeLiquidatableLoan swallowing zero health factorsCloses #2244
Closes #2251
Closes #2252
Closes #2307
Detailed Root Causes & Changes
1. Case #2244 — Lending Pool
adjust_outstandingEvent EmissionLendingPool::adjust_outstandingmutatedTotalOutstanding(the primary input to pool utilization calculation) without emitting any event, causing off-chain indexers and risk monitors to silently desynchronize during loan repayments, liquidations, and defaults.events::outstanding_adjusted(env, token, delta, new_total)emitting(OutstandingAdjusted, token)topics with(delta, new_total)data payload; added schema and event emission unit tests incontracts/lending_pool/src/events.rsandcontracts/lending_pool/src/test.rs.2. Case #2251 — Fuzz Invariant Set Alignment with v2 Accounting
contracts/fuzz_invariants.mddescribed obsolete v1 invariant assumptions (such as strict balance equality against raw token balance), incorrect score ranges (0 to max), claimed methods panic on invalid inputs rather than returning typed errors, and omitted multisig governance invariants.contracts/fuzz_invariants.mdagainst the v2 share-based accounting model:TotalManagedAssetsconsistency (TotalOutstanding <= TotalManagedAssets, donation attack resilience).[300, 850]credit score band andMAX_PENALTY_MULTIPLIERlimits.PoolError,LoanError,ContractError) rather than unhandled panics.contracts/FUZZING_README.mdand report generation incontracts/fuzz_campaign.sh.3. Case #2252 — Architecture Document Regeneration & CI Contract Doc Sync Guard
ARCHITECTURE.mdreferenced deprecated structs (RemittanceNFT { id, ... }), non-existent entrypoints (mint_nft,allocate_funds,return_funds,lock_nft), and inaccurate access control rules.RemittanceMetadata, 7-stateLoanStatus,PoolStats,PendingTransfer,PendingUpgrade).#[contractimpl]entrypoints.scripts/check-contract-doc-sync.mjsand unit tests inscripts/check-contract-doc-sync.test.mjs.contract-doc-sync-checkjob to.github/workflows/ci.ymland script targets toscripts/package.json.4. Case #2307 — Preservation of Zero Health Factor in Frontend Normalization
normalizeLiquidatableLoaninfrontend/src/app/hooks/useApi.tsused logical OR (||) fallback (healthFactor || collateralRatio), causinghealthFactor: 0(the most liquidation-critical state) to be replaced by the collateral ratio.??, ensuring numeric0is preserved. Added unit test suite infrontend/src/app/hooks/useApi.normalizeLiquidatableLoan.test.ts.Verification
cargo test -p lending_pool).node scripts/check-contract-doc-sync.mjs && node --test scripts/check-contract-doc-sync.test.mjs).npm test -- useApi.normalizeLiquidatableLoan.test.ts).