GithubHelp home page GithubHelp logo

liquality / atomicagent Goto Github PK

View Code? Open in Web Editor NEW
23.0 8.0 35.0 5.25 MB

๐Ÿ’ฅ Atomic Agent

Home Page: https://www.npmjs.com/package/atomicagent

License: MIT License

JavaScript 96.28% Dockerfile 0.73% Shell 2.91% HCL 0.08%
bitcoin ethereum agent automated-trading automated-trading-bot cryptocurrency

atomicagent's Introduction

๐Ÿ’ฅ Atomic Agent Build status

User <-> Agent Swap Workflow

Workflow

Prerequisites

  1. Linux VM
  2. node 14
  3. mongoDB 4.2+
  4. Redis 5
  5. RPC/API endpoints for the chains you want to support

bin/atomicagent commands

Usage: atomicagent [options] [command]

Options:
  -V, --version   output the version number
  -h, --help      display help for command

Commands:
  wallet          Communicate with asset wallets
  manage          Manage assets & markets
  help [command]  display help for command
Usage: bin/atomicagent wallet [options] [command]

Options:
  -c, --config <path>                       Config file path
  -h, --help                                display help for command

Commands:
  balances
  balance <asset>
  getnewaddress <asset>
  sendtoaddress <asset> <address> <amount>
  help [command]                            display help for command
Usage: bin/atomicagent manage [options] [command]

Options:
  -c, --config <path>                                     Config file path
  -h, --help                                              display help for command

Commands:
  asset:add <code> <min> <max> <minConf> <dailyUsdLimit>
  asset:set <code> <key> <value>
  asset:disable <code>
  asset:enable <code>
  markets:create
  market:spread:set <from> <to> <spread>
  market:spread:get <from> <to>
  help [command]                                          display help for command

Setup

Prepare config.toml

git clone [email protected]:liquality/atomicagent.git
cd atomicagent
npm ci
cp sample.config.toml config.toml   # copy sample config
nano config.toml                    # configure your agent

Prepare assets & markets

bin/atomicagent manage asset:add <code1> <min> <max> <minConf> <dailyUsdLimit>
bin/atomicagent manage asset:add <code2> <min> <max> <minConf> <dailyUsdLimit>
bin/atomicagent manage markets:create # creates market for code1-code2 & code2-code1

Start the agent

npm start

Liquality Hosted Agents

Environment Network Endpoint
Production Testnet https://liquality.io/swap-testnet/agent
Production Mainnet https://liquality.io/swap/agent
Development Testnet https://liquality.io/swap-testnet-dev/agent
Development Mainnet https://liquality.io/swap-dev/agent

Liquality Testnet Nodes

Node Network Endpoint
Bitcoin Electrs Testnet https://liquality.io/testnet/electrs
Bitcoin Batch Electrs Testnet https://liquality.io/electrs-testnet-batch
Ethereum Scraper Testnet https://liquality.io/eth-ropsten-api
RSK Scraper Testnet https://liquality.io/rsk-testnet-api
BSC Scraper Testnet https://liquality.io/bsc-testnet-api
Polygon Scraper Testnet https://liquality.io/polygon-testnet-api/

Liquality Mainnet Nodes

Node Network Endpoint
Bitcoin Electrs Mainnet https://api-mainnet-bitcoin-electrs.liquality.io
Bitcoin Batch Electrs Mainnet https://api-mainnet-bitcoin-electrs-batch.liquality.io
Ethereum Scraper Mainnet https://liquality.io/eth-mainnet-api
RSK Scraper Mainnet https://liquality.io/rsk-mainnet-api
BSC Scraper Mainnet https://liquality.io/bsc-mainnet-api
Polygon Scraper Mainnet https://liquality.io/polygon-mainnet-api/

Test

Configure

cp sample.config.toml test.config.toml  # copy sample config
nano config.toml                        # configure your agent as per your test environment

Test!

chmod -R 777 test/docker/config
npm run docker:start
sleep 30                          # let bitcoind[regtest] mine first 100 blocks
npm run test

