@orderly.network/hooks 0.0.95 → 0.0.97
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.js +144 -146
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +9 -10
- package/dist/index.mjs.map +1 -1
- package/package.json +7 -7
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { createContext, useContext, useState, useEffect, useCallback, useMemo, useRef } from 'react';
|
|
2
2
|
import useSWR, { useSWRConfig } from 'swr';
|
|
3
3
|
export { SWRConfig, default as useSWR } from 'swr';
|
|
4
4
|
import { WS, get, mutate } from '@orderly.network/net';
|
|
@@ -7,6 +7,7 @@ import useConstant from 'use-constant';
|
|
|
7
7
|
export { default as useConstant } from 'use-constant';
|
|
8
8
|
import { SimpleDI, Account, EventEmitter, utils } from '@orderly.network/core';
|
|
9
9
|
import { AccountStatusEnum, OrderStatus, OrderSide, chainsInfoMap, ARBITRUM_TESTNET_CHAINID, ARBITRUM_MAINNET_CHAINID, WS_WalletStatusEnum, OrderType } from '@orderly.network/types';
|
|
10
|
+
import { jsx } from 'react/jsx-runtime';
|
|
10
11
|
import { Decimal, zero, getPrecisionByNumber, timeConvertString } from '@orderly.network/utils';
|
|
11
12
|
import useSWRSubscription from 'swr/subscription';
|
|
12
13
|
import { pathOr, propOr, compose, head, prop, mergeDeepRight, pick, min } from 'ramda';
|
|
@@ -434,7 +435,7 @@ var DataSourceProvider = (props) => {
|
|
|
434
435
|
useAccountInstance();
|
|
435
436
|
useConstant(() => {
|
|
436
437
|
});
|
|
437
|
-
return /* @__PURE__ */
|
|
438
|
+
return /* @__PURE__ */ jsx(DataSourceContext.Provider, { value: {}, children: props.children });
|
|
438
439
|
};
|
|
439
440
|
var WS_NAME = "nativeWebsocketClient";
|
|
440
441
|
var useWS = () => {
|
|
@@ -1425,7 +1426,8 @@ var useOrderStream = ({
|
|
|
1425
1426
|
const cancelOrder = useCallback((orderId, symbol2) => {
|
|
1426
1427
|
return doCancelOrder(null, {
|
|
1427
1428
|
order_id: orderId,
|
|
1428
|
-
symbol: symbol2
|
|
1429
|
+
symbol: symbol2,
|
|
1430
|
+
source: "mweb"
|
|
1429
1431
|
}).then((res) => {
|
|
1430
1432
|
if (res.success) ; else {
|
|
1431
1433
|
throw new Error(res.message);
|
|
@@ -3309,6 +3311,7 @@ var useWithdraw = () => {
|
|
|
3309
3311
|
const { account: account5, state } = useAccount();
|
|
3310
3312
|
const [isLoading, setIsLoading] = useState(false);
|
|
3311
3313
|
const { unsettledPnL, availableBalance } = useCollateral();
|
|
3314
|
+
const { freeCollateral } = useCollateral();
|
|
3312
3315
|
const withdraw = useCallback(
|
|
3313
3316
|
(inputs) => {
|
|
3314
3317
|
return account5.assetsManager.withdraw(inputs).then((res) => {
|
|
@@ -3317,14 +3320,10 @@ var useWithdraw = () => {
|
|
|
3317
3320
|
},
|
|
3318
3321
|
[state]
|
|
3319
3322
|
);
|
|
3320
|
-
|
|
3323
|
+
useHoldingStream();
|
|
3321
3324
|
const maxAmount = useMemo(() => {
|
|
3322
|
-
|
|
3323
|
-
|
|
3324
|
-
if (unsettledPnL >= 0)
|
|
3325
|
-
return usdc?.holding ?? 0;
|
|
3326
|
-
return new Decimal(usdc.holding).add(unsettledPnL).toNumber();
|
|
3327
|
-
}, [usdc, unsettledPnL]);
|
|
3325
|
+
return freeCollateral;
|
|
3326
|
+
}, [freeCollateral]);
|
|
3328
3327
|
return { withdraw, isLoading, maxAmount, availableBalance, unsettledPnL };
|
|
3329
3328
|
};
|
|
3330
3329
|
var useDeposit = (options) => {
|