@pear-protocol/symmio-client 0.1.10 → 0.1.11

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.
@@ -930,11 +930,11 @@ declare function useSymmPerformanceOverlays(selection: SymmChartSelection): {
930
930
 
931
931
  declare const symmKeys: {
932
932
  all: readonly ["symm"];
933
- accounts: (address?: Address) => readonly ["symm", "accounts", `0x${string}` | undefined];
933
+ accounts: (address?: Address, chainId?: number) => readonly ["symm", "accounts", `0x${string}` | undefined, number | undefined];
934
934
  accountSummary: (address?: Address, chainId?: number) => readonly ["symm", "accountSummary", `0x${string}` | undefined, number | undefined];
935
935
  accountData: (address?: Address, chainId?: number) => readonly ["symm", "accountData", `0x${string}` | undefined, number | undefined];
936
- signature: (address?: Address) => readonly ["symm", "signature", `0x${string}` | undefined];
937
- approval: (owner?: Address, spender?: Address) => readonly ["symm", "approval", `0x${string}` | undefined, `0x${string}` | undefined];
936
+ signature: (address?: Address, chainId?: number) => readonly ["symm", "signature", `0x${string}` | undefined, number | undefined];
937
+ approval: (owner?: Address, spender?: Address, chainId?: number) => readonly ["symm", "approval", `0x${string}` | undefined, `0x${string}` | undefined, number | undefined];
938
938
  balances: (address?: Address, chainId?: number) => readonly ["symm", "balances", `0x${string}` | undefined, number | undefined];
939
939
  positions: (address?: Address, chainId?: number) => readonly ["symm", "positions", `0x${string}` | undefined, number | undefined];
940
940
  openOrders: (address?: Address, chainId?: number) => readonly ["symm", "openOrders", `0x${string}` | undefined, number | undefined];
@@ -930,11 +930,11 @@ declare function useSymmPerformanceOverlays(selection: SymmChartSelection): {
930
930
 
931
931
  declare const symmKeys: {
932
932
  all: readonly ["symm"];
933
- accounts: (address?: Address) => readonly ["symm", "accounts", `0x${string}` | undefined];
933
+ accounts: (address?: Address, chainId?: number) => readonly ["symm", "accounts", `0x${string}` | undefined, number | undefined];
934
934
  accountSummary: (address?: Address, chainId?: number) => readonly ["symm", "accountSummary", `0x${string}` | undefined, number | undefined];
935
935
  accountData: (address?: Address, chainId?: number) => readonly ["symm", "accountData", `0x${string}` | undefined, number | undefined];
936
- signature: (address?: Address) => readonly ["symm", "signature", `0x${string}` | undefined];
937
- approval: (owner?: Address, spender?: Address) => readonly ["symm", "approval", `0x${string}` | undefined, `0x${string}` | undefined];
936
+ signature: (address?: Address, chainId?: number) => readonly ["symm", "signature", `0x${string}` | undefined, number | undefined];
937
+ approval: (owner?: Address, spender?: Address, chainId?: number) => readonly ["symm", "approval", `0x${string}` | undefined, `0x${string}` | undefined, number | undefined];
938
938
  balances: (address?: Address, chainId?: number) => readonly ["symm", "balances", `0x${string}` | undefined, number | undefined];
939
939
  positions: (address?: Address, chainId?: number) => readonly ["symm", "positions", `0x${string}` | undefined, number | undefined];
940
940
  openOrders: (address?: Address, chainId?: number) => readonly ["symm", "openOrders", `0x${string}` | undefined, number | undefined];
@@ -24357,8 +24357,8 @@ function SymmProvider({
24357
24357
  }) {
24358
24358
  const { address, chainId: walletChainId } = wagmi.useAccount();
24359
24359
  const publicClient = wagmi.usePublicClient();
24360
- const { data: walletClient } = wagmi.useWalletClient();
24361
24360
  const chainId = configChainId ?? walletChainId ?? 42161;
24361
+ const { data: walletClient } = wagmi.useWalletClient({ chainId });
24362
24362
  const [accessToken, setAccessToken] = react.useState(null);
24363
24363
  const prevAddressRef = react.useRef(address);
24364
24364
  const prevChainRef = react.useRef(chainId);
@@ -24455,6 +24455,13 @@ function SymmProvider({
24455
24455
  clearCachedToken(previousAddress, previousChainId);
24456
24456
  }
24457
24457
  }, [address, walletClient, chainId]);
24458
+ react.useEffect(() => {
24459
+ console.log("[SymmProvider] symmCoreConfig", {
24460
+ apiUrl: symmCoreConfig.apiUrl,
24461
+ wsUrl: symmCoreConfig.wsUrl,
24462
+ resolvedChainId: chainId
24463
+ });
24464
+ }, [symmCoreConfig.apiUrl, symmCoreConfig.wsUrl, chainId]);
24458
24465
  const symmCoreClient = react.useMemo(() => {
24459
24466
  return symmCore.createSymmSDK({
24460
24467
  apiUrl: symmCoreConfig.apiUrl,
@@ -24517,11 +24524,11 @@ var ALL_TRADING_SELECTORS = [
24517
24524
  // src/react/query-keys.ts
24518
24525
  var symmKeys = {
24519
24526
  all: ["symm"],
24520
- accounts: (address) => ["symm", "accounts", address],
24527
+ accounts: (address, chainId) => ["symm", "accounts", address, chainId],
24521
24528
  accountSummary: (address, chainId) => ["symm", "accountSummary", address, chainId],
24522
24529
  accountData: (address, chainId) => ["symm", "accountData", address, chainId],
24523
- signature: (address) => ["symm", "signature", address],
24524
- approval: (owner, spender) => ["symm", "approval", owner, spender],
24530
+ signature: (address, chainId) => ["symm", "signature", address, chainId],
24531
+ approval: (owner, spender, chainId) => ["symm", "approval", owner, spender, chainId],
24525
24532
  balances: (address, chainId) => ["symm", "balances", address, chainId],
24526
24533
  positions: (address, chainId) => ["symm", "positions", address, chainId],
24527
24534
  openOrders: (address, chainId) => ["symm", "openOrders", address, chainId],
@@ -24688,12 +24695,12 @@ function useSymmInstantTrade(params) {
24688
24695
  }
24689
24696
  var EMPTY_ACCOUNTS = [];
24690
24697
  function useSymmAccounts(userAddress, options) {
24691
- const { symmioClient } = useSymmContext();
24698
+ const { symmioClient, chainId } = useSymmContext();
24692
24699
  const queryClient = reactQuery.useQueryClient();
24693
24700
  const internalEnabled = !!symmioClient && !!userAddress;
24694
24701
  const accountsQuery = reactQuery.useQuery({
24695
24702
  ...options?.query,
24696
- queryKey: symmKeys.accounts(userAddress),
24703
+ queryKey: symmKeys.accounts(userAddress, chainId),
24697
24704
  queryFn: () => symmioClient.account.getAll(userAddress),
24698
24705
  enabled: internalEnabled && (options?.query?.enabled ?? true)
24699
24706
  });
@@ -24703,7 +24710,7 @@ function useSymmAccounts(userAddress, options) {
24703
24710
  return symmioClient.account.addAccount(name);
24704
24711
  },
24705
24712
  onSuccess: () => {
24706
- queryClient.invalidateQueries({ queryKey: symmKeys.accounts(userAddress) });
24713
+ queryClient.invalidateQueries({ queryKey: symmKeys.accounts(userAddress, chainId) });
24707
24714
  }
24708
24715
  });
24709
24716
  const editName = reactQuery.useMutation({
@@ -24715,7 +24722,7 @@ function useSymmAccounts(userAddress, options) {
24715
24722
  return symmioClient.account.editName(accountAddress, name);
24716
24723
  },
24717
24724
  onSuccess: () => {
24718
- queryClient.invalidateQueries({ queryKey: symmKeys.accounts(userAddress) });
24725
+ queryClient.invalidateQueries({ queryKey: symmKeys.accounts(userAddress, chainId) });
24719
24726
  }
24720
24727
  });
24721
24728
  return {
@@ -24729,7 +24736,7 @@ function useSymmAccounts(userAddress, options) {
24729
24736
  };
24730
24737
  }
24731
24738
  function useSymmApproval(params) {
24732
- const { symmioClient } = useSymmContext();
24739
+ const { symmioClient, chainId } = useSymmContext();
24733
24740
  const queryClient = reactQuery.useQueryClient();
24734
24741
  const { owner, amount, spender, collateralToken } = params;
24735
24742
  const resolvedSpender = spender ?? symmioClient?.addresses.multiAccount;
@@ -24744,7 +24751,7 @@ function useSymmApproval(params) {
24744
24751
  const internalEnabled = !!symmioClient && !!owner && !!resolvedSpender && !!resolvedToken;
24745
24752
  const approvalQuery = reactQuery.useQuery({
24746
24753
  ...params.query,
24747
- queryKey: symmKeys.approval(owner, resolvedSpender),
24754
+ queryKey: symmKeys.approval(owner, resolvedSpender, chainId),
24748
24755
  queryFn: async () => {
24749
24756
  const [allowance, balance] = await Promise.all([
24750
24757
  symmioClient.approval.getAllowance(resolvedToken, owner, resolvedSpender),
@@ -24762,7 +24769,7 @@ function useSymmApproval(params) {
24762
24769
  },
24763
24770
  onSuccess: () => {
24764
24771
  queryClient.invalidateQueries({
24765
- queryKey: symmKeys.approval(owner, resolvedSpender)
24772
+ queryKey: symmKeys.approval(owner, resolvedSpender, chainId)
24766
24773
  });
24767
24774
  }
24768
24775
  });
@@ -24868,12 +24875,12 @@ function useSymmCollateral() {
24868
24875
  return { allocate: allocate2, deallocate: deallocate2, internalTransfer: internalTransfer2 };
24869
24876
  }
24870
24877
  function useSymmSignature(userAddress, options) {
24871
- const { symmioClient } = useSymmContext();
24878
+ const { symmioClient, chainId } = useSymmContext();
24872
24879
  const queryClient = reactQuery.useQueryClient();
24873
24880
  const internalEnabled = !!symmioClient && !!userAddress;
24874
24881
  const signedQuery = reactQuery.useQuery({
24875
24882
  ...options?.query,
24876
- queryKey: symmKeys.signature(userAddress),
24883
+ queryKey: symmKeys.signature(userAddress, chainId),
24877
24884
  queryFn: () => symmioClient.signature.hasSigned(userAddress),
24878
24885
  enabled: internalEnabled && (options?.query?.enabled ?? true)
24879
24886
  });
@@ -24885,7 +24892,7 @@ function useSymmSignature(userAddress, options) {
24885
24892
  },
24886
24893
  onSuccess: () => {
24887
24894
  queryClient.invalidateQueries({
24888
- queryKey: symmKeys.signature(userAddress)
24895
+ queryKey: symmKeys.signature(userAddress, chainId)
24889
24896
  });
24890
24897
  }
24891
24898
  });
@@ -24896,7 +24903,7 @@ function useSymmSignature(userAddress, options) {
24896
24903
  };
24897
24904
  }
24898
24905
  function useSymmAvailableMargin(params) {
24899
- const { symmioClient } = useSymmContext();
24906
+ const { symmioClient, chainId } = useSymmContext();
24900
24907
  const { accountAddress, upnl } = params;
24901
24908
  const resolvedUpnl = upnl ?? 0n;
24902
24909
  const selectWithUpnl = react.useCallback(
@@ -24910,7 +24917,7 @@ function useSymmAvailableMargin(params) {
24910
24917
  const internalEnabled = !!symmioClient && !!accountAddress;
24911
24918
  const query = reactQuery.useQuery({
24912
24919
  ...params.query,
24913
- queryKey: symmKeys.availableMargin(accountAddress, symmioClient?.chainId),
24920
+ queryKey: symmKeys.availableMargin(accountAddress, chainId),
24914
24921
  queryFn: () => symmioClient.stats.getPartyAStats(accountAddress),
24915
24922
  select: selectWithUpnl,
24916
24923
  enabled: internalEnabled && (params.query?.enabled ?? true),