@yuants/vendor-hyperliquid 0.6.2 → 0.6.3

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.
@@ -1,5 +1,5 @@
1
1
  import { encodePath, formatTime } from '@yuants/utils';
2
- import { getUserOpenOrders, getUserPerpetualsAccountSummary } from '../../api/public-api';
2
+ import { getUserPerpetualsAccountSummary } from '../../api/public-api';
3
3
  import { getAddressFromCredential } from '../../api/types';
4
4
  /**
5
5
  * Get account info for perpetual account
@@ -7,7 +7,6 @@ import { getAddressFromCredential } from '../../api/types';
7
7
  export const getPerpAccountInfo = async (credential, account_id) => {
8
8
  console.info(`[${formatTime(Date.now())}] Getting perp account info for ${account_id}`);
9
9
  const summary = await getUserPerpetualsAccountSummary({ user: getAddressFromCredential(credential) });
10
- const orders = await getUserOpenOrders({ user: getAddressFromCredential(credential) });
11
10
  // Map positions
12
11
  const positions = summary.assetPositions.map((position) => ({
13
12
  position_id: `${position.position.coin}-USD`,
@@ -33,27 +32,6 @@ export const getPerpAccountInfo = async (credential, account_id) => {
33
32
  }
34
33
  return 'OPEN_LONG';
35
34
  };
36
- const pending_orders = orders.map((order) => {
37
- var _a, _b;
38
- return ({
39
- order_id: `${order.oid}`,
40
- account_id,
41
- product_id: encodePath('PERPETUAL', `${(_a = order.coin) === null || _a === void 0 ? void 0 : _a.trim()}-USD`),
42
- order_type: 'LIMIT',
43
- order_direction: mapOrderDirection(order.side),
44
- volume: Number(order.sz) || 0,
45
- price: Number(order.limitPx) || undefined,
46
- submit_at: Number((_b = order.timestamp) !== null && _b !== void 0 ? _b : Date.now()),
47
- });
48
- });
49
- return {
50
- money: {
51
- currency: 'USD',
52
- equity: +summary.crossMarginSummary.accountValue,
53
- free: +summary.withdrawable,
54
- },
55
- positions,
56
- pending_orders,
57
- };
35
+ return positions;
58
36
  };
59
37
  //# sourceMappingURL=perp.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"perp.js","sourceRoot":"","sources":["../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,CAAC,SAAS,mCAAI,IAAI,CAAC,GAAG,EAAE,CAAC;SACjD,CAAC,CAAA;KAAA,CAAC,CAAC;IAEJ,OAAO;QACL,KAAK,EAAE;YACL,QAAQ,EAAE,KAAK;YACf,MAAM,EAAE,CAAC,OAAO,CAAC,kBAAkB,CAAC,YAAY;YAChD,IAAI,EAAE,CAAC,OAAO,CAAC,YAAY;SAC5B;QACD,SAAS;QACT,cAAc;KACf,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import { IPosition } from '@yuants/data-account';\nimport { encodePath, formatTime } from '@yuants/utils';\nimport { getUserOpenOrders, getUserPerpetualsAccountSummary } from '../../api/public-api';\nimport { getAddressFromCredential, ICredential } from '../../api/types';\n\n/**\n * Get account info for perpetual account\n */\nexport const getPerpAccountInfo = async (credential: ICredential, account_id: string) => {\n console.info(`[${formatTime(Date.now())}] Getting perp account info for ${account_id}`);\n\n const summary = await getUserPerpetualsAccountSummary({ user: getAddressFromCredential(credential) });\n const orders = await getUserOpenOrders({ user: getAddressFromCredential(credential) });\n\n // Map positions\n const positions = summary.assetPositions.map(\n (position): IPosition => ({\n position_id: `${position.position.coin}-USD`,\n datasource_id: 'HYPERLIQUID',\n product_id: encodePath('PERPETUAL', `${position.position.coin}-USD`),\n direction: +position.position.szi > 0 ? 'LONG' : 'SHORT',\n volume: Math.abs(+position.position.szi),\n free_volume: Math.abs(+position.position.szi),\n position_price: +position.position.entryPx,\n closable_price: Math.abs(+position.position.positionValue / +position.position.szi || 0),\n floating_profit: +position.position.unrealizedPnl,\n valuation: +position.position.positionValue,\n margin: +position.position.marginUsed,\n }),\n );\n\n // Map orders\n const mapOrderDirection = (side: string) => {\n const normalized = side.toUpperCase();\n if (normalized === 'BID' || normalized === 'BUY') {\n return 'OPEN_LONG';\n }\n if (normalized === 'ASK' || normalized === 'SELL') {\n return 'OPEN_SHORT';\n }\n return 'OPEN_LONG';\n };\n\n const pending_orders = orders.map((order) => ({\n order_id: `${order.oid}`,\n account_id,\n product_id: encodePath('PERPETUAL', `${order.coin?.trim()}-USD`),\n order_type: 'LIMIT',\n order_direction: mapOrderDirection(order.side),\n volume: Number(order.sz) || 0,\n price: Number(order.limitPx) || undefined,\n submit_at: Number(order.timestamp ?? Date.now()),\n }));\n\n return {\n money: {\n currency: 'USD',\n equity: +summary.crossMarginSummary.accountValue,\n free: +summary.withdrawable,\n },\n positions,\n pending_orders,\n };\n};\n"]}
1
+ {"version":3,"file":"perp.js","sourceRoot":"","sources":["../../../src/services/accounts/perp.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,EAAE,+BAA+B,EAAE,MAAM,sBAAsB,CAAC;AACvE,OAAO,EAAE,wBAAwB,EAAe,MAAM,iBAAiB,CAAC;AAExE;;GAEG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,KAAK,EAAE,UAAuB,EAAE,UAAkB,EAAE,EAAE;IACtF,OAAO,CAAC,IAAI,CAAC,IAAI,UAAU,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,mCAAmC,UAAU,EAAE,CAAC,CAAC;IAExF,MAAM,OAAO,GAAG,MAAM,+BAA+B,CAAC,EAAE,IAAI,EAAE,wBAAwB,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC;IAEtG,gBAAgB;IAChB,MAAM,SAAS,GAAG,OAAO,CAAC,cAAc,CAAC,GAAG,CAC1C,CAAC,QAAQ,EAAa,EAAE,CAAC,CAAC;QACxB,WAAW,EAAE,GAAG,QAAQ,CAAC,QAAQ,CAAC,IAAI,MAAM;QAC5C,aAAa,EAAE,aAAa;QAC5B,UAAU,EAAE,UAAU,CAAC,WAAW,EAAE,GAAG,QAAQ,CAAC,QAAQ,CAAC,IAAI,MAAM,CAAC;QACpE,SAAS,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO;QACxD,MAAM,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC;QACxC,WAAW,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC;QAC7C,cAAc,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,OAAO;QAC1C,cAAc,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,aAAa,GAAG,CAAC,QAAQ,CAAC,QAAQ,CAAC,GAAG,IAAI,CAAC,CAAC;QACxF,eAAe,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,aAAa;QACjD,SAAS,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,aAAa;QAC3C,MAAM,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,UAAU;KACtC,CAAC,CACH,CAAC;IAEF,aAAa;IACb,MAAM,iBAAiB,GAAG,CAAC,IAAY,EAAE,EAAE;QACzC,MAAM,UAAU,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;QACtC,IAAI,UAAU,KAAK,KAAK,IAAI,UAAU,KAAK,KAAK,EAAE;YAChD,OAAO,WAAW,CAAC;SACpB;QACD,IAAI,UAAU,KAAK,KAAK,IAAI,UAAU,KAAK,MAAM,EAAE;YACjD,OAAO,YAAY,CAAC;SACrB;QACD,OAAO,WAAW,CAAC;IACrB,CAAC,CAAC;IAEF,OAAO,SAAS,CAAC;AACnB,CAAC,CAAC","sourcesContent":["import { IPosition } from '@yuants/data-account';\nimport { encodePath, formatTime } from '@yuants/utils';\nimport { getUserPerpetualsAccountSummary } from '../../api/public-api';\nimport { getAddressFromCredential, ICredential } from '../../api/types';\n\n/**\n * Get account info for perpetual account\n */\nexport const getPerpAccountInfo = async (credential: ICredential, account_id: string) => {\n console.info(`[${formatTime(Date.now())}] Getting perp account info for ${account_id}`);\n\n const summary = await getUserPerpetualsAccountSummary({ user: getAddressFromCredential(credential) });\n\n // Map positions\n const positions = summary.assetPositions.map(\n (position): IPosition => ({\n position_id: `${position.position.coin}-USD`,\n datasource_id: 'HYPERLIQUID',\n product_id: encodePath('PERPETUAL', `${position.position.coin}-USD`),\n direction: +position.position.szi > 0 ? 'LONG' : 'SHORT',\n volume: Math.abs(+position.position.szi),\n free_volume: Math.abs(+position.position.szi),\n position_price: +position.position.entryPx,\n closable_price: Math.abs(+position.position.positionValue / +position.position.szi || 0),\n floating_profit: +position.position.unrealizedPnl,\n valuation: +position.position.positionValue,\n margin: +position.position.marginUsed,\n }),\n );\n\n // Map orders\n const mapOrderDirection = (side: string) => {\n const normalized = side.toUpperCase();\n if (normalized === 'BID' || normalized === 'BUY') {\n return 'OPEN_LONG';\n }\n if (normalized === 'ASK' || normalized === 'SELL') {\n return 'OPEN_SHORT';\n }\n return 'OPEN_LONG';\n };\n\n return positions;\n};\n"]}
@@ -1,3 +1,4 @@
1
+ import { makeSpotPosition } from '@yuants/data-account';
1
2
  import { encodePath, formatTime } from '@yuants/utils';
2
3
  import { getUserTokenBalances } from '../../api/public-api';
3
4
  import { getAddressFromCredential } from '../../api/types';
@@ -10,27 +11,14 @@ export const getSpotAccountInfo = async (credential, account_id) => {
10
11
  // Map token balances to positions (using spot as "positions")
11
12
  const positions = balances.balances
12
13
  .filter((balance) => Number(balance.total) > 0)
13
- .map((balance) => ({
14
+ .map((balance) => makeSpotPosition({
14
15
  position_id: `${balance.coin}`,
15
16
  datasource_id: 'HYPERLIQUID',
16
17
  product_id: encodePath('SPOT', `${balance.coin}-USDC`),
17
- direction: 'LONG',
18
18
  volume: Number(balance.total),
19
19
  free_volume: Number(balance.total) - Number(balance.hold),
20
- position_price: 1,
21
20
  closable_price: 1,
22
- floating_profit: 0,
23
- valuation: Number(balance.total),
24
- margin: 0,
25
21
  }));
26
- return {
27
- money: {
28
- currency: 'USDC',
29
- equity: positions.reduce((sum, pos) => sum + pos.valuation, 0),
30
- free: positions.reduce((sum, pos) => sum + pos.free_volume, 0),
31
- },
32
- positions,
33
- pending_orders: [], // Spot orders would need separate API call
34
- };
22
+ return positions;
35
23
  };
36
24
  //# sourceMappingURL=spot.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"spot.js","sourceRoot":"","sources":["../../../src/services/accounts/spot.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAE,wBAAwB,EAAe,MAAM,iBAAiB,CAAC;AAExE;;GAEG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,KAAK,EAAE,UAAuB,EAAE,UAAkB,EAAE,EAAE;IACtF,OAAO,CAAC,IAAI,CAAC,IAAI,UAAU,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,mCAAmC,UAAU,EAAE,CAAC,CAAC;IAExF,MAAM,QAAQ,GAAG,MAAM,oBAAoB,CAAC,EAAE,IAAI,EAAE,wBAAwB,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC;IAE5F,8DAA8D;IAC9D,MAAM,SAAS,GAAG,QAAQ,CAAC,QAAQ;SAChC,MAAM,CAAC,CAAC,OAAY,EAAE,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;SACnD,GAAG,CACF,CAAC,OAAY,EAAa,EAAE,CAAC,CAAC;QAC5B,WAAW,EAAE,GAAG,OAAO,CAAC,IAAI,EAAE;QAC9B,aAAa,EAAE,aAAa;QAC5B,UAAU,EAAE,UAAU,CAAC,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,OAAO,CAAC;QACtD,SAAS,EAAE,MAAM;QACjB,MAAM,EAAE,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC;QAC7B,WAAW,EAAE,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC;QACzD,cAAc,EAAE,CAAC;QACjB,cAAc,EAAE,CAAC;QACjB,eAAe,EAAE,CAAC;QAClB,SAAS,EAAE,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC;QAChC,MAAM,EAAE,CAAC;KACV,CAAC,CACH,CAAC;IAEJ,OAAO;QACL,KAAK,EAAE;YACL,QAAQ,EAAE,MAAM;YAChB,MAAM,EAAE,SAAS,CAAC,MAAM,CAAC,CAAC,GAAW,EAAE,GAAQ,EAAE,EAAE,CAAC,GAAG,GAAG,GAAG,CAAC,SAAS,EAAE,CAAC,CAAC;YAC3E,IAAI,EAAE,SAAS,CAAC,MAAM,CAAC,CAAC,GAAW,EAAE,GAAQ,EAAE,EAAE,CAAC,GAAG,GAAG,GAAG,CAAC,WAAW,EAAE,CAAC,CAAC;SAC5E;QACD,SAAS;QACT,cAAc,EAAE,EAAE,EAAE,2CAA2C;KAChE,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import { IPosition } from '@yuants/data-account';\nimport { encodePath, formatTime } from '@yuants/utils';\nimport { getUserTokenBalances } from '../../api/public-api';\nimport { getAddressFromCredential, ICredential } from '../../api/types';\n\n/**\n * Get account info for spot account\n */\nexport const getSpotAccountInfo = async (credential: ICredential, account_id: string) => {\n console.info(`[${formatTime(Date.now())}] Getting spot account info for ${account_id}`);\n\n const balances = await getUserTokenBalances({ user: getAddressFromCredential(credential) });\n\n // Map token balances to positions (using spot as \"positions\")\n const positions = balances.balances\n .filter((balance: any) => Number(balance.total) > 0)\n .map(\n (balance: any): IPosition => ({\n position_id: `${balance.coin}`,\n datasource_id: 'HYPERLIQUID',\n product_id: encodePath('SPOT', `${balance.coin}-USDC`),\n direction: 'LONG',\n volume: Number(balance.total),\n free_volume: Number(balance.total) - Number(balance.hold),\n position_price: 1, // USDC as quote currency\n closable_price: 1,\n floating_profit: 0,\n valuation: Number(balance.total),\n margin: 0,\n }),\n );\n\n return {\n money: {\n currency: 'USDC',\n equity: positions.reduce((sum: number, pos: any) => sum + pos.valuation, 0),\n free: positions.reduce((sum: number, pos: any) => sum + pos.free_volume, 0),\n },\n positions,\n pending_orders: [], // Spot orders would need separate API call\n };\n};\n"]}
1
+ {"version":3,"file":"spot.js","sourceRoot":"","sources":["../../../src/services/accounts/spot.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACnE,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAE,wBAAwB,EAAe,MAAM,iBAAiB,CAAC;AAExE;;GAEG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,KAAK,EAAE,UAAuB,EAAE,UAAkB,EAAE,EAAE;IACtF,OAAO,CAAC,IAAI,CAAC,IAAI,UAAU,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,mCAAmC,UAAU,EAAE,CAAC,CAAC;IAExF,MAAM,QAAQ,GAAG,MAAM,oBAAoB,CAAC,EAAE,IAAI,EAAE,wBAAwB,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC;IAE5F,8DAA8D;IAC9D,MAAM,SAAS,GAAG,QAAQ,CAAC,QAAQ;SAChC,MAAM,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;SAC9C,GAAG,CACF,CAAC,OAAO,EAAa,EAAE,CACrB,gBAAgB,CAAC;QACf,WAAW,EAAE,GAAG,OAAO,CAAC,IAAI,EAAE;QAC9B,aAAa,EAAE,aAAa;QAC5B,UAAU,EAAE,UAAU,CAAC,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,OAAO,CAAC;QACtD,MAAM,EAAE,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC;QAC7B,WAAW,EAAE,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC;QACzD,cAAc,EAAE,CAAC;KAClB,CAAC,CACL,CAAC;IAEJ,OAAO,SAAS,CAAC;AACnB,CAAC,CAAC","sourcesContent":["import { IPosition, makeSpotPosition } from '@yuants/data-account';\nimport { encodePath, formatTime } from '@yuants/utils';\nimport { getUserTokenBalances } from '../../api/public-api';\nimport { getAddressFromCredential, ICredential } from '../../api/types';\n\n/**\n * Get account info for spot account\n */\nexport const getSpotAccountInfo = async (credential: ICredential, account_id: string) => {\n console.info(`[${formatTime(Date.now())}] Getting spot account info for ${account_id}`);\n\n const balances = await getUserTokenBalances({ user: getAddressFromCredential(credential) });\n\n // Map token balances to positions (using spot as \"positions\")\n const positions = balances.balances\n .filter((balance) => Number(balance.total) > 0)\n .map(\n (balance): IPosition =>\n makeSpotPosition({\n position_id: `${balance.coin}`,\n datasource_id: 'HYPERLIQUID',\n product_id: encodePath('SPOT', `${balance.coin}-USDC`),\n volume: Number(balance.total),\n free_volume: Number(balance.total) - Number(balance.hold),\n closable_price: 1,\n }),\n );\n\n return positions;\n};\n"]}
@@ -5,6 +5,7 @@ import { getAddressFromCredential, getDefaultCredential } from '../api/types';
5
5
  import { getPerpAccountInfo } from './accounts/perp';
6
6
  import { getSpotAccountInfo } from './accounts/spot';
7
7
  import { cancelOrderAction } from './orders/cancelOrder';
8
+ import { listOrders } from './orders/listOrders';
8
9
  import { submitOrder } from './orders/submitOrder';
9
10
  const terminal = Terminal.fromNodeEnv();
10
11
  const credential = getDefaultCredential();
@@ -15,23 +16,10 @@ addAccountMarket(terminal, { account_id: defaultPerpAccountId, market_id: 'HYPER
15
16
  addAccountMarket(terminal, { account_id: defaultSpotAccountId, market_id: 'HYPERLIQUID/SPOT' });
16
17
  provideAccountInfoService(terminal, defaultPerpAccountId, async () => {
17
18
  const info = await getPerpAccountInfo(credential, defaultPerpAccountId);
18
- return {
19
- money: info.money,
20
- positions: info.positions,
21
- orders: info.pending_orders,
22
- };
19
+ return info;
23
20
  }, { auto_refresh_interval: 1000 });
24
- providePendingOrdersService(terminal, defaultPerpAccountId, async () => {
25
- const info = await getPerpAccountInfo(credential, defaultPerpAccountId);
26
- return info.pending_orders;
27
- }, { auto_refresh_interval: 2000 });
28
- provideAccountInfoService(terminal, defaultSpotAccountId, async () => {
29
- const info = await getSpotAccountInfo(credential, defaultSpotAccountId);
30
- return {
31
- money: info.money,
32
- positions: info.positions,
33
- };
34
- }, { auto_refresh_interval: 5000 });
21
+ providePendingOrdersService(terminal, defaultPerpAccountId, async () => listOrders(credential, defaultPerpAccountId), { auto_refresh_interval: 2000 });
22
+ provideAccountInfoService(terminal, defaultSpotAccountId, async () => getSpotAccountInfo(credential, defaultSpotAccountId), { auto_refresh_interval: 5000 });
35
23
  terminal.server.provideService('SubmitOrder', {
36
24
  required: ['account_id', 'product_id', 'order_type', 'order_direction', 'volume'],
37
25
  properties: {
@@ -1 +1 @@
1
- {"version":3,"file":"legacy.js","sourceRoot":"","sources":["../../src/services/legacy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;AACnF,OAAO,EAAU,2BAA2B,EAAE,MAAM,oBAAoB,CAAC;AACzE,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,wBAAwB,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAC9E,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAEnD,MAAM,QAAQ,GAAG,QAAQ,CAAC,WAAW,EAAE,CAAC;AACxC,MAAM,UAAU,GAAG,oBAAoB,EAAE,CAAC;AAC1C,MAAM,aAAa,GAAG,wBAAwB,CAAC,UAAU,CAAC,CAAC,WAAW,EAAE,CAAC;AACzE,MAAM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E,QAAQ,EAAE,CAAC,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE,iBAAiB,EAAE,QAAQ,CAAC;IACjF,UAAU,EAAE;QACV,UAAU,EAAE,EAAE,KAAK,EAAE,oBAAoB,EAAE;KAC5C;CACF,EACD,KAAK,EAAE,GAAG,EAAE,EAAE;IACZ,OAAO;QACL,GAAG,EAAE;YACH,IAAI,EAAE,CAAC;YACP,OAAO,EAAE,IAAI;YACb,IAAI,EAAE,MAAM,WAAW,CAAC,UAAU,EAAE,GAAG,CAAC,GAAG,CAAC;SAC7C;KACF,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,QAAQ,CAAC,MAAM,CAAC,cAAc,CAC5B,aAAa,EACb;IACE,QAAQ,EAAE,CAAC,YAAY,EAAE,UAAU,EAAE,YAAY,CAAC;IAClD,UAAU,EAAE;QACV,UAAU,EAAE,EAAE,KAAK,EAAE,oBAAoB,EAAE;KAC5C;CACF,EACD,KAAK,EAAE,GAAG,EAAE,EAAE;IACZ,MAAM,iBAAiB,CAAC,UAAU,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC;IAC7C,OAAO;QACL,GAAG,EAAE;YACH,IAAI,EAAE,CAAC;YACP,OAAO,EAAE,IAAI;SACd;KACF,CAAC;AACJ,CAAC,CACF,CAAC","sourcesContent":["import { addAccountMarket, provideAccountInfoService } from '@yuants/data-account';\nimport { IOrder, providePendingOrdersService } from '@yuants/data-order';\nimport { Terminal } from '@yuants/protocol';\nimport { getAddressFromCredential, getDefaultCredential } from '../api/types';\nimport { getPerpAccountInfo } from './accounts/perp';\nimport { getSpotAccountInfo } from './accounts/spot';\nimport { cancelOrderAction } from './orders/cancelOrder';\nimport { submitOrder } from './orders/submitOrder';\n\nconst terminal = Terminal.fromNodeEnv();\nconst credential = getDefaultCredential();\nconst walletAddress = getAddressFromCredential(credential).toLowerCase();\nconst defaultPerpAccountId = `hyperliquid/${walletAddress}/perp`;\nconst defaultSpotAccountId = `hyperliquid/${walletAddress}/spot`;\n\naddAccountMarket(terminal, { account_id: defaultPerpAccountId, market_id: 'HYPERLIQUID/PERP' });\naddAccountMarket(terminal, { account_id: defaultSpotAccountId, market_id: 'HYPERLIQUID/SPOT' });\n\nprovideAccountInfoService(\n terminal,\n defaultPerpAccountId,\n async () => {\n const info = await getPerpAccountInfo(credential, defaultPerpAccountId);\n return {\n money: info.money,\n positions: info.positions,\n orders: info.pending_orders,\n };\n },\n { auto_refresh_interval: 1000 },\n);\n\nprovidePendingOrdersService(\n terminal,\n defaultPerpAccountId,\n async () => {\n const info = await getPerpAccountInfo(credential, defaultPerpAccountId);\n return info.pending_orders;\n },\n { auto_refresh_interval: 2000 },\n);\n\nprovideAccountInfoService(\n terminal,\n defaultSpotAccountId,\n async () => {\n const info = await getSpotAccountInfo(credential, defaultSpotAccountId);\n return {\n money: info.money,\n positions: info.positions,\n };\n },\n { auto_refresh_interval: 5000 },\n);\n\nterminal.server.provideService<IOrder, { order_id?: string }>(\n 'SubmitOrder',\n {\n required: ['account_id', 'product_id', 'order_type', 'order_direction', 'volume'],\n properties: {\n account_id: { const: defaultPerpAccountId },\n },\n },\n async (msg) => {\n return {\n res: {\n code: 0,\n message: 'OK',\n data: await submitOrder(credential, msg.req),\n },\n };\n },\n);\n\nterminal.server.provideService<IOrder>(\n 'CancelOrder',\n {\n required: ['account_id', 'order_id', 'product_id'],\n properties: {\n account_id: { const: defaultPerpAccountId },\n },\n },\n async (msg) => {\n await cancelOrderAction(credential, msg.req);\n return {\n res: {\n code: 0,\n message: 'OK',\n },\n };\n },\n);\n"]}
1
+ {"version":3,"file":"legacy.js","sourceRoot":"","sources":["../../src/services/legacy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;AACnF,OAAO,EAAU,2BAA2B,EAAE,MAAM,oBAAoB,CAAC;AACzE,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,wBAAw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AAI,EAAE,CAAC,kBAAkB,CAAC,UAAU,EAAE,oBAAoB,CAAC,EAChE,EAAE,qBAAqB,EAAE,IAAI,EAAE,CAChC,CAAC;AAEF,QAAQ,CAAC,MAAM,CAAC,cAAc,CAC5B,aAAa,EACb;IACE,QAAQ,EAAE,CAAC,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE,iBAAiB,EAAE,QAAQ,CAAC;IACjF,UAAU,EAAE;QACV,UAAU,EAAE,EAAE,KAAK,EAAE,oBAAoB,EAAE;KAC5C;CACF,EACD,KAAK,EAAE,GAAG,EAAE,EAAE;IACZ,OAAO;QACL,GAAG,EAAE;YACH,IAAI,EAAE,CAAC;YACP,OAAO,EAAE,IAAI;YACb,IAAI,EAAE,MAAM,WAAW,CAAC,UAAU,EAAE,GAAG,CAAC,GAAG,CAAC;SAC7C;KACF,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,QAAQ,CAAC,MAAM,CAAC,cAAc,CAC5B,aAAa,EACb;IACE,QAAQ,EAAE,CAAC,YAAY,EAAE,UAAU,EAAE,YAAY,CAAC;IAClD,UAAU,EAAE;QACV,UAAU,EAAE,EAAE,KAAK,EAAE,oBAAoB,EAAE;KAC5C;CACF,EACD,KAAK,EAAE,GAAG,EAAE,EAAE;IACZ,MAAM,iBAAiB,CAAC,UAAU,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC;IAC7C,OAAO;QACL,GAAG,EAAE;YACH,IAAI,EAAE,CAAC;YACP,OAAO,EAAE,IAAI;SACd;KACF,CAAC;AACJ,CAAC,CACF,CAAC","sourcesContent":["import { addAccountMarket, provideAccountInfoService } from '@yuants/data-account';\nimport { IOrder, providePendingOrdersService } from '@yuants/data-order';\nimport { Terminal } from '@yuants/protocol';\nimport { getAddressFromCredential, getDefaultCredential } from '../api/types';\nimport { getPerpAccountInfo } from './accounts/perp';\nimport { getSpotAccountInfo } from './accounts/spot';\nimport { cancelOrderAction } from './orders/cancelOrder';\nimport { listOrders } from './orders/listOrders';\nimport { submitOrder } from './orders/submitOrder';\n\nconst terminal = Terminal.fromNodeEnv();\nconst credential = getDefaultCredential();\nconst walletAddress = getAddressFromCredential(credential).toLowerCase();\nconst defaultPerpAccountId = `hyperliquid/${walletAddress}/perp`;\nconst defaultSpotAccountId = `hyperliquid/${walletAddress}/spot`;\n\naddAccountMarket(terminal, { account_id: defaultPerpAccountId, market_id: 'HYPERLIQUID/PERP' });\naddAccountMarket(terminal, { account_id: defaultSpotAccountId, market_id: 'HYPERLIQUID/SPOT' });\n\nprovideAccountInfoService(\n terminal,\n defaultPerpAccountId,\n async () => {\n const info = await getPerpAccountInfo(credential, defaultPerpAccountId);\n return info;\n },\n { auto_refresh_interval: 1000 },\n);\n\nprovidePendingOrdersService(\n terminal,\n defaultPerpAccountId,\n async () => listOrders(credential, defaultPerpAccountId),\n { auto_refresh_interval: 2000 },\n);\n\nprovideAccountInfoService(\n terminal,\n defaultSpotAccountId,\n async () => getSpotAccountInfo(credential, defaultSpotAccountId),\n { auto_refresh_interval: 5000 },\n);\n\nterminal.server.provideService<IOrder, { order_id?: string }>(\n 'SubmitOrder',\n {\n required: ['account_id', 'product_id', 'order_type', 'order_direction', 'volume'],\n properties: {\n account_id: { const: defaultPerpAccountId },\n },\n },\n async (msg) => {\n return {\n res: {\n code: 0,\n message: 'OK',\n data: await submitOrder(credential, msg.req),\n },\n };\n },\n);\n\nterminal.server.provideService<IOrder>(\n 'CancelOrder',\n {\n required: ['account_id', 'order_id', 'product_id'],\n properties: {\n account_id: { const: defaultPerpAccountId },\n },\n },\n async (msg) => {\n await cancelOrderAction(credential, msg.req);\n return {\n res: {\n code: 0,\n message: 'OK',\n },\n };\n },\n);\n"]}
@@ -3,22 +3,5 @@ import { ICredential } from '../../api/types';
3
3
  /**
4
4
  * Get account info for perpetual account
5
5
  */
6
- export declare const getPerpAccountInfo: (credential: ICredential, account_id: string) => Promise<{
7
- money: {
8
- currency: string;
9
- equity: number;
10
- free: number;
11
- };
12
- positions: IPosition[];
13
- pending_orders: {
14
- order_id: string;
15
- account_id: string;
16
- product_id: string;
17
- order_type: string;
18
- order_direction: string;
19
- volume: number;
20
- price: number | undefined;
21
- submit_at: number;
22
- }[];
23
- }>;
6
+ export declare const getPerpAccountInfo: (credential: ICredential, account_id: string) => Promise<IPosition[]>;
24
7
  //# sourceMappingURL=perp.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"perp.d.ts","sourceRoot":"","sources":["../../../src/services/accounts/perp.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAGjD,OAAO,EAA4B,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAExE;;GAEG;AACH,eAAO,MAAM,kBAAkB,eAAsB,WAAW,cAAc,MAAM;;;;;;;;;;;;;;;;;EAuDnF,CAAC"}
1
+ {"version":3,"file":"perp.d.ts","sourceRoot":"","sources":["../../../src/services/accounts/perp.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAGjD,OAAO,EAA4B,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAExE;;GAEG;AACH,eAAO,MAAM,kBAAkB,eAAsB,WAAW,cAAc,MAAM,yBAmCnF,CAAC"}
@@ -10,7 +10,6 @@ const types_1 = require("../../api/types");
10
10
  const getPerpAccountInfo = async (credential, account_id) => {
11
11
  console.info(`[${(0, utils_1.formatTime)(Date.now())}] Getting perp account info for ${account_id}`);
12
12
  const summary = await (0, public_api_1.getUserPerpetualsAccountSummary)({ user: (0, types_1.getAddressFromCredential)(credential) });
13
- const orders = await (0, public_api_1.getUserOpenOrders)({ user: (0, types_1.getAddressFromCredential)(credential) });
14
13
  // Map positions
15
14
  const positions = summary.assetPositions.map((position) => ({
16
15
  position_id: `${position.position.coin}-USD`,
@@ -36,28 +35,7 @@ const getPerpAccountInfo = async (credential, account_id) => {
36
35
  }
37
36
  return 'OPEN_LONG';
38
37
  };
39
- const pending_orders = orders.map((order) => {
40
- var _a, _b;
41
- return ({
42
- order_id: `${order.oid}`,
43
- account_id,
44
- product_id: (0, utils_1.encodePath)('PERPETUAL', `${(_a = order.coin) === null || _a === void 0 ? void 0 : _a.trim()}-USD`),
45
- order_type: 'LIMIT',
46
- order_direction: mapOrderDirection(order.side),
47
- volume: Number(order.sz) || 0,
48
- price: Number(order.limitPx) || undefined,
49
- submit_at: Number((_b = order.timestamp) !== null && _b !== void 0 ? _b : Date.now()),
50
- });
51
- });
52
- return {
53
- money: {
54
- currency: 'USD',
55
- equity: +summary.crossMarginSummary.accountValue,
56
- free: +summary.withdrawable,
57
- },
58
- positions,
59
- pending_orders,
60
- };
38
+ return positions;
61
39
  };
62
40
  exports.getPerpAccountInfo = getPerpAccountInfo;
63
41
  //# sourceMappingURL=perp.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"perp.js","sourceRoot":"","sources":["../../../src/services/accounts/perp.ts"],"names":[],"mappings":";;;AACA,yCAAuD;AACvD,qDAA0F;AAC1F,2CAAwE;AAExE;;GAEG;AACI,MAAM,kBAAkB,GAAG,KAAK,EAAE,UAAuB,EAAE,UAAkB,EAAE,EAAE;IACtF,OAAO,CAAC,IAAI,CAAC,IAAI,IAAA,kBAAU,EAAC,IAAI,CAAC,GAAG,EAAE,CAAC,mCAAmC,UAAU,EAAE,CAAC,CAAC;IAExF,MAAM,OAAO,GAAG,MAAM,IAAA,4CAA+B,EAAC,EAAE,IAAI,EAAE,IAAA,gCAAwB,EAAC,UAAU,CAAC,EAAE,CAAC,CAAC;IACtG,MAAM,MAAM,GAAG,MAAM,IAAA,8BAAiB,EAAC,EAAE,IAAI,EAAE,IAAA,gCAAwB,EAAC,UAAU,CAAC,EAAE,CAAC,CAAC;IAEvF,gBAAgB;IAChB,MAAM,SAAS,GAAG,OAAO,CAAC,cAAc,CAAC,GAAG,CAC1C,CAAC,QAAQ,EAAa,EAAE,CAAC,CAAC;QACxB,WAAW,EAAE,GAAG,QAAQ,CAAC,QAAQ,CAAC,IAAI,MAA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AA,CAAC;YAC5C,QAAQ,EAAE,GAAG,KAAK,CAAC,GAAG,EAAE;YACxB,UAAU;YACV,UAAU,EAAE,IAAA,kBAAU,EAAC,WAAW,EAAE,GAAG,MAAA,KAAK,CAAC,IAAI,0CAAE,IAAI,EAAE,MAAM,CAAC;YAChE,UAAU,EAAE,OAAO;YACnB,eAAe,EAAE,iBAAiB,CAAC,KAAK,CAAC,IAAI,CAAC;YAC9C,MAAM,EAAE,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,IAAI,CAAC;YAC7B,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,SAAS;YACzC,SAAS,EAAE,MAAM,CAAC,MAAA,KAAK,CAAC,SAAS,mCAAI,IAAI,CAAC,GAAG,EAAE,CAAC;SACjD,CAAC,CAAA;KAAA,CAAC,CAAC;IAEJ,OAAO;QACL,KAAK,EAAE;YACL,QAAQ,EAAE,KAAK;YACf,MAAM,EAAE,CAAC,OAAO,CAAC,kBAAkB,CAAC,YAAY;YAChD,IAAI,EAAE,CAAC,OAAO,CAAC,YAAY;SAC5B;QACD,SAAS;QACT,cAAc;KACf,CAAC;AACJ,CAAC,CAAC;AAvDW,QAAA,kBAAkB,sBAuD7B","sourcesContent":["import { IPosition } from '@yuants/data-account';\nimport { encodePath, formatTime } from '@yuants/utils';\nimport { getUserOpenOrders, getUserPerpetualsAccountSummary } from '../../api/public-api';\nimport { getAddressFromCredential, ICredential } from '../../api/types';\n\n/**\n * Get account info for perpetual account\n */\nexport const getPerpAccountInfo = async (credential: ICredential, account_id: string) => {\n console.info(`[${formatTime(Date.now())}] Getting perp account info for ${account_id}`);\n\n const summary = await getUserPerpetualsAccountSummary({ user: getAddressFromCredential(credential) });\n const orders = await getUserOpenOrders({ user: getAddressFromCredential(credential) });\n\n // Map positions\n const positions = summary.assetPositions.map(\n (position): IPosition => ({\n position_id: `${position.position.coin}-USD`,\n datasource_id: 'HYPERLIQUID',\n product_id: encodePath('PERPETUAL', `${position.position.coin}-USD`),\n direction: +position.position.szi > 0 ? 'LONG' : 'SHORT',\n volume: Math.abs(+position.position.szi),\n free_volume: Math.abs(+position.position.szi),\n position_price: +position.position.entryPx,\n closable_price: Math.abs(+position.position.positionValue / +position.position.szi || 0),\n floating_profit: +position.position.unrealizedPnl,\n valuation: +position.position.positionValue,\n margin: +position.position.marginUsed,\n }),\n );\n\n // Map orders\n const mapOrderDirection = (side: string) => {\n const normalized = side.toUpperCase();\n if (normalized === 'BID' || normalized === 'BUY') {\n return 'OPEN_LONG';\n }\n if (normalized === 'ASK' || normalized === 'SELL') {\n return 'OPEN_SHORT';\n }\n return 'OPEN_LONG';\n };\n\n const pending_orders = orders.map((order) => ({\n order_id: `${order.oid}`,\n account_id,\n product_id: encodePath('PERPETUAL', `${order.coin?.trim()}-USD`),\n order_type: 'LIMIT',\n order_direction: mapOrderDirection(order.side),\n volume: Number(order.sz) || 0,\n price: Number(order.limitPx) || undefined,\n submit_at: Number(order.timestamp ?? Date.now()),\n }));\n\n return {\n money: {\n currency: 'USD',\n equity: +summary.crossMarginSummary.accountValue,\n free: +summary.withdrawable,\n },\n positions,\n pending_orders,\n };\n};\n"]}
1
+ {"version":3,"file":"perp.js","sourceRoot":"","sources":["../../../src/services/accounts/perp.ts"],"names":[],"mappings":";;;AACA,yCAAuD;AACvD,qDAAuE;AACvE,2CAAwE;AAExE;;GAEG;AACI,MAAM,kBAAkB,GAAG,KAAK,EAAE,UAAuB,EAAE,UAAkB,EAAE,EAAE;IACtF,OAAO,CAAC,IAAI,CAAC,IAAI,IAAA,kBAAU,EAAC,IAAI,CAAC,GAAG,EAAE,CAAC,mCAAmC,UAAU,EAAE,CAAC,CAAC;IAExF,MAAM,OAAO,GAAG,MAAM,IAAA,4CAA+B,EAAC,EAAE,IAAI,EAAE,IAAA,gCAAwB,EAAC,UAAU,CAAC,EAAE,CAAC,CAAC;IAEtG,gBAAgB;IAChB,MAAM,SAAS,GAAG,OAAO,CAAC,cAAc,CAAC,GA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W,CAAC;IACrB,CAAC,CAAC;IAEF,OAAO,SAAS,CAAC;AACnB,CAAC,CAAC;AAnCW,QAAA,kBAAkB,sBAmC7B","sourcesContent":["import { IPosition } from '@yuants/data-account';\nimport { encodePath, formatTime } from '@yuants/utils';\nimport { getUserPerpetualsAccountSummary } from '../../api/public-api';\nimport { getAddressFromCredential, ICredential } from '../../api/types';\n\n/**\n * Get account info for perpetual account\n */\nexport const getPerpAccountInfo = async (credential: ICredential, account_id: string) => {\n console.info(`[${formatTime(Date.now())}] Getting perp account info for ${account_id}`);\n\n const summary = await getUserPerpetualsAccountSummary({ user: getAddressFromCredential(credential) });\n\n // Map positions\n const positions = summary.assetPositions.map(\n (position): IPosition => ({\n position_id: `${position.position.coin}-USD`,\n datasource_id: 'HYPERLIQUID',\n product_id: encodePath('PERPETUAL', `${position.position.coin}-USD`),\n direction: +position.position.szi > 0 ? 'LONG' : 'SHORT',\n volume: Math.abs(+position.position.szi),\n free_volume: Math.abs(+position.position.szi),\n position_price: +position.position.entryPx,\n closable_price: Math.abs(+position.position.positionValue / +position.position.szi || 0),\n floating_profit: +position.position.unrealizedPnl,\n valuation: +position.position.positionValue,\n margin: +position.position.marginUsed,\n }),\n );\n\n // Map orders\n const mapOrderDirection = (side: string) => {\n const normalized = side.toUpperCase();\n if (normalized === 'BID' || normalized === 'BUY') {\n return 'OPEN_LONG';\n }\n if (normalized === 'ASK' || normalized === 'SELL') {\n return 'OPEN_SHORT';\n }\n return 'OPEN_LONG';\n };\n\n return positions;\n};\n"]}
@@ -3,13 +3,5 @@ import { ICredential } from '../../api/types';
3
3
  /**
4
4
  * Get account info for spot account
5
5
  */
6
- export declare const getSpotAccountInfo: (credential: ICredential, account_id: string) => Promise<{
7
- money: {
8
- currency: string;
9
- equity: number;
10
- free: number;
11
- };
12
- positions: IPosition[];
13
- pending_orders: never[];
14
- }>;
6
+ export declare const getSpotAccountInfo: (credential: ICredential, account_id: string) => Promise<IPosition[]>;
15
7
  //# sourceMappingURL=spot.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"spot.d.ts","sourceRoot":"","sources":["../../../src/services/accounts/spot.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAGjD,OAAO,EAA4B,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAExE;;GAEG;AACH,eAAO,MAAM,kBAAkB,eAAsB,WAAW,cAAc,MAAM;;;;;;;;EAiCnF,CAAC"}
1
+ {"version":3,"file":"spot.d.ts","sourceRoot":"","sources":["../../../src/services/accounts/spot.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAoB,MAAM,sBAAsB,CAAC;AAGnE,OAAO,EAA4B,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAExE;;GAEG;AACH,eAAO,MAAM,kBAAkB,eAAsB,WAAW,cAAc,MAAM,yBAqBnF,CAAC"}
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getSpotAccountInfo = void 0;
4
+ const data_account_1 = require("@yuants/data-account");
4
5
  const utils_1 = require("@yuants/utils");
5
6
  const public_api_1 = require("../../api/public-api");
6
7
  const types_1 = require("../../api/types");
@@ -13,28 +14,15 @@ const getSpotAccountInfo = async (credential, account_id) => {
13
14
  // Map token balances to positions (using spot as "positions")
14
15
  const positions = balances.balances
15
16
  .filter((balance) => Number(balance.total) > 0)
16
- .map((balance) => ({
17
+ .map((balance) => (0, data_account_1.makeSpotPosition)({
17
18
  position_id: `${balance.coin}`,
18
19
  datasource_id: 'HYPERLIQUID',
19
20
  product_id: (0, utils_1.encodePath)('SPOT', `${balance.coin}-USDC`),
20
- direction: 'LONG',
21
21
  volume: Number(balance.total),
22
22
  free_volume: Number(balance.total) - Number(balance.hold),
23
- position_price: 1,
24
23
  closable_price: 1,
25
- floating_profit: 0,
26
- valuation: Number(balance.total),
27
- margin: 0,
28
24
  }));
29
- return {
30
- money: {
31
- currency: 'USDC',
32
- equity: positions.reduce((sum, pos) => sum + pos.valuation, 0),
33
- free: positions.reduce((sum, pos) => sum + pos.free_volume, 0),
34
- },
35
- positions,
36
- pending_orders: [], // Spot orders would need separate API call
37
- };
25
+ return positions;
38
26
  };
39
27
  exports.getSpotAccountInfo = getSpotAccountInfo;
40
28
  //# sourceMappingURL=spot.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"spot.js","sourceRoot":"","sources":["../../../src/services/accounts/spot.ts"],"names":[],"mappings":";;;AACA,yCAAuD;AACvD,qDAA4D;AAC5D,2CAAwE;AAExE;;GAEG;AACI,MAAM,kBAAkB,GAAG,KAAK,EAAE,UAAuB,EAAE,UAAkB,EAAE,EAAE;IACtF,OAAO,CAAC,IAAI,CAAC,IAAI,IAAA,kBAAU,EAAC,IAAI,CAAC,GAAG,EAAE,CAAC,mCAAmC,UAAU,EAAE,CAAC,CAAC;IAExF,MAAM,QAAQ,GAAG,MAAM,IAAA,iCAAoB,EAAC,EAAE,IAAI,EAAE,IAAA,gCAAwB,EAAC,UAAU,CAAC,EAAE,CAAC,CAAC;IAE5F,8DAA8D;IAC9D,MAAM,SAAS,GAAG,QAAQ,CAAC,QAAQ;SAChC,MAAM,CAAC,CAAC,OAAY,EAAE,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;SACnD,GAAG,CACF,CAAC,OAAY,EAAa,EAAE,CAAC,CAAC;QAC5B,WAAW,EAAE,GAAG,OAAO,CAAC,IAAI,EAAE;QAC9B,aAAa,EAAE,aAAa;QAC5B,UAAU,EAAE,IAAA,kBAAU,EAAC,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,OAAO,CAAC;QACtD,SAAS,EAAE,MAAM;QACjB,MAAM,EAAE,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC;QAC7B,WAAW,EAAE,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC;QACzD,cAAc,EAAE,CAAC;QACjB,cAAc,EAAE,CAAC;QACjB,eAAe,EAAE,CAAC;QAClB,SAAS,EAAE,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC;QAChC,MAAM,EAAE,CAAC;KACV,CAAC,CACH,CAAC;IAEJ,OAAO;QACL,KAAK,EAAE;YACL,QAAQ,EAAE,MAAM;YAChB,MAAM,EAAE,SAAS,CAAC,MAAM,CAAC,CAAC,GAAW,EAAE,GAAQ,EAAE,EAAE,CAAC,GAAG,GAAG,GAAG,CAAC,SAAS,EAAE,CAAC,CAAC;YAC3E,IAAI,EAAE,SAAS,CAAC,MAAM,CAAC,CAAC,GAAW,EAAE,GAAQ,EAAE,EAAE,CAAC,GAAG,GAAG,GAAG,CAAC,WAAW,EAAE,CAAC,CAAC;SAC5E;QACD,SAAS;QACT,cAAc,EAAE,EAAE,EAAE,2CAA2C;KAChE,CAAC;AACJ,CAAC,CAAC;AAjCW,QAAA,kBAAkB,sBAiC7B","sourcesContent":["import { IPosition } from '@yuants/data-account';\nimport { encodePath, formatTime } from '@yuants/utils';\nimport { getUserTokenBalances } from '../../api/public-api';\nimport { getAddressFromCredential, ICredential } from '../../api/types';\n\n/**\n * Get account info for spot account\n */\nexport const getSpotAccountInfo = async (credential: ICredential, account_id: string) => {\n console.info(`[${formatTime(Date.now())}] Getting spot account info for ${account_id}`);\n\n const balances = await getUserTokenBalances({ user: getAddressFromCredential(credential) });\n\n // Map token balances to positions (using spot as \"positions\")\n const positions = balances.balances\n .filter((balance: any) => Number(balance.total) > 0)\n .map(\n (balance: any): IPosition => ({\n position_id: `${balance.coin}`,\n datasource_id: 'HYPERLIQUID',\n product_id: encodePath('SPOT', `${balance.coin}-USDC`),\n direction: 'LONG',\n volume: Number(balance.total),\n free_volume: Number(balance.total) - Number(balance.hold),\n position_price: 1, // USDC as quote currency\n closable_price: 1,\n floating_profit: 0,\n valuation: Number(balance.total),\n margin: 0,\n }),\n );\n\n return {\n money: {\n currency: 'USDC',\n equity: positions.reduce((sum: number, pos: any) => sum + pos.valuation, 0),\n free: positions.reduce((sum: number, pos: any) => sum + pos.free_volume, 0),\n },\n positions,\n pending_orders: [], // Spot orders would need separate API call\n };\n};\n"]}
1
+ {"version":3,"file":"spot.js","sourceRoot":"","sources":["../../../src/services/accounts/spot.ts"],"names":[],"mappings":";;;AAAA,uDAAmE;AACnE,yCAAuD;AACvD,qDAA4D;AAC5D,2CAAwE;AAExE;;GAEG;AACI,MAAM,kBAAkB,GAAG,KAAK,EAAE,UAAuB,EAAE,UAAkB,EAAE,EAAE;IACtF,OAAO,CAAC,IAAI,CAAC,IAAI,IAAA,kBAAU,EAAC,IAAI,CAAC,GAAG,EAAE,CAAC,mCAAmC,UAAU,EAAE,CAAC,CAAC;IAExF,MAAM,QAAQ,GAAG,MAAM,IAAA,iCAAoB,EAAC,EAAE,IAAI,EAAE,IAAA,gCAAwB,EAAC,UAAU,CAAC,EAAE,CAAC,CAAC;IAE5F,8DAA8D;IAC9D,MAAM,SAAS,GAAG,QAAQ,CAAC,QAAQ;SAChC,MAAM,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;SAC9C,GAAG,CACF,CAAC,OAAO,EAAa,EAAE,CACrB,IAAA,+BAAgB,EAAC;QACf,WAAW,EAAE,GAAG,OAAO,CAAC,IAAI,EAAE;QAC9B,aAAa,EAAE,aAAa;QAC5B,UAAU,EAAE,IAAA,kBAAU,EAAC,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,OAAO,CAAC;QACtD,MAAM,EAAE,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC;QAC7B,WAAW,EAAE,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC;QACzD,cAAc,EAAE,CAAC;KAClB,CAAC,CACL,CAAC;IAEJ,OAAO,SAAS,CAAC;AACnB,CAAC,CAAC;AArBW,QAAA,kBAAkB,sBAqB7B","sourcesContent":["import { IPosition, makeSpotPosition } from '@yuants/data-account';\nimport { encodePath, formatTime } from '@yuants/utils';\nimport { getUserTokenBalances } from '../../api/public-api';\nimport { getAddressFromCredential, ICredential } from '../../api/types';\n\n/**\n * Get account info for spot account\n */\nexport const getSpotAccountInfo = async (credential: ICredential, account_id: string) => {\n console.info(`[${formatTime(Date.now())}] Getting spot account info for ${account_id}`);\n\n const balances = await getUserTokenBalances({ user: getAddressFromCredential(credential) });\n\n // Map token balances to positions (using spot as \"positions\")\n const positions = balances.balances\n .filter((balance) => Number(balance.total) > 0)\n .map(\n (balance): IPosition =>\n makeSpotPosition({\n position_id: `${balance.coin}`,\n datasource_id: 'HYPERLIQUID',\n product_id: encodePath('SPOT', `${balance.coin}-USDC`),\n volume: Number(balance.total),\n free_volume: Number(balance.total) - Number(balance.hold),\n closable_price: 1,\n }),\n );\n\n return positions;\n};\n"]}
@@ -7,6 +7,7 @@ const types_1 = require("../api/types");
7
7
  const perp_1 = require("./accounts/perp");
8
8
  const spot_1 = require("./accounts/spot");
9
9
  const cancelOrder_1 = require("./orders/cancelOrder");
10
+ const listOrders_1 = require("./orders/listOrders");
10
11
  const submitOrder_1 = require("./orders/submitOrder");
11
12
  const terminal = protocol_1.Terminal.fromNodeEnv();
12
13
  const credential = (0, types_1.getDefaultCredential)();
@@ -17,23 +18,10 @@ const defaultSpotAccountId = `hyperliquid/${walletAddress}/spot`;
17
18
  (0, data_account_1.addAccountMarket)(terminal, { account_id: defaultSpotAccountId, market_id: 'HYPERLIQUID/SPOT' });
18
19
  (0, data_account_1.provideAccountInfoService)(terminal, defaultPerpAccountId, async () => {
19
20
  const info = await (0, perp_1.getPerpAccountInfo)(credential, defaultPerpAccountId);
20
- return {
21
- money: info.money,
22
- positions: info.positions,
23
- orders: info.pending_orders,
24
- };
21
+ return info;
25
22
  }, { auto_refresh_interval: 1000 });
26
- (0, data_order_1.providePendingOrdersService)(terminal, defaultPerpAccountId, async () => {
27
- const info = await (0, perp_1.getPerpAccountInfo)(credential, defaultPerpAccountId);
28
- return info.pending_orders;
29
- }, { auto_refresh_interval: 2000 });
30
- (0, data_account_1.provideAccountInfoService)(terminal, defaultSpotAccountId, async () => {
31
- const info = await (0, spot_1.getSpotAccountInfo)(credential, defaultSpotAccountId);
32
- return {
33
- money: info.money,
34
- positions: info.positions,
35
- };
36
- }, { auto_refresh_interval: 5000 });
23
+ (0, data_order_1.providePendingOrdersService)(terminal, defaultPerpAccountId, async () => (0, listOrders_1.listOrders)(credential, defaultPerpAccountId), { auto_refresh_interval: 2000 });
24
+ (0, data_account_1.provideAccountInfoService)(terminal, defaultSpotAccountId, async () => (0, spot_1.getSpotAccountInfo)(credential, defaultSpotAccountId), { auto_refresh_interval: 5000 });
37
25
  terminal.server.provideService('SubmitOrder', {
38
26
  required: ['account_id', 'product_id', 'order_type', 'order_direction', 'volume'],
39
27
  properties: {
@@ -1 +1 @@
1
- {"version":3,"file":"legacy.js","sourceRoot":"","sources":["../../src/services/legacy.ts"],"names":[],"mappings":";;AAAA,uDAAmF;AACnF,mDAAyE;AACzE,+CAA4C;AAC5C,wCAA8E;AAC9E,0CAAqD;AACrD,0CAAqD;AACrD,sDAAyD;AACzD,sDAAmD;AAEnD,MAAM,QAAQ,GAAG,mBAAQ,CAAC,WAAW,EAAE,CAAC;AACxC,MAAM,UAAU,GAAG,IAAA,4BAAoB,GAAE,CAAC;AAC1C,MAAM,aAAa,GAAG,IAAA,gCAAwB,EAAC,UAAU,CAAC,CAAC,WAAW,EAAE,CAAC;AACzE,MAAM,oBAAoB,GAAG,eAAe,aAAa,OAAO,CAAC;AACjE,MAAM,oBAAoB,GAAG,eAAe,aAAa,OAAO,CAAC;AAEjE,IAAA,+BAAgB,EAAC,QAAQ,EAAE,EAAE,UAAU,EAAE,oBAAoB,EAAE,SAAS,EAAE,kBAAkB,EAAE,CAAC,CAAC;AAChG,IAAA,+BAAgB,EAAC,QAAQ,EAAE,EAAE,UAAU,EAAE,oB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L,GAAG,EAAE;YACH,IAAI,EAAE,CAAC;YACP,OAAO,EAAE,IAAI;YACb,IAAI,EAAE,MAAM,IAAA,yBAAW,EAAC,UAAU,EAAE,GAAG,CAAC,GAAG,CAAC;SAC7C;KACF,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,QAAQ,CAAC,MAAM,CAAC,cAAc,CAC5B,aAAa,EACb;IACE,QAAQ,EAAE,CAAC,YAAY,EAAE,UAAU,EAAE,YAAY,CAAC;IAClD,UAAU,EAAE;QACV,UAAU,EAAE,EAAE,KAAK,EAAE,oBAAoB,EAAE;KAC5C;CACF,EACD,KAAK,EAAE,GAAG,EAAE,EAAE;IACZ,MAAM,IAAA,+BAAiB,EAAC,UAAU,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC;IAC7C,OAAO;QACL,GAAG,EAAE;YACH,IAAI,EAAE,CAAC;YACP,OAAO,EAAE,IAAI;SACd;KACF,CAAC;AACJ,CAAC,CACF,CAAC","sourcesContent":["import { addAccountMarket, provideAccountInfoService } from '@yuants/data-account';\nimport { IOrder, providePendingOrdersService } from '@yuants/data-order';\nimport { Terminal } from '@yuants/protocol';\nimport { getAddressFromCredential, getDefaultCredential } from '../api/types';\nimport { getPerpAccountInfo } from './accounts/perp';\nimport { getSpotAccountInfo } from './accounts/spot';\nimport { cancelOrderAction } from './orders/cancelOrder';\nimport { submitOrder } from './orders/submitOrder';\n\nconst terminal = Terminal.fromNodeEnv();\nconst credential = getDefaultCredential();\nconst walletAddress = getAddressFromCredential(credential).toLowerCase();\nconst defaultPerpAccountId = `hyperliquid/${walletAddress}/perp`;\nconst defaultSpotAccountId = `hyperliquid/${walletAddress}/spot`;\n\naddAccountMarket(terminal, { account_id: defaultPerpAccountId, market_id: 'HYPERLIQUID/PERP' });\naddAccountMarket(terminal, { account_id: defaultSpotAccountId, market_id: 'HYPERLIQUID/SPOT' });\n\nprovideAccountInfoService(\n terminal,\n defaultPerpAccountId,\n async () => {\n const info = await getPerpAccountInfo(credential, defaultPerpAccountId);\n return {\n money: info.money,\n positions: info.positions,\n orders: info.pending_orders,\n };\n },\n { auto_refresh_interval: 1000 },\n);\n\nprovidePendingOrdersService(\n terminal,\n defaultPerpAccountId,\n async () => {\n const info = await getPerpAccountInfo(credential, defaultPerpAccountId);\n return info.pending_orders;\n },\n { auto_refresh_interval: 2000 },\n);\n\nprovideAccountInfoService(\n terminal,\n defaultSpotAccountId,\n async () => {\n const info = await getSpotAccountInfo(credential, defaultSpotAccountId);\n return {\n money: info.money,\n positions: info.positions,\n };\n },\n { auto_refresh_interval: 5000 },\n);\n\nterminal.server.provideService<IOrder, { order_id?: string }>(\n 'SubmitOrder',\n {\n required: ['account_id', 'product_id', 'order_type', 'order_direction', 'volume'],\n properties: {\n account_id: { const: defaultPerpAccountId },\n },\n },\n async (msg) => {\n return {\n res: {\n code: 0,\n message: 'OK',\n data: await submitOrder(credential, msg.req),\n },\n };\n },\n);\n\nterminal.server.provideService<IOrder>(\n 'CancelOrder',\n {\n required: ['account_id', 'order_id', 'product_id'],\n properties: {\n account_id: { const: defaultPerpAccountId },\n },\n },\n async (msg) => {\n await cancelOrderAction(credential, msg.req);\n return {\n res: {\n code: 0,\n message: 'OK',\n },\n };\n },\n);\n"]}
1
+ {"version":3,"file":"legacy.js","sourceRoot":"","sources":["../../src/services/legacy.ts"],"names":[],"mappings":";;AAAA,uDAAmF;AACnF,mDAAyE;AACzE,+CAA4C;AAC5C,wCAA8E;AAC9E,0CAAqD;AACrD,0CAAqD;AACrD,sDAAyD;AACzD,oDAAiD;AACjD,sDAAmD;AAEnD,MAAM,QAAQ,GAAG,mBAAQ,CAAC,WAAW,EAAE,CAAC;AACxC,MAAM,UAAU,GAAG,IAAA,4BAAoB,GAAE,CAAC;AAC1C,MAAM,aAAa,GAAG,IAAA,gCAAwB,EAAC,UAAU,CAAC,CAAC,WAAW,EAAE,CAAC;AACzE,MAAM,oBAAoB,GAAG,eAAe,aAAa,OAAO,CAAC;AACjE,MAAM,oBAAoB,GA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C,GAAG,CAAC;SAC7C;KACF,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,QAAQ,CAAC,MAAM,CAAC,cAAc,CAC5B,aAAa,EACb;IACE,QAAQ,EAAE,CAAC,YAAY,EAAE,UAAU,EAAE,YAAY,CAAC;IAClD,UAAU,EAAE;QACV,UAAU,EAAE,EAAE,KAAK,EAAE,oBAAoB,EAAE;KAC5C;CACF,EACD,KAAK,EAAE,GAAG,EAAE,EAAE;IACZ,MAAM,IAAA,+BAAiB,EAAC,UAAU,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC;IAC7C,OAAO;QACL,GAAG,EAAE;YACH,IAAI,EAAE,CAAC;YACP,OAAO,EAAE,IAAI;SACd;KACF,CAAC;AACJ,CAAC,CACF,CAAC","sourcesContent":["import { addAccountMarket, provideAccountInfoService } from '@yuants/data-account';\nimport { IOrder, providePendingOrdersService } from '@yuants/data-order';\nimport { Terminal } from '@yuants/protocol';\nimport { getAddressFromCredential, getDefaultCredential } from '../api/types';\nimport { getPerpAccountInfo } from './accounts/perp';\nimport { getSpotAccountInfo } from './accounts/spot';\nimport { cancelOrderAction } from './orders/cancelOrder';\nimport { listOrders } from './orders/listOrders';\nimport { submitOrder } from './orders/submitOrder';\n\nconst terminal = Terminal.fromNodeEnv();\nconst credential = getDefaultCredential();\nconst walletAddress = getAddressFromCredential(credential).toLowerCase();\nconst defaultPerpAccountId = `hyperliquid/${walletAddress}/perp`;\nconst defaultSpotAccountId = `hyperliquid/${walletAddress}/spot`;\n\naddAccountMarket(terminal, { account_id: defaultPerpAccountId, market_id: 'HYPERLIQUID/PERP' });\naddAccountMarket(terminal, { account_id: defaultSpotAccountId, market_id: 'HYPERLIQUID/SPOT' });\n\nprovideAccountInfoService(\n terminal,\n defaultPerpAccountId,\n async () => {\n const info = await getPerpAccountInfo(credential, defaultPerpAccountId);\n return info;\n },\n { auto_refresh_interval: 1000 },\n);\n\nprovidePendingOrdersService(\n terminal,\n defaultPerpAccountId,\n async () => listOrders(credential, defaultPerpAccountId),\n { auto_refresh_interval: 2000 },\n);\n\nprovideAccountInfoService(\n terminal,\n defaultSpotAccountId,\n async () => getSpotAccountInfo(credential, defaultSpotAccountId),\n { auto_refresh_interval: 5000 },\n);\n\nterminal.server.provideService<IOrder, { order_id?: string }>(\n 'SubmitOrder',\n {\n required: ['account_id', 'product_id', 'order_type', 'order_direction', 'volume'],\n properties: {\n account_id: { const: defaultPerpAccountId },\n },\n },\n async (msg) => {\n return {\n res: {\n code: 0,\n message: 'OK',\n data: await submitOrder(credential, msg.req),\n },\n };\n },\n);\n\nterminal.server.provideService<IOrder>(\n 'CancelOrder',\n {\n required: ['account_id', 'order_id', 'product_id'],\n properties: {\n account_id: { const: defaultPerpAccountId },\n },\n },\n async (msg) => {\n await cancelOrderAction(credential, msg.req);\n return {\n res: {\n code: 0,\n message: 'OK',\n },\n };\n },\n);\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yuants/vendor-hyperliquid",
3
- "version": "0.6.2",
3
+ "version": "0.6.3",
4
4
  "main": "lib/index.js",
5
5
  "files": [
6
6
  "dist",
@@ -11,7 +11,7 @@
11
11
  "@yuants/cache": "0.3.0",
12
12
  "@yuants/protocol": "0.52.0",
13
13
  "@yuants/transfer": "0.2.35",
14
- "@yuants/data-account": "0.7.3",
14
+ "@yuants/data-account": "0.8.0",
15
15
  "@yuants/utils": "0.11.0",
16
16
  "@yuants/sql": "0.9.26",
17
17
  "@yuants/data-product": "0.4.17",
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "apps/vendor-hyperliquid/AGENTS.md": "1b845a9b4aaa66719b67ccffac0dd5d3ea832580",
3
- "apps/vendor-hyperliquid/CHANGELOG.json": "420bdbb0c493f9043fc41caa94e00241bb5ba9e1",
4
- "apps/vendor-hyperliquid/CHANGELOG.md": "5a44f1df75409438725d3a0b1f4b0173dffc4df4",
3
+ "apps/vendor-hyperliquid/CHANGELOG.json": "cf49be3d63dbacfb34f4d619d1202e88a57e5c3a",
4
+ "apps/vendor-hyperliquid/CHANGELOG.md": "56f03d2818e1941c9b0e2629fb0e034e743980b3",
5
5
  "apps/vendor-hyperliquid/SESSION_NOTES.md": "b01684ffd7e8f854b7bd7a03062cc159a478b144",
6
6
  "apps/vendor-hyperliquid/api-extractor.json": "62f4fd324425b9a235f0c117975967aab09ced0c",
7
7
  "apps/vendor-hyperliquid/config/jest.config.json": "4bb17bde3ee911163a3edb36a6eb71491d80b1bd",
8
8
  "apps/vendor-hyperliquid/config/rig.json": "f6c7b5537dc77a3170ba9f008bae3b6c3ee11956",
9
9
  "apps/vendor-hyperliquid/config/typescript.json": "854907e8a821f2050f6533368db160c649c25348",
10
10
  "apps/vendor-hyperliquid/etc/vendor-hyperliquid.api.md": "66675bd88afa1fe945f0d4023984c1c9c3e60a34",
11
- "apps/vendor-hyperliquid/package.json": "bdb5bb8fd84436b822ab108749c127668ee68107",
11
+ "apps/vendor-hyperliquid/package.json": "809be1afce8df19b213a125bb84d9f57d2433cf7",
12
12
  "apps/vendor-hyperliquid/src/api/client.ts": "90eb3b63394c9729cc442e0ee5482bfd494aafdd",
13
13
  "apps/vendor-hyperliquid/src/api/private-api.ts": "3d102ea20a75f649656b52e2ef39e898f1b82bee",
14
14
  "apps/vendor-hyperliquid/src/api/public-api.ts": "fbbb982308eea89a51b93cc21442de6ba45cfd60",
@@ -16,9 +16,9 @@
16
16
  "apps/vendor-hyperliquid/src/cli.ts": "9bf6b5559a6c6f33da20e74cc6c5d702c60ec891",
17
17
  "apps/vendor-hyperliquid/src/index.ts": "3344018bd20d261271abdbbea120c85d3b189805",
18
18
  "apps/vendor-hyperliquid/src/services/account-actions-with-credential.ts": "2b94a7d1330c6514158848737527a57f8989dd88",
19
- "apps/vendor-hyperliquid/src/services/accounts/perp.ts": "ee7c7022f2e56b8534ccbb217f55a7630bb8d973",
20
- "apps/vendor-hyperliquid/src/services/accounts/spot.ts": "fad46620c99f0d5e190b753e671869ef7d8c0507",
21
- "apps/vendor-hyperliquid/src/services/legacy.ts": "8979bae63b12ef048c19a02d185e52bdd422c59a",
19
+ "apps/vendor-hyperliquid/src/services/accounts/perp.ts": "15779a6642f9886cf83f07e14579aa6d4aaf1e2c",
20
+ "apps/vendor-hyperliquid/src/services/accounts/spot.ts": "6a02229557b14ddd66a56b014ec4f849aee56c0c",
21
+ "apps/vendor-hyperliquid/src/services/legacy.ts": "947cdefc681ffa82d7c4a8a3887f68dc6106f9f9",
22
22
  "apps/vendor-hyperliquid/src/services/markets/interest-rate.ts": "45b9f161f808ec0301a55241b39ec85f17e527fe",
23
23
  "apps/vendor-hyperliquid/src/services/markets/ohlc.ts": "7c1172a285efd5f08081dd3f8b8b27314cdf099d",
24
24
  "apps/vendor-hyperliquid/src/services/markets/product.ts": "51a2dc92036c595254a037d2e002f8f20e961216",
@@ -35,7 +35,7 @@
35
35
  "libraries/cache/temp/package-deps.json": "49789a92426969daa31f0c956bb56bd783929765",
36
36
  "libraries/protocol/temp/package-deps.json": "52d2a645608a17915da897e48a70b415312a94fb",
37
37
  "libraries/transfer/temp/package-deps.json": "43e6dc024979295961767cdfbbdbdf5aff2831b3",
38
- "libraries/data-account/temp/package-deps.json": "36ce528a841782d724392412ec002a155733a5d0",
38
+ "libraries/data-account/temp/package-deps.json": "459a552a5ff4304fff00dfd369bb0746bd33cf5f",
39
39
  "libraries/utils/temp/package-deps.json": "c58f1ca8f498315d9a0219ca8c498299a41d297b",
40
40
  "libraries/sql/temp/package-deps.json": "f718628b404248148aaa692928681b1087ccc7ba",
41
41
  "libraries/data-product/temp/package-deps.json": "436ccc170786fb1194c4bb48fada1cfd3ace78ab",