Why is no one helping me do an arbitrage flash loan?

Plankton5165

Regular Member
Joined
Jul 23, 2019
Messages
211
Reaction score
16
I am sick to death of seeking help on how to combine arbitrage with flash loans (I have done so for THREE MONTHS) and still NOT even figuring out how to do it!

I’ve already found these two videos:

The second one even involving this code:
const usdtUsdc500 = await deployPool(TETHER_ADDRESS, USDC_ADDRESS, 500, encodePriceSqrt(1, 1))
const usdtUsdc3000 = await deployPool(TETHER_ADDRESS, USDC_ADDRESS, 3000, encodePriceSqrt(1, 2))
const usdtUsdc10000 = await deployPool(TETHER_ADDRESS, USDC_ADDRESS, 10000, encodePriceSqrt(2, 1))

But the first one doesn’t showcase how to do arbitrage with a flash loan, and every time I’ve tried to initiate a transaction, it says the transaction fails from MetaMask. (I definitely have enough funds to pay for the gas, and the endpoint is right)

And the second one, I don’t think I can get Hardhat on a Chromebook, so I tried running it on Remix IDE, and got seven errors, and I already told the video uploader that, but he has not been responsive.

Also, Equalizer claims to make DeFi flash loans easy. However, they tell me to add the business logic myself. What business logic??? What code do I add as business logic? No one’s answered that either!

I don’t want to have to quit flash loans altogether because of everyone being unresponsive!
 
I understand the frustration after 3 months of failing, but I highly suggest you change the title, as it makes you sound extremely entitled, and no one has to help you.
Low key was just thinking that. :) I mean, after 3 months why don't you flip niches? It's clear it's not working out haha.
Also, ARB is extremely risky, you need extremely low ms for it to actually work properly, it's why people in for example forex pay billions for a few ms.
 
Have you tried to do it manually before jumping to dev environment like Remix and Hardhat? What's your experience with solidity and/or JS?
 
Solidity, I cannot even bother to use because I cannot even download. So I figured I would just use Solidity code in Remix IDE.

And what do you mean no one has to help me? Does every successful arbitrage flash loan user invent their own code themselves?
 
Check this article (on Medium) to get a bigger picture of what's involved in this kind of arbitrage (Remix or hardhat). If you can understand all that's written in this article you will be able to start with arbitrage in no time.
 
Check this article (on Medium) to get a bigger picture of what's involved in this kind of arbitrage (Remix or hardhat). If you can understand all that's written in this article you will be able to start with arbitrage in no time.
Remix and Hardhat? It says it’s for Hardhat. It doesn’t mention Remix in the title.

Also, I don’t really understand why dex.sol is necessary. I can’t find anyone on YouTube that talks about it. I’m trying to swap a token, any token, from one exchange to another. And don’t I put in an address like a PoolAddressProvider?

If no one answers me, I will move on from this. It’s not like I’m trying to win the lottery here.

For three months, I’ve known how to find arbitrage opportunities, but not how to execute arbitrage flash loans. I would expect it to be usually the other way around for everyone else.
 
Remix and Hardhat? It says it’s for Hardhat. It doesn’t mention Remix in the title.

Also, I don’t really understand why dex.sol is necessary. I can’t find anyone on YouTube that talks about it. I’m trying to swap a token, any token, from one exchange to another. And don’t I put in an address like a PoolAddressProvider?

If no one answers me, I will move on from this. It’s not like I’m trying to win the lottery here.

For three months, I’ve known how to find arbitrage opportunities, but not how to execute arbitrage flash loans. I would expect it to be usually the other way around for everyone else.
Man... Did you understood any of what's written in the Medium article i posted? Do you have any dev/programming experience? There is even GH repo to help you started at the bottom of article.
 
Because it's bullshit, forget it and move on, there are another ways to make money
 
Okay gonna try this out myself , will let you know how it goes.
 
