+ Pool limit exceeded. Max short size is{" "} + {formatBalance({ + balance: maxBondsOut || 0n, + decimals: hyperdrive.decimals, + })}{" "} + hy{baseToken.symbol} +
+ ); + } else { return (Insufficient balance
@@ -250,22 +265,34 @@ export function OpenShortForm({
You pay{" "}
- {formatBalance({
- balance: traderDeposit || 0n,
- decimals: activeToken.decimals,
- includeCommas: true,
- places: activeToken.places,
- })}{" "}
- {activeToken.symbol}
+ {openShortPreviewStatus === "loading" ? (
+ // make this an inline skeleton
+
+
- Pool limit exceeded. Max short size is{" "} - {formatBalance({ - balance: maxBondsOut || 0n, - decimals: hyperdrive.decimals, - })}{" "} - hy{baseToken.symbol} -
- ); - } })()} actionButton={(() => { if (!account) { diff --git a/apps/hyperdrive-trading/src/ui/hyperdrive/shorts/OpenShortPreview/OpenShortPreview.tsx b/apps/hyperdrive-trading/src/ui/hyperdrive/shorts/OpenShortPreview/OpenShortPreview.tsx index da46e593c..a450bd9db 100644 --- a/apps/hyperdrive-trading/src/ui/hyperdrive/shorts/OpenShortPreview/OpenShortPreview.tsx +++ b/apps/hyperdrive-trading/src/ui/hyperdrive/shorts/OpenShortPreview/OpenShortPreview.tsx @@ -6,6 +6,7 @@ import { import classNames from "classnames"; import * as dnum from "dnum"; import { ReactElement } from "react"; +import Skeleton from "react-loading-skeleton"; import { convertMillisecondsToDays } from "src/base/convertMillisecondsToDays"; import { formatRate } from "src/base/formatRate"; import { useAppConfig } from "src/ui/appconfig/useAppConfig"; @@ -20,6 +21,7 @@ interface OpenShortPreviewProps { shortSize: bigint | undefined; spotRateAfterOpen: bigint | undefined; curveFee: bigint | undefined; + openShortPreviewStatus: "error" | "idle" | "loading" | "success"; } export function OpenShortPreview({ @@ -29,6 +31,7 @@ export function OpenShortPreview({ shortSize, spotRateAfterOpen, curveFee, + openShortPreviewStatus, }: OpenShortPreviewProps): ReactElement { const appConfig = useAppConfig(); const baseToken = findBaseToken({ @@ -36,7 +39,6 @@ export function OpenShortPreview({ tokens: appConfig.tokens, }); const { fixedAPR } = useCurrentFixedAPR(hyperdrive.address); - const termLengthMS = Number(hyperdrive.poolConfig.positionDuration * 1000n); return (