@orderly.network/hooks 2.11.3-rc.0 → 2.12.0
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 +191 -104
- package/dist/index.d.ts +191 -104
- package/dist/index.js +207 -28
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +202 -28
- package/dist/index.mjs.map +1 -1
- package/package.json +10 -10
package/dist/index.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
import React, { createContext, createElement, useContext, useCallback, useState, useEffect, useMemo, useRef, useId, useLayoutEffect } from 'react';
|
|
1
2
|
import { get, WS, mutate as mutate$1 } from '@orderly.network/net';
|
|
2
3
|
import useSWR5__default, { mutate } from 'swr';
|
|
3
4
|
import * as useSWR5 from 'swr';
|
|
4
5
|
export { useSWR5 as swr };
|
|
5
6
|
export { unstable_serialize, default as useSWR, useSWRConfig } from 'swr';
|
|
6
7
|
import { TesnetTokenFallback, ArbitrumSepoliaTokenInfo, SolanaDevnetTokenInfo, OrderType, OrderSide, MarginMode, SDKError, TrackerEventName, AccountStatusEnum, AlgoOrderType, AlgoOrderRootType, OrderStatus, ArbitrumSepoliaChainInfo, SolanaDevnetChainInfo, EMPTY_LIST, EMPTY_OBJECT, isNativeTokenChecker, nativeTokenAddress, ChainKey, chainsInfoMap, ARBITRUM_TESTNET_CHAINID, ARBITRUM_MAINNET_CHAINID, ChainNamespace, MaxUint256, DEPOSIT_FEE_RATE, ETHEREUM_MAINNET_CHAINID, LedgerWalletKey, SOLANA_TESTNET_CHAINID, MONAD_TESTNET_CHAINID, ABSTRACT_TESTNET_CHAINID, BSC_TESTNET_CHAINID, SolanaChains, PositionType, DistributionType, TriggerPriceType } from '@orderly.network/types';
|
|
7
|
-
import React, { createContext, useContext, useCallback, useState, useEffect, useMemo, useRef, useId, useLayoutEffect } from 'react';
|
|
8
8
|
import { zero, windowGuard, getTimestamp, getGlobalObject, Decimal, timeConvertString, isTestnet, getPrecisionByNumber, getBBOType, camelCaseToUnderscoreCase, commify, todpIfNeed, getTPSLDirection } from '@orderly.network/utils';
|
|
9
9
|
import useSWRMutation from 'swr/mutation';
|
|
10
10
|
import useConstant from 'use-constant';
|
|
@@ -34,13 +34,24 @@ var __export = (target, all) => {
|
|
|
34
34
|
for (var name in all)
|
|
35
35
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
36
36
|
};
|
|
37
|
+
var MarketCategoriesConfigContext = createContext(void 0);
|
|
38
|
+
var MarketCategoriesConfigProvider = ({ value, children }) => {
|
|
39
|
+
return createElement(
|
|
40
|
+
MarketCategoriesConfigContext.Provider,
|
|
41
|
+
{ value },
|
|
42
|
+
children
|
|
43
|
+
);
|
|
44
|
+
};
|
|
45
|
+
function useMarketCategoriesConfig() {
|
|
46
|
+
return useContext(MarketCategoriesConfigContext);
|
|
47
|
+
}
|
|
37
48
|
|
|
38
49
|
// src/version.ts
|
|
39
50
|
if (typeof window !== "undefined") {
|
|
40
51
|
window.__ORDERLY_VERSION__ = window.__ORDERLY_VERSION__ || {};
|
|
41
|
-
window.__ORDERLY_VERSION__["@orderly.network/hooks"] = "2.
|
|
52
|
+
window.__ORDERLY_VERSION__["@orderly.network/hooks"] = "2.12.0";
|
|
42
53
|
}
|
|
43
|
-
var version_default = "2.
|
|
54
|
+
var version_default = "2.12.0";
|
|
44
55
|
var fetcher = (url, init2 = {}, queryOptions) => get(url, init2, queryOptions?.formatter);
|
|
45
56
|
var noCacheConfig = {
|
|
46
57
|
dedupingInterval: 0,
|
|
@@ -2576,16 +2587,12 @@ var createDataStore = (config) => {
|
|
|
2576
2587
|
const brokerIdQuery = typeof options?.brokerId === "string" && options?.brokerId !== "orderly" ? `?broker_id=${options?.brokerId}` : "";
|
|
2577
2588
|
const url = `${dynamicBaseUrl || baseUrl || ""}${endpoint}${brokerIdQuery}`;
|
|
2578
2589
|
const data = await fetcher(url, {}, { formatter });
|
|
2579
|
-
const dataWithBrokerId = data.map((item) => ({
|
|
2580
|
-
...item,
|
|
2581
|
-
broker_id: options?.brokerId
|
|
2582
|
-
}));
|
|
2583
2590
|
set({
|
|
2584
|
-
data
|
|
2591
|
+
data,
|
|
2585
2592
|
loading: false,
|
|
2586
2593
|
error: null
|
|
2587
2594
|
});
|
|
2588
|
-
return
|
|
2595
|
+
return data;
|
|
2589
2596
|
} catch (error) {
|
|
2590
2597
|
set({ error, loading: false });
|
|
2591
2598
|
return null;
|
|
@@ -3417,6 +3424,7 @@ var MarketsType = /* @__PURE__ */ ((MarketsType2) => {
|
|
|
3417
3424
|
MarketsType2[MarketsType2["ALL"] = 2] = "ALL";
|
|
3418
3425
|
MarketsType2[MarketsType2["RWA"] = 3] = "RWA";
|
|
3419
3426
|
MarketsType2[MarketsType2["NEW_LISTING"] = 4] = "NEW_LISTING";
|
|
3427
|
+
MarketsType2[MarketsType2["COMMUNITY"] = 5] = "COMMUNITY";
|
|
3420
3428
|
return MarketsType2;
|
|
3421
3429
|
})(MarketsType || {});
|
|
3422
3430
|
var MarketsStorageKey = "orderly_markets";
|
|
@@ -3586,6 +3594,8 @@ var addFieldToMarkets = (futures, symbolsInfo, rwaSymbolsInfo) => {
|
|
|
3586
3594
|
const rwaInfo = !rwaSymbolsInfo.isNil ? rwaSymbolsInfo[item.symbol]() : null;
|
|
3587
3595
|
return {
|
|
3588
3596
|
...item,
|
|
3597
|
+
broker_id: item.broker_id,
|
|
3598
|
+
display_symbol_name: item.display_symbol_name,
|
|
3589
3599
|
quote_dp: info("quote_dp"),
|
|
3590
3600
|
created_time: info("created_time"),
|
|
3591
3601
|
displayName: info("displayName"),
|
|
@@ -3607,7 +3617,7 @@ var addFieldToMarkets = (futures, symbolsInfo, rwaSymbolsInfo) => {
|
|
|
3607
3617
|
var filterMarkets = (params) => {
|
|
3608
3618
|
const { markets, favorites, recent, newListing, type } = params;
|
|
3609
3619
|
let curData = [];
|
|
3610
|
-
if (type === 2 /* ALL */) {
|
|
3620
|
+
if (type === 2 /* ALL */ || type === 5 /* COMMUNITY */) {
|
|
3611
3621
|
curData = markets;
|
|
3612
3622
|
} else if (type === 3 /* RWA */) {
|
|
3613
3623
|
curData = markets.filter((item) => item.isRwa);
|
|
@@ -4529,7 +4539,7 @@ var useMarket = (type) => {
|
|
|
4529
4539
|
const getData = (type2) => {
|
|
4530
4540
|
const localData = type2 === 0 /* FAVORITES */ ? [...favorites] : [...recent];
|
|
4531
4541
|
const keys = localData.map((item) => item.name);
|
|
4532
|
-
const filter = type2 == 2 /* ALL */ ? marketsList : marketsList?.filter((item) => keys.includes(item.symbol));
|
|
4542
|
+
const filter = type2 == 2 /* ALL */ || type2 == 4 /* COMMUNITY */ ? marketsList : marketsList?.filter((item) => keys.includes(item.symbol));
|
|
4533
4543
|
const favoritesData = [...favorites];
|
|
4534
4544
|
const favoriteKeys = favoritesData.map((item) => item.name);
|
|
4535
4545
|
if (filter) {
|
|
@@ -4728,6 +4738,80 @@ var useSymbolLeverageMap = () => {
|
|
|
4728
4738
|
refresh: mutate6
|
|
4729
4739
|
};
|
|
4730
4740
|
};
|
|
4741
|
+
|
|
4742
|
+
// src/trading-rewards/useAllBrokers.ts
|
|
4743
|
+
var useAllBrokers = () => {
|
|
4744
|
+
const { data } = useQuery("/v1/public/broker/name", {
|
|
4745
|
+
formatter: (res) => {
|
|
4746
|
+
const { rows } = res;
|
|
4747
|
+
return rows?.map((item) => ({ [item.broker_id]: item.broker_name })).reduce((acc, curr) => ({ ...acc, ...curr }), {});
|
|
4748
|
+
},
|
|
4749
|
+
revalidateOnFocus: false
|
|
4750
|
+
});
|
|
4751
|
+
return [data];
|
|
4752
|
+
};
|
|
4753
|
+
|
|
4754
|
+
// src/useBadgeBySymbol.ts
|
|
4755
|
+
function brokerNameBaseFromRaw(rawBrokerName) {
|
|
4756
|
+
if (!rawBrokerName) return void 0;
|
|
4757
|
+
const first = rawBrokerName.trim().split(/[ _-]/, 1)[0]?.trim() ?? "";
|
|
4758
|
+
return first.length > 0 ? first : void 0;
|
|
4759
|
+
}
|
|
4760
|
+
var useBadgeBySymbol = (symbol) => {
|
|
4761
|
+
const symbolsInfo = useSymbolsInfo();
|
|
4762
|
+
const [brokers] = useAllBrokers();
|
|
4763
|
+
return useMemo(() => {
|
|
4764
|
+
if (!symbol || symbolsInfo.isNil) {
|
|
4765
|
+
return {
|
|
4766
|
+
displayName: symbol ?? "",
|
|
4767
|
+
brokerId: void 0,
|
|
4768
|
+
brokerName: void 0,
|
|
4769
|
+
brokerNameRaw: void 0
|
|
4770
|
+
};
|
|
4771
|
+
}
|
|
4772
|
+
const getter = symbolsInfo[symbol];
|
|
4773
|
+
const info = typeof getter === "function" ? getter() : void 0;
|
|
4774
|
+
const displayName = info?.displayName ?? info?.display_symbol_name ?? symbol;
|
|
4775
|
+
const brokerId = info?.broker_id ?? void 0;
|
|
4776
|
+
const rawBrokerName = brokerId ? brokers?.[brokerId] : void 0;
|
|
4777
|
+
const base = brokerNameBaseFromRaw(rawBrokerName);
|
|
4778
|
+
const brokerName = base ? base.length > 7 ? `${base.slice(0, 7)}...` : base : void 0;
|
|
4779
|
+
return {
|
|
4780
|
+
displayName,
|
|
4781
|
+
brokerId,
|
|
4782
|
+
brokerName,
|
|
4783
|
+
brokerNameRaw: rawBrokerName
|
|
4784
|
+
};
|
|
4785
|
+
}, [brokers, symbolsInfo, symbol]);
|
|
4786
|
+
};
|
|
4787
|
+
function formatSymbolWithBroker(symbol, symbolsInfo, brokers) {
|
|
4788
|
+
if (!symbol) return "";
|
|
4789
|
+
let brokerNameBase;
|
|
4790
|
+
if (!symbolsInfo.isNil) {
|
|
4791
|
+
const getter = symbolsInfo[symbol];
|
|
4792
|
+
const info = typeof getter === "function" ? getter() : void 0;
|
|
4793
|
+
const brokerId = info?.broker_id ?? void 0;
|
|
4794
|
+
const rawBrokerName = brokerId ? brokers?.[brokerId] : void 0;
|
|
4795
|
+
brokerNameBase = brokerNameBaseFromRaw(rawBrokerName);
|
|
4796
|
+
}
|
|
4797
|
+
const parts = symbol.split("_");
|
|
4798
|
+
const base = parts.length >= 3 ? parts[1] ?? "" : symbol.match(/^([A-Za-z]+)/)?.[1] ?? symbol;
|
|
4799
|
+
const hasBrokerSuffix = symbol.includes("-") || symbol.split("_").length > 3;
|
|
4800
|
+
if (brokerNameBase && hasBrokerSuffix) {
|
|
4801
|
+
return `${base}-${brokerNameBase}`;
|
|
4802
|
+
}
|
|
4803
|
+
return base;
|
|
4804
|
+
}
|
|
4805
|
+
var useSymbolWithBroker = (symbol) => {
|
|
4806
|
+
const symbolsInfo = useSymbolsInfo();
|
|
4807
|
+
const [brokers] = useAllBrokers();
|
|
4808
|
+
return useMemo(
|
|
4809
|
+
() => formatSymbolWithBroker(symbol, symbolsInfo, brokers),
|
|
4810
|
+
[brokers, symbolsInfo, symbol]
|
|
4811
|
+
);
|
|
4812
|
+
};
|
|
4813
|
+
|
|
4814
|
+
// src/orderly/useMarginModes.ts
|
|
4731
4815
|
var useMarginModes = () => {
|
|
4732
4816
|
const { data, error, isLoading, mutate: mutate6 } = usePrivateQuery("/v1/client/margin_modes", {
|
|
4733
4817
|
revalidateOnFocus: false,
|
|
@@ -4769,22 +4853,28 @@ var useMarginModes = () => {
|
|
|
4769
4853
|
};
|
|
4770
4854
|
var useMarginModeBySymbol = (symbol, fallback = MarginMode.CROSS) => {
|
|
4771
4855
|
const { marginModes, isLoading, error, refresh, updateMarginMode } = useMarginModes();
|
|
4772
|
-
const
|
|
4856
|
+
const { brokerId } = useBadgeBySymbol(symbol);
|
|
4857
|
+
const marginMode = useMemo(() => {
|
|
4858
|
+
if (brokerId) return MarginMode.ISOLATED;
|
|
4859
|
+
return fallback === null ? marginModes[symbol] : marginModes[symbol] ?? fallback;
|
|
4860
|
+
}, [brokerId, fallback, marginModes, symbol]);
|
|
4773
4861
|
const update = useCallback(
|
|
4774
4862
|
async (mode) => {
|
|
4863
|
+
if (brokerId) mode = MarginMode.ISOLATED;
|
|
4775
4864
|
return updateMarginMode({
|
|
4776
4865
|
symbol_list: [symbol],
|
|
4777
4866
|
default_margin_mode: mode
|
|
4778
4867
|
});
|
|
4779
4868
|
},
|
|
4780
|
-
[symbol, updateMarginMode]
|
|
4869
|
+
[brokerId, symbol, updateMarginMode]
|
|
4781
4870
|
);
|
|
4782
4871
|
return {
|
|
4783
4872
|
marginMode,
|
|
4784
4873
|
isLoading,
|
|
4785
4874
|
error,
|
|
4786
4875
|
refresh,
|
|
4787
|
-
update
|
|
4876
|
+
update,
|
|
4877
|
+
isPermissionlessListing: !!brokerId
|
|
4788
4878
|
};
|
|
4789
4879
|
};
|
|
4790
4880
|
|
|
@@ -12686,6 +12776,9 @@ var DataPaint = class extends BasePaint {
|
|
|
12686
12776
|
this.DEFAULT_LOSS_COLOR = "rgb(255,103,194)";
|
|
12687
12777
|
this.transformTop = 0;
|
|
12688
12778
|
this.QRCODE_SIZE = 56;
|
|
12779
|
+
this.BROKER_BADGE_HEIGHT = 18;
|
|
12780
|
+
this.BROKER_BADGE_PADDING_X = 8;
|
|
12781
|
+
this.BROKER_BADGE_RADIUS = 4;
|
|
12689
12782
|
}
|
|
12690
12783
|
formatMarginMode(marginMode) {
|
|
12691
12784
|
return marginMode === MarginMode.ISOLATED ? "Isolated" : "Cross";
|
|
@@ -12775,6 +12868,49 @@ var DataPaint = class extends BasePaint {
|
|
|
12775
12868
|
fontSize: this._ratio(fontSize),
|
|
12776
12869
|
fontFamily: options.fontFamily
|
|
12777
12870
|
});
|
|
12871
|
+
const brokerName = options.data?.position.brokerName?.trim();
|
|
12872
|
+
if (brokerName) {
|
|
12873
|
+
left += (prevElementBoundingBox.width ?? 0) + this._ratio(10);
|
|
12874
|
+
const badgeHeight = this._ratio(this.BROKER_BADGE_HEIGHT);
|
|
12875
|
+
const badgePaddingX = this._ratio(this.BROKER_BADGE_PADDING_X);
|
|
12876
|
+
const badgeRadius = this._ratio(this.BROKER_BADGE_RADIUS);
|
|
12877
|
+
const badgeFontSize = this._ratio(12);
|
|
12878
|
+
const badgeFontWeight = 600;
|
|
12879
|
+
const textMetrics = this._drawText(
|
|
12880
|
+
brokerName,
|
|
12881
|
+
{
|
|
12882
|
+
left: 0,
|
|
12883
|
+
top: 0,
|
|
12884
|
+
fontSize: badgeFontSize,
|
|
12885
|
+
fontWeight: badgeFontWeight,
|
|
12886
|
+
fontFamily: options.fontFamily
|
|
12887
|
+
},
|
|
12888
|
+
true
|
|
12889
|
+
);
|
|
12890
|
+
const badgeWidth = (textMetrics.width ?? 0) + badgePaddingX * 2;
|
|
12891
|
+
const badgeTop = this._ratio(top) - badgeHeight / 2;
|
|
12892
|
+
this._fillRoundedRect(
|
|
12893
|
+
left,
|
|
12894
|
+
badgeTop,
|
|
12895
|
+
badgeWidth,
|
|
12896
|
+
badgeHeight,
|
|
12897
|
+
badgeRadius,
|
|
12898
|
+
"rgba(255,255,255,0.06)"
|
|
12899
|
+
);
|
|
12900
|
+
this._drawText(brokerName, {
|
|
12901
|
+
color: "rgba(255,255,255,0.36)",
|
|
12902
|
+
left: left + badgePaddingX,
|
|
12903
|
+
top: badgeTop + badgeHeight / 2,
|
|
12904
|
+
fontSize: badgeFontSize,
|
|
12905
|
+
fontWeight: badgeFontWeight,
|
|
12906
|
+
fontFamily: options.fontFamily,
|
|
12907
|
+
textBaseline: "middle"
|
|
12908
|
+
});
|
|
12909
|
+
prevElementBoundingBox = {
|
|
12910
|
+
...prevElementBoundingBox,
|
|
12911
|
+
width: badgeWidth
|
|
12912
|
+
};
|
|
12913
|
+
}
|
|
12778
12914
|
}
|
|
12779
12915
|
const marginMode = options.data?.position.marginMode;
|
|
12780
12916
|
if (marginMode) {
|
|
@@ -12822,6 +12958,20 @@ var DataPaint = class extends BasePaint {
|
|
|
12822
12958
|
);
|
|
12823
12959
|
}
|
|
12824
12960
|
}
|
|
12961
|
+
_fillRoundedRect(x, y, width, height, radius, color) {
|
|
12962
|
+
const r = Math.min(radius, width / 2, height / 2);
|
|
12963
|
+
this.ctx.save();
|
|
12964
|
+
this.ctx.fillStyle = color;
|
|
12965
|
+
this.ctx.beginPath();
|
|
12966
|
+
this.ctx.moveTo(x + r, y);
|
|
12967
|
+
this.ctx.arcTo(x + width, y, x + width, y + height, r);
|
|
12968
|
+
this.ctx.arcTo(x + width, y + height, x, y + height, r);
|
|
12969
|
+
this.ctx.arcTo(x, y + height, x, y, r);
|
|
12970
|
+
this.ctx.arcTo(x, y, x + width, y, r);
|
|
12971
|
+
this.ctx.closePath();
|
|
12972
|
+
this.ctx.fill();
|
|
12973
|
+
this.ctx.restore();
|
|
12974
|
+
}
|
|
12825
12975
|
drawUnrealizedPnL(options, offsetTop = 0) {
|
|
12826
12976
|
const layout = path(
|
|
12827
12977
|
["layout", "unrealizedPnl"],
|
|
@@ -13275,18 +13425,6 @@ var useEpochInfo = (type) => {
|
|
|
13275
13425
|
}, [epochInfo]);
|
|
13276
13426
|
return [epochInfo, { isLoading, curEpochInfo, isNotStared, refresh }];
|
|
13277
13427
|
};
|
|
13278
|
-
|
|
13279
|
-
// src/trading-rewards/useAllBrokers.ts
|
|
13280
|
-
var useAllBrokers = () => {
|
|
13281
|
-
const { data } = useQuery("/v1/public/broker/name", {
|
|
13282
|
-
formatter: (res) => {
|
|
13283
|
-
const { rows } = res;
|
|
13284
|
-
return rows?.map((item) => ({ [item.broker_id]: item.broker_name })).reduce((acc, curr) => ({ ...acc, ...curr }), {});
|
|
13285
|
-
},
|
|
13286
|
-
revalidateOnFocus: false
|
|
13287
|
-
});
|
|
13288
|
-
return [data];
|
|
13289
|
-
};
|
|
13290
13428
|
var useCurEpochEstimate = (type) => {
|
|
13291
13429
|
const [data, setData] = useState(void 0);
|
|
13292
13430
|
const { account: account9 } = useAccount();
|
|
@@ -18642,6 +18780,19 @@ var useOrderEntryNextInternal = (symbol, options = {}) => {
|
|
|
18642
18780
|
orderEntryActions.updateOrder(newValues);
|
|
18643
18781
|
return newValues;
|
|
18644
18782
|
};
|
|
18783
|
+
const setValuesRaw = (values) => {
|
|
18784
|
+
if (!symbolInfo) {
|
|
18785
|
+
orderEntryActions.updateOrder(values);
|
|
18786
|
+
return;
|
|
18787
|
+
}
|
|
18788
|
+
const currentEntry = useOrderStore.getState().entry;
|
|
18789
|
+
const newValues = {
|
|
18790
|
+
...currentEntry,
|
|
18791
|
+
...values
|
|
18792
|
+
};
|
|
18793
|
+
orderEntryActions.updateOrder(newValues);
|
|
18794
|
+
return newValues;
|
|
18795
|
+
};
|
|
18645
18796
|
const onMarkPriceUpdated = useCallback(
|
|
18646
18797
|
(markPrice, baseOn = []) => {
|
|
18647
18798
|
if (!options.symbolInfo) return;
|
|
@@ -18705,6 +18856,7 @@ var useOrderEntryNextInternal = (symbol, options = {}) => {
|
|
|
18705
18856
|
formattedOrder: orderEntity,
|
|
18706
18857
|
setValue,
|
|
18707
18858
|
setValues,
|
|
18859
|
+
setValuesRaw,
|
|
18708
18860
|
submit: submitOrder,
|
|
18709
18861
|
reset: resetOrder,
|
|
18710
18862
|
generateOrder,
|
|
@@ -18720,6 +18872,8 @@ var useOrderEntry2 = (symbol, options = {}) => {
|
|
|
18720
18872
|
}
|
|
18721
18873
|
const ee = useEventEmitter();
|
|
18722
18874
|
const { track: track2 } = useTrack();
|
|
18875
|
+
const apiBaseUrl = useConfig("apiBaseUrl");
|
|
18876
|
+
const fetchSymbols = useSymbolStore((state) => state.fetchData);
|
|
18723
18877
|
const [meta, setMeta] = useState({
|
|
18724
18878
|
dirty: {},
|
|
18725
18879
|
submitted: false,
|
|
@@ -18749,6 +18903,7 @@ var useOrderEntry2 = (symbol, options = {}) => {
|
|
|
18749
18903
|
formattedOrder,
|
|
18750
18904
|
setValue: setValueInternal,
|
|
18751
18905
|
setValues: setValuesInternal,
|
|
18906
|
+
setValuesRaw: setValuesRawInternal,
|
|
18752
18907
|
validate,
|
|
18753
18908
|
generateOrder,
|
|
18754
18909
|
reset,
|
|
@@ -18948,6 +19103,21 @@ var useOrderEntry2 = (symbol, options = {}) => {
|
|
|
18948
19103
|
interactiveValidate(newValues);
|
|
18949
19104
|
}
|
|
18950
19105
|
};
|
|
19106
|
+
const setValuesRaw = (values) => {
|
|
19107
|
+
if (!Object.keys(values).every(
|
|
19108
|
+
(key) => canSetTPSLPrice(
|
|
19109
|
+
key,
|
|
19110
|
+
values[key],
|
|
19111
|
+
formattedOrder.order_type
|
|
19112
|
+
)
|
|
19113
|
+
)) {
|
|
19114
|
+
return;
|
|
19115
|
+
}
|
|
19116
|
+
const newValues = setValuesRawInternal(values);
|
|
19117
|
+
if (newValues) {
|
|
19118
|
+
interactiveValidate(newValues);
|
|
19119
|
+
}
|
|
19120
|
+
};
|
|
18951
19121
|
async function validateFunc(order) {
|
|
18952
19122
|
const creator = getOrderCreator(order);
|
|
18953
19123
|
return validate(order, creator, prepareData());
|
|
@@ -19002,7 +19172,7 @@ var useOrderEntry2 = (symbol, options = {}) => {
|
|
|
19002
19172
|
markPrice: markPrice2,
|
|
19003
19173
|
totalCollateral,
|
|
19004
19174
|
futures_taker_fee_rate: accountInfo.futures_taker_fee_rate,
|
|
19005
|
-
imr_factor: accountInfo.imr_factor[symbol],
|
|
19175
|
+
imr_factor: accountInfo.imr_factor?.[symbol] ?? 0,
|
|
19006
19176
|
symbol,
|
|
19007
19177
|
positions: positions3,
|
|
19008
19178
|
symbolInfo,
|
|
@@ -19091,6 +19261,9 @@ var useOrderEntry2 = (symbol, options = {}) => {
|
|
|
19091
19261
|
orders: appendOrderMetadata(order.orders, orderMetadata)
|
|
19092
19262
|
} : appendOrderMetadata(order, orderMetadata);
|
|
19093
19263
|
const result = await doCreateOrder(params);
|
|
19264
|
+
if (!result.success && (order.order_type === OrderType.MARKET || order.order_type === OrderType.STOP_MARKET)) {
|
|
19265
|
+
void fetchSymbols(apiBaseUrl);
|
|
19266
|
+
}
|
|
19094
19267
|
if (result.success) {
|
|
19095
19268
|
let trackParams = {
|
|
19096
19269
|
side: order.side,
|
|
@@ -19157,6 +19330,7 @@ var useOrderEntry2 = (symbol, options = {}) => {
|
|
|
19157
19330
|
freeCollateral: effectiveMarginMode === MarginMode.ISOLATED ? freeCollateralUSDCOnly : freeCollateral,
|
|
19158
19331
|
setValue: useMemoizedFn(setValue),
|
|
19159
19332
|
setValues: useMemoizedFn(setValues),
|
|
19333
|
+
setValuesRaw: useMemoizedFn(setValuesRaw),
|
|
19160
19334
|
symbolInfo: symbolInfo || EMPTY_OBJECT,
|
|
19161
19335
|
metaState: meta,
|
|
19162
19336
|
isMutating,
|
|
@@ -19613,6 +19787,6 @@ var FlagKeys = /* @__PURE__ */ ((FlagKeys2) => {
|
|
|
19613
19787
|
return FlagKeys2;
|
|
19614
19788
|
})(FlagKeys || {});
|
|
19615
19789
|
|
|
19616
|
-
export { DefaultLayoutConfig, DistributionId, ENVType2 as ENVType, ERROR_MSG_CODES, EpochStatus, ExtendedConfigStore, FlagKeys, MaintenanceStatus, MarketsStorageKey, MarketsType, ORDERLY_ORDERBOOK_DEPTH_KEY, OrderlyConfigProvider, OrderlyContext, OrderlyProvider, StatusProvider, TWType, WalletConnectorContext, WsNetworkStatus, checkNotional, cleanStringStyle, fetcher, findPositionTPSLFromOrders, findTPSLFromOrder, findTPSLOrderPriceFromOrder, getMinNotional, getPriceKey, indexedDBManager, initializeAppDatabase, isCurrentlyClosed, isCurrentlyTrading, noCacheConfig, parseJSON, persistIndexedDB, resetTimestampOffsetState, timestampWaitingMiddleware, useAccount, useAccountInfo2 as useAccountInfo, useAccountInstance, useAccountRewardsHistory, useAllBrokers, useApiKeyManager, useAppStore, useAssetsHistory, useAudioPlayer, useBalanceSubscription, useBalanceTopic, useBoolean, useChain, useChainInfo, useChains, useCheckReferralCode, useCollateral, useCommission, useComputedLTV, useConfig, useConvert, useCurEpochEstimate, useDaily, useDeposit, useDistribution, useDistributionHistory, useEpochInfo, useEstLiqPriceBySymbol, useEventEmitter, useFeatureFlag, useFeeState, useFundingDetails, useFundingFeeHistory, useFundingRate, useFundingRateBySymbol, useFundingRateHistory, useFundingRates, useFundingRatesStore, useGetClaimed, useGetEnv, useGetEstLiqPrice, useGetReferralCode, useGetRwaSymbolCloseTimeInterval, useGetRwaSymbolInfo, useGetRwaSymbolOpenStatus, useGetRwaSymbolOpenTimeInterval, useHoldingStream, useIndexPrice, useIndexPricesStream, useInfiniteQuery, useInitRwaSymbolsRuntime, useInternalTransfer, useKeyStore, useLazyQuery, useLeverage, useLeverageBySymbol, useLocalStorage, useMainTokenStore, useMainnetChainsStore, useMaintenanceStatus, useMarginModeBySymbol, useMarginModes, useMarginRatio, useMarkPrice, useMarkPriceBySymbol, useMarkPricesStream, useMarket, useMarketList, useMarketMap, useMarketTradeStream, useMarkets, useMarketsStore, useMarketsStream, useMaxLeverage, useMaxQty, useMaxWithdrawal, useMediaQuery, useMemoizedFn, useMutation, useNetworkInfo, useOdosQuote, useOrderEntity, useOrderEntry2 as useOrderEntry, useOrderEntry as useOrderEntry_deprecated, useOrderStore, useOrderStream, useOrderbookStream, useOrderlyContext, usePortfolio, usePositionActions, usePositionClose, usePositionStream, usePositions, usePoster, usePreLoadData, usePrivateDataObserver, usePrivateInfiniteQuery, usePrivateQuery, useQuery, useRefereeHistory, useRefereeInfo, useRefereeRebateSummary, useReferralInfo, useReferralRebateSummary, useRestrictedInfo, useRwaSymbolsInfo, useRwaSymbolsInfoStore, useSessionStorage, useSettleSubscription, useSimpleDI, useStatisticsDaily, useStorageChain, useStorageLedgerAddress, useSubAccountAlgoOrderStream, useSubAccountDataObserver, useSubAccountMaxWithdrawal, useSubAccountMutation, useSubAccountQuery, useSubAccountWS, useSwapSupportStore, useSymbolInfo, useSymbolLeverage, useSymbolLeverageMap, useSymbolPriceRange, useSymbolsInfo, useSymbolsInfoStore, useTPSLOrder, useTestTokenStore, useTestnetChainsStore, useTickerStream, useTokenInfo, useTokensInfo, useTpslPriceChecker, useTrack, useTrackingInstance, useTradingRewardsStatus, useTransfer, useTransferHistory, useUpdatedRef, useUserStatistics, useVaultsHistory, useWS, useWalletConnector, useWalletRewardsHistory, useWalletSubscription, useWalletTopic, useWithdraw, useWsStatus, utils_exports as utils, version_default as version };
|
|
19790
|
+
export { DefaultLayoutConfig, DistributionId, ENVType2 as ENVType, ERROR_MSG_CODES, EpochStatus, ExtendedConfigStore, FlagKeys, MaintenanceStatus, MarketCategoriesConfigProvider, MarketsStorageKey, MarketsType, ORDERLY_ORDERBOOK_DEPTH_KEY, OrderlyConfigProvider, OrderlyContext, OrderlyProvider, StatusProvider, TWType, WalletConnectorContext, WsNetworkStatus, checkNotional, cleanStringStyle, fetcher, findPositionTPSLFromOrders, findTPSLFromOrder, findTPSLOrderPriceFromOrder, formatSymbolWithBroker, getMinNotional, getPriceKey, indexedDBManager, initializeAppDatabase, isCurrentlyClosed, isCurrentlyTrading, noCacheConfig, parseJSON, persistIndexedDB, resetTimestampOffsetState, timestampWaitingMiddleware, useAccount, useAccountInfo2 as useAccountInfo, useAccountInstance, useAccountRewardsHistory, useAllBrokers, useApiKeyManager, useAppStore, useAssetsHistory, useAudioPlayer, useBadgeBySymbol, useBalanceSubscription, useBalanceTopic, useBoolean, useChain, useChainInfo, useChains, useCheckReferralCode, useCollateral, useCommission, useComputedLTV, useConfig, useConvert, useCurEpochEstimate, useDaily, useDeposit, useDistribution, useDistributionHistory, useEpochInfo, useEstLiqPriceBySymbol, useEventEmitter, useFeatureFlag, useFeeState, useFundingDetails, useFundingFeeHistory, useFundingRate, useFundingRateBySymbol, useFundingRateHistory, useFundingRates, useFundingRatesStore, useGetClaimed, useGetEnv, useGetEstLiqPrice, useGetReferralCode, useGetRwaSymbolCloseTimeInterval, useGetRwaSymbolInfo, useGetRwaSymbolOpenStatus, useGetRwaSymbolOpenTimeInterval, useHoldingStream, useIndexPrice, useIndexPricesStream, useInfiniteQuery, useInitRwaSymbolsRuntime, useInternalTransfer, useKeyStore, useLazyQuery, useLeverage, useLeverageBySymbol, useLocalStorage, useMainTokenStore, useMainnetChainsStore, useMaintenanceStatus, useMarginModeBySymbol, useMarginModes, useMarginRatio, useMarkPrice, useMarkPriceBySymbol, useMarkPricesStream, useMarket, useMarketCategoriesConfig, useMarketList, useMarketMap, useMarketTradeStream, useMarkets, useMarketsStore, useMarketsStream, useMaxLeverage, useMaxQty, useMaxWithdrawal, useMediaQuery, useMemoizedFn, useMutation, useNetworkInfo, useOdosQuote, useOrderEntity, useOrderEntry2 as useOrderEntry, useOrderEntry as useOrderEntry_deprecated, useOrderStore, useOrderStream, useOrderbookStream, useOrderlyContext, usePortfolio, usePositionActions, usePositionClose, usePositionStream, usePositions, usePoster, usePreLoadData, usePrivateDataObserver, usePrivateInfiniteQuery, usePrivateQuery, useQuery, useRefereeHistory, useRefereeInfo, useRefereeRebateSummary, useReferralInfo, useReferralRebateSummary, useRestrictedInfo, useRwaSymbolsInfo, useRwaSymbolsInfoStore, useSessionStorage, useSettleSubscription, useSimpleDI, useStatisticsDaily, useStorageChain, useStorageLedgerAddress, useSubAccountAlgoOrderStream, useSubAccountDataObserver, useSubAccountMaxWithdrawal, useSubAccountMutation, useSubAccountQuery, useSubAccountWS, useSwapSupportStore, useSymbolInfo, useSymbolLeverage, useSymbolLeverageMap, useSymbolPriceRange, useSymbolWithBroker, useSymbolsInfo, useSymbolsInfoStore, useTPSLOrder, useTestTokenStore, useTestnetChainsStore, useTickerStream, useTokenInfo, useTokensInfo, useTpslPriceChecker, useTrack, useTrackingInstance, useTradingRewardsStatus, useTransfer, useTransferHistory, useUpdatedRef, useUserStatistics, useVaultsHistory, useWS, useWalletConnector, useWalletRewardsHistory, useWalletSubscription, useWalletTopic, useWithdraw, useWsStatus, utils_exports as utils, version_default as version };
|
|
19617
19791
|
//# sourceMappingURL=index.mjs.map
|
|
19618
19792
|
//# sourceMappingURL=index.mjs.map
|