@pear-protocol/symmio-client 0.2.7 → 0.2.9
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 +3 -6
- package/dist/react/index.d.ts +3 -6
- package/dist/react/index.js +14 -31
- package/dist/react/index.js.map +1 -1
- package/dist/react/index.mjs +14 -31
- package/dist/react/index.mjs.map +1 -1
- package/dist/react/{provider-xhUge8b7.d.mts → provider-BoNiSPy9.d.mts} +2 -8
- package/dist/react/{provider-xhUge8b7.d.ts → provider-BoNiSPy9.d.ts} +2 -8
- package/dist/react/provider.d.mts +1 -1
- package/dist/react/provider.d.ts +1 -1
- package/dist/react/provider.js +2 -18
- package/dist/react/provider.js.map +1 -1
- package/dist/react/provider.mjs +2 -18
- package/dist/react/provider.mjs.map +1 -1
- package/package.json +1 -6
package/dist/react/index.d.mts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { S as SymmioSDKConfig } from './provider-
|
|
2
|
-
export { a as SymmProvider, b as SymmProviderProps } from './provider-
|
|
3
|
-
import { Address, WalletClient, Hex, PublicClient } from 'viem';
|
|
1
|
+
import { S as SymmioSDKConfig } from './provider-BoNiSPy9.mjs';
|
|
2
|
+
export { a as SymmProvider, b as SymmProviderProps } from './provider-BoNiSPy9.mjs';
|
|
4
3
|
import * as _pear_protocol_symm_core from '@pear-protocol/symm-core';
|
|
5
4
|
import { SymmSDK, CloseOrderRequest, OpenBasketPositionRequest, ClosePositionRequest, CancelOpenRequest, UpdatePositionRequest, SetTpslRequest, CancelTpslRequest, GetTpslOrdersRequest, UpsertTriggerConfigRequest, GetSymmHedgerMarketsRequest, MarketItem } from '@pear-protocol/symm-core';
|
|
5
|
+
import { Address, WalletClient, Hex, PublicClient } from 'viem';
|
|
6
6
|
import * as _tanstack_react_query from '@tanstack/react-query';
|
|
7
7
|
import * as _tanstack_query_core from '@tanstack/query-core';
|
|
8
8
|
import * as node_modules__pear_protocol_symm_core_dist_types from 'node_modules/@pear-protocol/symm-core/dist/types';
|
|
@@ -15,9 +15,6 @@ type SymmContextValue = {
|
|
|
15
15
|
chainId: number;
|
|
16
16
|
address?: `0x${string}`;
|
|
17
17
|
symmioConfig?: Partial<SymmioSDKConfig>;
|
|
18
|
-
accessToken: string | null;
|
|
19
|
-
authToken: string | null;
|
|
20
|
-
refreshAuth: (accountAddress?: Address) => Promise<string | null>;
|
|
21
18
|
};
|
|
22
19
|
declare function useSymmContext(): SymmContextValue;
|
|
23
20
|
|
package/dist/react/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { S as SymmioSDKConfig } from './provider-
|
|
2
|
-
export { a as SymmProvider, b as SymmProviderProps } from './provider-
|
|
3
|
-
import { Address, WalletClient, Hex, PublicClient } from 'viem';
|
|
1
|
+
import { S as SymmioSDKConfig } from './provider-BoNiSPy9.js';
|
|
2
|
+
export { a as SymmProvider, b as SymmProviderProps } from './provider-BoNiSPy9.js';
|
|
4
3
|
import * as _pear_protocol_symm_core from '@pear-protocol/symm-core';
|
|
5
4
|
import { SymmSDK, CloseOrderRequest, OpenBasketPositionRequest, ClosePositionRequest, CancelOpenRequest, UpdatePositionRequest, SetTpslRequest, CancelTpslRequest, GetTpslOrdersRequest, UpsertTriggerConfigRequest, GetSymmHedgerMarketsRequest, MarketItem } from '@pear-protocol/symm-core';
|
|
5
|
+
import { Address, WalletClient, Hex, PublicClient } from 'viem';
|
|
6
6
|
import * as _tanstack_react_query from '@tanstack/react-query';
|
|
7
7
|
import * as _tanstack_query_core from '@tanstack/query-core';
|
|
8
8
|
import * as node_modules__pear_protocol_symm_core_dist_types from 'node_modules/@pear-protocol/symm-core/dist/types';
|
|
@@ -15,9 +15,6 @@ type SymmContextValue = {
|
|
|
15
15
|
chainId: number;
|
|
16
16
|
address?: `0x${string}`;
|
|
17
17
|
symmioConfig?: Partial<SymmioSDKConfig>;
|
|
18
|
-
accessToken: string | null;
|
|
19
|
-
authToken: string | null;
|
|
20
|
-
refreshAuth: (accountAddress?: Address) => Promise<string | null>;
|
|
21
18
|
};
|
|
22
19
|
declare function useSymmContext(): SymmContextValue;
|
|
23
20
|
|
package/dist/react/index.js
CHANGED
|
@@ -152,13 +152,9 @@ function useSymmWs(params) {
|
|
|
152
152
|
}, [symmCoreClient, accountAddress, chainId, queryClient, setConnected]);
|
|
153
153
|
return { isConnected };
|
|
154
154
|
}
|
|
155
|
-
var noopRefreshAuth = async () => null;
|
|
156
155
|
function SymmProvider({
|
|
157
156
|
chainId = 42161,
|
|
158
157
|
address,
|
|
159
|
-
accessToken = null,
|
|
160
|
-
authToken,
|
|
161
|
-
refreshAuth = noopRefreshAuth,
|
|
162
158
|
symmCoreConfig,
|
|
163
159
|
symmioConfig,
|
|
164
160
|
children
|
|
@@ -170,27 +166,15 @@ function SymmProvider({
|
|
|
170
166
|
defaultChainId: chainId
|
|
171
167
|
});
|
|
172
168
|
}, [chainId, symmCoreConfig.apiUrl, symmCoreConfig.wsUrl]);
|
|
173
|
-
const resolvedAuthToken = authToken ?? accessToken;
|
|
174
169
|
useSymmWs({ symmCoreClient, accountAddress: address, chainId });
|
|
175
170
|
const value = react.useMemo(
|
|
176
171
|
() => ({
|
|
177
172
|
symmCoreClient,
|
|
178
173
|
chainId,
|
|
179
174
|
address,
|
|
180
|
-
symmioConfig
|
|
181
|
-
accessToken,
|
|
182
|
-
authToken: resolvedAuthToken,
|
|
183
|
-
refreshAuth
|
|
175
|
+
symmioConfig
|
|
184
176
|
}),
|
|
185
|
-
[
|
|
186
|
-
symmCoreClient,
|
|
187
|
-
chainId,
|
|
188
|
-
address,
|
|
189
|
-
symmioConfig,
|
|
190
|
-
accessToken,
|
|
191
|
-
resolvedAuthToken,
|
|
192
|
-
refreshAuth
|
|
193
|
-
]
|
|
177
|
+
[symmCoreClient, chainId, address, symmioConfig]
|
|
194
178
|
);
|
|
195
179
|
return /* @__PURE__ */ jsxRuntime.jsx(SymmContext.Provider, { value, children });
|
|
196
180
|
}
|
|
@@ -1063,8 +1047,7 @@ function useSymmInstantTrade(params) {
|
|
|
1063
1047
|
symmCoreClient,
|
|
1064
1048
|
chainId,
|
|
1065
1049
|
address,
|
|
1066
|
-
symmioConfig
|
|
1067
|
-
refreshAuth
|
|
1050
|
+
symmioConfig
|
|
1068
1051
|
} = useSymmContext();
|
|
1069
1052
|
const { publicClient, walletClient } = params;
|
|
1070
1053
|
const queryClient = reactQuery.useQueryClient();
|
|
@@ -1090,9 +1073,9 @@ function useSymmInstantTrade(params) {
|
|
|
1090
1073
|
if (selectors.length === 0) {
|
|
1091
1074
|
throw new Error("at least one delegation selector is required");
|
|
1092
1075
|
}
|
|
1093
|
-
const accessToken = useSymmAuthStore.getState().getToken(accountAddress, chainId)
|
|
1076
|
+
const accessToken = useSymmAuthStore.getState().getToken(accountAddress, chainId);
|
|
1094
1077
|
if (!accessToken) {
|
|
1095
|
-
throw new Error("
|
|
1078
|
+
throw new Error("auth token is required for instant trading");
|
|
1096
1079
|
}
|
|
1097
1080
|
const accessStates = await Promise.all(
|
|
1098
1081
|
selectors.map(
|
|
@@ -1477,7 +1460,7 @@ function useSymmApproval(params) {
|
|
|
1477
1460
|
};
|
|
1478
1461
|
}
|
|
1479
1462
|
function useSymmCancelClose() {
|
|
1480
|
-
const { symmCoreClient,
|
|
1463
|
+
const { symmCoreClient, chainId, address } = useSymmContext();
|
|
1481
1464
|
const queryClient = reactQuery.useQueryClient();
|
|
1482
1465
|
const cancelClose = reactQuery.useMutation({
|
|
1483
1466
|
mutationFn: async ({
|
|
@@ -1489,14 +1472,16 @@ function useSymmCancelClose() {
|
|
|
1489
1472
|
if (!symmCoreClient) {
|
|
1490
1473
|
throw new Error("symm-core client not available");
|
|
1491
1474
|
}
|
|
1492
|
-
const
|
|
1475
|
+
const resolvedAccountAddress = accountAddress ?? address;
|
|
1476
|
+
const resolvedChainId = overrideChainId ?? chainId;
|
|
1477
|
+
const resolvedAuthToken = authToken ?? (resolvedAccountAddress ? useSymmAuthStore.getState().getToken(resolvedAccountAddress, resolvedChainId) : null);
|
|
1493
1478
|
if (!resolvedAuthToken) {
|
|
1494
1479
|
throw new Error("auth token is required to cancel a pending close");
|
|
1495
1480
|
}
|
|
1496
1481
|
return symmCoreClient.orders.cancelClose({
|
|
1497
1482
|
quoteId,
|
|
1498
1483
|
authToken: resolvedAuthToken,
|
|
1499
|
-
chainId:
|
|
1484
|
+
chainId: resolvedChainId
|
|
1500
1485
|
});
|
|
1501
1486
|
},
|
|
1502
1487
|
onSuccess: () => {
|
|
@@ -1507,7 +1492,7 @@ function useSymmCancelClose() {
|
|
|
1507
1492
|
return { cancelClose };
|
|
1508
1493
|
}
|
|
1509
1494
|
function useSymmCloseOrder() {
|
|
1510
|
-
const { symmCoreClient,
|
|
1495
|
+
const { symmCoreClient, address, chainId } = useSymmContext();
|
|
1511
1496
|
const queryClient = reactQuery.useQueryClient();
|
|
1512
1497
|
const closeOrder = reactQuery.useMutation({
|
|
1513
1498
|
mutationFn: async (request) => {
|
|
@@ -1517,7 +1502,7 @@ function useSymmCloseOrder() {
|
|
|
1517
1502
|
return symmCoreClient.orders.close(request.id, {
|
|
1518
1503
|
kind: request.kind,
|
|
1519
1504
|
type: request.type,
|
|
1520
|
-
authToken: request.authToken ??
|
|
1505
|
+
authToken: request.authToken ?? (address ? useSymmAuthStore.getState().getToken(address, chainId) ?? void 0 : void 0)
|
|
1521
1506
|
});
|
|
1522
1507
|
},
|
|
1523
1508
|
onSuccess: () => {
|
|
@@ -25239,9 +25224,7 @@ function useSymmPendingIds(params) {
|
|
|
25239
25224
|
function useSymmPendingInstantOpens(params) {
|
|
25240
25225
|
const {
|
|
25241
25226
|
symmCoreClient,
|
|
25242
|
-
chainId: ctxChainId
|
|
25243
|
-
authToken: ctxAuthToken,
|
|
25244
|
-
refreshAuth
|
|
25227
|
+
chainId: ctxChainId
|
|
25245
25228
|
} = useSymmContext();
|
|
25246
25229
|
const { accountAddress, authToken: providedAuthToken } = params;
|
|
25247
25230
|
const chainId = params.chainId ?? ctxChainId;
|
|
@@ -25250,7 +25233,7 @@ function useSymmPendingInstantOpens(params) {
|
|
|
25250
25233
|
...params.query,
|
|
25251
25234
|
queryKey: symmKeys.pendingInstantOpens(accountAddress, chainId),
|
|
25252
25235
|
queryFn: async () => {
|
|
25253
|
-
const authToken = providedAuthToken ?? useSymmAuthStore.getState().getToken(accountAddress, chainId)
|
|
25236
|
+
const authToken = providedAuthToken ?? useSymmAuthStore.getState().getToken(accountAddress, chainId);
|
|
25254
25237
|
if (!authToken) {
|
|
25255
25238
|
throw new Error("failed to acquire auth token for pending instant opens");
|
|
25256
25239
|
}
|