From e88ab7d0593793a7109de28e916805fe7184c608 Mon Sep 17 00:00:00 2001 From: Ivan Zhelyazkov Date: Thu, 18 Jul 2024 11:34:41 +0300 Subject: [PATCH] carbon vortex - minor fix --- contracts/vortex/CarbonVortex.sol | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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); }