Skip to content

Commit

Permalink
fix tvl
Browse files Browse the repository at this point in the history
  • Loading branch information
namgold committed Oct 12, 2023
1 parent c75b1b9 commit 30b4b05
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 11 deletions.
8 changes: 4 additions & 4 deletions src/components/YieldPools/ListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ import { currencyIdFromAddress } from 'utils/currencyId'
import { getTradingFeeAPR, useFarmApr, useFarmRewards, useFarmRewardsUSD } from 'utils/dmm'
import { formatTokenBalance, getFullDisplayBalance } from 'utils/formatBalance'
import { getFormattedTimeFromSecond } from 'utils/formatTime'
import { formatDollarAmount } from 'utils/numbers'
import { formatDisplayNumber } from 'utils/numbers'
import { unwrappedToken } from 'utils/wrappedCurrency'

import { ModalContentWrapper } from './ElasticFarmModals/styled'
Expand Down Expand Up @@ -368,7 +368,7 @@ const ListItem = ({ farm }: ListItemProps) => {
{/* STAKED TVL */}
<Row>
<Text fontSize="14px" fontWeight={400}>
{formatDollarAmount(liquidity)}
{formatDisplayNumber(liquidity, { style: 'currency', significantDigits: 6 })}
</Text>
</Row>
{/* AVG APR */}
Expand Down Expand Up @@ -551,7 +551,7 @@ const ListItem = ({ farm }: ListItemProps) => {
</RowBetween>
<RowBetween marginBottom="16px">
<Text fontSize="16px" color={theme.text} lineHeight="20px">
{formatDollarAmount(liquidity)}
{formatDisplayNumber(liquidity, { style: 'currency', significantDigits: 6 })}
</Text>
{farm.version === FairLaunchVersion.V2 ? (
farm.startTime > currentTimestamp ? (
Expand All @@ -573,7 +573,7 @@ const ListItem = ({ farm }: ListItemProps) => {
</RowBetween>
<RowBetween marginBottom="16px">
<Text fontSize="16px" color={theme.text} lineHeight="20px">
{!!userStakedBalanceUSD ? formatDollarAmount(userStakedBalanceUSD) : '--'}
{formatDisplayNumber(userStakedBalanceUSD, { style: 'currency', significantDigits: 6, allowZero: false })}
</Text>
</RowBetween>
<RowBetween marginBottom="16px">
Expand Down
7 changes: 3 additions & 4 deletions src/state/farms/classic/knUpdater.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ const KNUpdater = ({ isInterval = true }: { isInterval?: boolean }) => {
const rewardTokens = farmPool.rewardTokens.map(
({ id, decimals, symbol, name }) => new Token(chainId, id, Number(decimals), symbol, name),
)
const totalStake = parseNum(farmPool.stakedTvl)
const stakeToken = id // todo namgold: check this
const totalStake = parseNum(farmPool.stakedAmount).divide(10 ** 18)
const stakeToken = id
const token0 = { id: farmPool.pool.token0.id, symbol: farmPool.pool.token0.symbol }
const token1 = { id: farmPool.pool.token1.id, symbol: farmPool.pool.token1.symbol }
const amp = Number(farmPool.pool.amp)
Expand All @@ -65,11 +65,10 @@ const KNUpdater = ({ isInterval = true }: { isInterval?: boolean }) => {
.subtract(parseNum(farmPool.pool.feesUsdOneDayAgo))
.toFixed(18)
const oneDayFeeUntracked = '0'
const userData = {} // todo namgold: fill this.

const rewardPerUnits: BigNumber[] = farmPool.rewardPerUnits.map(i => parseUnits(toFixed(i), 0))
const start = Number(farmPool.start)
const end = Number(farmPool.end)
const userData = {} // todo namgold: fill this.

if (version === FairLaunchVersion.V1) {
return {
Expand Down
4 changes: 2 additions & 2 deletions src/state/farms/classic/rpcUpdater.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -140,13 +140,13 @@ export default function RPCUpdater({ isInterval = true }: { isInterval?: boolean
(farmData: Farm) => farmData && farmData.id.toLowerCase() === poolInfo.stakeToken.toLowerCase(),
),
...poolInfo,
version: isV2 ? FairLaunchVersion.V2 : isV3 ? FairLaunchVersion.V3 : FairLaunchVersion.V1,
rewardTokens: poolInfo.rewardTokens,
fairLaunchAddress: contract.address,
userData: {
stakedBalance: stakedBalances[index],
rewards: [FairLaunchVersion.V2, FairLaunchVersion.V3].includes(poolInfo.fairLaunchVersion)
? pendingRewards[index] &&
pendingRewards[index].map((pendingReward: BigNumber, pendingRewardIndex: number) =>
? pendingRewards[index]?.map((pendingReward: BigNumber, pendingRewardIndex: number) =>
pendingReward.div(
isV3 ? poolInfo.multipliers[pendingRewardIndex] : poolInfo.rewardMultipliers[pendingRewardIndex],
),
Expand Down
2 changes: 1 addition & 1 deletion src/state/farms/classic/updater.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import KNUpdater from 'state/farms/classic/knUpdater'
import RPCUpdater from 'state/farms/classic/rpcUpdater'

export default function Updater({ isInterval = true }: { isInterval?: boolean }) {
// const { isEnableKNProtocol } = useKyberSwapConfig()
// const { isEnableKNProtocol } = useKyberSwapConfig() // todo namgold: revert
const isEnableKNProtocol = true
return isEnableKNProtocol ? <KNUpdater isInterval={isInterval} /> : <RPCUpdater isInterval={isInterval} />
}
3 changes: 3 additions & 0 deletions src/utils/numbers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ type FormatOptions = {
significantDigits?: number // usually for decimal style
fallback?: string
allowNegative?: boolean
allowZero?: boolean
}
interface RequiredFraction extends FormatOptions {
fractionDigits: number // usually for percent & currency styles
Expand Down Expand Up @@ -156,6 +157,7 @@ export const formatDisplayNumber = (
fractionDigits,
fallback = '--',
allowNegative = false,
allowZero = true,
}: RequiredFraction | RequiredSignificant,
): string => {
const currency = style === 'currency' ? '$' : ''
Expand All @@ -165,6 +167,7 @@ export const formatDisplayNumber = (
if (value === undefined || value === null || Number.isNaN(value)) return fallbackResult
const parsedFraction = parseNum(value)
if (!allowNegative && parsedFraction.lessThan(BIG_INT_ZERO)) return fallbackResult
if (!allowZero && parsedFraction.equalTo(BIG_INT_ZERO)) return fallbackResult

const shownFraction = style === 'percent' ? parsedFraction.multiply(100) : parsedFraction
const absShownFraction = shownFraction.lessThan(0) ? shownFraction.multiply(-1) : shownFraction
Expand Down

0 comments on commit 30b4b05

Please sign in to comment.