Skip to content

Commit

Permalink
Merge pull request #807 from invariant-labs/staging
Browse files Browse the repository at this point in the history
Update prod env
  • Loading branch information
wojciech-cichocki authored Dec 6, 2024
2 parents 3bbb6dd + 31694d8 commit aed1c00
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 44 deletions.
56 changes: 12 additions & 44 deletions src/components/Stats/PoolListItem/PoolListItem.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { useMemo } from 'react'
import { theme } from '@static/theme'
import { useStyles } from './style'
import { Box, Grid, Tooltip, Typography, useMediaQuery } from '@mui/material'
import { Box, Grid, Typography, useMediaQuery } from '@mui/material'
import ArrowDropDownIcon from '@mui/icons-material/ArrowDropDown'
import ArrowDropUpIcon from '@mui/icons-material/ArrowDropUp'
import { useNavigate } from 'react-router-dom'
Expand All @@ -14,6 +14,7 @@ import { DECIMAL } from '@invariant-labs/sdk/lib/utils'
import { TooltipHover } from '@components/TooltipHover/TooltipHover'
import { VariantType } from 'notistack'
import FileCopyOutlinedIcon from '@mui/icons-material/FileCopyOutlined'
import { apyToApr } from '@utils/uiUtils'

interface IProps {
TVL?: number
Expand Down Expand Up @@ -60,11 +61,6 @@ const PoolListItem: React.FC<IProps> = ({
addressTo,
network,
apy = 0,
apyData = {
fees: 0,
accumulatedFarmsAvg: 0,
accumulatedFarmsSingleTick: 0
},
isUnknownFrom,
isUnknownTo,
poolAddress,
Expand Down Expand Up @@ -117,6 +113,8 @@ const PoolListItem: React.FC<IProps> = ({
})
}

const apr = apyToApr(apy)

return (
<Grid maxWidth='100%'>
{displayType === 'token' ? (
Expand Down Expand Up @@ -165,43 +163,12 @@ const PoolListItem: React.FC<IProps> = ({
</Grid>
</Grid>
{!isSm ? (
<Typography>
{`${apy > 1000 ? '>1000%' : apy === 0 ? '-' : apy.toFixed(2) + '%'}`}
{apy !== 0 && (
<Tooltip
title={
<>
<Typography className={classes.liquidityTitle}>Pool APY</Typography>
<Typography className={classes.liquidityDesc}>
Pool fees: {`${apyData.fees > 1000 ? '>1000' : apyData.fees.toFixed(2)}%`}
{apyData.accumulatedFarmsAvg > 0 ? (
<>
<br />+ All farms rewards with single tick position:{' '}
{`${
apyData.accumulatedFarmsSingleTick > 1000
? '>1000'
: apyData.accumulatedFarmsSingleTick.toFixed(2)
}%`}
<br />
(All farms rewards with average position:{' '}
{`${
apyData.accumulatedFarmsAvg > 1000
? '>1000'
: apyData.accumulatedFarmsAvg.toFixed(2)
}%`}
)
</>
) : null}
</Typography>
</>
}
placement='bottom'
classes={{
tooltip: classes.liquidityTooltip
}}>
<span className={classes.activeLiquidityIcon}>i</span>
</Tooltip>
)}
<Typography className={classes.row}>
{`${apr > 1000 ? '>1000%' : apr === 0 ? '-' : apr.toFixed(2) + '%'}`}
<span
className={
classes.apy
}>{`${apy > 1000 ? '>1000%' : apy === 0 ? '' : apy.toFixed(2) + '%'}`}</span>
</Typography>
) : null}
<Typography>{fee}%</Typography>
Expand Down Expand Up @@ -260,6 +227,7 @@ const PoolListItem: React.FC<IProps> = ({
</Typography>
{!isSm ? (
<Typography
className={classes.row}
style={{ cursor: 'pointer' }}
onClick={() => {
if (sortType === SortTypePoolList.APY_DESC) {
Expand All @@ -268,7 +236,7 @@ const PoolListItem: React.FC<IProps> = ({
onSort?.(SortTypePoolList.APY_DESC)
}
}}>
7-days APY
APR <span className={classes.apy}>APY</span>
{sortType === SortTypePoolList.APY_ASC ? (
<ArrowDropUpIcon className={classes.icon} />
) : sortType === SortTypePoolList.APY_DESC ? (
Expand Down
11 changes: 11 additions & 0 deletions src/components/Stats/PoolListItem/style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,5 +173,16 @@ export const useStyles = makeStyles()(() => ({
color: colors.invariant.lightHover
}
}
},
row: {
display: 'flex',
gap: 4,
fontSize: 30,
height: 32
},
apy: {
fontSize: 12,
alignSelf: 'flex-end',
color: colors.invariant.textGrey
}
}))
5 changes: 5 additions & 0 deletions src/utils/uiUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,8 @@ export const importantStyles = (styleObject: { [key: string]: string | number })
}),
styleObject
)

export const apyToApr = (apy: number) => {
const dailyRate = Math.pow(1 + apy / 100, 1 / 365) - 1
return dailyRate * 365 * 100
}

0 comments on commit aed1c00

Please sign in to comment.