import { PrimaryButton } from '@shared/ui' import { truncateDecimals } from '@shared/lib/utils/truncateDecimals' import type { Pool, LpQuote } from '@features/pools' import { formatFeeTier } from '../model/meta' import styles from './LpDepositCard.module.css' interface Props { pool: Pool | null quote: LpQuote | undefined quoteFetching?: boolean pending?: boolean amount0: string amount1: string priceLower: string priceUpper: string slippage: string useNativeEth: boolean onAmount0Change: (v: string) => void onAmount1Change: (v: string) => void onPriceLowerChange: (v: string) => void onPriceUpperChange: (v: string) => void onSlippageChange: (v: string) => void onUseNativeEthChange: (v: boolean) => void onSubmit: () => void } const DASH = '—' const decimalRe = /^(\d+\.?\d*|\.?\d*)$/ function AmountInput({ symbol, value, onChange, }: { symbol: string value: string onChange: (v: string) => void }) { return (
{ const v = e.target.value if (decimalRe.test(v) || v === '') onChange(v) }} placeholder="0" aria-label={`Сумма ${symbol}`} />
{symbol}
) } function PriceInput({ label, value, onChange, }: { label: string value: string onChange: (v: string) => void }) { return ( ) } export function LpDepositCard({ pool, quote, quoteFetching, pending, amount0, amount1, priceLower, priceUpper, slippage, useNativeEth, onAmount0Change, onAmount1Change, onPriceLowerChange, onPriceUpperChange, onSlippageChange, onUseNativeEthChange, onSubmit, }: Props) { if (!pool) { return (

Выберите пул

Выберите пул в таблице выше, чтобы внести ликвидность.

) } const balance = quote?.balance // sufficient ноги может быть null (не проверялось / покрыто нативным ETH) — это не «не хватает». const insufficient = balance?.sufficient === false const apr = quote?.aprPercent != null ? `${quote.aprPercent}%` : DASH const feeUsd = quote?.appFeeTotalUsd != null ? `≈ $${quote.appFeeTotalUsd.toFixed(2)}` : DASH const amount0Out = quote ? truncateDecimals(quote.amount0DesiredHuman, 8) : DASH const amount1Out = quote ? truncateDecimals(quote.amount1DesiredHuman, 8) : DASH const shortLeg = balance && balance.token1.sufficient === false ? balance.token1 : balance?.token0 const canSubmit = !!quote && !insufficient && !pending return (
{pool.symbol0}/{pool.symbol1} {formatFeeTier(pool.feeTier)}
Суммы взноса
Диапазон цен ({pool.symbol1} за {pool.symbol0})
Взнос {pool.symbol0} {amount0Out}
Взнос {pool.symbol1} {amount1Out}
Комиссия сервиса (0.7%) {feeUsd}
Годовая доходность (APR) {apr}
{insufficient && (

Недостаточно средств{shortLeg ? `: не хватает ${shortLeg.symbol}` : ''}. Пополните баланс.

)}
) }