Skip to content

feat: permissionless liquidation trigger for defaulted invoices - #1045

Open
Dannyswiss1 wants to merge 1 commit into
astera-hq:mainfrom
Dannyswiss1:feat/1037-permissionless-liquidation-trigger
Open

feat: permissionless liquidation trigger for defaulted invoices#1045
Dannyswiss1 wants to merge 1 commit into
astera-hq:mainfrom
Dannyswiss1:feat/1037-permissionless-liquidation-trigger

Conversation

@Dannyswiss1

Copy link
Copy Markdown
Contributor

Title: feat: permissionless liquidation trigger for defaulted invoices

Suggested branch: feat/1037-permissionless-liquidation-trigger

Body:

Summary

First slice of the end-to-end liquidation pipeline proposed in #1037: a permissionless keeper entrypoint for the collateral-seizure step of the state machine.

  • Add PoolContract::liquidate_invoice(caller, invoice_id) — any address can trigger it once an invoice is objectively Defaulted on the invoice contract. Unlike the existing seize_collateral, there's no admin/governance-proposal gate on the trigger itself.
  • Refactor the seizure logic into a shared seize_collateral_core helper so both the governance path (execute_seize_collateral) and the new permissionless path share one idempotency guard (CollateralDeposit.settled) and one non_reentrant! lock — a defaulted invoice cannot be double-liquidated through either path.
  • Emit distinct liq_started / liq_seized events (separate from the existing col_seiz_default) so the indexer can later distinguish keeper-triggered liquidations for pipeline-stage tracking.
  • packages/sdk: add PoolClient.liquidateInvoice() (the keeper-trigger call) and PoolClient.getCollateralDeposit() (a liquidation-status query), plus the CollateralDeposit type.

This covers only the "mark defaulted → seize collateral" step. Still open, per #1037's full acceptance criteria:

  • Insurance draw-down wiring (insurance.file_claim as a keeper-chained follow-up call — pool can't call it atomically due to Soroban's pool→insurance→pool re-entrancy restriction, noted in the code)
  • Auction clearing for seized non-cash collateral
  • Senior/junior tranche loss-ordering on liquidation
  • Frontend "Defaulted invoices" keeper/investor views
  • Indexer event handling + liquidation-history endpoint
  • The two full pipeline integration tests (simple + tranched) named in the acceptance criteria

Test plan

  • cargo test -p pool --lib liquidate_invoice — 3/3 new tests pass (permissionless happy path, rejection when not yet defaulted, double-liquidation rejection via both permissionless and governance paths)
  • cargo test -p pool --lib seize_collateral — all 6 existing tests still pass (no regression from the refactor)
  • tsc --noEmit clean in packages/sdk
  • packages/sdk Jest suite passes (4/4)

Closes #1037

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Build an end-to-end automated liquidation pipeline for defaulted invoices

1 participant