|
|
@ -34,6 +34,7 @@ import { |
|
|
|
fetchAndSetSwapsGasPriceInfo, |
|
|
|
fetchAndSetSwapsGasPriceInfo, |
|
|
|
fetchSwapsLiveness, |
|
|
|
fetchSwapsLiveness, |
|
|
|
getUseNewSwapsApi, |
|
|
|
getUseNewSwapsApi, |
|
|
|
|
|
|
|
getFromToken, |
|
|
|
} from '../../ducks/swaps/swaps'; |
|
|
|
} from '../../ducks/swaps/swaps'; |
|
|
|
import { |
|
|
|
import { |
|
|
|
AWAITING_SIGNATURES_ROUTE, |
|
|
|
AWAITING_SIGNATURES_ROUTE, |
|
|
@ -70,6 +71,7 @@ import { |
|
|
|
fetchTopAssets, |
|
|
|
fetchTopAssets, |
|
|
|
getSwapsTokensReceivedFromTxMeta, |
|
|
|
getSwapsTokensReceivedFromTxMeta, |
|
|
|
fetchAggregatorMetadata, |
|
|
|
fetchAggregatorMetadata, |
|
|
|
|
|
|
|
countDecimals, |
|
|
|
} from './swaps.util'; |
|
|
|
} from './swaps.util'; |
|
|
|
import AwaitingSignatures from './awaiting-signatures'; |
|
|
|
import AwaitingSignatures from './awaiting-signatures'; |
|
|
|
import AwaitingSwap from './awaiting-swap'; |
|
|
|
import AwaitingSwap from './awaiting-swap'; |
|
|
@ -94,6 +96,7 @@ export default function Swap() { |
|
|
|
const [inputValue, setInputValue] = useState(fetchParams?.value || ''); |
|
|
|
const [inputValue, setInputValue] = useState(fetchParams?.value || ''); |
|
|
|
const [maxSlippage, setMaxSlippage] = useState(fetchParams?.slippage || 3); |
|
|
|
const [maxSlippage, setMaxSlippage] = useState(fetchParams?.slippage || 3); |
|
|
|
const [isFeatureFlagLoaded, setIsFeatureFlagLoaded] = useState(false); |
|
|
|
const [isFeatureFlagLoaded, setIsFeatureFlagLoaded] = useState(false); |
|
|
|
|
|
|
|
const [tokenFromError, setTokenFromError] = useState(null); |
|
|
|
|
|
|
|
|
|
|
|
const routeState = useSelector(getBackgroundSwapRouteState); |
|
|
|
const routeState = useSelector(getBackgroundSwapRouteState); |
|
|
|
const selectedAccount = useSelector(getSelectedAccount); |
|
|
|
const selectedAccount = useSelector(getSelectedAccount); |
|
|
@ -108,6 +111,7 @@ export default function Swap() { |
|
|
|
const chainId = useSelector(getCurrentChainId); |
|
|
|
const chainId = useSelector(getCurrentChainId); |
|
|
|
const isSwapsChain = useSelector(getIsSwapsChain); |
|
|
|
const isSwapsChain = useSelector(getIsSwapsChain); |
|
|
|
const useNewSwapsApi = useSelector(getUseNewSwapsApi); |
|
|
|
const useNewSwapsApi = useSelector(getUseNewSwapsApi); |
|
|
|
|
|
|
|
const fromToken = useSelector(getFromToken); |
|
|
|
|
|
|
|
|
|
|
|
const { |
|
|
|
const { |
|
|
|
balance: ethBalance, |
|
|
|
balance: ethBalance, |
|
|
@ -288,10 +292,15 @@ export default function Swap() { |
|
|
|
|
|
|
|
|
|
|
|
const onInputChange = (newInputValue, balance) => { |
|
|
|
const onInputChange = (newInputValue, balance) => { |
|
|
|
setInputValue(newInputValue); |
|
|
|
setInputValue(newInputValue); |
|
|
|
dispatch( |
|
|
|
const balanceError = new BigNumber(newInputValue || 0).gt( |
|
|
|
setBalanceError( |
|
|
|
balance || 0, |
|
|
|
new BigNumber(newInputValue || 0).gt(balance || 0), |
|
|
|
); |
|
|
|
), |
|
|
|
// "setBalanceError" is just a warning, a user can still click on the "Review Swap" button.
|
|
|
|
|
|
|
|
dispatch(setBalanceError(balanceError)); |
|
|
|
|
|
|
|
setTokenFromError( |
|
|
|
|
|
|
|
countDecimals(newInputValue) > fromToken.decimals |
|
|
|
|
|
|
|
? 'tooManyDecimals' |
|
|
|
|
|
|
|
: null, |
|
|
|
); |
|
|
|
); |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
@ -304,6 +313,7 @@ export default function Swap() { |
|
|
|
selectedAccountAddress={selectedAccountAddress} |
|
|
|
selectedAccountAddress={selectedAccountAddress} |
|
|
|
maxSlippage={maxSlippage} |
|
|
|
maxSlippage={maxSlippage} |
|
|
|
isFeatureFlagLoaded={isFeatureFlagLoaded} |
|
|
|
isFeatureFlagLoaded={isFeatureFlagLoaded} |
|
|
|
|
|
|
|
tokenFromError={tokenFromError} |
|
|
|
/> |
|
|
|
/> |
|
|
|
); |
|
|
|
); |
|
|
|
}} |
|
|
|
}} |
|
|
|