Skip to content

Commit

Permalink
Merge pull request #824 from invariant-labs/dev
Browse files Browse the repository at this point in the history
Update staging env
  • Loading branch information
wojciech-cichocki authored Dec 21, 2024
2 parents 541931c + c2d680f commit 194c52a
Show file tree
Hide file tree
Showing 12 changed files with 61 additions and 20 deletions.
6 changes: 5 additions & 1 deletion src/components/LiquidityPoolList/LiquidityPoolList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export interface PoolListInterface {
network: NetworkType
copyAddressHandler: (message: string, variant: VariantType) => void
isLoading: boolean
showAPY: boolean
}

import { Keypair } from '@solana/web3.js'
Expand Down Expand Up @@ -77,7 +78,8 @@ const LiquidityPoolList: React.FC<PoolListInterface> = ({
data,
network,
copyAddressHandler,
isLoading
isLoading,
showAPY
}) => {
const { classes } = useStyles()
const [page, setPage] = React.useState(1)
Expand Down Expand Up @@ -144,6 +146,7 @@ const LiquidityPoolList: React.FC<PoolListInterface> = ({
onSort={setSortType}
sortType={sortType}
network={network}
showAPY={showAPY}
/>
{data.length > 0 || isLoading ? (
paginator(page).map((element, index) => (
Expand Down Expand Up @@ -173,6 +176,7 @@ const LiquidityPoolList: React.FC<PoolListInterface> = ({
isUnknownTo={element.isUnknownTo}
poolAddress={element.poolAddress}
copyAddressHandler={copyAddressHandler}
showAPY={showAPY}
/>
))
) : (
Expand Down
6 changes: 4 additions & 2 deletions src/components/PopularPools/Card/Card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { DECIMAL } from '@invariant-labs/sdk/lib/utils'
export interface ICard extends PopularPoolData {
isLoading: boolean
network: NetworkType
showAPY: boolean
}

const Card: React.FC<ICard> = ({
Expand All @@ -34,7 +35,8 @@ const Card: React.FC<ICard> = ({
symbolFrom,
symbolTo,
volume,
network
network,
showAPY
}) => {
const { classes } = useStyles()
const navigate = useNavigate()
Expand Down Expand Up @@ -114,7 +116,7 @@ const Card: React.FC<ICard> = ({
{shortenAddress(symbolFrom ?? '')} - {shortenAddress(symbolTo ?? '')}
</Typography>
<Grid container gap='8px'>
{apy !== undefined && (
{apy !== undefined && showAPY && (
<StatsLabel
title='APY'
value={`${apy > 1000 ? '>1000%' : apy === 0 ? '-' : apy.toFixed(2) + '%'}`}
Expand Down
4 changes: 3 additions & 1 deletion src/components/PopularPools/PopularPools.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ export interface IPopularPools {
pools: PopularPoolData[]
isLoading: boolean
network: NetworkType
showAPY: boolean
}

const PopularPools: React.FC<IPopularPools> = ({ pools, isLoading, network }) => {
const PopularPools: React.FC<IPopularPools> = ({ pools, isLoading, network, showAPY }) => {
const { classes } = useStyles()

const isLgDown = useMediaQuery(theme.breakpoints.down('lg'))
Expand Down Expand Up @@ -65,6 +66,7 @@ const PopularPools: React.FC<IPopularPools> = ({ pools, isLoading, network }) =>
isUnknownTo={pool.isUnknownTo}
isLoading={isLoading}
network={network}
showAPY={showAPY}
/>
))}
</Slider>
Expand Down
6 changes: 5 additions & 1 deletion src/components/Stats/PoolList/PoolList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export interface PoolListInterface {
network: NetworkType
copyAddressHandler: (message: string, variant: VariantType) => void
isLoading: boolean
showAPY: boolean
}

const ITEMS_PER_PAGE = 10
Expand Down Expand Up @@ -75,7 +76,8 @@ const PoolList: React.FC<PoolListInterface> = ({
data,
network,
copyAddressHandler,
isLoading
isLoading,
showAPY
}) => {
const { classes } = useStyles()
const [page, setPage] = React.useState(1)
Expand Down Expand Up @@ -142,6 +144,7 @@ const PoolList: React.FC<PoolListInterface> = ({
onSort={setSortType}
sortType={sortType}
network={network}
showAPY={showAPY}
/>
{data.length > 0 || isLoading ? (
paginator(page).map((element, index) => (
Expand Down Expand Up @@ -171,6 +174,7 @@ const PoolList: React.FC<PoolListInterface> = ({
isUnknownTo={element.isUnknownTo}
poolAddress={element.poolAddress}
copyAddressHandler={copyAddressHandler}
showAPY={showAPY}
/>
))
) : (
Expand Down
3 changes: 2 additions & 1 deletion src/components/Stats/PoolList/Stats.PoolList.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ export const Primary: Story = {
data: poolsList,
network: NetworkType.Local,
copyAddressHandler: fn(),
isLoading: false
isLoading: false,
showAPY: true
}
}
20 changes: 15 additions & 5 deletions src/components/Stats/PoolListItem/PoolListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { TooltipHover } from '@components/TooltipHover/TooltipHover'
import { VariantType } from 'notistack'
import FileCopyOutlinedIcon from '@mui/icons-material/FileCopyOutlined'
import { apyToApr } from '@utils/uiUtils'
import classNames from 'classnames'

interface IProps {
TVL?: number
Expand Down Expand Up @@ -42,6 +43,7 @@ interface IProps {
isUnknownTo?: boolean
poolAddress?: string
copyAddressHandler?: (message: string, variant: VariantType) => void
showAPY: boolean
}

const PoolListItem: React.FC<IProps> = ({
Expand All @@ -64,7 +66,8 @@ const PoolListItem: React.FC<IProps> = ({
isUnknownFrom,
isUnknownTo,
poolAddress,
copyAddressHandler
copyAddressHandler,
showAPY
}) => {
const { classes } = useStyles()

Expand Down Expand Up @@ -120,7 +123,9 @@ const PoolListItem: React.FC<IProps> = ({
{displayType === 'token' ? (
<Grid
container
classes={{ container: classes.container }}
classes={{
container: classNames(classes.container, { [classes.containerNoAPY]: !showAPY })
}}
style={hideBottomLine ? { border: 'none' } : undefined}>
{!isMd ? <Typography>{tokenIndex}</Typography> : null}
<Grid className={classes.imageContainer}>
Expand Down Expand Up @@ -160,7 +165,7 @@ const PoolListItem: React.FC<IProps> = ({
</TooltipHover>
</Grid>
</Grid>
{!isSmd ? (
{!isSmd && showAPY ? (
<Typography className={classes.row}>
{`${apr > 1000 ? '>1000%' : apr === 0 ? '-' : apr.toFixed(2) + '%'}`}
<span
Expand Down Expand Up @@ -201,7 +206,12 @@ const PoolListItem: React.FC<IProps> = ({
)}
</Grid>
) : (
<Grid container classes={{ container: classes.container, root: classes.header }}>
<Grid
container
classes={{
container: classNames(classes.container, { [classes.containerNoAPY]: !showAPY }),
root: classes.header
}}>
{!isMd && (
<Typography style={{ lineHeight: '11px' }}>
N<sup>o</sup>
Expand All @@ -223,7 +233,7 @@ const PoolListItem: React.FC<IProps> = ({
<ArrowDropDownIcon className={classes.icon} />
) : null}
</Typography>
{!isSmd ? (
{!isSmd && showAPY ? (
<Typography
className={classes.row}
style={{ cursor: 'pointer' }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ export const Header: Story = {
displayType: 'header',
onSort: fn(),
sortType: SortTypePoolList.TVL_DESC,
network: NetworkType.Mainnet
network: NetworkType.Mainnet,
showAPY: true
}
}

Expand All @@ -48,6 +49,7 @@ export const Token: Story = {
volume: 1000000000,
TVL: 500000000,
hideBottomLine: false,
network: NetworkType.Mainnet
network: NetworkType.Mainnet,
showAPY: true
}
}
4 changes: 3 additions & 1 deletion src/components/Stats/PoolListItem/style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ export const useStyles = makeStyles()(() => ({
}
}
},

containerNoAPY: {
gridTemplateColumns: '5% auto 12% 15% 12% 160px'
},
imageContainer: {
display: 'flex',
alignItems: 'center'
Expand Down
3 changes: 0 additions & 3 deletions src/components/Stats/TokenListItem/TokenListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ const TokenListItem: React.FC<IProps> = ({
const { classes } = useStyles()
// const isNegative = priceChange < 0

const isSm = useMediaQuery(theme.breakpoints.down('sm'))
const isMd = useMediaQuery(theme.breakpoints.down('md'))

const networkUrl = useMemo(() => {
Expand Down Expand Up @@ -81,8 +80,6 @@ const TokenListItem: React.FC<IProps> = ({
})
}

console.log(isSm)

return (
<Grid>
{displayType === 'tokens' ? (
Expand Down
11 changes: 10 additions & 1 deletion src/containers/PopularPoolsWrapper/PopularPoolsWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,22 @@ export const PopularPoolsWrapper: React.FC = () => {
return data
}, [poolsList])

const showAPY = useMemo(() => {
return list.some(pool => pool.apy !== 0)
}, [list])

useEffect(() => {
dispatch(actions.getCurrentStats())
}, [])

return (
<Grid container>
<PopularPools pools={list} isLoading={isLoadingStats} network={currentNetwork} />
<PopularPools
pools={list}
isLoading={isLoadingStats}
network={currentNetwork}
showAPY={showAPY}
/>
</Grid>
)
}
Expand Down
5 changes: 5 additions & 0 deletions src/containers/WrappedPoolList/WrappedPoolList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ export const WrappedPoolList: React.FC = () => {
})
}, [isLoadingStats, poolsList, deferredSearchPoolsValue])

const showAPY = useMemo(() => {
return filteredPoolsList.some(pool => pool.apy !== 0)
}, [filteredPoolsList])

const copyAddressHandler = (message: string, variant: VariantType) => {
dispatch(
snackbarActions.add({
Expand Down Expand Up @@ -114,6 +118,7 @@ export const WrappedPoolList: React.FC = () => {
network={currentNetwork}
copyAddressHandler={copyAddressHandler}
isLoading={isLoadingStats}
showAPY={showAPY}
/>
</div>
)
Expand Down
7 changes: 5 additions & 2 deletions src/containers/WrappedStats/WrappedStats.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,10 @@ export const WrappedStats: React.FC = () => {
return acc
}, [allFarms])

const showAPY = useMemo(() => {
return filteredPoolsList.some(pool => pool.apy !== 0)
}, [filteredPoolsList])

const copyAddressHandler = (message: string, variant: VariantType) => {
dispatch(
snackbarActions.add({
Expand All @@ -136,8 +140,6 @@ export const WrappedStats: React.FC = () => {
)
}

console.log(liquidityPlotData.length, isLoadingStats)

return (
<Grid container className={classes.wrapper} direction='column'>
{liquidityPlotData.length === 0 && !isLoadingStats ? (
Expand Down Expand Up @@ -270,6 +272,7 @@ export const WrappedStats: React.FC = () => {
network={currentNetwork}
copyAddressHandler={copyAddressHandler}
isLoading={isLoadingStats}
showAPY={showAPY}
/>
</>
)}
Expand Down

0 comments on commit 194c52a

Please sign in to comment.