@pear-protocol/symmio-client 0.3.20 → 0.3.21
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 +54 -22
- package/dist/react/index.d.ts +54 -22
- package/dist/react/index.js +105 -25
- package/dist/react/index.js.map +1 -1
- package/dist/react/index.mjs +105 -25
- 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.mjs
CHANGED
|
@@ -627,7 +627,7 @@ var symmKeys = {
|
|
|
627
627
|
tradeHistory: (params) => ["symm", "tradeHistory", params],
|
|
628
628
|
tpslOrders: (address, chainId) => ["symm", "tpslOrders", address, chainId],
|
|
629
629
|
tpslOrdersList: (params) => ["symm", "tpslOrders", params],
|
|
630
|
-
twapOrders: (
|
|
630
|
+
twapOrders: (params) => ["symm", "twapOrders", params],
|
|
631
631
|
triggerOrders: (params) => ["symm", "triggerOrders", params],
|
|
632
632
|
triggerConfig: (orderId) => ["symm", "triggerConfig", orderId],
|
|
633
633
|
markets: (chainId, search, pageSize) => ["symm", "markets", chainId, search, pageSize],
|
|
@@ -2553,10 +2553,9 @@ function useSymmCloseOrder(options) {
|
|
|
2553
2553
|
if (!symmCoreClient) {
|
|
2554
2554
|
throw new Error("symm-core client not available");
|
|
2555
2555
|
}
|
|
2556
|
-
const typedRequest = request;
|
|
2557
2556
|
const authToken = await resolveAuthToken(
|
|
2558
|
-
|
|
2559
|
-
|
|
2557
|
+
request.authToken,
|
|
2558
|
+
request.accountAddress
|
|
2560
2559
|
);
|
|
2561
2560
|
if (!authToken) {
|
|
2562
2561
|
throw new Error("auth token is required to close an order");
|
|
@@ -26465,23 +26464,64 @@ function useSymmUpdatePositionMutation(paramsOrOptions, maybeOptions) {
|
|
|
26465
26464
|
}
|
|
26466
26465
|
});
|
|
26467
26466
|
}
|
|
26467
|
+
|
|
26468
|
+
// src/react/hooks/order-status.ts
|
|
26469
|
+
var ACTIVE_ORDER_STATUS = "active";
|
|
26470
|
+
function normalizeOrderStatus(status) {
|
|
26471
|
+
return status.toLowerCase();
|
|
26472
|
+
}
|
|
26473
|
+
function isMatchingOrderStatus(orderStatus, requestedStatus) {
|
|
26474
|
+
if (!orderStatus) {
|
|
26475
|
+
return false;
|
|
26476
|
+
}
|
|
26477
|
+
const normalizedOrderStatus = normalizeOrderStatus(orderStatus);
|
|
26478
|
+
const normalizedRequestedStatus = normalizeOrderStatus(requestedStatus);
|
|
26479
|
+
return normalizedOrderStatus === normalizedRequestedStatus;
|
|
26480
|
+
}
|
|
26481
|
+
function filterOrdersByStatus(response, status) {
|
|
26482
|
+
const orders = response.data?.orders;
|
|
26483
|
+
if (!orders) {
|
|
26484
|
+
return response;
|
|
26485
|
+
}
|
|
26486
|
+
const filteredOrders = orders.filter((order) => isMatchingOrderStatus(order.status, status));
|
|
26487
|
+
return {
|
|
26488
|
+
...response,
|
|
26489
|
+
data: {
|
|
26490
|
+
...response.data,
|
|
26491
|
+
orders: filteredOrders
|
|
26492
|
+
}
|
|
26493
|
+
};
|
|
26494
|
+
}
|
|
26495
|
+
|
|
26496
|
+
// src/react/hooks/use-symm-open-orders.ts
|
|
26468
26497
|
function useSymmOpenOrders(params) {
|
|
26469
26498
|
const { symmCoreClient, chainId: ctxChainId } = useSymmContext();
|
|
26470
|
-
const { accountAddress, address } = params;
|
|
26499
|
+
const { accountAddress, address, kind, limit, offset } = params;
|
|
26500
|
+
const status = ACTIVE_ORDER_STATUS;
|
|
26471
26501
|
const resolvedAddress = accountAddress ? void 0 : address;
|
|
26472
26502
|
const chainId = params.chainId ?? ctxChainId;
|
|
26473
26503
|
const internalEnabled = !!symmCoreClient && !!(accountAddress || resolvedAddress);
|
|
26504
|
+
const request = {
|
|
26505
|
+
accountAddress,
|
|
26506
|
+
address: resolvedAddress,
|
|
26507
|
+
chainId,
|
|
26508
|
+
status,
|
|
26509
|
+
kind,
|
|
26510
|
+
limit,
|
|
26511
|
+
offset
|
|
26512
|
+
};
|
|
26474
26513
|
return useQuery({
|
|
26475
26514
|
...params.query,
|
|
26476
26515
|
queryKey: symmKeys.openOrders({
|
|
26477
26516
|
accountAddress,
|
|
26478
26517
|
address: resolvedAddress,
|
|
26479
|
-
chainId
|
|
26480
|
-
|
|
26481
|
-
|
|
26482
|
-
|
|
26483
|
-
|
|
26518
|
+
chainId,
|
|
26519
|
+
status,
|
|
26520
|
+
kind,
|
|
26521
|
+
limit,
|
|
26522
|
+
offset
|
|
26484
26523
|
}),
|
|
26524
|
+
queryFn: async () => filterOrdersByStatus(await symmCoreClient.orders.list(request), status),
|
|
26485
26525
|
enabled: internalEnabled && (params.query?.enabled ?? true)
|
|
26486
26526
|
});
|
|
26487
26527
|
}
|
|
@@ -26543,12 +26583,14 @@ function useSymmCancelTpslMutation(options) {
|
|
|
26543
26583
|
}
|
|
26544
26584
|
function useSymmTpslOrders(params) {
|
|
26545
26585
|
const { symmCoreClient, chainId: ctxChainId } = useSymmContext();
|
|
26546
|
-
const { accountAddress, address, positionId, type
|
|
26586
|
+
const { accountAddress, address, positionId, type } = params;
|
|
26587
|
+
const status = params.status ?? ACTIVE_ORDER_STATUS;
|
|
26547
26588
|
const resolvedAddress = accountAddress ? void 0 : address;
|
|
26548
26589
|
const chainId = params.chainId ?? ctxChainId;
|
|
26549
|
-
const internalEnabled = !!symmCoreClient && !!(accountAddress || resolvedAddress
|
|
26590
|
+
const internalEnabled = !!symmCoreClient && !!(accountAddress || resolvedAddress);
|
|
26550
26591
|
const request = {
|
|
26551
|
-
|
|
26592
|
+
accountAddress,
|
|
26593
|
+
address: resolvedAddress,
|
|
26552
26594
|
positionId,
|
|
26553
26595
|
type,
|
|
26554
26596
|
status,
|
|
@@ -26564,27 +26606,58 @@ function useSymmTpslOrders(params) {
|
|
|
26564
26606
|
status,
|
|
26565
26607
|
chainId
|
|
26566
26608
|
}),
|
|
26567
|
-
queryFn: () => symmCoreClient.orders.getTpslOrders(request),
|
|
26609
|
+
queryFn: async () => filterOrdersByStatus(await symmCoreClient.orders.getTpslOrders(request), status),
|
|
26568
26610
|
enabled: internalEnabled && (params.query?.enabled ?? true)
|
|
26569
26611
|
});
|
|
26570
26612
|
}
|
|
26571
26613
|
function useResolvedTwapParams(params) {
|
|
26572
26614
|
const { symmCoreClient, chainId: ctxChainId } = useSymmContext();
|
|
26573
|
-
const { accountAddress, address } = params;
|
|
26615
|
+
const { accountAddress, address, limit, offset } = params;
|
|
26616
|
+
const status = params.status ?? ACTIVE_ORDER_STATUS;
|
|
26574
26617
|
const resolvedAddress = accountAddress ? void 0 : address;
|
|
26575
26618
|
const chainId = params.chainId ?? ctxChainId;
|
|
26576
|
-
return {
|
|
26619
|
+
return {
|
|
26620
|
+
symmCoreClient,
|
|
26621
|
+
accountAddress,
|
|
26622
|
+
resolvedAddress,
|
|
26623
|
+
chainId,
|
|
26624
|
+
status,
|
|
26625
|
+
limit,
|
|
26626
|
+
offset,
|
|
26627
|
+
query: params.query
|
|
26628
|
+
};
|
|
26577
26629
|
}
|
|
26578
26630
|
function useSymmTwapOrdersQuery(params) {
|
|
26579
|
-
const {
|
|
26631
|
+
const {
|
|
26632
|
+
symmCoreClient,
|
|
26633
|
+
accountAddress,
|
|
26634
|
+
resolvedAddress,
|
|
26635
|
+
chainId,
|
|
26636
|
+
status,
|
|
26637
|
+
limit,
|
|
26638
|
+
offset,
|
|
26639
|
+
query
|
|
26640
|
+
} = useResolvedTwapParams(params);
|
|
26580
26641
|
const internalEnabled = !!symmCoreClient && !!(accountAddress || resolvedAddress);
|
|
26642
|
+
const request = {
|
|
26643
|
+
accountAddress,
|
|
26644
|
+
address: resolvedAddress,
|
|
26645
|
+
chainId,
|
|
26646
|
+
status,
|
|
26647
|
+
limit,
|
|
26648
|
+
offset
|
|
26649
|
+
};
|
|
26581
26650
|
return useQuery({
|
|
26582
26651
|
...query,
|
|
26583
|
-
queryKey: symmKeys.twapOrders(
|
|
26584
|
-
|
|
26585
|
-
address:
|
|
26586
|
-
chainId
|
|
26652
|
+
queryKey: symmKeys.twapOrders({
|
|
26653
|
+
accountAddress,
|
|
26654
|
+
address: resolvedAddress,
|
|
26655
|
+
chainId,
|
|
26656
|
+
status,
|
|
26657
|
+
limit,
|
|
26658
|
+
offset
|
|
26587
26659
|
}),
|
|
26660
|
+
queryFn: async () => filterOrdersByStatus(await symmCoreClient.orders.getTwapOrders(request), status),
|
|
26588
26661
|
enabled: internalEnabled && (query?.enabled ?? true)
|
|
26589
26662
|
});
|
|
26590
26663
|
}
|
|
@@ -26658,12 +26731,14 @@ function useSymmClearTriggerConfigMutation(params, options) {
|
|
|
26658
26731
|
}
|
|
26659
26732
|
function useSymmTriggerOrders(params) {
|
|
26660
26733
|
const { symmCoreClient, chainId: ctxChainId } = useSymmContext();
|
|
26661
|
-
const { accountAddress, address,
|
|
26734
|
+
const { accountAddress, address, limit, offset } = params;
|
|
26735
|
+
const status = params.status ?? ACTIVE_ORDER_STATUS;
|
|
26662
26736
|
const resolvedAddress = accountAddress ? void 0 : address;
|
|
26663
26737
|
const chainId = params.chainId ?? ctxChainId;
|
|
26664
26738
|
const internalEnabled = !!symmCoreClient && !!(accountAddress || resolvedAddress);
|
|
26665
26739
|
const request = {
|
|
26666
|
-
|
|
26740
|
+
accountAddress,
|
|
26741
|
+
address: resolvedAddress,
|
|
26667
26742
|
chainId,
|
|
26668
26743
|
status,
|
|
26669
26744
|
limit,
|
|
@@ -26679,7 +26754,7 @@ function useSymmTriggerOrders(params) {
|
|
|
26679
26754
|
limit,
|
|
26680
26755
|
offset
|
|
26681
26756
|
}),
|
|
26682
|
-
queryFn: () => symmCoreClient.orders.listTriggerOrders(request),
|
|
26757
|
+
queryFn: async () => filterOrdersByStatus(await symmCoreClient.orders.listTriggerOrders(request), status),
|
|
26683
26758
|
enabled: internalEnabled && (params.query?.enabled ?? true)
|
|
26684
26759
|
});
|
|
26685
26760
|
}
|
|
@@ -26860,6 +26935,11 @@ async function fetch24hrTickers() {
|
|
|
26860
26935
|
|
|
26861
26936
|
// src/react/hooks/use-symm-token-selection-markets.ts
|
|
26862
26937
|
var EMPTY_MARKETS = [];
|
|
26938
|
+
function toSortedSymbolsKey(symbols) {
|
|
26939
|
+
const sortedSymbols = Array.from(symbols);
|
|
26940
|
+
sortedSymbols.sort();
|
|
26941
|
+
return sortedSymbols.join(",");
|
|
26942
|
+
}
|
|
26863
26943
|
function useSymmTokenSelectionMarkets(params) {
|
|
26864
26944
|
const query = useSymmHedgerMarkets(params);
|
|
26865
26945
|
const baseMarkets = query.data?.filteredMarkets ?? query.data?.markets ?? EMPTY_MARKETS;
|
|
@@ -26872,7 +26952,7 @@ function useSymmTokenSelectionMarkets(params) {
|
|
|
26872
26952
|
[baseMarkets]
|
|
26873
26953
|
);
|
|
26874
26954
|
const symbolsKey = useMemo(
|
|
26875
|
-
() =>
|
|
26955
|
+
() => toSortedSymbolsKey(marketSymbols),
|
|
26876
26956
|
[marketSymbols]
|
|
26877
26957
|
);
|
|
26878
26958
|
const liveMarkPrices = useBinanceMarkPriceStore((state) => state.markPrices);
|