@pear-protocol/symmio-client 0.3.20 → 0.3.22
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 +71 -28
- package/dist/react/index.d.ts +71 -28
- package/dist/react/index.js +109 -27
- package/dist/react/index.js.map +1 -1
- package/dist/react/index.mjs +109 -27
- package/dist/react/index.mjs.map +1 -1
- package/dist/react/provider.js +1 -1
- package/dist/react/provider.js.map +1 -1
- package/dist/react/provider.mjs +1 -1
- package/dist/react/provider.mjs.map +1 -1
- package/package.json +2 -2
package/dist/react/index.js
CHANGED
|
@@ -629,7 +629,7 @@ var symmKeys = {
|
|
|
629
629
|
tradeHistory: (params) => ["symm", "tradeHistory", params],
|
|
630
630
|
tpslOrders: (address, chainId) => ["symm", "tpslOrders", address, chainId],
|
|
631
631
|
tpslOrdersList: (params) => ["symm", "tpslOrders", params],
|
|
632
|
-
twapOrders: (
|
|
632
|
+
twapOrders: (params) => ["symm", "twapOrders", params],
|
|
633
633
|
triggerOrders: (params) => ["symm", "triggerOrders", params],
|
|
634
634
|
triggerConfig: (orderId) => ["symm", "triggerConfig", orderId],
|
|
635
635
|
markets: (chainId, search, pageSize) => ["symm", "markets", chainId, search, pageSize],
|
|
@@ -1195,7 +1195,7 @@ function useSymmAuth(params) {
|
|
|
1195
1195
|
const authEntry = useSymmAuthStore(
|
|
1196
1196
|
(state) => selectAuthStoreEntry(state, activeAccountAddress, chainId, address)
|
|
1197
1197
|
);
|
|
1198
|
-
useSymmAuthStore(
|
|
1198
|
+
const isLoading = useSymmAuthStore(
|
|
1199
1199
|
(state) => selectAuthStoreStatus(state, activeAccountAddress, chainId, address).isLoading
|
|
1200
1200
|
);
|
|
1201
1201
|
const error = useSymmAuthStore(
|
|
@@ -1230,7 +1230,8 @@ function useSymmAuth(params) {
|
|
|
1230
1230
|
} catch (error2) {
|
|
1231
1231
|
clearAuthState(resolvedAccountAddress, chainId, address);
|
|
1232
1232
|
setAuthStoreStatus(resolvedAccountAddress, chainId, address, {
|
|
1233
|
-
error: error2 instanceof Error ? error2 : new Error("failed to sign in")
|
|
1233
|
+
error: error2 instanceof Error ? error2 : new Error("failed to sign in"),
|
|
1234
|
+
isLoading: false
|
|
1234
1235
|
});
|
|
1235
1236
|
return null;
|
|
1236
1237
|
}
|
|
@@ -1253,6 +1254,7 @@ function useSymmAuth(params) {
|
|
|
1253
1254
|
return {
|
|
1254
1255
|
accessToken: token,
|
|
1255
1256
|
isAuthenticated: !!token,
|
|
1257
|
+
isLoading,
|
|
1256
1258
|
error,
|
|
1257
1259
|
signIn,
|
|
1258
1260
|
clear: clearAuth
|
|
@@ -2555,10 +2557,9 @@ function useSymmCloseOrder(options) {
|
|
|
2555
2557
|
if (!symmCoreClient) {
|
|
2556
2558
|
throw new Error("symm-core client not available");
|
|
2557
2559
|
}
|
|
2558
|
-
const typedRequest = request;
|
|
2559
2560
|
const authToken = await resolveAuthToken(
|
|
2560
|
-
|
|
2561
|
-
|
|
2561
|
+
request.authToken,
|
|
2562
|
+
request.accountAddress
|
|
2562
2563
|
);
|
|
2563
2564
|
if (!authToken) {
|
|
2564
2565
|
throw new Error("auth token is required to close an order");
|
|
@@ -26467,23 +26468,64 @@ function useSymmUpdatePositionMutation(paramsOrOptions, maybeOptions) {
|
|
|
26467
26468
|
}
|
|
26468
26469
|
});
|
|
26469
26470
|
}
|
|
26471
|
+
|
|
26472
|
+
// src/react/hooks/order-status.ts
|
|
26473
|
+
var ACTIVE_ORDER_STATUS = "active";
|
|
26474
|
+
function normalizeOrderStatus(status) {
|
|
26475
|
+
return status.toLowerCase();
|
|
26476
|
+
}
|
|
26477
|
+
function isMatchingOrderStatus(orderStatus, requestedStatus) {
|
|
26478
|
+
if (!orderStatus) {
|
|
26479
|
+
return false;
|
|
26480
|
+
}
|
|
26481
|
+
const normalizedOrderStatus = normalizeOrderStatus(orderStatus);
|
|
26482
|
+
const normalizedRequestedStatus = normalizeOrderStatus(requestedStatus);
|
|
26483
|
+
return normalizedOrderStatus === normalizedRequestedStatus;
|
|
26484
|
+
}
|
|
26485
|
+
function filterOrdersByStatus(response, status) {
|
|
26486
|
+
const orders = response.data?.orders;
|
|
26487
|
+
if (!orders) {
|
|
26488
|
+
return response;
|
|
26489
|
+
}
|
|
26490
|
+
const filteredOrders = orders.filter((order) => isMatchingOrderStatus(order.status, status));
|
|
26491
|
+
return {
|
|
26492
|
+
...response,
|
|
26493
|
+
data: {
|
|
26494
|
+
...response.data,
|
|
26495
|
+
orders: filteredOrders
|
|
26496
|
+
}
|
|
26497
|
+
};
|
|
26498
|
+
}
|
|
26499
|
+
|
|
26500
|
+
// src/react/hooks/use-symm-open-orders.ts
|
|
26470
26501
|
function useSymmOpenOrders(params) {
|
|
26471
26502
|
const { symmCoreClient, chainId: ctxChainId } = useSymmContext();
|
|
26472
|
-
const { accountAddress, address } = params;
|
|
26503
|
+
const { accountAddress, address, kind, limit, offset } = params;
|
|
26504
|
+
const status = ACTIVE_ORDER_STATUS;
|
|
26473
26505
|
const resolvedAddress = accountAddress ? void 0 : address;
|
|
26474
26506
|
const chainId = params.chainId ?? ctxChainId;
|
|
26475
26507
|
const internalEnabled = !!symmCoreClient && !!(accountAddress || resolvedAddress);
|
|
26508
|
+
const request = {
|
|
26509
|
+
accountAddress,
|
|
26510
|
+
address: resolvedAddress,
|
|
26511
|
+
chainId,
|
|
26512
|
+
status,
|
|
26513
|
+
kind,
|
|
26514
|
+
limit,
|
|
26515
|
+
offset
|
|
26516
|
+
};
|
|
26476
26517
|
return reactQuery.useQuery({
|
|
26477
26518
|
...params.query,
|
|
26478
26519
|
queryKey: symmKeys.openOrders({
|
|
26479
26520
|
accountAddress,
|
|
26480
26521
|
address: resolvedAddress,
|
|
26481
|
-
chainId
|
|
26482
|
-
|
|
26483
|
-
|
|
26484
|
-
|
|
26485
|
-
|
|
26522
|
+
chainId,
|
|
26523
|
+
status,
|
|
26524
|
+
kind,
|
|
26525
|
+
limit,
|
|
26526
|
+
offset
|
|
26486
26527
|
}),
|
|
26528
|
+
queryFn: async () => filterOrdersByStatus(await symmCoreClient.orders.list(request), status),
|
|
26487
26529
|
enabled: internalEnabled && (params.query?.enabled ?? true)
|
|
26488
26530
|
});
|
|
26489
26531
|
}
|
|
@@ -26545,12 +26587,14 @@ function useSymmCancelTpslMutation(options) {
|
|
|
26545
26587
|
}
|
|
26546
26588
|
function useSymmTpslOrders(params) {
|
|
26547
26589
|
const { symmCoreClient, chainId: ctxChainId } = useSymmContext();
|
|
26548
|
-
const { accountAddress, address, positionId, type
|
|
26590
|
+
const { accountAddress, address, positionId, type } = params;
|
|
26591
|
+
const status = params.status ?? ACTIVE_ORDER_STATUS;
|
|
26549
26592
|
const resolvedAddress = accountAddress ? void 0 : address;
|
|
26550
26593
|
const chainId = params.chainId ?? ctxChainId;
|
|
26551
|
-
const internalEnabled = !!symmCoreClient && !!(accountAddress || resolvedAddress
|
|
26594
|
+
const internalEnabled = !!symmCoreClient && !!(accountAddress || resolvedAddress);
|
|
26552
26595
|
const request = {
|
|
26553
|
-
|
|
26596
|
+
accountAddress,
|
|
26597
|
+
address: resolvedAddress,
|
|
26554
26598
|
positionId,
|
|
26555
26599
|
type,
|
|
26556
26600
|
status,
|
|
@@ -26566,27 +26610,58 @@ function useSymmTpslOrders(params) {
|
|
|
26566
26610
|
status,
|
|
26567
26611
|
chainId
|
|
26568
26612
|
}),
|
|
26569
|
-
queryFn: () => symmCoreClient.orders.getTpslOrders(request),
|
|
26613
|
+
queryFn: async () => filterOrdersByStatus(await symmCoreClient.orders.getTpslOrders(request), status),
|
|
26570
26614
|
enabled: internalEnabled && (params.query?.enabled ?? true)
|
|
26571
26615
|
});
|
|
26572
26616
|
}
|
|
26573
26617
|
function useResolvedTwapParams(params) {
|
|
26574
26618
|
const { symmCoreClient, chainId: ctxChainId } = useSymmContext();
|
|
26575
|
-
const { accountAddress, address } = params;
|
|
26619
|
+
const { accountAddress, address, limit, offset } = params;
|
|
26620
|
+
const status = params.status ?? ACTIVE_ORDER_STATUS;
|
|
26576
26621
|
const resolvedAddress = accountAddress ? void 0 : address;
|
|
26577
26622
|
const chainId = params.chainId ?? ctxChainId;
|
|
26578
|
-
return {
|
|
26623
|
+
return {
|
|
26624
|
+
symmCoreClient,
|
|
26625
|
+
accountAddress,
|
|
26626
|
+
resolvedAddress,
|
|
26627
|
+
chainId,
|
|
26628
|
+
status,
|
|
26629
|
+
limit,
|
|
26630
|
+
offset,
|
|
26631
|
+
query: params.query
|
|
26632
|
+
};
|
|
26579
26633
|
}
|
|
26580
26634
|
function useSymmTwapOrdersQuery(params) {
|
|
26581
|
-
const {
|
|
26635
|
+
const {
|
|
26636
|
+
symmCoreClient,
|
|
26637
|
+
accountAddress,
|
|
26638
|
+
resolvedAddress,
|
|
26639
|
+
chainId,
|
|
26640
|
+
status,
|
|
26641
|
+
limit,
|
|
26642
|
+
offset,
|
|
26643
|
+
query
|
|
26644
|
+
} = useResolvedTwapParams(params);
|
|
26582
26645
|
const internalEnabled = !!symmCoreClient && !!(accountAddress || resolvedAddress);
|
|
26646
|
+
const request = {
|
|
26647
|
+
accountAddress,
|
|
26648
|
+
address: resolvedAddress,
|
|
26649
|
+
chainId,
|
|
26650
|
+
status,
|
|
26651
|
+
limit,
|
|
26652
|
+
offset
|
|
26653
|
+
};
|
|
26583
26654
|
return reactQuery.useQuery({
|
|
26584
26655
|
...query,
|
|
26585
|
-
queryKey: symmKeys.twapOrders(
|
|
26586
|
-
|
|
26587
|
-
address:
|
|
26588
|
-
chainId
|
|
26656
|
+
queryKey: symmKeys.twapOrders({
|
|
26657
|
+
accountAddress,
|
|
26658
|
+
address: resolvedAddress,
|
|
26659
|
+
chainId,
|
|
26660
|
+
status,
|
|
26661
|
+
limit,
|
|
26662
|
+
offset
|
|
26589
26663
|
}),
|
|
26664
|
+
queryFn: async () => filterOrdersByStatus(await symmCoreClient.orders.getTwapOrders(request), status),
|
|
26590
26665
|
enabled: internalEnabled && (query?.enabled ?? true)
|
|
26591
26666
|
});
|
|
26592
26667
|
}
|
|
@@ -26660,12 +26735,14 @@ function useSymmClearTriggerConfigMutation(params, options) {
|
|
|
26660
26735
|
}
|
|
26661
26736
|
function useSymmTriggerOrders(params) {
|
|
26662
26737
|
const { symmCoreClient, chainId: ctxChainId } = useSymmContext();
|
|
26663
|
-
const { accountAddress, address,
|
|
26738
|
+
const { accountAddress, address, limit, offset } = params;
|
|
26739
|
+
const status = params.status ?? ACTIVE_ORDER_STATUS;
|
|
26664
26740
|
const resolvedAddress = accountAddress ? void 0 : address;
|
|
26665
26741
|
const chainId = params.chainId ?? ctxChainId;
|
|
26666
26742
|
const internalEnabled = !!symmCoreClient && !!(accountAddress || resolvedAddress);
|
|
26667
26743
|
const request = {
|
|
26668
|
-
|
|
26744
|
+
accountAddress,
|
|
26745
|
+
address: resolvedAddress,
|
|
26669
26746
|
chainId,
|
|
26670
26747
|
status,
|
|
26671
26748
|
limit,
|
|
@@ -26681,7 +26758,7 @@ function useSymmTriggerOrders(params) {
|
|
|
26681
26758
|
limit,
|
|
26682
26759
|
offset
|
|
26683
26760
|
}),
|
|
26684
|
-
queryFn: () => symmCoreClient.orders.listTriggerOrders(request),
|
|
26761
|
+
queryFn: async () => filterOrdersByStatus(await symmCoreClient.orders.listTriggerOrders(request), status),
|
|
26685
26762
|
enabled: internalEnabled && (params.query?.enabled ?? true)
|
|
26686
26763
|
});
|
|
26687
26764
|
}
|
|
@@ -26862,6 +26939,11 @@ async function fetch24hrTickers() {
|
|
|
26862
26939
|
|
|
26863
26940
|
// src/react/hooks/use-symm-token-selection-markets.ts
|
|
26864
26941
|
var EMPTY_MARKETS = [];
|
|
26942
|
+
function toSortedSymbolsKey(symbols) {
|
|
26943
|
+
const sortedSymbols = Array.from(symbols);
|
|
26944
|
+
sortedSymbols.sort();
|
|
26945
|
+
return sortedSymbols.join(",");
|
|
26946
|
+
}
|
|
26865
26947
|
function useSymmTokenSelectionMarkets(params) {
|
|
26866
26948
|
const query = useSymmHedgerMarkets(params);
|
|
26867
26949
|
const baseMarkets = query.data?.filteredMarkets ?? query.data?.markets ?? EMPTY_MARKETS;
|
|
@@ -26874,7 +26956,7 @@ function useSymmTokenSelectionMarkets(params) {
|
|
|
26874
26956
|
[baseMarkets]
|
|
26875
26957
|
);
|
|
26876
26958
|
const symbolsKey = react.useMemo(
|
|
26877
|
-
() =>
|
|
26959
|
+
() => toSortedSymbolsKey(marketSymbols),
|
|
26878
26960
|
[marketSymbols]
|
|
26879
26961
|
);
|
|
26880
26962
|
const liveMarkPrices = useBinanceMarkPriceStore((state) => state.markPrices);
|