From fda1e9d9fe593de45d4f77d52ed21de11fdc673c Mon Sep 17 00:00:00 2001 From: "Ian C." Date: Wed, 22 Apr 2026 11:37:28 +0100 Subject: [PATCH 1/2] Align close position with REST path contract The close-position endpoint identifies the position in the URL path. Sending position_id again in the JSON body now fails against the backend's deny-unknown-fields request schema, so the SDK only sends close parameters in the body. Constraint: Backend expects /api/v1/positions/{position_id}/close with close_type payload only Rejected: Loosen backend JSON parsing | would hide stale client contracts instead of fixing SDK request shape Confidence: high Scope-risk: narrow Directive: Keep resource IDs in path-only bodies out of SDK JSON payloads unless the backend contract explicitly requires duplication Tested: bun test packages/core/tests/unit/api/positions.test.ts; bun run check --- packages/core/src/api/positions/api.ts | 1 - packages/core/tests/unit/api/positions.test.ts | 1 - 2 files changed, 2 deletions(-) diff --git a/packages/core/src/api/positions/api.ts b/packages/core/src/api/positions/api.ts index 4677947e..e1b6a8b7 100644 --- a/packages/core/src/api/positions/api.ts +++ b/packages/core/src/api/positions/api.ts @@ -46,7 +46,6 @@ export class PositionsAPIImpl extends BaseAPI implements PositionsAPI { return await this.makeAuthenticatedRequest(perpRoutes.positions.close(positionId), { method: "POST", body: JSON.stringify({ - position_id: positionId, close_type: request.closeType, limit_price: request.limitPrice, slippage_tolerance_bps: request.slippageToleranceBps, diff --git a/packages/core/tests/unit/api/positions.test.ts b/packages/core/tests/unit/api/positions.test.ts index 4cfa874c..fe7db42e 100644 --- a/packages/core/tests/unit/api/positions.test.ts +++ b/packages/core/tests/unit/api/positions.test.ts @@ -87,7 +87,6 @@ describe("PositionsAPIImpl", () => { Authorization: `Bearer ${mockAccessToken}`, }, body: JSON.stringify({ - position_id: positionId, close_type: "LIMIT", limit_price: "50500", slippage_tolerance_bps: 100, From 1fd5d17f498c6bf9bcdf46028e20c42b3243dce4 Mon Sep 17 00:00:00 2001 From: "Ian C." Date: Wed, 22 Apr 2026 23:53:03 +0100 Subject: [PATCH 2/2] Release close-position contract fix The close-position SDK fix changes the published @0xmonaco/core package behavior, so it needs a patch changeset for the release pipeline. Constraint: Changesets bot requires package-impact metadata for SDK release PRs Confidence: high Scope-risk: narrow Tested: bun test packages/core/tests/unit/api/positions.test.ts Tested: bun run check Not-tested: Full package publish pipeline --- .changeset/close-position-path-only.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/close-position-path-only.md diff --git a/.changeset/close-position-path-only.md b/.changeset/close-position-path-only.md new file mode 100644 index 00000000..f89aa468 --- /dev/null +++ b/.changeset/close-position-path-only.md @@ -0,0 +1,5 @@ +--- +"@0xmonaco/core": patch +--- + +Align close-position requests with the REST contract by keeping `position_id` in the URL path only.