Skip to content

Commit

Permalink
chore: minor change
Browse files Browse the repository at this point in the history
  • Loading branch information
ap211unitech committed Jun 24, 2024
1 parent 9201275 commit 484a88f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,16 @@ export const ConfirmTransaction = ({
if (isDestinationPolkadex) return undefined;
const autoSwapAmount = showAutoSwap ? swapPrice : 0;

if (showAutoSwap && !swapPrice) return CrossChainError.NOT_ENOUGH_LIQUIDITY;
if (showAutoSwap && !swapPrice)
return CrossChainError.NOT_ENOUGH_LIQUIDITY_WITHDRAW(
selectedAsset?.ticker as string
);

if (showAutoSwap && amount <= autoSwapAmount)
return CrossChainError.AUTO_SWAP(
autoSwapAmount.toFixed(4),
selectedAsset?.ticker as string
selectedAsset?.ticker as string,
true
);
}, [
amount,
Expand Down Expand Up @@ -180,10 +184,10 @@ export const ConfirmTransaction = ({
</div>
</Copy>
</GenericHorizontalItem>
{showAutoSwap && (
{showAutoSwap && swapPrice > 0 && (
<GenericHorizontalItem
label="Swap required"
tooltip={`In order to withdraw your funds, you must have to transfer at least {----} ${selectedAsset?.ticker}. A small part of your transfer will be auto-swapped to PDEX to pay the fee.`}
tooltip={`In order to withdraw your funds, you must have to transfer at least ${swapPrice.toFixed(4)} ${selectedAsset?.ticker}. A small part of your transfer will be auto-swapped to PDEX to pay the fee.`}
defaultOpen
>
<div className="flex items-center gap-1">
Expand Down
6 changes: 4 additions & 2 deletions packages/core/src/constants/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,10 @@ export const CrossChainError = {
SOURCE_FEE: "Insufficient balance to pay the transaction fee at source chain",
NOT_ENOUGH_LIQUIDITY:
"Not enough PDEX in the destination account. Please transfer 1+ PDEX first.",
AUTO_SWAP: (swapAmount: string, ticker: string) =>
`Please transfer more than ${swapAmount} ${ticker} since Autoswap is required`,
NOT_ENOUGH_LIQUIDITY_WITHDRAW: (asset: string) =>
`Insufficient liquidity to convert ${asset} tokens to PDEX for fee payment.`,
AUTO_SWAP: (swapAmount: string, ticker: string, withdraw?: boolean) =>
`Please transfer more than ${swapAmount} ${ticker} since Autoswap is required ${withdraw ? "to pay the fee" : ""}`,
};

export const MAX_DIGITS_AFTER_DECIMAL = 8;
Expand Down

0 comments on commit 484a88f

Please sign in to comment.