Skip to content

Commit

Permalink
Refactor initial stake amount calculation and update styling for stak…
Browse files Browse the repository at this point in the history
…e and unstake buttons
  • Loading branch information
shibatales committed Feb 5, 2024
1 parent 3e3e22d commit d2831db
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/modals/ManageStaking.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -446,12 +446,14 @@ const ManageStaking = (props: { isOpen: boolean; }) => {
}, [selectedCoreInfo, stakeForm, unstakeForm]);

useEffect(() => {
const availableBalanceBN = new BigNumber(metadata?.availableBalance as string);
const oneTNKR = new BigNumber(10).pow(12); // Adjust the exponent according to your token's decimals
const initialStakeAmount = availableBalanceBN.minus(oneTNKR).dividedBy(oneTNKR);
if (!metadata || !metadata.availableBalance) return;

// Set the initial stake amount in the form
stakeForm.setValue('amount', initialStakeAmount.toString());
const availableBalanceBN = new BigNumber(metadata.availableBalance as string);
const oneTNKR = new BigNumber(10).pow(12);
const initialStakeAmount = availableBalanceBN.minus(oneTNKR);
const stakeValue = initialStakeAmount.dividedBy(oneTNKR).toString();

stakeForm.setValue('amount', stakeValue);
}, [metadata, stakeForm]);

const RestakingDropdown = memo(() => {
Expand Down Expand Up @@ -574,7 +576,7 @@ const ManageStaking = (props: { isOpen: boolean; }) => {
{
showStakeMaxButton && (
<span
className="block cursor-pointer text-white hover:text-tinkerYellow text-xs focus:outline-none"
className="block cursor-pointer text-white hover:text-tinkerYellow text-xs focus:outline-none hover:underline underline-offset-2"
onClick={handleStakeMax}
tabIndex={0}
>
Expand Down Expand Up @@ -609,7 +611,7 @@ const ManageStaking = (props: { isOpen: boolean; }) => {
>
<div>
<label
htmlFor="stakeAmount"
htmlFor="unstakeAmount"
className="block text-xxs font-medium text-white mb-1"
>Unstake Amount</label>
<div className="relative flex flex-row items-center">
Expand All @@ -618,7 +620,7 @@ const ManageStaking = (props: { isOpen: boolean; }) => {
})} type="text" id="unstakeAmount" />
<div className="absolute inset-y-0 right-0 flex flex-row items-center gap-4 transform -translate-x-1/2">
<span
className="block cursor-pointer text-white hover:text-tinkerYellow text-xs focus:outline-none"
className="block cursor-pointer text-white hover:text-tinkerYellow text-xs focus:outline-none hover:underline underline-offset-2"
onClick={handleUnstakeMax}
tabIndex={0}
>
Expand Down

0 comments on commit d2831db

Please sign in to comment.