@orderly.network/hooks 1.0.28-alpha.26 → 1.0.28-alpha.27
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 +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +38 -44
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +38 -44
- package/dist/index.mjs.map +1 -1
- package/package.json +7 -7
package/dist/index.d.mts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -28,9 +28,9 @@ var useSWRSubscription__default = /*#__PURE__*/_interopDefault(useSWRSubscriptio
|
|
|
28
28
|
// src/version.ts
|
|
29
29
|
if (typeof window !== "undefined") {
|
|
30
30
|
window.__ORDERLY_VERSION__ = window.__ORDERLY_VERSION__ || {};
|
|
31
|
-
window.__ORDERLY_VERSION__["@orderly.network/hooks"] = "1.0.28-alpha.
|
|
31
|
+
window.__ORDERLY_VERSION__["@orderly.network/hooks"] = "1.0.28-alpha.27";
|
|
32
32
|
}
|
|
33
|
-
var version_default = "1.0.28-alpha.
|
|
33
|
+
var version_default = "1.0.28-alpha.27";
|
|
34
34
|
var fetcher = (url, init = {}, queryOptions) => net.get(url, init, queryOptions?.formatter);
|
|
35
35
|
var OrderlyContext = React.createContext({
|
|
36
36
|
// configStore: new MemoryConfigStore(),
|
|
@@ -1993,32 +1993,26 @@ var LimitOrderCreator = class extends BaseOrderCreator {
|
|
|
1993
1993
|
price_scope,
|
|
1994
1994
|
side
|
|
1995
1995
|
);
|
|
1996
|
-
|
|
1996
|
+
const priceRange = side === "BUY" ? {
|
|
1997
|
+
min: scropePriceNumbere,
|
|
1998
|
+
max: maxPriceNumber
|
|
1999
|
+
} : {
|
|
2000
|
+
min: minPriceNumber,
|
|
2001
|
+
max: scropePriceNumbere
|
|
2002
|
+
};
|
|
2003
|
+
if (price.gt(priceRange.max)) {
|
|
1997
2004
|
errors.order_price = {
|
|
1998
2005
|
type: "max",
|
|
1999
2006
|
message: `price must be less than ${new utils.Decimal(
|
|
2000
|
-
|
|
2001
|
-
).todp(symbol.quote_dp)}`
|
|
2002
|
-
};
|
|
2003
|
-
} else if (side === types.OrderSide.BUY && price.lt(scropePriceNumbere)) {
|
|
2004
|
-
errors.order_price = {
|
|
2005
|
-
type: "max",
|
|
2006
|
-
message: `price must be more than ${new utils.Decimal(
|
|
2007
|
-
scropePriceNumbere
|
|
2007
|
+
priceRange.max
|
|
2008
2008
|
).todp(symbol.quote_dp)}`
|
|
2009
2009
|
};
|
|
2010
|
-
}
|
|
2011
|
-
|
|
2012
|
-
type: "min",
|
|
2013
|
-
message: `price must be greater than ${new utils.Decimal(
|
|
2014
|
-
minPriceNumber
|
|
2015
|
-
).todp(symbol.quote_dp)}`
|
|
2016
|
-
};
|
|
2017
|
-
} else if (side === types.OrderSide.SELL && price.gt(scropePriceNumbere)) {
|
|
2010
|
+
}
|
|
2011
|
+
if (price.lt(priceRange.min)) {
|
|
2018
2012
|
errors.order_price = {
|
|
2019
2013
|
type: "min",
|
|
2020
|
-
message: `price must be
|
|
2021
|
-
|
|
2014
|
+
message: `price must be more than ${new utils.Decimal(
|
|
2015
|
+
priceRange.min
|
|
2022
2016
|
).todp(symbol.quote_dp)}`
|
|
2023
2017
|
};
|
|
2024
2018
|
}
|
|
@@ -2083,36 +2077,30 @@ var StopLimitOrderCreator = class extends LimitOrderCreator {
|
|
|
2083
2077
|
const maxPriceNumber = maxPrice(config.markPrice, price_range);
|
|
2084
2078
|
const minPriceNumber = minPrice(config.markPrice, price_range);
|
|
2085
2079
|
const scropePriceNumbere = scropePrice(
|
|
2086
|
-
|
|
2080
|
+
trigger_price,
|
|
2087
2081
|
price_scope,
|
|
2088
2082
|
side
|
|
2089
2083
|
);
|
|
2090
|
-
|
|
2084
|
+
const priceRange = side === "BUY" ? {
|
|
2085
|
+
min: scropePriceNumbere,
|
|
2086
|
+
max: maxPriceNumber
|
|
2087
|
+
} : {
|
|
2088
|
+
min: minPriceNumber,
|
|
2089
|
+
max: scropePriceNumbere
|
|
2090
|
+
};
|
|
2091
|
+
if (price.gt(priceRange.max)) {
|
|
2091
2092
|
errors.order_price = {
|
|
2092
2093
|
type: "max",
|
|
2093
2094
|
message: `price must be less than ${new utils.Decimal(
|
|
2094
|
-
|
|
2095
|
+
priceRange.max
|
|
2095
2096
|
).todp(symbol.quote_dp)}`
|
|
2096
2097
|
};
|
|
2097
|
-
}
|
|
2098
|
-
|
|
2099
|
-
type: "max",
|
|
2100
|
-
message: `price must be more than ${new utils.Decimal(
|
|
2101
|
-
scropePriceNumbere
|
|
2102
|
-
).todp(symbol.quote_dp)}`
|
|
2103
|
-
};
|
|
2104
|
-
} else if (side === types.OrderSide.SELL && price.lt(minPriceNumber)) {
|
|
2105
|
-
errors.order_price = {
|
|
2106
|
-
type: "min",
|
|
2107
|
-
message: `price must be greater than ${new utils.Decimal(
|
|
2108
|
-
minPriceNumber
|
|
2109
|
-
).todp(symbol.quote_dp)}`
|
|
2110
|
-
};
|
|
2111
|
-
} else if (side === types.OrderSide.SELL && price.gt(scropePriceNumbere)) {
|
|
2098
|
+
}
|
|
2099
|
+
if (price.lt(priceRange.min)) {
|
|
2112
2100
|
errors.order_price = {
|
|
2113
2101
|
type: "min",
|
|
2114
|
-
message: `price must be
|
|
2115
|
-
|
|
2102
|
+
message: `price must be more than ${new utils.Decimal(
|
|
2103
|
+
priceRange.min
|
|
2116
2104
|
).todp(symbol.quote_dp)}`
|
|
2117
2105
|
};
|
|
2118
2106
|
}
|
|
@@ -2266,7 +2254,7 @@ function useOrderEntry(symbolOrOrder, sideOrOptions, reduceOnly, options) {
|
|
|
2266
2254
|
const k = keys[i];
|
|
2267
2255
|
let preveValue = prev[k];
|
|
2268
2256
|
let currentValue = current[k];
|
|
2269
|
-
if (
|
|
2257
|
+
if (typeof preveValue === "undefined" && typeof currentValue === "undefined")
|
|
2270
2258
|
continue;
|
|
2271
2259
|
if (preveValue !== currentValue) {
|
|
2272
2260
|
key = k;
|
|
@@ -2337,7 +2325,8 @@ function useOrderEntry(symbolOrOrder, sideOrOptions, reduceOnly, options) {
|
|
|
2337
2325
|
});
|
|
2338
2326
|
return doCreateOrder(
|
|
2339
2327
|
ramda.omit(["order_type_ext"], {
|
|
2340
|
-
...values,
|
|
2328
|
+
// ...values,
|
|
2329
|
+
...ramda.omit(["order_price"], values),
|
|
2341
2330
|
...data2
|
|
2342
2331
|
})
|
|
2343
2332
|
).then((res) => {
|
|
@@ -2434,6 +2423,8 @@ function useOrderEntry(symbolOrOrder, sideOrOptions, reduceOnly, options) {
|
|
|
2434
2423
|
markPrice
|
|
2435
2424
|
]);
|
|
2436
2425
|
React.useEffect(() => {
|
|
2426
|
+
if (!markPrice)
|
|
2427
|
+
return;
|
|
2437
2428
|
validator(formattedOrder)?.then((err) => {
|
|
2438
2429
|
setErrors(err);
|
|
2439
2430
|
});
|
|
@@ -2452,10 +2443,13 @@ function useOrderEntry(symbolOrOrder, sideOrOptions, reduceOnly, options) {
|
|
|
2452
2443
|
ee.off("orderbook_update", onOrderbookUpdate);
|
|
2453
2444
|
};
|
|
2454
2445
|
}, [optionsValue?.watchOrderbook]);
|
|
2446
|
+
React.useEffect(() => {
|
|
2447
|
+
askAndBid.current = [];
|
|
2448
|
+
}, [parsedData?.symbol]);
|
|
2455
2449
|
const getPriceAndQty = (symbolOrOrder2) => {
|
|
2456
2450
|
let quantity = Number(symbolOrOrder2.order_quantity);
|
|
2457
2451
|
const orderPrice = Number(symbolOrOrder2.order_price);
|
|
2458
|
-
if (isNaN(quantity) || quantity <= 0)
|
|
2452
|
+
if (isNaN(quantity) || quantity <= 0 || askAndBid.current.length === 0)
|
|
2459
2453
|
return null;
|
|
2460
2454
|
if ((symbolOrOrder2.order_type === types.OrderType.LIMIT || symbolOrOrder2.order_type === types.OrderType.STOP_LIMIT) && isNaN(orderPrice))
|
|
2461
2455
|
return null;
|