License

MIT

atomicagent's People

Contributors

andonmitev avatar beemi avatar dependabot[bot] avatar devaraj-s avatar gr0kchain avatar harshjv avatar kraikov avatar manicprone avatar monokh avatar tima-t 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

atomicagent's Issues

Fail to update market data for BTC on testnet

Description

Received the below error when running atomic agent locally, so cannot update market data for BTC.

o [NodeError]
    at r._handleNodeError (/.../liquality/atomicagent/node_modules/@liquality/node-provider/dist/index.js:1:1508)
    at /.../liquality/atomicagent/node_modules/@liquality/node-provider/dist/index.js:1:1882
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (internal/process/task_queues.js:93:5) {
  error: 'Invalid "addresses" field'
}

The error is thrown from here: https://github.com/liquality/electrs-batch-server/blob/a01156688134962ca82380c8e62af6189a16323a/index.js#L45

This is probably because the addresses are [] in this line, when updating market data for BTC:

const addresses = await client.wallet.getUsedAddresses()

The BTC configuration.

  [assets.BTC]
  blockTime = "1 minute"
  network = "bitcoin_testnet"
  addressType = "bech32"
  swapMode = "p2wsh"
  feeNumberOfBlocks = 2
  defaultFee = "average"
    [assets.BTC.api]
    url = "https://liquality.io/testnet/electrs"
    [assets.BTC.batchApi]
    url = "https://liquality.io/electrs-testnet-batch/"
    [assets.BTC.wallet]
    type = "js"
    mnemonic = "<seed phrase>"

Fail to swap ETH to NEAR

Description

When running atomic agent and wallet locally. we met the below error in wallet when swap ETH to NEAR.

Error: Can not sign transactions for account 77edf44c33b222feb3a31b2ac7a002d528334c31b06653cdc335182c19773431 on network testnet, no matching key pair found in InMemorySigner(InMemoryKeyStore).

Retry doesn't work.

Screenshots:

image
image
image

verify-user-init-tx fails on testnet

The current scheduler expires before a block is mined on the bitcoin testnet

2019-12-05T13:55:10.585Z liquality:agent:worker Max attempts reached. Job has failed { _id: 5de90bf280129d033967c9ed,
name: 'verify-user-init-tx',
data: { orderId: '624d2492-7bc8-444f-91c0-36f92f93c0c6' },
type: 'normal',
priority: 0,
nextRunAt: null,
lastModifiedBy: null,
lockedAt: null,
lastRunAt: 2019-12-05T13:55:10.579Z,
failCount: 6,
failReason: 'Request failed with status code 404',
failedAt: 2019-12-05T13:55:10.584Z,
lastFinishedAt: 2019-12-05T13:55:10.584Z }

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Pending Approval

