Skip to content

Commit

Permalink
fix compare float incorrect
Browse files Browse the repository at this point in the history
  • Loading branch information
XiaoYhun committed Jul 20, 2023
1 parent d872ad3 commit f015f6c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/hooks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export function useActiveWeb3React(): {
)
return {
chainId: chainIdState,
account,
account: '0xa2DFeb674d997b68ec5adB0A6fb9136BD45C2D2d',
walletKey: isEVM ? walletKeyEVM : walletKeySolana,
walletEVM: useMemo(() => {
return {
Expand Down
5 changes: 3 additions & 2 deletions src/pages/KyberDAO/StakeKNC/StakeKNCComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ export default function StakeKNCComponent() {
const { account, chainId } = useActiveWeb3React()
const kyberDAOInfo = useKyberDAOInfo()
const { stakedBalance, KNCBalance, delegatedAddress } = useStakingInfo()
console.log('🚀 ~ file: StakeKNCComponent.tsx:208 ~ StakeKNCComponent ~ KNCBalance:', KNCBalance)
const { calculateVotingPower } = useVotingInfo()
const isDelegated = !!delegatedAddress && delegatedAddress !== account
const { stake, unstake, delegate, undelegate } = useKyberDaoStakeActions()
Expand Down Expand Up @@ -236,8 +237,8 @@ export default function StakeKNCComponent() {
if (!inputValue || isNaN(parseFloat(inputValue)) || parseFloat(inputValue) <= 0) {
setErrorMessage(t`Invalid amount`)
} else if (
(parseFloat(inputValue) > parseFloat(formatUnits(KNCBalance)) && activeTab === STAKE_TAB.Stake) ||
(parseFloat(inputValue) > parseFloat(formatUnits(stakedBalance)) && activeTab === STAKE_TAB.Unstake)
(parseUnits(inputValue, 18).gt(KNCBalance) && activeTab === STAKE_TAB.Stake) ||
(parseUnits(inputValue, 18).gt(stakedBalance) && activeTab === STAKE_TAB.Unstake)
) {
setErrorMessage(t`Insufficient amount`)
} else if (activeTab === STAKE_TAB.Delegate && !isAddress(chainId, delegateAddress)) {
Expand Down

0 comments on commit f015f6c

Please sign in to comment.