Skip to content

feat(data): report converted shares on conversion activity - #408

Open
kartojal wants to merge 1 commit into
mainfrom
fix/conversion-activity-shares
Open

kartojal wants to merge 1 commit into
mainfrom
fix/conversion-activity-shares

Conversation

@kartojal

@kartojal kartojal commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Summary

ConversionActivity.amount comes from usdc_size. Protocol v2 conversions release no collateral, so activity rows serve the converted share amount in size and 0 in usdc_size. The SDK reported every v2 conversion with amount == 0 and had no field for the shares that moved.

This adds shares, read from size, the same way THRESHOLD_COMPOSE and THRESHOLD_DECOMPOSE expose it in #404. Matches Polymarket/ts-sdk#502.

amount stays and is not deprecated. Legacy multi-outcome conversions serve usdc_size = shares * (k - 1), the collateral released when NO is converted on k outcomes, so the field still carries real data for those rows. The class docstring now says what each field is and when amount is 0.

Changes

  • ConversionActivity gains shares: Decimal, required like TradeActivity.shares.
  • Unit test with a v2 row shape (size 25, usdc_size 0), a legacy multi-outcome row, and a row missing size.

Checks

  • ruff check, ruff format --check and pyright pass.
  • pytest -m "not integration": 3560 passed, 2 failed. The failures are test_secure_client_defaults_wallet_to_current_deposit_wallet and test_create_defaults_wallet_to_current_deposit_wallet, which hit a connection reset from the remote host on this machine. They are unrelated to this change.

🤖 Generated with Claude Code


Note

Low Risk
Scoped to activity parsing and an additive public field; the only behavioral tightening is rejecting CONVERSION payloads without size.

Overview
Conversion activity rows now expose shares from the API’s size, so protocol v2 conversions (where usdc_size is 0) no longer look like zero-sized events. amount still maps to usdc_size for released collateral on legacy multi-outcome conversions.

The ConversionActivity model adds a required shares field with parsing/validation aligned to TradeActivity, plus a docstring clarifying when amount is zero vs non-zero. Unit tests cover v2 and legacy payload shapes and assert missing size raises UnexpectedResponseError.

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

ConversionActivity only exposed amount, read from usdc_size. Protocol v2
conversions serve 0 there because they release no collateral, so the
converted quantity was lost. The wire carries it in size.

Add shares from size. Keep amount, which is the collateral released by
legacy multi-outcome conversions ((k - 1) * shares), and document that it
is 0 for single-outcome and protocol v2 conversions.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

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