@pear-protocol/symmio-client 0.2.13 → 0.2.15
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 +8478 -195
- package/dist/react/index.d.ts +8478 -195
- package/dist/react/index.js +526 -383
- package/dist/react/index.js.map +1 -1
- package/dist/react/index.mjs +498 -373
- package/dist/react/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/react/index.mjs
CHANGED
|
@@ -948,95 +948,124 @@ function invalidateOrders(qc) {
|
|
|
948
948
|
qc.invalidateQueries({ queryKey: ["symm", "triggerOrders"] });
|
|
949
949
|
}
|
|
950
950
|
|
|
951
|
-
// src/react/
|
|
952
|
-
function
|
|
951
|
+
// src/react/mutation-config.ts
|
|
952
|
+
function withSymmMutationConfig(config, internal) {
|
|
953
953
|
const {
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
} =
|
|
959
|
-
|
|
960
|
-
|
|
954
|
+
onSuccess: configOnSuccess,
|
|
955
|
+
onError: configOnError,
|
|
956
|
+
onSettled: configOnSettled,
|
|
957
|
+
...rest
|
|
958
|
+
} = config ?? {};
|
|
959
|
+
return {
|
|
960
|
+
...rest,
|
|
961
|
+
onSuccess: async (...args) => {
|
|
962
|
+
await internal?.onSuccess?.(...args);
|
|
963
|
+
await configOnSuccess?.(...args);
|
|
964
|
+
},
|
|
965
|
+
onError: async (...args) => {
|
|
966
|
+
await internal?.onError?.(...args);
|
|
967
|
+
await configOnError?.(...args);
|
|
968
|
+
},
|
|
969
|
+
onSettled: async (...args) => {
|
|
970
|
+
await internal?.onSettled?.(...args);
|
|
971
|
+
await configOnSettled?.(...args);
|
|
972
|
+
}
|
|
973
|
+
};
|
|
974
|
+
}
|
|
975
|
+
|
|
976
|
+
// src/react/hooks/use-symm-instant-trade.ts
|
|
977
|
+
function useInstantTradeDeps(params) {
|
|
978
|
+
const { symmCoreClient, chainId, address, symmioConfig } = useSymmContext();
|
|
961
979
|
const multiAccount = symmioConfig?.multiAccountAddress ?? getAddress(MULTI_ACCOUNT_ADDRESS, chainId, "MultiAccount");
|
|
962
980
|
const defaultAccountAddress = params.accountAddress ?? address;
|
|
963
981
|
const defaultTarget = params.target ?? DEFAULT_PARTY_B_ADDRESS[chainId];
|
|
964
982
|
const defaultSelectors = params.selectors ?? ALL_TRADING_SELECTORS;
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
);
|
|
996
|
-
if (!accessStates.every(Boolean)) {
|
|
997
|
-
await delegateAccess(walletClient, publicClient, multiAccount, {
|
|
998
|
-
account: accountAddress,
|
|
999
|
-
target,
|
|
1000
|
-
selectors: [...selectors],
|
|
1001
|
-
activate: true
|
|
1002
|
-
});
|
|
1003
|
-
await queryClient.invalidateQueries({
|
|
1004
|
-
queryKey: symmKeys.delegation(accountAddress, target, selectors, chainId)
|
|
1005
|
-
});
|
|
1006
|
-
}
|
|
1007
|
-
return {
|
|
1008
|
-
accessToken,
|
|
1009
|
-
accountAddress,
|
|
983
|
+
return {
|
|
984
|
+
chainId,
|
|
985
|
+
defaultAccountAddress,
|
|
986
|
+
defaultSelectors,
|
|
987
|
+
defaultTarget,
|
|
988
|
+
multiAccount,
|
|
989
|
+
publicClient: params.publicClient,
|
|
990
|
+
symmCoreClient,
|
|
991
|
+
walletClient: params.walletClient
|
|
992
|
+
};
|
|
993
|
+
}
|
|
994
|
+
async function ensureInstantTradeReady(deps, queryClient, request) {
|
|
995
|
+
const { chainId, defaultAccountAddress, defaultSelectors, defaultTarget, multiAccount, publicClient, walletClient } = deps;
|
|
996
|
+
if (!publicClient || !walletClient) throw new Error("Clients not available");
|
|
997
|
+
const accountAddress = request?.accountAddress ?? defaultAccountAddress;
|
|
998
|
+
const target = request?.target ?? defaultTarget;
|
|
999
|
+
const selectors = request?.selectors ?? defaultSelectors;
|
|
1000
|
+
if (!accountAddress) throw new Error("account address is required");
|
|
1001
|
+
if (!target) throw new Error("delegation target is not configured");
|
|
1002
|
+
if (selectors.length === 0) {
|
|
1003
|
+
throw new Error("at least one delegation selector is required");
|
|
1004
|
+
}
|
|
1005
|
+
const accessToken = useSymmAuthStore.getState().getToken(accountAddress, chainId);
|
|
1006
|
+
if (!accessToken) {
|
|
1007
|
+
throw new Error("auth token is required for instant trading");
|
|
1008
|
+
}
|
|
1009
|
+
const accessStates = await Promise.all(
|
|
1010
|
+
selectors.map(
|
|
1011
|
+
(selector) => hasDelegatedAccess(publicClient, multiAccount, {
|
|
1012
|
+
account: accountAddress,
|
|
1010
1013
|
target,
|
|
1011
|
-
|
|
1012
|
-
}
|
|
1013
|
-
|
|
1014
|
+
selector
|
|
1015
|
+
})
|
|
1016
|
+
)
|
|
1017
|
+
);
|
|
1018
|
+
if (!accessStates.every(Boolean)) {
|
|
1019
|
+
await delegateAccess(walletClient, publicClient, multiAccount, {
|
|
1020
|
+
account: accountAddress,
|
|
1021
|
+
target,
|
|
1022
|
+
selectors: [...selectors],
|
|
1023
|
+
activate: true
|
|
1024
|
+
});
|
|
1025
|
+
await queryClient.invalidateQueries({
|
|
1026
|
+
queryKey: symmKeys.delegation(accountAddress, target, selectors, chainId)
|
|
1027
|
+
});
|
|
1028
|
+
}
|
|
1029
|
+
return {
|
|
1030
|
+
accessToken,
|
|
1031
|
+
accountAddress,
|
|
1032
|
+
target,
|
|
1033
|
+
selectors
|
|
1034
|
+
};
|
|
1035
|
+
}
|
|
1036
|
+
function useSymmInstantTradeEnsureReadyMutation(params, options) {
|
|
1037
|
+
const queryClient = useQueryClient();
|
|
1038
|
+
const deps = useInstantTradeDeps(params);
|
|
1039
|
+
return useMutation({
|
|
1040
|
+
...withSymmMutationConfig(options?.mutation),
|
|
1041
|
+
mutationFn: async (request) => ensureInstantTradeReady(deps, queryClient, request)
|
|
1014
1042
|
});
|
|
1015
|
-
|
|
1043
|
+
}
|
|
1044
|
+
function useSymmInstantTradeExecuteMutation(params, options) {
|
|
1045
|
+
const queryClient = useQueryClient();
|
|
1046
|
+
const deps = useInstantTradeDeps(params);
|
|
1047
|
+
return useMutation({
|
|
1048
|
+
...withSymmMutationConfig(options?.mutation, {
|
|
1049
|
+
onSuccess: (_data, variables) => {
|
|
1050
|
+
if (variables.invalidatePositionsOnSuccess !== false) {
|
|
1051
|
+
invalidatePositions(queryClient);
|
|
1052
|
+
}
|
|
1053
|
+
}
|
|
1054
|
+
}),
|
|
1016
1055
|
mutationFn: async (request) => {
|
|
1017
|
-
if (!symmCoreClient) throw new Error("symm-core client not available");
|
|
1018
|
-
const setup = await
|
|
1056
|
+
if (!deps.symmCoreClient) throw new Error("symm-core client not available");
|
|
1057
|
+
const setup = await ensureInstantTradeReady(deps, queryClient, {
|
|
1019
1058
|
accountAddress: request.accountAddress,
|
|
1020
1059
|
target: request.target,
|
|
1021
1060
|
selectors: request.selectors
|
|
1022
1061
|
});
|
|
1023
1062
|
return request.action({
|
|
1024
|
-
symmCoreClient,
|
|
1063
|
+
symmCoreClient: deps.symmCoreClient,
|
|
1025
1064
|
accessToken: setup.accessToken,
|
|
1026
1065
|
accountAddress: setup.accountAddress
|
|
1027
1066
|
});
|
|
1028
|
-
},
|
|
1029
|
-
onSuccess: (_data, variables) => {
|
|
1030
|
-
if (variables.invalidatePositionsOnSuccess !== false) {
|
|
1031
|
-
invalidatePositions(queryClient);
|
|
1032
|
-
}
|
|
1033
1067
|
}
|
|
1034
1068
|
});
|
|
1035
|
-
return {
|
|
1036
|
-
delegation,
|
|
1037
|
-
ensureReady,
|
|
1038
|
-
execute
|
|
1039
|
-
};
|
|
1040
1069
|
}
|
|
1041
1070
|
function prepareAddAccount(multiAccount, account, name) {
|
|
1042
1071
|
const data = encodeFunctionData({
|
|
@@ -1095,51 +1124,65 @@ async function getAccounts(publicClient, multiAccount, user, start = 0, size = 1
|
|
|
1095
1124
|
}
|
|
1096
1125
|
|
|
1097
1126
|
// src/react/hooks/use-symm-accounts.ts
|
|
1098
|
-
function
|
|
1127
|
+
function useResolvedMultiAccount() {
|
|
1099
1128
|
const { chainId, symmioConfig } = useSymmContext();
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1129
|
+
return symmioConfig?.multiAccountAddress ?? getAddress(MULTI_ACCOUNT_ADDRESS, chainId, "MultiAccount");
|
|
1130
|
+
}
|
|
1131
|
+
function useSymmAccountsQuery(params = {}, options) {
|
|
1132
|
+
const { chainId } = useSymmContext();
|
|
1133
|
+
const multiAccount = useResolvedMultiAccount();
|
|
1134
|
+
const { userAddress, publicClient } = params;
|
|
1103
1135
|
const internalEnabled = !!publicClient && !!userAddress;
|
|
1104
|
-
|
|
1136
|
+
return useQuery({
|
|
1105
1137
|
...options?.query,
|
|
1106
1138
|
queryKey: symmKeys.accounts(userAddress, chainId),
|
|
1107
1139
|
queryFn: () => getAccounts(publicClient, multiAccount, userAddress),
|
|
1108
1140
|
enabled: internalEnabled && (options?.query?.enabled ?? true)
|
|
1109
1141
|
});
|
|
1110
|
-
|
|
1142
|
+
}
|
|
1143
|
+
function useSymmCreateAccountMutation(params = {}, options) {
|
|
1144
|
+
const { chainId } = useSymmContext();
|
|
1145
|
+
const queryClient = useQueryClient();
|
|
1146
|
+
const multiAccount = useResolvedMultiAccount();
|
|
1147
|
+
const { userAddress, publicClient, walletClient } = params;
|
|
1148
|
+
return useMutation({
|
|
1149
|
+
...withSymmMutationConfig(options?.mutation, {
|
|
1150
|
+
onSuccess: () => {
|
|
1151
|
+
queryClient.invalidateQueries({ queryKey: symmKeys.accounts(userAddress, chainId) });
|
|
1152
|
+
}
|
|
1153
|
+
}),
|
|
1111
1154
|
mutationFn: async ({ name }) => {
|
|
1112
1155
|
if (!walletClient || !publicClient) throw new Error("Clients not available");
|
|
1113
1156
|
return addAccount(walletClient, publicClient, multiAccount, name);
|
|
1114
|
-
},
|
|
1115
|
-
onSuccess: () => {
|
|
1116
|
-
queryClient.invalidateQueries({ queryKey: symmKeys.accounts(userAddress, chainId) });
|
|
1117
1157
|
}
|
|
1118
1158
|
});
|
|
1119
|
-
|
|
1159
|
+
}
|
|
1160
|
+
function useSymmEditAccountNameMutation(params = {}, options) {
|
|
1161
|
+
const { chainId } = useSymmContext();
|
|
1162
|
+
const queryClient = useQueryClient();
|
|
1163
|
+
const multiAccount = useResolvedMultiAccount();
|
|
1164
|
+
const { userAddress, publicClient, walletClient } = params;
|
|
1165
|
+
return useMutation({
|
|
1166
|
+
...withSymmMutationConfig(options?.mutation, {
|
|
1167
|
+
onSuccess: () => {
|
|
1168
|
+
queryClient.invalidateQueries({ queryKey: symmKeys.accounts(userAddress, chainId) });
|
|
1169
|
+
}
|
|
1170
|
+
}),
|
|
1120
1171
|
mutationFn: async ({
|
|
1121
1172
|
accountAddress,
|
|
1122
1173
|
name
|
|
1123
1174
|
}) => {
|
|
1124
1175
|
if (!walletClient || !publicClient) throw new Error("Clients not available");
|
|
1125
1176
|
return editAccountName(walletClient, publicClient, multiAccount, accountAddress, name);
|
|
1126
|
-
},
|
|
1127
|
-
onSuccess: () => {
|
|
1128
|
-
queryClient.invalidateQueries({ queryKey: symmKeys.accounts(userAddress, chainId) });
|
|
1129
1177
|
}
|
|
1130
1178
|
});
|
|
1131
|
-
return {
|
|
1132
|
-
query: accountsQuery,
|
|
1133
|
-
createAccount,
|
|
1134
|
-
editName
|
|
1135
|
-
};
|
|
1136
1179
|
}
|
|
1137
1180
|
function useSymmAccountsApi(params) {
|
|
1138
1181
|
const { symmCoreClient, chainId: ctxChainId } = useSymmContext();
|
|
1139
1182
|
const { userAddress } = params;
|
|
1140
1183
|
const chainId = params.chainId ?? ctxChainId;
|
|
1141
1184
|
const internalEnabled = !!symmCoreClient && !!userAddress;
|
|
1142
|
-
|
|
1185
|
+
return useQuery({
|
|
1143
1186
|
...params.query,
|
|
1144
1187
|
queryKey: symmKeys.accountsApi(userAddress, chainId),
|
|
1145
1188
|
queryFn: () => symmCoreClient.accounts.list({
|
|
@@ -1148,16 +1191,13 @@ function useSymmAccountsApi(params) {
|
|
|
1148
1191
|
}),
|
|
1149
1192
|
enabled: internalEnabled && (params.query?.enabled ?? true)
|
|
1150
1193
|
});
|
|
1151
|
-
return {
|
|
1152
|
-
query
|
|
1153
|
-
};
|
|
1154
1194
|
}
|
|
1155
1195
|
function useSymmAccountsLength(params) {
|
|
1156
1196
|
const { symmCoreClient, chainId: ctxChainId } = useSymmContext();
|
|
1157
1197
|
const { userAddress } = params;
|
|
1158
1198
|
const chainId = params.chainId ?? ctxChainId;
|
|
1159
1199
|
const internalEnabled = !!symmCoreClient && !!userAddress;
|
|
1160
|
-
|
|
1200
|
+
return useQuery({
|
|
1161
1201
|
...params.query,
|
|
1162
1202
|
queryKey: symmKeys.accountsLength(userAddress, chainId),
|
|
1163
1203
|
queryFn: () => symmCoreClient.accounts.getLength({
|
|
@@ -1166,16 +1206,13 @@ function useSymmAccountsLength(params) {
|
|
|
1166
1206
|
}),
|
|
1167
1207
|
enabled: internalEnabled && (params.query?.enabled ?? true)
|
|
1168
1208
|
});
|
|
1169
|
-
return {
|
|
1170
|
-
query
|
|
1171
|
-
};
|
|
1172
1209
|
}
|
|
1173
1210
|
function useSymmAccountsWithPositions(params) {
|
|
1174
1211
|
const { symmCoreClient, chainId: ctxChainId } = useSymmContext();
|
|
1175
1212
|
const { userAddress } = params;
|
|
1176
1213
|
const chainId = params.chainId ?? ctxChainId;
|
|
1177
1214
|
const internalEnabled = !!symmCoreClient && !!userAddress;
|
|
1178
|
-
|
|
1215
|
+
return useQuery({
|
|
1179
1216
|
...params.query,
|
|
1180
1217
|
queryKey: symmKeys.accountsWithPositions(userAddress, chainId),
|
|
1181
1218
|
queryFn: () => symmCoreClient.accounts.getWithPositions({
|
|
@@ -1184,9 +1221,6 @@ function useSymmAccountsWithPositions(params) {
|
|
|
1184
1221
|
}),
|
|
1185
1222
|
enabled: internalEnabled && (params.query?.enabled ?? true)
|
|
1186
1223
|
});
|
|
1187
|
-
return {
|
|
1188
|
-
query
|
|
1189
|
-
};
|
|
1190
1224
|
}
|
|
1191
1225
|
|
|
1192
1226
|
// src/abis/ERC20.ts
|
|
@@ -1304,14 +1338,22 @@ async function getBalance(publicClient, tokenAddress, account) {
|
|
|
1304
1338
|
}
|
|
1305
1339
|
|
|
1306
1340
|
// src/react/hooks/use-symm-approval.ts
|
|
1307
|
-
function
|
|
1341
|
+
function useResolvedApprovalConfig(params) {
|
|
1308
1342
|
const { chainId, symmioConfig } = useSymmContext();
|
|
1309
|
-
const queryClient = useQueryClient();
|
|
1310
|
-
const { owner, amount, publicClient, walletClient, spender, collateralToken } = params;
|
|
1311
1343
|
const multiAccount = symmioConfig?.multiAccountAddress ?? getAddress(MULTI_ACCOUNT_ADDRESS, chainId, "MultiAccount");
|
|
1312
1344
|
const collateral = symmioConfig?.collateralAddress ?? getAddress(COLLATERAL_ADDRESS, chainId, "Collateral");
|
|
1313
|
-
const resolvedSpender = spender ?? multiAccount;
|
|
1314
|
-
const resolvedToken = collateralToken ?? collateral;
|
|
1345
|
+
const resolvedSpender = params.spender ?? multiAccount;
|
|
1346
|
+
const resolvedToken = params.collateralToken ?? collateral;
|
|
1347
|
+
return {
|
|
1348
|
+
chainId,
|
|
1349
|
+
multiAccount,
|
|
1350
|
+
resolvedSpender,
|
|
1351
|
+
resolvedToken
|
|
1352
|
+
};
|
|
1353
|
+
}
|
|
1354
|
+
function useSymmApprovalQuery(params) {
|
|
1355
|
+
const { owner, amount, publicClient } = params;
|
|
1356
|
+
const { chainId, resolvedSpender, resolvedToken } = useResolvedApprovalConfig(params);
|
|
1315
1357
|
const selectWithAmount = useCallback(
|
|
1316
1358
|
(data) => ({
|
|
1317
1359
|
...data,
|
|
@@ -1320,7 +1362,7 @@ function useSymmApproval(params) {
|
|
|
1320
1362
|
[amount]
|
|
1321
1363
|
);
|
|
1322
1364
|
const internalEnabled = !!publicClient && !!owner && !!resolvedSpender && !!resolvedToken;
|
|
1323
|
-
|
|
1365
|
+
return useQuery({
|
|
1324
1366
|
...params.query,
|
|
1325
1367
|
queryKey: symmKeys.approval(owner, resolvedSpender, chainId, resolvedToken),
|
|
1326
1368
|
queryFn: async () => {
|
|
@@ -1333,26 +1375,35 @@ function useSymmApproval(params) {
|
|
|
1333
1375
|
select: selectWithAmount,
|
|
1334
1376
|
enabled: internalEnabled && (params.query?.enabled ?? true)
|
|
1335
1377
|
});
|
|
1336
|
-
|
|
1378
|
+
}
|
|
1379
|
+
function useSymmApproveMutation(params, options) {
|
|
1380
|
+
const { owner, publicClient, walletClient } = params;
|
|
1381
|
+
const { chainId, multiAccount, resolvedSpender, resolvedToken } = useResolvedApprovalConfig(params);
|
|
1382
|
+
const queryClient = useQueryClient();
|
|
1383
|
+
return useMutation({
|
|
1384
|
+
...withSymmMutationConfig(options?.mutation, {
|
|
1385
|
+
onSuccess: () => {
|
|
1386
|
+
queryClient.invalidateQueries({
|
|
1387
|
+
queryKey: symmKeys.approval(owner, resolvedSpender, chainId, resolvedToken)
|
|
1388
|
+
});
|
|
1389
|
+
}
|
|
1390
|
+
}),
|
|
1337
1391
|
mutationFn: async (approveAmount) => {
|
|
1338
1392
|
if (!walletClient || !publicClient) throw new Error("Clients not available");
|
|
1339
1393
|
return approve(walletClient, publicClient, resolvedToken, multiAccount, approveAmount);
|
|
1340
|
-
},
|
|
1341
|
-
onSuccess: () => {
|
|
1342
|
-
queryClient.invalidateQueries({
|
|
1343
|
-
queryKey: symmKeys.approval(owner, resolvedSpender, chainId, resolvedToken)
|
|
1344
|
-
});
|
|
1345
1394
|
}
|
|
1346
1395
|
});
|
|
1347
|
-
return {
|
|
1348
|
-
query: approvalQuery,
|
|
1349
|
-
approve: approveMutation
|
|
1350
|
-
};
|
|
1351
1396
|
}
|
|
1352
|
-
function useSymmCancelClose() {
|
|
1397
|
+
function useSymmCancelClose(options) {
|
|
1353
1398
|
const { symmCoreClient, chainId, address } = useSymmContext();
|
|
1354
1399
|
const queryClient = useQueryClient();
|
|
1355
|
-
|
|
1400
|
+
return useMutation({
|
|
1401
|
+
...withSymmMutationConfig(options?.mutation, {
|
|
1402
|
+
onSuccess: () => {
|
|
1403
|
+
invalidateOrders(queryClient);
|
|
1404
|
+
invalidatePositions(queryClient);
|
|
1405
|
+
}
|
|
1406
|
+
}),
|
|
1356
1407
|
mutationFn: async ({
|
|
1357
1408
|
quoteId,
|
|
1358
1409
|
authToken,
|
|
@@ -1373,18 +1424,19 @@ function useSymmCancelClose() {
|
|
|
1373
1424
|
authToken: resolvedAuthToken,
|
|
1374
1425
|
chainId: resolvedChainId
|
|
1375
1426
|
});
|
|
1376
|
-
},
|
|
1377
|
-
onSuccess: () => {
|
|
1378
|
-
invalidateOrders(queryClient);
|
|
1379
|
-
invalidatePositions(queryClient);
|
|
1380
1427
|
}
|
|
1381
1428
|
});
|
|
1382
|
-
return { cancelClose };
|
|
1383
1429
|
}
|
|
1384
|
-
function useSymmCloseOrder() {
|
|
1430
|
+
function useSymmCloseOrder(options) {
|
|
1385
1431
|
const { symmCoreClient, address, chainId } = useSymmContext();
|
|
1386
1432
|
const queryClient = useQueryClient();
|
|
1387
|
-
|
|
1433
|
+
return useMutation({
|
|
1434
|
+
...withSymmMutationConfig(options?.mutation, {
|
|
1435
|
+
onSuccess: () => {
|
|
1436
|
+
invalidateOrders(queryClient);
|
|
1437
|
+
invalidatePositions(queryClient);
|
|
1438
|
+
}
|
|
1439
|
+
}),
|
|
1388
1440
|
mutationFn: async (request) => {
|
|
1389
1441
|
if (!symmCoreClient) {
|
|
1390
1442
|
throw new Error("symm-core client not available");
|
|
@@ -1394,13 +1446,8 @@ function useSymmCloseOrder() {
|
|
|
1394
1446
|
type: request.type,
|
|
1395
1447
|
authToken: request.authToken ?? (address ? useSymmAuthStore.getState().getToken(address, chainId) ?? void 0 : void 0)
|
|
1396
1448
|
});
|
|
1397
|
-
},
|
|
1398
|
-
onSuccess: () => {
|
|
1399
|
-
invalidateOrders(queryClient);
|
|
1400
|
-
invalidatePositions(queryClient);
|
|
1401
1449
|
}
|
|
1402
1450
|
});
|
|
1403
|
-
return { closeOrder };
|
|
1404
1451
|
}
|
|
1405
1452
|
function prepareDeposit(multiAccount, account, params) {
|
|
1406
1453
|
validateAmount(params.amount, "deposit amount");
|
|
@@ -1454,38 +1501,52 @@ async function depositAndAllocate(walletClient, publicClient, multiAccount, para
|
|
|
1454
1501
|
}
|
|
1455
1502
|
|
|
1456
1503
|
// src/react/hooks/use-symm-deposit.ts
|
|
1457
|
-
function
|
|
1504
|
+
function useResolvedDepositParams(params = {}) {
|
|
1458
1505
|
const { chainId, symmioConfig } = useSymmContext();
|
|
1459
|
-
const { publicClient, walletClient } = params;
|
|
1460
|
-
const queryClient = useQueryClient();
|
|
1461
1506
|
const multiAccount = symmioConfig?.multiAccountAddress ?? getAddress(MULTI_ACCOUNT_ADDRESS, chainId, "MultiAccount");
|
|
1462
|
-
|
|
1507
|
+
return {
|
|
1508
|
+
multiAccount,
|
|
1509
|
+
publicClient: params.publicClient,
|
|
1510
|
+
walletClient: params.walletClient
|
|
1511
|
+
};
|
|
1512
|
+
}
|
|
1513
|
+
function useSymmDepositMutation(params = {}, options) {
|
|
1514
|
+
const queryClient = useQueryClient();
|
|
1515
|
+
const { multiAccount, publicClient, walletClient } = useResolvedDepositParams(params);
|
|
1516
|
+
return useMutation({
|
|
1517
|
+
...withSymmMutationConfig(options?.mutation, {
|
|
1518
|
+
onSuccess: () => {
|
|
1519
|
+
invalidateBalances(queryClient);
|
|
1520
|
+
queryClient.invalidateQueries({ queryKey: ["symm", "approval"] });
|
|
1521
|
+
}
|
|
1522
|
+
}),
|
|
1463
1523
|
mutationFn: async ({
|
|
1464
1524
|
account,
|
|
1465
1525
|
amount
|
|
1466
1526
|
}) => {
|
|
1467
1527
|
if (!walletClient || !publicClient) throw new Error("Clients not available");
|
|
1468
1528
|
return deposit(walletClient, publicClient, multiAccount, { account, amount });
|
|
1469
|
-
},
|
|
1470
|
-
onSuccess: () => {
|
|
1471
|
-
invalidateBalances(queryClient);
|
|
1472
|
-
queryClient.invalidateQueries({ queryKey: ["symm", "approval"] });
|
|
1473
1529
|
}
|
|
1474
1530
|
});
|
|
1475
|
-
|
|
1531
|
+
}
|
|
1532
|
+
function useSymmDepositAndAllocateMutation(params = {}, options) {
|
|
1533
|
+
const queryClient = useQueryClient();
|
|
1534
|
+
const { multiAccount, publicClient, walletClient } = useResolvedDepositParams(params);
|
|
1535
|
+
return useMutation({
|
|
1536
|
+
...withSymmMutationConfig(options?.mutation, {
|
|
1537
|
+
onSuccess: () => {
|
|
1538
|
+
invalidateBalances(queryClient);
|
|
1539
|
+
queryClient.invalidateQueries({ queryKey: ["symm", "approval"] });
|
|
1540
|
+
}
|
|
1541
|
+
}),
|
|
1476
1542
|
mutationFn: async ({
|
|
1477
1543
|
account,
|
|
1478
1544
|
amount
|
|
1479
1545
|
}) => {
|
|
1480
1546
|
if (!walletClient || !publicClient) throw new Error("Clients not available");
|
|
1481
1547
|
return depositAndAllocate(walletClient, publicClient, multiAccount, { account, amount });
|
|
1482
|
-
},
|
|
1483
|
-
onSuccess: () => {
|
|
1484
|
-
invalidateBalances(queryClient);
|
|
1485
|
-
queryClient.invalidateQueries({ queryKey: ["symm", "approval"] });
|
|
1486
1548
|
}
|
|
1487
1549
|
});
|
|
1488
|
-
return { deposit: depositMutation, depositAndAllocate: depositAndAllocateMutation };
|
|
1489
1550
|
}
|
|
1490
1551
|
function prepareWithdraw(multiAccount, account, params) {
|
|
1491
1552
|
validateAmount(params.amount, "withdraw amount");
|
|
@@ -1514,24 +1575,25 @@ async function withdraw(walletClient, publicClient, multiAccount, params) {
|
|
|
1514
1575
|
}
|
|
1515
1576
|
|
|
1516
1577
|
// src/react/hooks/use-symm-withdraw.ts
|
|
1517
|
-
function useSymmWithdraw(params = {}) {
|
|
1578
|
+
function useSymmWithdraw(params = {}, options) {
|
|
1518
1579
|
const { chainId, symmioConfig } = useSymmContext();
|
|
1519
1580
|
const { publicClient, walletClient } = params;
|
|
1520
1581
|
const queryClient = useQueryClient();
|
|
1521
1582
|
const multiAccount = symmioConfig?.multiAccountAddress ?? getAddress(MULTI_ACCOUNT_ADDRESS, chainId, "MultiAccount");
|
|
1522
|
-
|
|
1583
|
+
return useMutation({
|
|
1584
|
+
...withSymmMutationConfig(options?.mutation, {
|
|
1585
|
+
onSuccess: () => {
|
|
1586
|
+
invalidateBalances(queryClient);
|
|
1587
|
+
}
|
|
1588
|
+
}),
|
|
1523
1589
|
mutationFn: async ({
|
|
1524
1590
|
account,
|
|
1525
1591
|
amount
|
|
1526
1592
|
}) => {
|
|
1527
1593
|
if (!walletClient || !publicClient) throw new Error("Clients not available");
|
|
1528
1594
|
return withdraw(walletClient, publicClient, multiAccount, { account, amount });
|
|
1529
|
-
},
|
|
1530
|
-
onSuccess: () => {
|
|
1531
|
-
invalidateBalances(queryClient);
|
|
1532
1595
|
}
|
|
1533
1596
|
});
|
|
1534
|
-
return { withdraw: withdrawMutation };
|
|
1535
1597
|
}
|
|
1536
1598
|
|
|
1537
1599
|
// src/abis/SymmioDiamond.ts
|
|
@@ -24182,10 +24244,8 @@ var MuonClient = class {
|
|
|
24182
24244
|
};
|
|
24183
24245
|
|
|
24184
24246
|
// src/react/hooks/use-symm-collateral.ts
|
|
24185
|
-
function
|
|
24247
|
+
function useResolvedCollateralDeps(params = {}) {
|
|
24186
24248
|
const { chainId, symmioConfig } = useSymmContext();
|
|
24187
|
-
const { publicClient, walletClient } = params;
|
|
24188
|
-
const queryClient = useQueryClient();
|
|
24189
24249
|
const multiAccount = symmioConfig?.multiAccountAddress ?? getAddress(MULTI_ACCOUNT_ADDRESS, chainId, "MultiAccount");
|
|
24190
24250
|
const symmioDiamond = symmioConfig?.symmioDiamondAddress ?? getAddress(SYMMIO_DIAMOND_ADDRESS, chainId, "SymmioDiamond");
|
|
24191
24251
|
const muon = useMemo(
|
|
@@ -24195,19 +24255,42 @@ function useSymmCollateral(params = {}) {
|
|
|
24195
24255
|
}),
|
|
24196
24256
|
[symmioConfig?.muonBaseUrls, symmioConfig?.muonAppName]
|
|
24197
24257
|
);
|
|
24198
|
-
|
|
24258
|
+
return {
|
|
24259
|
+
chainId,
|
|
24260
|
+
muon,
|
|
24261
|
+
multiAccount,
|
|
24262
|
+
publicClient: params.publicClient,
|
|
24263
|
+
symmioDiamond,
|
|
24264
|
+
walletClient: params.walletClient
|
|
24265
|
+
};
|
|
24266
|
+
}
|
|
24267
|
+
function useSymmAllocateCollateralMutation(params = {}, options) {
|
|
24268
|
+
const queryClient = useQueryClient();
|
|
24269
|
+
const { multiAccount, publicClient, walletClient } = useResolvedCollateralDeps(params);
|
|
24270
|
+
return useMutation({
|
|
24271
|
+
...withSymmMutationConfig(options?.mutation, {
|
|
24272
|
+
onSuccess: () => {
|
|
24273
|
+
invalidateBalances(queryClient);
|
|
24274
|
+
}
|
|
24275
|
+
}),
|
|
24199
24276
|
mutationFn: async ({
|
|
24200
24277
|
subAccount,
|
|
24201
24278
|
amount
|
|
24202
24279
|
}) => {
|
|
24203
24280
|
if (!walletClient || !publicClient) throw new Error("Clients not available");
|
|
24204
24281
|
return allocate(walletClient, publicClient, multiAccount, subAccount, { amount });
|
|
24205
|
-
},
|
|
24206
|
-
onSuccess: () => {
|
|
24207
|
-
invalidateBalances(queryClient);
|
|
24208
24282
|
}
|
|
24209
24283
|
});
|
|
24210
|
-
|
|
24284
|
+
}
|
|
24285
|
+
function useSymmDeallocateCollateralMutation(params = {}, options) {
|
|
24286
|
+
const queryClient = useQueryClient();
|
|
24287
|
+
const { chainId, muon, multiAccount, publicClient, symmioDiamond, walletClient } = useResolvedCollateralDeps(params);
|
|
24288
|
+
return useMutation({
|
|
24289
|
+
...withSymmMutationConfig(options?.mutation, {
|
|
24290
|
+
onSuccess: () => {
|
|
24291
|
+
invalidateBalances(queryClient);
|
|
24292
|
+
}
|
|
24293
|
+
}),
|
|
24211
24294
|
mutationFn: async ({
|
|
24212
24295
|
subAccount,
|
|
24213
24296
|
amount
|
|
@@ -24222,28 +24305,26 @@ function useSymmCollateral(params = {}) {
|
|
|
24222
24305
|
amount,
|
|
24223
24306
|
upnlSig
|
|
24224
24307
|
});
|
|
24225
|
-
},
|
|
24226
|
-
onSuccess: () => {
|
|
24227
|
-
invalidateBalances(queryClient);
|
|
24228
24308
|
}
|
|
24229
24309
|
});
|
|
24230
|
-
|
|
24310
|
+
}
|
|
24311
|
+
function useSymmInternalTransferCollateralMutation(params = {}, options) {
|
|
24312
|
+
const queryClient = useQueryClient();
|
|
24313
|
+
const { multiAccount, publicClient, walletClient } = useResolvedCollateralDeps(params);
|
|
24314
|
+
return useMutation({
|
|
24315
|
+
...withSymmMutationConfig(options?.mutation, {
|
|
24316
|
+
onSuccess: () => {
|
|
24317
|
+
invalidateBalances(queryClient);
|
|
24318
|
+
}
|
|
24319
|
+
}),
|
|
24231
24320
|
mutationFn: async ({
|
|
24232
24321
|
subAccount,
|
|
24233
24322
|
params: transferParams
|
|
24234
24323
|
}) => {
|
|
24235
24324
|
if (!walletClient || !publicClient) throw new Error("Clients not available");
|
|
24236
24325
|
return internalTransfer(walletClient, publicClient, multiAccount, subAccount, transferParams);
|
|
24237
|
-
},
|
|
24238
|
-
onSuccess: () => {
|
|
24239
|
-
invalidateBalances(queryClient);
|
|
24240
24326
|
}
|
|
24241
24327
|
});
|
|
24242
|
-
return {
|
|
24243
|
-
allocate: allocateMutation,
|
|
24244
|
-
deallocate: deallocateMutation,
|
|
24245
|
-
internalTransfer: internalTransferMutation
|
|
24246
|
-
};
|
|
24247
24328
|
}
|
|
24248
24329
|
|
|
24249
24330
|
// src/abis/SignatureStore.ts
|
|
@@ -24335,40 +24416,47 @@ async function hasSignedCurrentVersion(publicClient, signatureStore, user) {
|
|
|
24335
24416
|
}
|
|
24336
24417
|
|
|
24337
24418
|
// src/react/hooks/use-symm-signature.ts
|
|
24338
|
-
function
|
|
24419
|
+
function useResolvedSignatureStore() {
|
|
24339
24420
|
const { chainId, symmioConfig } = useSymmContext();
|
|
24340
|
-
const { userAddress, publicClient, walletClient } = params;
|
|
24341
|
-
const queryClient = useQueryClient();
|
|
24342
24421
|
let signatureStore;
|
|
24343
24422
|
try {
|
|
24344
24423
|
signatureStore = symmioConfig?.signatureStoreAddress ?? getAddress(SIGNATURE_STORE_ADDRESS, chainId, "SignatureStore");
|
|
24345
24424
|
} catch {
|
|
24425
|
+
signatureStore = void 0;
|
|
24346
24426
|
}
|
|
24427
|
+
return { chainId, signatureStore };
|
|
24428
|
+
}
|
|
24429
|
+
function useSymmSignatureQuery(params = {}, options) {
|
|
24430
|
+
const { userAddress, publicClient } = params;
|
|
24431
|
+
const { chainId, signatureStore } = useResolvedSignatureStore();
|
|
24347
24432
|
const internalEnabled = !!publicClient && !!userAddress && !!signatureStore;
|
|
24348
|
-
|
|
24433
|
+
return useQuery({
|
|
24349
24434
|
...options?.query,
|
|
24350
24435
|
queryKey: symmKeys.signature(userAddress, chainId),
|
|
24351
24436
|
queryFn: () => hasSignedCurrentVersion(publicClient, signatureStore, userAddress),
|
|
24352
24437
|
enabled: internalEnabled && (options?.query?.enabled ?? true)
|
|
24353
24438
|
});
|
|
24354
|
-
|
|
24439
|
+
}
|
|
24440
|
+
function useSymmSignTermsMutation(params = {}, options) {
|
|
24441
|
+
const { userAddress, publicClient, walletClient } = params;
|
|
24442
|
+
const { chainId, signatureStore } = useResolvedSignatureStore();
|
|
24443
|
+
const queryClient = useQueryClient();
|
|
24444
|
+
return useMutation({
|
|
24445
|
+
...withSymmMutationConfig(options?.mutation, {
|
|
24446
|
+
onSuccess: () => {
|
|
24447
|
+
queryClient.invalidateQueries({
|
|
24448
|
+
queryKey: symmKeys.signature(userAddress, chainId)
|
|
24449
|
+
});
|
|
24450
|
+
}
|
|
24451
|
+
}),
|
|
24355
24452
|
mutationFn: async () => {
|
|
24356
24453
|
if (!walletClient || !publicClient || !signatureStore) {
|
|
24357
24454
|
throw new Error("Clients or SignatureStore not available");
|
|
24358
24455
|
}
|
|
24359
24456
|
const sig = await signTermsMessage(walletClient, publicClient, signatureStore);
|
|
24360
24457
|
await storeSignature(walletClient, publicClient, signatureStore, sig);
|
|
24361
|
-
},
|
|
24362
|
-
onSuccess: () => {
|
|
24363
|
-
queryClient.invalidateQueries({
|
|
24364
|
-
queryKey: symmKeys.signature(userAddress, chainId)
|
|
24365
|
-
});
|
|
24366
24458
|
}
|
|
24367
24459
|
});
|
|
24368
|
-
return {
|
|
24369
|
-
query: signedQuery,
|
|
24370
|
-
signTerms
|
|
24371
|
-
};
|
|
24372
24460
|
}
|
|
24373
24461
|
|
|
24374
24462
|
// src/actions/stats.ts
|
|
@@ -24411,23 +24499,20 @@ function useSymmAvailableMargin(params) {
|
|
|
24411
24499
|
[resolvedUpnl]
|
|
24412
24500
|
);
|
|
24413
24501
|
const internalEnabled = !!publicClient && !!accountAddress;
|
|
24414
|
-
|
|
24502
|
+
return useQuery({
|
|
24415
24503
|
...params.query,
|
|
24416
24504
|
queryKey: symmKeys.availableMargin(accountAddress, chainId),
|
|
24417
24505
|
queryFn: () => getPartyAStats(publicClient, symmioDiamond, accountAddress),
|
|
24418
24506
|
select: selectWithUpnl,
|
|
24419
24507
|
enabled: internalEnabled && (params.query?.enabled ?? true)
|
|
24420
24508
|
});
|
|
24421
|
-
return {
|
|
24422
|
-
query
|
|
24423
|
-
};
|
|
24424
24509
|
}
|
|
24425
24510
|
function useSymmAccountSummary(params) {
|
|
24426
24511
|
const { symmCoreClient, chainId: ctxChainId } = useSymmContext();
|
|
24427
24512
|
const { userAddress } = params;
|
|
24428
24513
|
const chainId = params.chainId ?? ctxChainId;
|
|
24429
24514
|
const internalEnabled = !!symmCoreClient && !!userAddress;
|
|
24430
|
-
|
|
24515
|
+
return useQuery({
|
|
24431
24516
|
...params.query,
|
|
24432
24517
|
queryKey: symmKeys.accountSummary(userAddress, chainId),
|
|
24433
24518
|
queryFn: () => symmCoreClient.accounts.getSummary({
|
|
@@ -24436,16 +24521,13 @@ function useSymmAccountSummary(params) {
|
|
|
24436
24521
|
}),
|
|
24437
24522
|
enabled: internalEnabled && (params.query?.enabled ?? true)
|
|
24438
24523
|
});
|
|
24439
|
-
return {
|
|
24440
|
-
query
|
|
24441
|
-
};
|
|
24442
24524
|
}
|
|
24443
24525
|
function useSymmAccountData(params) {
|
|
24444
24526
|
const { symmCoreClient, chainId: ctxChainId } = useSymmContext();
|
|
24445
24527
|
const { address, upnl } = params;
|
|
24446
24528
|
const chainId = params.chainId ?? ctxChainId;
|
|
24447
24529
|
const internalEnabled = !!symmCoreClient && !!address;
|
|
24448
|
-
|
|
24530
|
+
return useQuery({
|
|
24449
24531
|
...params.query,
|
|
24450
24532
|
queryKey: symmKeys.accountData(address, chainId, upnl),
|
|
24451
24533
|
queryFn: () => symmCoreClient.accounts.getData({
|
|
@@ -24455,16 +24537,13 @@ function useSymmAccountData(params) {
|
|
|
24455
24537
|
}),
|
|
24456
24538
|
enabled: internalEnabled && (params.query?.enabled ?? true)
|
|
24457
24539
|
});
|
|
24458
|
-
return {
|
|
24459
|
-
query
|
|
24460
|
-
};
|
|
24461
24540
|
}
|
|
24462
24541
|
function useSymmBalances(params) {
|
|
24463
24542
|
const { symmCoreClient, chainId: ctxChainId } = useSymmContext();
|
|
24464
24543
|
const { userAddress, multiAccountAddress } = params;
|
|
24465
24544
|
const chainId = params.chainId ?? ctxChainId;
|
|
24466
24545
|
const internalEnabled = !!symmCoreClient && !!userAddress;
|
|
24467
|
-
|
|
24546
|
+
return useQuery({
|
|
24468
24547
|
...params.query,
|
|
24469
24548
|
queryKey: symmKeys.balances(userAddress, chainId),
|
|
24470
24549
|
queryFn: () => symmCoreClient.accounts.getBalanceInfo({
|
|
@@ -24474,62 +24553,134 @@ function useSymmBalances(params) {
|
|
|
24474
24553
|
}),
|
|
24475
24554
|
enabled: internalEnabled && (params.query?.enabled ?? true)
|
|
24476
24555
|
});
|
|
24477
|
-
return {
|
|
24478
|
-
query
|
|
24479
|
-
};
|
|
24480
24556
|
}
|
|
24481
|
-
function
|
|
24557
|
+
function useResolveTradeAuthToken() {
|
|
24558
|
+
const context = useSymmContext();
|
|
24559
|
+
const { address, chainId } = context;
|
|
24560
|
+
const { refreshAuth } = useSymmAuth({ address, chainId });
|
|
24561
|
+
const refreshAuthFromContext = context.refreshAuth;
|
|
24562
|
+
return useCallback(
|
|
24563
|
+
async (providedAuthToken, accountAddress) => {
|
|
24564
|
+
if (providedAuthToken) {
|
|
24565
|
+
return providedAuthToken;
|
|
24566
|
+
}
|
|
24567
|
+
const resolvedAccountAddress = accountAddress ?? address;
|
|
24568
|
+
if (!resolvedAccountAddress) {
|
|
24569
|
+
return null;
|
|
24570
|
+
}
|
|
24571
|
+
const inMemoryToken = useSymmAuthStore.getState().getToken(resolvedAccountAddress, chainId);
|
|
24572
|
+
if (inMemoryToken) {
|
|
24573
|
+
return inMemoryToken;
|
|
24574
|
+
}
|
|
24575
|
+
if (refreshAuthFromContext) {
|
|
24576
|
+
return refreshAuthFromContext(resolvedAccountAddress);
|
|
24577
|
+
}
|
|
24578
|
+
return refreshAuth(resolvedAccountAddress);
|
|
24579
|
+
},
|
|
24580
|
+
[address, chainId, refreshAuth, refreshAuthFromContext]
|
|
24581
|
+
);
|
|
24582
|
+
}
|
|
24583
|
+
function useSymmOpenBasketMutation(options) {
|
|
24482
24584
|
const { symmCoreClient } = useSymmContext();
|
|
24483
24585
|
const queryClient = useQueryClient();
|
|
24484
|
-
|
|
24586
|
+
return useMutation({
|
|
24587
|
+
...withSymmMutationConfig(options?.mutation, {
|
|
24588
|
+
onSuccess: () => {
|
|
24589
|
+
invalidatePositions(queryClient);
|
|
24590
|
+
}
|
|
24591
|
+
}),
|
|
24485
24592
|
mutationFn: async (request) => {
|
|
24486
24593
|
if (!symmCoreClient) throw new Error("symm-core client not available");
|
|
24487
24594
|
return symmCoreClient.positions.openBasket(request);
|
|
24488
|
-
},
|
|
24489
|
-
onSuccess: () => {
|
|
24490
|
-
invalidatePositions(queryClient);
|
|
24491
24595
|
}
|
|
24492
24596
|
});
|
|
24493
|
-
|
|
24597
|
+
}
|
|
24598
|
+
function useSymmClosePositionMutation(options) {
|
|
24599
|
+
const { symmCoreClient } = useSymmContext();
|
|
24600
|
+
const queryClient = useQueryClient();
|
|
24601
|
+
const resolveAuthToken = useResolveTradeAuthToken();
|
|
24602
|
+
return useMutation({
|
|
24603
|
+
...withSymmMutationConfig(options?.mutation, {
|
|
24604
|
+
onSuccess: () => {
|
|
24605
|
+
invalidatePositions(queryClient);
|
|
24606
|
+
}
|
|
24607
|
+
}),
|
|
24494
24608
|
mutationFn: async (request) => {
|
|
24495
24609
|
if (!symmCoreClient) throw new Error("symm-core client not available");
|
|
24496
|
-
|
|
24497
|
-
|
|
24498
|
-
|
|
24499
|
-
|
|
24610
|
+
const typedRequest = request;
|
|
24611
|
+
const authToken = await resolveAuthToken(
|
|
24612
|
+
typedRequest.authToken,
|
|
24613
|
+
typedRequest.accountAddress
|
|
24614
|
+
);
|
|
24615
|
+
if (!authToken) {
|
|
24616
|
+
throw new Error("auth token is required to close a position");
|
|
24617
|
+
}
|
|
24618
|
+
return symmCoreClient.positions.close({
|
|
24619
|
+
...request,
|
|
24620
|
+
authToken
|
|
24621
|
+
});
|
|
24500
24622
|
}
|
|
24501
24623
|
});
|
|
24502
|
-
|
|
24624
|
+
}
|
|
24625
|
+
function useSymmCloseAllPositionsMutation(options) {
|
|
24626
|
+
const { symmCoreClient } = useSymmContext();
|
|
24627
|
+
const queryClient = useQueryClient();
|
|
24628
|
+
return useMutation({
|
|
24629
|
+
...withSymmMutationConfig(options?.mutation, {
|
|
24630
|
+
onSuccess: () => {
|
|
24631
|
+
invalidatePositions(queryClient);
|
|
24632
|
+
}
|
|
24633
|
+
}),
|
|
24503
24634
|
mutationFn: async (request) => {
|
|
24504
24635
|
if (!symmCoreClient) throw new Error("symm-core client not available");
|
|
24505
24636
|
return symmCoreClient.positions.closeAll(request);
|
|
24506
|
-
},
|
|
24507
|
-
onSuccess: () => {
|
|
24508
|
-
invalidatePositions(queryClient);
|
|
24509
24637
|
}
|
|
24510
24638
|
});
|
|
24511
|
-
|
|
24639
|
+
}
|
|
24640
|
+
function useSymmCancelOpenMutation(options) {
|
|
24641
|
+
const { symmCoreClient } = useSymmContext();
|
|
24642
|
+
const queryClient = useQueryClient();
|
|
24643
|
+
return useMutation({
|
|
24644
|
+
...withSymmMutationConfig(options?.mutation, {
|
|
24645
|
+
onSuccess: () => {
|
|
24646
|
+
invalidatePositions(queryClient);
|
|
24647
|
+
}
|
|
24648
|
+
}),
|
|
24512
24649
|
mutationFn: async (request) => {
|
|
24513
24650
|
if (!symmCoreClient) throw new Error("symm-core client not available");
|
|
24514
24651
|
return symmCoreClient.positions.cancelOpen(request);
|
|
24515
|
-
},
|
|
24516
|
-
onSuccess: () => {
|
|
24517
|
-
invalidatePositions(queryClient);
|
|
24518
24652
|
}
|
|
24519
24653
|
});
|
|
24520
|
-
|
|
24654
|
+
}
|
|
24655
|
+
function useSymmUpdatePositionMutation(options) {
|
|
24656
|
+
const { symmCoreClient } = useSymmContext();
|
|
24657
|
+
const queryClient = useQueryClient();
|
|
24658
|
+
const resolveAuthToken = useResolveTradeAuthToken();
|
|
24659
|
+
return useMutation({
|
|
24660
|
+
...withSymmMutationConfig(options?.mutation, {
|
|
24661
|
+
onSuccess: () => {
|
|
24662
|
+
invalidatePositions(queryClient);
|
|
24663
|
+
}
|
|
24664
|
+
}),
|
|
24521
24665
|
mutationFn: async ({
|
|
24522
24666
|
positionId,
|
|
24523
24667
|
request
|
|
24524
24668
|
}) => {
|
|
24525
24669
|
if (!symmCoreClient) throw new Error("symm-core client not available");
|
|
24526
|
-
|
|
24527
|
-
|
|
24528
|
-
|
|
24529
|
-
|
|
24670
|
+
const typedRequest = request;
|
|
24671
|
+
const authToken = await resolveAuthToken(
|
|
24672
|
+
typedRequest.authToken,
|
|
24673
|
+
typedRequest.accountAddress
|
|
24674
|
+
);
|
|
24675
|
+
if (!authToken) {
|
|
24676
|
+
throw new Error("auth token is required to update a position");
|
|
24677
|
+
}
|
|
24678
|
+
return symmCoreClient.positions.update(positionId, {
|
|
24679
|
+
...request,
|
|
24680
|
+
authToken
|
|
24681
|
+
});
|
|
24530
24682
|
}
|
|
24531
24683
|
});
|
|
24532
|
-
return { openBasket, closePosition, closeAll, cancelOpen, updatePosition };
|
|
24533
24684
|
}
|
|
24534
24685
|
function useSymmPositions(params) {
|
|
24535
24686
|
const { symmCoreClient, chainId: ctxChainId } = useSymmContext();
|
|
@@ -24537,14 +24688,7 @@ function useSymmPositions(params) {
|
|
|
24537
24688
|
const resolvedAddress = accountAddress ? void 0 : address;
|
|
24538
24689
|
const chainId = params.chainId ?? ctxChainId;
|
|
24539
24690
|
const internalEnabled = !!symmCoreClient && !!(accountAddress || resolvedAddress);
|
|
24540
|
-
|
|
24541
|
-
symmCoreClient,
|
|
24542
|
-
accountAddress,
|
|
24543
|
-
resolvedAddress,
|
|
24544
|
-
chainId,
|
|
24545
|
-
internalEnabled
|
|
24546
|
-
});
|
|
24547
|
-
const query = useQuery({
|
|
24691
|
+
return useQuery({
|
|
24548
24692
|
...params.query,
|
|
24549
24693
|
queryKey: symmKeys.positions({
|
|
24550
24694
|
accountAddress,
|
|
@@ -24558,10 +24702,6 @@ function useSymmPositions(params) {
|
|
|
24558
24702
|
}),
|
|
24559
24703
|
enabled: internalEnabled && (params.query?.enabled ?? true)
|
|
24560
24704
|
});
|
|
24561
|
-
console.log("positions query", { data: query.data });
|
|
24562
|
-
return {
|
|
24563
|
-
query
|
|
24564
|
-
};
|
|
24565
24705
|
}
|
|
24566
24706
|
function useSymmOpenOrders(params) {
|
|
24567
24707
|
const { symmCoreClient, chainId: ctxChainId } = useSymmContext();
|
|
@@ -24569,7 +24709,7 @@ function useSymmOpenOrders(params) {
|
|
|
24569
24709
|
const resolvedAddress = accountAddress ? void 0 : address;
|
|
24570
24710
|
const chainId = params.chainId ?? ctxChainId;
|
|
24571
24711
|
const internalEnabled = !!symmCoreClient && !!(accountAddress || resolvedAddress);
|
|
24572
|
-
|
|
24712
|
+
return useQuery({
|
|
24573
24713
|
...params.query,
|
|
24574
24714
|
queryKey: symmKeys.openOrders({
|
|
24575
24715
|
accountAddress,
|
|
@@ -24582,9 +24722,6 @@ function useSymmOpenOrders(params) {
|
|
|
24582
24722
|
}),
|
|
24583
24723
|
enabled: internalEnabled && (params.query?.enabled ?? true)
|
|
24584
24724
|
});
|
|
24585
|
-
return {
|
|
24586
|
-
query
|
|
24587
|
-
};
|
|
24588
24725
|
}
|
|
24589
24726
|
function useSymmTradeHistory(params) {
|
|
24590
24727
|
const { symmCoreClient, chainId: ctxChainId } = useSymmContext();
|
|
@@ -24592,7 +24729,7 @@ function useSymmTradeHistory(params) {
|
|
|
24592
24729
|
const resolvedAddress = accountAddress ? void 0 : address;
|
|
24593
24730
|
const chainId = params.chainId ?? ctxChainId;
|
|
24594
24731
|
const internalEnabled = !!symmCoreClient && !!(accountAddress || resolvedAddress);
|
|
24595
|
-
|
|
24732
|
+
return useQuery({
|
|
24596
24733
|
...params.query,
|
|
24597
24734
|
queryKey: symmKeys.tradeHistory({
|
|
24598
24735
|
accountAddress,
|
|
@@ -24609,34 +24746,38 @@ function useSymmTradeHistory(params) {
|
|
|
24609
24746
|
},
|
|
24610
24747
|
enabled: internalEnabled && (params.query?.enabled ?? true)
|
|
24611
24748
|
});
|
|
24612
|
-
return {
|
|
24613
|
-
query
|
|
24614
|
-
};
|
|
24615
24749
|
}
|
|
24616
|
-
function
|
|
24750
|
+
function useSymmSetTpslMutation(options) {
|
|
24617
24751
|
const { symmCoreClient } = useSymmContext();
|
|
24618
24752
|
const queryClient = useQueryClient();
|
|
24619
|
-
|
|
24753
|
+
return useMutation({
|
|
24754
|
+
...withSymmMutationConfig(options?.mutation, {
|
|
24755
|
+
onSuccess: () => {
|
|
24756
|
+
invalidateOrders(queryClient);
|
|
24757
|
+
invalidatePositions(queryClient);
|
|
24758
|
+
}
|
|
24759
|
+
}),
|
|
24620
24760
|
mutationFn: async (request) => {
|
|
24621
24761
|
if (!symmCoreClient) throw new Error("symm-core client not available");
|
|
24622
24762
|
return symmCoreClient.orders.setTpsl(request);
|
|
24623
|
-
},
|
|
24624
|
-
onSuccess: () => {
|
|
24625
|
-
invalidateOrders(queryClient);
|
|
24626
|
-
invalidatePositions(queryClient);
|
|
24627
24763
|
}
|
|
24628
24764
|
});
|
|
24629
|
-
|
|
24765
|
+
}
|
|
24766
|
+
function useSymmCancelTpslMutation(options) {
|
|
24767
|
+
const { symmCoreClient } = useSymmContext();
|
|
24768
|
+
const queryClient = useQueryClient();
|
|
24769
|
+
return useMutation({
|
|
24770
|
+
...withSymmMutationConfig(options?.mutation, {
|
|
24771
|
+
onSuccess: () => {
|
|
24772
|
+
invalidateOrders(queryClient);
|
|
24773
|
+
invalidatePositions(queryClient);
|
|
24774
|
+
}
|
|
24775
|
+
}),
|
|
24630
24776
|
mutationFn: async (request) => {
|
|
24631
24777
|
if (!symmCoreClient) throw new Error("symm-core client not available");
|
|
24632
24778
|
return symmCoreClient.orders.cancelTpsl(request);
|
|
24633
|
-
},
|
|
24634
|
-
onSuccess: () => {
|
|
24635
|
-
invalidateOrders(queryClient);
|
|
24636
|
-
invalidatePositions(queryClient);
|
|
24637
24779
|
}
|
|
24638
24780
|
});
|
|
24639
|
-
return { setTpsl, cancelTpsl };
|
|
24640
24781
|
}
|
|
24641
24782
|
function useSymmTpslOrders(params) {
|
|
24642
24783
|
const { symmCoreClient, chainId: ctxChainId } = useSymmContext();
|
|
@@ -24651,7 +24792,7 @@ function useSymmTpslOrders(params) {
|
|
|
24651
24792
|
status,
|
|
24652
24793
|
chainId
|
|
24653
24794
|
};
|
|
24654
|
-
|
|
24795
|
+
return useQuery({
|
|
24655
24796
|
...params.query,
|
|
24656
24797
|
queryKey: symmKeys.tpslOrdersList({
|
|
24657
24798
|
accountAddress,
|
|
@@ -24664,84 +24805,94 @@ function useSymmTpslOrders(params) {
|
|
|
24664
24805
|
queryFn: () => symmCoreClient.orders.getTpslOrders(request),
|
|
24665
24806
|
enabled: internalEnabled && (params.query?.enabled ?? true)
|
|
24666
24807
|
});
|
|
24667
|
-
return {
|
|
24668
|
-
query
|
|
24669
|
-
};
|
|
24670
24808
|
}
|
|
24671
|
-
function
|
|
24809
|
+
function useResolvedTwapParams(params) {
|
|
24672
24810
|
const { symmCoreClient, chainId: ctxChainId } = useSymmContext();
|
|
24673
|
-
const queryClient = useQueryClient();
|
|
24674
24811
|
const { accountAddress, address } = params;
|
|
24675
24812
|
const resolvedAddress = accountAddress ? void 0 : address;
|
|
24676
24813
|
const chainId = params.chainId ?? ctxChainId;
|
|
24814
|
+
return { symmCoreClient, accountAddress, resolvedAddress, chainId, query: params.query };
|
|
24815
|
+
}
|
|
24816
|
+
function useSymmTwapOrdersQuery(params) {
|
|
24817
|
+
const { symmCoreClient, accountAddress, resolvedAddress, chainId, query } = useResolvedTwapParams(params);
|
|
24677
24818
|
const internalEnabled = !!symmCoreClient && !!(accountAddress || resolvedAddress);
|
|
24678
|
-
|
|
24679
|
-
...
|
|
24819
|
+
return useQuery({
|
|
24820
|
+
...query,
|
|
24680
24821
|
queryKey: symmKeys.twapOrders(accountAddress ?? resolvedAddress, chainId),
|
|
24681
24822
|
queryFn: () => symmCoreClient.orders.getTwapOrders({
|
|
24682
24823
|
address: accountAddress ?? resolvedAddress,
|
|
24683
24824
|
chainId
|
|
24684
24825
|
}),
|
|
24685
|
-
enabled: internalEnabled && (
|
|
24826
|
+
enabled: internalEnabled && (query?.enabled ?? true)
|
|
24686
24827
|
});
|
|
24687
|
-
|
|
24828
|
+
}
|
|
24829
|
+
function useSymmCancelTwapOrderMutation(options) {
|
|
24830
|
+
const { symmCoreClient } = useSymmContext();
|
|
24831
|
+
const queryClient = useQueryClient();
|
|
24832
|
+
return useMutation({
|
|
24833
|
+
...withSymmMutationConfig(options?.mutation, {
|
|
24834
|
+
onSuccess: () => {
|
|
24835
|
+
invalidateOrders(queryClient);
|
|
24836
|
+
}
|
|
24837
|
+
}),
|
|
24688
24838
|
mutationFn: async (orderId) => {
|
|
24689
24839
|
if (!symmCoreClient) throw new Error("symm-core client not available");
|
|
24690
24840
|
return symmCoreClient.orders.cancelTwapOrder(orderId);
|
|
24691
|
-
},
|
|
24692
|
-
onSuccess: () => {
|
|
24693
|
-
invalidateOrders(queryClient);
|
|
24694
24841
|
}
|
|
24695
24842
|
});
|
|
24696
|
-
return {
|
|
24697
|
-
query,
|
|
24698
|
-
cancelTwap
|
|
24699
|
-
};
|
|
24700
24843
|
}
|
|
24701
|
-
function
|
|
24844
|
+
function useSymmTriggerConfigQuery(params) {
|
|
24702
24845
|
const { symmCoreClient } = useSymmContext();
|
|
24703
|
-
const queryClient = useQueryClient();
|
|
24704
24846
|
const { orderId } = params;
|
|
24705
24847
|
const internalEnabled = !!symmCoreClient && !!orderId;
|
|
24706
|
-
|
|
24848
|
+
return useQuery({
|
|
24707
24849
|
...params.query,
|
|
24708
24850
|
queryKey: symmKeys.triggerConfig(orderId),
|
|
24709
24851
|
queryFn: () => symmCoreClient.orders.getTriggerConfig(orderId),
|
|
24710
24852
|
enabled: internalEnabled && (params.query?.enabled ?? true)
|
|
24711
24853
|
});
|
|
24712
|
-
|
|
24854
|
+
}
|
|
24855
|
+
function useSymmSetTriggerConfigMutation(params, options) {
|
|
24856
|
+
const { symmCoreClient } = useSymmContext();
|
|
24857
|
+
const { orderId } = params;
|
|
24858
|
+
const queryClient = useQueryClient();
|
|
24859
|
+
return useMutation({
|
|
24860
|
+
...withSymmMutationConfig(options?.mutation, {
|
|
24861
|
+
onSuccess: () => {
|
|
24862
|
+
queryClient.invalidateQueries({
|
|
24863
|
+
queryKey: symmKeys.triggerConfig(orderId)
|
|
24864
|
+
});
|
|
24865
|
+
invalidateOrders(queryClient);
|
|
24866
|
+
}
|
|
24867
|
+
}),
|
|
24713
24868
|
mutationFn: async (request) => {
|
|
24714
24869
|
if (!symmCoreClient || !orderId) {
|
|
24715
24870
|
throw new Error("symm-core client or orderId not available");
|
|
24716
24871
|
}
|
|
24717
24872
|
return symmCoreClient.orders.setTriggerConfig(orderId, request);
|
|
24718
|
-
},
|
|
24719
|
-
onSuccess: () => {
|
|
24720
|
-
queryClient.invalidateQueries({
|
|
24721
|
-
queryKey: symmKeys.triggerConfig(orderId)
|
|
24722
|
-
});
|
|
24723
|
-
invalidateOrders(queryClient);
|
|
24724
24873
|
}
|
|
24725
24874
|
});
|
|
24726
|
-
|
|
24875
|
+
}
|
|
24876
|
+
function useSymmClearTriggerConfigMutation(params, options) {
|
|
24877
|
+
const { symmCoreClient } = useSymmContext();
|
|
24878
|
+
const { orderId } = params;
|
|
24879
|
+
const queryClient = useQueryClient();
|
|
24880
|
+
return useMutation({
|
|
24881
|
+
...withSymmMutationConfig(options?.mutation, {
|
|
24882
|
+
onSuccess: () => {
|
|
24883
|
+
queryClient.invalidateQueries({
|
|
24884
|
+
queryKey: symmKeys.triggerConfig(orderId)
|
|
24885
|
+
});
|
|
24886
|
+
invalidateOrders(queryClient);
|
|
24887
|
+
}
|
|
24888
|
+
}),
|
|
24727
24889
|
mutationFn: async () => {
|
|
24728
24890
|
if (!symmCoreClient || !orderId) {
|
|
24729
24891
|
throw new Error("symm-core client or orderId not available");
|
|
24730
24892
|
}
|
|
24731
24893
|
return symmCoreClient.orders.clearTriggerConfig(orderId);
|
|
24732
|
-
},
|
|
24733
|
-
onSuccess: () => {
|
|
24734
|
-
queryClient.invalidateQueries({
|
|
24735
|
-
queryKey: symmKeys.triggerConfig(orderId)
|
|
24736
|
-
});
|
|
24737
|
-
invalidateOrders(queryClient);
|
|
24738
24894
|
}
|
|
24739
24895
|
});
|
|
24740
|
-
return {
|
|
24741
|
-
query,
|
|
24742
|
-
setTriggerConfig,
|
|
24743
|
-
clearTriggerConfig
|
|
24744
|
-
};
|
|
24745
24896
|
}
|
|
24746
24897
|
function useSymmTriggerOrders(params) {
|
|
24747
24898
|
const { symmCoreClient, chainId: ctxChainId } = useSymmContext();
|
|
@@ -24756,7 +24907,7 @@ function useSymmTriggerOrders(params) {
|
|
|
24756
24907
|
limit,
|
|
24757
24908
|
offset
|
|
24758
24909
|
};
|
|
24759
|
-
|
|
24910
|
+
return useQuery({
|
|
24760
24911
|
...params.query,
|
|
24761
24912
|
queryKey: symmKeys.triggerOrders({
|
|
24762
24913
|
accountAddress,
|
|
@@ -24769,16 +24920,13 @@ function useSymmTriggerOrders(params) {
|
|
|
24769
24920
|
queryFn: () => symmCoreClient.orders.listTriggerOrders(request),
|
|
24770
24921
|
enabled: internalEnabled && (params.query?.enabled ?? true)
|
|
24771
24922
|
});
|
|
24772
|
-
return {
|
|
24773
|
-
query
|
|
24774
|
-
};
|
|
24775
24923
|
}
|
|
24776
24924
|
function useSymmMarkets(params) {
|
|
24777
24925
|
const { symmCoreClient, chainId: ctxChainId } = useSymmContext();
|
|
24778
24926
|
const chainId = params?.chainId ?? ctxChainId;
|
|
24779
24927
|
const searchText = params?.searchText;
|
|
24780
24928
|
const internalEnabled = !!symmCoreClient;
|
|
24781
|
-
|
|
24929
|
+
return useQuery({
|
|
24782
24930
|
...params?.query,
|
|
24783
24931
|
queryKey: symmKeys.markets(chainId, searchText),
|
|
24784
24932
|
queryFn: () => {
|
|
@@ -24790,46 +24938,37 @@ function useSymmMarkets(params) {
|
|
|
24790
24938
|
},
|
|
24791
24939
|
enabled: internalEnabled && (params?.query?.enabled ?? true)
|
|
24792
24940
|
});
|
|
24793
|
-
return {
|
|
24794
|
-
query
|
|
24795
|
-
};
|
|
24796
24941
|
}
|
|
24797
24942
|
function useSymmHedgerMarketById(params) {
|
|
24798
24943
|
const { symmCoreClient, chainId: ctxChainId } = useSymmContext();
|
|
24799
24944
|
const { id } = params;
|
|
24800
24945
|
const chainId = params.chainId ?? ctxChainId;
|
|
24801
24946
|
const internalEnabled = !!symmCoreClient && id != null;
|
|
24802
|
-
|
|
24947
|
+
return useQuery({
|
|
24803
24948
|
...params.query,
|
|
24804
24949
|
queryKey: symmKeys.hedgerMarketById(id, chainId),
|
|
24805
24950
|
queryFn: () => symmCoreClient.markets.getById(id, chainId),
|
|
24806
24951
|
enabled: internalEnabled && (params.query?.enabled ?? true)
|
|
24807
24952
|
});
|
|
24808
|
-
return {
|
|
24809
|
-
query
|
|
24810
|
-
};
|
|
24811
24953
|
}
|
|
24812
24954
|
function useSymmHedgerMarketBySymbol(params) {
|
|
24813
24955
|
const { symmCoreClient, chainId: ctxChainId } = useSymmContext();
|
|
24814
24956
|
const { symbol } = params;
|
|
24815
24957
|
const chainId = params.chainId ?? ctxChainId;
|
|
24816
24958
|
const internalEnabled = !!symmCoreClient && !!symbol;
|
|
24817
|
-
|
|
24959
|
+
return useQuery({
|
|
24818
24960
|
...params.query,
|
|
24819
24961
|
queryKey: symmKeys.hedgerMarketBySymbol(symbol, chainId),
|
|
24820
24962
|
queryFn: () => symmCoreClient.markets.getBySymbol(symbol, chainId),
|
|
24821
24963
|
enabled: internalEnabled && (params.query?.enabled ?? true)
|
|
24822
24964
|
});
|
|
24823
|
-
return {
|
|
24824
|
-
query
|
|
24825
|
-
};
|
|
24826
24965
|
}
|
|
24827
24966
|
function useSymmLockedParams(params) {
|
|
24828
24967
|
const { symmCoreClient, chainId: ctxChainId } = useSymmContext();
|
|
24829
24968
|
const { marketName, leverage } = params;
|
|
24830
24969
|
const chainId = params.chainId ?? ctxChainId;
|
|
24831
24970
|
const internalEnabled = !!symmCoreClient && !!marketName && leverage != null;
|
|
24832
|
-
|
|
24971
|
+
return useQuery({
|
|
24833
24972
|
...params.query,
|
|
24834
24973
|
queryKey: symmKeys.lockedParams(marketName, leverage, chainId),
|
|
24835
24974
|
queryFn: () => symmCoreClient.markets.getLockedParams({
|
|
@@ -24839,9 +24978,6 @@ function useSymmLockedParams(params) {
|
|
|
24839
24978
|
}),
|
|
24840
24979
|
enabled: internalEnabled && (params.query?.enabled ?? true)
|
|
24841
24980
|
});
|
|
24842
|
-
return {
|
|
24843
|
-
query
|
|
24844
|
-
};
|
|
24845
24981
|
}
|
|
24846
24982
|
function useSymmHedgerMarkets(params) {
|
|
24847
24983
|
const { symmCoreClient, chainId: ctxChainId } = useSymmContext();
|
|
@@ -24855,29 +24991,23 @@ function useSymmHedgerMarkets(params) {
|
|
|
24855
24991
|
searchText: searchText || void 0
|
|
24856
24992
|
};
|
|
24857
24993
|
const internalEnabled = !!symmCoreClient;
|
|
24858
|
-
|
|
24994
|
+
return useQuery({
|
|
24859
24995
|
...params?.query,
|
|
24860
24996
|
queryKey: symmKeys.hedgerMarkets(request),
|
|
24861
24997
|
queryFn: () => symmCoreClient.markets.listSymmHedger(request),
|
|
24862
24998
|
enabled: internalEnabled && consumerEnabled
|
|
24863
24999
|
});
|
|
24864
|
-
return {
|
|
24865
|
-
query
|
|
24866
|
-
};
|
|
24867
25000
|
}
|
|
24868
25001
|
function useSymmFunding(params) {
|
|
24869
25002
|
const { symmCoreClient, chainId: ctxChainId } = useSymmContext();
|
|
24870
25003
|
const chainId = params?.chainId ?? ctxChainId;
|
|
24871
25004
|
const internalEnabled = !!symmCoreClient;
|
|
24872
|
-
|
|
25005
|
+
return useQuery({
|
|
24873
25006
|
...params?.query,
|
|
24874
25007
|
queryKey: symmKeys.fundingRates(chainId),
|
|
24875
25008
|
queryFn: () => symmCoreClient.funding.getRates({ chainId }),
|
|
24876
25009
|
enabled: internalEnabled && (params?.query?.enabled ?? true)
|
|
24877
25010
|
});
|
|
24878
|
-
return {
|
|
24879
|
-
query
|
|
24880
|
-
};
|
|
24881
25011
|
}
|
|
24882
25012
|
function useSymmFundingHistory(params) {
|
|
24883
25013
|
const { symmCoreClient, chainId: ctxChainId } = useSymmContext();
|
|
@@ -24900,15 +25030,12 @@ function useSymmFundingHistory(params) {
|
|
|
24900
25030
|
weightMode,
|
|
24901
25031
|
includeContributions
|
|
24902
25032
|
};
|
|
24903
|
-
|
|
25033
|
+
return useQuery({
|
|
24904
25034
|
...params.query,
|
|
24905
25035
|
queryKey: symmKeys.fundingHistory(request),
|
|
24906
25036
|
queryFn: () => symmCoreClient.funding.getHistory(request),
|
|
24907
25037
|
enabled: internalEnabled && (params.query?.enabled ?? true)
|
|
24908
25038
|
});
|
|
24909
|
-
return {
|
|
24910
|
-
query
|
|
24911
|
-
};
|
|
24912
25039
|
}
|
|
24913
25040
|
function useSymmFundingPayments(params) {
|
|
24914
25041
|
const { symmCoreClient, chainId: ctxChainId } = useSymmContext();
|
|
@@ -24922,7 +25049,7 @@ function useSymmFundingPayments(params) {
|
|
|
24922
25049
|
limit,
|
|
24923
25050
|
offset
|
|
24924
25051
|
};
|
|
24925
|
-
|
|
25052
|
+
return useQuery({
|
|
24926
25053
|
...params.query,
|
|
24927
25054
|
queryKey: symmKeys.fundingPayments({
|
|
24928
25055
|
address,
|
|
@@ -24934,9 +25061,6 @@ function useSymmFundingPayments(params) {
|
|
|
24934
25061
|
queryFn: () => symmCoreClient.funding.getPayments(request),
|
|
24935
25062
|
enabled: internalEnabled && (params.query?.enabled ?? true)
|
|
24936
25063
|
});
|
|
24937
|
-
return {
|
|
24938
|
-
query
|
|
24939
|
-
};
|
|
24940
25064
|
}
|
|
24941
25065
|
function useSymmPortfolio(params) {
|
|
24942
25066
|
const { symmCoreClient, chainId: ctxChainId } = useSymmContext();
|
|
@@ -24944,7 +25068,7 @@ function useSymmPortfolio(params) {
|
|
|
24944
25068
|
const resolvedAddress = accountAddress ? void 0 : address;
|
|
24945
25069
|
const chainId = params.chainId ?? ctxChainId;
|
|
24946
25070
|
const internalEnabled = !!symmCoreClient && !!(accountAddress || resolvedAddress);
|
|
24947
|
-
|
|
25071
|
+
return useQuery({
|
|
24948
25072
|
...params.query,
|
|
24949
25073
|
queryKey: symmKeys.portfolio({
|
|
24950
25074
|
accountAddress,
|
|
@@ -24961,66 +25085,76 @@ function useSymmPortfolio(params) {
|
|
|
24961
25085
|
},
|
|
24962
25086
|
enabled: internalEnabled && (params.query?.enabled ?? true)
|
|
24963
25087
|
});
|
|
24964
|
-
return {
|
|
24965
|
-
query
|
|
24966
|
-
};
|
|
24967
25088
|
}
|
|
24968
|
-
function
|
|
25089
|
+
function useResolvedNotificationsParams(params) {
|
|
24969
25090
|
const { symmCoreClient, chainId: ctxChainId } = useSymmContext();
|
|
24970
|
-
const queryClient = useQueryClient();
|
|
24971
|
-
const { userAddress } = params;
|
|
24972
25091
|
const chainId = params.chainId ?? ctxChainId;
|
|
25092
|
+
return {
|
|
25093
|
+
symmCoreClient,
|
|
25094
|
+
chainId,
|
|
25095
|
+
userAddress: params.userAddress,
|
|
25096
|
+
query: params.query
|
|
25097
|
+
};
|
|
25098
|
+
}
|
|
25099
|
+
function useSymmNotificationsQuery(params) {
|
|
25100
|
+
const { symmCoreClient, chainId, userAddress, query } = useResolvedNotificationsParams(params);
|
|
24973
25101
|
const internalEnabled = !!symmCoreClient && !!userAddress;
|
|
24974
|
-
|
|
24975
|
-
...
|
|
25102
|
+
return useQuery({
|
|
25103
|
+
...query,
|
|
24976
25104
|
queryKey: symmKeys.notifications(userAddress, chainId),
|
|
24977
25105
|
queryFn: () => symmCoreClient.notifications.list({
|
|
24978
25106
|
userAddress,
|
|
24979
25107
|
chainId
|
|
24980
25108
|
}),
|
|
24981
|
-
enabled: internalEnabled && (
|
|
25109
|
+
enabled: internalEnabled && (query?.enabled ?? true)
|
|
24982
25110
|
});
|
|
24983
|
-
|
|
24984
|
-
|
|
25111
|
+
}
|
|
25112
|
+
function useSymmUnreadCountQuery(params) {
|
|
25113
|
+
const { symmCoreClient, chainId, userAddress, query } = useResolvedNotificationsParams(params);
|
|
25114
|
+
const internalEnabled = !!symmCoreClient && !!userAddress;
|
|
25115
|
+
return useQuery({
|
|
25116
|
+
...query,
|
|
24985
25117
|
queryKey: symmKeys.unreadCount(userAddress, chainId),
|
|
24986
25118
|
queryFn: () => symmCoreClient.notifications.getUnreadCount({
|
|
24987
25119
|
userAddress,
|
|
24988
25120
|
chainId
|
|
24989
25121
|
}),
|
|
24990
|
-
enabled: internalEnabled && (
|
|
25122
|
+
enabled: internalEnabled && (query?.enabled ?? true)
|
|
24991
25123
|
});
|
|
24992
|
-
|
|
25124
|
+
}
|
|
25125
|
+
function useSymmMarkReadNotificationMutation(params, options) {
|
|
25126
|
+
const { symmCoreClient, chainId, userAddress } = useResolvedNotificationsParams(params);
|
|
25127
|
+
const queryClient = useQueryClient();
|
|
25128
|
+
return useMutation({
|
|
25129
|
+
...withSymmMutationConfig(options?.mutation, {
|
|
25130
|
+
onSuccess: () => {
|
|
25131
|
+
queryClient.invalidateQueries({
|
|
25132
|
+
queryKey: symmKeys.notifications(userAddress, chainId)
|
|
25133
|
+
});
|
|
25134
|
+
queryClient.invalidateQueries({
|
|
25135
|
+
queryKey: symmKeys.unreadCount(userAddress, chainId)
|
|
25136
|
+
});
|
|
25137
|
+
}
|
|
25138
|
+
}),
|
|
24993
25139
|
mutationFn: async ({ id, timestamp }) => {
|
|
24994
|
-
if (!symmCoreClient || !userAddress)
|
|
25140
|
+
if (!symmCoreClient || !userAddress) {
|
|
24995
25141
|
throw new Error("symm-core client not available");
|
|
25142
|
+
}
|
|
24996
25143
|
return symmCoreClient.notifications.markRead({
|
|
24997
25144
|
id,
|
|
24998
25145
|
timestamp,
|
|
24999
25146
|
userAddress,
|
|
25000
25147
|
chainId
|
|
25001
25148
|
});
|
|
25002
|
-
},
|
|
25003
|
-
onSuccess: () => {
|
|
25004
|
-
queryClient.invalidateQueries({
|
|
25005
|
-
queryKey: symmKeys.notifications(userAddress, chainId)
|
|
25006
|
-
});
|
|
25007
|
-
queryClient.invalidateQueries({
|
|
25008
|
-
queryKey: symmKeys.unreadCount(userAddress, chainId)
|
|
25009
|
-
});
|
|
25010
25149
|
}
|
|
25011
25150
|
});
|
|
25012
|
-
return {
|
|
25013
|
-
query: notificationsQuery,
|
|
25014
|
-
unreadQuery,
|
|
25015
|
-
markRead
|
|
25016
|
-
};
|
|
25017
25151
|
}
|
|
25018
25152
|
function useSymmPendingIds(params) {
|
|
25019
25153
|
const { symmCoreClient, chainId: ctxChainId } = useSymmContext();
|
|
25020
25154
|
const { accountAddress } = params;
|
|
25021
25155
|
const chainId = params.chainId ?? ctxChainId;
|
|
25022
25156
|
const internalEnabled = !!symmCoreClient && !!accountAddress;
|
|
25023
|
-
|
|
25157
|
+
return useQuery({
|
|
25024
25158
|
...params.query,
|
|
25025
25159
|
queryKey: symmKeys.pendingIds(accountAddress, chainId),
|
|
25026
25160
|
queryFn: () => symmCoreClient.positions.getPendingIds({
|
|
@@ -25029,9 +25163,6 @@ function useSymmPendingIds(params) {
|
|
|
25029
25163
|
}),
|
|
25030
25164
|
enabled: internalEnabled && (params.query?.enabled ?? true)
|
|
25031
25165
|
});
|
|
25032
|
-
return {
|
|
25033
|
-
query
|
|
25034
|
-
};
|
|
25035
25166
|
}
|
|
25036
25167
|
function useSymmPendingInstantOpens(params) {
|
|
25037
25168
|
const {
|
|
@@ -25041,7 +25172,7 @@ function useSymmPendingInstantOpens(params) {
|
|
|
25041
25172
|
const { accountAddress, authToken: providedAuthToken } = params;
|
|
25042
25173
|
const chainId = params.chainId ?? ctxChainId;
|
|
25043
25174
|
const internalEnabled = !!symmCoreClient && !!accountAddress;
|
|
25044
|
-
|
|
25175
|
+
return useQuery({
|
|
25045
25176
|
...params.query,
|
|
25046
25177
|
queryKey: symmKeys.pendingInstantOpens(accountAddress, chainId),
|
|
25047
25178
|
queryFn: async () => {
|
|
@@ -25057,23 +25188,17 @@ function useSymmPendingInstantOpens(params) {
|
|
|
25057
25188
|
},
|
|
25058
25189
|
enabled: internalEnabled && (params.query?.enabled ?? true)
|
|
25059
25190
|
});
|
|
25060
|
-
return {
|
|
25061
|
-
query
|
|
25062
|
-
};
|
|
25063
25191
|
}
|
|
25064
25192
|
function useSymmTwapOrder(params) {
|
|
25065
25193
|
const { symmCoreClient } = useSymmContext();
|
|
25066
25194
|
const { orderId } = params;
|
|
25067
25195
|
const internalEnabled = !!symmCoreClient && !!orderId;
|
|
25068
|
-
|
|
25196
|
+
return useQuery({
|
|
25069
25197
|
...params.query,
|
|
25070
25198
|
queryKey: symmKeys.twapOrder(orderId),
|
|
25071
25199
|
queryFn: () => symmCoreClient.orders.getTwapOrder(orderId),
|
|
25072
25200
|
enabled: internalEnabled && (params.query?.enabled ?? true)
|
|
25073
25201
|
});
|
|
25074
|
-
return {
|
|
25075
|
-
query
|
|
25076
|
-
};
|
|
25077
25202
|
}
|
|
25078
25203
|
var useSymmWsStore = create((set) => ({
|
|
25079
25204
|
isConnected: false,
|
|
@@ -26272,6 +26397,6 @@ function getSymmErrorMessage(error) {
|
|
|
26272
26397
|
return "An unexpected error occurred.";
|
|
26273
26398
|
}
|
|
26274
26399
|
|
|
26275
|
-
export { SymmProvider, getSymmErrorMessage, symmKeys, useBinanceMarkPriceStore, useSymmAccountData, useSymmAccountSummary,
|
|
26400
|
+
export { SymmProvider, getSymmErrorMessage, symmKeys, useBinanceMarkPriceStore, useSymmAccountData, useSymmAccountSummary, useSymmAccountsApi, useSymmAccountsLength, useSymmAccountsQuery, useSymmAccountsWithPositions, useSymmAllocateCollateralMutation, useSymmApprovalQuery, useSymmApproveMutation, useSymmAuth, useSymmAuthStore, useSymmAvailableMargin, useSymmBalances, useSymmCancelClose, useSymmCancelOpenMutation, useSymmCancelTpslMutation, useSymmCancelTwapOrderMutation, useSymmChartCandles, useSymmChartSelection, useSymmClearTriggerConfigMutation, useSymmCloseAllPositionsMutation, useSymmCloseOrder, useSymmClosePositionMutation, useSymmContext, useSymmCoreClient, useSymmCreateAccountMutation, useSymmDeallocateCollateralMutation, useSymmDelegation, useSymmDepositAndAllocateMutation, useSymmDepositMutation, useSymmEditAccountNameMutation, useSymmFunding, useSymmFundingHistory, useSymmFundingPayments, useSymmHedgerMarketById, useSymmHedgerMarketBySymbol, useSymmHedgerMarkets, useSymmInstantTradeEnsureReadyMutation, useSymmInstantTradeExecuteMutation, useSymmInternalTransferCollateralMutation, useSymmLockedParams, useSymmMarkReadNotificationMutation, useSymmMarkets, useSymmNotificationsQuery, useSymmOpenBasketMutation, useSymmOpenOrders, useSymmPendingIds, useSymmPendingInstantOpens, useSymmPerformanceOverlays, useSymmPortfolio, useSymmPositions, useSymmSetTpslMutation, useSymmSetTriggerConfigMutation, useSymmSignTermsMutation, useSymmSignatureQuery, useSymmTokenSelectionMetadata, useSymmTpslOrders, useSymmTradeHistory, useSymmTriggerConfigQuery, useSymmTriggerOrders, useSymmTwapOrder, useSymmTwapOrdersQuery, useSymmUnreadCountQuery, useSymmUpdatePositionMutation, useSymmWithdraw, useSymmWs, useSymmWsStore };
|
|
26276
26401
|
//# sourceMappingURL=index.mjs.map
|
|
26277
26402
|
//# sourceMappingURL=index.mjs.map
|