Skip to content

DEV-204: TS SDK support split/merge and redeem#94

Open
cesarenaldi wants to merge 5 commits into
mainfrom
feature/dev-204-ts-sdk-support-splitmerge-and-redeem
Open

DEV-204: TS SDK support split/merge and redeem#94
cesarenaldi wants to merge 5 commits into
mainfrom
feature/dev-204-ts-sdk-support-splitmerge-and-redeem

Conversation

@cesarenaldi
Copy link
Copy Markdown
Collaborator

@cesarenaldi cesarenaldi commented Jun 5, 2026

Summary

  • add combo position listing through listComboPositions with typed bindings and SDK-owned pagination
  • add combo split and merge support by legs
  • add protocol helpers for canonical combo legs and condition ID derivation
  • add integration coverage for combo split/merge using listComboPositions

Verification

  • pnpm lint
  • pnpm typecheck
  • pnpm vitest packages/client/src/protocol.test.ts

Redeem support is intentionally not included in this PR.


Note

High Risk
Large changes to on-chain split/merge/redeem paths and merge amount resolution; incorrect routing or balance logic could cause failed or wrong transactions.

Overview
Adds combo portfolio and lifecycle support to the TypeScript SDK: typed listComboPositions (with pagination/filters), combo split/merge by leg position IDs, and combo redeem by combo position ID (full on-chain balance via protocol v2).

Market split, merge (amount: 'max'), and redeem are refactored to resolve context from market metadata and on-chain ERC1155 balances instead of inferring amounts from the positions API. Combo flows use new protocol helpers (canonical legs, derived condition IDs) plus v2 router / combinatorial module transaction builders and environment addresses; a preproduction environment supports combo integration tests.

Bindings widen condition ID validation for v2 (bytes31/32). Public client docs/examples are updated for the unified splitPosition / mergePositions / redeemPositions entry points.

Reviewed by Cursor Bugbot for commit 288d140. Bugbot is set up for automated code reviews on this repo. Configure here.

@cesarenaldi cesarenaldi changed the title Support combo position split and merge DEV-204: TS SDK support split/merge and redeem Jun 5, 2026
Comment thread packages/client/src/actions/positions.ts
Comment thread packages/client/src/actions/positions.ts
Comment thread packages/client/src/actions/portfolio.ts
Comment thread packages/client/src/actions/positions.ts
@cesarenaldi cesarenaldi changed the base branch from chore/update-rfq-quoter-ws-url to main June 5, 2026 20:32
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 288d140. Configure here.

: client.environment.collateralAdapter,
positionErc1155Address: marketContext.negRisk
? client.environment.negRiskAdapter
: client.environment.conditionalTokens,
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wrong ERC1155 contract neg-risk

High Severity

For negative-risk markets, prepareMergeMarketPosition reads YES/NO balances via balanceOfBatch on negRiskAdapter, but holdings for those token IDs live on conditionalTokens. Merge amount resolution then sees zero balances and rejects merges (or caps 'max' at zero) even when the wallet holds complementary positions.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 288d140. Configure here.

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