@totalis/hip4-client 0.109.0 → 0.110.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,22 @@
3
3
  `@totalis/hip4-client` follows [semantic versioning](https://semver.org).
4
4
  The contract version the generated types come from is `sdkVersion` in `./version`.
5
5
 
6
+ ## 0.110.0
7
+
8
+ ### Changed
9
+
10
+ - Portfolio Margin accounts (TT-2868, contract
11
+ `245.0.0-portfolio-margin-funding`). `getHypercoreBalance` and
12
+ `getHypercorePortfolio` answer a Portfolio Margin account with its
13
+ `account_mode` and positions instead of failing `DEPENDENCY_STALE`; its
14
+ `funding` amounts `spot_usdc`, `perp_usdc`, `spot_usdc_total` and
15
+ `spot_usdc_hold` are `null`, since Hyperliquid signs its spot `hold` (and
16
+ `total` while borrowing) and total less hold is not its cash. They are typed
17
+ `string | null`; every other mode still gets strings. `readCoreCash`
18
+ answers `PORTFOLIO_MARGIN` with `spendable` `0n` whatever the spot read
19
+ says, and leaves all three fields `null` when the spot read is Portfolio
20
+ Margin's but the mode read is not.
21
+
6
22
  ## 0.109.0
7
23
 
8
24
  ### Added
@@ -4472,21 +4472,21 @@ export type components = {
4472
4472
  };
4473
4473
  /** Format: date-time */
4474
4474
  readonly "$defs-Timestamp": string;
4475
- /** @description USDC available on HyperCore for funding. */
4475
+ /** @description USDC available on HyperCore for funding. Every amount is null when account_mode is PORTFOLIO_MARGIN, whose USDC is not defined as total minus hold, and only then. */
4476
4476
  readonly HypercoreFunding: {
4477
4477
  /**
4478
4478
  * @description Hyperliquid account abstraction: STANDARD keeps separate spot and perp balances, UNIFIED and PORTFOLIO_MARGIN pool them, UNKNOWN when the mode could not be read or is unrecognized.
4479
4479
  * @enum {unknown}
4480
4480
  */
4481
4481
  readonly account_mode: "STANDARD" | "UNIFIED" | "PORTFOLIO_MARGIN" | "UNKNOWN";
4482
- /** @description Spot USDC not held by open orders (spot_usdc_total minus spot_usdc_hold), as a decimal string. */
4483
- readonly spot_usdc: string;
4484
- /** @description Withdrawable perp USDC as a decimal string; "0" unless account_mode is STANDARD. */
4485
- readonly perp_usdc: string;
4486
- /** @description Total spot USDC, held or not, as a decimal string; "0" when the account holds no USDC. */
4487
- readonly spot_usdc_total: string;
4488
- /** @description Spot USDC held by open orders, as a decimal string; "0" when the account holds no USDC. */
4489
- readonly spot_usdc_hold: string;
4482
+ /** @description Spot USDC not held by open orders (spot_usdc_total minus spot_usdc_hold), as a decimal string; null in PORTFOLIO_MARGIN. */
4483
+ readonly spot_usdc: string | null;
4484
+ /** @description Withdrawable perp USDC as a decimal string; "0" when account_mode is UNIFIED or UNKNOWN, null in PORTFOLIO_MARGIN. */
4485
+ readonly perp_usdc: string | null;
4486
+ /** @description Total spot USDC, held or not, as a decimal string; "0" when the account holds no USDC, null in PORTFOLIO_MARGIN. */
4487
+ readonly spot_usdc_total: string | null;
4488
+ /** @description Spot USDC held by open orders, as a decimal string; "0" when the account holds no USDC, null in PORTFOLIO_MARGIN. */
4489
+ readonly spot_usdc_hold: string | null;
4490
4490
  };
4491
4491
  readonly HypercorePortfolioPosition: {
4492
4492
  /** @description Hyperliquid HIP-4 outcome ID the balance belongs to. */
@@ -1,5 +1,5 @@
1
- export declare const sdkVersion = "244.0.0-rounds-live-trades";
2
- export declare const openapiSha256 = "5be33e1cd7cb9262f11128c7a87ffd725eb954196764d3a19213fd624f99a4a9";
1
+ export declare const sdkVersion = "245.0.0-portfolio-margin-funding";
2
+ export declare const openapiSha256 = "f19e1adddfab9856b22023f837186ffc2ade8a861d37431e1531e7bd7e4cc928";
3
3
  export declare const realtimeSha256 = "69596dce99d3ebcd4bbac4587e711017b37ce7e7830940c76b1449d78c070da3";
4
4
  export declare const jsonSchemaSha256: {
5
5
  readonly "account.schema.json": "e6cd5a75429d074f23bd7f6ffd370fa59d0e3f7dbd6aef6433e5ba0d21b5baeb";
@@ -7,7 +7,7 @@ export declare const jsonSchemaSha256: {
7
7
  readonly "common.schema.json": "04f51deb3cbea448e59195e26ede3212598d58a7940fe67eb2123fd9161c5edb";
8
8
  readonly "core-exit.schema.json": "c7f617e815225cdcac95c236f8b73fbe288ee5713ff444c3be90eb915fc3a401";
9
9
  readonly "error.schema.json": "f444f3ff2a13553f1eea5eaab0088760862691c0d02c60641065cf46022a743f";
10
- readonly "hypercore.schema.json": "5b89b2bbff7ec8cc1b8717375d12ce9cd5ab6aa5af03c4fdc6cc753ef9583a2c";
10
+ readonly "hypercore.schema.json": "521372f8980353bcdd90ca3d0292bc6b41c69dbad3164bfd501b1ca99dac4cb8";
11
11
  readonly "identity.schema.json": "896d975e5f4076cb34ae33f2dcfc41559fd3df1ed39e3d72ac9e342ca1f957fa";
12
12
  readonly "maker-access.schema.json": "49698ee0235e42064aae0397db1e0f646bdc10d9dfa10121714ba06dd69fee3b";
13
13
  readonly "maker-action.schema.json": "dc41e52c868848e85cdeb918992cb710d34616d2803a63f6d9a658e016744a50";
@@ -1,6 +1,6 @@
1
1
  // Generated by scripts/generate.mjs; do not edit.
2
- export const sdkVersion = "244.0.0-rounds-live-trades";
3
- export const openapiSha256 = "5be33e1cd7cb9262f11128c7a87ffd725eb954196764d3a19213fd624f99a4a9";
2
+ export const sdkVersion = "245.0.0-portfolio-margin-funding";
3
+ export const openapiSha256 = "f19e1adddfab9856b22023f837186ffc2ade8a861d37431e1531e7bd7e4cc928";
4
4
  export const realtimeSha256 = "69596dce99d3ebcd4bbac4587e711017b37ce7e7830940c76b1449d78c070da3";
5
5
  export const jsonSchemaSha256 = {
6
6
  "account.schema.json": "e6cd5a75429d074f23bd7f6ffd370fa59d0e3f7dbd6aef6433e5ba0d21b5baeb",
@@ -8,7 +8,7 @@ export const jsonSchemaSha256 = {
8
8
  "common.schema.json": "04f51deb3cbea448e59195e26ede3212598d58a7940fe67eb2123fd9161c5edb",
9
9
  "core-exit.schema.json": "c7f617e815225cdcac95c236f8b73fbe288ee5713ff444c3be90eb915fc3a401",
10
10
  "error.schema.json": "f444f3ff2a13553f1eea5eaab0088760862691c0d02c60641065cf46022a743f",
11
- "hypercore.schema.json": "5b89b2bbff7ec8cc1b8717375d12ce9cd5ab6aa5af03c4fdc6cc753ef9583a2c",
11
+ "hypercore.schema.json": "521372f8980353bcdd90ca3d0292bc6b41c69dbad3164bfd501b1ca99dac4cb8",
12
12
  "identity.schema.json": "896d975e5f4076cb34ae33f2dcfc41559fd3df1ed39e3d72ac9e342ca1f957fa",
13
13
  "maker-access.schema.json": "49698ee0235e42064aae0397db1e0f646bdc10d9dfa10121714ba06dd69fee3b",
14
14
  "maker-action.schema.json": "dc41e52c868848e85cdeb918992cb710d34616d2803a63f6d9a658e016744a50",
@@ -122,10 +122,11 @@ export type CoreAccountMode = "STANDARD" | "UNIFIED" | "PORTFOLIO_MARGIN";
122
122
  * The account's HyperCore USDC as a Combo can bridge it, read from
123
123
  * Hyperliquid. `spendable` is spot USDC `total` less `hold`, then floored
124
124
  * to USDC base units (6 decimals); `hold` already carries order holds and
125
- * position margin. A Portfolio Margin account offers none, as in the Totalis
126
- * app. `setupFee` says whether a bridge from it also pays `coreSetupFee`; it is
127
- * read only when there is something to bridge. Each is `null` when unread or
128
- * unreadable, never 0.
125
+ * position margin. A Portfolio Margin account offers none whatever its spot
126
+ * read says, as in the Totalis app. `setupFee` says whether a bridge from it
127
+ * also pays `coreSetupFee`; it is read only when there is something to
128
+ * bridge. Each is `null` when unread or unreadable, never 0, and all three
129
+ * are `null` when the spot read is Portfolio Margin's and the mode read is not.
129
130
  */
130
131
  export type CoreCash = {
131
132
  readonly mode: CoreAccountMode | null;
package/dist/hypercore.js CHANGED
@@ -198,8 +198,13 @@ export async function readCoreCash(network, account, info = hyperliquidInfo(), s
198
198
  info(network, { type: "spotClearinghouseState", user: account }, signal),
199
199
  ]);
200
200
  const mode = coreMode(settledValue(modeRead));
201
- const spot = spotUsdc(settledValue(spotRead));
202
- const spendable = mode === null || spot === null ? null : mode === "PORTFOLIO_MARGIN" ? 0n : spot;
201
+ if (mode === "PORTFOLIO_MARGIN")
202
+ return { mode, spendable: 0n, setupFee: null };
203
+ const spotAnswer = settledValue(spotRead);
204
+ if (record(spotAnswer) && spotAnswer.portfolioMarginEnabled === true)
205
+ return { mode: null, spendable: null, setupFee: null };
206
+ const spot = spotUsdc(spotAnswer);
207
+ const spendable = mode === null || spot === null ? null : spot;
203
208
  if (spendable === null || spendable === 0n)
204
209
  return { mode, spendable, setupFee: null };
205
210
  const check = await info(network, { type: "preTransferCheck", user: hyperevmUsdcBridge, source: account }, signal).then(setupFeeCharged, () => null);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@totalis/hip4-client",
3
- "version": "0.109.0",
3
+ "version": "0.110.0",
4
4
  "description": "Totalis HIP-4 SDK: typed HTTP clients, signer-agnostic typed data, a retrying request layer, pagination, a realtime stream and taker/maker flows",
5
5
  "type": "module",
6
6
  "files": [