# crypto-bot-trader

> swapping of ERC-20 Tokens (buy/sell) based on the market health with bot strategy (condition) - by utilizing metamask & pupeteer

Latest version **2.4.3** (published 2022-08-14) · ISC license · 0 weekly downloads

## Install

```sh
npm install crypto-bot-trader
pnpm add crypto-bot-trader
yarn add crypto-bot-trader
bun add crypto-bot-trader
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.4.3 |
| Published | 2022-08-14 |
| First published | 2021-12-27 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 9 |
| Unpacked size | 180.6 KB |
| Known vulnerabilities | 0 (+15 in 1 direct dependencies) |
| Install scripts | no |
| Author | marx |
| Maintainers | marcelo.oblan |

## Links

- npm: https://www.npmjs.com/package/crypto-bot-trader
- Repository: https://github.com/marcelooblan2016/crypto-bot-trader
- Homepage: https://github.com/marcelooblan2016/crypto-bot-trader.git#readme
- Issues: https://github.com/marcelooblan2016/crypto-bot-trader.git/issues
- npm.io page: https://npm.io/package/crypto-bot-trader

## Dependencies (9)

- [xvfb](https://npm.io/package/xvfb.md) ^0.4.0
- [cryptr](https://npm.io/package/cryptr.md) ^6.0.2
- [lodash](https://npm.io/package/lodash.md) ^4.17.21
- [moment](https://npm.io/package/moment.md) ^2.29.1
- [forever](https://npm.io/package/forever.md) ^4.0.1
- [nodemailer](https://npm.io/package/nodemailer.md) ^6.7.2
- [readline-sync](https://npm.io/package/readline-sync.md) ^1.4.10
- [api.coinmarketcap](https://npm.io/package/api.coinmarketcap.md) ^1.0.1
- [@chainsafe/dappeteer](https://npm.io/package/@chainsafe/dappeteer.md) 3.0.0-rc.0

## Recent versions

- 2.4.3 (latest) — 2022-08-14
- 2.4.2-beta.11 (beta) — 2022-08-11
- 2.4.2 — 2022-08-11
- 2.4.2-beta.1 — 2022-08-11
- 2.4.1 — 2022-08-10
- 2.4.0 — 2022-08-04
- 2.3.6 — 2022-08-01
- 2.3.5 — 2022-07-17
- 2.3.0 — 2022-05-02
- 2.2.2 — 2022-02-23
- 2.2.0 — 2022-02-17
- 2.1.7 — 2022-01-18
- 2.1.6 — 2022-01-18
- 2.1.5 — 2022-01-15
- 2.1.4 — 2022-01-14
- … 30 more at https://npm.io/package/crypto-bot-trader/versions

## README

# CryptoCurrency Bot Trader
swapping of [ERC-20 Tokens][erc20] (buy/sell) based on the market health with bot strategy (condition) - by utilizing MetaMask &amp; Puppeteer

![image](https://drive.google.com/uc?export=view&id=1IzFTRLwAVSPK3j1h2AkwkqbOBOq6VzeC)

## List of ERC-20 Tokens Included
- ChainLink Token, Decentraland, Uniswap, Aave, Curve (CRV), Sushi Token, Avalanche, Wrapped Matic, Wrapped BTC
- [Full Details][erc20List] 
## Compatible Networks
- Polygon

## Important token/coin
- usdc (for trading)
- matic (for gas fees)

## Notes
- Always make sure to have a balance in usdc (used for trading) & matic (for gas fees)
- One trade at a time (for now)
- Compound trading

## Installation

```bash
npm i crypto-bot-trader
```
## Usage
Filename as .env in {root}
```bash
PREFERRED_NETWORK="matic-mainnet"
# Default: 0
HEADLESS_BROWSER=1
# Sell Options
# Default: -10 (percent as unit)
SELL_CUTLOSS=-5
# Default: 5 (percent as unit)
SELL_PROFIT=1
```

## Security
As for initial setup will require you to input your PrivateKey & password (required upon encryption of your data)
![image](https://drive.google.com/uc?export=view&id=1a7fPmue1yNcsjbS9_pQvgAUBIpifCTkW)

Filename as {jsFile} in {root}

```js
const {metaMask, trader, token} = require('crypto-bot-trader');

(async function() {
    // // initiate 
    await metaMask.build();
    const initiatedTrader = new trader({metamask_with_build: metaMask, token: token});
    
    await initiatedTrader.analyzeMarket()
    setInterval(async () => {
        await initiatedTrader.analyzeMarket()
    }, 300000);
    // every 5 minutes

})();
```

```bash
node {jsFile}
```

## Extras
You can also stop your trading bot on a certain date; This is quite ideal on cloud server <Which im currently working-on>

On Env File: Add the following key
```bash
CHECKPOINT_DATE="{YOUR_DATE_HERE-> Format: YYYY-MM-DD HH:mm} (24-hour)"
```

## Headless
Typical headless in puppeteer with extension of metamask will not work. Alternatively, you can use X Virtual Frame Buffer (xvfb) [See Details][npmforever] 

```js
const {metaMask, trader, token} = require('crypto-bot-trader');
const Xvfb = require('xvfb');

(async function() {
    let xvfb = new Xvfb();
    xvfb.startSync();
    // // initiate 
    await metaMask.build();
    const initiatedTrader = new trader({metamask_with_build: metaMask, token: token});
    
    await initiatedTrader.analyzeMarket()
    setInterval(async () => {
        await initiatedTrader.analyzeMarket()
    }, 300000);
    // every 5 minutes

})();
```

## Deploy in cloud server
Setup in cloud server, A simple CLI tool for ensuring that a given script runs continuously/in-background called (forever) [See Details][npmforever] 

```js
const {metaMask, trader, token} = require('crypto-bot-trader');
const { exec } = require("child_process");

(async function() {
    await metaMask.initializeSecurity({pwd: null, is_setup: true});
    exec(`forever start headless.js --pwd=1`, (error, stdout, stderr) => {});

})();
```

## Focus Feature
Focus on a specific token, this is good especially if the volatility of token is really high.
- focus on matic? wmatic
- focus on bitcoin? wbtc
- foucus on etherium? weth

```bash
node {jsFile} --focus=wmatic
```

[erc20]: https://etherscan.io/tokens
[erc20List]: https://github.com/marcelooblan2016/crypto-bot-trader/blob/main/src/Records/Migrations/tokenContracts.js
[npmforever]: https://www.npmjs.com/package/forever
[npmxvfb]: https://www.npmjs.com/package/xvfb

## Method: 'sendto'
After a successful trade, profit will be sent to a specific wallet address.
This feature is good if you have bunch of bot traders & you want the profit to be centralized.
```bash
node {jsFile} --focus=wmatic --method=sendto
```
In .env in {root}
```bash
WALLET_ADDRESS=
# Exact amount that will be the baseline of trader to prevent draining of wallet; (USDC Currency)
# Ex: 200
BASE_AMOUNT=
```

---
_Source: https://npm.io/package/crypto-bot-trader · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
