diff --git a/apps/web/src/views/FixedStaking/components/FixedStakingPosition.tsx b/apps/web/src/views/FixedStaking/components/FixedStakingActions.tsx
similarity index 97%
rename from apps/web/src/views/FixedStaking/components/FixedStakingPosition.tsx
rename to apps/web/src/views/FixedStaking/components/FixedStakingActions.tsx
index 3d0fbb2653ad57..f544439b4379c3 100644
--- a/apps/web/src/views/FixedStaking/components/FixedStakingPosition.tsx
+++ b/apps/web/src/views/FixedStaking/components/FixedStakingActions.tsx
@@ -36,7 +36,7 @@ import { StakePositionUserInfo } from '../type'
import { UnlockedFixedTag } from './UnlockedFixedTag'
import { FixedStakingModal } from './FixedStakingModal'
-export function FixedStakingPosition({
+export function FixedStakingActions({
token,
stakePositionUserInfo,
unlockTime,
@@ -168,7 +168,7 @@ export function FixedStakingPosition({
APR
- 36%
+ 0%
@@ -180,7 +180,7 @@ export function FixedStakingPosition({
Projected Return
- 2.055 {token.symbol}
+ 0 {token.symbol}
@@ -196,13 +196,13 @@ export function FixedStakingPosition({
Withdrawal Commission
- 1.2507 {token.symbol}
+ 0 {token.symbol}
You Will Get
- 1,1410 {token.symbol}
+ 0 {token.symbol}
) : (
{
+ const isBoost = useMemo(() => new BigNumber(pool.boostDayPercent).gt(0), [pool.boostDayPercent])
+ const { t } = useTranslation()
+ const totalStakedAmount = getBalanceAmount(pool.totalDeposited, pool.token.decimals)
+ const { isMobile, isTablet } = useMatchBreakpoints()
+
+ const currentDate = useCurrenDay()
+
+ const remainingDays = pool.endDay - currentDate
+
+ const formattedUsdValueStaked = useStablecoinPriceAmount(pool.token, totalStakedAmount.toNumber())
+ const stakePosition = stakedPositions.find((position) => position.pool.token.address === pool.token.address)
+
+ return (
+
+
+
+
+ {t('APR:')}
+
+
+
+
+ {t('Ends in')}
+
+ {remainingDays > 0 ? remainingDays : 0} {t('days')}
+
+
+
+
+ {stakePosition ? (
+
+
+
+ ) : null}
+
+ {stakePosition ? (
+
+
+
+ {`${pool.token.symbol} `}
+
+
+ {t('Staked')}
+
+
+
+
+ ) : (
+
+
+
+ {t('Stake')}
+
+
+ {`${pool.token.symbol} `}
+
+
+
+ {(openModal) => {t('Stake')}}
+
+
+ )}
+
+
+
+ }
+ >
+
+
+
+
+ {pool.token.symbol}
+
+ {isBoost ? (
+ isMobile || isTablet ? (
+ <>
+
+ {pool.lockPeriod}D
+
+ {isBoost ? (
+ }
+ >
+
+ vCAKE
+
+
+ ) : null}
+ >
+ ) : isBoost ? (
+ }
+ >
+
+ vCAKE Boost
+
+
+ ) : null
+ ) : null}
+
+
+ {isMobile || isTablet ? null : (
+
+
+
+ Lock Periods
+
+ {pool.lockPeriod}D
+
+
+ )}
+
+
+
+ {t('APR')}
+
+
+
+
+
+
+
+ {t('Total Staked:')}
+
+
+
+
+ {isMobile || isTablet ? null : (
+
+
+
+ {t('Ends in')}
+
+
+ {remainingDays > 0 ? remainingDays : 0} {t('days')}
+
+
+
+ )}
+
+ )
+}
+
+export default memo(FixedStakingRow)
diff --git a/apps/web/src/views/FixedStaking/components/HarvestFixedStaking.tsx b/apps/web/src/views/FixedStaking/components/HarvestFixedStaking.tsx
index 763a2fcdd12c10..cad478ec4b0def 100644
--- a/apps/web/src/views/FixedStaking/components/HarvestFixedStaking.tsx
+++ b/apps/web/src/views/FixedStaking/components/HarvestFixedStaking.tsx
@@ -8,8 +8,6 @@ import {
PreTitle,
Text,
useModalV2,
- Message,
- MessageText,
useToast,
Balance,
} from '@pancakeswap/uikit'
@@ -36,11 +34,13 @@ export function HarvestFixedStaking({
stakePositionUserInfo,
unlockTime,
lockPeriod,
+ poolIndex,
}: {
unlockTime: number
token: Token
stakePositionUserInfo: StakePositionUserInfo
lockPeriod: number
+ poolIndex: number
}) {
const { t } = useTranslation()
const stakeModal = useModalV2()
@@ -49,26 +49,26 @@ export function HarvestFixedStaking({
const { callWithGasPrice } = useCallWithGasPrice()
const { toastSuccess } = useToast()
- const totalStakedAmount = getBalanceAmount(stakePositionUserInfo.userDeposit, token.decimals)
+ const earnedAmount = getBalanceAmount(stakePositionUserInfo.accrueInterest, token.decimals)
- const formattedUsdValueStaked = useStablecoinPriceAmount(token, totalStakedAmount.toNumber())
+ const formattedUsdEarnedAmount = useStablecoinPriceAmount(token, earnedAmount.toNumber())
const handleSubmission = useCallback(async () => {
const receipt = await fetchWithCatchTxError(() => {
- const methodArgs = [0]
- return callWithGasPrice(fixedStakingContract, 'withdraw', methodArgs)
+ const methodArgs = [poolIndex]
+ return callWithGasPrice(fixedStakingContract, 'harvest', methodArgs)
})
if (receipt?.status) {
toastSuccess(
t('Successfully submitted!'),
- {t('Your withdrawn request has been submitted.')}
+ {t('Your harvest request has been submitted.')}
,
)
stakeModal.onDismiss()
}
- }, [callWithGasPrice, fetchWithCatchTxError, fixedStakingContract, stakeModal, t, toastSuccess])
+ }, [callWithGasPrice, fetchWithCatchTxError, fixedStakingContract, poolIndex, stakeModal, t, toastSuccess])
const shouldUnlock = differenceInMilliseconds(unlockTime * 1_000, new Date())
@@ -79,27 +79,28 @@ export function HarvestFixedStaking({
-
+
{token.symbol}
-
+
- {shouldUnlock ? {t('End')} : {t('90D')}}
+ {shouldUnlock ? (
+ {t('Ended')}
+ ) : (
+ {unlockTime}D
+ )}
- APR: 35%
+ APR: 0%
Unlock on {format(unlockTime * 1_000, 'MMM d, yyyy')}
-
- Est. Reward: 2.155 {token.symbol}
-
{t('Harvest')}
@@ -115,7 +116,7 @@ export function HarvestFixedStaking({
{token?.symbol}
{shouldUnlock ? (
- {t('End')}
+ {t('Ended')}
) : (
{lockPeriod}D
)}
@@ -128,15 +129,15 @@ export function HarvestFixedStaking({
- {t('Stake Amount')}
+ {t('Earned Amount')}
-
+
{token.symbol}
-
+
@@ -157,57 +158,7 @@ export function HarvestFixedStaking({
-
- {t('Position Details')}
-
-
-
-
- Duration
-
- {lockPeriod} Days
-
-
-
- APR
-
- 36%
-
-
-
- Unlock Date
-
- {format(unlockTime * 1_000, 'MMM d, yyyy hh:mm')}
-
-
-
- Projected Return
-
- 2.055 {token.symbol}
-
-
-
- {t('Withdrawal Details')}
-
-
-
-
- {t('No rewards are credited for early withdrawal, and commission is required')}
-
-
-
-
- Withdrawal Commission
-
- 1.2507 {token.symbol}
-
-
-
- You Will Get
-
- 1,1410 {token.symbol}
-
-
+
- {pendingTx ? t('Unstaking...') : t('Unstake')}
+ {pendingTx ? t('Harvesting') : t('Harvest')}
diff --git a/apps/web/src/views/FixedStaking/components/InlineText.tsx b/apps/web/src/views/FixedStaking/components/InlineText.tsx
new file mode 100644
index 00000000000000..ead7783987323a
--- /dev/null
+++ b/apps/web/src/views/FixedStaking/components/InlineText.tsx
@@ -0,0 +1,6 @@
+import { Text } from '@pancakeswap/uikit'
+import styled from 'styled-components'
+
+export const InlineText = styled(Text)`
+ display: inline;
+`
diff --git a/apps/web/src/views/FixedStaking/components/LockedFixedTag.tsx b/apps/web/src/views/FixedStaking/components/LockedFixedTag.tsx
index 11c3b3a88a08af..0d41d5b839f0b3 100644
--- a/apps/web/src/views/FixedStaking/components/LockedFixedTag.tsx
+++ b/apps/web/src/views/FixedStaking/components/LockedFixedTag.tsx
@@ -1,8 +1,9 @@
import { Tag, LockIcon } from '@pancakeswap/uikit'
+import { ReactNode, CSSProperties } from 'react'
-export function LockedFixedTag({ children }) {
+export function LockedFixedTag({ children, style }: { children: ReactNode; style?: CSSProperties }) {
return (
- }>
+ }>
{children}
)
diff --git a/apps/web/src/views/FixedStaking/hooks/useStakedPools.ts b/apps/web/src/views/FixedStaking/hooks/useStakedPools.ts
index 6eb83999cf879a..7cb2375be9d0fc 100644
--- a/apps/web/src/views/FixedStaking/hooks/useStakedPools.ts
+++ b/apps/web/src/views/FixedStaking/hooks/useStakedPools.ts
@@ -6,8 +6,26 @@ import { useContractRead } from 'wagmi'
import toNumber from 'lodash/toNumber'
import { useMemo } from 'react'
import { useSingleContractMultipleData } from 'state/multicall/hooks'
+import BigNumber from 'bignumber.js'
import { FixedStakingPool, StakedPosition } from '../type'
+export function useCurrenDay(): number {
+ const fixedStakingContract = useFixedStakingContract()
+
+ const { chainId } = useActiveWeb3React()
+
+ const { data } = useContractRead({
+ abi: fixedStakingContract.abi,
+ address: fixedStakingContract.address as `0x${string}`,
+ functionName: 'getCurrentDay',
+ enabled: true,
+ watch: true,
+ chainId,
+ })
+
+ return (data || 0) as number
+}
+
export function useStakedPositionsByUser(): StakedPosition[] {
const fixedStakingContract = useFixedStakingContract()
const { account, chainId } = useActiveWeb3React()
@@ -80,7 +98,7 @@ export function useStakedPools(): FixedStakingPool[] {
depositEnabled: fixedStakePool[7],
maxDeposit: fixedStakePool[8],
minDeposit: fixedStakePool[9],
- totalDeposited: fixedStakePool[10],
+ totalDeposited: new BigNumber(fixedStakePool[10]),
maxPoolAmount: fixedStakePool[11],
minBoostAmount: fixedStakePool[12],
}
diff --git a/apps/web/src/views/FixedStaking/index.tsx b/apps/web/src/views/FixedStaking/index.tsx
index 9c1e46fa046809..b6225a628b2f57 100644
--- a/apps/web/src/views/FixedStaking/index.tsx
+++ b/apps/web/src/views/FixedStaking/index.tsx
@@ -1,110 +1,42 @@
import { useTranslation } from '@pancakeswap/localization'
import {
- CardBody,
Flex,
FlexLayout,
Heading,
- StarFillIcon,
PageHeader,
- Tag,
- Box,
- Text,
- Button,
+ Pool,
+ ToggleView,
+ ViewMode,
+ ButtonMenu,
+ ButtonMenuItem,
} from '@pancakeswap/uikit'
-import { StyledCard } from '@pancakeswap/uikit/src/widgets/Pool'
import Page from 'components/Layout/Page'
-import CurrencyLogo from 'components/Logo/CurrencyLogo'
-import BigNumber from 'bignumber.js'
-import styled from 'styled-components'
+import { useState } from 'react'
+import { useCurrenDay, useStakedPools, useStakedPositionsByUser } from './hooks/useStakedPools'
+import { FixedStakingCard } from './components/FixedStakingCard'
+import FixedStakingRow from './components/FixedStakingRow'
-import { FixedStakingCardBody } from './components/FixedStakingCardBody'
-import { FixedStakingPosition } from './components/FixedStakingPosition'
-import { useStakedPools, useStakedPositionsByUser } from './hooks/useStakedPools'
-import { FixedStakingPool, StakedPosition } from './type'
-import { HarvestFixedStaking } from './components/HarvestFixedStaking'
-import { FixedStakingModal } from './components/FixedStakingModal'
-
-const InlineText = styled(Text)`
- display: inline;
-`
-
-function FixedStakingCard({ pool, stakedPositions }: { pool: FixedStakingPool; stakedPositions: StakedPosition[] }) {
- const { t } = useTranslation()
-
- const stakePosition = stakedPositions.find((position) => position.pool.token.address === pool.token.address)
-
- return (
-
-
- <>
-
-
-
- {pool.token.symbol}
-
- {new BigNumber(pool.boostDayPercent).gt(0) ? (
- }>
- vCAKE Boost
-
- ) : null}
-
- >
-
-
-
- {stakePosition ? (
- <>
-
-
- {`${pool.token.symbol} `}
-
-
- {t('Earned')}
-
-
-
- >
- ) : null}
- {stakePosition ? (
- <>
-
-
- {`${pool.token.symbol} `}
-
-
- {t('Staked')}
-
-
-
- >
- ) : (
-
- {(openModal) => {t('Stake')}}
-
- )}
-
-
-
- )
+enum POOL_STATUS {
+ Finished = 1,
+ Live = 0,
}
const FixedStaking = () => {
const { t } = useTranslation()
+ const [viewMode, setViewMode] = useState(ViewMode.TABLE)
+
+ const [poolStatus, togglePoolStatus] = useState(POOL_STATUS.Live)
+
const stakingPools = useStakedPools()
const stakedPositions = useStakedPositionsByUser()
+ const currentDate = useCurrenDay()
+
+ const displayPools =
+ poolStatus === POOL_STATUS.Live
+ ? stakingPools.filter((pool) => pool.endDay > currentDate)
+ : stakingPools.filter((pool) => pool.endDay <= currentDate)
return (
<>
@@ -121,19 +53,44 @@ const FixedStaking = () => {
-
- {stakingPools.map(
- (pool) =>
- pool?.token && (
- stakedPool.token.address === pool.token.address,
- )}
- />
- ),
- )}
-
+
+
+
+
+ {t('Live')}
+ {t('Finished')}
+
+
+
+ {viewMode === ViewMode.TABLE ? (
+
+ {displayPools.map(
+ (pool) =>
+ pool && (
+ stakedPool.token.address === pool.token.address,
+ )}
+ pool={pool}
+ />
+ ),
+ )}
+
+ ) : (
+
+ {displayPools.map(
+ (pool) =>
+ pool?.token && (
+ stakedPool.token.address === pool.token.address,
+ )}
+ />
+ ),
+ )}
+
+ )}
>
)
diff --git a/apps/web/src/views/FixedStaking/type.ts b/apps/web/src/views/FixedStaking/type.ts
index a9cd322abfd38b..00a7d2afd2bda3 100644
--- a/apps/web/src/views/FixedStaking/type.ts
+++ b/apps/web/src/views/FixedStaking/type.ts
@@ -19,7 +19,7 @@ export interface FixedStakingPool {
depositEnabled: boolean
maxDeposit: number
minDeposit: number
- totalDeposited: number
+ totalDeposited: BigNumber
maxPoolAmount: number
minBoostAmount: number
}
diff --git a/apps/web/src/views/Pools/components/PoolsTable/ActionPanel/ActionPanel.tsx b/apps/web/src/views/Pools/components/PoolsTable/ActionPanel/ActionPanel.tsx
index 5b64805d54955c..566660513b22ef 100644
--- a/apps/web/src/views/Pools/components/PoolsTable/ActionPanel/ActionPanel.tsx
+++ b/apps/web/src/views/Pools/components/PoolsTable/ActionPanel/ActionPanel.tsx
@@ -37,7 +37,7 @@ const collapseAnimation = keyframes`
}
`
-const StyledActionPanel = styled.div<{ expanded: boolean }>`
+export const StyledActionPanel = styled.div<{ expanded: boolean }>`
animation: ${({ expanded }) =>
expanded
? css`
@@ -59,7 +59,7 @@ const StyledActionPanel = styled.div<{ expanded: boolean }>`
}
`
-const ActionContainer = styled.div<{ isAutoVault?: boolean; hasBalance?: boolean }>`
+export const ActionContainer = styled(Box)<{ isAutoVault?: boolean; hasBalance?: boolean }>`
display: flex;
flex-direction: column;
flex: 1;
@@ -81,7 +81,7 @@ interface ActionPanelProps {
expanded: boolean
}
-const InfoSection = styled(Box)`
+export const InfoSection = styled(Box)`
flex-grow: 0;
flex-shrink: 0;
flex-basis: auto;
diff --git a/apps/web/src/views/Pools/components/PoolsTable/Cells/NameCell.tsx b/apps/web/src/views/Pools/components/PoolsTable/Cells/NameCell.tsx
index 57fa806f82f6ea..565571ae82ef91 100644
--- a/apps/web/src/views/Pools/components/PoolsTable/Cells/NameCell.tsx
+++ b/apps/web/src/views/Pools/components/PoolsTable/Cells/NameCell.tsx
@@ -15,7 +15,7 @@ interface NameCellProps {
pool: Pool.DeserializedPool
}
-const StyledCell = styled(Pool.BaseCell)`
+export const StyledCell = styled(Pool.BaseCell)`
flex: 5;
flex-direction: row;
padding-left: 12px;