diff --git a/src/components/stakingCalculator.tsx b/src/components/stakingCalculator.tsx index 450622c..3498852 100644 --- a/src/components/stakingCalculator.tsx +++ b/src/components/stakingCalculator.tsx @@ -1,6 +1,6 @@ import { StakingPoolsStorage } from "@/contexts/stakingPoolsStorage"; import { useEffect, useState } from "react"; -import { Button, Input } from "antd"; +import { Button, Input, Tooltip } from "antd"; import { WalletConnector } from "@/contexts/walletConnector"; import { formatPercentage, convertZilValueInToken, getTxExplorerUrl, formatAddress } from "@/misc/formatting"; import { formatUnits, parseEther } from "viem"; @@ -32,7 +32,7 @@ const StakingCalculator: React.FC = () => { const [zilToStake, setZilToStake] = useState(formatUnits(stakingPoolForView?.stakingPool.definition.minimumStake || 0n, 18)); useEffect(() => { - setZilToStake("0.00"); + onMinClick(); }, [stakingPoolForView]); const handleChange = (e: React.ChangeEvent) => { @@ -48,7 +48,7 @@ const StakingCalculator: React.FC = () => { }; const handleFocus = () => { - if (zilToStake === '0.00') setZilToStake(''); + if (zilToStake === '') onMinClick(); }; const handleBlur = () => { @@ -62,7 +62,7 @@ const StakingCalculator: React.FC = () => { } setZilToStake(valueTemp.replace(/0*(\d+)/, '$1')); - if (zilToStake === '') setZilToStake('0.00'); + if (zilToStake === '') onMinClick(); }; const zilToStakeNumber = parseFloat(zilToStake); @@ -84,7 +84,7 @@ const StakingCalculator: React.FC = () => { stakingPoolForView && ( <>
-
+
{ prefix="ZIL" status={!zilToStakeOk ? 'error' : undefined} /> - + {stakingPoolForView!.stakingPool.data ? ( <> - + ~ - {convertZilValueInToken( - zilToStakeNumber, - stakingPoolForView.stakingPool.data - .zilToTokenRate - )}{' '} + { + !isNaN(zilToStakeNumber) && !isNaN(stakingPoolForView.stakingPool.data + .zilToTokenRate) + ? convertZilValueInToken(zilToStakeNumber, stakingPoolForView.stakingPool.data + .zilToTokenRate) + : "" + } + {' '} { stakingPoolForView.stakingPool.definition .tokenSymbol }{' '} - + ~ {formatPercentage( stakingPoolForView!.stakingPool.data.apr @@ -122,7 +125,7 @@ const StakingCalculator: React.FC = () => { ) : (
)} - APR + APR
@@ -164,11 +167,13 @@ const StakingCalculator: React.FC = () => {
Rate
{stakingPoolForView!.stakingPool.data && ( -
{`1 ZIL = ~${convertZilValueInToken(zilToStakeNumber, stakingPoolForView.stakingPool.data.zilToTokenRate)} ${stakingPoolForView.stakingPool.definition.tokenSymbol}`}
+
{`1 ZIL = ~${ stakingPoolForView.stakingPool.data.zilToTokenRate} ${stakingPoolForView.stakingPool.definition.tokenSymbol}`}
)}
-
APR:
+ + APR + {stakingPoolForView!.stakingPool.data ? ( <> ~{formatPercentage( @@ -206,7 +211,7 @@ const StakingCalculator: React.FC = () => { } {stakeContractCallError && ( -
+
{stakeContractCallError.message}
)} diff --git a/src/components/stakingPoolCard.tsx b/src/components/stakingPoolCard.tsx index 804c6c7..10a3f52 100644 --- a/src/components/stakingPoolCard.tsx +++ b/src/components/stakingPoolCard.tsx @@ -1,6 +1,7 @@ import { formatPercentage, formatUnitsToHumanReadable } from '@/misc/formatting'; import { StakingPool } from '@/misc/stakingPoolsConfig'; import { UserStakingPoolData } from '@/misc/walletsConfig'; +import { Tooltip } from 'antd'; import Image from 'next/image'; interface StakingPoolCardProps { @@ -49,7 +50,7 @@ const StakingPoolCard: React.FC = ({ {stakingPoolData.definition.tokenSymbol}
-
+
{userStakingPoolData && userStakingPoolData.stakingTokenAmount ? ( <> @@ -60,7 +61,7 @@ const StakingPoolCard: React.FC = ({ )} ${stakingPoolData.definition.tokenSymbol}`} ) : ( - - + - )}
= ({ { stakingPoolData.data ? (
= 50 ? 'text-red1' : stakingPoolData.data.votingPower * 100 >= 30 @@ -90,7 +91,7 @@ const StakingPoolCard: React.FC = ({
) : ( <> - VP + VP ) @@ -108,8 +109,13 @@ const StakingPoolCard: React.FC = ({ }
-
- APR{' '} + + +
+ + APR + + { stakingPoolData.data ? ( <> diff --git a/src/components/stakingPoolDetailsView.tsx b/src/components/stakingPoolDetailsView.tsx index 1b911d2..11008f1 100644 --- a/src/components/stakingPoolDetailsView.tsx +++ b/src/components/stakingPoolDetailsView.tsx @@ -74,8 +74,8 @@ const StakingPoolDetailsView: React.FC = ({ const humanReadableStakingToken = (value: bigint) => formatUnitsToHumanReadable(value, stakingPoolData.definition.tokenDecimals); return ( -
diff --git a/src/components/stakingPoolsList.tsx b/src/components/stakingPoolsList.tsx index 40f8a95..57ff5d4 100644 --- a/src/components/stakingPoolsList.tsx +++ b/src/components/stakingPoolsList.tsx @@ -50,11 +50,11 @@ const StakingPoolsList: React.FC = () => { return ( <> -
+
Liquid Validators
-
+
{ />
-
+
{sortedStakingPoolsData.map(({ stakingPool, userData }) => ( { }; const handleFocus = () => { - if (zilToUnstake === '0.00') setZilToUnstake(''); + if (zilToUnstake === '') onMaxClick(); }; const handleBlur = () => { @@ -44,11 +44,11 @@ const UnstakingCalculator: React.FC = () => { valueTemp = zilToUnstake.slice(0, -1); } setZilToUnstake(valueTemp.replace(/0*(\d+)/, '$1')); - if (zilToUnstake === '') setZilToUnstake('0.00'); + if (zilToUnstake === '') onMaxClick(); }; useEffect(() => { - setZilToUnstake('0.00'); + setZilToUnstake('1'); }, [stakingPoolForView]); const stakedTokenAvailable = @@ -82,7 +82,7 @@ const UnstakingCalculator: React.FC = () => { stakingPoolForView && (
-
+
{ = ~ {formatUnitsToHumanReadable( convertTokenToZil( - zilInWei, + parseEther('1'), stakingPoolForView.stakingPool.data .zilToTokenRate ), 18 )} - + + ) : (
)} @@ -186,7 +187,9 @@ const UnstakingCalculator: React.FC = () => {
-
APR:
+ + APR + {stakingPoolForView!.stakingPool.data ? ( <> ~ @@ -202,7 +205,7 @@ const UnstakingCalculator: React.FC = () => {
{unstakeContractCallError && ( -
+
{unstakeContractCallError.message}
)} diff --git a/src/components/withdrawUnstakedZilPanel.tsx b/src/components/withdrawUnstakedZilPanel.tsx index 708b69c..5c0dfc6 100644 --- a/src/components/withdrawUnstakedZilPanel.tsx +++ b/src/components/withdrawUnstakedZilPanel.tsx @@ -60,17 +60,21 @@ const WithdrawZilPanel: React.FC = ({ {!!availableUnstake?.length ? ( availableUnstake.map((item, claimIdx) => ( -
{stakingPoolData.data ? ( -
- {parseFloat( - formatUnits(item.zilAmount, 18) - ).toFixed(3)}{' '} - ZIL -
+
+
+ {parseFloat( + formatUnits(item.zilAmount, 18) + ).toFixed(3)}{' '} + ZIL +
+
avZIL
+ +
) : (
)} @@ -89,7 +93,7 @@ const WithdrawZilPanel: React.FC = ({
)) ) : !!pendingUnstake?.length ? ( -
+
Next available reward
diff --git a/src/components/withdrawZilView.tsx b/src/components/withdrawZilView.tsx index 683792d..2be2c56 100644 --- a/src/components/withdrawZilView.tsx +++ b/src/components/withdrawZilView.tsx @@ -22,20 +22,23 @@ const WithdrawZilView: React.FC = () => { ] return ( -
-
+
+

Staking Portal Claims

-

+

Below are withdrawal claims waiting for you

{ unstakingItems.length > 0 ? ( -
{ unstakingItems.map((item, claimIdx) => ( diff --git a/src/misc/formatting.ts b/src/misc/formatting.ts index 283ea3c..e44681f 100644 --- a/src/misc/formatting.ts +++ b/src/misc/formatting.ts @@ -38,7 +38,7 @@ export function convertTokenToZil(tokenAmount: bigint, zilToTokenRate: number): } export function convertZilValueInToken(zilAmount: number, zilToTokenRate: number) { - return `${(zilAmount * zilToTokenRate).toFixed(2)}` + return `${(zilAmount * zilToTokenRate).toFixed(2)}` } export function formatUnitsToHumanReadable(value: bigint, decimals: number): string { diff --git a/src/pages/index.tsx b/src/pages/index.tsx index 3bf4d07..3835179 100644 --- a/src/pages/index.tsx +++ b/src/pages/index.tsx @@ -48,7 +48,7 @@ const HomePage = () => { const [mobileShowClaims, setMobileShowClaims] = useState(false); const mobileOverlayWrapper = (children: React.ReactNode) => ( -
+
{children}
) @@ -59,7 +59,8 @@ const HomePage = () => { !isWalletConnected ? ( ) : stakingPoolForView ? ( -
+
{ selectStakingPoolForView(null); @@ -105,14 +106,14 @@ const HomePage = () => { ) const mobileBottomNavition = ( -
+
{ isWalletConnected ? ( <> { mobileShowClaims && ( -
+
+ ) } +
+ {connectWallet} +
+ + ) }
@@ -187,7 +212,7 @@ const HomePage = () => {
{/* Header */} -
+
@@ -233,10 +258,11 @@ const HomePage = () => {
-
-
+
+
{/* Left column */} -
+
diff --git a/src/styles/globals.css b/src/styles/globals.css index 8369684..996cce1 100644 --- a/src/styles/globals.css +++ b/src/styles/globals.css @@ -101,7 +101,7 @@ body { } .btn-secondary-colored { - @apply !gap-0 !bg-transparent !whitespace-normal py-3 px-8 w-full rounded font-int-extrabold text-12 leading-6 tracking-widest !h-auto uppercase border-solid border-2 cursor-pointer duration-500 ease-in-out; + @apply !gap-0 !bg-transparent !whitespace-normal py-1.5 px-4 w-full rounded font-int-extrabold text-12 leading-6 tracking-widest !h-auto uppercase border-solid border-2 cursor-pointer duration-500 ease-in-out; &:hover { @apply !opacity-80; diff --git a/tailwind.config.ts b/tailwind.config.ts index 56631c8..c4cc5d3 100644 --- a/tailwind.config.ts +++ b/tailwind.config.ts @@ -13,9 +13,8 @@ const config: Config = { "gradient-conic": "conic-gradient(from 180deg at 50% 50%, var(--tw-gradient-stops))", 'primary-gradient' : 'radial-gradient(120.62% 683.52% at 110.84% 156.15%, #C5FFFD 6.84%, rgba(111, 255, 194, 0.760784) 48.36%, #00DABA 100%)', - 'gradientbg': 'linear-gradient(129.93deg, rgba(175, 175, 175, 0.12) 16.6%, rgba(17, 243, 179, 0.12) 90.65%)', - 'darkbg': 'linear-gradient(314.92deg, rgba(17, 39, 49, 0.4) 28.08%, rgba(9, 9, 9, 0.4) 97.04%)', - + 'gradientbg': 'linear-gradient(129.93deg, rgba(175, 175, 175, 0.12) 16.6%, rgba(17, 243, 179, 0.12) 90.65%)', + 'darkbg': 'linear-gradient(314.92deg, rgba(17, 39, 49, 0.4) 28.08%, rgba(9, 9, 9, 0.4) 97.04%)', }, colors: { black1: '#010101',