Skip to content

Commit

Permalink
Savings page card adjustments (#496)
Browse files Browse the repository at this point in the history
* Remove and replace base devnet icon

* Make sure savings opportunity layout works correctly

* Change savings token card header

* Display chains for which savings are available

* Fix lint
  • Loading branch information
oskarvu authored Dec 17, 2024
1 parent ca29dbb commit 9a8c708
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 16 deletions.
22 changes: 20 additions & 2 deletions packages/app/src/config/chain/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { base, gnosis, mainnet } from 'viem/chains'
import { NATIVE_ASSET_MOCK_ADDRESS, infoSkyApiUrl } from '../consts'
import { AppConfig } from '../feature-flags'
import { PLAYWRIGHT_USDS_CONTRACTS_NOT_AVAILABLE_KEY } from '../wagmi/config.e2e'
import { farmAddresses, farmStablecoinsEntryGroup, susdsAddresses } from './constants'
import { SUPPORTED_CHAINS, farmAddresses, farmStablecoinsEntryGroup, susdsAddresses } from './constants'
import { ChainConfigEntry, ChainMeta, SupportedChainId } from './types'

const commonTokenSymbolToReplacedName = {
Expand Down Expand Up @@ -308,7 +308,7 @@ const chainConfig: Record<SupportedChainId, ChainConfigEntry> = {
psmStables: [TokenSymbol('USDC'), TokenSymbol('USDS')],
meta: {
name: 'Base',
logo: assets.chain.baseDevNet,
logo: assets.chain.base,
},
tokensWithMalformedApprove: [],
permitSupport: {},
Expand Down Expand Up @@ -348,6 +348,24 @@ const chainConfig: Record<SupportedChainId, ChainConfigEntry> = {
},
}

export const featureAvailability = (function getFeatureAvailability(): Record<
'savings' | 'markets' | 'farms',
SupportedChainId[]
> {
// @note: using SUPPORTED_CHAIN instead of Object.values(chainConfig) to maintain chains order,
// since chain config members are automatically sorted in js (object key is a number).
function getSupportedChains(predicate: (config: ChainConfigEntry) => boolean): SupportedChainId[] {
return SUPPORTED_CHAINS.map((chain) => chainConfig[chain.id])
.filter(predicate)
.map((config) => config.originChainId)
}
return {
savings: getSupportedChains((config) => config.savings !== undefined),
markets: getSupportedChains((config) => config.markets !== undefined),
farms: getSupportedChains((config) => config.farms !== undefined),
}
})()

export function getChainConfigEntry(chainId: number): ChainConfigEntry {
const sandboxConfig = useStore.getState().appConfig.sandbox
const sandbox = useStore.getState().sandbox.network
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const meta: Meta<typeof SelectNetworkDialogView> = {
onSelect: () => {},
},
{
logo: assets.chain.baseDevNet,
logo: assets.chain.base,
name: 'Base',
supportedPages: ['Savings', 'Farms'],
selected: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export function Card({ children, hasNoCash }: CardProps) {
spacing="m"
className={cn(
'grid grid-cols-1 gap-8 bg-center bg-cover',
'bg-savings-opportunity-panel bg-no-repeat lg:grid-cols-[3fr_2fr]',
'bg-savings-opportunity-panel bg-no-repeat xl:grid-cols-[3fr_2fr]',
hasNoCash && 'gap-6 lg:grid-cols-1',
)}
data-testid={testIds.savings.opportunity.panel}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { getChainConfigEntry } from '@/config/chain'
import { featureAvailability, getChainConfigEntry } from '@/config/chain'
import { SupportedChainId } from '@/config/chain/types'
import { USD_MOCK_TOKEN } from '@/domain/types/Token'
import { TokenSymbol } from '@/domain/types/TokenSymbol'
import { SavingsMeta } from '@/features/savings/logic/makeSavingsMeta'
import { getTokenImage } from '@/ui/assets'
import { testIds } from '@/ui/utils/testIds'
import { NormalizedUnitNumber } from '@marsfoundation/common-universal'
import { ArrowRightIcon } from 'lucide-react'
import { SlashIcon } from 'lucide-react'

export interface ExplainerProps {
stablecoinValue?: NormalizedUnitNumber
Expand All @@ -16,17 +16,17 @@ export interface ExplainerProps {

export function Explainer({ stablecoinValue, savingsMeta, originChainId }: ExplainerProps) {
const { stablecoin, rateName } = savingsMeta.primary
const { savings, sdaiSymbol, susdsSymbol } = getChainConfigEntry(originChainId)
const { savings } = getChainConfigEntry(originChainId)

return (
<div className="flex flex-col justify-end gap-5">
<div className="flex items-center gap-1">
{savings?.inputTokens.map((symbol) => (
<img key={symbol} src={getTokenImage(TokenSymbol(symbol))} className="h-6 w-6" />
))}
<ArrowRightIcon className="icon-xs icon-primary-inverse" />
{[sdaiSymbol, susdsSymbol].filter(Boolean).map((symbol) => (
<img key={symbol} src={getTokenImage(TokenSymbol(symbol))} className="h-6 w-6" />
<SlashIcon className="icon-xs icon-tertiary -rotate-12" />
{featureAvailability.savings.map((chainId) => (
<img key={chainId} src={getChainConfigEntry(chainId).meta.logo} className="h-6 w-6" />
))}
</div>
<div className="typography-body-4 max-w-[52ch] text-tertiary">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export function SavingsTokenPanel({
<div className="flex w-full flex-row items-center justify-between">
<div className="flex flex-row items-center gap-1">
<div className="typography-heading-4 text-primary-inverse">
{savingsType === 'sdai' ? 'Savings DAI' : 'Savings USDS'}
{savingsType === 'sdai' ? 'DAI Savings' : 'USDS Savings'}
</div>
</div>
<div className="md:-mt-2 md:-mr-2 flex flex-row gap-1">
Expand Down
3 changes: 0 additions & 3 deletions packages/app/src/ui/assets/chains/baseDevNet.svg

This file was deleted.

2 changes: 0 additions & 2 deletions packages/app/src/ui/assets/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import symbolDark from './brand/symbol-dark.svg'
import symbolGradient from './brand/symbol-gradient.svg'
import symboLight from './brand/symbol-light.svg'
import base from './chains/base.svg'
import baseDevNet from './chains/baseDevNet.svg'
import ethereum from './chains/ethereum.svg'
import gnosis from './chains/gnosis.svg'
import checkCircle from './check-circle.svg'
Expand Down Expand Up @@ -162,7 +161,6 @@ export const assets = {
gnosis,
ethereum,
unknown,
baseDevNet,
base,
},
token: {
Expand Down

0 comments on commit 9a8c708

Please sign in to comment.