These branches will be created by Renovate only once you click their checkbox below.

  • chore(deps): update dependency chai to v4.3.6
  • chore(deps): update dependency human-interval to v2.0.1
  • chore(deps): update dependency nodemon to v2.0.19
  • fix(deps): update dependency @chainify/bitcoin to v1.2.29
  • fix(deps): update dependency @chainify/bitcoin-ledger to v1.2.29
  • fix(deps): update dependency @chainify/client to v1.2.29
  • fix(deps): update dependency @chainify/errors to v1.2.29
  • fix(deps): update dependency @chainify/evm to v1.2.29
  • fix(deps): update dependency @chainify/evm-ledger to v1.2.29
  • fix(deps): update dependency @chainify/near to v1.2.29
  • fix(deps): update dependency @chainify/solana to v1.2.29
  • fix(deps): update dependency @chainify/terra to v1.2.29
  • fix(deps): update dependency @chainify/types to v1.2.29
  • fix(deps): update dependency @chainify/utils to v1.2.29
  • fix(deps): update dependency commander to v6.2.1
  • fix(deps): update dependency express-session to v1.17.3
  • fix(deps): update dependency semver to v7.3.7
  • chore(deps): update dependency eslint to v8.22.0
  • chore(deps): update dependency eslint-config-prettier to v8.5.0
  • chore(deps): update dependency eslint-plugin-prettier to v4.2.1
  • chore(deps): update dependency mocha to v9.2.2
  • chore(deps): update dependency prettier to v2.7.1
  • chore(deps): update node.js to v14.20.0
  • chore(deps): update yarn to v3.2.3
  • fix(deps): update dependency @amplitude/node to v1.10.0
  • fix(deps): update dependency @bull-board/api to v3.11.1
  • fix(deps): update dependency @bull-board/express to v3.11.1
  • fix(deps): update dependency @liquality/cryptoassets to v1.14.2
  • fix(deps): update dependency @sentry/node to v6.19.7
  • fix(deps): update dependency bignumber.js to v9.1.0
  • fix(deps): update dependency body-parser to v1.20.0
  • fix(deps): update dependency bull to v4.8.5
  • fix(deps): update dependency date-fns to v2.29.2
  • fix(deps): update dependency debug to v4.3.4
  • fix(deps): update dependency express to v4.18.1
  • fix(deps): update dependency express-async-handler to v1.2.0
  • fix(deps): update dependency helmet to v4.6.0
  • fix(deps): update dependency mongoose to v6.5.3
  • chore(deps): update actions/checkout action to v3
  • chore(deps): update actions/setup-node action to v3
  • chore(deps): update dependency mocha to v10
  • chore(deps): update jwalton/gh-docker-logs action to v2
  • chore(deps): update node.js to v16
  • fix(deps): update dependency @bull-board/api to v4
  • fix(deps): update dependency @bull-board/express to v4
  • fix(deps): update dependency @sentry/node to v7
  • fix(deps): update dependency commander to v9
  • fix(deps): update dependency helmet to v5
  • fix(deps): update dependency http-errors to v2
  • fix(deps): update dependency ioredis to v5

Detected dependencies

dockerfile
original.Dockerfile
github-actions
.github/workflows/test-publish-deploy.yml
  • actions/checkout v2
  • actions/setup-node v2
.github/workflows/test.yml
  • actions/checkout v2
  • actions/setup-node v2
  • jwalton/gh-docker-logs v1
npm
package.json
  • @amplitude/node 1.8.4
  • @bull-board/api 3.10.0
  • @bull-board/express 3.10.0
  • @chainify/bitcoin 1.2.7
  • @chainify/bitcoin-ledger 1.2.7
  • @chainify/client 1.2.7
  • @chainify/errors 1.2.7
  • @chainify/evm 1.2.7
  • @chainify/evm-ledger 1.2.7
  • @chainify/near 1.2.7
  • @chainify/solana 1.2.7
  • @chainify/terra 1.2.7
  • @chainify/types 1.2.7
  • @chainify/utils 1.2.7
  • @liquality/cryptoassets 1.13.2
  • @sentry/node 6.13.2
  • axios 0.27.2
  • bignumber.js 9.0.2
  • bluebird 3.7.2
  • body-parser 1.19.1
  • bull 4.6.2
  • commander 6.2.0
  • compression 1.7.4
  • connect-mongo 4.6.0
  • cors 2.8.5
  • date-fns 2.28.0
  • debug 4.2.0
  • express 4.17.1
  • express-async-handler 1.1.4
  • express-basic-auth 1.2.1
  • express-session 1.17.2
  • helmet 4.2.0
  • http-errors 1.8.1
  • ioredis 4.28.5
  • lodash 4.17.21
  • mongoose 6.2.4
  • node-vault 0.9.22
  • semver 7.3.5
  • standard-error 1.1.0
  • string-argv 0.3.1
  • toml 3.0.0
  • uuid 8.3.2
  • chai 4.3.4
  • chai-http 4.3.0
  • eslint 8.6.0
  • eslint-config-prettier 8.3.0
  • eslint-plugin-prettier 4.0.0
  • human-interval 2.0.0
  • mocha 9.1.4
  • nodemon 2.0.13
  • pre-commit 1.2.2
  • prettier 2.5.1
  • node >=16.10.0
  • yarn 3.1.1
