@pear-protocol/hyperliquid-sdk 0.0.51 → 0.0.53

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,4 +1,4 @@
1
- import type { ApiResponse, SyncFillsRequestDto, SyncFillsResponseDto } from '../types';
1
+ import type { ApiResponse, AssetPosition, SyncFillsRequestDto, SyncFillsResponseDto } from '../types';
2
2
  /**
3
3
  * Sync external fills into Pear Hyperliquid service (POST /sync/fills)
4
4
  */
@@ -6,4 +6,4 @@ export declare const syncFills: (baseUrl: string, accessToken: string, payload:
6
6
  /**
7
7
  * Convenience: fetch user fills from HyperLiquid, then sync them to Pear backend
8
8
  */
9
- export declare const syncUserFillsFromHyperliquid: (baseUrl: string, accessToken: string, user: string, aggregateByTime?: boolean, lastSyncAt?: number | null) => Promise<ApiResponse<SyncFillsResponseDto>>;
9
+ export declare const syncUserFillsFromHyperliquid: (baseUrl: string, accessToken: string, user: string, aggregateByTime: boolean | undefined, lastSyncAt: number | null | undefined, assetPositions: AssetPosition[]) => Promise<ApiResponse<SyncFillsResponseDto>>;
package/dist/index.js CHANGED
@@ -6007,7 +6007,7 @@ const syncFills = async (baseUrl, accessToken, payload) => {
6007
6007
  /**
6008
6008
  * Convenience: fetch user fills from HyperLiquid, then sync them to Pear backend
6009
6009
  */
6010
- const syncUserFillsFromHyperliquid = async (baseUrl, accessToken, user, aggregateByTime = true, lastSyncAt = null) => {
6010
+ const syncUserFillsFromHyperliquid = async (baseUrl, accessToken, user, aggregateByTime = true, lastSyncAt = null, assetPositions) => {
6011
6011
  const firstStartTime = lastSyncAt ? Number(lastSyncAt) : 1735660800000;
6012
6012
  const allFills = [];
6013
6013
  const seenTids = new Set();
@@ -6030,7 +6030,7 @@ const syncUserFillsFromHyperliquid = async (baseUrl, accessToken, user, aggregat
6030
6030
  startTime = last.time;
6031
6031
  }
6032
6032
  } while (batchSize === 2000);
6033
- return syncFills(baseUrl, accessToken, { user, fills: allFills });
6033
+ return syncFills(baseUrl, accessToken, { user, fills: allFills, assetPositions });
6034
6034
  };
6035
6035
 
6036
6036
  /**
@@ -6054,18 +6054,21 @@ function useAutoSyncFills(options) {
6054
6054
  return Boolean(enabled && address && baseUrl && accessToken);
6055
6055
  }, [enabled, address, baseUrl, accessToken]);
6056
6056
  const doSync = useCallback(async () => {
6057
+ var _a;
6057
6058
  if (!canRun)
6058
6059
  return;
6059
6060
  if (runningRef.current)
6060
6061
  return;
6061
6062
  if (!useUserData.getState().accountSummary)
6062
6063
  return;
6064
+ if (!((_a = useHyperliquidData.getState().aggregatedClearingHouseState) === null || _a === void 0 ? void 0 : _a.assetPositions))
6065
+ return;
6063
6066
  setIsSyncing(true);
6064
6067
  setError(null);
6065
6068
  const promise = (async () => {
6066
6069
  var _a;
6067
6070
  try {
6068
- const { data } = await syncUserFillsFromHyperliquid(baseUrl, accessToken, address, aggregateByTime, lastSyncedAt);
6071
+ const { data } = await syncUserFillsFromHyperliquid(baseUrl, accessToken, address, aggregateByTime, lastSyncedAt, useHyperliquidData.getState().aggregatedClearingHouseState.assetPositions);
6069
6072
  if (!mountedRef.current)
6070
6073
  return;
6071
6074
  setLastResult(data);
@@ -6346,6 +6349,8 @@ const buildPositionValue = (rawPositions, clearinghouseState, allMids) => {
6346
6349
  let mappedPosition = {
6347
6350
  positionId: position.positionId,
6348
6351
  address: position.address,
6352
+ createdAt: position.createdAt,
6353
+ updatedAt: position.updatedAt,
6349
6354
  entryRatio: 1,
6350
6355
  marginUsed: 0,
6351
6356
  markRatio: 1,
package/dist/types.d.ts CHANGED
@@ -35,6 +35,7 @@ export interface ExternalFillDto {
35
35
  export interface SyncFillsRequestDto {
36
36
  user: string;
37
37
  fills: ExternalFillDto[];
38
+ assetPositions?: AssetPosition[];
38
39
  }
39
40
  export interface SyncFillsResponseDto {
40
41
  insertedFills: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pear-protocol/hyperliquid-sdk",
3
- "version": "0.0.51",
3
+ "version": "0.0.53",
4
4
  "description": "React SDK for Pear Protocol Hyperliquid API integration",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",