diff --git a/screens/Staking/index.tsx b/screens/Staking/index.tsx index 976a9ce2..c90548e9 100644 --- a/screens/Staking/index.tsx +++ b/screens/Staking/index.tsx @@ -115,7 +115,7 @@ const Staking = () => { setModal({ name: "staking" })} className="w-full" - disabled={!total} + // disabled={!total} > Stake diff --git a/screens/Staking/modalStaking.tsx b/screens/Staking/modalStaking.tsx index add12ed7..2bf8d904 100644 --- a/screens/Staking/modalStaking.tsx +++ b/screens/Staking/modalStaking.tsx @@ -56,30 +56,34 @@ const ModalStaking = ({ isOpen, onClose }) => { .replace(/(?!^)-/g, "") .replace(/^0+(\d)/gm, "$1"); - const sliderValue = Math.round((amount * 100) / Number(total)) || 0; + const sliderValue = useMemo(() => { + if (Number(amount) > Number(total)) { + return 100; + } + return Math.round((Number(amount) * 100) / Number(total)) || 0; + }, [amount, total]); const handleMaxClick = () => { trackMaxStaking({ total: totalToken }); setAmount(totalToken); }; const handleInputChange = (e) => { - let { value } = e?.target || {}; + const { value } = e?.target || {}; const numRegex = /^([0-9]*\.?[0-9]*$)/; if (!numRegex.test(value)) { e.preventDefault(); return; } - if (Number(value) > Number(total)) { - value = total; - } setAmount(value); }; const handleRangeSliderChange = (percent) => { - if (Number(percent) >= 99.7) { + if (percent >= 100) { + setAmount(String(Number(total) * 1.01)); + } else if (Number(percent) >= 99.7) { setAmount(totalToken); } else { - setAmount((Number(total) * percent) / 100); + setAmount(((Number(total) * percent) / 100).toFixed(8)); } }; @@ -208,7 +212,7 @@ const ModalStaking = ({ isOpen, onClose }) => { isLoading={loadingStake} className="w-full mt-2 mb-4" > - Stake + {Number(amount) > Number(total) ? "Insufficient Balance" : "Stake"}