Flashloan arbitriage is relatively low risk, especially now that tx fees have changed in nature, so there's tons of competition. Just like in HFT firms, there's a very expensive fight for nanoseconds of latency with the eth network. People who know how to do this stuff will only want to work with people who know what they are doing, otherwise anyone who approaches you is just trying to scam you.
 
You seem to have very little solidity experience, executing CAs/deployments without it is a pretty good way to have your funds stuck in limbo.
 
Man... Did you understood any of what's written in the Medium article i posted? Do you have any dev/programming experience? There is even GH repo to help you started at the bottom of article.
I think what I did last time was skip the first three steps, as I figured (or at least hoped) it wouldn't be necessary to follow them.

I wasn't aware that the terms had to be put in a terminal which I didn't even know Remix had. But I just found the Remix terminal now. However, every time I try to run a command, it says "missing initializer in const declaration".

However, I've also tried using AirCode, which claims to allow users to code node.js functions, as I cannot download node.js or npm on my computer, but I was able to install on AirCode the following in "dependencies": npm, hardhat, yarn, hardhat-ethers, @nomiclabs/hardhat-ethers, aave/core-v3.

So, according to step 3, it says my project directory should have a specific structure, but nothing happened to the structure in AirCode. Maybe this only happens if I'm using Remix.
 
I think what I did last time was skip the first three steps, as I figured (or at least hoped) it wouldn't be necessary to follow them.

I wasn't aware that the terms had to be put in a terminal which I didn't even know Remix had. But I just found the Remix terminal now. However, every time I try to run a command, it says "missing initializer in const declaration".

However, I've also tried using AirCode, which claims to allow users to code node.js functions, as I cannot download node.js or npm on my computer, but I was able to install on AirCode the following in "dependencies": npm, hardhat, yarn, hardhat-ethers, @nomiclabs/hardhat-ethers, aave/core-v3.

So, according to step 3, it says my project directory should have a specific structure, but nothing happened to the structure in AirCode. Maybe this only happens if I'm using Remix.
Mate don't get me wrong, but you should learn a lot more about Remix IDE, Solidity and how blockchain and DEX works in general. This way by simply copying codes from tutorials like ones you've linked in your initial post you can lose all your wits trying to figure out where did your money went just to find out about gas fees and that you set it wrong.

If you are still desperate to start with crypto arbitrage, you better set yourself off to find good working bot. When you find one check all the comments before deploying it because lot of scammers are out there. Once you find it be prepared to pay fees to the creator (usually in range 0.1 - 0.3% of profit), build it in Remix IDE, deploy, fund with ETH from your wallet (Usually you'll need some web3 provider wallet like MetaMask Chrome Extension installed. It's not necessary but helps a lot) and start it.

Note: Do not expect huge returns on this job. 0.5-2% daily profit is most you can get but it will huge depend on trading/swap volume, coin price, gas price and market itself. Everybody that promises daily returns of 5%+ is probably trying to scam you.

P.S. I forgot to mention that you must fund initial contract with at least 0.5 to 1 ETH or you will be drowned in gas fees.
 
Last edited:
here is a code that i use for flashloans

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts/access/AccessControl.sol";
import "@openzeppelin/contracts/security/Pausable.sol";

interface ISwapRouter {
// Define the interface for ISwapRouter here
}

interface IBancorNetwork {
// Define the interface for IBancorNetwork here
}

interface IUniswapV2Router02 {
// Define the interface for IUniswapV2Router02 here
}

