diff --git a/components/Modal/Controls.tsx b/components/Modal/Controls.tsx index b9d281f2..f934eff0 100644 --- a/components/Modal/Controls.tsx +++ b/components/Modal/Controls.tsx @@ -7,15 +7,7 @@ import RangeSlider from "./RangeSlider"; import TokenBox from "./TokenBox"; import { isMemeCategory } from "../../redux/categorySelectors"; -export default function Controls({ - amount, - available, - action, - tokenId, - asset, - totalAvailable, - available$, -}) { +export default function Controls({ amount, available, action, asset, totalAvailable, available$ }) { const dispatch = useAppDispatch(); const isMeme = useAppSelector(isMemeCategory); const handleInputChange = (e) => { @@ -31,22 +23,22 @@ export default function Controls({ dispatch(updateAmount({ isMax: false, amount: value })); } }; - const handleSliderChange = (percent) => { const p = percent < 1 ? 0 : percent > 99 ? 100 : percent; const value = new Decimal(available).mul(p).div(100).toFixed(); + const decimalLength = value?.split(".")?.[1]?.length || 0; if (isMeme) { dispatch( updateAmountMEME({ isMax: p === 100, - amount: new Decimal(value || 0).toFixed(), + amount: new Decimal(value || 0).toFixed(Math.min(decimalLength, asset.decimals)), }), ); } else { dispatch( updateAmount({ isMax: p === 100, - amount: new Decimal(value || 0).toFixed(), + amount: new Decimal(value || 0).toFixed(Math.min(decimalLength, asset.decimals)), }), ); } diff --git a/components/Modal/RangeSlider.tsx b/components/Modal/RangeSlider.tsx index 955c96ab..41b7d115 100644 --- a/components/Modal/RangeSlider.tsx +++ b/components/Modal/RangeSlider.tsx @@ -55,7 +55,6 @@ export default function RangeSlider(props: any) { function changeValue(v: string, isClickValue?: boolean) { let matchedValue; const numValue = Number(v); - // const toPercent = (100 / splitList.length) * numValue; if (isClickValue) { matchedValue = numValue; if (isMonth) { diff --git a/components/Modal/index.tsx b/components/Modal/index.tsx index 51d80e20..312e7ef9 100644 --- a/components/Modal/index.tsx +++ b/components/Modal/index.tsx @@ -189,7 +189,6 @@ const Modal = () => { amount={amount} available={isBtcSupply ? btcAvailableBalance : available} action={action} - tokenId={tokenId} asset={asset} totalAvailable={isBtcSupply ? btcAvailableBalance : available} available$={available$}