Description
The contract supports slashing (slash/slash_bond) and per-identity withdrawal, but there is no explicit liquidation path that finalizes a bond whose slashed_amount == bonded_amount or whose lock-up has long expired without renewal. The bond is described as the source of truth for liquidation, yet active is only ever set false inside withdraw_bond. We need a dedicated liquidate entrypoint that marks such bonds closed, sweeps residual slashed funds to the treasury, and emits a liquidation event the keeper/indexer can act on.
Requirements and context
- Secure:
liquidate(identity) callable by admin/keeper; only valid when fully slashed or expired-and-unrenewed; transfer residual to treasury (after token integration); set active = false.
- Idempotent: re-liquidating an already-liquidated bond reverts cleanly.
- Tested: liquidate fully-slashed bond, expired bond, reject healthy bond, idempotency.
- Documented: add
docs/liquidation.md referencing the existing paginated liquidation scanner work.
Suggested execution
git checkout -b feature/bond-liquidation-entrypoint
- Add
liquidate to ours.rs with eligibility checks and event.
- Write eligibility and idempotency tests.
- Add docs
docs/liquidation.md.
- Add
/// doc comments on eligibility rules.
- Validate only eligible bonds can be liquidated.
Test and commit
- Run
cargo test.
- Cover edge cases: partially slashed (reject), expired rolling vs fixed, double-liquidate.
- Include test output and security notes.
Example commit message
feat: add bond liquidation entrypoint for fully-slashed/expired bonds
Guidelines
- Minimum 95% test coverage
- Clear documentation
- Timeframe: 96 hours
Description
The contract supports slashing (
slash/slash_bond) and per-identity withdrawal, but there is no explicit liquidation path that finalizes a bond whoseslashed_amount == bonded_amountor whose lock-up has long expired without renewal. The bond is described as the source of truth for liquidation, yetactiveis only ever set false insidewithdraw_bond. We need a dedicatedliquidateentrypoint that marks such bonds closed, sweeps residual slashed funds to the treasury, and emits a liquidation event the keeper/indexer can act on.Requirements and context
liquidate(identity)callable by admin/keeper; only valid when fully slashed or expired-and-unrenewed; transfer residual to treasury (after token integration); setactive = false.docs/liquidation.mdreferencing the existing paginated liquidation scanner work.Suggested execution
git checkout -b feature/bond-liquidation-entrypointliquidatetoours.rswith eligibility checks and event.docs/liquidation.md.///doc comments on eligibility rules.Test and commit
cargo test.Example commit message
feat: add bond liquidation entrypoint for fully-slashed/expired bondsGuidelines