diff --git a/src/components/RouteIcons.tsx b/src/components/RouteIcons.tsx index 0a8b7e414..fc219bfb1 100644 --- a/src/components/RouteIcons.tsx +++ b/src/components/RouteIcons.tsx @@ -2,13 +2,17 @@ import { type ComponentType, type SVGProps, useState } from 'react' import { cx } from 'zyzz' +import LogoArbitrum from '~icons/token-branded/arbitrum-one' +import LogoAvalanche from '~icons/token-branded/avalanche' import LogoBase from '~icons/token-branded/base' import LogoBnb from '~icons/token-branded/bnb' import LogoEthereum from '~icons/token-branded/ethereum' import LogoHyperEvm from '~icons/token-branded/hyper-evm' import LogoMonad from '~icons/token-branded/monad' +import LogoOptimism from '~icons/token-branded/optimism' import LogoPolygon from '~icons/token-branded/polygon' import LogoSolana from '~icons/token-branded/solana' +import LogoStellar from '~icons/token-branded/stellar' import LogoTron from '~icons/token-branded/tron' import LogoUsdc from '~icons/token-branded/usdc' import LogoUsdt from '~icons/token-branded/usdt' @@ -21,16 +25,24 @@ type Logo = ComponentType> // Official chain marks (Web3 Icons) keyed by CAIP-2 id, matching the console's Routes map. const chainLogos: Record = { 'eip155:1': LogoEthereum, + 'eip155:10': LogoOptimism, 'eip155:137': LogoPolygon, 'eip155:143': LogoMonad, + 'eip155:42161': LogoArbitrum, + 'eip155:43114': LogoAvalanche, 'eip155:56': LogoBnb, 'eip155:8453': LogoBase, 'eip155:999': LogoHyperEvm, 'solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp': LogoSolana, + 'stellar:pubnet': LogoStellar, 'tron:0x2b6653dc': LogoTron, } // Tempo chains whose tokens have icons in the token list service. const tempoChainIds: Record = { 'eip155:4217': 4217, 'eip155:42431': 42431 } +// Tempo-issued tokens bridged to other networks share their Tempo icon, keyed by symbol. +const tempoIssued: Record = { + OUSD: '4217/0x20c0000000000000000000006a37da5c996874be', +} // Off-Tempo stablecoins with an official mark, by symbol family. const tokenLogo = (symbol: string): Logo | undefined => /^USDC/i.test(symbol) ? LogoUsdc : /^USDT/i.test(symbol) ? LogoUsdt : undefined @@ -84,8 +96,9 @@ export function ChainLogo({ } /** - * A token's icon: Tempo tokens load theirs from the token list service, other stablecoins use - * their official mark, and anything else falls back to a monogram. + * A token's icon: Tempo tokens, and Tempo-issued tokens on other networks, load theirs from the + * token list service, other stablecoins use their official mark, and anything else falls back to + * a monogram. */ export function TokenLogo({ chainId, @@ -102,13 +115,14 @@ export function TokenLogo({ const [broken, setBroken] = useState(false) const tempo = chainId ? tempoChainIds[chainId] : undefined const address = tokenKey ? erc20Address(tokenKey) : undefined - if (symbol && tempo && address && !broken) + const icon = tempo && address ? `${tempo}/${address}` : symbol ? tempoIssued[symbol] : undefined + if (symbol && icon && !broken) return ( setBroken(true)} - src={`https://tokenlist.tempo.xyz/icon/${tempo}/${address}.svg`} + src={`https://tokenlist.tempo.xyz/icon/${icon}.svg`} /> ) const Logo = symbol ? tokenLogo(symbol) : undefined diff --git a/src/lib/routes-test.test.ts b/src/lib/routes-test.test.ts index 64620e26c..ca6b69b2f 100644 --- a/src/lib/routes-test.test.ts +++ b/src/lib/routes-test.test.ts @@ -260,6 +260,21 @@ describe('quickRoutes', () => { ] expect(quickRoutes(routes).map((r) => r.id)).toEqual(['base', 'eth-usdt', 'arb']) }) + it('puts Solana USDC, then Ethereum USDC, to Tempo OUSD after Base', () => { + const ousd = (id: string, source: string) => ({ + ...make(id, source, 'eip155:4217'), + destinationToken: { tokenKey: 'eip155:4217/erc20:ousd', symbol: 'OUSD', decimals: 6 }, + }) + const routes = [ + make('eth-usdt', 'eip155:1', 'eip155:4217', 'USDT'), + make('op', 'eip155:10', 'eip155:4217'), + make('base', 'eip155:8453', 'eip155:4217'), + make('solana-usdce', 'solana:mainnet', 'eip155:4217'), + ousd('solana-ousd', 'solana:mainnet'), + ousd('eth-ousd', 'eip155:1'), + ] + expect(quickRoutes(routes).map((r) => r.id)).toEqual(['base', 'solana-ousd', 'eth-ousd']) + }) it('skips routes the demo cannot run and fills from the rest of the directory', () => { const solanaTransferOnly = { ...make('solana', 'solana:mainnet', 'eip155:4217'), diff --git a/src/lib/routes-test.ts b/src/lib/routes-test.ts index f6d47426d..21a4d7751 100644 --- a/src/lib/routes-test.ts +++ b/src/lib/routes-test.ts @@ -244,13 +244,17 @@ export function routeTestRequest(route: TestRoute, input: RouteInput) { /** * Up to `limit` routes the demo can run, offered as one-click starts: Base USDC to Tempo USDC.e - * first, then other routes into Tempo, one per source network where possible. + * first, then Solana USDC and Ethereum USDC to Tempo OUSD, then other routes into Tempo, one per + * source network where possible. */ export function quickRoutes(routes: TestRoute[], limit = 3) { const rank = (route: TestRoute) => { - if (!isTempo(route.destinationChain.id)) return 2 - const baseUsdc = route.sourceChain.id === 'eip155:8453' && route.sourceToken.symbol === 'USDC' - return baseUsdc && route.destinationToken.symbol === 'USDC.e' ? 0 : 1 + if (!isTempo(route.destinationChain.id)) return 4 + if (route.sourceToken.symbol !== 'USDC') return 3 + const [source, destination] = [route.sourceChain.id, route.destinationToken.symbol] + if (source === 'eip155:8453' && destination === 'USDC.e') return 0 + if (source.startsWith('solana:') && destination === 'OUSD') return 1 + return source === 'eip155:1' && destination === 'OUSD' ? 2 : 3 } const ranked = routes .filter((route) => demoMethods(route).length > 0)