diff --git a/src/components/Swap.tsx b/src/components/Swap.tsx index 2cba7b6a..f2979fce 100644 --- a/src/components/Swap.tsx +++ b/src/components/Swap.tsx @@ -54,6 +54,10 @@ const useStyles = makeStyles((theme) => ({ fontSize: 16, fontWeight: 700, padding: theme.spacing(1.5), + "&:disabled": { + cursor: "not-allowed", + pointerEvents: 'all !important' + } }, swapToFromButton: { display: "block", @@ -348,6 +352,16 @@ export function SwapButton() { const quoteMintInfo = useMint(quoteMint); const quoteWallet = useOwnedTokenAccount(quoteMint); + let minimumAmt = fromMarket?.minOrderSize ?? 0; + let baseMint = fromMarket?.decoded.baseMint ?? null; + + let minAmtCondt = false; + if (baseMint?.toString() === fromMint.toString()) { + minAmtCondt = fromAmount >= minimumAmt; + } else { + minAmtCondt = fromAmount >= minimumAmt * (fair ?? 0); + } + // Click handler. const sendSwapTransaction = async () => { if (!fromMintInfo || !toMintInfo) { @@ -446,7 +460,7 @@ export function SwapButton() { variant="contained" className={styles.swapButton} onClick={sendSwapTransaction} - disabled={!canSwap} + disabled={!canSwap && !minAmtCondt} > Swap