Code Monkey home page Code Monkey logo

defi-bot's People

Contributors

codemedici avatar extropycoder avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

defi-bot's Issues

Got this error when trying to run.

I’m very new to this coding thing, but I really wanna learn and thought this project could help me learn, but when I tried to run it it threw this error: syntax error: unexpected identifier.
I can’t understand anything can somebody please help me how to set this bot up.
When I opened it up I just made a .env file and filled it nothing more.
Do I have to do anything more or what. Im completely lost at this point.

Cannot read property of 'address' of undefined

I'm getting this error whenever I run the index.js bot and I'm not sure what the solution is. I've tried defining 'address' in the code where it's throwing the error, and it still says the same thing.

INFO: Could not find files for the given pattern(s).
INFO: Could not find files for the given pattern(s).
INFO: Could not find files for the given pattern(s).
INFO: Could not find files for the given pattern(s).
INFO: Could not find files for the given pattern(s).
INFO: Could not find files for the given pattern(s).
INFO: Could not find files for the given pattern(s).
INFO: Could not find files for the given pattern(s).
C:\Users\water\Documents\github\defi-bot\node_modules\web3-eth-accounts\lib\index.js:408
if (!this[account.address]) {
^

TypeError: Cannot read property 'address' of undefined
at Wallet.add (C:\Users\water\Documents\github\defi-bot\node_modules\web3-eth-accounts\lib\index.js:408:23)
at Object. (C:\Users\water\Documents\github\defi-bot\src\index.js:23:26)
at Module._compile (internal/modules/cjs/loader.js:1063:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
at Module.load (internal/modules/cjs/loader.js:928:32)
at Function.Module._load (internal/modules/cjs/loader.js:769:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
at internal/main/run_main_module.js:17:47

Does anyone have any ideas what could be causing this issue?

I am getting this error when running: SyntaxError: Unexpected identifier

Here are the details:
SyntaxError: Unexpected identifier
at wrapSafe (internal/modules/cjs/loader.js:915:16)
at Module._compile (internal/modules/cjs/loader.js:963:27)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
at Module.load (internal/modules/cjs/loader.js:863:32)
at Function.Module._load (internal/modules/cjs/loader.js:708:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js
:60:12)
at internal/main/run_main_module.js:17:47

Cannot find module 'dotenv' when executing

I've done all the steps to set up the node.js bot and have added the info to my .env file but it keeps throwing this error:

internal/modules/cjs/loader.js:883
throw err;
^

Error: Cannot find module 'dotenv'
Require stack:

  • C:\Users\water\Documents\GitHub\defi-bot\src\index.js
    ←[90m at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15)←[39m
    ←[90m at Function.Module._load (internal/modules/cjs/loader.js:725:27)←[39m
    ←[90m at Module.require (internal/modules/cjs/loader.js:952:19)←[39m
    ←[90m at require (internal/modules/cjs/helpers.js:88:18)←[39m
    at Object. (C:\Users\water\Documents\GitHub\defi-bot\src\index.js:1:1)
    ←[90m at Module._compile (internal/modules/cjs/loader.js:1063:30)←[39m
    ←[90m at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)←[39m
    ←[90m at Module.load (internal/modules/cjs/loader.js:928:32)←[39m
    ←[90m at Function.Module._load (internal/modules/cjs/loader.js:769:14)←[39m
    ←[90m at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)←[39m {
    code: ←[32m'MODULE_NOT_FOUND'←[39m,
    requireStack: [ ←[32m'C:\Users\water\Documents\GitHub\defi-bot\src\index.js'←[39m ]
    }

none of the files have been moved around, although I did copy the .env file into the root directory as well as the \src folder just to be sure it could find the file it is looking for. Has anyone else come across this issue? What do I need to do so that it can find the file?

[DEP0005] & [ERR_IPC_CHANNEL_CLOSED]

I've been getting these error messages after importing the required libraries. I've been trying to fix this however the debug isn't much help and just directs me to line 5 of the bootstrap-fork.js file.

Windows 10
Node.js v16.3.0.
Typescript version 4.3.4
VS Code 1.57.1

Thanks. Also, codemedici I appreciate you helping me out last time even though my question was pretty simple. I'm using this bot as a means to help teach myself to code. Figured I'd get more enjoyment out of it if I'm working on something I actually care about.

Error
error2
error1

Insufficient Funds Error

Hi,

First off thanks for putting this together. It has been extremely useful in better understanding Smart Contracts and Arbitrage in general.

I'm currently using the project as a basis to create my own bot in Go.

Currently when I run the node app I get an Insufficient Funds error whenever an arbitrage opportunity is detected.

Error:

Profitable?  Asset Order      Exchange Order  Input                   Output                  Profit                  Timestamp
-----------  ---------------  --------------  ----------------------  ----------------------  ----------------------  -------------------------
true         WETH, DAI, WETH  ZRX, 1Split     0.00128                 0.001282346964590108    0.000002346964590107    2021-02-03T11:49:13-06:00

/Users/daidokoro/Projects/crypto/defi-bot/node_modules/web3-core-helpers/lib/errors.js:28
        var err = new Error('Returned error: ' + message);
                  ^

Error: Returned error: insufficient funds for gas * price + value
    at Object.ErrorResponse (/Users/daidokoro/Projects/crypto/defi-bot/node_modules/web3-core-helpers/lib/errors.js:28:19)
    at /Users/daidokoro/Projects/crypto/defi-bot/node_modules/web3-core-requestmanager/lib/index.js:303:36
    at XMLHttpRequest.request.onreadystatechange (/Users/daidokoro/Projects/crypto/defi-bot/node_modules/web3-providers-http/lib/index.js:98:13)
    at XMLHttpRequestEventTarget.dispatchEvent (/Users/daidokoro/Projects/crypto/defi-bot/node_modules/xhr2-cookies/dist/xml-http-request-event-target.js:34:22)
    at XMLHttpRequest._setReadyState (/Users/daidokoro/Projects/crypto/defi-bot/node_modules/xhr2-cookies/dist/xml-http-request.js:208:14)
    at XMLHttpRequest._onHttpResponseEnd (/Users/daidokoro/Projects/crypto/defi-bot/node_modules/xhr2-cookies/dist/xml-http-request.js:318:14)
    at IncomingMessage.<anonymous> (/Users/daidokoro/Projects/crypto/defi-bot/node_modules/xhr2-cookies/dist/xml-http-request.js:289:61)
    at IncomingMessage.emit (node:events:341:22)
    at endReadableNT (node:internal/streams/readable:1294:12)
    at processTicksAndRejections (node:internal/process/task_queues:80:21) {
  data: null
}

My Config

RPC_URL="https://mainnet.infura.io/v3/<apikey>"
ADDRESS="0x<my account hash>"
PRIVATE_KEY="0x<my private key>"
CONTRACT_ADDRESS="0x<my deployed contract hash>"
GAS_LIMIT=3000000
GAS_PRICE=400
ESTIMATED_GAS=1700000

The account I'm using currently has a balance of 0.8 ETH

I have tried reducing the FLASH_AMOUNT variable in the script as I believed maybe it was trying to borrow more than it could actually afford, but even with the value set to 1 ETH, I still get the same error.

I also noticed that the Input value shown in the table is always 0.00128. When I print out the non-profitable values, the inputs vary, but only the input value above seems to show up when a profitable arbitrage is detected.

Is there something i'm missing here?

Thanks in advance

Fail with error 'OneSplit: swap makes no sense'

Transaction keeps reverting with the error "Fail with error 'OneSplit: swap makes no sense'"

https://etherscan.io/tx/0x35c7e07964a90184d8f3571ae4b5d6b976b978b55f306cd21dcfeca39e5eff49

It seems the error is being thrown from OneSplit's swap function

function swap(
        IERC20 fromToken,
        IERC20 toToken,
        uint256 amount,
        uint256 minReturn,
        uint256[] memory distribution,
        uint256 featureFlags // See contants in IOneSplit.sol
    ) public payable {
        require(fromToken != toToken && amount > 0, "OneSplit: swap makes no sense");
        require((msg.value != 0) == fromToken.isETH(), "OneSplit: msg.value shoule be used only for ETH swap");

        uint256 fromTokenBalanceBefore = fromToken.universalBalanceOf(address(this)).sub(msg.value);
        uint256 toTokenBalanceBefore = toToken.universalBalanceOf(address(this));

        fromToken.universalTransferFromSenderToThis(amount);
        fromToken.universalApprove(address(oneSplitImpl), amount);

        oneSplitImpl.swap.value(msg.value)(
            fromToken,
            toToken,
            amount,
            minReturn,
            distribution,
            featureFlags
        );

        uint256 fromTokenBalanceAfter = fromToken.universalBalanceOf(address(this));
        uint256 toTokenBalanceAfter = toToken.universalBalanceOf(address(this));

        uint256 returnAmount = toTokenBalanceAfter.sub(toTokenBalanceBefore);
        require(returnAmount >= minReturn, "OneSplit: actual return amount is less than minReturn");
        toToken.universalTransfer(msg.sender, returnAmount);

        if (fromTokenBalanceAfter > fromTokenBalanceBefore) {
            fromToken.universalTransfer(msg.sender, fromTokenBalanceAfter.sub(fromTokenBalanceBefore));
        }
    }

More specifically, this line here
require(fromToken != toToken && amount > 0, "OneSplit: swap makes no sense");

My guess is that the amount being passed is less than zero in the TradingBot contract.

uint256 _toAmount = _afterBalance - _beforeBalance;
// Swap on 1Split: give _toToken, receive _fromToken
_oneSplitSwap(_toToken, _fromToken, _toAmount, _1SplitMinReturn, _1SplitDistribution);

Does anyone have any ideas what might be happening or how to work around this?

UnimplementedFeatureError:

if ı try deploy code from remix , ı have this issue :

"UnimplementedFeatureError:"

why and what can ı do ?

trouble launching bot from root directory

sudo node src/index.js
/home/user/Desktop/Crypto Bot/defi-bot-main (copy 1)/defi-bot-main/node_modules/web3-eth-accounts/lib/index.js:408
if (!this[account.address]) {
^

TypeError: Cannot read property 'address' of undefined
at Wallet.add (/home/user/Desktop/Crypto Bot/defi-bot-main (copy 1)/defi-bot-main/node_modules/web3-eth-accounts/lib/index.js:408:23)
at Object. (/home/user/Desktop/Crypto Bot/defi-bot-main (copy 1)/defi-bot-main/src/index.js:23:26)
at Module._compile (node:internal/modules/cjs/loader:1102:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1131:10)
at Module.load (node:internal/modules/cjs/loader:967:32)
at Function.Module._load (node:internal/modules/cjs/loader:807:14)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:76:12)
at node:internal/main/run_main_module:17:47

i get this error everytime i try and launch from the root directory, any suggestions?

Trouble deploying TradingBot.sol

I cannot deploy the TradingBot.sol contract on the blockchain networks (I have been using Kovan and Ropsten test networks) on Remix IDE. Remix is giving me an the error:

"Gas estimation errored with the following message (see below). The transaction execution will likely fail. Do you want to force sending?
execution reverted"

I am using compiler version 0.5.17 as suggested by the documentation.

When I send anyways, the contract fails. The failed contract deployment transaction can be seen here : https://ropsten.etherscan.io/tx/0xa632f0d856ed5de32e45e5bcaad1e9a976f9565b752f8f8697d5732b76912e2a

I have tried increasing gas limit, but the error still appears.

Additionally, when I compile the TradingBot.sol, I receive two warnings,

TradingBot.sol:2:1: Warning: Experimental features are turned on. Do not use experimental features on live deployments.
pragma experimental ABIEncoderV2;
^-------------------------------^
TradingBot.sol:307:9: Warning: Return value of low-level calls not used.
address(ZRX_EXCHANGE_ADDRESS).call.value(msg.value)(_calldataHexString);
^---------------------------------------------------------------------^

Is there a solution to deploy the TradingBot.sol?

ts(1005) Error

defi bot error

A few things I've tried:

  • Put a semicolon and comma at the end
  • Disabled TypeScript and JavaScript Language Features

Typescript version 4.3.4
VS Code 1.57.1
Windows 10

Any ideas on what the actual issue is, and how to fix it?

Thanks

Some help plz, have 2 issues

Hello, im having 2 problems when deploying the TradingBot.sol.

First is in line 2: "Warning: Experimental features are turned on. Do not use experimental features on live deployments. Pragma experimental ABIEncoderV"

second is in line 306: "Warning: return value of low-level calls not used. Address (ZRX_EXCHANGE_ADDRESS). call.value.(msg.value)(_calldateHexString);"

Can someone help? ty

Testnet Support

Hi there,

Please is it possible to run this bot on a testnet?

Thanks,
Babs

What is the optimum values for Gas For Arb to Run

Hi thanks for the article and code. The challenge i have is getting the optimum value for Gas for Arb. How much is sufficient is the value provided in .env is the right values ? It turns out to be too much cost from a txn fee prospective.

gateway error

I'm running the bot in an ubuntu ec2 instance and when it finds an opportunity and attempts a trade I get:

Error: Invalid JSON RPC response: "<html>\r\n<head><title>504 Gateway Time-out</title></head>\r\n<body>\r\n<center><h1>504 Gateway Time-out</h1></center>\r\n<hr><center>Microsoft-Azure-Application-Gateway/v2</center>\r\n</body>\r\n</html>\r\n"

Am I needing to open up ports on my security group on my ec2 instance or something?

More of the stack trace:

Fetching market data @ 2021-01-26T12:59:11-06:00 ...

Profitable?  Asset Order      Exchange Order  Input                   Output                  Profit                  Timestamp                
-----------  ---------------  --------------  ----------------------  ----------------------  ----------------------  -------------------------
true         WETH, DAI, WETH  ZRX, 1Split     1                       1.033573150904851463    0.033573150904851456    2021-01-26T12:59:12-06:00

Error playing sound!
Fetching market data @ 2021-01-26T12:59:14-06:00 ...


(node:17917) UnhandledPromiseRejectionWarning: Error: Invalid JSON RPC response: "<html>\r\n<head><title>504 Gateway Time-out</title></head>\r\n<body>\r\n<center><h1>504 Gateway Time-out</h1></center>\r\n<hr><center>Microsoft-Azure-Application-Gateway/v2</center>\r\n</body>\r\n</html>\r\n"
    at Object.InvalidResponse (/home/ec2-user/environment/projects/defi-advanced-bot/node_modules/web3-core-helpers/lib/errors.js:43:16)
    at XMLHttpRequest.request.onreadystatechange (/home/ec2-user/environment/projects/defi-advanced-bot/node_modules/web3-providers-http/lib/index.js:95:32)
    at XMLHttpRequestEventTarget.dispatchEvent (/home/ec2-user/environment/projects/defi-advanced-bot/node_modules/xhr2-cookies/dist/xml-http-request-event-target.js:34:22)
    at XMLHttpRequest._setReadyState (/home/ec2-user/environment/projects/defi-advanced-bot/node_modules/xhr2-cookies/dist/xml-http-request.js:208:14)
    at XMLHttpRequest._onHttpResponseEnd (/home/ec2-user/environment/projects/defi-advanced-bot/node_modules/xhr2-cookies/dist/xml-http-request.js:318:14)
    at IncomingMessage.<anonymous> (/home/ec2-user/environment/projects/defi-advanced-bot/node_modules/xhr2-cookies/dist/xml-http-request.js:289:61)
    at IncomingMessage.emit (events.js:203:15)
    at endReadableNT (_stream_readable.js:1145:12)
    at process._tickCallback (internal/process/next_tick.js:63:19)

[Solved]: Error: Invalid JSON RPC response: ""

Hi guys and gals,

I was able to successfully deploy the TradingBot.sol contract to the mainnet (after many unsuccessful attempts on Ropsten and Rinkeby). Then I wanted to get index.js to run. After commenting out line 327, I did a yarn install and npm install in the directory and then ran node src/index.js. However I always get the following error messages in return:

Fetching market data @ 2021-08-02T11:18:22-05:00 ...

Fetching market data @ 2021-08-02T11:18:25-05:00 ...

(node:130667) UnhandledPromiseRejectionWarning: Error: Invalid JSON RPC response: ""
    at Object.InvalidResponse (/root/defi-bot/node_modules/web3-core-helpers/lib/errors.js:43:16)
    at XMLHttpRequest.request.onreadystatechange (/root/defi-bot/node_modules/web3-providers-http/lib/index.js:95:32)
    at XMLHttpRequestEventTarget.dispatchEvent (/root/defi-bot/node_modules/xhr2-cookies/dist/xml-http-request-event-target.js:34:22)
    at XMLHttpRequest._setReadyState (/root/defi-bot/node_modules/xhr2-cookies/dist/xml-http-request.js:208:14)
    at XMLHttpRequest._onHttpRequestError (/root/defi-bot/node_modules/xhr2-cookies/dist/xml-http-request.js:349:14)
    at ClientRequest.<anonymous> (/root/defi-bot/node_modules/xhr2-cookies/dist/xml-http-request.js:252:61)
    at ClientRequest.emit (events.js:375:28)
    at Socket.socketErrorListener (_http_client.js:475:9)
    at Socket.emit (events.js:375:28)
    at emitErrorNT (internal/streams/destroy.js:106:8)
    at emitErrorCloseNT (internal/streams/destroy.js:74:3)
    at processTicksAndRejections (internal/process/task_queues.js:82:21)
(node:130667) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 608)

This error message appears almost every time. The cases, where two Fetching market data messages appear after another are extremely rare. Does anyone have an idea how to solve this?
Thanks

Best Regards

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.