@pear-protocol/symmio-client 0.1.10 → 0.2.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.
@@ -24355,8 +24355,8 @@ function SymmProvider({
24355
24355
  }) {
24356
24356
  const { address, chainId: walletChainId } = useAccount();
24357
24357
  const publicClient = usePublicClient();
24358
- const { data: walletClient } = useWalletClient();
24359
24358
  const chainId = configChainId ?? walletChainId ?? 42161;
24359
+ const { data: walletClient } = useWalletClient({ chainId });
24360
24360
  const [accessToken, setAccessToken] = useState(null);
24361
24361
  const prevAddressRef = useRef(address);
24362
24362
  const prevChainRef = useRef(chainId);
@@ -24453,6 +24453,13 @@ function SymmProvider({
24453
24453
  clearCachedToken(previousAddress, previousChainId);
24454
24454
  }
24455
24455
  }, [address, walletClient, chainId]);
24456
+ useEffect(() => {
24457
+ console.log("[SymmProvider] symmCoreConfig", {
24458
+ apiUrl: symmCoreConfig.apiUrl,
24459
+ wsUrl: symmCoreConfig.wsUrl,
24460
+ resolvedChainId: chainId
24461
+ });
24462
+ }, [symmCoreConfig.apiUrl, symmCoreConfig.wsUrl, chainId]);
24456
24463
  const symmCoreClient = useMemo(() => {
24457
24464
  return createSymmSDK({
24458
24465
  apiUrl: symmCoreConfig.apiUrl,
@@ -24515,24 +24522,38 @@ var ALL_TRADING_SELECTORS = [
24515
24522
  // src/react/query-keys.ts
24516
24523
  var symmKeys = {
24517
24524
  all: ["symm"],
24518
- accounts: (address) => ["symm", "accounts", address],
24525
+ accounts: (address, chainId) => ["symm", "accounts", address, chainId],
24526
+ accountsApi: (address, chainId) => ["symm", "accountsApi", address, chainId],
24527
+ accountsLength: (address, chainId) => ["symm", "accountsLength", address, chainId],
24528
+ accountsWithPositions: (address, chainId) => ["symm", "accountsWithPositions", address, chainId],
24519
24529
  accountSummary: (address, chainId) => ["symm", "accountSummary", address, chainId],
24520
24530
  accountData: (address, chainId) => ["symm", "accountData", address, chainId],
24521
- signature: (address) => ["symm", "signature", address],
24522
- approval: (owner, spender) => ["symm", "approval", owner, spender],
24531
+ signature: (address, chainId) => ["symm", "signature", address, chainId],
24532
+ approval: (owner, spender, chainId) => ["symm", "approval", owner, spender, chainId],
24523
24533
  balances: (address, chainId) => ["symm", "balances", address, chainId],
24524
24534
  positions: (address, chainId) => ["symm", "positions", address, chainId],
24525
24535
  openOrders: (address, chainId) => ["symm", "openOrders", address, chainId],
24526
24536
  tradeHistory: (address, chainId) => ["symm", "tradeHistory", address, chainId],
24527
24537
  tpslOrders: (address, chainId) => ["symm", "tpslOrders", address, chainId],
24538
+ tpslOrdersList: (params) => ["symm", "tpslOrders", params],
24528
24539
  twapOrders: (address, chainId) => ["symm", "twapOrders", address, chainId],
24540
+ triggerOrders: (params) => ["symm", "triggerOrders", params],
24541
+ triggerConfig: (orderId) => ["symm", "triggerConfig", orderId],
24529
24542
  markets: (chainId, search) => ["symm", "markets", chainId, search],
24543
+ hedgerMarketById: (id, chainId) => ["symm", "hedgerMarketById", id, chainId],
24544
+ hedgerMarketBySymbol: (symbol, chainId) => ["symm", "hedgerMarketBySymbol", symbol, chainId],
24545
+ lockedParams: (marketName, leverage, chainId) => ["symm", "lockedParams", marketName, leverage, chainId],
24530
24546
  hedgerMarkets: (request) => ["symm", "hedgerMarkets", request],
24531
24547
  fundingRates: (chainId) => ["symm", "fundingRates", chainId],
24548
+ fundingPayments: (params) => ["symm", "fundingPayments", params],
24549
+ fundingHistory: (params) => ["symm", "fundingHistory", params],
24532
24550
  portfolio: (address, chainId) => ["symm", "portfolio", address, chainId],
24533
24551
  notifications: (address, chainId) => ["symm", "notifications", address, chainId],
24534
24552
  unreadCount: (address, chainId) => ["symm", "unreadCount", address, chainId],
24535
24553
  availableMargin: (address, chainId) => ["symm", "availableMargin", address, chainId],
24554
+ pendingIds: (address, chainId) => ["symm", "pendingIds", address, chainId],
24555
+ pendingInstantOpens: (accountAddress, chainId) => ["symm", "pendingInstantOpens", accountAddress, chainId],
24556
+ twapOrder: (orderId) => ["symm", "twapOrder", orderId],
24536
24557
  delegation: (account, target, selectors, chainId) => ["symm", "delegation", account, target, selectors, chainId],
24537
24558
  chartMetadata: (symbolsKey, positionKey) => ["symm", "chartMetadata", symbolsKey, positionKey]
24538
24559
  };
@@ -24594,6 +24615,7 @@ function invalidateOrders(qc) {
24594
24615
  qc.invalidateQueries({ queryKey: ["symm", "openOrders"] });
24595
24616
  qc.invalidateQueries({ queryKey: ["symm", "tpslOrders"] });
24596
24617
  qc.invalidateQueries({ queryKey: ["symm", "twapOrders"] });
24618
+ qc.invalidateQueries({ queryKey: ["symm", "triggerOrders"] });
24597
24619
  }
24598
24620
 
24599
24621
  // src/react/hooks/use-symm-instant-trade.ts
@@ -24686,12 +24708,12 @@ function useSymmInstantTrade(params) {
24686
24708
  }
24687
24709
  var EMPTY_ACCOUNTS = [];
24688
24710
  function useSymmAccounts(userAddress, options) {
24689
- const { symmioClient } = useSymmContext();
24711
+ const { symmioClient, chainId } = useSymmContext();
24690
24712
  const queryClient = useQueryClient();
24691
24713
  const internalEnabled = !!symmioClient && !!userAddress;
24692
24714
  const accountsQuery = useQuery({
24693
24715
  ...options?.query,
24694
- queryKey: symmKeys.accounts(userAddress),
24716
+ queryKey: symmKeys.accounts(userAddress, chainId),
24695
24717
  queryFn: () => symmioClient.account.getAll(userAddress),
24696
24718
  enabled: internalEnabled && (options?.query?.enabled ?? true)
24697
24719
  });
@@ -24701,7 +24723,7 @@ function useSymmAccounts(userAddress, options) {
24701
24723
  return symmioClient.account.addAccount(name);
24702
24724
  },
24703
24725
  onSuccess: () => {
24704
- queryClient.invalidateQueries({ queryKey: symmKeys.accounts(userAddress) });
24726
+ queryClient.invalidateQueries({ queryKey: symmKeys.accounts(userAddress, chainId) });
24705
24727
  }
24706
24728
  });
24707
24729
  const editName = useMutation({
@@ -24713,7 +24735,7 @@ function useSymmAccounts(userAddress, options) {
24713
24735
  return symmioClient.account.editName(accountAddress, name);
24714
24736
  },
24715
24737
  onSuccess: () => {
24716
- queryClient.invalidateQueries({ queryKey: symmKeys.accounts(userAddress) });
24738
+ queryClient.invalidateQueries({ queryKey: symmKeys.accounts(userAddress, chainId) });
24717
24739
  }
24718
24740
  });
24719
24741
  return {
@@ -24726,8 +24748,74 @@ function useSymmAccounts(userAddress, options) {
24726
24748
  editName
24727
24749
  };
24728
24750
  }
24751
+ function useSymmAccountsApi(params) {
24752
+ const { symmCoreClient, chainId: ctxChainId } = useSymmContext();
24753
+ const { userAddress } = params;
24754
+ const chainId = params.chainId ?? ctxChainId;
24755
+ const internalEnabled = !!symmCoreClient && !!userAddress;
24756
+ const query = useQuery({
24757
+ ...params.query,
24758
+ queryKey: symmKeys.accountsApi(userAddress, chainId),
24759
+ queryFn: () => symmCoreClient.accounts.list({
24760
+ userAddress,
24761
+ chainId
24762
+ }),
24763
+ enabled: internalEnabled && (params.query?.enabled ?? true),
24764
+ staleTime: params.query?.staleTime ?? 1e4
24765
+ });
24766
+ return {
24767
+ accounts: query.data?.data?.accounts ?? [],
24768
+ total: query.data?.data?.total ?? 0,
24769
+ isLoading: query.isLoading,
24770
+ refetch: query.refetch
24771
+ };
24772
+ }
24773
+ function useSymmAccountsLength(params) {
24774
+ const { symmCoreClient, chainId: ctxChainId } = useSymmContext();
24775
+ const { userAddress } = params;
24776
+ const chainId = params.chainId ?? ctxChainId;
24777
+ const internalEnabled = !!symmCoreClient && !!userAddress;
24778
+ const query = useQuery({
24779
+ ...params.query,
24780
+ queryKey: symmKeys.accountsLength(userAddress, chainId),
24781
+ queryFn: () => symmCoreClient.accounts.getLength({
24782
+ userAddress,
24783
+ chainId
24784
+ }),
24785
+ enabled: internalEnabled && (params.query?.enabled ?? true),
24786
+ staleTime: params.query?.staleTime ?? 1e4
24787
+ });
24788
+ return {
24789
+ chains: query.data?.data?.chains ?? [],
24790
+ total: query.data?.data?.total ?? 0,
24791
+ isLoading: query.isLoading,
24792
+ refetch: query.refetch
24793
+ };
24794
+ }
24795
+ function useSymmAccountsWithPositions(params) {
24796
+ const { symmCoreClient, chainId: ctxChainId } = useSymmContext();
24797
+ const { userAddress } = params;
24798
+ const chainId = params.chainId ?? ctxChainId;
24799
+ const internalEnabled = !!symmCoreClient && !!userAddress;
24800
+ const query = useQuery({
24801
+ ...params.query,
24802
+ queryKey: symmKeys.accountsWithPositions(userAddress, chainId),
24803
+ queryFn: () => symmCoreClient.accounts.getWithPositions({
24804
+ userAddress,
24805
+ chainId
24806
+ }),
24807
+ enabled: internalEnabled && (params.query?.enabled ?? true),
24808
+ staleTime: params.query?.staleTime ?? 1e4
24809
+ });
24810
+ return {
24811
+ accounts: query.data?.data?.accounts ?? [],
24812
+ total: query.data?.data?.total ?? 0,
24813
+ isLoading: query.isLoading,
24814
+ refetch: query.refetch
24815
+ };
24816
+ }
24729
24817
  function useSymmApproval(params) {
24730
- const { symmioClient } = useSymmContext();
24818
+ const { symmioClient, chainId } = useSymmContext();
24731
24819
  const queryClient = useQueryClient();
24732
24820
  const { owner, amount, spender, collateralToken } = params;
24733
24821
  const resolvedSpender = spender ?? symmioClient?.addresses.multiAccount;
@@ -24742,7 +24830,7 @@ function useSymmApproval(params) {
24742
24830
  const internalEnabled = !!symmioClient && !!owner && !!resolvedSpender && !!resolvedToken;
24743
24831
  const approvalQuery = useQuery({
24744
24832
  ...params.query,
24745
- queryKey: symmKeys.approval(owner, resolvedSpender),
24833
+ queryKey: symmKeys.approval(owner, resolvedSpender, chainId),
24746
24834
  queryFn: async () => {
24747
24835
  const [allowance, balance] = await Promise.all([
24748
24836
  symmioClient.approval.getAllowance(resolvedToken, owner, resolvedSpender),
@@ -24760,7 +24848,7 @@ function useSymmApproval(params) {
24760
24848
  },
24761
24849
  onSuccess: () => {
24762
24850
  queryClient.invalidateQueries({
24763
- queryKey: symmKeys.approval(owner, resolvedSpender)
24851
+ queryKey: symmKeys.approval(owner, resolvedSpender, chainId)
24764
24852
  });
24765
24853
  }
24766
24854
  });
@@ -24772,6 +24860,57 @@ function useSymmApproval(params) {
24772
24860
  approve: approve2
24773
24861
  };
24774
24862
  }
24863
+ function useSymmCancelClose() {
24864
+ const { symmCoreClient, authToken: ctxAuthToken, refreshAuth, chainId } = useSymmContext();
24865
+ const queryClient = useQueryClient();
24866
+ const cancelClose = useMutation({
24867
+ mutationFn: async ({
24868
+ quoteId,
24869
+ authToken,
24870
+ accountAddress,
24871
+ overrideChainId
24872
+ }) => {
24873
+ if (!symmCoreClient) {
24874
+ throw new Error("symm-core client not available");
24875
+ }
24876
+ const resolvedAuthToken = authToken ?? ctxAuthToken ?? (accountAddress ? await refreshAuth(accountAddress) : null);
24877
+ if (!resolvedAuthToken) {
24878
+ throw new Error("auth token is required to cancel a pending close");
24879
+ }
24880
+ return symmCoreClient.orders.cancelClose({
24881
+ quoteId,
24882
+ authToken: resolvedAuthToken,
24883
+ chainId: overrideChainId ?? chainId
24884
+ });
24885
+ },
24886
+ onSuccess: () => {
24887
+ invalidateOrders(queryClient);
24888
+ invalidatePositions(queryClient);
24889
+ }
24890
+ });
24891
+ return { cancelClose };
24892
+ }
24893
+ function useSymmCloseOrder() {
24894
+ const { symmCoreClient, authToken: ctxAuthToken } = useSymmContext();
24895
+ const queryClient = useQueryClient();
24896
+ const closeOrder = useMutation({
24897
+ mutationFn: async (request) => {
24898
+ if (!symmCoreClient) {
24899
+ throw new Error("symm-core client not available");
24900
+ }
24901
+ return symmCoreClient.orders.close(request.id, {
24902
+ kind: request.kind,
24903
+ type: request.type,
24904
+ authToken: request.authToken ?? ctxAuthToken ?? void 0
24905
+ });
24906
+ },
24907
+ onSuccess: () => {
24908
+ invalidateOrders(queryClient);
24909
+ invalidatePositions(queryClient);
24910
+ }
24911
+ });
24912
+ return { closeOrder };
24913
+ }
24775
24914
  function useSymmDeposit() {
24776
24915
  const { symmioClient } = useSymmContext();
24777
24916
  const queryClient = useQueryClient();
@@ -24866,12 +25005,12 @@ function useSymmCollateral() {
24866
25005
  return { allocate: allocate2, deallocate: deallocate2, internalTransfer: internalTransfer2 };
24867
25006
  }
24868
25007
  function useSymmSignature(userAddress, options) {
24869
- const { symmioClient } = useSymmContext();
25008
+ const { symmioClient, chainId } = useSymmContext();
24870
25009
  const queryClient = useQueryClient();
24871
25010
  const internalEnabled = !!symmioClient && !!userAddress;
24872
25011
  const signedQuery = useQuery({
24873
25012
  ...options?.query,
24874
- queryKey: symmKeys.signature(userAddress),
25013
+ queryKey: symmKeys.signature(userAddress, chainId),
24875
25014
  queryFn: () => symmioClient.signature.hasSigned(userAddress),
24876
25015
  enabled: internalEnabled && (options?.query?.enabled ?? true)
24877
25016
  });
@@ -24883,7 +25022,7 @@ function useSymmSignature(userAddress, options) {
24883
25022
  },
24884
25023
  onSuccess: () => {
24885
25024
  queryClient.invalidateQueries({
24886
- queryKey: symmKeys.signature(userAddress)
25025
+ queryKey: symmKeys.signature(userAddress, chainId)
24887
25026
  });
24888
25027
  }
24889
25028
  });
@@ -24894,7 +25033,7 @@ function useSymmSignature(userAddress, options) {
24894
25033
  };
24895
25034
  }
24896
25035
  function useSymmAvailableMargin(params) {
24897
- const { symmioClient } = useSymmContext();
25036
+ const { symmioClient, chainId } = useSymmContext();
24898
25037
  const { accountAddress, upnl } = params;
24899
25038
  const resolvedUpnl = upnl ?? 0n;
24900
25039
  const selectWithUpnl = useCallback(
@@ -24908,7 +25047,7 @@ function useSymmAvailableMargin(params) {
24908
25047
  const internalEnabled = !!symmioClient && !!accountAddress;
24909
25048
  const query = useQuery({
24910
25049
  ...params.query,
24911
- queryKey: symmKeys.availableMargin(accountAddress, symmioClient?.chainId),
25050
+ queryKey: symmKeys.availableMargin(accountAddress, chainId),
24912
25051
  queryFn: () => symmioClient.stats.getPartyAStats(accountAddress),
24913
25052
  select: selectWithUpnl,
24914
25053
  enabled: internalEnabled && (params.query?.enabled ?? true),
@@ -25131,6 +25270,40 @@ function useSymmTpsl() {
25131
25270
  });
25132
25271
  return { setTpsl, cancelTpsl };
25133
25272
  }
25273
+ function useSymmTpslOrders(params) {
25274
+ const { symmCoreClient, chainId: ctxChainId } = useSymmContext();
25275
+ const { accountAddress, mainAddress, positionId, type, status } = params;
25276
+ const chainId = params.chainId ?? ctxChainId;
25277
+ const internalEnabled = !!symmCoreClient && !!(accountAddress || mainAddress || positionId);
25278
+ const request = {
25279
+ address: accountAddress,
25280
+ mainAddress,
25281
+ positionId,
25282
+ type,
25283
+ status,
25284
+ chainId
25285
+ };
25286
+ const query = useQuery({
25287
+ ...params.query,
25288
+ queryKey: symmKeys.tpslOrdersList({
25289
+ accountAddress,
25290
+ mainAddress,
25291
+ positionId,
25292
+ type,
25293
+ status,
25294
+ chainId
25295
+ }),
25296
+ queryFn: () => symmCoreClient.orders.getTpslOrders(request),
25297
+ enabled: internalEnabled && (params.query?.enabled ?? true),
25298
+ staleTime: params.query?.staleTime ?? 5e3
25299
+ });
25300
+ return {
25301
+ tpslOrders: query.data?.data?.tpslOrders ?? [],
25302
+ total: query.data?.data?.total ?? 0,
25303
+ isLoading: query.isLoading,
25304
+ refetch: query.refetch
25305
+ };
25306
+ }
25134
25307
  function useSymmTwap(params) {
25135
25308
  const { symmCoreClient, chainId: ctxChainId } = useSymmContext();
25136
25309
  const queryClient = useQueryClient();
@@ -25163,6 +25336,90 @@ function useSymmTwap(params) {
25163
25336
  cancelTwap
25164
25337
  };
25165
25338
  }
25339
+ function useSymmTriggerConfig(params) {
25340
+ const { symmCoreClient } = useSymmContext();
25341
+ const queryClient = useQueryClient();
25342
+ const { orderId } = params;
25343
+ const internalEnabled = !!symmCoreClient && !!orderId;
25344
+ const query = useQuery({
25345
+ ...params.query,
25346
+ queryKey: symmKeys.triggerConfig(orderId),
25347
+ queryFn: () => symmCoreClient.orders.getTriggerConfig(orderId),
25348
+ enabled: internalEnabled && (params.query?.enabled ?? true),
25349
+ staleTime: params.query?.staleTime ?? 5e3
25350
+ });
25351
+ const setTriggerConfig = useMutation({
25352
+ mutationFn: async (request) => {
25353
+ if (!symmCoreClient || !orderId) {
25354
+ throw new Error("symm-core client or orderId not available");
25355
+ }
25356
+ return symmCoreClient.orders.setTriggerConfig(orderId, request);
25357
+ },
25358
+ onSuccess: () => {
25359
+ queryClient.invalidateQueries({
25360
+ queryKey: symmKeys.triggerConfig(orderId)
25361
+ });
25362
+ invalidateOrders(queryClient);
25363
+ }
25364
+ });
25365
+ const clearTriggerConfig = useMutation({
25366
+ mutationFn: async () => {
25367
+ if (!symmCoreClient || !orderId) {
25368
+ throw new Error("symm-core client or orderId not available");
25369
+ }
25370
+ return symmCoreClient.orders.clearTriggerConfig(orderId);
25371
+ },
25372
+ onSuccess: () => {
25373
+ queryClient.invalidateQueries({
25374
+ queryKey: symmKeys.triggerConfig(orderId)
25375
+ });
25376
+ invalidateOrders(queryClient);
25377
+ }
25378
+ });
25379
+ return {
25380
+ triggerConfig: query.data?.data?.triggerConfig ?? null,
25381
+ isLoading: query.isLoading,
25382
+ refetch: query.refetch,
25383
+ setTriggerConfig,
25384
+ clearTriggerConfig
25385
+ };
25386
+ }
25387
+ function useSymmTriggerOrders(params) {
25388
+ const { symmCoreClient, chainId: ctxChainId } = useSymmContext();
25389
+ const { accountAddress, mainAddress, status, limit, offset } = params;
25390
+ const chainId = params.chainId ?? ctxChainId;
25391
+ const internalEnabled = !!symmCoreClient && !!(accountAddress || mainAddress);
25392
+ const request = {
25393
+ address: accountAddress,
25394
+ mainAddress,
25395
+ chainId,
25396
+ status,
25397
+ limit,
25398
+ offset
25399
+ };
25400
+ const query = useQuery({
25401
+ ...params.query,
25402
+ queryKey: symmKeys.triggerOrders({
25403
+ accountAddress,
25404
+ mainAddress,
25405
+ chainId,
25406
+ status,
25407
+ limit,
25408
+ offset
25409
+ }),
25410
+ queryFn: () => symmCoreClient.orders.listTriggerOrders(request),
25411
+ enabled: internalEnabled && (params.query?.enabled ?? true),
25412
+ staleTime: params.query?.staleTime ?? 5e3
25413
+ });
25414
+ return {
25415
+ orders: query.data?.data?.orders ?? [],
25416
+ total: query.data?.data?.total ?? 0,
25417
+ limit: query.data?.data?.limit ?? limit ?? 0,
25418
+ offset: query.data?.data?.offset ?? offset ?? 0,
25419
+ isLoading: query.isLoading,
25420
+ refetch: query.refetch
25421
+ };
25422
+ }
25166
25423
  function useSymmMarkets(params) {
25167
25424
  const { symmCoreClient, chainId: ctxChainId } = useSymmContext();
25168
25425
  const chainId = params?.chainId ?? ctxChainId;
@@ -25186,6 +25443,66 @@ function useSymmMarkets(params) {
25186
25443
  refetch: query.refetch
25187
25444
  };
25188
25445
  }
25446
+ function useSymmHedgerMarketById(params) {
25447
+ const { symmCoreClient, chainId: ctxChainId } = useSymmContext();
25448
+ const { id } = params;
25449
+ const chainId = params.chainId ?? ctxChainId;
25450
+ const internalEnabled = !!symmCoreClient && id != null;
25451
+ const query = useQuery({
25452
+ ...params.query,
25453
+ queryKey: symmKeys.hedgerMarketById(id, chainId),
25454
+ queryFn: () => symmCoreClient.markets.getById(id, chainId),
25455
+ enabled: internalEnabled && (params.query?.enabled ?? true),
25456
+ staleTime: params.query?.staleTime ?? 3e4
25457
+ });
25458
+ return {
25459
+ market: query.data?.data?.markets?.[0] ?? null,
25460
+ markets: query.data?.data?.markets ?? [],
25461
+ isLoading: query.isLoading,
25462
+ refetch: query.refetch
25463
+ };
25464
+ }
25465
+ function useSymmHedgerMarketBySymbol(params) {
25466
+ const { symmCoreClient, chainId: ctxChainId } = useSymmContext();
25467
+ const { symbol } = params;
25468
+ const chainId = params.chainId ?? ctxChainId;
25469
+ const internalEnabled = !!symmCoreClient && !!symbol;
25470
+ const query = useQuery({
25471
+ ...params.query,
25472
+ queryKey: symmKeys.hedgerMarketBySymbol(symbol, chainId),
25473
+ queryFn: () => symmCoreClient.markets.getBySymbol(symbol, chainId),
25474
+ enabled: internalEnabled && (params.query?.enabled ?? true),
25475
+ staleTime: params.query?.staleTime ?? 3e4
25476
+ });
25477
+ return {
25478
+ market: query.data?.data?.markets?.[0] ?? null,
25479
+ markets: query.data?.data?.markets ?? [],
25480
+ isLoading: query.isLoading,
25481
+ refetch: query.refetch
25482
+ };
25483
+ }
25484
+ function useSymmLockedParams(params) {
25485
+ const { symmCoreClient, chainId: ctxChainId } = useSymmContext();
25486
+ const { marketName, leverage } = params;
25487
+ const chainId = params.chainId ?? ctxChainId;
25488
+ const internalEnabled = !!symmCoreClient && !!marketName && leverage != null;
25489
+ const query = useQuery({
25490
+ ...params.query,
25491
+ queryKey: symmKeys.lockedParams(marketName, leverage, chainId),
25492
+ queryFn: () => symmCoreClient.markets.getLockedParams({
25493
+ marketName,
25494
+ leverage,
25495
+ chainId
25496
+ }),
25497
+ enabled: internalEnabled && (params.query?.enabled ?? true),
25498
+ staleTime: params.query?.staleTime ?? 3e4
25499
+ });
25500
+ return {
25501
+ lockedParams: query.data?.data ?? null,
25502
+ isLoading: query.isLoading,
25503
+ refetch: query.refetch
25504
+ };
25505
+ }
25189
25506
  var EMPTY_MARKETS = [];
25190
25507
  var EMPTY_SYMBOLS = [];
25191
25508
  var EMPTY_MAP_BY_ID = /* @__PURE__ */ new Map();
@@ -25242,6 +25559,72 @@ function useSymmFunding(params) {
25242
25559
  isLoading: query.isLoading
25243
25560
  };
25244
25561
  }
25562
+ function useSymmFundingHistory(params) {
25563
+ const { symmCoreClient, chainId: ctxChainId } = useSymmContext();
25564
+ const chainId = params.chainId ?? ctxChainId;
25565
+ const {
25566
+ period,
25567
+ longSymbols,
25568
+ shortSymbols,
25569
+ interval,
25570
+ weightMode,
25571
+ includeContributions
25572
+ } = params;
25573
+ const internalEnabled = !!symmCoreClient;
25574
+ const request = {
25575
+ chainId,
25576
+ period,
25577
+ longSymbols,
25578
+ shortSymbols,
25579
+ interval,
25580
+ weightMode,
25581
+ includeContributions
25582
+ };
25583
+ const query = useQuery({
25584
+ ...params.query,
25585
+ queryKey: symmKeys.fundingHistory(request),
25586
+ queryFn: () => symmCoreClient.funding.getHistory(request),
25587
+ enabled: internalEnabled && (params.query?.enabled ?? true),
25588
+ staleTime: params.query?.staleTime ?? 3e4
25589
+ });
25590
+ return {
25591
+ history: query.data?.data ?? null,
25592
+ isLoading: query.isLoading,
25593
+ refetch: query.refetch
25594
+ };
25595
+ }
25596
+ function useSymmFundingPayments(params) {
25597
+ const { symmCoreClient, chainId: ctxChainId } = useSymmContext();
25598
+ const { address, positionId, limit, offset } = params;
25599
+ const chainId = params.chainId ?? ctxChainId;
25600
+ const internalEnabled = !!symmCoreClient && !!(address || positionId);
25601
+ const request = {
25602
+ address,
25603
+ positionId,
25604
+ chainId,
25605
+ limit,
25606
+ offset
25607
+ };
25608
+ const query = useQuery({
25609
+ ...params.query,
25610
+ queryKey: symmKeys.fundingPayments({
25611
+ address,
25612
+ positionId,
25613
+ chainId,
25614
+ limit,
25615
+ offset
25616
+ }),
25617
+ queryFn: () => symmCoreClient.funding.getPayments(request),
25618
+ enabled: internalEnabled && (params.query?.enabled ?? true),
25619
+ staleTime: params.query?.staleTime ?? 3e4
25620
+ });
25621
+ return {
25622
+ payments: query.data?.data?.payments ?? [],
25623
+ total: query.data?.data?.total ?? 0,
25624
+ isLoading: query.isLoading,
25625
+ refetch: query.refetch
25626
+ };
25627
+ }
25245
25628
  function useSymmPortfolio(params) {
25246
25629
  const { symmCoreClient, chainId: ctxChainId } = useSymmContext();
25247
25630
  const { accountAddress, mainAddress } = params;
@@ -25291,11 +25674,12 @@ function useSymmNotifications(params) {
25291
25674
  staleTime: params.query?.staleTime ?? 1e4
25292
25675
  });
25293
25676
  const markRead = useMutation({
25294
- mutationFn: async ({ id }) => {
25677
+ mutationFn: async ({ id, timestamp }) => {
25295
25678
  if (!symmCoreClient || !userAddress)
25296
25679
  throw new Error("symm-core client not available");
25297
25680
  return symmCoreClient.notifications.markRead({
25298
25681
  id,
25682
+ timestamp,
25299
25683
  userAddress,
25300
25684
  chainId
25301
25685
  });
@@ -25317,6 +25701,78 @@ function useSymmNotifications(params) {
25317
25701
  refetch: notificationsQuery.refetch
25318
25702
  };
25319
25703
  }
25704
+ function useSymmPendingIds(params) {
25705
+ const { symmCoreClient, chainId: ctxChainId } = useSymmContext();
25706
+ const { accountAddress } = params;
25707
+ const chainId = params.chainId ?? ctxChainId;
25708
+ const internalEnabled = !!symmCoreClient && !!accountAddress;
25709
+ const query = useQuery({
25710
+ ...params.query,
25711
+ queryKey: symmKeys.pendingIds(accountAddress, chainId),
25712
+ queryFn: () => symmCoreClient.positions.getPendingIds({
25713
+ address: accountAddress,
25714
+ chainId
25715
+ }),
25716
+ enabled: internalEnabled && (params.query?.enabled ?? true),
25717
+ staleTime: params.query?.staleTime ?? 5e3
25718
+ });
25719
+ return {
25720
+ pendingIds: query.data?.data?.pendingIds ?? [],
25721
+ isLoading: query.isLoading,
25722
+ refetch: query.refetch
25723
+ };
25724
+ }
25725
+ function useSymmPendingInstantOpens(params) {
25726
+ const {
25727
+ symmCoreClient,
25728
+ chainId: ctxChainId,
25729
+ authToken: ctxAuthToken,
25730
+ refreshAuth
25731
+ } = useSymmContext();
25732
+ const { accountAddress, authToken: providedAuthToken } = params;
25733
+ const chainId = params.chainId ?? ctxChainId;
25734
+ const internalEnabled = !!symmCoreClient && !!accountAddress;
25735
+ const query = useQuery({
25736
+ ...params.query,
25737
+ queryKey: symmKeys.pendingInstantOpens(accountAddress, chainId),
25738
+ queryFn: async () => {
25739
+ const authToken = providedAuthToken ?? ctxAuthToken ?? await refreshAuth(accountAddress);
25740
+ if (!authToken) {
25741
+ throw new Error("failed to acquire auth token for pending instant opens");
25742
+ }
25743
+ return symmCoreClient.positions.getPendingInstantOpens({
25744
+ accountAddress,
25745
+ chainId,
25746
+ authToken
25747
+ });
25748
+ },
25749
+ enabled: internalEnabled && (params.query?.enabled ?? true),
25750
+ staleTime: params.query?.staleTime ?? 5e3
25751
+ });
25752
+ return {
25753
+ pendingOpens: query.data?.data?.pendingOpens ?? [],
25754
+ total: query.data?.data?.total ?? 0,
25755
+ isLoading: query.isLoading,
25756
+ refetch: query.refetch
25757
+ };
25758
+ }
25759
+ function useSymmTwapOrder(params) {
25760
+ const { symmCoreClient } = useSymmContext();
25761
+ const { orderId } = params;
25762
+ const internalEnabled = !!symmCoreClient && !!orderId;
25763
+ const query = useQuery({
25764
+ ...params.query,
25765
+ queryKey: symmKeys.twapOrder(orderId),
25766
+ queryFn: () => symmCoreClient.orders.getTwapOrder(orderId),
25767
+ enabled: internalEnabled && (params.query?.enabled ?? true),
25768
+ staleTime: params.query?.staleTime ?? 5e3
25769
+ });
25770
+ return {
25771
+ order: query.data?.data ?? null,
25772
+ isLoading: query.isLoading,
25773
+ refetch: query.refetch
25774
+ };
25775
+ }
25320
25776
  function asUnsubscribeFn(value) {
25321
25777
  return typeof value === "function" ? value : null;
25322
25778
  }
@@ -25374,17 +25830,20 @@ function useSymmWs(params) {
25374
25830
  }));
25375
25831
  if (notificationsUnsub) unsubscribers.push(notificationsUnsub);
25376
25832
  const tpslUnsub = asUnsubscribeFn(ws.subscribeToTpsl(addr, chainId, () => {
25377
- queryClient.invalidateQueries({
25378
- queryKey: symmKeys.tpslOrders(accountAddress, chainId)
25379
- });
25833
+ queryClient.invalidateQueries({ queryKey: ["symm", "tpslOrders"] });
25834
+ queryClient.invalidateQueries({ queryKey: ["symm", "openOrders"] });
25380
25835
  }));
25381
25836
  if (tpslUnsub) unsubscribers.push(tpslUnsub);
25382
25837
  const twapUnsub = asUnsubscribeFn(ws.subscribeToTwapOrders(addr, chainId, () => {
25383
- queryClient.invalidateQueries({
25384
- queryKey: symmKeys.twapOrders(accountAddress, chainId)
25385
- });
25838
+ queryClient.invalidateQueries({ queryKey: ["symm", "twapOrders"] });
25839
+ queryClient.invalidateQueries({ queryKey: ["symm", "openOrders"] });
25386
25840
  }));
25387
25841
  if (twapUnsub) unsubscribers.push(twapUnsub);
25842
+ const triggerOrdersUnsub = asUnsubscribeFn(ws.subscribeToTriggerOrders(addr, chainId, () => {
25843
+ queryClient.invalidateQueries({ queryKey: ["symm", "triggerOrders"] });
25844
+ queryClient.invalidateQueries({ queryKey: ["symm", "openOrders"] });
25845
+ }));
25846
+ if (triggerOrdersUnsub) unsubscribers.push(triggerOrdersUnsub);
25388
25847
  const executionsUnsub = asUnsubscribeFn(ws.subscribeToExecutions(addr, chainId, () => {
25389
25848
  queryClient.invalidateQueries({
25390
25849
  queryKey: symmKeys.positions(accountAddress, chainId)
@@ -26424,6 +26883,6 @@ function getSymmErrorMessage(error) {
26424
26883
  return "An unexpected error occurred.";
26425
26884
  }
26426
26885
 
26427
- export { SymmProvider, getSymmErrorMessage, symmKeys, useSymmAccountData, useSymmAccountSummary, useSymmAccounts, useSymmApproval, useSymmAuth, useSymmAvailableMargin, useSymmBalances, useSymmChartCandles, useSymmChartSelection, useSymmCollateral, useSymmContext, useSymmCoreClient, useSymmDelegation, useSymmDeposit, useSymmFunding, useSymmHedgerMarkets, useSymmInstantTrade, useSymmMarkets, useSymmNotifications, useSymmOpenOrders, useSymmPerformanceOverlays, useSymmPortfolio, useSymmPositions, useSymmSignature, useSymmTokenSelectionMetadata, useSymmTpsl, useSymmTrade, useSymmTradeHistory, useSymmTwap, useSymmWithdraw, useSymmWs, useSymmioClient };
26886
+ export { SymmProvider, getSymmErrorMessage, symmKeys, useSymmAccountData, useSymmAccountSummary, useSymmAccounts, useSymmAccountsApi, useSymmAccountsLength, useSymmAccountsWithPositions, useSymmApproval, useSymmAuth, useSymmAvailableMargin, useSymmBalances, useSymmCancelClose, useSymmChartCandles, useSymmChartSelection, useSymmCloseOrder, useSymmCollateral, useSymmContext, useSymmCoreClient, useSymmDelegation, useSymmDeposit, useSymmFunding, useSymmFundingHistory, useSymmFundingPayments, useSymmHedgerMarketById, useSymmHedgerMarketBySymbol, useSymmHedgerMarkets, useSymmInstantTrade, useSymmLockedParams, useSymmMarkets, useSymmNotifications, useSymmOpenOrders, useSymmPendingIds, useSymmPendingInstantOpens, useSymmPerformanceOverlays, useSymmPortfolio, useSymmPositions, useSymmSignature, useSymmTokenSelectionMetadata, useSymmTpsl, useSymmTpslOrders, useSymmTrade, useSymmTradeHistory, useSymmTriggerConfig, useSymmTriggerOrders, useSymmTwap, useSymmTwapOrder, useSymmWithdraw, useSymmWs, useSymmioClient };
26428
26887
  //# sourceMappingURL=index.mjs.map
26429
26888
  //# sourceMappingURL=index.mjs.map