From f4c76d3b496a472aeca0351f2abec06103abef11 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 22 Nov 2026 22:53:11 +0200 Subject: [PATCH 1/2] Reword the coin page Earn banner for people who already hold Yield Title now names the idle amount ("Earn 6.4% a year on this $18.98") and the subtitle reads "Move it to USD Yield, with your $36.17". For T-263. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01RHaUoPFs8TgCcE2naeM9mq --- components/Coin/CoinEarnBanner.tsx | 12 +++++++--- .../Coin/__tests__/CoinEarnBanner.test.tsx | 22 ++++++++++++++++++- 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/components/Coin/CoinEarnBanner.tsx b/components/Coin/CoinEarnBanner.tsx index 0aef26a30..040d21029 100644 --- a/components/Coin/CoinEarnBanner.tsx +++ b/components/Coin/CoinEarnBanner.tsx @@ -91,12 +91,18 @@ const EarnBannerRow = ({ vault, symbol, balance, balanceUsd }: EarnOffer) => { ? (balanceUsd * Number(apyText)) / 100 >= 1 : yearlyYield.raw >= 10n ** BigInt(yearlyYield.decimals); + // Someone who already holds this Yield product reads the idle amount itself. + const idleAmount = Number(formatUnits(balance.raw, balance.decimals)); + const idleLabel = isEth + ? `${formatTokenAmount(idleAmount)} ETH` + : formatYieldAmount(idleAmount, vault.type); + let subtitle = `Put it in ${name}`; if (savings) { subtitle = savings.balance > 0 - ? `Add it to your ${formatYieldAmount(savings.balance, vault.type)} in ${name}` - : `Add it to ${name}`; + ? `Move it to ${name}, with your ${formatYieldAmount(savings.balance, vault.type)}` + : `Move it to ${name}`; } else if (apyLabel && meetsEstimateMinimum) { subtitle += isEth ? ` ยท ~${formatTokenAmount(Number(formatUnits(yearlyYield.raw, yearlyYield.decimals)))} ETH a year` @@ -145,7 +151,7 @@ const EarnBannerRow = ({ vault, symbol, balance, balanceUsd }: EarnOffer) => { ) : ( (apyLabel ?? 'yield') )} - {savings ? ` on this ${symbol} too` : `${apyLabel ? ' a year' : ''} on your ${symbol}`} + {`${apyLabel ? ' a year' : ''} on ${savings ? `this ${idleLabel}` : `your ${symbol}`}`} {!slim && {subtitle}} diff --git a/components/Coin/__tests__/CoinEarnBanner.test.tsx b/components/Coin/__tests__/CoinEarnBanner.test.tsx index b8d9381fd..891361ef7 100644 --- a/components/Coin/__tests__/CoinEarnBanner.test.tsx +++ b/components/Coin/__tests__/CoinEarnBanner.test.tsx @@ -4,6 +4,7 @@ import { arbitrum, base, fuse, mainnet } from 'viem/chains'; import CoinEarnBanner from '@/components/Coin/CoinEarnBanner'; import { useMaxAPY } from '@/hooks/useAnalytics'; +import { useSavingsVaults } from '@/hooks/useSavingsVaults'; import { TokenBalance, TokenType, VaultType } from '@/lib/types'; import { getVaultDepositToken } from '@/lib/vaults'; @@ -15,7 +16,7 @@ jest.mock('react-native/Libraries/Utilities/useWindowDimensions', () => ({ default: () => ({ width: 419 }), })); jest.mock('@/hooks/useAnalytics', () => ({ useMaxAPY: jest.fn() })); -jest.mock('@/hooks/useSavingsVaults', () => ({ useSavingsVaults: () => ({ vaults: [] }) })); +jest.mock('@/hooks/useSavingsVaults', () => ({ useSavingsVaults: jest.fn() })); jest.mock('@/components/ui/text', () => ({ Text: 'Text' })); jest.mock('@/lib/utils', () => ({ cn: (...classes: string[]) => classes.filter(Boolean).join(' '), @@ -51,6 +52,7 @@ const copy = () => .replace(/\s+/g, ' '); beforeEach(() => { + (useSavingsVaults as jest.Mock).mockReturnValue({ vaults: [] }); (useMaxAPY as jest.Mock).mockImplementation((vault: VaultType) => ({ maxAPY: vault === VaultType.EUR ? 0 : vault === VaultType.ETH ? 2.9 : 4.5, })); @@ -73,6 +75,24 @@ it('projects the eligible USDC across networks and opens USD Yield', () => { expect(router.push).toHaveBeenCalledWith({ pathname: '/savings', params: { vault: 'usdc' } }); }); +it('names the idle amount and the USD Yield balance for someone who already holds USD Yield', () => { + (useSavingsVaults as jest.Mock).mockReturnValue({ vaults: [{ key: 'USD', balance: 36.17 }] }); + render(heldToken('USDC', base.id, '18980000')); + + expect(copy()).toContain('4.5%'); + expect(copy()).toContain('a year on this $18.98'); + expect(copy()).toContain('Move it to USD Yield, with your $36.17'); + expect(copy()).not.toContain('too'); +}); + +it('drops the balance from the subtitle once the USD Yield holding is empty', () => { + (useSavingsVaults as jest.Mock).mockReturnValue({ vaults: [{ key: 'USD', balance: 0 }] }); + render(heldToken('USDC', base.id, '18980000')); + + expect(copy()).toContain('a year on this $18.98'); + expect(copy()).toMatch(/Move it to USD Yield$/); +}); + it('omits the offer when the wallet holds only an unsupported contract with the right ticker', () => { render({ ...heldToken('USDT', mainnet.id, '500000000'), chainId: base.id }); expect(root.toJSON()).toBeNull(); From 881812d23d51815276ace51cea22160c97e95146 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 23 Nov 2026 11:11:15 +0200 Subject: [PATCH 2/2] Earn banner: format the idle amount in token units and keep the slim title on one line For task T-263. The existing-holder title now formats the idle amount from its bigint token units instead of a floating-point number, and under 390pt the title stays on one line by shrinking to fit. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01RHaUoLe7mFtPNbjcA2pAk9 --- components/Coin/CoinEarnBanner.tsx | 25 ++++++++++-- .../Coin/__tests__/CoinEarnBanner.test.tsx | 39 ++++++++++++++++++- 2 files changed, 60 insertions(+), 4 deletions(-) diff --git a/components/Coin/CoinEarnBanner.tsx b/components/Coin/CoinEarnBanner.tsx index 040d21029..40a36af19 100644 --- a/components/Coin/CoinEarnBanner.tsx +++ b/components/Coin/CoinEarnBanner.tsx @@ -71,6 +71,22 @@ const getEarnOffer = (token: TokenBalance, tokens: TokenBalance[]): EarnOffer | } }; +/** The idle cash to the cent, kept in token units: `$18.98`, or `<$0.01` under a cent. */ +const formatIdleCash = (amount: TokenUnits, currency: string) => + amount.raw * 100n < 10n ** BigInt(amount.decimals) + ? `<${currency}0.01` + : `${currency}${formatTokenUnits(amount, 2, 2)}`; + +/** The idle ETH kept short and in token units, the way `formatTokenAmount` shortens a number. */ +const formatIdleEth = (amount: TokenUnits) => { + const one = 10n ** BigInt(amount.decimals); + if (amount.raw >= 1000n * one) return formatTokenUnits(amount, 2, 2); + if (amount.raw >= one) return formatTokenUnits(amount, 4, 2); + // About four significant digits: the leading zeros after the point, plus three. + const leadingPlaces = amount.decimals - amount.raw.toString().length + 1; + return formatTokenUnits(amount, Math.min(8, leadingPlaces + 3)); +}; + /** Figma 31247:16253 and 31247:16245. */ const EarnBannerRow = ({ vault, symbol, balance, balanceUsd }: EarnOffer) => { const { width } = useWindowDimensions(); @@ -92,10 +108,9 @@ const EarnBannerRow = ({ vault, symbol, balance, balanceUsd }: EarnOffer) => { : yearlyYield.raw >= 10n ** BigInt(yearlyYield.decimals); // Someone who already holds this Yield product reads the idle amount itself. - const idleAmount = Number(formatUnits(balance.raw, balance.decimals)); const idleLabel = isEth - ? `${formatTokenAmount(idleAmount)} ETH` - : formatYieldAmount(idleAmount, vault.type); + ? `${formatIdleEth(balance)} ETH` + : formatIdleCash(balance, getVaultCurrencySymbol(vault.type)); let subtitle = `Put it in ${name}`; if (savings) { @@ -139,6 +154,10 @@ const EarnBannerRow = ({ vault, symbol, balance, balanceUsd }: EarnOffer) => { ({ router: { push: jest.fn() } })); jest.mock('expo-image', () => ({ Image: 'Image' })); +let mockWidth = 419; jest.mock('react-native/Libraries/Utilities/useWindowDimensions', () => ({ __esModule: true, - default: () => ({ width: 419 }), + default: () => ({ width: mockWidth }), })); jest.mock('@/hooks/useAnalytics', () => ({ useMaxAPY: jest.fn() })); jest.mock('@/hooks/useSavingsVaults', () => ({ useSavingsVaults: jest.fn() })); @@ -60,6 +61,7 @@ beforeEach(() => { afterEach(() => { act(() => root.unmount()); + mockWidth = 419; jest.clearAllMocks(); }); @@ -93,6 +95,41 @@ it('drops the balance from the subtitle once the USD Yield holding is empty', () expect(copy()).toMatch(/Move it to USD Yield$/); }); +it('shows the idle ETH in ETH, and under a cent of idle cash as less than a cent', () => { + (useSavingsVaults as jest.Mock).mockReturnValue({ + vaults: [ + { key: 'ETH', balance: 1 }, + { key: 'USD', balance: 36.17 }, + ], + }); + render(heldToken('ETH', mainnet.id, '150000000000000000')); + expect(copy()).toContain('a year on this 0.15 ETH'); + + act(() => root.unmount()); + render(heldToken('ETH', mainnet.id, '1234567890123456789012')); + expect(copy()).toContain('a year on this 1,234.57 ETH'); + + act(() => root.unmount()); + render(heldToken('ETH', mainnet.id, '9123456789012345')); + expect(copy()).toContain('a year on this 0.009123 ETH'); + + act(() => root.unmount()); + render(heldToken('USDC', base.id, '9999')); + expect(copy()).toContain('a year on this <$0.01'); +}); + +it('keeps the title on one line on a narrow phone, where it is the only text', () => { + mockWidth = 375; + (useSavingsVaults as jest.Mock).mockReturnValue({ vaults: [{ key: 'USD', balance: 36.17 }] }); + render(heldToken('USDC', base.id, '12345670000')); + + expect(copy()).toContain('a year on this $12,345.67'); + expect(copy()).not.toContain('Move it to'); + const title = root.root.findAllByType('Text')[0]; + expect(title.props.numberOfLines).toBe(1); + expect(title.props.adjustsFontSizeToFit).toBe(true); +}); + it('omits the offer when the wallet holds only an unsupported contract with the right ticker', () => { render({ ...heldToken('USDT', mainnet.id, '500000000'), chainId: base.id }); expect(root.toJSON()).toBeNull();