Skip to content

Split predict redeem by authority (owner vs permissionless)#1064

Draft
emmazzz wants to merge 1 commit into
mainfrom
emma/predict-redeem-authority-split
Draft

Split predict redeem by authority (owner vs permissionless)#1064
emmazzz wants to merge 1 commit into
mainfrom
emma/predict-redeem-authority-split

Conversation

@emmazzz

@emmazzz emmazzz commented Jun 3, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • expiry_market::redeem carried three different authority models selected by control flow — the liquidated and settled branches were permissionless, the live branch was owner-only — with the owner check buried inside redeem_live_internal. The public signature gave no hint that the function was sometimes keeper-callable.
  • Make redeem owner-gated at the entry (hoist manager.assert_owner); it handles the owner's own live / settled / liquidated closes.
  • Add redeem_permissionless for keeper-driven finalization of any manager's settled or liquidated order. It pays the manager (never the caller) and aborts on a live order.
  • Extract lifecycle dispatch into a private redeem_internal; drop the now-redundant owner check in redeem_live_internal.
  • Add the ENotPermissionlesslyRedeemable abort code.

Key decisions

  • 2-way split (redeem owner / redeem_permissionless keeper) rather than three lifecycle entrypoints: authority now maps to the function name, and no single function contains branches with differing authority. The owner path still handles the owner's own settled/liquidated orders for convenience.
  • redeem_permissionless drops close_quantity / pyth / clock — it is always a full close and runs no liquidation pass, finalizing only already-terminal (settled or tombstoned) orders. The keeper flow is liquidate (to tombstone underwater orders) then redeem_permissionless (to clear them).
  • Based off main independent of the live-pricing-context PR (per request). The two edit expiry_market.move and will need a rebase when the first merges.

Test plan

  • sui move test --path packages/predict --gas-limit 100000000000 — 449 passed, 0 failed
  • redeem_permissionless_settles_for_non_owner — non-owner finalizes a settled order; position cleared, returned id matches
  • redeem_permissionless_live_order_abortsENotPermissionlesslyRedeemable on a live order
  • redeem_by_non_owner_abortspredict_manager::ENotOwner on the owner-gated redeem
  • Follow-up: extract a shared expiry-market flow fixture so redeem tests don't live in plp_rebate_flow_tests.move

🤖 Generated with Claude Code

redeem previously carried three authority models selected by control flow: liquidated/settled branches were permissionless, the live branch owner-only, with the gate buried inside redeem_live_internal and invisible from the signature. Hoist the owner check to a now owner-gated redeem, and add a name-explicit redeem_permissionless for keeper-driven settled/liquidated finalization of any manager (pays the manager, never the caller; aborts on a live order). Lifecycle dispatch moves into a private redeem_internal; the redundant owner check in redeem_live_internal is removed. Adds ENotPermissionlesslyRedeemable.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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