Skip to content

feat(client): support directional collateral return - #401

Draft
kartojal wants to merge 2 commits into
mainfrom
feat/directional-collateral-return
Draft

kartojal wants to merge 2 commits into
mainfrom
feat/directional-collateral-return

Conversation

@kartojal

@kartojal kartojal commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

Market makers can merge ABOVE on a lower threshold with BELOW on a higher threshold to receive pUSD and the middle-bucket YES positions, then reverse it with the same two IDs. Ports the current position-ID workflow from TypeScript PR #428.

pairs = client.find_directional_pairs()
if pairs:
    selected = pairs[0]
    transaction = client.merge_directional(
        selected.above_position_id,
        selected.below_position_id,
        amount=selected.amount,
    )
    transaction.wait()
  • Sync SecureClient is the default; AsyncSecureClient offers the same methods with native async transport. Both accept unordered wing IDs, keyword-only base-unit amounts, and a default of "max". Splits check pUSD and every consumed bucket.
  • Python prepare_* methods return the existing immutable TransactionCall for execute_transaction or custom signing, rather than copying the TypeScript signing generator. Models use frozen dataclasses, output enums, and plain-string input vocabularies.
  • Include pair discovery with fresh on-chain balances, local ID decoding/derivation, bucket/Void and whole-event operations, threshold compose/decompose, and condition-based split/merge/redeem without a market listing. Pair candidates can overlap and are not an execution plan.
  • Add the four dedicated activity models, directional resolution kinds, a usage guide and an offline example. Existing approval and EOA / Deposit Wallet / Safe / Proxy execution paths are reused. Collateral-return service planning remains deferred.

Validation

uv run ruff check ., uv run ruff format --check ., uv run pyright, uv run pytest -m "not integration", uv build, and the Sphinx reference build pass. 3,573 tests pass; focused coverage pins Router selectors against the TypeScript ABI and exercises unordered pairs, balance limits, exact Void-inclusive baskets, all four wallet paths, paginated discovery, activity economics, and local directional redemption.

The offline directional example runs. Added an opt-in metered staging round trip using shared integration fixtures; it skips without metered opt-in and credentials. Live Python staging execution remains unverified. The test seeds inventory using line splits and does not establish trading/fill settlement.

This branch has not been deployed

No deployments
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