@@ -70,8 +68,8 @@ export const SwapPage = () => {
to,
} = useSwapForm();
- const fromToken = from ? INPUT_TOKEN_CONFIG[from] : undefined;
- const toToken = to ? OUTPUT_TOKEN_CONFIG[to] : undefined;
+ const fromToken = INPUT_TOKEN_CONFIG[from];
+ const toToken = OUTPUT_TOKEN_CONFIG[to];
const tokenOutData = useTokenOutAmount({
wantsSwap: true,
@@ -130,57 +128,47 @@ export const SwapPage = () => {
const ReceiveNumericInput = useMemo(
() => (
setModalType('to')}
registerInput={form.register('toAmount')}
disabled={isQuoteSubmitted || tokenOutData.isLoading}
readOnly={true}
/>
),
- [
- toToken?.fiat?.symbol,
- toToken?.fiat?.string,
- toToken?.stellarAsset.code.string,
- to,
- form,
- isQuoteSubmitted,
- tokenOutData.isLoading,
- setModalType,
- ],
+ [toToken.fiat.symbol, toToken.fiat.assetIcon, to, form, isQuoteSubmitted, tokenOutData.isLoading, setModalType],
);
const WidthrawNumericInput = useMemo(
() => (
setIsQuoteSubmitted(true) })}
- tokenType={from}
- tokenSymbol={fromToken?.assetSymbol}
+ tokenSymbol={fromToken.assetSymbol}
+ assetIcon={fromToken.polygonAssetIcon}
onClick={() => setModalType('from')}
/>
),
- [form, from, fromToken?.assetSymbol, setModalType],
+ [form, fromToken.polygonAssetIcon, fromToken.polygonAssetIcon, setModalType],
);
function getCurrentErrorMessage() {
const amountOut = tokenOutData.data?.amountOut;
- if (amountOut !== undefined && toToken !== undefined) {
+ if (amountOut !== undefined) {
const maxAmountRaw = Big(toToken.maxWithdrawalAmountRaw);
const minAmountRaw = Big(toToken.minWithdrawalAmountRaw);
if (maxAmountRaw.lt(Big(amountOut.rawBalance))) {
const maxAmountUnits = multiplyByPowerOfTen(maxAmountRaw, -toToken.decimals);
return `Maximum withdrawal amount is ${stringifyBigWithSignificantDecimals(maxAmountUnits, 2)} ${
- SHOW_RECEIVED_CURRENCY_IN_FIAT ? toToken.fiat?.string : toToken.stellarAsset.code.string
+ toToken.fiat.symbol
}.`;
}
if (config.test.overwriteMinimumTransferAmount === false && minAmountRaw.gt(Big(amountOut.rawBalance))) {
const minAmountUnits = multiplyByPowerOfTen(minAmountRaw, -toToken.decimals);
return `Minimum withdrawal amount is ${stringifyBigWithSignificantDecimals(minAmountUnits, 2)} ${
- SHOW_RECEIVED_CURRENCY_IN_FIAT ? toToken.fiat?.string : toToken.stellarAsset.code.string
+ toToken.fiat.symbol
}.`;
}
}
@@ -193,12 +181,12 @@ export const SwapPage = () => {
? Object.entries(INPUT_TOKEN_CONFIG).map(([key, value]) => ({
type: key as InputTokenType,
assetSymbol: value.assetSymbol,
- fiat: undefined,
+ assetIcon: value.polygonAssetIcon,
}))
: Object.entries(OUTPUT_TOKEN_CONFIG).map(([key, value]) => ({
type: key as OutputTokenType,
- assetSymbol: value.stellarAsset.code.string,
- fiat: SHOW_RECEIVED_CURRENCY_IN_FIAT ? value.fiat : undefined,
+ assetSymbol: value.fiat.symbol,
+ assetIcon: value.fiat.assetIcon,
}));
const modals = (
@@ -239,13 +227,13 @@ export const SwapPage = () => {
{...{
tokenOutData,
fromToken,
- toTokenSymbol: SHOW_RECEIVED_CURRENCY_IN_FIAT ? toToken?.fiat?.string : toToken?.stellarAsset.code.string,
+ toTokenSymbol: toToken.fiat.symbol,
}}
/>