contract FlashLoanBot is AccessControl, Pausable {
using SafeERC20 for IERC20;

bytes32 public constant ADMIN_ROLE = keccak256("ADMIN_ROLE");

IBancorNetwork private constant bancorNetwork = IBancorNetwork(0xb3fa5DcF7506D146485856439eb5e401E0796B5D);
address private constant BANCOR_ETH_ADDRESS = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;
address private constant BANCOR_ETHBNT_POOL = 0x1aCE5DD13Ba14CA42695A905526f2ec366720b13;
address private constant BNT = 0xF35cCfbcE1228014F66809EDaFCDB836BFE388f5;

IUniswapV2Router02 private constant sushiRouter = IUniswapV2Router02(0x1b02dA8Cb0d097eB8D57A175b88c7D8b47997506);
address private constant INJ = 0x9108Ab1bb7D054a3C1Cd62329668536f925397e5;

ISwapRouter private constant uniswapRouter = ISwapRouter(0xE592427A0AEce92De3Edee1F18E0157C05861564);
address private constant DAI = 0xaD6D458402F60fD3Bd25163575031ACDce07538D;

constructor() {
_setupRole(DEFAULT_ADMIN_ROLE, msg.sender);
_setupRole(ADMIN_ROLE, msg.sender);
_setupRole(PAUSER_ROLE, msg.sender);

// Only the admin can grant/revoke the ADMIN_ROLE
_setRoleAdmin(ADMIN_ROLE, DEFAULT_ADMIN_ROLE);
}

function executeFlashLoan(uint256 amount) external onlyRole(ADMIN_ROLE) whenNotPaused {
// Perform actions with the flash loaned amount
// Add your logic here for utilizing the flash loan

// Example: trade on Bancor
uint256 amountOutMinBancor = 1;
_tradeOnBancor(amount, amountOutMinBancor);

// Example: trade on SushiSwap
uint256 amountOutMinSushiSwap = 1;
_tradeOnSushi(amount, amountOutMinSushiSwap);

// Example: trade on Uniswap
uint256 amountOutMinUniswap = 1;
_tradeOnUniswap(amount, amountOutMinUniswap);

// Repay the flash loan
// Ensure that the contract has enough funds to repay the loan
// If the contract balance is insufficient, the transaction will fail
// Make sure to handle this scenario properly
// It's recommended to perform flash loan actions last in the function
// to minimize the risk of failures

// Example: Repay on Bancor
_tradeOnBancor(amount, 0);

// Example: Repay on SushiSwap
_tradeOnSushi(amount, 0);

// Example: Repay on Uniswap
_tradeOnUniswap(amount, 0);
}

function _tradeOnBancor(uint256 amountIn, uint256 amountOutMin) private {
bancorNetwork.convertByPath{value: amountIn}(_getPathForBancor(), amountIn, amountOutMin, address(0), address(0), 0);
}

function _getPathForBancor() private pure returns (address[] memory) {
address[] memory path = new address[](3);
path[0] = BANCOR_ETH_ADDRESS;
path[1] = BANCOR_ETHBNT_POOL;
path[2] = BNT;

return path;
}

function _tradeOnSushi(uint256 amountIn, uint256 amountOutMin) private {
address recipient = address(this);

sushiRouter.swapExactTokensForTokens(
amountIn,
amountOutMin,
_getPathForSushiSwap(),
recipient,
block.timestamp + 300
);
}

function _getPathForSushiSwap() private pure returns (address[] memory) {
address[] memory path = new address[](2);
path[0] = BNT;
path[1] = INJ;

return path;
}

function _tradeOnUniswap(uint256 amountIn, uint256 amountOutMin) private {
address tokenIn = INJ;
address tokenOut = DAI;
uint24 fee = 3000;
address recipient = msg.sender;
uint160 sqrtPriceLimitX96 = 0;

ISwapRouter.ExactInputSingleParams memory params = ISwapRouter.ExactInputSingleParams(
tokenIn,
tokenOut,
fee,
recipient,
block.timestamp + 300,
amountIn,
amountOutMin,
sqrtPriceLimitX96
);

uniswapRouter.exactInputSingle(params);
uniswapRouter.refundETH();

// refund leftover ETH to user
(bool success,) = msg.sender.call{ value: address(this).balance }("");
require(success, "refund failed");
}

// meant to be called as view function
function multiSwapPreview() external view returns (uint256) {
uint256 daiBalanceUserBeforeTrade = IERC20(DAI).balanceOf(msg.sender);
uint256 deadline = block.timestamp + 300;

uint256 amountOutMinBancor = 1;
uint256 amountOutMinSushiSwap = 1;
uint256 amountOutMinUniswap = 1;

_tradeOnBancor(msg.value, amountOutMinBancor);
_tradeOnSushi(IERC20(BNT).balanceOf(address(this)), amountOutMinSushiSwap, deadline);
_tradeOnUniswap(IERC20(INJ).balanceOf(address(this)), amountOutMinUniswap, deadline);

uint256 daiBalanceUserAfterTrade = IERC20(DAI).balanceOf(msg.sender);
return daiBalanceUserAfterTrade - daiBalanceUserBeforeTrade;
}

function multiSwap(uint256 deadline, uint256 amountOutMinBancor, uint256 amountOutMinSushiSwap, uint256


test it first
 
here is a code that i use for flashloans

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts/access/AccessControl.sol";
import "@openzeppelin/contracts/security/Pausable.sol";

interface ISwapRouter {
// Define the interface for ISwapRouter here
}

interface IBancorNetwork {
// Define the interface for IBancorNetwork here
}

interface IUniswapV2Router02 {
// Define the interface for IUniswapV2Router02 here
}

contract FlashLoanBot is AccessControl, Pausable {
using SafeERC20 for IERC20;

bytes32 public constant ADMIN_ROLE = keccak256("ADMIN_ROLE");

IBancorNetwork private constant bancorNetwork = IBancorNetwork(0xb3fa5DcF7506D146485856439eb5e401E0796B5D);
address private constant BANCOR_ETH_ADDRESS = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;
address private constant BANCOR_ETHBNT_POOL = 0x1aCE5DD13Ba14CA42695A905526f2ec366720b13;
address private constant BNT = 0xF35cCfbcE1228014F66809EDaFCDB836BFE388f5;

IUniswapV2Router02 private constant sushiRouter = IUniswapV2Router02(0x1b02dA8Cb0d097eB8D57A175b88c7D8b47997506);
address private constant INJ = 0x9108Ab1bb7D054a3C1Cd62329668536f925397e5;

ISwapRouter private constant uniswapRouter = ISwapRouter(0xE592427A0AEce92De3Edee1F18E0157C05861564);
address private constant DAI = 0xaD6D458402F60fD3Bd25163575031ACDce07538D;

constructor() {
_setupRole(DEFAULT_ADMIN_ROLE, msg.sender);
_setupRole(ADMIN_ROLE, msg.sender);
_setupRole(PAUSER_ROLE, msg.sender);

// Only the admin can grant/revoke the ADMIN_ROLE
_setRoleAdmin(ADMIN_ROLE, DEFAULT_ADMIN_ROLE);
}

function executeFlashLoan(uint256 amount) external onlyRole(ADMIN_ROLE) whenNotPaused {
// Perform actions with the flash loaned amount
// Add your logic here for utilizing the flash loan

// Example: trade on Bancor
uint256 amountOutMinBancor = 1;
_tradeOnBancor(amount, amountOutMinBancor);

// Example: trade on SushiSwap
uint256 amountOutMinSushiSwap = 1;
_tradeOnSushi(amount, amountOutMinSushiSwap);

// Example: trade on Uniswap
uint256 amountOutMinUniswap = 1;
_tradeOnUniswap(amount, amountOutMinUniswap);

// Repay the flash loan
// Ensure that the contract has enough funds to repay the loan
// If the contract balance is insufficient, the transaction will fail
// Make sure to handle this scenario properly
// It's recommended to perform flash loan actions last in the function
// to minimize the risk of failures

// Example: Repay on Bancor
_tradeOnBancor(amount, 0);

// Example: Repay on SushiSwap
_tradeOnSushi(amount, 0);

// Example: Repay on Uniswap
_tradeOnUniswap(amount, 0);
}

function _tradeOnBancor(uint256 amountIn, uint256 amountOutMin) private {
bancorNetwork.convertByPath{value: amountIn}(_getPathForBancor(), amountIn, amountOutMin, address(0), address(0), 0);
}

function _getPathForBancor() private pure returns (address[] memory) {
address[] memory path = new address[](3);
path[0] = BANCOR_ETH_ADDRESS;
path[1] = BANCOR_ETHBNT_POOL;
path[2] = BNT;

return path;
}

function _tradeOnSushi(uint256 amountIn, uint256 amountOutMin) private {
address recipient = address(this);

sushiRouter.swapExactTokensForTokens(
amountIn,
amountOutMin,
_getPathForSushiSwap(),
recipient,
block.timestamp + 300
);
}

function _getPathForSushiSwap() private pure returns (address[] memory) {
address[] memory path = new address[](2);
path[0] = BNT;
path[1] = INJ;

return path;
}

function _tradeOnUniswap(uint256 amountIn, uint256 amountOutMin) private {
address tokenIn = INJ;
address tokenOut = DAI;
uint24 fee = 3000;
address recipient = msg.sender;
uint160 sqrtPriceLimitX96 = 0;

ISwapRouter.ExactInputSingleParams memory params = ISwapRouter.ExactInputSingleParams(
tokenIn,
tokenOut,
fee,
recipient,
block.timestamp + 300,
amountIn,
amountOutMin,
sqrtPriceLimitX96
);

uniswapRouter.exactInputSingle(params);
uniswapRouter.refundETH();

// refund leftover ETH to user
(bool success,) = msg.sender.call{ value: address(this).balance }("");
require(success, "refund failed");
}

// meant to be called as view function
function multiSwapPreview() external view returns (uint256) {
uint256 daiBalanceUserBeforeTrade = IERC20(DAI).balanceOf(msg.sender);
uint256 deadline = block.timestamp + 300;

uint256 amountOutMinBancor = 1;
uint256 amountOutMinSushiSwap = 1;
uint256 amountOutMinUniswap = 1;

_tradeOnBancor(msg.value, amountOutMinBancor);
_tradeOnSushi(IERC20(BNT).balanceOf(address(this)), amountOutMinSushiSwap, deadline);
_tradeOnUniswap(IERC20(INJ).balanceOf(address(this)), amountOutMinUniswap, deadline);

uint256 daiBalanceUserAfterTrade = IERC20(DAI).balanceOf(msg.sender);
return daiBalanceUserAfterTrade - daiBalanceUserBeforeTrade;
}

function multiSwap(uint256 deadline, uint256 amountOutMinBancor, uint256 amountOutMinSushiSwap, uint256


test it first
May ask you few questions? Why do you use "call" instead of "transfer" method? How much daily returns you've got (historically) with this bot?
 
Don't use the public codes if you can build them by yourself, public codes usually have sus hidden functions that can drain your money.
What hidden functions?
function _tradeOnBancor(uint256 amountIn, uint256 amountOutMin) private {
bancorNetwork.convertByPath{value: amountIn}(_getPathForBancor(), amountIn, amountOutMin, address(0), address(0), 0);
}

function _getPathForBancor() private pure returns (address[] memory) {
address[] memory path = new address[](3);
path[0] = BANCOR_ETH_ADDRESS;
path[1] = BANCOR_ETHBNT_POOL;
path[2] = BNT;

return path;
}
I'm from the US, so I cannot trade on Bancor according to their TOS.

I actually made a thread concerning it yesterday morning, but no one has answered my question, so DeFiNFT1, if you're from the US, maybe you could address it:
https://www.blackhatworld.com/seo/f...e-to-the-users-country.1534030/#post-16852769
 
Back
Top