diff --git a/contracts/vortex/CarbonVortex.sol b/contracts/vortex/CarbonVortex.sol index cbf53d12..053fe01d 100644 --- a/contracts/vortex/CarbonVortex.sol +++ b/contracts/vortex/CarbonVortex.sol @@ -679,10 +679,6 @@ contract CarbonVortex is ICarbonVortex, Upgradeable, ReentrancyGuardUpgradeable, if (sourceAmount == 0) { revert InvalidTrade(); } - // revert if unnecessary native token is received - if (_finalTargetToken != NATIVE_TOKEN && msg.value > 0) { - revert UnnecessaryNativeTokenReceived(); - } // check enough final target token (if final target token is native) has been sent for the trade if (_finalTargetToken == NATIVE_TOKEN) { @@ -691,6 +687,10 @@ contract CarbonVortex is ICarbonVortex, Upgradeable, ReentrancyGuardUpgradeable, } payable(_transferAddress).sendValue(sourceAmount); } else { + // revert if unnecessary native token is received + if (msg.value > 0) { + revert UnnecessaryNativeTokenReceived(); + } // transfer the tokens from the user to the _transferAddress _finalTargetToken.safeTransferFrom(msg.sender, _transferAddress, sourceAmount); }