Skip to content
Merged
9 changes: 5 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"dependencies": {
"@emotion/react": "^11.11.4",
"@emotion/styled": "^11.11.5",
"@invariant-labs/a0-sdk": "^0.2.29",
"@invariant-labs/a0-sdk": "^0.2.32",
"@mui/icons-material": "^5.15.15",
"@mui/material": "^5.15.15",
"@nightlylabs/wallet-selector-polkadot": "^0.2.6",
Expand Down
5 changes: 2 additions & 3 deletions src/components/Stats/Liquidity/Liquidity.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { colors, typography } from '@static/theme'
import { useStyles } from './style'
import { TimeData } from '@store/reducers/stats'
import { Grid, Typography } from '@mui/material'
import { formatNumber, formatNumbers, showPrefix } from '@utils/utils'
import { formatNumber } from '@utils/utils'

interface LiquidityInterface {
liquidityPercent: number
Expand All @@ -31,8 +31,7 @@ const Liquidity: React.FC<LiquidityInterface> = ({
<Typography className={classes.liquidityHeader}>Liquidity</Typography>
<Grid className={classes.volumePercentHeader}>
<Typography className={classes.volumeLiquidityHeader}>
${formatNumbers()(liquidityVolume.toString())}
{showPrefix(liquidityVolume)}
${formatNumber(liquidityVolume)}
</Typography>
<Grid className={classes.volumeStatusContainer}>
<Grid
Expand Down
44 changes: 23 additions & 21 deletions src/components/Stats/PoolListItem/PoolListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react'
import { theme } from '@static/theme'
import { useStyles } from './style'
import { Box, Grid, Typography, useMediaQuery } from '@mui/material'
import { addressToTicker, formatNumbers, parseFeeToPathFee, showPrefix } from '@utils/utils'
import { addressToTicker, formatNumber, parseFeeToPathFee } from '@utils/utils'
import ArrowDropDownIcon from '@mui/icons-material/ArrowDropDown'
import ArrowDropUpIcon from '@mui/icons-material/ArrowDropUp'
import { useNavigate } from 'react-router-dom'
Expand Down Expand Up @@ -62,7 +62,7 @@ const PoolListItem: React.FC<IProps> = ({
const { classes } = useStyles()

const navigate = useNavigate()
const isXs = useMediaQuery(theme.breakpoints.down('xs'))
const isSm = useMediaQuery(theme.breakpoints.down('sm'))

const handleOpenPosition = () => {
navigate(
Expand All @@ -82,9 +82,9 @@ const PoolListItem: React.FC<IProps> = ({
container
classes={{ container: classes.container }}
style={hideBottomLine ? { border: 'none' } : undefined}>
{!isXs ? <Typography>{tokenIndex}</Typography> : null}
{!isSm ? <Typography>{tokenIndex}</Typography> : null}
<Grid className={classes.imageContainer}>
{!isXs && (
{!isSm && (
<Box className={classes.iconsWrapper}>
<img src={iconFrom} alt='Token from' />
<img src={iconTo} alt='Token to' />
Expand All @@ -96,7 +96,7 @@ const PoolListItem: React.FC<IProps> = ({
</Typography>
</Grid>
</Grid>
{/* {!isXs ? (
{/* {!isSm ? (
<Typography>
{`${apy > 1000 ? '>1000' : apy.toFixed(2)}%`}
<Tooltip
Expand Down Expand Up @@ -137,24 +137,26 @@ const PoolListItem: React.FC<IProps> = ({
</Typography>
) : null} */}
<Typography>{fee}%</Typography>
<Typography>{`$${formatNumbers()(volume.toString())}${showPrefix(volume)}`}</Typography>
<Typography>{`$${formatNumbers()(TVL.toString())}${showPrefix(TVL)}`}</Typography>
<Box className={classes.action}>
<TooltipHover text='Exchange'>
<button className={classes.actionButton} onClick={handleOpenSwap}>
<img width={32} height={32} src={icons.horizontalSwapIcon} alt={'Exchange'} />
</button>
</TooltipHover>
<TooltipHover text='Add position'>
<button className={classes.actionButton} onClick={handleOpenPosition}>
<img width={32} height={32} src={icons.plusIcon} alt={'Open'} />
</button>
</TooltipHover>
</Box>
<Typography>{`$${formatNumber(volume)}`}</Typography>
<Typography>{`$${formatNumber(TVL)}`}</Typography>
{!isSm && (
<Box className={classes.action}>
<TooltipHover text='Exchange'>
<button className={classes.actionButton} onClick={handleOpenSwap}>
<img width={32} height={32} src={icons.horizontalSwapIcon} alt={'Exchange'} />
</button>
</TooltipHover>
<TooltipHover text='Add position'>
<button className={classes.actionButton} onClick={handleOpenPosition}>
<img width={32} height={32} src={icons.plusIcon} alt={'Open'} />
</button>
</TooltipHover>
</Box>
)}
</Grid>
) : (
<Grid container classes={{ container: classes.container, root: classes.header }}>
{!isXs && (
{!isSm && (
<Typography style={{ lineHeight: '11px' }}>
N<sup>o</sup>
</Typography>
Expand Down Expand Up @@ -241,7 +243,7 @@ const PoolListItem: React.FC<IProps> = ({
<ArrowDropDownIcon className={classes.icon} />
) : null}
</Typography>
<Typography align='right'>Action</Typography>
{!isSm && <Typography align='right'>Action</Typography>}
</Grid>
)}
</Grid>
Expand Down
12 changes: 6 additions & 6 deletions src/components/Stats/PoolListItem/style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,12 @@ export const useStyles = makeStyles()(() => ({
},

[theme.breakpoints.down('sm')]: {
gridTemplateColumns: '32.5% 17.5% 35% 15% ',

'& p': {
justifyContent: 'flex-start',
...typography.caption1
}
},

[theme.breakpoints.down('xs')]: {
gridTemplateColumns: '28% 15% 30% 25%'
}
},

Expand Down Expand Up @@ -72,8 +71,9 @@ export const useStyles = makeStyles()(() => ({
display: 'block'
},

[theme.breakpoints.down('xs')]: {
marginLeft: 0
[theme.breakpoints.down('sm')]: {
marginLeft: 0,
justifyContent: 'flex-start'
}
},
icon: {
Expand Down
17 changes: 9 additions & 8 deletions src/components/Stats/TokenListItem/TokenListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import ArrowDropDownIcon from '@mui/icons-material/ArrowDropDown'
import ArrowDropUpIcon from '@mui/icons-material/ArrowDropUp'
import { useStyles } from './style'
import { Grid, Typography, useMediaQuery } from '@mui/material'
import { formatNumbers, showPrefix } from '@utils/utils'
import { formatNumber } from '@utils/utils'
import { SortTypeTokenList } from '@store/consts/static'

interface IProps {
Expand Down Expand Up @@ -39,7 +39,7 @@ const TokenListItem: React.FC<IProps> = ({
const { classes } = useStyles()
// const isNegative = priceChange < 0

const isXDown = useMediaQuery(theme.breakpoints.down('sm'))
const isSm = useMediaQuery(theme.breakpoints.down('sm'))
const hideName = useMediaQuery(theme.breakpoints.down('xs'))

return (
Expand All @@ -49,29 +49,30 @@ const TokenListItem: React.FC<IProps> = ({
container
classes={{ container: classes.container, root: classes.tokenList }}
style={hideBottomLine ? { border: 'none' } : undefined}>
{!hideName && <Typography component='p'>{itemNumber}</Typography>}
{!hideName && !isSm && <Typography component='p'>{itemNumber}</Typography>}
<Grid className={classes.tokenName}>
{!isXDown && <img src={icon} alt='Token icon'></img>}
{!isSm && <img src={icon} alt='Token icon'></img>}
<Typography>
{hideName ? symbol : name}
{!hideName && <span className={classes.tokenSymbol}>{` (${symbol})`}</span>}
</Typography>
</Grid>
<Typography>{`~$${formatNumbers()(price.toString())}${showPrefix(price)}`}</Typography>
<Typography>{`~$${formatNumber(price)}`}</Typography>

{/* {!hideName && (
<Typography style={{ color: isNegative ? colors.invariant.Error : colors.green.main }}>
{isNegative ? `${priceChange.toFixed(2)}%` : `+${priceChange.toFixed(2)}%`}
</Typography>
)} */}
<Typography>{`$${formatNumbers()(volume.toString())}${showPrefix(volume)}`}</Typography>
<Typography>{`$${formatNumbers()(TVL.toString())}${showPrefix(TVL)}`}</Typography>
<Typography>{`$${formatNumber(volume)}`}</Typography>
<Typography>{`$${formatNumber(TVL)}`}</Typography>
</Grid>
) : (
<Grid
container
style={{ color: colors.invariant.textGrey, fontWeight: 400 }}
classes={{ container: classes.container, root: classes.header }}>
{!hideName && (
{!hideName && !isSm && (
<Typography style={{ lineHeight: '12px' }}>
N<sup>o</sup>
</Typography>
Expand Down
8 changes: 2 additions & 6 deletions src/components/Stats/TokenListItem/style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,10 @@ export const useStyles = makeStyles()((theme: Theme) => ({
whiteSpace: 'nowrap',

[theme.breakpoints.down('sm')]: {
gridTemplateColumns: '5% 35% 15% 17.5% 16.5% 15%',
gridTemplateColumns: '30% 22.5% 32.5% 15%',
'& p': {
...typography.caption2
...typography.caption1
}
},

[theme.breakpoints.down('xs')]: {
gridTemplateColumns: '15% 25% 35% 25%'
}
},

Expand Down
7 changes: 2 additions & 5 deletions src/components/Stats/Volume/Volume.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { useStyles } from './style'
import { TimeData } from '@store/reducers/stats'
import { Grid, Typography, useMediaQuery } from '@mui/material'
import { Box } from '@mui/system'
import { formatNumber, formatNumbers, showPrefix } from '@utils/utils'
import { formatNumber } from '@utils/utils'

interface StatsInterface {
percentVolume: number
Expand Down Expand Up @@ -38,10 +38,7 @@ const Volume: React.FC<StatsInterface> = ({ percentVolume, volume, data, classNa
<Box className={classes.volumeContainer}>
<Typography className={classes.volumeHeader}>Volume</Typography>
<div className={classes.volumePercentContainer}>
<Typography className={classes.volumePercentHeader}>
${formatNumbers()(volume.toString())}
{showPrefix(volume)}
</Typography>
<Typography className={classes.volumePercentHeader}>${formatNumber(volume)}</Typography>
<Box className={classes.volumeStatusContainer}>
<Box
className={classNames(
Expand Down
17 changes: 4 additions & 13 deletions src/components/Stats/volumeBar/VolumeBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import classNames from 'classnames'
import { theme } from '@static/theme'
import { useStyles } from './style'
import { Box, Grid, Typography, useMediaQuery } from '@mui/material'
import { formatNumbers, showPrefix } from '@utils/utils'
import { formatNumber } from '@utils/utils'

interface Iprops {
percentVolume: number
Expand All @@ -30,10 +30,7 @@ const VolumeBar: React.FC<Iprops> = ({
<Grid container classes={{ container: classes.container }}>
<Box className={classes.tokenName}>
<Typography className={classes.tokenHeader}>Volume 24H:</Typography>
<Typography className={classes.tokenContent}>
${formatNumbers()(volume.toString())}
{showPrefix(volume)}
</Typography>
<Typography className={classes.tokenContent}>${formatNumber(volume)}</Typography>
{!isXDown && (
<Typography
className={classNames(
Expand All @@ -48,10 +45,7 @@ const VolumeBar: React.FC<Iprops> = ({
</Box>
<Box className={classes.tokenName}>
<Typography className={classes.tokenHeader}>TVL 24H:</Typography>
<Typography className={classes.tokenContent}>
${formatNumbers()(tvlVolume.toString())}
{showPrefix(tvlVolume)}
</Typography>
<Typography className={classes.tokenContent}>${formatNumber(tvlVolume)}</Typography>
{!isXDown && (
<Typography
className={classNames(
Expand All @@ -64,10 +58,7 @@ const VolumeBar: React.FC<Iprops> = ({
</Box>
<Box className={classes.tokenName}>
<Typography className={classes.tokenHeader}>Fees 24H:</Typography>
<Typography className={classes.tokenContent}>
${formatNumbers()(feesVolume.toString())}
{showPrefix(feesVolume)}
</Typography>
<Typography className={classes.tokenContent}>${formatNumber(feesVolume)}</Typography>
{!isXDown && (
<Typography
className={classNames(
Expand Down
3 changes: 2 additions & 1 deletion src/components/Swap/Swap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import settingIcon from '@static/svg/settings.svg'
import SwapArrows from '@static/svg/swap-arrows.svg'
import {
DEFAULT_TOKEN_DECIMAL,
MAX,
REFRESHER_INTERVAL,
SWAP_SAFE_TRANSACTION_FEE
} from '@store/consts/static'
Expand Down Expand Up @@ -353,7 +354,7 @@ export const Swap: React.FC<ISwap> = ({
if (
tokenFrom !== null &&
convertBalanceToBigint(amountFrom, Number(tokens[tokenFrom]?.decimals ?? 0n)) !== 0n &&
isError(SwapError.Unknown)
(amountFrom.replace('.', '') == MAX.toString() || amountTo === '')
) {
return 'Not enough liquidity'
}
Expand Down
6 changes: 3 additions & 3 deletions src/containers/NewPositionWrapper/NewPositionWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { PERCENTAGE_SCALE } from '@invariant-labs/a0-sdk/target/consts'
import {
ALL_FEE_TIERS_DATA,
DEFAULT_NEW_POSITION_SLIPPAGE,
U128MAX,
MAX,
bestTiers,
commonTokensForNetworks
} from '@store/consts/static'
Expand Down Expand Up @@ -461,7 +461,7 @@ export const NewPositionWrapper: React.FC<IProps> = ({
}
} catch (error) {
setIsGetLiquidityError(true)
return printBigint(U128MAX, tokens[tokenA].decimals)
return printBigint(MAX, tokens[tokenA].decimals)
}

try {
Expand All @@ -480,7 +480,7 @@ export const NewPositionWrapper: React.FC<IProps> = ({
return tokenXAmount
} catch (error) {
setIsGetLiquidityError(true)
return printBigint(U128MAX, tokens[tokenB].decimals)
return printBigint(MAX, tokens[tokenB].decimals)
}

return BigInt(0)
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 @@ -248,7 +248,7 @@ export const ALL_FEE_TIERS_DATA = FEE_TIERS.map((tier, index) => ({
primaryIndex: index
}))

export const U128MAX = 2n ** 128n - 1n
export const MAX = 2n ** 128n - 1n

export const SWAP_SAFE_TRANSACTION_FEE = BigInt(Math.ceil(0.1 * 10 ** 12))
export const POOL_SAFE_TRANSACTION_FEE = BigInt(Math.ceil(0.2 * 10 ** 12))
Expand Down
4 changes: 2 additions & 2 deletions src/store/sagas/positions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
POOL_SAFE_TRANSACTION_FEE,
POSITIONS_PER_QUERY,
PSP22_APPROVE_OPTIONS,
U128MAX,
MAX,
WAZERO_DEPOSIT_OPTIONS
} from '@store/consts/static'
import {
Expand Down Expand Up @@ -56,7 +56,7 @@ export function getWithdrawAllWAZEROTxs(
): SubmittableExtrinsic[] {
const txs: SubmittableExtrinsic[] = []

const approveTx = psp22.approveTx(invariantAddress, U128MAX, wazeroAddress, PSP22_APPROVE_OPTIONS)
const approveTx = psp22.approveTx(invariantAddress, MAX, wazeroAddress, PSP22_APPROVE_OPTIONS)
txs.push(approveTx)

const unwrapTx = invariant.withdrawAllWAZEROTx(wazeroAddress, INVARIANT_WITHDRAW_ALL_WAZERO)
Expand Down
4 changes: 2 additions & 2 deletions src/store/sagas/swap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
INVARIANT_SWAP_OPTIONS,
PSP22_APPROVE_OPTIONS,
SWAP_SAFE_TRANSACTION_FEE,
U128MAX,
MAX,
WAZERO_DEPOSIT_OPTIONS,
WAZERO_WITHDRAW_OPTIONS
} from '@store/consts/static'
Expand Down Expand Up @@ -279,7 +279,7 @@ export function* handleGetSimulateResult(action: PayloadAction<Simulate>) {
}

let poolKey = null
let amountOut = byAmountIn ? 0n : U128MAX
let amountOut = byAmountIn ? 0n : MAX
let insufficientLiquidityAmountOut = 0n
let priceImpact = 0
let targetSqrtPrice = 0n
Expand Down
Loading