From a08ee75282f40f56e6bd3e0445dd2de6e7511b6e Mon Sep 17 00:00:00 2001 From: nktkas Date: Sun, 2 Aug 2026 02:49:17 +0300 Subject: [PATCH] refactor(api/userFees): fix `stakingLink` shape and type `nextTrialAvailableTimestamp` Co-authored-by: Claude Opus 5 (1M context) --- src/api/info/_methods/userFees.ts | 25 +++++++++++++++---------- tests/api/info/userFees.test.ts | 5 +++-- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/src/api/info/_methods/userFees.ts b/src/api/info/_methods/userFees.ts index 4b6258ee..400f6d88 100644 --- a/src/api/info/_methods/userFees.ts +++ b/src/api/info/_methods/userFees.ts @@ -165,8 +165,8 @@ export type UserFeesResponse = { * @pattern ^[0-9]+(\.[0-9]+)?$ */ feeTrialEscrow: string; - /** Timestamp when next trial becomes available. */ - nextTrialAvailableTimestamp: unknown | null; + /** Timestamp when next trial becomes available (in ms since epoch). */ + nextTrialAvailableTimestamp: number | null; /** * Permanent link between staking and trading accounts. * Staking user gains full control of trading account funds. @@ -174,19 +174,24 @@ export type UserFeesResponse = { */ stakingLink: { /** - * Linked account address: - * - When queried by staking account: contains trading account address. - * - When queried by trading account: contains staking account address. + * Link status: + * - `"requested"`: Link initiated by trading user, awaiting staking user confirmation. + * - `"tradingUser"`: Response queried by trading account. + */ + type: "requested" | "tradingUser"; + /** + * Staking account address. * @pattern ^0x[a-fA-F0-9]{40}$ */ stakingUser: `0x${string}`; + } | { + /** Link status: response queried by staking account. */ + type: "stakingUser"; /** - * Link status: - * - `requested` = link initiated by trading user, awaiting staking user confirmation. - * - `stakingUser` = response queried by staking account. - * - `tradingUser` = response queried by trading account. + * Trading account address. + * @pattern ^0x[a-fA-F0-9]{40}$ */ - type: "requested" | "stakingUser" | "tradingUser"; + tradingUser: `0x${string}`; } | null; /** Active staking discount details. */ activeStakingDiscount: { diff --git a/tests/api/info/userFees.test.ts b/tests/api/info/userFees.test.ts index 30651560..043928b3 100644 --- a/tests/api/info/userFees.test.ts +++ b/tests/api/info/userFees.test.ts @@ -15,6 +15,8 @@ runTest({ const params: UserFeesParameters[] = [ { user: "0xe973105a27e17350500926ae664dfcfe6006d924" }, { user: "0x768484f7e2ebb675c57838366c02ae99ba2a9b08" }, // userAddRate/userSpotAddRate negative + { user: "0xeffb9c711ec1d3e551a7391dd848290a614c2e63" }, // stakingLink.type = tradingUser + { user: "0xc066dda6748bc50b4fa17720b215783f5d60045f" }, // stakingLink.type = stakingUser ]; const data = await Promise.all(params.map((p) => client.userFees(p))); @@ -22,8 +24,7 @@ runTest({ schemaCoverage(paramsSchema, params); schemaCoverage(responseSchema, data, [ "#/properties/trial/defined", - "#/properties/nextTrialAvailableTimestamp/defined", - "#/properties/stakingLink/defined", + "#/properties/stakingLink/anyOf/0/properties/type/enum/0", ]); }, });