From 73fb694fae4065a8e7828d8f889bc8a981e285c9 Mon Sep 17 00:00:00 2001 From: nktkas Date: Sun, 2 Aug 2026 02:34:07 +0300 Subject: [PATCH] refactor(api/spotClearinghouseState): fix outcome `coin` and add `tokenToPortfolioSupplyRatio` Co-authored-by: Claude Opus 5 (1M context) --- .../info/_methods/spotClearinghouseState.ts | 18 ++++++++++++++++-- tests/api/info/spotClearinghouseState.test.ts | 10 +++------- tests/api/info/subAccounts.test.ts | 1 + tests/api/info/subAccounts2.test.ts | 1 + tests/api/info/webData2.test.ts | 1 + tests/api/subscription/spotState.test.ts | 1 + 6 files changed, 23 insertions(+), 9 deletions(-) diff --git a/src/api/info/_methods/spotClearinghouseState.ts b/src/api/info/_methods/spotClearinghouseState.ts index 290e9c91..6d355fc2 100644 --- a/src/api/info/_methods/spotClearinghouseState.ts +++ b/src/api/info/_methods/spotClearinghouseState.ts @@ -69,8 +69,12 @@ export type SpotClearinghouseStateResponse = { */ supplied?: string; } | { - /** Outcome market identifier ("+" followed by `assetId - 100000000`). */ - coin: `+${number}`; + /** + * Outcome market identifier: + * - `+N`: `N` is `assetId - 100000000` of an active outcome market. + * - `oN`: `N` is the identifier of a settled outcome. + */ + coin: `+${number}` | `o${number}`; /** * Total balance. * @pattern ^[0-9]+(\.[0-9]+)?$ @@ -114,6 +118,16 @@ export type SpotClearinghouseStateResponse = { */ ratio: string, ][]; + /** Portfolio supply ratio per token. */ + tokenToPortfolioSupplyRatio?: [ + /** Token identifier. */ + token: number, + /** + * Supply ratio. + * @pattern ^[0-9]+(\.[0-9]+)?$ + */ + ratio: string, + ][]; /** Amount available after maintenance per token. */ tokenToAvailableAfterMaintenance?: [ /** Token identifier. */ diff --git a/tests/api/info/spotClearinghouseState.test.ts b/tests/api/info/spotClearinghouseState.test.ts index 778ef6ed..be919f4e 100644 --- a/tests/api/info/spotClearinghouseState.test.ts +++ b/tests/api/info/spotClearinghouseState.test.ts @@ -15,21 +15,17 @@ runTest({ const params: SpotClearinghouseStateParameters[] = [ { user: "0x563C175E6f11582f65D6d9E360A618699DEe14a9" }, // balances.length > 0 { user: "0x1defed46db35334232b9f5fd2e5c6180276fb99d" }, // evmEscrows.length > 0 + { user: "0x8c967e73e7b15087c42a10d344cff4c96d877f1d" }, // balances with an outcome market identifier + { user: "0x6b043579b088d44400dffa1ef1c5e3e3bfbdf9d2" }, // portfolio margin enabled ]; const data = await Promise.all(params.map((p) => client.spotClearinghouseState(p))); schemaCoverage(paramsSchema, params); schemaCoverage(responseSchema, data, [ - "#/properties/portfolioMarginEnabled/present", "#/properties/balances/items/anyOf/0/properties/spotHold/present", - "#/properties/balances/items/anyOf/0/properties/ltv/present", "#/properties/balances/items/anyOf/0/properties/borrowed/present", - "#/properties/balances/items/anyOf/0/properties/supplied/present", - "#/properties/balances/items/anyOf/1", - "#/properties/portfolioMarginRatio/present", - "#/properties/tokenToPortfolioBorrowRatio/present", - "#/properties/tokenToAvailableAfterMaintenance/present", + "#/properties/tokenToPortfolioSupplyRatio/array", ]); }, }); diff --git a/tests/api/info/subAccounts.test.ts b/tests/api/info/subAccounts.test.ts index 9e5d600b..d3ae37c5 100644 --- a/tests/api/info/subAccounts.test.ts +++ b/tests/api/info/subAccounts.test.ts @@ -28,6 +28,7 @@ runTest({ "#/anyOf/0/items/properties/spotState/properties/portfolioMarginEnabled/present", "#/anyOf/0/items/properties/spotState/properties/portfolioMarginRatio/present", "#/anyOf/0/items/properties/spotState/properties/tokenToPortfolioBorrowRatio/present", + "#/anyOf/0/items/properties/spotState/properties/tokenToPortfolioSupplyRatio/present", "#/anyOf/0/items/properties/spotState/properties/tokenToAvailableAfterMaintenance/present", "#/anyOf/0/items/properties/spotState/properties/balances/items/anyOf/0/properties/spotHold/present", "#/anyOf/0/items/properties/spotState/properties/balances/items/anyOf/0/properties/ltv/present", diff --git a/tests/api/info/subAccounts2.test.ts b/tests/api/info/subAccounts2.test.ts index 6bdcb294..648ebf66 100644 --- a/tests/api/info/subAccounts2.test.ts +++ b/tests/api/info/subAccounts2.test.ts @@ -28,6 +28,7 @@ runTest({ "#/anyOf/0/items/properties/spotState/properties/portfolioMarginEnabled/present", "#/anyOf/0/items/properties/spotState/properties/portfolioMarginRatio/present", "#/anyOf/0/items/properties/spotState/properties/tokenToPortfolioBorrowRatio/present", + "#/anyOf/0/items/properties/spotState/properties/tokenToPortfolioSupplyRatio/present", "#/anyOf/0/items/properties/spotState/properties/tokenToAvailableAfterMaintenance/present", "#/anyOf/0/items/properties/spotState/properties/balances/items/anyOf/0/properties/spotHold/present", "#/anyOf/0/items/properties/spotState/properties/balances/items/anyOf/0/properties/ltv/present", diff --git a/tests/api/info/webData2.test.ts b/tests/api/info/webData2.test.ts index 1aca85c1..b09d3ab8 100644 --- a/tests/api/info/webData2.test.ts +++ b/tests/api/info/webData2.test.ts @@ -45,6 +45,7 @@ runTest({ "#/properties/spotState/properties/portfolioMarginEnabled/present", "#/properties/spotState/properties/portfolioMarginRatio/present", "#/properties/spotState/properties/tokenToPortfolioBorrowRatio/present", + "#/properties/spotState/properties/tokenToPortfolioSupplyRatio/present", "#/properties/spotState/properties/tokenToAvailableAfterMaintenance/present", "#/properties/spotState/properties/balances/items/anyOf/0/properties/spotHold/present", "#/properties/spotState/properties/balances/items/anyOf/0/properties/ltv/present", diff --git a/tests/api/subscription/spotState.test.ts b/tests/api/subscription/spotState.test.ts index 53c3c774..6e0c5df1 100644 --- a/tests/api/subscription/spotState.test.ts +++ b/tests/api/subscription/spotState.test.ts @@ -29,6 +29,7 @@ runTest({ "#/properties/spotState/properties/portfolioMarginEnabled/present", "#/properties/spotState/properties/portfolioMarginRatio/present", "#/properties/spotState/properties/tokenToPortfolioBorrowRatio/present", + "#/properties/spotState/properties/tokenToPortfolioSupplyRatio/present", "#/properties/spotState/properties/tokenToAvailableAfterMaintenance/present", "#/properties/spotState/properties/balances/items/anyOf/0/properties/spotHold/present", "#/properties/spotState/properties/balances/items/anyOf/0/properties/ltv/present",