Skip to content

feat(client): support Perps cancel-all orders - #184

Merged
cesarenaldi merged 3 commits into
mainfrom
feat/perps-cancel-all-orders
Jul 7, 2026
Merged

feat(client): support Perps cancel-all orders#184
cesarenaldi merged 3 commits into
mainfrom
feat/perps-cancel-all-orders

Conversation

@cesarenaldi

@cesarenaldi cesarenaldi commented Jul 7, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • add Perps session.cancelAllOrders({ instrumentId?, expiresAt? })
  • sign and send the proxy-authenticated cancel-all REST request added in Polymarket/perpetuals#487
  • validate the { status: "ok" } response and export the new request type
  • add session-level REST serialization coverage plus metered integration coverage for scoped cancel-all

Verification

  • pnpm lint
  • pnpm typecheck
  • pnpm test:bindings
  • pnpm test:client
  • pnpm exec vitest --project client-integration packages/client/tests/integration/perps.test.ts --run (metered tests skipped unless enabled)

Rollout note

The live cancel-all integration test depends on the backend endpoint being deployed.


Note

Medium Risk
Introduces a bulk trading cancel on live Perps accounts; behavior is accept-on-ACK with possible races on individual orders, and depends on the backend cancel-all endpoint being deployed.

Overview
Adds session.cancelAllOrders({ instrumentId?, expiresAt? }) so Perps users can cancel every open order account-wide or for one instrument, via a signed REST DELETE /v1/trade/orders/all (unlike single/batch cancels over the session WebSocket).

The client builds a cancelAll signed op, serializes optional iid in the request body, validates { status: "ok" }, and exports CancelAllPerpsOrdersRequest from bindings and public entry points. PerpsSessionTradingError now includes rate-limit and unexpected-response failures for this path.

Also bumps ORDER_PLACEMENT_UPDATE_TIMEOUT_MS from 1s to 2s, adds MSW coverage for scoped vs global cancel-all payloads, and a metered integration test that places two orders then cancel-all for one instrument.

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

@cursor cursor Bot left a comment

Copy link
Copy Markdown

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 using default effort 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 a843149. Configure here.

.then(expectNonEmptyArray);
const [ticker] = await publicClient
.fetchPerpsTickers({ instrumentId: instrument.id })
.then(expectNonEmptyArray);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Module load hits live Perps API

Medium Severity

Hoisting fetchPerpsInstruments and fetchPerpsTickers to top-level await runs two live Perps REST calls when the module loads. All cases use it.runIf(runMeteredTests), so with metered tests off Vitest still evaluates the file and can fail collection on network or empty data before any test is skipped.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit a843149. Configure here.

@cesarenaldi
cesarenaldi merged commit 86e54dd into main Jul 7, 2026
4 checks passed
@cesarenaldi
cesarenaldi deleted the feat/perps-cancel-all-orders branch July 7, 2026 15:34
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