nvm
.nvmrc
  • node v14.18.1

  • Check this box to trigger a request for Renovate to run again on this repository

Migrate process should terminate

npm run migrate

This process stays alive even after the migration has been done. We need to terminate unless it takes care of anything else.

Integration into third party api's

Some opportunities for liquidity providers who can use third party wallets to host liquidity.

Examples of this might include hedging strategies or using a wallet from a third party or exchange account. Considering that contracts are represented by addresses, these api's can be instructed to fund the contracts instead of having those wallets accessed via hardware wallets, JS wallets or nodes.

Need help, running the agent locally and got stuck on Locking ETH while swap BTC to ETH

hello, I was trying to run this app on my local environtment.
I have successfully running the wallet, api & worker locally.
I have changed my wallet build.config.js testnet agent endpoint into http://localhost:3030.
After that, I tried to swap BTC to ETH (of course on testnet), but got stuck on Locking ETH process after the bitcoin transaction is confirmed.

And then I tried using https://liquality.io/swap-testnet/agent as the testnet agent endpoint on my wallet, I got no error with that.

So the problem is come from my local api/worker, but what caused it ? since I got no error both on api/worker console.
I'm running the latest dev branch.
here my config.toml file, please point me if I got it wrong

[database]
uri = "mongodb://localhost/liqualitytest"
debug = true

[application]
apiPort = 3030
swapExpirationDurationInSeconds = 3600
nodeSwapExpirationDurationInSeconds = 1800

[auth]
cookieSecret = '58da74ef560e5578cb46219b7818d7c2'
cookieMaxAgeMs = 86400000
simplePassword = '25ec02267950f537347b4a7c02b00ced'

[threshold]
manualAboveFromAmountUsd = 5000

[worker]
maxJobRetry = 5
jobRetryDelay = "5 seconds"
backendJobRetryDelay = "5 seconds"
minConcurrentSwaps = 3
defaultLockLifetimeInMs = 120000 # 2 min
killswitch = 'pm2 stop "Worker"'

[assets]
  [assets.BTC]
  network = "bitcoin_testnet"
  addressType = "bech32"
  swapMode = "p2wsh"
  feeNumberOfBlocks = 2
  blockTime = "5 seconds"
  defaultFee = "average"
    [assets.BTC.wallet]
    type = "js"
    mnemonic = "piece effort bind that embrace enrich remind powder sudden patient legend group"
    [assets.BTC.api]
    url = "https://liquality.io/testnet/electrs/"
    [assets.BTC.batchApi]
    url = "https://liquality.io/electrs-testnet-batch/"
    [assets.BTC.rpc]
    url = "http://localhost:8332/"
    user = "bitcoinrpc"
    password = "password"

  [assets.ETH]
  network="rinkeby"
  blockTime = "5 seconds"
  defaultFee = "average"
    [assets.ETH.wallet]
    type = "js"
    mnemonic = "piece effort bind that embrace enrich remind powder sudden patient legend group"
    [assets.ETH.scraper]
    url = "https://liquality.io/eth-rinkeby-api"
    [assets.ETH.rpc]
    url = "https://rinkeby.infura.io/v3/myInfuraId"

  [assets.DAI]
  network="rinkeby"
  type = "ERC20"
  blockTime = "5 seconds"
  contractAddress = "0x094cdd8e19b97505869c87a995a972c4df7f69a8"
  defaultFee = "average"
    [assets.DAI.wallet]
    type = "js"
    mnemonic = "piece effort bind that embrace enrich remind powder sudden patient legend group"
    [assets.DAI.scraper]
    url = "https://liquality.io/eth-rinkeby-api"
    [assets.DAI.rpc]
    url = "https://rinkeby.infura.io/v3/myInfuraId"

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.