@orderly.network/hooks 0.0.33 → 0.0.35

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/index.d.mts CHANGED
@@ -1,12 +1,12 @@
1
1
  import useSWR, { SWRConfiguration, SWRResponse } from 'swr';
2
2
  export { SWRConfiguration, default as useSWR } from 'swr';
3
3
  import { SWRMutationConfiguration } from 'swr/mutation';
4
- import { Account, AccountState, ConfigStore, OrderlyKeyStore, WalletAdapter, IContract, EventEmitter, WSMessage } from '@orderly.network/core';
4
+ import { Account, AccountState, ConfigStore, OrderlyKeyStore, WalletAdapter, IContract, EventEmitter } from '@orderly.network/core';
5
5
  import * as react from 'react';
6
6
  import react__default, { FC, PropsWithChildren } from 'react';
7
7
  export { default as useConstant } from 'use-constant';
8
8
  import { WS } from '@orderly.network/net';
9
- import { OrderSide, OrderEntity, API } from '@orderly.network/types';
9
+ import { OrderSide, OrderEntity, API, WSMessage } from '@orderly.network/types';
10
10
  import * as swr__internal from 'swr/_internal';
11
11
  import * as swr_subscription from 'swr/subscription';
12
12
 
package/dist/index.d.ts CHANGED
@@ -1,12 +1,12 @@
1
1
  import useSWR, { SWRConfiguration, SWRResponse } from 'swr';
2
2
  export { SWRConfiguration, default as useSWR } from 'swr';
3
3
  import { SWRMutationConfiguration } from 'swr/mutation';
4
- import { Account, AccountState, ConfigStore, OrderlyKeyStore, WalletAdapter, IContract, EventEmitter, WSMessage } from '@orderly.network/core';
4
+ import { Account, AccountState, ConfigStore, OrderlyKeyStore, WalletAdapter, IContract, EventEmitter } from '@orderly.network/core';
5
5
  import * as react from 'react';
6
6
  import react__default, { FC, PropsWithChildren } from 'react';
7
7
  export { default as useConstant } from 'use-constant';
8
8
  import { WS } from '@orderly.network/net';
9
- import { OrderSide, OrderEntity, API } from '@orderly.network/types';
9
+ import { OrderSide, OrderEntity, API, WSMessage } from '@orderly.network/types';
10
10
  import * as swr__internal from 'swr/_internal';
11
11
  import * as swr_subscription from 'swr/subscription';
12
12
 
package/dist/index.js CHANGED
@@ -186,7 +186,8 @@ var signatureMiddleware = (useSWRNext) => {
186
186
  const { apiBaseUrl } = React2.useContext(OrderlyContext);
187
187
  return (key, fetcher4, config) => {
188
188
  try {
189
- const extendedFetcher = (url) => __async(void 0, null, function* () {
189
+ const extendedFetcher = (args) => __async(void 0, null, function* () {
190
+ let url = Array.isArray(args) ? args[0] : args;
190
191
  let account5 = core.SimpleDI.get("account");
191
192
  let fullUrl = `${apiBaseUrl}${url}`;
192
193
  const signer = account5.signer;
@@ -280,7 +281,7 @@ var usePrivateQuery = (query, options) => {
280
281
  const account5 = useAccount();
281
282
  const middleware = Array.isArray(options == null ? void 0 : options.use) ? (_b = options == null ? void 0 : options.use) != null ? _b : [] : [];
282
283
  return useSWR__default.default(
283
- () => account5.state.status >= types.AccountStatusEnum.EnableTrading ? query : null,
284
+ () => account5.state.status >= types.AccountStatusEnum.EnableTrading ? [query, account5.state.accountId] : null,
284
285
  // query,
285
286
  (url, init) => {
286
287
  return fetcher(url, init, { formatter });
@@ -687,6 +688,8 @@ var mergeItems = (data, update) => {
687
688
  const [price, quantity] = item;
688
689
  const index = data.findIndex(([p], index2) => p === price);
689
690
  if (index === -1) {
691
+ if (quantity === 0)
692
+ continue;
690
693
  data.push(item);
691
694
  } else {
692
695
  if (quantity === 0) {
@@ -1047,10 +1050,8 @@ var usePositionStream = (symbol, options) => {
1047
1050
  const formatedPositions = React2.useMemo(() => {
1048
1051
  if (!(data == null ? void 0 : data.rows) || !symbolInfo || !accountInfo)
1049
1052
  return null;
1050
- const filteredData = typeof symbol === "undefined" || symbol === "" ? data.rows.filter((item) => {
1051
- return item.position_qty !== 0;
1052
- }) : data.rows.filter((item) => {
1053
- return item.symbol === symbol && item.position_qty !== 0;
1053
+ const filteredData = typeof symbol === "undefined" || symbol === "" ? data.rows : data.rows.filter((item) => {
1054
+ return item.symbol === symbol;
1054
1055
  });
1055
1056
  let unrealPnL_total = utils.zero, notional_total = utils.zero, unsettlementPnL_total = utils.zero;
1056
1057
  const formatted = filteredData.map((item) => {
@@ -1126,7 +1127,7 @@ var usePositionStream = (symbol, options) => {
1126
1127
  if (!symbolInfo || !accountInfo)
1127
1128
  return formatedPositions[0];
1128
1129
  const total = totalCollateral.toNumber();
1129
- return formatedPositions[0].map((item) => {
1130
+ return formatedPositions[0].filter((item) => item.position_qty !== 0).map((item) => {
1130
1131
  const info = symbolInfo == null ? void 0 : symbolInfo[item.symbol];
1131
1132
  const MMR = futures.positions.MMR({
1132
1133
  baseMMR: info("base_mmr"),