@pear-protocol/symmio-client 0.2.49 → 0.3.1
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/react/index.d.mts +20 -3
- package/dist/react/index.d.ts +20 -3
- package/dist/react/index.js +320 -75
- package/dist/react/index.js.map +1 -1
- package/dist/react/index.mjs +320 -75
- package/dist/react/index.mjs.map +1 -1
- package/dist/react/provider.js +280 -0
- package/dist/react/provider.js.map +1 -1
- package/dist/react/provider.mjs +281 -1
- package/dist/react/provider.mjs.map +1 -1
- package/package.json +2 -2
package/dist/react/index.mjs
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
import { createContext, useContext, useMemo, useCallback, useRef, useEffect } from 'react';
|
|
3
3
|
import { createSymmSDK, isAuthExpiredError, isNetworkError, isInsufficientMarginError, isRateLimitedError, isTimeoutError } from '@pear-protocol/symm-core';
|
|
4
4
|
import { create } from 'zustand';
|
|
5
|
-
import { jsx } from 'react/jsx-runtime';
|
|
6
5
|
import { useQueryClient, useQuery, useMutation } from '@tanstack/react-query';
|
|
6
|
+
import { jsx } from 'react/jsx-runtime';
|
|
7
7
|
import { SiweMessage } from 'siwe';
|
|
8
8
|
import { isAddress, encodeFunctionData } from 'viem';
|
|
9
9
|
|
|
@@ -488,6 +488,280 @@ function useBinanceWs(params) {
|
|
|
488
488
|
};
|
|
489
489
|
}, [symmCoreClient, chainId, subscribeSymbol, unsubscribeSymbol]);
|
|
490
490
|
}
|
|
491
|
+
|
|
492
|
+
// src/react/query-keys.ts
|
|
493
|
+
var symmKeys = {
|
|
494
|
+
all: ["symm"],
|
|
495
|
+
balancesRoot: ["symm", "balances"],
|
|
496
|
+
accountSummaryRoot: ["symm", "accountSummary"],
|
|
497
|
+
accountDataRoot: ["symm", "accountData"],
|
|
498
|
+
approvalRoot: ["symm", "approval"],
|
|
499
|
+
positionsRoot: ["symm", "positions"],
|
|
500
|
+
openOrdersRoot: ["symm", "openOrders"],
|
|
501
|
+
tradeHistoryRoot: ["symm", "tradeHistory"],
|
|
502
|
+
portfolioRoot: ["symm", "portfolio"],
|
|
503
|
+
tpslOrdersRoot: ["symm", "tpslOrders"],
|
|
504
|
+
twapOrdersRoot: ["symm", "twapOrders"],
|
|
505
|
+
triggerOrdersRoot: ["symm", "triggerOrders"],
|
|
506
|
+
accounts: (address, chainId) => ["symm", "accounts", address, chainId],
|
|
507
|
+
accountsApi: (address, chainId) => ["symm", "accountsApi", address, chainId],
|
|
508
|
+
accountsLength: (address, chainId) => ["symm", "accountsLength", address, chainId],
|
|
509
|
+
accountsWithPositions: (address, chainId) => ["symm", "accountsWithPositions", address, chainId],
|
|
510
|
+
accountSummary: (address, chainId) => ["symm", "accountSummary", address, chainId],
|
|
511
|
+
accountData: (address, chainId, upnl) => ["symm", "accountData", address, chainId, upnl],
|
|
512
|
+
signature: (address, chainId) => ["symm", "signature", address, chainId],
|
|
513
|
+
auth: (accountAddress, chainId, signerAddress) => ["symm", "auth", accountAddress, chainId, signerAddress],
|
|
514
|
+
approval: (owner, spender, chainId, token) => ["symm", "approval", owner, spender, chainId, token],
|
|
515
|
+
balances: (address, chainId) => ["symm", "balances", address, chainId],
|
|
516
|
+
positions: (params) => ["symm", "positions", params],
|
|
517
|
+
openOrders: (params) => ["symm", "openOrders", params],
|
|
518
|
+
tradeHistory: (params) => ["symm", "tradeHistory", params],
|
|
519
|
+
tpslOrders: (address, chainId) => ["symm", "tpslOrders", address, chainId],
|
|
520
|
+
tpslOrdersList: (params) => ["symm", "tpslOrders", params],
|
|
521
|
+
twapOrders: (address, chainId) => ["symm", "twapOrders", address, chainId],
|
|
522
|
+
triggerOrders: (params) => ["symm", "triggerOrders", params],
|
|
523
|
+
triggerConfig: (orderId) => ["symm", "triggerConfig", orderId],
|
|
524
|
+
markets: (chainId, search, pageSize) => ["symm", "markets", chainId, search, pageSize],
|
|
525
|
+
hedgerMarketById: (id, chainId) => ["symm", "hedgerMarketById", id, chainId],
|
|
526
|
+
hedgerMarketBySymbol: (symbol, chainId) => ["symm", "hedgerMarketBySymbol", symbol, chainId],
|
|
527
|
+
lockedParams: (marketName, leverage, chainId) => ["symm", "lockedParams", marketName, leverage, chainId],
|
|
528
|
+
hedgerMarkets: (request) => ["symm", "hedgerMarkets", request],
|
|
529
|
+
fundingRates: (chainId) => ["symm", "fundingRates", chainId],
|
|
530
|
+
fundingPayments: (params) => ["symm", "fundingPayments", params],
|
|
531
|
+
fundingHistory: (params) => ["symm", "fundingHistory", params],
|
|
532
|
+
portfolio: (params) => ["symm", "portfolio", params],
|
|
533
|
+
notifications: (params) => ["symm", "notifications", params],
|
|
534
|
+
unreadCount: (params) => ["symm", "unreadCount", params],
|
|
535
|
+
availableMargin: (address, chainId) => ["symm", "availableMargin", address, chainId],
|
|
536
|
+
pendingIds: (address, chainId) => ["symm", "pendingIds", address, chainId],
|
|
537
|
+
pendingInstantOpens: (accountAddress, chainId) => ["symm", "pendingInstantOpens", accountAddress, chainId],
|
|
538
|
+
twapOrder: (orderId) => ["symm", "twapOrder", orderId],
|
|
539
|
+
delegation: (account, target, selectors, chainId) => ["symm", "delegation", account, target, selectors, chainId],
|
|
540
|
+
chartMetadata: (symbolsKey, positionKey) => ["symm", "chartMetadata", symbolsKey, positionKey]
|
|
541
|
+
};
|
|
542
|
+
var useSymmWsStore = create((set) => ({
|
|
543
|
+
isConnected: false,
|
|
544
|
+
setConnected: (isConnected) => set({ isConnected })
|
|
545
|
+
}));
|
|
546
|
+
|
|
547
|
+
// src/react/hooks/use-symm-ws.ts
|
|
548
|
+
function asUnsubscribeFn(value) {
|
|
549
|
+
return typeof value === "function" ? value : null;
|
|
550
|
+
}
|
|
551
|
+
function logSymmWs(event, details) {
|
|
552
|
+
if (typeof window === "undefined") {
|
|
553
|
+
return;
|
|
554
|
+
}
|
|
555
|
+
console.debug("[symm-ws]", event, details ?? {});
|
|
556
|
+
}
|
|
557
|
+
function useSymmWs(params = {}) {
|
|
558
|
+
const ctx = useContext(SymmContext);
|
|
559
|
+
const queryClient = useQueryClient();
|
|
560
|
+
const isConnected = useSymmWsStore((state) => state.isConnected);
|
|
561
|
+
const setConnected = useSymmWsStore((state) => state.setConnected);
|
|
562
|
+
const symmCoreClient = params.symmCoreClient ?? ctx?.symmCoreClient ?? null;
|
|
563
|
+
const accountAddress = params.accountAddress ?? ctx?.address;
|
|
564
|
+
const chainId = params.chainId ?? ctx?.chainId ?? 42161;
|
|
565
|
+
useEffect(() => {
|
|
566
|
+
if (!symmCoreClient || !accountAddress) {
|
|
567
|
+
logSymmWs("setup:skip", {
|
|
568
|
+
hasClient: !!symmCoreClient,
|
|
569
|
+
accountAddress,
|
|
570
|
+
chainId
|
|
571
|
+
});
|
|
572
|
+
setConnected(false);
|
|
573
|
+
return;
|
|
574
|
+
}
|
|
575
|
+
const ws = symmCoreClient.ws;
|
|
576
|
+
const addr = accountAddress;
|
|
577
|
+
const unsubscribers = [];
|
|
578
|
+
let cancelled = false;
|
|
579
|
+
logSymmWs("setup:start", {
|
|
580
|
+
accountAddress: addr,
|
|
581
|
+
chainId,
|
|
582
|
+
alreadyConnected: typeof ws.isConnected === "function" ? ws.isConnected() : void 0
|
|
583
|
+
});
|
|
584
|
+
const removeOnConnect = ws.onConnect(() => {
|
|
585
|
+
logSymmWs("connection:connected", {
|
|
586
|
+
accountAddress: addr,
|
|
587
|
+
chainId
|
|
588
|
+
});
|
|
589
|
+
setConnected(true);
|
|
590
|
+
});
|
|
591
|
+
const removeOnDisconnect = ws.onDisconnect(() => {
|
|
592
|
+
logSymmWs("connection:disconnected", {
|
|
593
|
+
accountAddress: addr,
|
|
594
|
+
chainId
|
|
595
|
+
});
|
|
596
|
+
setConnected(false);
|
|
597
|
+
});
|
|
598
|
+
const removeOnError = asUnsubscribeFn(
|
|
599
|
+
ws.onError?.((error) => {
|
|
600
|
+
logSymmWs("connection:error", {
|
|
601
|
+
accountAddress: addr,
|
|
602
|
+
chainId,
|
|
603
|
+
error: error instanceof Error ? error.message : String(error)
|
|
604
|
+
});
|
|
605
|
+
})
|
|
606
|
+
);
|
|
607
|
+
const removeOnWelcome = asUnsubscribeFn(
|
|
608
|
+
ws.onWelcome?.((message) => {
|
|
609
|
+
logSymmWs("connection:welcome", {
|
|
610
|
+
accountAddress: addr,
|
|
611
|
+
chainId,
|
|
612
|
+
message
|
|
613
|
+
});
|
|
614
|
+
})
|
|
615
|
+
);
|
|
616
|
+
unsubscribers.push(removeOnConnect, removeOnDisconnect);
|
|
617
|
+
if (removeOnError) unsubscribers.push(removeOnError);
|
|
618
|
+
if (removeOnWelcome) unsubscribers.push(removeOnWelcome);
|
|
619
|
+
const positionsUnsub = asUnsubscribeFn(
|
|
620
|
+
ws.subscribeToPositions(addr, chainId, () => {
|
|
621
|
+
logSymmWs("message:positions", {
|
|
622
|
+
accountAddress: addr,
|
|
623
|
+
chainId
|
|
624
|
+
});
|
|
625
|
+
queryClient.invalidateQueries({
|
|
626
|
+
queryKey: symmKeys.positionsRoot
|
|
627
|
+
});
|
|
628
|
+
})
|
|
629
|
+
);
|
|
630
|
+
if (positionsUnsub) unsubscribers.push(positionsUnsub);
|
|
631
|
+
const openOrdersUnsub = asUnsubscribeFn(
|
|
632
|
+
ws.subscribeToOpenOrders(addr, chainId, () => {
|
|
633
|
+
logSymmWs("message:open-orders", {
|
|
634
|
+
accountAddress: addr,
|
|
635
|
+
chainId
|
|
636
|
+
});
|
|
637
|
+
queryClient.invalidateQueries({
|
|
638
|
+
queryKey: symmKeys.openOrdersRoot
|
|
639
|
+
});
|
|
640
|
+
})
|
|
641
|
+
);
|
|
642
|
+
if (openOrdersUnsub) unsubscribers.push(openOrdersUnsub);
|
|
643
|
+
const tradesUnsub = asUnsubscribeFn(
|
|
644
|
+
ws.subscribeToTrades(addr, chainId, () => {
|
|
645
|
+
logSymmWs("message:trades", {
|
|
646
|
+
accountAddress: addr,
|
|
647
|
+
chainId
|
|
648
|
+
});
|
|
649
|
+
queryClient.invalidateQueries({
|
|
650
|
+
queryKey: symmKeys.tradeHistoryRoot
|
|
651
|
+
});
|
|
652
|
+
})
|
|
653
|
+
);
|
|
654
|
+
if (tradesUnsub) unsubscribers.push(tradesUnsub);
|
|
655
|
+
const accountSummaryUnsub = asUnsubscribeFn(
|
|
656
|
+
ws.subscribeToAccountSummary(addr, chainId, () => {
|
|
657
|
+
logSymmWs("message:account-summary", {
|
|
658
|
+
accountAddress: addr,
|
|
659
|
+
chainId
|
|
660
|
+
});
|
|
661
|
+
queryClient.invalidateQueries({
|
|
662
|
+
queryKey: symmKeys.balances(accountAddress, chainId)
|
|
663
|
+
});
|
|
664
|
+
queryClient.invalidateQueries({
|
|
665
|
+
queryKey: symmKeys.accountSummary(accountAddress, chainId)
|
|
666
|
+
});
|
|
667
|
+
})
|
|
668
|
+
);
|
|
669
|
+
if (accountSummaryUnsub) unsubscribers.push(accountSummaryUnsub);
|
|
670
|
+
const notificationsUnsub = asUnsubscribeFn(
|
|
671
|
+
ws.subscribeToNotifications(addr, chainId, () => {
|
|
672
|
+
logSymmWs("message:notifications", {
|
|
673
|
+
accountAddress: addr,
|
|
674
|
+
chainId
|
|
675
|
+
});
|
|
676
|
+
queryClient.invalidateQueries({
|
|
677
|
+
queryKey: symmKeys.notifications({ accountAddress, chainId })
|
|
678
|
+
});
|
|
679
|
+
queryClient.invalidateQueries({
|
|
680
|
+
queryKey: symmKeys.unreadCount({ accountAddress, chainId })
|
|
681
|
+
});
|
|
682
|
+
})
|
|
683
|
+
);
|
|
684
|
+
if (notificationsUnsub) unsubscribers.push(notificationsUnsub);
|
|
685
|
+
const tpslUnsub = asUnsubscribeFn(
|
|
686
|
+
ws.subscribeToTpsl(addr, chainId, () => {
|
|
687
|
+
logSymmWs("message:tpsl", {
|
|
688
|
+
accountAddress: addr,
|
|
689
|
+
chainId
|
|
690
|
+
});
|
|
691
|
+
queryClient.invalidateQueries({ queryKey: symmKeys.tpslOrdersRoot });
|
|
692
|
+
queryClient.invalidateQueries({ queryKey: symmKeys.openOrdersRoot });
|
|
693
|
+
})
|
|
694
|
+
);
|
|
695
|
+
if (tpslUnsub) unsubscribers.push(tpslUnsub);
|
|
696
|
+
const twapUnsub = asUnsubscribeFn(
|
|
697
|
+
ws.subscribeToTwapOrders(addr, chainId, () => {
|
|
698
|
+
logSymmWs("message:twap-orders", {
|
|
699
|
+
accountAddress: addr,
|
|
700
|
+
chainId
|
|
701
|
+
});
|
|
702
|
+
queryClient.invalidateQueries({ queryKey: symmKeys.twapOrdersRoot });
|
|
703
|
+
queryClient.invalidateQueries({ queryKey: symmKeys.openOrdersRoot });
|
|
704
|
+
})
|
|
705
|
+
);
|
|
706
|
+
if (twapUnsub) unsubscribers.push(twapUnsub);
|
|
707
|
+
const triggerOrdersUnsub = asUnsubscribeFn(
|
|
708
|
+
ws.subscribeToTriggerOrders(addr, chainId, () => {
|
|
709
|
+
logSymmWs("message:trigger-orders", {
|
|
710
|
+
accountAddress: addr,
|
|
711
|
+
chainId
|
|
712
|
+
});
|
|
713
|
+
queryClient.invalidateQueries({ queryKey: symmKeys.triggerOrdersRoot });
|
|
714
|
+
queryClient.invalidateQueries({ queryKey: symmKeys.openOrdersRoot });
|
|
715
|
+
})
|
|
716
|
+
);
|
|
717
|
+
if (triggerOrdersUnsub) unsubscribers.push(triggerOrdersUnsub);
|
|
718
|
+
const executionsUnsub = asUnsubscribeFn(
|
|
719
|
+
ws.subscribeToExecutions(addr, chainId, () => {
|
|
720
|
+
logSymmWs("message:executions", {
|
|
721
|
+
accountAddress: addr,
|
|
722
|
+
chainId
|
|
723
|
+
});
|
|
724
|
+
queryClient.invalidateQueries({
|
|
725
|
+
queryKey: symmKeys.positionsRoot
|
|
726
|
+
});
|
|
727
|
+
queryClient.invalidateQueries({
|
|
728
|
+
queryKey: symmKeys.portfolioRoot
|
|
729
|
+
});
|
|
730
|
+
})
|
|
731
|
+
);
|
|
732
|
+
if (executionsUnsub) unsubscribers.push(executionsUnsub);
|
|
733
|
+
void ws.connect().then(() => {
|
|
734
|
+
if (cancelled) {
|
|
735
|
+
return;
|
|
736
|
+
}
|
|
737
|
+
logSymmWs("connection:connect-called", {
|
|
738
|
+
accountAddress: addr,
|
|
739
|
+
chainId
|
|
740
|
+
});
|
|
741
|
+
}).catch((error) => {
|
|
742
|
+
if (cancelled) {
|
|
743
|
+
return;
|
|
744
|
+
}
|
|
745
|
+
logSymmWs("connection:connect-failed", {
|
|
746
|
+
accountAddress: addr,
|
|
747
|
+
chainId,
|
|
748
|
+
error: error instanceof Error ? error.message : String(error)
|
|
749
|
+
});
|
|
750
|
+
setConnected(false);
|
|
751
|
+
});
|
|
752
|
+
return () => {
|
|
753
|
+
cancelled = true;
|
|
754
|
+
logSymmWs("cleanup:start", {
|
|
755
|
+
accountAddress: addr,
|
|
756
|
+
chainId
|
|
757
|
+
});
|
|
758
|
+
unsubscribers.forEach((unsubscribe) => unsubscribe());
|
|
759
|
+
ws.disconnect();
|
|
760
|
+
setConnected(false);
|
|
761
|
+
};
|
|
762
|
+
}, [symmCoreClient, accountAddress, chainId, queryClient, setConnected]);
|
|
763
|
+
return { isConnected };
|
|
764
|
+
}
|
|
491
765
|
function SymmProvider({
|
|
492
766
|
chainId = 42161,
|
|
493
767
|
address,
|
|
@@ -520,6 +794,11 @@ function SymmProvider({
|
|
|
520
794
|
symmCoreClient,
|
|
521
795
|
chainId
|
|
522
796
|
});
|
|
797
|
+
useSymmWs({
|
|
798
|
+
symmCoreClient,
|
|
799
|
+
accountAddress: address,
|
|
800
|
+
chainId
|
|
801
|
+
});
|
|
523
802
|
return /* @__PURE__ */ jsx(SymmContext.Provider, { value, children });
|
|
524
803
|
}
|
|
525
804
|
|
|
@@ -702,57 +981,6 @@ async function fetchAccessTokenEntry(walletClient, signerAddress, accountAddress
|
|
|
702
981
|
return cachedToken;
|
|
703
982
|
}
|
|
704
983
|
|
|
705
|
-
// src/react/query-keys.ts
|
|
706
|
-
var symmKeys = {
|
|
707
|
-
all: ["symm"],
|
|
708
|
-
balancesRoot: ["symm", "balances"],
|
|
709
|
-
accountSummaryRoot: ["symm", "accountSummary"],
|
|
710
|
-
accountDataRoot: ["symm", "accountData"],
|
|
711
|
-
approvalRoot: ["symm", "approval"],
|
|
712
|
-
positionsRoot: ["symm", "positions"],
|
|
713
|
-
openOrdersRoot: ["symm", "openOrders"],
|
|
714
|
-
tradeHistoryRoot: ["symm", "tradeHistory"],
|
|
715
|
-
portfolioRoot: ["symm", "portfolio"],
|
|
716
|
-
tpslOrdersRoot: ["symm", "tpslOrders"],
|
|
717
|
-
twapOrdersRoot: ["symm", "twapOrders"],
|
|
718
|
-
triggerOrdersRoot: ["symm", "triggerOrders"],
|
|
719
|
-
accounts: (address, chainId) => ["symm", "accounts", address, chainId],
|
|
720
|
-
accountsApi: (address, chainId) => ["symm", "accountsApi", address, chainId],
|
|
721
|
-
accountsLength: (address, chainId) => ["symm", "accountsLength", address, chainId],
|
|
722
|
-
accountsWithPositions: (address, chainId) => ["symm", "accountsWithPositions", address, chainId],
|
|
723
|
-
accountSummary: (address, chainId) => ["symm", "accountSummary", address, chainId],
|
|
724
|
-
accountData: (address, chainId, upnl) => ["symm", "accountData", address, chainId, upnl],
|
|
725
|
-
signature: (address, chainId) => ["symm", "signature", address, chainId],
|
|
726
|
-
auth: (accountAddress, chainId, signerAddress) => ["symm", "auth", accountAddress, chainId, signerAddress],
|
|
727
|
-
approval: (owner, spender, chainId, token) => ["symm", "approval", owner, spender, chainId, token],
|
|
728
|
-
balances: (address, chainId) => ["symm", "balances", address, chainId],
|
|
729
|
-
positions: (params) => ["symm", "positions", params],
|
|
730
|
-
openOrders: (params) => ["symm", "openOrders", params],
|
|
731
|
-
tradeHistory: (params) => ["symm", "tradeHistory", params],
|
|
732
|
-
tpslOrders: (address, chainId) => ["symm", "tpslOrders", address, chainId],
|
|
733
|
-
tpslOrdersList: (params) => ["symm", "tpslOrders", params],
|
|
734
|
-
twapOrders: (address, chainId) => ["symm", "twapOrders", address, chainId],
|
|
735
|
-
triggerOrders: (params) => ["symm", "triggerOrders", params],
|
|
736
|
-
triggerConfig: (orderId) => ["symm", "triggerConfig", orderId],
|
|
737
|
-
markets: (chainId, search, pageSize) => ["symm", "markets", chainId, search, pageSize],
|
|
738
|
-
hedgerMarketById: (id, chainId) => ["symm", "hedgerMarketById", id, chainId],
|
|
739
|
-
hedgerMarketBySymbol: (symbol, chainId) => ["symm", "hedgerMarketBySymbol", symbol, chainId],
|
|
740
|
-
lockedParams: (marketName, leverage, chainId) => ["symm", "lockedParams", marketName, leverage, chainId],
|
|
741
|
-
hedgerMarkets: (request) => ["symm", "hedgerMarkets", request],
|
|
742
|
-
fundingRates: (chainId) => ["symm", "fundingRates", chainId],
|
|
743
|
-
fundingPayments: (params) => ["symm", "fundingPayments", params],
|
|
744
|
-
fundingHistory: (params) => ["symm", "fundingHistory", params],
|
|
745
|
-
portfolio: (params) => ["symm", "portfolio", params],
|
|
746
|
-
notifications: (address, chainId) => ["symm", "notifications", address, chainId],
|
|
747
|
-
unreadCount: (address, chainId) => ["symm", "unreadCount", address, chainId],
|
|
748
|
-
availableMargin: (address, chainId) => ["symm", "availableMargin", address, chainId],
|
|
749
|
-
pendingIds: (address, chainId) => ["symm", "pendingIds", address, chainId],
|
|
750
|
-
pendingInstantOpens: (accountAddress, chainId) => ["symm", "pendingInstantOpens", accountAddress, chainId],
|
|
751
|
-
twapOrder: (orderId) => ["symm", "twapOrder", orderId],
|
|
752
|
-
delegation: (account, target, selectors, chainId) => ["symm", "delegation", account, target, selectors, chainId],
|
|
753
|
-
chartMetadata: (symbolsKey, positionKey) => ["symm", "chartMetadata", symbolsKey, positionKey]
|
|
754
|
-
};
|
|
755
|
-
|
|
756
984
|
// src/react/auth-cache.ts
|
|
757
985
|
function getAuthQueryData(queryClient, accountAddress, chainId, signerAddress) {
|
|
758
986
|
return queryClient.getQueryData(
|
|
@@ -25474,13 +25702,14 @@ function useSymmUpdatePositionMutation(paramsOrOptions, maybeOptions) {
|
|
|
25474
25702
|
typedRequest.authToken,
|
|
25475
25703
|
typedRequest.accountAddress
|
|
25476
25704
|
);
|
|
25477
|
-
|
|
25478
|
-
throw new Error("auth token is required to update a position");
|
|
25479
|
-
}
|
|
25480
|
-
return symmCoreClient.positions.update(positionId, {
|
|
25705
|
+
const requestWithOptionalAuth = authToken ? {
|
|
25481
25706
|
...request,
|
|
25482
25707
|
authToken
|
|
25483
|
-
}
|
|
25708
|
+
} : request;
|
|
25709
|
+
return symmCoreClient.positions.update(
|
|
25710
|
+
positionId,
|
|
25711
|
+
requestWithOptionalAuth
|
|
25712
|
+
);
|
|
25484
25713
|
}
|
|
25485
25714
|
});
|
|
25486
25715
|
}
|
|
@@ -26038,61 +26267,81 @@ function useSymmPortfolio(params) {
|
|
|
26038
26267
|
function useResolvedNotificationsParams(params) {
|
|
26039
26268
|
const { symmCoreClient, chainId: ctxChainId } = useSymmContext();
|
|
26040
26269
|
const chainId = params.chainId ?? ctxChainId;
|
|
26270
|
+
const accountAddress = params.accountAddress;
|
|
26271
|
+
const address = accountAddress ? void 0 : params.address;
|
|
26041
26272
|
return {
|
|
26042
26273
|
symmCoreClient,
|
|
26043
26274
|
chainId,
|
|
26044
|
-
|
|
26275
|
+
accountAddress,
|
|
26276
|
+
address,
|
|
26045
26277
|
query: params.query
|
|
26046
26278
|
};
|
|
26047
26279
|
}
|
|
26048
26280
|
function useSymmNotificationsQuery(params) {
|
|
26049
|
-
const { symmCoreClient, chainId,
|
|
26050
|
-
const internalEnabled = !!symmCoreClient && !!
|
|
26281
|
+
const { symmCoreClient, chainId, accountAddress, address, query } = useResolvedNotificationsParams(params);
|
|
26282
|
+
const internalEnabled = !!symmCoreClient && !!(accountAddress || address);
|
|
26283
|
+
const queryParams = {
|
|
26284
|
+
accountAddress,
|
|
26285
|
+
address,
|
|
26286
|
+
chainId
|
|
26287
|
+
};
|
|
26051
26288
|
return useQuery({
|
|
26052
26289
|
...query,
|
|
26053
|
-
queryKey: symmKeys.notifications(
|
|
26290
|
+
queryKey: symmKeys.notifications(queryParams),
|
|
26054
26291
|
queryFn: () => symmCoreClient.notifications.list({
|
|
26055
|
-
|
|
26292
|
+
accountAddress,
|
|
26293
|
+
address,
|
|
26056
26294
|
chainId
|
|
26057
26295
|
}),
|
|
26058
26296
|
enabled: internalEnabled && (query?.enabled ?? true)
|
|
26059
26297
|
});
|
|
26060
26298
|
}
|
|
26061
26299
|
function useSymmUnreadCountQuery(params) {
|
|
26062
|
-
const { symmCoreClient, chainId,
|
|
26063
|
-
const internalEnabled = !!symmCoreClient && !!
|
|
26300
|
+
const { symmCoreClient, chainId, accountAddress, address, query } = useResolvedNotificationsParams(params);
|
|
26301
|
+
const internalEnabled = !!symmCoreClient && !!(accountAddress || address);
|
|
26302
|
+
const queryParams = {
|
|
26303
|
+
accountAddress,
|
|
26304
|
+
address,
|
|
26305
|
+
chainId
|
|
26306
|
+
};
|
|
26064
26307
|
return useQuery({
|
|
26065
26308
|
...query,
|
|
26066
|
-
queryKey: symmKeys.unreadCount(
|
|
26309
|
+
queryKey: symmKeys.unreadCount(queryParams),
|
|
26067
26310
|
queryFn: () => symmCoreClient.notifications.getUnreadCount({
|
|
26068
|
-
|
|
26311
|
+
accountAddress,
|
|
26312
|
+
address,
|
|
26069
26313
|
chainId
|
|
26070
26314
|
}),
|
|
26071
26315
|
enabled: internalEnabled && (query?.enabled ?? true)
|
|
26072
26316
|
});
|
|
26073
26317
|
}
|
|
26074
26318
|
function useSymmMarkReadNotificationMutation(params, options) {
|
|
26075
|
-
const { symmCoreClient, chainId,
|
|
26319
|
+
const { symmCoreClient, chainId, accountAddress, address } = useResolvedNotificationsParams(params);
|
|
26076
26320
|
const queryClient = useQueryClient();
|
|
26321
|
+
const queryParams = {
|
|
26322
|
+
accountAddress,
|
|
26323
|
+
address,
|
|
26324
|
+
chainId
|
|
26325
|
+
};
|
|
26077
26326
|
return useMutation({
|
|
26078
26327
|
...withSymmMutationConfig(options?.mutation, {
|
|
26079
26328
|
onSuccess: () => {
|
|
26080
26329
|
queryClient.invalidateQueries({
|
|
26081
|
-
queryKey: symmKeys.notifications(
|
|
26330
|
+
queryKey: symmKeys.notifications(queryParams)
|
|
26082
26331
|
});
|
|
26083
26332
|
queryClient.invalidateQueries({
|
|
26084
|
-
queryKey: symmKeys.unreadCount(
|
|
26333
|
+
queryKey: symmKeys.unreadCount(queryParams)
|
|
26085
26334
|
});
|
|
26086
26335
|
}
|
|
26087
26336
|
}),
|
|
26088
26337
|
mutationFn: async ({ id, timestamp }) => {
|
|
26089
|
-
if (!symmCoreClient || !
|
|
26338
|
+
if (!symmCoreClient || !accountAddress) {
|
|
26090
26339
|
throw new Error("symm-core client not available");
|
|
26091
26340
|
}
|
|
26092
26341
|
return symmCoreClient.notifications.markRead({
|
|
26093
26342
|
id,
|
|
26094
26343
|
timestamp,
|
|
26095
|
-
|
|
26344
|
+
accountAddress,
|
|
26096
26345
|
chainId
|
|
26097
26346
|
});
|
|
26098
26347
|
}
|
|
@@ -26898,10 +27147,6 @@ function getSymmErrorMessage(error) {
|
|
|
26898
27147
|
if (error instanceof Error) return error.message;
|
|
26899
27148
|
return "An unexpected error occurred.";
|
|
26900
27149
|
}
|
|
26901
|
-
var useSymmWsStore = create((set) => ({
|
|
26902
|
-
isConnected: false,
|
|
26903
|
-
setConnected: (isConnected) => set({ isConnected })
|
|
26904
|
-
}));
|
|
26905
27150
|
|
|
26906
27151
|
export { SymmProvider, getSymmErrorMessage, symmKeys, useBinanceMarkPriceStore, useSymmAccountData, useSymmAccountSummary, useSymmAccountsApi, useSymmAccountsLength, useSymmAccountsQuery, useSymmAccountsWithPositions, useSymmAllocateCollateralMutation, useSymmApprovalQuery, useSymmApproveMutation, useSymmAuth, useSymmAvailableMargin, useSymmBalances, useSymmCancelClose, useSymmCancelOpenMutation, useSymmCancelTpslMutation, useSymmCancelTwapOrderMutation, useSymmChartCandles, useSymmChartSelection, useSymmClearTriggerConfigMutation, useSymmCloseAllPositionsMutation, useSymmCloseOrder, useSymmClosePositionMutation, useSymmContext, useSymmCoreClient, useSymmCreateAccountMutation, useSymmDeallocateCollateralMutation, useSymmDelegateAccessMutation, useSymmDelegation, useSymmDepositAndAllocateMutation, useSymmDepositMutation, useSymmEditAccountNameMutation, useSymmFunding, useSymmFundingHistory, useSymmFundingPayments, useSymmHedgerMarketById, useSymmHedgerMarketBySymbol, useSymmHedgerMarkets, useSymmInstantTradeEnsureReadyMutation, useSymmInstantTradeExecuteMutation, useSymmInternalTransferCollateralMutation, useSymmLockedParams, useSymmMarkReadNotificationMutation, useSymmMarkets, useSymmNotificationsQuery, useSymmOpenBasketMutation, useSymmOpenOrders, useSymmPendingIds, useSymmPendingInstantOpens, useSymmPerformanceOverlays, useSymmPortfolio, useSymmPositions, useSymmProposeRevokeDelegationMutation, useSymmRevokeDelegationMutation, useSymmSetTpslMutation, useSymmSetTriggerConfigMutation, useSymmSignTermsMutation, useSymmSignatureQuery, useSymmTokenMarkPrice, useSymmTokenSelectionMarkets, useSymmTokenSelectionMetadata, useSymmTpslOrders, useSymmTradeHistory, useSymmTriggerConfigQuery, useSymmTriggerOrders, useSymmTwapOrder, useSymmTwapOrdersQuery, useSymmUnreadCountQuery, useSymmUpdatePositionMutation, useSymmWithdraw, useSymmWsStore };
|
|
26907
27152
|
//# sourceMappingURL=index.mjs.map
|