@orderly.network/hooks 0.0.82 → 0.0.84
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 +6 -2
- package/dist/index.d.ts +6 -2
- package/dist/index.js +50 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +51 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +7 -7
package/dist/index.mjs
CHANGED
|
@@ -7,7 +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, OrderSide, chainsInfoMap, ARBITRUM_TESTNET_CHAINID, ARBITRUM_MAINNET_CHAINID, OrderStatus as OrderStatus$1, WS_WalletStatusEnum, OrderType } from '@orderly.network/types';
|
|
10
|
-
import { Decimal, zero, getPrecisionByNumber, timeConvertString } from '@orderly.network/utils';
|
|
10
|
+
import { Decimal, zero, getPrecisionByNumber, timeConvertString, capitalizeString, transSymbolformString } from '@orderly.network/utils';
|
|
11
11
|
import useSWRSubscription from 'swr/subscription';
|
|
12
12
|
import { pathOr, propOr, compose, head, prop, mergeDeepRight, pick } from 'ramda';
|
|
13
13
|
import { positions, account, order } from '@orderly.network/futures';
|
|
@@ -3522,17 +3522,64 @@ var usePrivateDataObserver = () => {
|
|
|
3522
3522
|
};
|
|
3523
3523
|
}, [state.accountId]);
|
|
3524
3524
|
};
|
|
3525
|
-
var useExecutionReport = () => {
|
|
3525
|
+
var useExecutionReport = (options) => {
|
|
3526
3526
|
const ws = useWS();
|
|
3527
3527
|
const { data } = useSWRSubscription("executionreport", (_, { next }) => {
|
|
3528
|
-
const unsubscribe = ws.privateSubscribe(
|
|
3528
|
+
const unsubscribe = ws.privateSubscribe({
|
|
3529
|
+
id: "executionreport",
|
|
3530
|
+
event: "subscribe",
|
|
3531
|
+
topic: "executionreport",
|
|
3532
|
+
ts: Date.now()
|
|
3533
|
+
}, {
|
|
3529
3534
|
onMessage: (data2) => {
|
|
3535
|
+
options?.onMessage?.(data2);
|
|
3536
|
+
next(data2);
|
|
3530
3537
|
}
|
|
3531
3538
|
});
|
|
3532
3539
|
return () => unsubscribe();
|
|
3533
3540
|
});
|
|
3534
3541
|
return data;
|
|
3535
3542
|
};
|
|
3543
|
+
function parseExecutionReportToToastMsg(data, symbolsInfo) {
|
|
3544
|
+
const { symbol } = data;
|
|
3545
|
+
const getSymbolInfo = symbolsInfo[symbol];
|
|
3546
|
+
const baseTick = getSymbolInfo("base_dp");
|
|
3547
|
+
const { status } = data;
|
|
3548
|
+
const { side } = data;
|
|
3549
|
+
const { quantity } = data;
|
|
3550
|
+
const displaySide = capitalizeString(side);
|
|
3551
|
+
const displaySymbol = transSymbolformString(symbol);
|
|
3552
|
+
const displayQuantity = baseTick === void 0 ? quantity : quantity.toFixed(baseTick);
|
|
3553
|
+
let msg = "";
|
|
3554
|
+
let title = "";
|
|
3555
|
+
switch (status) {
|
|
3556
|
+
case "NEW":
|
|
3557
|
+
title = "Order opened";
|
|
3558
|
+
msg = `Order opened ${displaySide} ${displaySymbol} ${displayQuantity}`;
|
|
3559
|
+
break;
|
|
3560
|
+
case "FILLED":
|
|
3561
|
+
case "PARTIAL_FILLED":
|
|
3562
|
+
const { totalExecutedQuantity } = data;
|
|
3563
|
+
const displayTotalExecutedQuantity = baseTick === void 0 ? totalExecutedQuantity : totalExecutedQuantity.toFixed(baseTick);
|
|
3564
|
+
title = "Order filled";
|
|
3565
|
+
msg = `Order filled ${displaySide} ${displaySymbol} ${displayTotalExecutedQuantity} / ${displayQuantity}`;
|
|
3566
|
+
break;
|
|
3567
|
+
case "CANCELLED":
|
|
3568
|
+
title = "Order cancelled";
|
|
3569
|
+
msg = `Order cancelled ${displaySide} ${displaySymbol} ${displayQuantity}`;
|
|
3570
|
+
break;
|
|
3571
|
+
case "REJECTED":
|
|
3572
|
+
title = "Order rejected";
|
|
3573
|
+
msg = `Order rejected ${displaySide} ${displaySymbol} ${displayQuantity}`;
|
|
3574
|
+
break;
|
|
3575
|
+
}
|
|
3576
|
+
if (msg.length === 0)
|
|
3577
|
+
return null;
|
|
3578
|
+
return {
|
|
3579
|
+
title,
|
|
3580
|
+
msg
|
|
3581
|
+
};
|
|
3582
|
+
}
|
|
3536
3583
|
|
|
3537
3584
|
// src/apis/index.ts
|
|
3538
3585
|
var apis_exports = {};
|
|
@@ -4162,6 +4209,6 @@ var useSwap = () => {
|
|
|
4162
4209
|
};
|
|
4163
4210
|
};
|
|
4164
4211
|
|
|
4165
|
-
export { DataSourceProvider, OrderStatus, OrderlyContext, OrderlyProvider, apis_exports as apis, useAccount, useAccountInfo, useAccountInstance, useAppState, useBalance, useBoolean, useChain, useChains, useCollateral, useConfig, useCrossSwap, useDeposit, useEventEmitter, useExecutionReport, useFetures, useFundingRate, useHoldingStream, useIndexPrice, useLazyQuery, useLeverage, useLocalStorage, useMarginRatio, useMarkPrice, useMarkPricesStream, useMarketTradeStream, useMarketsStream, useMaxQty, useMutation, useOpenInterest, useOrderEntry, useOrderStream, useOrderbookStream, usePositionStream, usePreLoadData, usePrivateDataObserver, usePrivateQuery, useQuery, useRunOnce, useSessionStorage, useSettleSubscription, useSwap, useSymbolsInfo, useTickerStream, useTokenInfo, useTopicObserve, useTradingView, useWS, useWalletSubscription, useWithdraw, useWooCrossSwapQuery, useWooSwapQuery };
|
|
4212
|
+
export { DataSourceProvider, OrderStatus, OrderlyContext, OrderlyProvider, apis_exports as apis, parseExecutionReportToToastMsg, useAccount, useAccountInfo, useAccountInstance, useAppState, useBalance, useBoolean, useChain, useChains, useCollateral, useConfig, useCrossSwap, useDeposit, useEventEmitter, useExecutionReport, useFetures, useFundingRate, useHoldingStream, useIndexPrice, useLazyQuery, useLeverage, useLocalStorage, useMarginRatio, useMarkPrice, useMarkPricesStream, useMarketTradeStream, useMarketsStream, useMaxQty, useMutation, useOpenInterest, useOrderEntry, useOrderStream, useOrderbookStream, usePositionStream, usePreLoadData, usePrivateDataObserver, usePrivateQuery, useQuery, useRunOnce, useSessionStorage, useSettleSubscription, useSwap, useSymbolsInfo, useTickerStream, useTokenInfo, useTopicObserve, useTradingView, useWS, useWalletSubscription, useWithdraw, useWooCrossSwapQuery, useWooSwapQuery };
|
|
4166
4213
|
//# sourceMappingURL=out.js.map
|
|
4167
4214
|
//# sourceMappingURL=index.mjs.map
|