@orderly.network/ui-order-entry 3.1.12 → 3.2.0-alpha.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 +5 -5
- package/dist/index.d.ts +5 -5
- package/dist/index.js +46 -27
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +46 -27
- package/dist/index.mjs.map +1 -1
- package/package.json +13 -13
package/dist/index.d.mts
CHANGED
|
@@ -162,6 +162,7 @@ declare const useOrderEntryScript: (inputs: OrderEntryScriptInputs) => {
|
|
|
162
162
|
onBBOChange: (value: _orderly_network_types.BBOOrderType) => void;
|
|
163
163
|
toggleBBO: () => void;
|
|
164
164
|
currentLtv: number;
|
|
165
|
+
usdcBorrowLimit: number;
|
|
165
166
|
fillMiddleValue: () => void;
|
|
166
167
|
symbol: string;
|
|
167
168
|
soundAlert: any;
|
|
@@ -170,9 +171,7 @@ declare const useOrderEntryScript: (inputs: OrderEntryScriptInputs) => {
|
|
|
170
171
|
walletAddress: string | undefined;
|
|
171
172
|
isPermissionlessListing: boolean;
|
|
172
173
|
isSymbolPostOnly: boolean;
|
|
173
|
-
submit: (options?: {
|
|
174
|
-
resetOnSuccess?: boolean;
|
|
175
|
-
}) => Promise<{
|
|
174
|
+
submit: (options?: _orderly_network_hooks.SubmitOrderOptions) => Promise<{
|
|
176
175
|
success: boolean;
|
|
177
176
|
data: Record<string, any>;
|
|
178
177
|
timestamp: number;
|
|
@@ -191,8 +190,9 @@ declare const useOrderEntryScript: (inputs: OrderEntryScriptInputs) => {
|
|
|
191
190
|
estLeverage: number | null;
|
|
192
191
|
estSlippage: number | null;
|
|
193
192
|
helper: {
|
|
194
|
-
validator: () => Promise<
|
|
195
|
-
validate: (otherErrors?: _orderly_network_hooks.OrderValidationResult) => Promise<
|
|
193
|
+
validator: () => Promise<_orderly_network_types.OrderlyOrder>;
|
|
194
|
+
validate: (otherErrors?: _orderly_network_hooks.OrderValidationResult) => Promise<_orderly_network_types.OrderlyOrder>;
|
|
195
|
+
getProjectedUSDCBorrow: (order: Partial<_orderly_network_types.OrderlyOrder>) => number | null;
|
|
196
196
|
};
|
|
197
197
|
freeCollateral: number;
|
|
198
198
|
metaState: {
|
package/dist/index.d.ts
CHANGED
|
@@ -162,6 +162,7 @@ declare const useOrderEntryScript: (inputs: OrderEntryScriptInputs) => {
|
|
|
162
162
|
onBBOChange: (value: _orderly_network_types.BBOOrderType) => void;
|
|
163
163
|
toggleBBO: () => void;
|
|
164
164
|
currentLtv: number;
|
|
165
|
+
usdcBorrowLimit: number;
|
|
165
166
|
fillMiddleValue: () => void;
|
|
166
167
|
symbol: string;
|
|
167
168
|
soundAlert: any;
|
|
@@ -170,9 +171,7 @@ declare const useOrderEntryScript: (inputs: OrderEntryScriptInputs) => {
|
|
|
170
171
|
walletAddress: string | undefined;
|
|
171
172
|
isPermissionlessListing: boolean;
|
|
172
173
|
isSymbolPostOnly: boolean;
|
|
173
|
-
submit: (options?: {
|
|
174
|
-
resetOnSuccess?: boolean;
|
|
175
|
-
}) => Promise<{
|
|
174
|
+
submit: (options?: _orderly_network_hooks.SubmitOrderOptions) => Promise<{
|
|
176
175
|
success: boolean;
|
|
177
176
|
data: Record<string, any>;
|
|
178
177
|
timestamp: number;
|
|
@@ -191,8 +190,9 @@ declare const useOrderEntryScript: (inputs: OrderEntryScriptInputs) => {
|
|
|
191
190
|
estLeverage: number | null;
|
|
192
191
|
estSlippage: number | null;
|
|
193
192
|
helper: {
|
|
194
|
-
validator: () => Promise<
|
|
195
|
-
validate: (otherErrors?: _orderly_network_hooks.OrderValidationResult) => Promise<
|
|
193
|
+
validator: () => Promise<_orderly_network_types.OrderlyOrder>;
|
|
194
|
+
validate: (otherErrors?: _orderly_network_hooks.OrderValidationResult) => Promise<_orderly_network_types.OrderlyOrder>;
|
|
195
|
+
getProjectedUSDCBorrow: (order: Partial<_orderly_network_types.OrderlyOrder>) => number | null;
|
|
196
196
|
};
|
|
197
197
|
freeCollateral: number;
|
|
198
198
|
metaState: {
|
package/dist/index.js
CHANGED
|
@@ -611,9 +611,9 @@ var OrderConfirmDialog = (props) => {
|
|
|
611
611
|
const { t } = i18n.useTranslation();
|
|
612
612
|
const [{ rows: positions }] = hooks.usePositionStream(symbol);
|
|
613
613
|
const position = React3.useMemo(
|
|
614
|
-
() =>
|
|
615
|
-
(row) => row.symbol === symbol && row.margin_mode === orderMarginMode
|
|
616
|
-
)
|
|
614
|
+
() => positions?.find(
|
|
615
|
+
(row) => row.symbol === symbol && (row.margin_mode ?? types.MarginMode.CROSS) === (orderMarginMode ?? types.MarginMode.CROSS)
|
|
616
|
+
),
|
|
617
617
|
[positions, symbol, orderMarginMode]
|
|
618
618
|
);
|
|
619
619
|
const positionQty = position?.position_qty;
|
|
@@ -686,15 +686,17 @@ var OrderConfirmDialog = (props) => {
|
|
|
686
686
|
);
|
|
687
687
|
};
|
|
688
688
|
const renderTPSLQty = () => {
|
|
689
|
+
if (order.position_type === types.PositionType.FULL)
|
|
690
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { justify: "between", children: [
|
|
691
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { children: t("common.orderQty") }),
|
|
692
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { children: t("tpsl.entirePosition") })
|
|
693
|
+
] });
|
|
689
694
|
if (!positionQty || !order.order_quantity) {
|
|
690
695
|
return null;
|
|
691
696
|
}
|
|
692
|
-
|
|
693
|
-
if (order.position_type === types.PositionType.FULL) {
|
|
694
|
-
qty = qty.plus(new utils.Decimal(positionQty ?? 0));
|
|
695
|
-
}
|
|
697
|
+
const qty = new utils.Decimal(order.order_quantity);
|
|
696
698
|
return /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { justify: "between", children: [
|
|
697
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { children:
|
|
699
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { children: t("common.orderQty") }),
|
|
698
700
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
699
701
|
ui.Text.numeral,
|
|
700
702
|
{
|
|
@@ -1913,18 +1915,6 @@ var LTVRiskTooltipUI = (props) => {
|
|
|
1913
1915
|
}
|
|
1914
1916
|
);
|
|
1915
1917
|
};
|
|
1916
|
-
var useConvertThreshold = () => {
|
|
1917
|
-
const { data, error, isLoading } = hooks.useQuery(
|
|
1918
|
-
"/v1/public/auto_convert_threshold",
|
|
1919
|
-
{ errorRetryCount: 3 }
|
|
1920
|
-
);
|
|
1921
|
-
return {
|
|
1922
|
-
ltv_threshold: new utils.Decimal(data?.ltv_threshold ?? 0).mul(100).toNumber(),
|
|
1923
|
-
negative_usdc_threshold: data?.negative_usdc_threshold,
|
|
1924
|
-
isLoading,
|
|
1925
|
-
error
|
|
1926
|
-
};
|
|
1927
|
-
};
|
|
1928
1918
|
var useLTVTooltipScript = (marginMode) => {
|
|
1929
1919
|
const { isMobile } = ui.useScreen();
|
|
1930
1920
|
const { data: holdingList = [], isLoading: isHoldingLoading } = hooks.useHoldingStream();
|
|
@@ -1932,7 +1922,8 @@ var useLTVTooltipScript = (marginMode) => {
|
|
|
1932
1922
|
ltv_threshold,
|
|
1933
1923
|
negative_usdc_threshold,
|
|
1934
1924
|
isLoading: isThresholdLoading
|
|
1935
|
-
} = useConvertThreshold();
|
|
1925
|
+
} = hooks.useConvertThreshold();
|
|
1926
|
+
const ltvThresholdPercentage = new utils.Decimal(ltv_threshold ?? 0).mul(100).toNumber();
|
|
1936
1927
|
const tokensInfo = hooks.useAppStore((state) => state.tokensInfo);
|
|
1937
1928
|
const { getIndexPrice } = hooks.useIndexPricesStream();
|
|
1938
1929
|
const holdingData = holdingList.map((item) => {
|
|
@@ -1963,7 +1954,7 @@ var useLTVTooltipScript = (marginMode) => {
|
|
|
1963
1954
|
return {
|
|
1964
1955
|
holdingData,
|
|
1965
1956
|
isHoldingLoading,
|
|
1966
|
-
ltv_threshold,
|
|
1957
|
+
ltv_threshold: ltvThresholdPercentage,
|
|
1967
1958
|
negative_usdc_threshold,
|
|
1968
1959
|
isThresholdLoading,
|
|
1969
1960
|
currentLtv,
|
|
@@ -3363,6 +3354,7 @@ var LeverageBadge = (props) => {
|
|
|
3363
3354
|
const { enabled } = hooks.useFeatureFlag(hooks.FlagKeys.IsolatedMargin);
|
|
3364
3355
|
const marginMode = props.marginMode;
|
|
3365
3356
|
const isDisabled = !!disabled;
|
|
3357
|
+
const isMarginModeDisabled = isDisabled || !enabled;
|
|
3366
3358
|
const curLeverage = symbolLeverage ?? 1;
|
|
3367
3359
|
const showLeverageModal = () => {
|
|
3368
3360
|
if (isDisabled) return;
|
|
@@ -3375,7 +3367,7 @@ var LeverageBadge = (props) => {
|
|
|
3375
3367
|
});
|
|
3376
3368
|
};
|
|
3377
3369
|
const showMarginModeModal = () => {
|
|
3378
|
-
if (
|
|
3370
|
+
if (isMarginModeDisabled) {
|
|
3379
3371
|
return;
|
|
3380
3372
|
}
|
|
3381
3373
|
const modalId = isMobile ? MarginModeSwitchSheetId : MarginModeSwitchDialogId;
|
|
@@ -3402,11 +3394,11 @@ var LeverageBadge = (props) => {
|
|
|
3402
3394
|
"oui-flex oui-flex-1 oui-items-center oui-justify-center oui-gap-x-1",
|
|
3403
3395
|
"oui-px-3 oui-py-1.5",
|
|
3404
3396
|
"oui-text-xs oui-font-semibold oui-text-base-contrast-54",
|
|
3405
|
-
|
|
3397
|
+
isMarginModeDisabled ? "oui-cursor-not-allowed" : "oui-cursor-pointer"
|
|
3406
3398
|
),
|
|
3407
3399
|
"data-testid": "oui-testid-orderEntry-margin-mode",
|
|
3408
3400
|
"aria-label": t("marginMode.switchMarginMode"),
|
|
3409
|
-
disabled:
|
|
3401
|
+
disabled: isMarginModeDisabled,
|
|
3410
3402
|
onClick: showMarginModeModal,
|
|
3411
3403
|
children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { children: marginMode === void 0 ? "--" : marginMode === types.MarginMode.ISOLATED ? t("marginMode.isolated") : t("marginMode.cross") })
|
|
3412
3404
|
}
|
|
@@ -5700,7 +5692,8 @@ var OrderEntry = (props) => {
|
|
|
5700
5692
|
currentFocusInput,
|
|
5701
5693
|
walletAddress,
|
|
5702
5694
|
isPermissionlessListing,
|
|
5703
|
-
symbol
|
|
5695
|
+
symbol,
|
|
5696
|
+
usdcBorrowLimit
|
|
5704
5697
|
} = props;
|
|
5705
5698
|
const [maxQtyConfirmOpen, setMaxQtyConfirmOpen] = React3.useState(false);
|
|
5706
5699
|
const [selectedExtraId, setSelectedExtraId] = React3.useState(null);
|
|
@@ -5784,6 +5777,15 @@ var OrderEntry = (props) => {
|
|
|
5784
5777
|
return Promise.reject();
|
|
5785
5778
|
}
|
|
5786
5779
|
).then((order) => {
|
|
5780
|
+
const projectedBorrow = helper.getProjectedUSDCBorrow(order);
|
|
5781
|
+
if (projectedBorrow !== null && projectedBorrow > usdcBorrowLimit) {
|
|
5782
|
+
throw new hooks.USDCBorrowLimitExceededError(
|
|
5783
|
+
projectedBorrow,
|
|
5784
|
+
usdcBorrowLimit
|
|
5785
|
+
);
|
|
5786
|
+
}
|
|
5787
|
+
return order;
|
|
5788
|
+
}).then((order) => {
|
|
5787
5789
|
const shouldShowPermissionlessNotice = isPermissionlessListing && walletAddress && !(permissionlessAcknowledgedKeys ?? []).includes(
|
|
5788
5790
|
`${walletAddress}_${symbol}`
|
|
5789
5791
|
);
|
|
@@ -5815,7 +5817,10 @@ var OrderEntry = (props) => {
|
|
|
5815
5817
|
}
|
|
5816
5818
|
return true;
|
|
5817
5819
|
}).then(() => {
|
|
5818
|
-
return submit({
|
|
5820
|
+
return submit({
|
|
5821
|
+
resetOnSuccess: false,
|
|
5822
|
+
usdcBorrowLimit
|
|
5823
|
+
}).then((result) => {
|
|
5819
5824
|
if (!result.success && result.message) {
|
|
5820
5825
|
ui.toast.error(result.message);
|
|
5821
5826
|
} else if (result.success && isScaledOrder) {
|
|
@@ -5826,6 +5831,17 @@ var OrderEntry = (props) => {
|
|
|
5826
5831
|
}
|
|
5827
5832
|
});
|
|
5828
5833
|
}).catch((error) => {
|
|
5834
|
+
if (error instanceof hooks.USDCBorrowLimitExceededError) {
|
|
5835
|
+
ui.modal.alert({
|
|
5836
|
+
title: t("orderEntry.usdcBorrowLimit.title"),
|
|
5837
|
+
message: t("orderEntry.usdcBorrowLimit.content", {
|
|
5838
|
+
limit: new Intl.NumberFormat("en-US", {
|
|
5839
|
+
maximumFractionDigits: 8
|
|
5840
|
+
}).format(error.borrowLimit)
|
|
5841
|
+
})
|
|
5842
|
+
});
|
|
5843
|
+
return;
|
|
5844
|
+
}
|
|
5829
5845
|
if (error?.message) {
|
|
5830
5846
|
ui.toast.error(error.message);
|
|
5831
5847
|
}
|
|
@@ -6616,6 +6632,8 @@ var useOrderEntryScript = (inputs) => {
|
|
|
6616
6632
|
}
|
|
6617
6633
|
}, [isSymbolPostOnly, formattedOrder.order_type, setOrderValues]);
|
|
6618
6634
|
const currentLtv = hooks.useComputedLTV();
|
|
6635
|
+
const { negative_usdc_threshold } = hooks.useConvertThreshold();
|
|
6636
|
+
const usdcBorrowLimit = hooks.normalizeUSDCBorrowLimit(negative_usdc_threshold);
|
|
6619
6637
|
const askAndBid = useAskAndBid();
|
|
6620
6638
|
const fillMiddleValue = () => {
|
|
6621
6639
|
if (bboStatus === "on" /* ON */) {
|
|
@@ -6712,6 +6730,7 @@ var useOrderEntryScript = (inputs) => {
|
|
|
6712
6730
|
onBBOChange,
|
|
6713
6731
|
toggleBBO,
|
|
6714
6732
|
currentLtv,
|
|
6733
|
+
usdcBorrowLimit,
|
|
6715
6734
|
fillMiddleValue,
|
|
6716
6735
|
symbol,
|
|
6717
6736
|
soundAlert,
|