From b7d671eda2e733355ab89613cfb4394904946a56 Mon Sep 17 00:00:00 2001 From: Andrew Dmytrenko Date: Wed, 17 Jul 2024 15:58:55 +0300 Subject: [PATCH 1/2] remove unnecessary approve --- contracts/BNBPartyInternal.sol | 2 -- 1 file changed, 2 deletions(-) diff --git a/contracts/BNBPartyInternal.sol b/contracts/BNBPartyInternal.sol index cffde0e..f12d689 100644 --- a/contracts/BNBPartyInternal.sol +++ b/contracts/BNBPartyInternal.sol @@ -100,8 +100,6 @@ abstract contract BNBPartyInternal is BNBPartyState { function _executeSwap(address tokenOut) internal { require(address(swapRouter) != address(0), "BNBPartyFactory: swapRouter not set"); uint256 amountIn = msg.value - party.createTokenFee; - // Approve the swap router to spend WBNB - WBNB.approve(address(swapRouter), amountIn); // Prepare swap parameters ISwapRouter.ExactInputParams memory params = ISwapRouter From e0ce55a989ffb2540b62064c66fc8c45ba8cfcd7 Mon Sep 17 00:00:00 2001 From: Andrew Dmytrenko Date: Wed, 17 Jul 2024 17:15:48 +0300 Subject: [PATCH 2/2] remove approve from BNB -> MEME test --- test/BNBPartyFactory.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/test/BNBPartyFactory.ts b/test/BNBPartyFactory.ts index 2621a0e..56ba4d3 100644 --- a/test/BNBPartyFactory.ts +++ b/test/BNBPartyFactory.ts @@ -174,7 +174,6 @@ describe("BNBPartyFactory", function () { amountOutMinimum: "0", } const token1Contract = await ethers.getContractAt("ERC20", MEME) - await weth9.approve(await swapRouter.getAddress(), amountIn) const balanceBefore = await token1Contract.balanceOf(await signers[0].getAddress()) await expect(await swapRouter.exactInput(params, { value: amountIn })).to.emit(weth9, "Deposit")