feat(lending,oracle): events, oracle sanity checks, emergency pause, liquidation optimisation#68
Open
onjehdaniel889-ctrl wants to merge 1 commit into
Conversation
…liquidation optimisation - Add structured log event emission for all protocol actions (deposit, withdraw, borrow, repay, liquidate, flash_loan, accrue_interest, collect_protocol_fees, register_asset, set_collateral_enabled) using the log crate. Rejected operations emit warn-level events with the reason. - Add oracle price sanity checks: positive-price guard, per-asset absolute bounds (set_price_bounds), 50% deviation circuit-breaker, and staleness check (get_price_checked). Three new ProtocolError variants: OraclePriceStale, OraclePriceDeviationTooHigh, OraclePriceOutOfBounds. - Add emergency pause functionality. New pause()/unpause() admin-only methods block all user-facing operations (deposit, withdraw, borrow, repay, liquidate, flash_loan, set_collateral_enabled) while leaving admin operations available. is_paused() getter and ProtocolPaused error variant added. ProtocolSnapshot now includes paused field. - Optimise liquidation: replace full position() snapshot with lean health_check() (no map allocations), inline debt-burning to eliminate double accrue_interest call, merge collateral reserve mutations into a single pass, cap seize amount to available collateral before any state mutation, and add health_factor_after to LiquidationResult. Closes Kevin737866#39 Closes Kevin737866#40 Closes Kevin737866#41 Closes Kevin737866#43
|
@onjehdaniel889-ctrl 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 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.
Add structured log event emission for all protocol actions (deposit,
withdraw, borrow, repay, liquidate, flash_loan, accrue_interest,
collect_protocol_fees, register_asset, set_collateral_enabled) using
the log crate. Rejected operations emit warn-level events with the reason.
Add oracle price sanity checks: positive-price guard, per-asset absolute
bounds (set_price_bounds), 50% deviation circuit-breaker, and staleness
check (get_price_checked). Three new ProtocolError variants:
OraclePriceStale, OraclePriceDeviationTooHigh, OraclePriceOutOfBounds.
Add emergency pause functionality. New pause()/unpause() admin-only
methods block all user-facing operations while leaving admin operations
available. is_paused() getter and ProtocolPaused error variant added.
ProtocolSnapshot now includes paused field.
Optimise liquidation: replace full position() snapshot with lean
health_check() (no map allocations), inline debt-burning to eliminate
double accrue_interest call, merge collateral reserve mutations into a
single pass, cap seize amount to available collateral before any state
mutation, and add health_factor_after to LiquidationResult.
Closes #39
Closes #40
Closes #41
Closes #42