diff --git a/packages/ui/app/_components/CommonTable.tsx b/packages/ui/app/_components/CommonTable.tsx index 71cb8408d..e114cafb7 100644 --- a/packages/ui/app/_components/CommonTable.tsx +++ b/packages/ui/app/_components/CommonTable.tsx @@ -24,6 +24,7 @@ import { TableHeader, TableRow } from '@ui/components/ui/table'; +import type { MarketRowData } from '@ui/hooks/market/useMarketData'; import ResultHandler from './ResultHandler'; @@ -46,6 +47,11 @@ export const sortingFunctions = { type SortingType = keyof typeof sortingFunctions; +export interface MarketCellProps { + row: Row; + getValue: () => any; +} + export type EnhancedColumnDef = Omit< ColumnDef, 'header' | 'sortingFn' diff --git a/packages/ui/app/_components/MaxDeposit.tsx b/packages/ui/app/_components/MaxDeposit.tsx index 4f1e067b8..5a42fe3df 100644 --- a/packages/ui/app/_components/MaxDeposit.tsx +++ b/packages/ui/app/_components/MaxDeposit.tsx @@ -2,6 +2,7 @@ import { useState, useMemo, useRef, + useEffect, type SetStateAction, type Dispatch } from 'react'; @@ -16,6 +17,7 @@ import { Button } from '@ui/components/ui/button'; import { Card, CardContent } from '@ui/components/ui/card'; import { Input } from '@ui/components/ui/input'; +import { PrecisionSlider } from './PrecisionSlider'; import TokenSelector from './stake/TokenSelector'; import { icErc20Abi } from '@ionicprotocol/sdk'; @@ -40,6 +42,9 @@ interface IMaxDeposit { useUnderlyingBalance?: boolean; footerText?: string; decimals?: number; + // Added slider props + useSlider?: boolean; + sliderStep?: number; } function MaxDeposit({ @@ -56,9 +61,13 @@ function MaxDeposit({ setMaxTokenForUtilization, useUnderlyingBalance = false, footerText, - decimals: propDecimals + decimals: propDecimals, + // Added slider props with defaults + useSlider = false, + sliderStep = 1 }: IMaxDeposit) { const [bal, setBal] = useState(); + const [utilizationPercentage, setUtilizationPercentage] = useState(0); const { address } = useAccount(); // For regular token balance @@ -120,6 +129,15 @@ function MaxDeposit({ setMaxTokenForUtilization ]); + // Added effect to update utilization percentage + useEffect(() => { + if (bal && amount) { + const percentage = + (Number(amount) / Number(formatUnits(bal.value, bal.decimals))) * 100; + setUtilizationPercentage(percentage); + } + }, [amount, bal]); + function handlInpData(e: React.ChangeEvent) { if ( bal && @@ -140,6 +158,14 @@ function MaxDeposit({ }); } + // Added slider handler + function handleSliderChange(value: number) { + if (!handleInput || !bal) return; + const maxValue = Number(formatUnits(bal.value, bal.decimals)); + const newAmount = (value / 100) * maxValue; + handleInput(newAmount.toString()); + } + const newRef = useRef(null); const [open, setOpen] = useState(false); @@ -235,6 +261,39 @@ function MaxDeposit({ )} + {useSlider && ( +
+ +
+ = 25 ? 'text-accent' : ''} + > + 25% + + = 50 ? 'text-accent' : ''} + > + 50% + + = 75 ? 'text-accent' : ''} + > + 75% + + = 100 ? 'text-accent' : ''} + > + 100% + +
+
+ )} {footerText && (
{footerText} diff --git a/packages/ui/app/_components/veion/AddLiquidityDialog.tsx b/packages/ui/app/_components/veion/AddLiquidityDialog.tsx index 099f87ae6..0e75ce790 100644 --- a/packages/ui/app/_components/veion/AddLiquidityDialog.tsx +++ b/packages/ui/app/_components/veion/AddLiquidityDialog.tsx @@ -17,7 +17,7 @@ import { useVeIONContext } from '@ui/context/VeIonContext'; import { useVeIONActions } from '@ui/hooks/veion/useVeIONActions'; import BuyIonSection from './BuyIonSection'; -import MaxDeposit from '../stake/MaxDeposit'; +import MaxDeposit from '../MaxDeposit'; const Widget = dynamic(() => import('../stake/Widget'), { ssr: false @@ -112,7 +112,6 @@ export default function AddLiquidityDialog({ handleInput={handleIonInput} chain={currentChain} useSlider - size={16} />