@pear-protocol/symmio-client 0.3.27 → 0.3.28
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 +5 -4
- package/dist/react/index.d.ts +5 -4
- package/dist/react/index.js +27 -11
- package/dist/react/index.js.map +1 -1
- package/dist/react/index.mjs +28 -12
- package/dist/react/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/react/index.d.mts
CHANGED
|
@@ -9,6 +9,7 @@ import { UseMutationOptions, useQueryClient, UseMutationResult, UseQueryResult }
|
|
|
9
9
|
import * as node_modules_viem__types_actions_siwe_verifySiweMessage from 'node_modules/viem/_types/actions/siwe/verifySiweMessage';
|
|
10
10
|
import * as abitype from 'abitype';
|
|
11
11
|
import * as node_modules_viem__types_utils_ccip from 'node_modules/viem/_types/utils/ccip';
|
|
12
|
+
import * as _pear_protocol_symm_shared from '@pear-protocol/symm-shared';
|
|
12
13
|
import * as _tanstack_query_core from '@tanstack/query-core';
|
|
13
14
|
import * as node_modules__pear_protocol_symm_core_dist_types from 'node_modules/@pear-protocol/symm-core/dist/types';
|
|
14
15
|
import * as zustand from 'zustand';
|
|
@@ -8390,7 +8391,7 @@ declare function useSymmCancelClose(options?: {
|
|
|
8390
8391
|
accountAddress?: Address;
|
|
8391
8392
|
overrideChainId?: number;
|
|
8392
8393
|
}>;
|
|
8393
|
-
}): _tanstack_react_query.UseMutationResult<
|
|
8394
|
+
}): _tanstack_react_query.UseMutationResult<_pear_protocol_symm_shared.ApiResponse<unknown>, Error, {
|
|
8394
8395
|
quoteId: string;
|
|
8395
8396
|
authToken?: string;
|
|
8396
8397
|
accountAddress?: Address;
|
|
@@ -9309,7 +9310,7 @@ declare function useSymmCloseAllPositionsMutation(options?: {
|
|
|
9309
9310
|
*/
|
|
9310
9311
|
declare function useSymmCancelOpenMutation(options?: {
|
|
9311
9312
|
mutation?: SymmMutationConfig<unknown, Error, CancelOpenRequest>;
|
|
9312
|
-
}): _tanstack_react_query.UseMutationResult<
|
|
9313
|
+
}): _tanstack_react_query.UseMutationResult<_pear_protocol_symm_shared.ApiResponse<unknown>, Error, CancelOpenRequest, unknown>;
|
|
9313
9314
|
/**
|
|
9314
9315
|
* Use case: Update position settings with automatic auth-token resolution.
|
|
9315
9316
|
*/
|
|
@@ -9365,7 +9366,7 @@ declare function useSymmSetTpslMutation(options?: {
|
|
|
9365
9366
|
*/
|
|
9366
9367
|
declare function useSymmCancelTpslMutation(options?: {
|
|
9367
9368
|
mutation?: SymmMutationConfig<unknown, Error, CancelTpslRequest>;
|
|
9368
|
-
}): _tanstack_react_query.UseMutationResult<
|
|
9369
|
+
}): _tanstack_react_query.UseMutationResult<_pear_protocol_symm_shared.ApiResponse<unknown>, Error, CancelTpslRequest, unknown>;
|
|
9369
9370
|
|
|
9370
9371
|
type UseSymmTpslOrdersParams = {
|
|
9371
9372
|
accountAddress?: Address;
|
|
@@ -9497,7 +9498,7 @@ declare function useSymmLockedParams(params: {
|
|
|
9497
9498
|
leverage?: number;
|
|
9498
9499
|
chainId?: number;
|
|
9499
9500
|
query?: SymmQueryConfig;
|
|
9500
|
-
}): _tanstack_react_query.UseQueryResult<
|
|
9501
|
+
}): _tanstack_react_query.UseQueryResult<_pear_protocol_symm_shared.LockedParams, Error>;
|
|
9501
9502
|
|
|
9502
9503
|
type UseSymmHedgerMarketsParams = GetSymmHedgerMarketsRequest & {
|
|
9503
9504
|
/** @deprecated Use `query.enabled` instead. */
|
package/dist/react/index.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ import { UseMutationOptions, useQueryClient, UseMutationResult, UseQueryResult }
|
|
|
9
9
|
import * as node_modules_viem__types_actions_siwe_verifySiweMessage from 'node_modules/viem/_types/actions/siwe/verifySiweMessage';
|
|
10
10
|
import * as abitype from 'abitype';
|
|
11
11
|
import * as node_modules_viem__types_utils_ccip from 'node_modules/viem/_types/utils/ccip';
|
|
12
|
+
import * as _pear_protocol_symm_shared from '@pear-protocol/symm-shared';
|
|
12
13
|
import * as _tanstack_query_core from '@tanstack/query-core';
|
|
13
14
|
import * as node_modules__pear_protocol_symm_core_dist_types from 'node_modules/@pear-protocol/symm-core/dist/types';
|
|
14
15
|
import * as zustand from 'zustand';
|
|
@@ -8390,7 +8391,7 @@ declare function useSymmCancelClose(options?: {
|
|
|
8390
8391
|
accountAddress?: Address;
|
|
8391
8392
|
overrideChainId?: number;
|
|
8392
8393
|
}>;
|
|
8393
|
-
}): _tanstack_react_query.UseMutationResult<
|
|
8394
|
+
}): _tanstack_react_query.UseMutationResult<_pear_protocol_symm_shared.ApiResponse<unknown>, Error, {
|
|
8394
8395
|
quoteId: string;
|
|
8395
8396
|
authToken?: string;
|
|
8396
8397
|
accountAddress?: Address;
|
|
@@ -9309,7 +9310,7 @@ declare function useSymmCloseAllPositionsMutation(options?: {
|
|
|
9309
9310
|
*/
|
|
9310
9311
|
declare function useSymmCancelOpenMutation(options?: {
|
|
9311
9312
|
mutation?: SymmMutationConfig<unknown, Error, CancelOpenRequest>;
|
|
9312
|
-
}): _tanstack_react_query.UseMutationResult<
|
|
9313
|
+
}): _tanstack_react_query.UseMutationResult<_pear_protocol_symm_shared.ApiResponse<unknown>, Error, CancelOpenRequest, unknown>;
|
|
9313
9314
|
/**
|
|
9314
9315
|
* Use case: Update position settings with automatic auth-token resolution.
|
|
9315
9316
|
*/
|
|
@@ -9365,7 +9366,7 @@ declare function useSymmSetTpslMutation(options?: {
|
|
|
9365
9366
|
*/
|
|
9366
9367
|
declare function useSymmCancelTpslMutation(options?: {
|
|
9367
9368
|
mutation?: SymmMutationConfig<unknown, Error, CancelTpslRequest>;
|
|
9368
|
-
}): _tanstack_react_query.UseMutationResult<
|
|
9369
|
+
}): _tanstack_react_query.UseMutationResult<_pear_protocol_symm_shared.ApiResponse<unknown>, Error, CancelTpslRequest, unknown>;
|
|
9369
9370
|
|
|
9370
9371
|
type UseSymmTpslOrdersParams = {
|
|
9371
9372
|
accountAddress?: Address;
|
|
@@ -9497,7 +9498,7 @@ declare function useSymmLockedParams(params: {
|
|
|
9497
9498
|
leverage?: number;
|
|
9498
9499
|
chainId?: number;
|
|
9499
9500
|
query?: SymmQueryConfig;
|
|
9500
|
-
}): _tanstack_react_query.UseQueryResult<
|
|
9501
|
+
}): _tanstack_react_query.UseQueryResult<_pear_protocol_symm_shared.LockedParams, Error>;
|
|
9501
9502
|
|
|
9502
9503
|
type UseSymmHedgerMarketsParams = GetSymmHedgerMarketsRequest & {
|
|
9503
9504
|
/** @deprecated Use `query.enabled` instead. */
|
package/dist/react/index.js
CHANGED
|
@@ -27108,6 +27108,24 @@ function useSymmBalances(params) {
|
|
|
27108
27108
|
enabled: internalEnabled && (params.query?.enabled ?? true)
|
|
27109
27109
|
});
|
|
27110
27110
|
}
|
|
27111
|
+
function normalizeSideWeights(legs) {
|
|
27112
|
+
if (!legs?.length) return legs;
|
|
27113
|
+
const allWeighted = legs.every(
|
|
27114
|
+
(leg) => typeof leg.weight === "number" && Number.isFinite(leg.weight) && leg.weight > 0
|
|
27115
|
+
);
|
|
27116
|
+
if (!allWeighted) return legs;
|
|
27117
|
+
const total = legs.reduce((sum, leg) => sum + (leg.weight ?? 0), 0);
|
|
27118
|
+
if (total <= 0) return legs;
|
|
27119
|
+
if (Math.abs(total - 1) < 1e-9) return legs;
|
|
27120
|
+
return legs.map((leg) => ({ ...leg, weight: (leg.weight ?? 0) / total }));
|
|
27121
|
+
}
|
|
27122
|
+
function normalizeBasketWeights(request) {
|
|
27123
|
+
return {
|
|
27124
|
+
...request,
|
|
27125
|
+
longPositions: normalizeSideWeights(request.longPositions),
|
|
27126
|
+
shortPositions: normalizeSideWeights(request.shortPositions)
|
|
27127
|
+
};
|
|
27128
|
+
}
|
|
27111
27129
|
function useSymmOpenBasketMutation(options) {
|
|
27112
27130
|
const { symmCoreClient } = useSymmContext();
|
|
27113
27131
|
const queryClient = reactQuery.useQueryClient();
|
|
@@ -27128,10 +27146,12 @@ function useSymmOpenBasketMutation(options) {
|
|
|
27128
27146
|
if (!authToken) {
|
|
27129
27147
|
throw new Error("auth token is required to open a position");
|
|
27130
27148
|
}
|
|
27131
|
-
return symmCoreClient.positions.openBasket(
|
|
27132
|
-
|
|
27133
|
-
|
|
27134
|
-
|
|
27149
|
+
return symmCoreClient.positions.openBasket(
|
|
27150
|
+
normalizeBasketWeights({
|
|
27151
|
+
...request,
|
|
27152
|
+
authToken
|
|
27153
|
+
})
|
|
27154
|
+
);
|
|
27135
27155
|
}
|
|
27136
27156
|
});
|
|
27137
27157
|
}
|
|
@@ -27603,18 +27623,14 @@ function useSymmHedgerMarketBySymbol(params) {
|
|
|
27603
27623
|
});
|
|
27604
27624
|
}
|
|
27605
27625
|
function useSymmLockedParams(params) {
|
|
27606
|
-
const {
|
|
27626
|
+
const { chainId: ctxChainId } = useSymmContext();
|
|
27607
27627
|
const { marketName, leverage } = params;
|
|
27608
27628
|
const chainId = params.chainId ?? ctxChainId;
|
|
27609
|
-
const internalEnabled = !!
|
|
27629
|
+
const internalEnabled = !!marketName && leverage != null && typeof chainId === "number";
|
|
27610
27630
|
return reactQuery.useQuery({
|
|
27611
27631
|
...params.query,
|
|
27612
27632
|
queryKey: symmKeys.lockedParams(marketName, leverage, chainId),
|
|
27613
|
-
queryFn: () =>
|
|
27614
|
-
marketName,
|
|
27615
|
-
leverage,
|
|
27616
|
-
chainId
|
|
27617
|
-
}),
|
|
27633
|
+
queryFn: () => symmCore.HedgerClient.getLockedParams(chainId, marketName, leverage),
|
|
27618
27634
|
enabled: internalEnabled && (params.query?.enabled ?? true)
|
|
27619
27635
|
});
|
|
27620
27636
|
}
|