Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v7.9.5 #2796

Merged
merged 6 commits into from
Sep 28, 2023
Merged

v7.9.5 #2796

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "kwenta",
"version": "7.9.3",
"version": "7.9.5",
"description": "Kwenta",
"main": "index.js",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion packages/app/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@kwenta/app",
"version": "7.9.3",
"version": "7.9.5",
"scripts": {
"dev": "next",
"build": "next build",
Expand Down
5 changes: 3 additions & 2 deletions packages/app/src/components/ColoredPrice.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ import styled from 'styled-components'

import { PriceChange } from 'state/prices/types'

import { Body } from './Text'

export const getColorFromPriceChange = (change?: PriceChange) => {
return !change ? 'white' : change === 'up' ? 'green' : 'red'
}

const ColoredPrice = styled.div<{ priceChange?: PriceChange }>`
font-size: 13px;
const ColoredPrice = styled(Body)<{ priceChange?: PriceChange }>`
font-family: ${(props) => props.theme.fonts.mono};
color: ${(props) => {
const color = getColorFromPriceChange(props.priceChange)
Expand Down
8 changes: 5 additions & 3 deletions packages/app/src/components/Text/Body.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { ComponentType, memo } from 'react'
import styled, { css } from 'styled-components'

export type FontSize = 'xsmall' | 'small' | 'medium' | 'large'

export type BodyProps = React.HTMLAttributes<HTMLParagraphElement> & {
size?: 'xsmall' | 'small' | 'medium' | 'large'
size?: FontSize
weight?: 'regular' | 'bold' | 'black'
color?: 'primary' | 'secondary' | 'tertiary' | 'positive' | 'negative' | 'preview'
type?: 'p' | 'span'
Expand Down Expand Up @@ -51,7 +53,7 @@ const Body: React.FC<BodyProps> = memo(
)
)

const sizeMap = { xsmall: 10, small: 12, medium: 13, large: 15 } as const
export const fontSizeMap = { xsmall: 10, small: 12, medium: 13, large: 15 } as const

const getFontFamily = (weight: NonNullable<BodyProps['weight']>, mono?: boolean) => {
return mono ? (weight !== 'regular' ? 'monoBold' : 'mono') : weight
Expand All @@ -73,7 +75,7 @@ const BODY_STYLE = css<StyledBodyProps>`

${(props) => css`
color: ${props.theme.colors.selectedTheme.newTheme.text[props.$color]};
font-size: ${props.$fontSize ?? sizeMap[props.$size]}px;
font-size: ${props.$fontSize ?? fontSizeMap[props.$size]}px;
font-family: ${props.theme.fonts[getFontFamily(props.$weight, props.$mono)]};
${props.$capitalized &&
css`
Expand Down
3 changes: 0 additions & 3 deletions packages/app/src/constants/ui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,3 @@ export enum zIndex {
}

export const STAKING_DISABLED = false

// This flag controls the one-click swap-deposit-trade feature
export const SWAP_DEPOSIT_TRADE_ENABLED = false
10 changes: 5 additions & 5 deletions packages/app/src/pages/dashboard/staking.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import {
selectStakingV1,
selectTotalVestable,
} from 'state/staking/selectors'
import { selectRedirectToMigration } from 'state/stakingMigration/selectors'
import { selectStartMigration } from 'state/stakingMigration/selectors'
import media from 'styles/media'

import MigratePage from './migrate'
Expand All @@ -45,7 +45,7 @@ const StakingPage: StakingComponent = () => {
const kwentaRewards = useAppSelector(selectKwentaRewards)
const stakedResetTime = useAppSelector(selectStakedResetTime)
const stakingV1 = useAppSelector(selectStakingV1)
const redirectToMigration = useAppSelector(selectRedirectToMigration)
const startMigration = useAppSelector(selectStartMigration)

useFetchStakeMigrateData()

Expand All @@ -70,8 +70,8 @@ const StakingPage: StakingComponent = () => {

const timeLeft = useMemo(
() =>
stakedResetTime > new Date().getTime() / 1000
? formatTruncatedDuration(stakedResetTime - new Date().getTime() / 1000)
stakedResetTime > Date.now() / 1000
? formatTruncatedDuration(stakedResetTime - Date.now() / 1000)
: NO_VALUE,
[stakedResetTime]
)
Expand Down Expand Up @@ -200,7 +200,7 @@ const StakingPage: StakingComponent = () => {
}
}, [currentTab, handleChangeTab, stakingInfo, stakingV1, t])

return redirectToMigration ? (
return startMigration ? (
<MigratePage />
) : (
<>
Expand Down
1 change: 1 addition & 0 deletions packages/app/src/queries/rates/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export const mapPythCandles = (candleData: PythResponse): Candle[] => {

export const formatPythSymbol = (asset: string): string => {
if (asset === 'ETHBTC') return 'Crypto.ETH/BTC'
if (asset === 'STETH/ETH') return 'Crypto.STETH/ETH'
const prefix =
Object.keys(NON_CRYPTO_ASSET_TYPES).find((type) =>
NON_CRYPTO_ASSET_TYPES[type].includes(asset)
Expand Down
26 changes: 5 additions & 21 deletions packages/app/src/sections/dashboard/DashboardLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,7 @@ import ROUTES from 'constants/routes'
import AppLayout from 'sections/shared/Layout/AppLayout'
import { useAppSelector } from 'state/hooks'
import { selectStakingMigrationRequired } from 'state/staking/selectors'
import {
selectInMigrationPeriod,
selectIsMigrationPeriodStarted,
selectStartMigration,
} from 'state/stakingMigration/selectors'
import { selectStartMigration } from 'state/stakingMigration/selectors'
import { LeftSideContent, PageContent } from 'styles/common'

import Links from './Links'
Expand All @@ -34,10 +30,8 @@ const Tabs = Object.values(Tab)
const DashboardLayout: FC<{ children?: ReactNode }> = ({ children }) => {
const { t } = useTranslation()
const router = useRouter()
const stakngMigrationRequired = useAppSelector(selectStakingMigrationRequired)
const stakingMigrationRequired = useAppSelector(selectStakingMigrationRequired)
const startMigration = useAppSelector(selectStartMigration)
const isMigrationPeriodStarted = useAppSelector(selectIsMigrationPeriodStarted)
const inMigrationPeriod = useAppSelector(selectInMigrationPeriod)

const tabQuery = useMemo(() => {
if (router.pathname) {
Expand Down Expand Up @@ -76,17 +70,14 @@ const DashboardLayout: FC<{ children?: ReactNode }> = ({ children }) => {
label: t('dashboard.tabs.staking'),
active: activeTab === Tab.Stake,
href: ROUTES.Dashboard.Stake,
hidden:
(stakngMigrationRequired || startMigration) &&
isMigrationPeriodStarted &&
inMigrationPeriod,
hidden: startMigration,
},
{
name: Tab.Migrate,
label: t('dashboard.tabs.migrate'),
active: activeTab === Tab.Migrate,
href: ROUTES.Dashboard.Migrate,
hidden: !stakngMigrationRequired,
hidden: !stakingMigrationRequired && !startMigration,
},
{
name: Tab.Governance,
Expand All @@ -96,14 +87,7 @@ const DashboardLayout: FC<{ children?: ReactNode }> = ({ children }) => {
external: true,
},
],
[
t,
activeTab,
stakngMigrationRequired,
startMigration,
isMigrationPeriodStarted,
inMigrationPeriod,
]
[t, activeTab, startMigration, stakingMigrationRequired]
)

const visibleTabs = TABS.filter(({ hidden }) => !hidden)
Expand Down
5 changes: 3 additions & 2 deletions packages/app/src/sections/dashboard/FuturesMarketsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ const FuturesMarketsTable: React.FC<FuturesMarketsTableProps> = ({ search }) =>
<TableContainer>
<StyledTable
data={data}
showPagination
onTableRowClick={(row) => {
router.push(ROUTES.Markets.MarketPair(row.original.asset, accountType))
}}
Expand Down Expand Up @@ -138,7 +137,9 @@ const FuturesMarketsTable: React.FC<FuturesMarketsTableProps> = ({ search }) =>
cell: (cellProps) => {
return (
<ColoredPrice priceChange={cellProps.row.original.priceInfo?.change}>
{formatDollars(cellProps.row.original.price, { suggestDecimals: true })}
{formatDollars(cellProps.row.original.price, {
suggestDecimalsForAsset: cellProps.row.original.asset,
})}
</ColoredPrice>
)
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ const FuturesPositionsTable: FC<FuturesPositionTableProps> = ({
<StyledValue>
<ColoredPrice priceChange={cellProps.row.original.priceInfo?.change}>
{formatDollars(cellProps.row.original.marketPrice, {
suggestDecimals: true,
suggestDecimalsForAsset: cellProps.row.original.market.asset,
})}
</ColoredPrice>
</StyledValue>
Expand Down
18 changes: 10 additions & 8 deletions packages/app/src/sections/dashboard/Stake/StakingPortfolio.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,16 @@ const StakingPortfolio: FC<StakingPortfolioProps> = memo(({ title, cardsInfo })
{icon}
</LabelContainer>
<FlexDivRow columnGap="15px" justifyContent="flex-start">
{card.map(({ key, title, value, onClick }) => (
<FlexDivCol key={key} onClick={onClick} rowGap="5px">
<Body color="secondary">{title}</Body>
<Body size="large" color="preview">
{value}
</Body>
</FlexDivCol>
))}
{card
.filter((info) => !info.hidden)
.map(({ key, title, value, onClick }) => (
<FlexDivCol key={key} onClick={onClick} rowGap="5px">
<Body color="secondary">{title}</Body>
<Body size="large" color="preview">
{value}
</Body>
</FlexDivCol>
))}
</FlexDivRow>
</StyledFlexDivCol>
))}
Expand Down
21 changes: 20 additions & 1 deletion packages/app/src/sections/dashboard/Stake/StakingTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@ import { Body, Heading } from 'components/Text'
import { STAKING_DISABLED } from 'constants/ui'
import { StakingCard } from 'sections/dashboard/Stake/card'
import { useAppDispatch, useAppSelector } from 'state/hooks'
import { claimStakingRewards, claimStakingRewardsV2 } from 'state/staking/actions'
import { claimStakingRewards, claimStakingRewardsV2, compoundRewards } from 'state/staking/actions'
import {
selectApy,
selectClaimableBalance,
selectIsCompoundingRewards,
selectIsGettingReward,
selectStakedKwentaBalance,
selectStakingV1,
Expand All @@ -30,6 +31,7 @@ const StakingTab = () => {
const claimableBalance = useAppSelector(selectClaimableBalance)
const stakedKwentaBalance = useAppSelector(selectStakedKwentaBalance)
const isClaimingReward = useAppSelector(selectIsGettingReward)
const isCompoundingRewards = useAppSelector(selectIsCompoundingRewards)
const stakingV1 = useAppSelector(selectStakingV1)
const apy = useAppSelector(selectApy)

Expand All @@ -41,6 +43,10 @@ const StakingTab = () => {
}
}, [dispatch, stakingV1])

const handleCompoundReward = useCallback(() => {
dispatch(compoundRewards())
}, [dispatch])

const stakingAndRewardsInfo: StakingCards[] = useMemo(
() => [
{
Expand Down Expand Up @@ -116,6 +122,19 @@ const StakingTab = () => {
>
{t('dashboard.stake.tabs.staking.claim')}
</Button>
{!stakingV1 && (
<Button
variant="flat"
size="small"
textTransform="uppercase"
isRounded
loading={isCompoundingRewards}
disabled={claimableBalance.eq(0) || isCompoundingRewards || STAKING_DISABLED}
onClick={handleCompoundReward}
>
{t('dashboard.stake.tabs.staking.compound')}
</Button>
)}
</FlexDivRow>
</CardGridContainer>
</SplitContainer>
Expand Down
Loading
Loading