Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bugs #311

Merged
merged 3 commits into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/components/NewPosition/DepositSelector/style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ export const useStyles = makeStyles()(theme => {
wrapper: {
borderRadius: 10,
backgroundColor: colors.invariant.component,
padding: 24,
paddingTop: 16,
padding: '16px 24px 16px 24px',
flex: '1 1 0%',

[theme.breakpoints.down('sm')]: {
Expand Down
33 changes: 18 additions & 15 deletions src/components/Refresher/Refresher.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { createRef, useEffect, useState } from 'react'
import { useStyles } from './style'
import { Box } from '@mui/material'

type Props = {
currentIndex: number
Expand Down Expand Up @@ -30,21 +31,23 @@ export const Refresher = ({ currentIndex, maxIndex, onClick }: Props) => {
}, [circleRef, currentIndex, maxIndex])

return (
<svg className={classes.ring} width='20' height='20' onClick={onClick}>
<circle stroke='#3A466B' strokeWidth='2' fill='transparent' r='8' cx='10' cy='10' />
<circle
className={classes.innerCircle}
strokeDasharray='0'
strokeDashoffset='0'
stroke='#EF84F5'
strokeWidth='2'
fill='transparent'
r='8'
cx='10'
cy='10'
ref={circleRef}
/>
</svg>
<Box width={20} height={20}>
<svg className={classes.ring} width='20' height='20' onClick={onClick}>
<circle stroke='#3A466B' strokeWidth='2' fill='transparent' r='8' cx='10' cy='10' />
<circle
className={classes.innerCircle}
strokeDasharray='0'
strokeDashoffset='0'
stroke='#EF84F5'
strokeWidth='2'
fill='transparent'
r='8'
cx='10'
cy='10'
ref={circleRef}
/>
</svg>
</Box>
)
}

Expand Down
2 changes: 1 addition & 1 deletion src/store/consts/static.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export const FAUCET_TOKEN_AMOUNT = 1000n

export const TokenAirdropAmount = {
BTC: 100000n,
ETH: 20000000000n,
ETH: 20000000000000000n,
USDC: 50000000n
}

Expand Down
22 changes: 21 additions & 1 deletion src/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -603,14 +603,34 @@ export const nearestTickIndex = (
return BigInt(nearestSpacingMultiplicity(tick, Number(spacing)))
}

function safeConvertToBigInt(value: string): bigint {
if (value.toLowerCase().includes('e')) {
const [baseStr, exponentStr] = value.toLowerCase().split('e')

const baseBigInt = BigInt(baseStr.replace('.', ''))
const exponent = parseInt(exponentStr)
if (Math.abs(exponent) > 10000) {
return 0n
}

const decimalPlaces = (baseStr.split('.')[1] || '').length

const adjustedExponent = exponent - decimalPlaces

return baseBigInt * 10n ** BigInt(adjustedExponent)
} else {
return BigInt(value)
}
}

export const convertBalanceToBigint = (amount: string, decimals: bigint | number): bigint => {
const balanceString = amount.split('.')
if (balanceString.length !== 2) {
return BigInt(balanceString[0] + '0'.repeat(Number(decimals)))
}

if (balanceString[1].length <= decimals) {
return BigInt(
return safeConvertToBigInt(
balanceString[0] + balanceString[1] + '0'.repeat(Number(decimals) - balanceString[1].length)
)
}
Expand Down
Loading