jamesbachini / DEX-Arbitrage

Example arbitrage trading bot
GNU General Public License v3.0
615 stars 350 forks source link

TypeError: Cannot read properties of undefined (reading 'balance') #3

Closed h6561105 closed 2 years ago

h6561105 commented 2 years ago

I removed some of the baseAssets and I get this error message when I try to run trade.js, and also how do I transfer WETH into aurora?

TypeError: Cannot read properties of undefined (reading 'balance') at lookForDualTrade (I:\aurora2\DEX-Arbitrage\scripts\trade.js:52:50) at lookForDualTrade (I:\aurora2\DEX-Arbitrage\scripts\trade.js:64:13) at processTicksAndRejections (node:internal/process/task_queues:96:5) at lookForDualTrade (I:\aurora2\DEX-Arbitrage\scripts\trade.js:64:7) at main (I:\aurora2\DEX-Arbitrage\scripts\trade.js:19:3)

DDecoene commented 2 years ago

Paste your config and I will look at it

jamesbachini commented 2 years ago

Looks like a zero balance issue. Make sure the contract has at least one base asset to trade and is holding an amount of those funds. You can get WETH by wrapping ETH for WETH (Wrapped ETH) on Trisolaris. The team has implemented a transaction fee now unfortunately so you need some ETH in your main account to pay gas fees. You can get a tiny amount of ETH from https://aurora.dev/faucet for larger amounts use one of the bridges. Trisolaris has a list of them.

slawton3 commented 1 year ago

I am getting this issue as well. I made sure the contract and owner has enough eth for gas. Was anyone able to find a solution to this?

Here's my config for Aurora:

  "arbContract": "**contract-redacted**",
  "minBasisPointsPerTrade": 0,
  "routers": [
    { "dex": "trisolaris", "address": "0x2CB45Edb4517d5947aFdE3BEAbF95A582506858B" },
    { "dex": "wannaswap", "address": "0xa3a1ef5ae6561572023363862e238afa84c72ef5" },
    { "dex": "auroraswap", "address": "0xA1B1742e9c32C7cAa9726d8204bD5715e3419861" }
  ],
  "baseAssets": [
    { "sym": "weth","address": "0xC9BdeEd33CD01541e1eeD10f90519d2C06Fe3feB" },
    { "sym": "wnear", "address": "0xC42C30aC6Cc15faC9bD938618BcaA1a1FaE8501d" },
    { "sym": "aurora", "address": "0x8BEc47865aDe3B172A928df8f990Bc7f2A3b9f79" },
    { "sym": "usdc", "address": "0xB12BFcA5A55806AaF64E99521918A4bf0fC40802" }
  ],

Error:

undefined
TypeError: Cannot read properties of undefined (reading 'balance')
    at lookForDualTrade (C:\Users\Sean\dev\DEX-Arbitrage\scripts\trade.js:75:46)
    at lookForDualTrade (C:\Users\Sean\dev\DEX-Arbitrage\scripts\trade.js:66:15)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at lookForDualTrade (C:\Users\Sean\dev\DEX-Arbitrage\scripts\trade.js:66:9)
    at lookForDualTrade (C:\Users\Sean\dev\DEX-Arbitrage\scripts\trade.js:66:9)
    at lookForDualTrade (C:\Users\Sean\dev\DEX-Arbitrage\scripts\trade.js:76:5)
    at lookForDualTrade (C:\Users\Sean\dev\DEX-Arbitrage\scripts\trade.js:66:9)
    at lookForDualTrade (C:\Users\Sean\dev\DEX-Arbitrage\scripts\trade.js:66:9)
    at lookForDualTrade (C:\Users\Sean\dev\DEX-Arbitrage\scripts\trade.js:66:9)
    at lookForDualTrade (C:\Users\Sean\dev\DEX-Arbitrage\scripts\trade.js:76:5)

//logged the token after
{
  sym: 'wnear',
  balance: BigNumber { value: "7000000000000000000000000" },
  startBalance: BigNumber { value: "7000000000000000000000000" }
}
jamesbachini commented 1 year ago

Maybe the wannaswap address doesn't have the right checksum (all lowercase)?

Can't see why that would affect it though. Assume you didn't change anything in trade.js?

Would definitely double check all the addresses on a block explorer if that is all you've modified

zikkuratti commented 1 year ago

got the same

slawton3 commented 1 year ago

I've narrowed it down to the following:

It looks like the trade.js file is looking for the USDT and UST stablecoin addresses in the balances object under the target route.

This is returning undefined:

balances[targetRoute.token1]

Token 1 (US Terra) does not exist in the contract balance

{
  router1: '0xa3a1ef5ae6561572023363862e238afa84c72ef5',
  router2: '0xA1B1742e9c32C7cAa9726d8204bD5715e3419861',
  token1: '0x5ce9F0B6AFb36135b5ddBF11705cEB65E634A9dC',
  token2: '0xC42C30aC6Cc15faC9bD938618BcaA1a1FaE8501d'
}

Solution Update

Need to remove any routes from the config.json file that contain any removed stablecoin addresses.

zikkuratti commented 1 year ago

@slawton3 yep or just comment out this exception log) it's work