Skip to content

feat(lending,oracle): events, oracle sanity checks, emergency pause, liquidation optimisation#68

Open
onjehdaniel889-ctrl wants to merge 1 commit into
Kevin737866:mainfrom
onjehdaniel889-ctrl:feat/events-oracle-sanity-pause-liquidation-opt
Open

feat(lending,oracle): events, oracle sanity checks, emergency pause, liquidation optimisation#68
onjehdaniel889-ctrl wants to merge 1 commit into
Kevin737866:mainfrom
onjehdaniel889-ctrl:feat/events-oracle-sanity-pause-liquidation-opt

Conversation

@onjehdaniel889-ctrl
Copy link
Copy Markdown
Contributor

  • 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

…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
@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented Jun 1, 2026

@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! 🚀

Learn more about application limits

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant