Skip to content

Commit

Permalink
display ETH as WETH on swap-related pages
Browse files Browse the repository at this point in the history
  • Loading branch information
eli-d committed Dec 17, 2024
1 parent 5962791 commit 91cb687
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 6 deletions.
17 changes: 13 additions & 4 deletions web/src/app/swap/explore/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,19 @@ const ExplorePage = () => {
[fUSDC],
);

const tokensData = useMemo(
() => [fUSDCData, ...(tokensData_ ?? [])],
[fUSDCData, tokensData_],
);
const tokensData = useMemo(() => {
// Override WETH name to ETH on swap-related pages
const tokens =
tokensData_?.map((t) => ({
...t,
token: {
...t.token,
symbol: t.token.symbol === "WETH" ? "ETH" : t.token.symbol,
name: t.token.name === "WETH" ? "ETH" : t.token.name,
},
})) ?? [];
return [fUSDCData, ...tokens];
}, [fUSDCData, tokensData_]);

const showMockData = useFeatureFlag("ui show demo data");

Expand Down
19 changes: 17 additions & 2 deletions web/src/stores/useSwapStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,23 @@ export const useSwapStore = create<SwapStore>((set) => ({
token0: EmptyToken,
token1: EmptyToken,

setToken0: (token) => set({ token0: token }),
setToken1: (token) => set({ token1: token }),
// Override WETH name to ETH on swap-related pages
setToken0: (token) =>
set({
token0: {
...token,
symbol: token.symbol === "WETH" ? "ETH" : token.symbol,
name: token.name === "WETH" ? "ETH" : token.name,
},
}),
setToken1: (token) =>
set({
token1: {
...token,
symbol: token.symbol === "WETH" ? "ETH" : token.symbol,
name: token.name === "WETH" ? "ETH" : token.name,
},
}),
flipTokens: () => {
set(
({
Expand Down

0 comments on commit 91cb687

Please sign in to comment.