Skip to content

feat(contracts): liquidation safeguards, recovery sequencing, and gated telemetry (#1165, #1172, #1174) - #1218

Merged
Junirezz merged 2 commits into
Junirezz:mainfrom
Samuel1-ona:feat/vault-recovery-telemetry-backup-validation
Aug 25, 2026
Merged

feat(contracts): liquidation safeguards, recovery sequencing, and gated telemetry (#1165, #1172, #1174)#1218
Junirezz merged 2 commits into
Junirezz:mainfrom
Samuel1-ona:feat/vault-recovery-telemetry-backup-validation

Conversation

@Samuel1-ona

@Samuel1-ona Samuel1-ona commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Closes #1165
Closes #1172
Closes #1174
Closes #1164

…ed telemetry

Addresses Junirezz#1165, Junirezz#1172, and Junirezz#1174, and repairs the vault test targets so the
new tests can actually run.

Junirezz#1165 — liquidation_safeguards.rs
Pure, pre-mutation decision layer for strategy shortfalls: assess_shortfall
classifies a position as healthy/degraded/impaired against an operator-set
tolerance (rounding shortfall bps up so a sub-basis-point loss never reads as
zero), check_recovery_preconditions rejects recovery attempted on a live vault,
below the governance threshold, against a solvent position, or for more than
the measured shortfall, and socialize_loss applies a write-down with a floor at
zero.

Junirezz#1172 — recovery_sequence.rs
Models vault accounting as a state machine where `apply` is transactional by
construction: it validates, computes the whole next state, and only then returns
it, so a failing step provably leaves the caller's state untouched. Regression
tests interleave deposits, withdrawals, yield accrual, and fee changes with
injected failures and assert that state is unchanged after an interruption, the
invariants hold at every point, and a corrected retry lands on the same state as
a clean run.

Junirezz#1174 — telemetry.rs + `diagnostics` entry point
One consistent aggregate-only snapshot of vault state plus a derived health
classification. Off by default and enabled only by an admin-authorised
set_diagnostics_enabled. The snapshot reads vault-local storage only — it never
calls the strategy or oracle, so it stays answerable when an external dependency
is what is broken. Field policy (no addresses, no per-user balances, no
credentials) is enforced by a test, not just prose.

Pre-existing build repairs, needed because neither vault test target compiled:
- event_tests: import the `Events` testutils trait, fix a stale helper name
- formal_verification_tests: replace an unavailable `alloc` Vec with an array
- feature_tests: drop `.unwrap()` on client methods that return `()`, and use
  the RescueUnauthorized code the contract actually returns
- deposit_withdraw_props: route fee/treasury changes through the Junirezz#969 timelock
  API that replaced the removed direct setters
- lib.rs: move the `#[cfg(test)]` queue-seed helper out of `#[contractimpl]`;
  under the `testutils` feature the macro generated a client method referencing
  a module that cfg stripped, breaking every integration test target

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MymD3u1QnAaBBb5AGD71S8
@drips-wave

drips-wave Bot commented Aug 25, 2026

Copy link
Copy Markdown

@Samuel1-ona 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

@Junirezz
Junirezz merged commit f835460 into Junirezz:main Aug 25, 2026
5 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants