Skip to content

Commit

Permalink
improve presentation for empty stake input form
Browse files Browse the repository at this point in the history
  • Loading branch information
eli-d committed Oct 14, 2024
1 parent e97b873 commit 0321d28
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions web/src/components/StakeForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,7 @@ export const StakeForm = ({ mode, poolId, positionId }: StakeFormProps) => {
const sqb = getSqrtRatioAtTick(upper);

if (quotedToken === "token0") {
if (!token0AmountRaw) return;
const delta = cur === upper ? 1n : 0n;
// delta is a guard for same lower and upper ticks
const liq = getLiquidityForAmount0(
Expand All @@ -290,6 +291,7 @@ export const StakeForm = ({ mode, poolId, positionId }: StakeFormProps) => {
if (token1Balance?.value && newToken1Amount > token1Balance.value) return;
setToken1AmountRaw(newToken1Amount.toString());
} else {
if (!token1AmountRaw) return;
// delta is a guard for same lower and upper ticks
const delta = cur === lower ? 1n : 0n;
const liq = getLiquidityForAmount1(
Expand Down Expand Up @@ -327,12 +329,12 @@ export const StakeForm = ({ mode, poolId, positionId }: StakeFormProps) => {

const usdPriceToken0 =
token0.address === fUSDC.address
? parseFloat(token0Amount)
? parseFloat(token0Amount === "" ? "0" : token0Amount)
: getFormattedPriceFromAmount(token0Amount, tokenPrice, fUSDC.decimals);

const usdPriceToken1 =
token1.address === fUSDC.address
? parseFloat(token1Amount)
? parseFloat(token1Amount === "" ? "0" : token1Amount)
: getFormattedPriceFromAmount(token1Amount, tokenPrice, fUSDC.decimals);

const [liquidityRangeType, setLiquidityRangeType] = useState<
Expand Down Expand Up @@ -508,6 +510,7 @@ export const StakeForm = ({ mode, poolId, positionId }: StakeFormProps) => {
<Input
className="-ml-2 border-0 bg-black pl-2 text-2xl"
autoFocus
placeholder="0"
variant={"no-ring"}
value={token0Amount}
onChange={(e) => quoteTokenAmount(e.target.value, "token0")}
Expand Down Expand Up @@ -569,6 +572,7 @@ export const StakeForm = ({ mode, poolId, positionId }: StakeFormProps) => {
<Input
className="-ml-2 border-0 bg-black pl-2 text-2xl"
autoFocus
placeholder="0"
variant={"no-ring"}
value={token1Amount}
onChange={(e) => quoteTokenAmount(e.target.value, "token1")}
Expand Down

0 comments on commit 0321d28

Please sign in to comment.