@pear-protocol/hyperliquid-sdk 0.0.34 → 0.0.35

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/dist/index.d.ts CHANGED
@@ -197,11 +197,12 @@ type OrderStatus = 'OPEN' | 'PARTIALLY_FILLED' | 'PROCESSING';
197
197
  /**
198
198
  * Order type
199
199
  */
200
- type OrderType = 'TP' | 'SL' | 'LIMIT' | 'MARKET';
200
+ type OrderType = 'TP' | 'SL' | 'LIMIT' | 'MARKET' | 'LIMIT_BTCDOM' | 'TWAP';
201
201
  /**
202
202
  * TP/SL trigger type
203
203
  */
204
- type TpSlTriggerType = 'RATIO' | 'PERCENTAGE' | 'PNL';
204
+ type TpSlTriggerType = 'PERCENTAGE' | 'DOLLAR' | 'POSITION_VALUE';
205
+ type OrderDirection = 'MORE_THAN' | 'LESS_THAN' | null;
205
206
  /**
206
207
  * Open limit order data structure
207
208
  */
@@ -209,16 +210,17 @@ interface OpenLimitOrderDto {
209
210
  orderId: string;
210
211
  address: string;
211
212
  clientId: string | null;
212
- positionId: string;
213
+ positionId?: string | null;
213
214
  leverage: number;
214
215
  usdValue: number;
215
- triggerValue: number;
216
- twapDuration: number | null;
217
- tpSlTriggerType: TpSlTriggerType;
216
+ triggerValue?: number | null;
217
+ twapDuration?: string | null;
218
+ tpSlTriggerType?: TpSlTriggerType | null;
218
219
  randomizeFlag: boolean;
219
220
  reduceOnlyFlag: boolean;
220
221
  status: OrderStatus;
221
222
  orderType: OrderType;
223
+ direction?: OrderDirection | null;
222
224
  longAssets: OrderAssetDto[];
223
225
  shortAssets: OrderAssetDto[];
224
226
  createdAt: string;
package/dist/index.js CHANGED
@@ -8363,7 +8363,12 @@ const calculatePositionAsset = (asset, currentPrice, totalInitialPositionSize, l
8363
8363
  };
8364
8364
  const buildPositionValue = (rawPositions, webData2, allMids) => {
8365
8365
  return rawPositions.map((position) => {
8366
- const webData2Position = webData2.clearinghouseState.assetPositions.find(ap => ap.position.coin === position.longAssets[0].coin || ap.position.coin === position.shortAssets[0].coin);
8366
+ const webData2Position = webData2.clearinghouseState.assetPositions.find(ap => {
8367
+ var _a, _b, _c, _d;
8368
+ const longCoin = (_b = (_a = position.longAssets) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.coin;
8369
+ const shortCoin = (_d = (_c = position.shortAssets) === null || _c === void 0 ? void 0 : _c[0]) === null || _d === void 0 ? void 0 : _d.coin;
8370
+ return ap.position.coin === longCoin || ap.position.coin === shortCoin;
8371
+ });
8367
8372
  let mappedPosition = {
8368
8373
  positionId: position.positionId,
8369
8374
  address: position.address,
@@ -8508,10 +8513,10 @@ function useOrders() {
8508
8513
  if (!openOrders)
8509
8514
  return null;
8510
8515
  return openOrders.map((ord) => {
8511
- var _a, _b, _c, _d;
8516
+ var _a, _b, _c, _d, _e;
8512
8517
  const isTpSl = ord.orderType === 'TP' || ord.orderType === 'SL';
8513
8518
  const hasAssets = ((_b = (_a = ord.longAssets) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0) > 0 || ((_d = (_c = ord.shortAssets) === null || _c === void 0 ? void 0 : _c.length) !== null && _d !== void 0 ? _d : 0) > 0;
8514
- const pos = positionsById.get(ord.positionId);
8519
+ const pos = positionsById.get((_e = ord.positionId) !== null && _e !== void 0 ? _e : '');
8515
8520
  if (!isTpSl || !pos)
8516
8521
  return ord;
8517
8522
  // Build order assets from position weights when TP/SL has no assets
package/dist/types.d.ts CHANGED
@@ -218,11 +218,12 @@ export type OrderStatus = 'OPEN' | 'PARTIALLY_FILLED' | 'PROCESSING';
218
218
  /**
219
219
  * Order type
220
220
  */
221
- export type OrderType = 'TP' | 'SL' | 'LIMIT' | 'MARKET';
221
+ export type OrderType = 'TP' | 'SL' | 'LIMIT' | 'MARKET' | 'LIMIT_BTCDOM' | 'TWAP';
222
222
  /**
223
223
  * TP/SL trigger type
224
224
  */
225
- export type TpSlTriggerType = 'RATIO' | 'PERCENTAGE' | 'PNL';
225
+ export type TpSlTriggerType = 'PERCENTAGE' | 'DOLLAR' | 'POSITION_VALUE';
226
+ export type OrderDirection = 'MORE_THAN' | 'LESS_THAN' | null;
226
227
  /**
227
228
  * Open limit order data structure
228
229
  */
@@ -230,16 +231,17 @@ export interface OpenLimitOrderDto {
230
231
  orderId: string;
231
232
  address: string;
232
233
  clientId: string | null;
233
- positionId: string;
234
+ positionId?: string | null;
234
235
  leverage: number;
235
236
  usdValue: number;
236
- triggerValue: number;
237
- twapDuration: number | null;
238
- tpSlTriggerType: TpSlTriggerType;
237
+ triggerValue?: number | null;
238
+ twapDuration?: string | null;
239
+ tpSlTriggerType?: TpSlTriggerType | null;
239
240
  randomizeFlag: boolean;
240
241
  reduceOnlyFlag: boolean;
241
242
  status: OrderStatus;
242
243
  orderType: OrderType;
244
+ direction?: OrderDirection | null;
243
245
  longAssets: OrderAssetDto[];
244
246
  shortAssets: OrderAssetDto[];
245
247
  createdAt: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pear-protocol/hyperliquid-sdk",
3
- "version": "0.0.34",
3
+ "version": "0.0.35",
4
4
  "description": "React SDK for Pear Protocol Hyperliquid API integration",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",