// fix the forever locked BNBs as per the certik's audit /** * The swapAndLiquify function converts half of the contractTokenBalance SafeMoon tokens to BNB. * For every swapAndLiquify function call, a small amount of BNB remains in the contract. * This amount grows over time with the swapAndLiquify function being called throughout the life * of the contract. The Safemoon contract does not contain a method to withdraw these funds, * and the BNB will be locked in the Safemoon contract forever. */ withdrawableBalance = address(this).balance; emit LiquidityAdded(tokenAmountSent, ethAmountSent, liquidity); }
/** * @dev The owner can withdraw ETH(BNB) collected in the contract from swapAndLiquify * or if someone (accidentally) sends ETH/BNB directly to the contract. * * Note: This addresses the contract flaw pointed out in the Certik Audit of Safemoon (SSL-03): * * The swapAndLiquify function converts half of the contractTokenBalance SafeMoon tokens to BNB. * For every swapAndLiquify function call, a small amount of BNB remains in the contract. * This amount grows over time with the swapAndLiquify function being called * throughout the life of the contract. The Safemoon contract does not contain a method * to withdraw these funds, and the BNB will be locked in the Safemoon contract forever. * https://www.certik.org/projects/safemoon */ function withdrawLockedEth(address payable recipient) external onlyManager(){ require(recipient != address(0), "Cannot withdraw the ETH balance to the zero address"); require(withdrawableBalance > 0, "The ETH balance must be greater than 0"); // prevent re-entrancy attacks uint256 amount = withdrawableBalance; withdrawableBalance = 0; recipient.transfer(amount); }
Aug 10, 2021, 4:56 AM