@pear-protocol/symmio-client 0.2.9 → 0.2.10
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 +13 -11
- package/dist/react/index.d.ts +13 -11
- package/dist/react/index.js +31 -13
- package/dist/react/index.js.map +1 -1
- package/dist/react/index.mjs +31 -13
- package/dist/react/index.mjs.map +1 -1
- package/dist/react/provider.js +12 -2
- package/dist/react/provider.js.map +1 -1
- package/dist/react/provider.mjs +13 -3
- package/dist/react/provider.mjs.map +1 -1
- package/package.json +3 -3
package/dist/react/index.d.mts
CHANGED
|
@@ -26,7 +26,7 @@ type UseSymmAuthParams = {
|
|
|
26
26
|
walletClient?: WalletClient;
|
|
27
27
|
siweDomain?: string;
|
|
28
28
|
};
|
|
29
|
-
declare function useSymmAuth(params
|
|
29
|
+
declare function useSymmAuth(params?: UseSymmAuthParams): {
|
|
30
30
|
accessToken: string | null;
|
|
31
31
|
authToken: string | null;
|
|
32
32
|
isAuthenticated: boolean;
|
|
@@ -120,7 +120,7 @@ type Account = {
|
|
|
120
120
|
name: string;
|
|
121
121
|
};
|
|
122
122
|
|
|
123
|
-
declare function useSymmAccounts(params
|
|
123
|
+
declare function useSymmAccounts(params?: {
|
|
124
124
|
userAddress?: Address;
|
|
125
125
|
publicClient?: PublicClient;
|
|
126
126
|
walletClient?: WalletClient;
|
|
@@ -210,7 +210,7 @@ declare function useSymmCloseOrder(): {
|
|
|
210
210
|
closeOrder: _tanstack_react_query.UseMutationResult<_pear_protocol_symm_core.CloseOrderResponse, Error, CloseOrderRequest, unknown>;
|
|
211
211
|
};
|
|
212
212
|
|
|
213
|
-
declare function useSymmDeposit(params
|
|
213
|
+
declare function useSymmDeposit(params?: {
|
|
214
214
|
publicClient?: PublicClient;
|
|
215
215
|
walletClient?: WalletClient;
|
|
216
216
|
}): {
|
|
@@ -224,7 +224,7 @@ declare function useSymmDeposit(params: {
|
|
|
224
224
|
}, unknown>;
|
|
225
225
|
};
|
|
226
226
|
|
|
227
|
-
declare function useSymmWithdraw(params
|
|
227
|
+
declare function useSymmWithdraw(params?: {
|
|
228
228
|
publicClient?: PublicClient;
|
|
229
229
|
walletClient?: WalletClient;
|
|
230
230
|
}): {
|
|
@@ -239,7 +239,7 @@ type InternalTransferParams = {
|
|
|
239
239
|
amount: bigint;
|
|
240
240
|
};
|
|
241
241
|
|
|
242
|
-
declare function useSymmCollateral(params
|
|
242
|
+
declare function useSymmCollateral(params?: {
|
|
243
243
|
publicClient?: PublicClient;
|
|
244
244
|
walletClient?: WalletClient;
|
|
245
245
|
}): {
|
|
@@ -257,7 +257,7 @@ declare function useSymmCollateral(params: {
|
|
|
257
257
|
}, unknown>;
|
|
258
258
|
};
|
|
259
259
|
|
|
260
|
-
declare function useSymmSignature(params
|
|
260
|
+
declare function useSymmSignature(params?: {
|
|
261
261
|
userAddress?: Address;
|
|
262
262
|
publicClient?: PublicClient;
|
|
263
263
|
walletClient?: WalletClient;
|
|
@@ -459,9 +459,11 @@ declare function useSymmMarkets(params?: {
|
|
|
459
459
|
searchText?: string;
|
|
460
460
|
query?: SymmQueryConfig;
|
|
461
461
|
}): {
|
|
462
|
-
markets:
|
|
462
|
+
markets: unknown[];
|
|
463
463
|
isLoading: boolean;
|
|
464
|
-
refetch: (options?: _tanstack_query_core.RefetchOptions) => Promise<_tanstack_query_core.QueryObserverResult<
|
|
464
|
+
refetch: (options?: _tanstack_query_core.RefetchOptions) => Promise<_tanstack_query_core.QueryObserverResult<{
|
|
465
|
+
markets?: unknown[];
|
|
466
|
+
}, Error>>;
|
|
465
467
|
};
|
|
466
468
|
|
|
467
469
|
declare function useSymmHedgerMarketById(params: {
|
|
@@ -650,10 +652,10 @@ declare function useSymmTwapOrder(params: {
|
|
|
650
652
|
refetch: (options?: _tanstack_query_core.RefetchOptions) => Promise<_tanstack_query_core.QueryObserverResult<node_modules__pear_protocol_symm_core_dist_types.TwapOrderResponse, Error>>;
|
|
651
653
|
};
|
|
652
654
|
|
|
653
|
-
declare function useSymmWs(params
|
|
654
|
-
symmCoreClient
|
|
655
|
+
declare function useSymmWs(params?: {
|
|
656
|
+
symmCoreClient?: SymmSDK | null;
|
|
655
657
|
accountAddress?: Address;
|
|
656
|
-
chainId
|
|
658
|
+
chainId?: number;
|
|
657
659
|
}): {
|
|
658
660
|
isConnected: boolean;
|
|
659
661
|
};
|
package/dist/react/index.d.ts
CHANGED
|
@@ -26,7 +26,7 @@ type UseSymmAuthParams = {
|
|
|
26
26
|
walletClient?: WalletClient;
|
|
27
27
|
siweDomain?: string;
|
|
28
28
|
};
|
|
29
|
-
declare function useSymmAuth(params
|
|
29
|
+
declare function useSymmAuth(params?: UseSymmAuthParams): {
|
|
30
30
|
accessToken: string | null;
|
|
31
31
|
authToken: string | null;
|
|
32
32
|
isAuthenticated: boolean;
|
|
@@ -120,7 +120,7 @@ type Account = {
|
|
|
120
120
|
name: string;
|
|
121
121
|
};
|
|
122
122
|
|
|
123
|
-
declare function useSymmAccounts(params
|
|
123
|
+
declare function useSymmAccounts(params?: {
|
|
124
124
|
userAddress?: Address;
|
|
125
125
|
publicClient?: PublicClient;
|
|
126
126
|
walletClient?: WalletClient;
|
|
@@ -210,7 +210,7 @@ declare function useSymmCloseOrder(): {
|
|
|
210
210
|
closeOrder: _tanstack_react_query.UseMutationResult<_pear_protocol_symm_core.CloseOrderResponse, Error, CloseOrderRequest, unknown>;
|
|
211
211
|
};
|
|
212
212
|
|
|
213
|
-
declare function useSymmDeposit(params
|
|
213
|
+
declare function useSymmDeposit(params?: {
|
|
214
214
|
publicClient?: PublicClient;
|
|
215
215
|
walletClient?: WalletClient;
|
|
216
216
|
}): {
|
|
@@ -224,7 +224,7 @@ declare function useSymmDeposit(params: {
|
|
|
224
224
|
}, unknown>;
|
|
225
225
|
};
|
|
226
226
|
|
|
227
|
-
declare function useSymmWithdraw(params
|
|
227
|
+
declare function useSymmWithdraw(params?: {
|
|
228
228
|
publicClient?: PublicClient;
|
|
229
229
|
walletClient?: WalletClient;
|
|
230
230
|
}): {
|
|
@@ -239,7 +239,7 @@ type InternalTransferParams = {
|
|
|
239
239
|
amount: bigint;
|
|
240
240
|
};
|
|
241
241
|
|
|
242
|
-
declare function useSymmCollateral(params
|
|
242
|
+
declare function useSymmCollateral(params?: {
|
|
243
243
|
publicClient?: PublicClient;
|
|
244
244
|
walletClient?: WalletClient;
|
|
245
245
|
}): {
|
|
@@ -257,7 +257,7 @@ declare function useSymmCollateral(params: {
|
|
|
257
257
|
}, unknown>;
|
|
258
258
|
};
|
|
259
259
|
|
|
260
|
-
declare function useSymmSignature(params
|
|
260
|
+
declare function useSymmSignature(params?: {
|
|
261
261
|
userAddress?: Address;
|
|
262
262
|
publicClient?: PublicClient;
|
|
263
263
|
walletClient?: WalletClient;
|
|
@@ -459,9 +459,11 @@ declare function useSymmMarkets(params?: {
|
|
|
459
459
|
searchText?: string;
|
|
460
460
|
query?: SymmQueryConfig;
|
|
461
461
|
}): {
|
|
462
|
-
markets:
|
|
462
|
+
markets: unknown[];
|
|
463
463
|
isLoading: boolean;
|
|
464
|
-
refetch: (options?: _tanstack_query_core.RefetchOptions) => Promise<_tanstack_query_core.QueryObserverResult<
|
|
464
|
+
refetch: (options?: _tanstack_query_core.RefetchOptions) => Promise<_tanstack_query_core.QueryObserverResult<{
|
|
465
|
+
markets?: unknown[];
|
|
466
|
+
}, Error>>;
|
|
465
467
|
};
|
|
466
468
|
|
|
467
469
|
declare function useSymmHedgerMarketById(params: {
|
|
@@ -650,10 +652,10 @@ declare function useSymmTwapOrder(params: {
|
|
|
650
652
|
refetch: (options?: _tanstack_query_core.RefetchOptions) => Promise<_tanstack_query_core.QueryObserverResult<node_modules__pear_protocol_symm_core_dist_types.TwapOrderResponse, Error>>;
|
|
651
653
|
};
|
|
652
654
|
|
|
653
|
-
declare function useSymmWs(params
|
|
654
|
-
symmCoreClient
|
|
655
|
+
declare function useSymmWs(params?: {
|
|
656
|
+
symmCoreClient?: SymmSDK | null;
|
|
655
657
|
accountAddress?: Address;
|
|
656
|
-
chainId
|
|
658
|
+
chainId?: number;
|
|
657
659
|
}): {
|
|
658
660
|
isConnected: boolean;
|
|
659
661
|
};
|
package/dist/react/index.js
CHANGED
|
@@ -64,11 +64,14 @@ var useSymmWsStore = zustand.create((set) => ({
|
|
|
64
64
|
function asUnsubscribeFn(value) {
|
|
65
65
|
return typeof value === "function" ? value : null;
|
|
66
66
|
}
|
|
67
|
-
function useSymmWs(params) {
|
|
67
|
+
function useSymmWs(params = {}) {
|
|
68
|
+
const { symmCoreClient: ctxClient, address: ctxAddress, chainId: ctxChainId } = useSymmContext();
|
|
68
69
|
const queryClient = reactQuery.useQueryClient();
|
|
69
70
|
const isConnected = useSymmWsStore((state) => state.isConnected);
|
|
70
71
|
const setConnected = useSymmWsStore((state) => state.setConnected);
|
|
71
|
-
const
|
|
72
|
+
const symmCoreClient = params.symmCoreClient ?? ctxClient;
|
|
73
|
+
const accountAddress = params.accountAddress ?? ctxAddress;
|
|
74
|
+
const chainId = params.chainId ?? ctxChainId;
|
|
72
75
|
react.useEffect(() => {
|
|
73
76
|
if (!symmCoreClient || !accountAddress) {
|
|
74
77
|
setConnected(false);
|
|
@@ -395,10 +398,17 @@ var useSymmAuthStore = zustand.create((set, get) => ({
|
|
|
395
398
|
|
|
396
399
|
// src/react/hooks/use-symm-auth.ts
|
|
397
400
|
function useSymmAuth(params) {
|
|
398
|
-
const
|
|
399
|
-
const
|
|
400
|
-
|
|
401
|
-
|
|
401
|
+
const ctx = useSymmContext();
|
|
402
|
+
const address = params?.address ?? ctx.address;
|
|
403
|
+
const chainId = params?.chainId ?? ctx.chainId ?? 42161;
|
|
404
|
+
const walletClient = params?.walletClient ?? ctx.walletClient;
|
|
405
|
+
const siweDomain = params?.siweDomain;
|
|
406
|
+
const accessToken = useSymmAuthStore((state) => {
|
|
407
|
+
if (address) {
|
|
408
|
+
return state.tokensByKey[symmAuthTokenKey(address, chainId)] ?? null;
|
|
409
|
+
}
|
|
410
|
+
return ctx.accessToken ?? ctx.authToken ?? null;
|
|
411
|
+
});
|
|
402
412
|
const setToken = useSymmAuthStore((state) => state.setToken);
|
|
403
413
|
const getToken = useSymmAuthStore((state) => state.getToken);
|
|
404
414
|
const clearToken = useSymmAuthStore((state) => state.clearToken);
|
|
@@ -1189,7 +1199,7 @@ async function getAccounts(publicClient, multiAccount, user, start = 0, size = 1
|
|
|
1189
1199
|
|
|
1190
1200
|
// src/react/hooks/use-symm-accounts.ts
|
|
1191
1201
|
var EMPTY_ACCOUNTS = [];
|
|
1192
|
-
function useSymmAccounts(params, options) {
|
|
1202
|
+
function useSymmAccounts(params = {}, options) {
|
|
1193
1203
|
const { chainId, symmioConfig } = useSymmContext();
|
|
1194
1204
|
const { userAddress, publicClient, walletClient } = params;
|
|
1195
1205
|
const queryClient = reactQuery.useQueryClient();
|
|
@@ -1564,7 +1574,7 @@ async function depositAndAllocate(walletClient, publicClient, multiAccount, para
|
|
|
1564
1574
|
}
|
|
1565
1575
|
|
|
1566
1576
|
// src/react/hooks/use-symm-deposit.ts
|
|
1567
|
-
function useSymmDeposit(params) {
|
|
1577
|
+
function useSymmDeposit(params = {}) {
|
|
1568
1578
|
const { chainId, symmioConfig } = useSymmContext();
|
|
1569
1579
|
const { publicClient, walletClient } = params;
|
|
1570
1580
|
const queryClient = reactQuery.useQueryClient();
|
|
@@ -1624,7 +1634,7 @@ async function withdraw(walletClient, publicClient, multiAccount, params) {
|
|
|
1624
1634
|
}
|
|
1625
1635
|
|
|
1626
1636
|
// src/react/hooks/use-symm-withdraw.ts
|
|
1627
|
-
function useSymmWithdraw(params) {
|
|
1637
|
+
function useSymmWithdraw(params = {}) {
|
|
1628
1638
|
const { chainId, symmioConfig } = useSymmContext();
|
|
1629
1639
|
const { publicClient, walletClient } = params;
|
|
1630
1640
|
const queryClient = reactQuery.useQueryClient();
|
|
@@ -24292,7 +24302,7 @@ var MuonClient = class {
|
|
|
24292
24302
|
};
|
|
24293
24303
|
|
|
24294
24304
|
// src/react/hooks/use-symm-collateral.ts
|
|
24295
|
-
function useSymmCollateral(params) {
|
|
24305
|
+
function useSymmCollateral(params = {}) {
|
|
24296
24306
|
const { chainId, symmioConfig } = useSymmContext();
|
|
24297
24307
|
const { publicClient, walletClient } = params;
|
|
24298
24308
|
const queryClient = reactQuery.useQueryClient();
|
|
@@ -24445,7 +24455,7 @@ async function hasSignedCurrentVersion(publicClient, signatureStore, user) {
|
|
|
24445
24455
|
}
|
|
24446
24456
|
|
|
24447
24457
|
// src/react/hooks/use-symm-signature.ts
|
|
24448
|
-
function useSymmSignature(params, options) {
|
|
24458
|
+
function useSymmSignature(params = {}, options) {
|
|
24449
24459
|
const { chainId, symmioConfig } = useSymmContext();
|
|
24450
24460
|
const { userAddress, publicClient, walletClient } = params;
|
|
24451
24461
|
const queryClient = reactQuery.useQueryClient();
|
|
@@ -24678,6 +24688,13 @@ function useSymmPositions(params) {
|
|
|
24678
24688
|
const resolvedAddress = accountAddress ? void 0 : address;
|
|
24679
24689
|
const chainId = params.chainId ?? ctxChainId;
|
|
24680
24690
|
const internalEnabled = !!symmCoreClient && !!(accountAddress || resolvedAddress);
|
|
24691
|
+
console.log({
|
|
24692
|
+
symmCoreClient,
|
|
24693
|
+
accountAddress,
|
|
24694
|
+
resolvedAddress,
|
|
24695
|
+
chainId,
|
|
24696
|
+
internalEnabled
|
|
24697
|
+
});
|
|
24681
24698
|
const query = reactQuery.useQuery({
|
|
24682
24699
|
...params.query,
|
|
24683
24700
|
queryKey: symmKeys.positions({
|
|
@@ -24932,10 +24949,11 @@ function useSymmMarkets(params) {
|
|
|
24932
24949
|
...params?.query,
|
|
24933
24950
|
queryKey: symmKeys.markets(chainId, searchText),
|
|
24934
24951
|
queryFn: () => {
|
|
24952
|
+
const marketsApi = symmCoreClient.markets;
|
|
24935
24953
|
if (searchText) {
|
|
24936
|
-
return
|
|
24954
|
+
return marketsApi.search(searchText, chainId);
|
|
24937
24955
|
}
|
|
24938
|
-
return
|
|
24956
|
+
return marketsApi.list({ pageSize: "500", chainId });
|
|
24939
24957
|
},
|
|
24940
24958
|
enabled: internalEnabled && (params?.query?.enabled ?? true)
|
|
24941
24959
|
});
|