Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
nick134-bit committed Aug 18, 2023
2 parents 933531d + 7140eca commit 303c293
Show file tree
Hide file tree
Showing 7 changed files with 154 additions and 131 deletions.
5 changes: 5 additions & 0 deletions components/Navbar/NavbarPopper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
} from '@chakra-ui/react'
import { BRIDGE_NETWORK_DEFAULTS } from 'constants/index'
import { useRouter } from 'next/router'
import { ChevronDownIcon, ExternalLinkIcon } from '@chakra-ui/icons'

import NavbarLink from './NavbarLink'

Expand Down Expand Up @@ -66,6 +67,10 @@ const NavbarPopper = ({ menu, currentChainName, chainId }) => {
color={isActiveLink ? 'white' : 'brand.50'}
>
{menu.label}
{menu.children ? <ChevronDownIcon /> : null}
{menu.isExternal ? (
<ExternalLinkIcon paddingLeft={''} paddingBottom={'1'} />
) : null}
</Text>
</HStack>
</PopoverTrigger>
Expand Down
30 changes: 21 additions & 9 deletions components/Pages/Incentivize/hooks/useIncentivePoolInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ import {
getPairAprAndDailyVolume,
getPairAprAndDailyVolumeTerra,
} from 'util/enigma'
import {
AMP_WHALE_TOKEN_SYMBOL,
B_WHALE_TOKEN_SYMBOL,
WHALE_TOKEN_SYMBOL,
} from 'constants/index'

export interface Flow {
claimed_amount: string
Expand Down Expand Up @@ -155,13 +160,16 @@ const getPoolFlowData = async (
lockedLpShare = 1
}

const flowList = flows.map((flow) => ({
denom:
flow.flow_asset.info?.native_token?.denom ??
flow.flow_asset.info.token.contract_addr,
dailyEmission: 0,
endEpoch: Number(flow.end_epoch),
}))
const flowList = flows
.map((flow) => ({
denom:
flow.flow_asset.info?.native_token?.denom ??
flow.flow_asset.info.token.contract_addr,
dailyEmission: 0,
endEpoch: Number(flow.end_epoch),
}))
.filter((flow) => flow.endEpoch >= currentEpochId)

const uniqueFlowList = flowList.reduce((acc, current) => {
if (!acc.some((item) => item.denom === current.denom)) {
acc.push(current)
Expand Down Expand Up @@ -207,13 +215,17 @@ const getPoolFlowData = async (
)
const tokenSymbol = poolAsset?.symbol
const logoURI = poolAsset?.logoURI

const price =
tokenSymbol === AMP_WHALE_TOKEN_SYMBOL ||
tokenSymbol === B_WHALE_TOKEN_SYMBOL
? prices[WHALE_TOKEN_SYMBOL]
: prices[tokenSymbol]
return {
...flow,
tokenSymbol,
logoURI,
apr:
((flow.dailyEmission * Number(prices[tokenSymbol]) * 365.25) /
((flow.dailyEmission * price * 365.25) /
(totalLiquidity * lockedLpShare)) *
100,
}
Expand Down
8 changes: 7 additions & 1 deletion components/Pages/Pools/MyPoolsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import Apr from './components/Apr'
import PoolName from './components/PoolName'
import { Pool } from './types'
import { IncentiveTooltip } from '../../InfoTooltip'
import Liquidity from './components/liquidity'

const columnHelper = createColumnHelper<Pool>()

Expand Down Expand Up @@ -75,7 +76,12 @@ const columns = [
{'Total Liquidity'}
</Text>
),
cell: (info) => <Text align="right">{info.getValue()}</Text>,
cell: (info) => (
<Liquidity
liquidity={info.getValue()?.toString()}
infos={info.row.original}
/>
),
}),
columnHelper.accessor('myPosition', {
header: () => (
Expand Down
17 changes: 2 additions & 15 deletions components/Pages/Pools/Pools.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,6 @@ import {
Tooltip,
VStack,
} from '@chakra-ui/react'
import {
Config,
useConfig,
} from 'components/Pages/Dashboard/hooks/useDashboardData'
import { useCurrentEpoch } from 'components/Pages/Incentivize/hooks/useCurrentEpoch'
import { useIncentivePoolInfo } from 'components/Pages/Incentivize/hooks/useIncentivePoolInfo'
import { Incentives } from 'components/Pages/Pools/Incentives'
import { ACTIVE_INCENTIVE_NETWORKS, STABLE_COIN_LIST } from 'constants/index'
Expand Down Expand Up @@ -51,21 +46,14 @@ type PoolData = PoolEntityTypeWithLiquidity &
const Pools = () => {
const [allPools, setAllPools] = useState<any[]>([])
const [isInitLoading, setInitLoading] = useState<boolean>(true)
const { chainId, status, network } = useRecoilValue(walletState)
const { chainId, status } = useRecoilValue(walletState)
const [_, setAprHelperState] = useRecoilState(aprHelperState)
const isWalletConnected: boolean = status === WalletStatusType.connected
const [incentivePoolsLoaded, setIncentivePoolsLoaded] = useState(
!ACTIVE_INCENTIVE_NETWORKS.includes(chainId)
)
const [showAllPools, setShowAllPools] = useState<boolean>(false)
const cosmwasmClient = useCosmwasmClient(chainId)
const config: Config = useConfig(network, chainId)

const { data: currentEpochData } = useCurrentEpoch(cosmwasmClient, config)
const currentEpoch = useMemo(
() => Number(currentEpochData?.currentEpoch?.epoch.id),
[currentEpochData]
)

const router = useRouter()
const chainIdParam = router.query.chainId as string
Expand Down Expand Up @@ -185,10 +173,9 @@ const Pools = () => {

useEffect(() => {
const updatedPools = allPools.map((pool) => {
const flows = (
const flows =
incentivePoolInfos?.find((info) => info.poolId === pool.poolId)
?.flowData ?? []
).filter((flow) => flow.endEpoch >= currentEpoch)

const incentiveBaseApr = flows.reduce(
(total, item) => total + (isNaN(item.apr) ? 0 : Number(item.apr)),
Expand Down
4 changes: 2 additions & 2 deletions components/Pages/Pools/components/Apr.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ const Apr = ({ apr, flows }: Props) => {
<Popover trigger="hover">
<PopoverTrigger>
<Button variant="unstyled">
<HStack borderBottom="1px dotted rgba(255, 255, 255, 0.5)" h="30px">
<Text align="right">{totalApr.toFixed(2)}%</Text>
<HStack borderBottom="1px dotted rgba(255, 255, 255, 0.5)">
<Text align="right" >{totalApr.toFixed(2)}%</Text>
</HStack>
</Button>
</PopoverTrigger>
Expand Down
77 changes: 38 additions & 39 deletions components/Pages/Pools/components/liquidity.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
HStack,
Text,
Tooltip,
VStack,
VStack
} from '@chakra-ui/react'

type Props = {
Expand All @@ -16,9 +16,11 @@ type Props = {

const Liquidity = ({ liquidity, infos }: Props) => {
const assets = infos.poolAssets
const ttDisabled = liquidity === 'n/a'
return (
<Tooltip
sx={{ boxShadow: 'none' }}
isDisabled={ttDisabled}
sx={{ 'boxShadow': 'none' }}
label={
<VStack
minW="250px"
Expand All @@ -30,48 +32,45 @@ const Liquidity = ({ liquidity, infos }: Props) => {
position="relative"
border="none"
justifyContent="center"
alignItems="center"
>
alignItems="center">
<>
{<> </>}
{assets.map((name, index) => {
return (
<React.Fragment key={name.name}>
<HStack
justify="space-between"
direction="row"
width="full"
px={2}
>
<Text color="whiteAlpha.600" fontSize={14}>
{name.name}
</Text>
<Text fontSize={14}>
{(
infos.liquidity.reserves.total[index] /
Math.pow(10, infos.poolAssets[index].decimals)
).toFixed(2)}
</Text>
</HStack>
{index !== assets.length - 1 && (
<Divider
width="93%"
borderWidth="0.1px"
color="whiteAlpha.300"
/>
)}
</React.Fragment>
)
})}
{assets.map((name, index) => (
<React.Fragment key={name.name}>
<HStack
justify="space-between"
direction="row"
width="full"
px={2}
>
<Text color="whiteAlpha.600" fontSize={14}>
{name.name}
</Text>
<Text fontSize={14}>
{(
infos.liquidity.reserves.total[index] /
10 ** infos.poolAssets[index].decimals
).toFixed(2)}
</Text>
</HStack>
{index !== assets.length - 1 && (
<Divider
width="93%"
borderWidth="0.1px"
color="whiteAlpha.300"
/>
)}
</React.Fragment>
))}
</>
</VStack>
} //displaying nothing when wallet disconnected
} // Displaying nothing when wallet disconnected
bg="transparent"
>
<VStack alignItems="flex-start" minW={100}>
<Text mb="-0.3rem" color="white">
{
<HStack borderBottom="1px dotted rgba(255, 255, 255, 0.5)" h="30px">
<HStack borderBottom={!ttDisabled ? '1px dotted rgba(255, 255, 255, 0.5)' : 'InactiveBorder'} paddingTop={'2'}>
<Text align="right">{liquidity}</Text>
</HStack>
}
Expand All @@ -80,15 +79,15 @@ const Liquidity = ({ liquidity, infos }: Props) => {
{
<div
style={{
width: `0px`,
height: '1px',
background: `repeating-linear-gradient(
'width': '0px',
'height': '1px',
'background': `repeating-linear-gradient(
to right,
white,
white 1px,
transparent 1px,
transparent 5px
)`,
)`
}}
/>
}
Expand Down
Loading

0 comments on commit 303c293

Please sign in to comment.