Skip to content

Commit

Permalink
Refactor code to include SkyUpgrade feature flag
Browse files Browse the repository at this point in the history
  • Loading branch information
marcinciarka committed Sep 18, 2024
1 parent 848bef6 commit 21e7347
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 8 deletions.
13 changes: 9 additions & 4 deletions components/portfolio/positions/PortfolioPositionBlock.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,11 @@ const getMigrationGradientsPerProtocol = (

export const PortfolioPositionBlock = ({ position }: { position: PortfolioPosition }) => {
const { t: tPortfolio } = useTranslation('portfolio')
const { EnableRefinance: isRefinanceEnabled, Rays: isRaysEnabled } = useAppConfig('features')
const {
EnableRefinance: isRefinanceEnabled,
Rays: isRaysEnabled,
SkyUpgrade,
} = useAppConfig('features')

const resolvedPairId = shouldShowPairId({
collateralToken: position.primaryToken,
Expand Down Expand Up @@ -87,9 +91,10 @@ export const PortfolioPositionBlock = ({ position }: { position: PortfolioPositi
: {}

const showSkyBanner =
position.protocol === LendingProtocol.Maker ||
[position.primaryToken, position.secondaryToken].includes('DAI') ||
[position.primaryToken, position.secondaryToken].includes('MKR')
SkyUpgrade &&
(position.protocol === LendingProtocol.Maker ||
[position.primaryToken, position.secondaryToken].includes('DAI') ||
[position.primaryToken, position.secondaryToken].includes('MKR'))

return (
<>
Expand Down
4 changes: 3 additions & 1 deletion components/vault/GeneralManageLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { VaultNoticesView } from 'features/notices/VaultsNoticesView'
import { vaultTypeToSDKType } from 'features/refinance/helpers/vaultTypeToSDKType'
import { useMakerRefinanceContextInputs } from 'features/refinance/hooks'
import { UpgradeToSkyBanner } from 'features/sky/components/UpgradeToSkyBanner'
import { useAppConfig } from 'helpers/config'
import { useTranslation } from 'next-i18next'
import React from 'react'
import { Box, Card, Grid } from 'theme-ui'
Expand All @@ -23,6 +24,7 @@ interface GeneralManageLayoutProps {

export function GeneralManageLayout({ generalManageVault, chainId }: GeneralManageLayoutProps) {
const { t } = useTranslation()
const { SkyUpgrade } = useAppConfig('features')
const { ilkData, vault, priceInfo, account } = generalManageVault.state
const colRatioPercnentage = vault.collateralizationRatio.times(100).toFixed(2)

Expand Down Expand Up @@ -75,7 +77,7 @@ export function GeneralManageLayout({ generalManageVault, chainId }: GeneralMana

return (
<Grid gap={0} sx={{ width: '100%' }}>
{isOwner && <UpgradeToSkyBanner />}
{isOwner && SkyUpgrade && <UpgradeToSkyBanner />}
<VaultNoticesView id={vault.id} />
<Box sx={{ zIndex: 2, mt: 4 }}>{headlineElement}</Box>
<GeneralManageTabBar
Expand Down
4 changes: 3 additions & 1 deletion features/dsr/containers/DsrView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { handleAmountChange } from 'features/dsr/utils/formUtils'
import { selectPrimaryAction } from 'features/dsr/utils/helpers'
import { VaultOwnershipBanner } from 'features/notices/VaultsNoticesView'
import { UpgradeToSkyBanner } from 'features/sky/components/UpgradeToSkyBanner'
import { useAppConfig } from 'helpers/config'
import { formatCryptoBalance, formatPercent } from 'helpers/formatters/format'
import type { Loadable } from 'helpers/loadable'
import { zero } from 'helpers/zero'
Expand Down Expand Up @@ -55,6 +56,7 @@ export function DsrView({
daiPrice,
}: DsrViewProps) {
const { t } = useTranslation()
const { SkyUpgrade } = useAppConfig('features')
const isLoading = isLoadingCollection.includes(dsrDepositState.stage)

const account = context.status === 'connected' ? context.account : undefined
Expand All @@ -70,7 +72,7 @@ export function DsrView({
<VaultOwnershipBanner account={account} controller={walletAddress} />
</Box>
)}
{isOwner && <UpgradeToSkyBanner />}
{isOwner && SkyUpgrade && <UpgradeToSkyBanner />}
<VaultHeadline
header={t('dsr.titles.heading')}
tokens={['DAI']}
Expand Down
5 changes: 3 additions & 2 deletions features/omni-kit/controllers/OmniLayoutController.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import React from 'react'
import { Box, Container, Grid } from 'theme-ui'

export function OmniLayoutController({ txHandler }: { txHandler: () => () => void }) {
const { ProxyReveal: proxyReveal, LambdaAutomations } = useAppConfig('features')
const { ProxyReveal: proxyReveal, LambdaAutomations, SkyUpgrade } = useAppConfig('features')

const { t } = useTranslation()

Expand Down Expand Up @@ -107,7 +107,8 @@ export function OmniLayoutController({ txHandler }: { txHandler: () => () => voi
: false

const showSkyBanner =
[quoteToken, collateralToken].includes('DAI') || [quoteToken, collateralToken].includes('MKR')
SkyUpgrade &&
([quoteToken, collateralToken].includes('DAI') || [quoteToken, collateralToken].includes('MKR'))

return (
<Container variant="vaultPageContainerStatic">
Expand Down

0 comments on commit 21e7347

Please sign in to comment.