From c6dbcb73b1f2f4afbe0681b4ec72c2b46de1a088 Mon Sep 17 00:00:00 2001 From: xieqiancaosissi Date: Thu, 24 Oct 2024 17:06:13 +0800 Subject: [PATCH 1/2] Update stake preview (#106) * update stake preview * Fix stake amount * Fix stake bugs --------- Co-authored-by: lq0-github <1441665200@qq.com> --- screens/Staking/index.tsx | 2 +- screens/Staking/modalStaking.tsx | 25 ++++++++++++++++--------- 2 files changed, 17 insertions(+), 10 deletions(-) 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..df519ef9 100644 --- a/screens/Staking/modalStaking.tsx +++ b/screens/Staking/modalStaking.tsx @@ -45,7 +45,7 @@ const ModalStaking = ({ isOpen, onClose }) => { const selectedMonths = stakingTimestamp ? Math.round(unstakeDate.diffNow().as("months")) : months; const invalidAmount = +amount > +total; const invalidMonths = months === maxMonth ? false : months < selectedMonths; - const disabledStake = !amount || invalidAmount || invalidMonths; + const disabledStake = !amount || invalidAmount || invalidMonths || Number(amount) === 0; const { avgStakeSupplyAPY, avgStakeBorrowAPY, avgStakeNetAPY, totalTokenNetMap } = useStakeRewardApy(); const [, , multiplier] = useAppSelector(getAccountBoostRatioData); @@ -56,30 +56,37 @@ 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 (Number(total) === 0) { + setAmount("0"); + } else if (percent >= 100) { + setAmount(totalToken); + } else if (Number(percent) >= 99.7) { setAmount(totalToken); } else { - setAmount((Number(total) * percent) / 100); + const calculatedAmount = (Number(total) * percent) / 100; + setAmount(Number(calculatedAmount) === 0 ? "0" : calculatedAmount); } }; @@ -208,7 +215,7 @@ const ModalStaking = ({ isOpen, onClose }) => { isLoading={loadingStake} className="w-full mt-2 mb-4" > - Stake + {Number(amount) > Number(total) ? "Insufficient Balance" : "Stake"}
From 834853f83e3aca806d77d6d011563922fd3e779b Mon Sep 17 00:00:00 2001 From: naturexie <786281870@qq.com> Date: Sun, 10 Nov 2024 10:56:33 +0800 Subject: [PATCH 2/2] feat: add fastnear rpc --- utils/rpcConfig.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/utils/rpcConfig.ts b/utils/rpcConfig.ts index cc7070d5..5de99b35 100644 --- a/utils/rpcConfig.ts +++ b/utils/rpcConfig.ts @@ -35,6 +35,10 @@ export function getExtendConfig( url: "https://beta.rpc.mainnet.near.org", simpleName: "official beta rpc", }, + fastnearRpc: { + url: "https://free.rpc.fastnear.com", + simpleName: "fastnear rpc", + }, // pagodaRpc: { // url: "https://rpc.mainnet.pagoda.co", // simpleName: "pagoda rpc",