Skip to content

Commit

Permalink
Don't show transaction details when inputs are empty (#1492)
Browse files Browse the repository at this point in the history
* Don't show transaction details when inputs are empty

* Fix bug causing eth fiat price to not return
  • Loading branch information
DannyDelott committed Sep 12, 2024
1 parent 1d5844d commit 80ccd71
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ export function OpenLongForm({
) : null
}
bottomRightElement={
<div className="flex flex-col gap-1 text-xs text-neutral-content">
<div className="flex flex-col gap-1 text-sm text-neutral-content">
<span>
{activeTokenBalance
? `Balance: ${formatBalance({
Expand All @@ -286,17 +286,19 @@ export function OpenLongForm({
/>
}
transactionPreview={
<OpenLongPreview
hyperdrive={hyperdrive}
spotRateAfterOpen={spotRateAfterOpen}
curveFee={curveFee}
activeToken={activeToken}
amountPaid={depositAmountAsBigInt || 0n}
bondAmount={bondsReceived || 0n}
openLongPreviewStatus={openLongPreviewStatus}
asBase={activeToken.address === baseToken.address}
vaultSharePrice={poolInfo?.vaultSharePrice}
/>
depositAmountAsBigInt ? (
<OpenLongPreview
hyperdrive={hyperdrive}
spotRateAfterOpen={spotRateAfterOpen}
curveFee={curveFee}
activeToken={activeToken}
amountPaid={depositAmountAsBigInt || 0n}
bondAmount={bondsReceived || 0n}
openLongPreviewStatus={openLongPreviewStatus}
asBase={activeToken.address === baseToken.address}
vaultSharePrice={poolInfo?.vaultSharePrice}
/>
) : null
}
disclaimer={(() => {
if (!!depositAmountAsBigInt && !hasEnoughLiquidity) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ export function AddLiquidityForm2({
</div>
}
bottomRightElement={
<div className="flex flex-col gap-1 text-xs text-neutral-content">
<div className="flex flex-col gap-1 text-sm text-neutral-content">
<span>
{activeTokenBalance
? `Balance: ${formatBalance({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -475,20 +475,13 @@ export function OpenShortForm({
);
}
// In all other cases where the user has input an amount, show the disclaimer, but ensure a skeleton is shown only on the stats that are being refetched on new blocks
return (
<div className="flex flex-col gap-4">
{!hasEnoughBalance && openShortPreviewStatus !== "loading" ? (
<p className="text-center text-sm text-error">
Insufficient balance
</p>
) : null}
{hyperdrive.withdrawOptions.isBaseTokenWithdrawalEnabled ? null : (
<p className="text-center text-sm text-neutral-content">
{`When closing your Short position, you'll receive ${sharesToken?.symbol}.`}
</p>
)}
</div>
);
if (!hasEnoughBalance && openShortPreviewStatus !== "loading") {
return (
<p className="flex flex-col text-center text-sm text-error">
Insufficient balance
</p>
);
}
})()}
actionButton={(() => {
if (!account) {
Expand Down
2 changes: 1 addition & 1 deletion apps/hyperdrive-trading/src/ui/token/TokenInputTwo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ export function TokenInputTwo({
<div className="text-base-content">
<button
className={classNames(
"ml-1 flex items-end text-xs font-semibold",
"ml-1 flex items-end text-sm font-semibold",
{
"daisy-btn-error": hasError,
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { parseFixed } from "@delvtech/fixed-point-wasm";
import { useQuery } from "@tanstack/react-query";
import { ZERO_ADDRESS } from "src/base/constants";
import { makeQueryKey } from "src/base/makeQueryKey";
import { isTestnetChain } from "src/chains/isTestnetChain";
import { ETH_MAGIC_NUMBER } from "src/token/ETH_MAGIC_NUMBER";
Expand Down Expand Up @@ -29,8 +28,7 @@ export function useTokenFiatPrice({
defiLlamaTokenId = `ethereum:${ETH_MAGIC_NUMBER}`;
}

const queryEnabled =
!isTestnetChain(chainId) && !!tokenAddress && tokenAddress !== ZERO_ADDRESS;
const queryEnabled = !isTestnetChain(chainId) && !!tokenAddress;

const { data } = useQuery({
queryKey: makeQueryKey("tokenFiatPrice", { defiLlamaTokenId }),
Expand Down

0 comments on commit 80ccd71

Please sign in to comment.