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