Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ export function CloseLongForm({

return (
<TransactionView
disclaimer={
previewCloseLongStatus === "error"
? "Insufficient liquidity: There is not enough liquidity in the pool to close your long position at this time. You may either add more funds to the pool or wait for the liquidity to improve."
: ""
}
heading="Close long"
tokenInput={
<TokenInput
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,13 +211,14 @@ function CurrentValueCell({
hyperdrive: Hyperdrive;
}) {
const { address: account } = useAccount();
const { baseAmountOut } = usePreviewCloseLong({
const { baseAmountOut, previewCloseLongStatus } = usePreviewCloseLong({
hyperdriveAddress: hyperdrive.address,
maturityTime: row.original.maturity,
bondAmountIn: row.original.bondAmount,
minBaseAmountOut: parseUnits("0", hyperdrive.baseToken.decimals),
destination: account,
});

const currentValue =
baseAmountOut &&
formatBalance({
Expand All @@ -228,7 +229,9 @@ function CurrentValueCell({

const isPositiveChangeInValue =
baseAmountOut && baseAmountOut > row.original.baseAmountPaid;

if (previewCloseLongStatus === "error") {
return <div>Insufficient Liquidity</div>;
}
return (
<div className="flex flex-col gap-1">
<span className="ml-2 font-bold">{currentValue?.toString()}</span>
Expand Down