Skip to content

fix(M1/M2/L4): revert-resilience for emergency & redemption paths - #17

Merged
jayeshy14 merged 1 commit into
mainfrom
fix/medium-revert-resilience
Jul 18, 2026
Merged

jayeshy14 merged 1 commit into
mainfrom
fix/medium-revert-resilience

Conversation

@jayeshy14

Copy link
Copy Markdown
Owner

Category PR grouping the audit's revert-resilience findings (M1, M2, L4) so no PT or swap leg can brick the paths the spec calls never-blocked. Branched off main, targets main.

M1 — SafeLegManager.provide

  • pt.withdraw wrapped in try/catch: a PT sale that can't meet its slippage bound reduces delivered assets instead of reverting the emergency de-risk / redemption funding.
  • Oracle-free fast path: a request that fits the deliverable buffer no longer reads pt.value(), so a Pendle-oracle outage can't block a buffer-only payout.
  • provide is now best-effort (delivers what's available) rather than reverting InsufficientValue.

M2 — onInflow / rebalanceBuffer

  • PT buys are best-effort: a dislocated Pendle market leaves the assets in the buffer (reclaimed from the adapter via new IPTAdapter.reclaim) instead of reverting the caller. onInflow runs inside the permissionless emergency rebalance, so a PT-buy revert must not unwind the de-risk.
  • PT-buy binary-search window is configurable (setApproxWindowBps, default 10%) so spot-vs-TWAP divergence is tolerable without a redeploy.

L4 — freeAssets

  • The risky shortfall sale is a try/catch self-call, so the safe-leg portion always delivers even when the risky sale can't clear its bound.

Deferred

L6's large-delta chunking is a distinct mechanism and is deferred; its acute parts (degraded bound, corrected invariant comment) were already handled in H6.

Tests

6 regressions: PT-withdraw revert delivers buffer best-effort; buffer-only path is oracle-free; over-ask is best-effort not revert; onInflow PT-buy revert leaves assets in the buffer; freeAssets delivers the safe portion when the risky sale reverts. Suite 123 -> 127; 9/9 fork tests green (adapter changes validated against live Pendle).

Groups the audit's revert-resilience mediums/lows so no PT or swap leg
can brick the paths the spec calls never-blocked:

- M1: SafeLegManager.provide wraps pt.withdraw in try/catch (PT that
  can't meet its bound reduces delivered assets, never reverts) and
  takes an oracle-free fast path when the request fits the buffer (a
  Pendle-oracle outage no longer blocks a buffer-only payout). provide
  is now best-effort: it delivers what's available instead of reverting.
- M2: onInflow/rebalanceBuffer buy PT best-effort; a dislocated Pendle
  market leaves the assets in the buffer (reclaimed from the adapter)
  instead of reverting the caller, so a PT-buy revert can't unwind the
  permissionless emergency rebalance. PT-buy search window is now
  configurable (setApproxWindowBps) so spot-vs-TWAP divergence is
  tolerable without a redeploy. Adds IPTAdapter.reclaim.
- L4: freeAssets self-calls the risky shortfall sale under try/catch so
  the safe-leg portion always delivers even when the risky sale can't
  clear its bound.

L6's large-delta chunking is deferred (a distinct mechanism; its acute
parts were handled in H6). 6 regression tests; 123 -> 127, 9 fork green.
@jayeshy14
jayeshy14 merged commit 07b590d into main Jul 18, 2026
3 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

Development

Successfully merging this pull request may close these issues.

1 participant