Skip to content

Commit 92dc255

Browse files
committed
Merge branch 'master' into feat/twitter-share
Signed-off-by: Gerhard Steenkamp <[email protected]>
2 parents 73a0a91 + c4b53a8 commit 92dc255

File tree

7 files changed

+117
-41
lines changed

7 files changed

+117
-41
lines changed

src/assets/token-logos/usdt0.svg

Lines changed: 6 additions & 0 deletions
Loading

src/utils/config.ts

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import assert from "assert";
22
import { Signer } from "./ethers";
33
import * as constants from "./constants";
44
import * as providerUtils from "./providers";
5+
import usdt0Logo from "assets/token-logos/usdt0.svg";
56
import filter from "lodash/filter";
67
import sortBy from "lodash/sortBy";
78

@@ -459,10 +460,10 @@ export class ConfigClient {
459460
token,
460461
`Token not found on chain: ${chainId} and address ${address}`
461462
);
462-
return token;
463+
return this.applyChainSpecificTokenDisplay(token, chainId);
463464
}
464465

465-
return tokens[0];
466+
return this.applyChainSpecificTokenDisplay(tokens[0], chainId);
466467
}
467468
getPoolTokenInfoByAddress(chainId: number, address: string): Token {
468469
return this.getTokenInfoByAddress(
@@ -476,14 +477,16 @@ export class ConfigClient {
476477
address: string
477478
): Token | undefined {
478479
try {
479-
return this.getTokenInfoByAddress(chainId, address);
480+
const token = this.getTokenInfoByAddress(chainId, address);
481+
return this.applyChainSpecificTokenDisplay(token, chainId);
480482
} catch (error) {
481483
return undefined;
482484
}
483485
}
484486
getTokenInfoBySymbol(chainId: number, symbol: string): Token {
485487
const tokens = this.getTokenList(chainId);
486-
return this._getTokenInfoBySymbol(chainId, symbol, tokens);
488+
const token = this._getTokenInfoBySymbol(chainId, symbol, tokens);
489+
return this.applyChainSpecificTokenDisplay(token, chainId);
487490
}
488491
getTokenInfoBySymbolSafe(chainId: number, symbol: string): Token | undefined {
489492
try {
@@ -494,11 +497,13 @@ export class ConfigClient {
494497
}
495498
getStakingPoolTokenInfoBySymbol(chainId: number, symbol: string): Token {
496499
const tokens = this.getStakingPoolTokenList(chainId);
497-
return this._getTokenInfoBySymbol(chainId, symbol, tokens);
500+
const token = this._getTokenInfoBySymbol(chainId, symbol, tokens);
501+
return this.applyChainSpecificTokenDisplay(token, chainId);
498502
}
499503
getPoolTokenInfoBySymbol(chainId: number, symbol: string): Token {
500504
const tokens = this.getTokenPoolList(chainId);
501-
return this._getTokenInfoBySymbol(chainId, symbol, tokens);
505+
const token = this._getTokenInfoBySymbol(chainId, symbol, tokens);
506+
return this.applyChainSpecificTokenDisplay(token, chainId);
502507
}
503508
_getTokenInfoBySymbol(
504509
chainId: number,
@@ -563,6 +568,28 @@ export class ConfigClient {
563568
return {};
564569
}
565570
}
571+
572+
/**
573+
* Determines if USDT should be displayed as USDT0 on the given chain
574+
*/
575+
private shouldShowUsdt0ForChain(chainId: number): boolean {
576+
return constants.chainsWithUsdt0Enabled.includes(chainId);
577+
}
578+
579+
/**
580+
* Applies chain-specific display modifications to a token
581+
*/
582+
private applyChainSpecificTokenDisplay(token: Token, chainId: number): Token {
583+
// Handle USDT -> USDT0 display for specific chains
584+
if (token.symbol === "USDT" && this.shouldShowUsdt0ForChain(chainId)) {
585+
return {
586+
...token,
587+
displaySymbol: "USDT0",
588+
logoURI: usdt0Logo,
589+
};
590+
}
591+
return token;
592+
}
566593
}
567594

568595
// singleton

src/utils/constants.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import unknownLogo from "assets/icons/question-circle.svg";
1414
import { ReactComponent as unknownLogoSvg } from "assets/icons/question-circle.svg";
1515
import OPCloudBackground from "assets/bg-banners/op-cloud-rebate.svg";
1616
import ARBCloudBackground from "assets/bg-banners/arb-cloud-rebate.svg";
17+
import usdt0Logo from "assets/token-logos/usdt0.svg";
1718

1819
// all routes should be pre imported to be able to switch based on chain id
1920
import MainnetRoutes from "data/routes_1_0xc186fA914353c44b2E33eBE05f21846F1048bEda.json";
@@ -305,6 +306,28 @@ export const getToken = (symbol: string): TokenInfo => {
305306
return token;
306307
};
307308

309+
/**
310+
* Gets token info with chain-specific display modifications (temporary for USDT0)
311+
* This is a temporary function that will be removed once all chains migrate to USDT0
312+
*/
313+
export const getTokenForChain = (
314+
symbol: string,
315+
chainId: number
316+
): TokenInfo => {
317+
const token = getToken(symbol);
318+
319+
// Handle USDT -> USDT0 display for specific chains
320+
if (token.symbol === "USDT" && chainsWithUsdt0Enabled.includes(chainId)) {
321+
return {
322+
...token,
323+
displaySymbol: "USDT0",
324+
logoURI: usdt0Logo,
325+
};
326+
}
327+
328+
return token;
329+
};
330+
308331
export const getRewardToken = (deposit: Deposit): TokenInfo | undefined => {
309332
if (!deposit.rewards) {
310333
return undefined;
@@ -645,3 +668,7 @@ export const acrossPlusMulticallHandler: Record<number, string> = {
645668
export const chainsWithSpeedupDisabled = [CHAIN_IDs.SOLANA];
646669

647670
export const pmfSurveyGFormUrl = process.env.REACT_APP_PMF_SURVEY_GFORM_URL;
671+
672+
// temporary list, to show usdt0 symbol & icon.
673+
// once all chains have migrated we can remove this list and make upstream changes to USDT icons in @constants.
674+
export const chainsWithUsdt0Enabled = [CHAIN_IDs.POLYGON, CHAIN_IDs.ARBITRUM];

src/views/Bridge/components/BridgeForm.tsx

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { Alert, Text } from "components";
88
import { Tooltip } from "components/Tooltip";
99

1010
import {
11-
getToken,
11+
getTokenForChain,
1212
GetBridgeFeesResult,
1313
QUERIESV2,
1414
chainIdToRewardsProgramName,
@@ -286,11 +286,20 @@ const BridgeForm = ({
286286
parsedAmount={parsedAmountInput}
287287
swapQuote={swapQuote}
288288
universalSwapQuote={universalSwapQuote}
289-
inputToken={getToken(selectedRoute.fromTokenSymbol)}
290-
outputToken={getToken(receiveTokenSymbol)}
289+
inputToken={getTokenForChain(
290+
selectedRoute.fromTokenSymbol,
291+
selectedRoute.fromChain
292+
)}
293+
outputToken={getTokenForChain(
294+
receiveTokenSymbol,
295+
selectedRoute.toChain
296+
)}
291297
swapToken={
292298
selectedRoute.type === "swap"
293-
? getToken(selectedRoute.swapTokenSymbol)
299+
? getTokenForChain(
300+
selectedRoute.swapTokenSymbol,
301+
selectedRoute.fromChain
302+
)
294303
: undefined
295304
}
296305
onSetNewSlippage={onSetNewSlippage}

src/views/Bridge/components/TokenSelector.tsx

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { ReactComponent as LinkExternalIcon } from "assets/icons/arrow-up-right-
55
import { Selector } from "components";
66
import { Text } from "components/Text";
77

8-
import { TokenInfo, getToken, tokenList } from "utils";
8+
import { TokenInfo, getTokenForChain, tokenList } from "utils";
99
import { useBalancesBySymbols } from "hooks/useBalance";
1010

1111
import { RouteNotSupportedTooltipText } from "./RouteNotSupportedTooltipText";
@@ -40,16 +40,19 @@ export function TokenSelector({
4040
toTokenSymbol,
4141
externalProjectId,
4242
} = selectedRoute;
43+
const relevantChainId = isInputTokenSelector ? fromChain : toChain;
4344

44-
const selectedToken = getToken(
45+
const selectedToken = getTokenForChain(
4546
isInputTokenSelector
4647
? selectedRoute.type === "swap"
4748
? selectedRoute.swapTokenSymbol
4849
: fromTokenSymbol
49-
: toTokenSymbol
50+
: toTokenSymbol,
51+
relevantChainId
5052
);
53+
5154
const tokenToDisplay = receiveTokenSymbol
52-
? getToken(receiveTokenSymbol)
55+
? getTokenForChain(receiveTokenSymbol, relevantChainId)
5356
: selectedToken;
5457

5558
const orderedTokens: Array<
@@ -82,13 +85,14 @@ export function TokenSelector({
8285
)
8386
.map((t) => ({ ...t, disabled: true }))
8487
: []),
85-
];
88+
].map((t) => getTokenForChain(t.symbol, relevantChainId));
8689
}, [
8790
fromChain,
8891
toChain,
8992
fromTokenSymbol,
9093
isInputTokenSelector,
9194
externalProjectId,
95+
relevantChainId,
9296
]);
9397

9498
const { balances } = useBalancesBySymbols({

src/views/DepositStatus/components/DepositTimesCard.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import {
1616
isDefined,
1717
formatUSD,
1818
getToken,
19+
getTokenForChain,
1920
} from "utils";
2021
import { useAmplitude } from "hooks";
2122
import { ampli } from "ampli";
@@ -190,7 +191,7 @@ export function DepositTimesCard({
190191
<Text color="grey-400">Amount sent</Text>
191192
<TokenWrapper>
192193
<TokenFee
193-
token={getToken(outputTokenSymbol)}
194+
token={getTokenForChain(outputTokenSymbol, toChainId)}
194195
amount={BigNumber.from(outputAmount)}
195196
tokenChainId={toChainId}
196197
tokenFirst
@@ -210,7 +211,7 @@ export function DepositTimesCard({
210211
fromChainId={fromChainId}
211212
toChainId={toChainId}
212213
inputToken={inputToken}
213-
outputToken={getToken(outputTokenSymbol)}
214+
outputToken={getTokenForChain(outputTokenSymbol, toChainId)}
214215
isSwap={isSwap}
215216
isUniversalSwap={isUniversalSwap}
216217
swapQuote={fromBridgePagePayload?.swapQuote}

test/api/_dexes/utils.test.ts

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,31 +3,33 @@ import { CHAIN_IDs, TOKEN_SYMBOLS_MAP } from "../../../api/_constants";
33

44
describe("_dexes/utils", () => {
55
describe("#getCrossSwapType()", () => {
6-
test("L1 stable -> Lens GHO - should return any-to-bridgeable", () => {
7-
const params = {
8-
inputToken: TOKEN_SYMBOLS_MAP.DAI.addresses[CHAIN_IDs.MAINNET],
9-
originChainId: CHAIN_IDs.MAINNET,
10-
outputToken: TOKEN_SYMBOLS_MAP.WGHO.addresses[CHAIN_IDs.LENS],
11-
destinationChainId: CHAIN_IDs.LENS,
12-
isOutputNative: true,
13-
isInputNative: false,
14-
};
15-
const crossSwapTypes = getCrossSwapTypes(params);
16-
expect(crossSwapTypes).toEqual([CROSS_SWAP_TYPE.ANY_TO_BRIDGEABLE]);
17-
});
6+
// TODO: Temporarily disabled - Lens has been temporarily disabled
7+
// test("L1 stable -> Lens GHO - should return any-to-bridgeable", () => {
8+
// const params = {
9+
// inputToken: TOKEN_SYMBOLS_MAP.DAI.addresses[CHAIN_IDs.MAINNET],
10+
// originChainId: CHAIN_IDs.MAINNET,
11+
// outputToken: TOKEN_SYMBOLS_MAP.WGHO.addresses[CHAIN_IDs.LENS],
12+
// destinationChainId: CHAIN_IDs.LENS,
13+
// isOutputNative: true,
14+
// isInputNative: false,
15+
// };
16+
// const crossSwapTypes = getCrossSwapTypes(params);
17+
// expect(crossSwapTypes).toEqual([CROSS_SWAP_TYPE.ANY_TO_BRIDGEABLE]);
18+
// });
1819

19-
test("Lens GHO -> L1 GHO - should return bridgeable-to-any", () => {
20-
const params = {
21-
inputToken: TOKEN_SYMBOLS_MAP.WGHO.addresses[CHAIN_IDs.LENS],
22-
originChainId: CHAIN_IDs.LENS,
23-
outputToken: TOKEN_SYMBOLS_MAP.GHO.addresses[CHAIN_IDs.MAINNET],
24-
destinationChainId: CHAIN_IDs.MAINNET,
25-
isOutputNative: false,
26-
isInputNative: true,
27-
};
28-
const crossSwapTypes = getCrossSwapTypes(params);
29-
expect(crossSwapTypes).toEqual([CROSS_SWAP_TYPE.BRIDGEABLE_TO_ANY]);
30-
});
20+
// TODO: Temporarily disabled - Lens has been temporarily disabled
21+
// test("Lens GHO -> L1 GHO - should return bridgeable-to-any", () => {
22+
// const params = {
23+
// inputToken: TOKEN_SYMBOLS_MAP.WGHO.addresses[CHAIN_IDs.LENS],
24+
// originChainId: CHAIN_IDs.LENS,
25+
// outputToken: TOKEN_SYMBOLS_MAP.GHO.addresses[CHAIN_IDs.MAINNET],
26+
// destinationChainId: CHAIN_IDs.MAINNET,
27+
// isOutputNative: false,
28+
// isInputNative: true,
29+
// };
30+
// const crossSwapTypes = getCrossSwapTypes(params);
31+
// expect(crossSwapTypes).toEqual([CROSS_SWAP_TYPE.BRIDGEABLE_TO_ANY]);
32+
// });
3133

3234
test("Optimism USDC -> Arbitrum USDC - should return bridgeable-to-bridgeable", () => {
3335
const params = {

0 commit comments

Comments
 (0)