From da76ff62f57b1f276a1772c8993b98a427b1b0aa Mon Sep 17 00:00:00 2001 From: |M| Date: Thu, 26 Aug 2021 08:40:22 -0600 Subject: [PATCH 01/15] Unify utilities into a single service for containerization (#372) * WIP - Adding back migrate check, working to unify services into one image * Unified utilities into one service * Renamed to api-service * Renaming to KEEP_ALIVE * Removing obsolete dockerfile * Pass full opts object to migrate * Renaming to service.dockerfile * Adding capabilities for running full system with docker compose * Invoking all services to run as full * Completed full system lifecycle, updated README * Formatting tweak to README * Reordered sections in README * Only trigger ci/cd tests on relevant changes * Fix on: syntax in test action --- .github/workflows/docker-push-to-personal.yml | 4 +- .github/workflows/test.yml | 9 +- README.md | 124 +++++++++++---- bin/{start-api.sh => start-service.sh} | 4 +- config.docker.toml | 97 ++++++++++++ env/local/config.local.toml | 146 ++++++++---------- env/local/run-mongodb.yml | 4 - env/personal/config.personal.toml | 30 +++- env/personal/run-mongodb.yml | 18 +++ env/tester/config.tester.toml | 102 ++++++++++++ env/tester/run-full-system.yml | 26 ++++ original.Dockerfile | 9 -- package.json | 8 +- api.dockerfile => service.dockerfile | 8 +- src/index.js | 15 +- src/migrate/index.js | 50 +++++- 16 files changed, 507 insertions(+), 147 deletions(-) rename bin/{start-api.sh => start-service.sh} (67%) create mode 100644 config.docker.toml create mode 100644 env/personal/run-mongodb.yml create mode 100644 env/tester/config.tester.toml create mode 100644 env/tester/run-full-system.yml delete mode 100644 original.Dockerfile rename api.dockerfile => service.dockerfile (85%) diff --git a/.github/workflows/docker-push-to-personal.yml b/.github/workflows/docker-push-to-personal.yml index bb714f673..9288dcf03 100644 --- a/.github/workflows/docker-push-to-personal.yml +++ b/.github/workflows/docker-push-to-personal.yml @@ -1,4 +1,4 @@ -name: 'deploy-to-personal' +name: 'Docker build, tag, push to ECR (personal)' on: push: @@ -14,7 +14,7 @@ env: AWS_REGION: 'us-east-2' IMAGE_NAME: 'atomicagent-personal' IMAGE_TAG: 'latest' - DOCKERFILE_PATH: 'api.dockerfile' + DOCKERFILE_PATH: 'service.dockerfile' jobs: docker-deploy: diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index eda30ec53..0d6bdeaeb 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,7 +1,14 @@ # This actions runs against every Pull request(Include Draft) name: Test -on: push +on: + push: + paths: + - 'src/**' + - 'test/**' + - 'sample.config.toml' + - 'package.json' + - '.github/workflows/test.yml' jobs: test: diff --git a/README.md b/README.md index 6d7acf1c0..f85f7021e 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,23 @@ ![Workflow](diagram.png "Workflow") +## Table of Contents + +* [Introduction][section-introduction] +* [Prerequisites][section-prerequisites] +* [Installation][section-installation] +* [Test][section-test] +* [Liquality Hosted Agents][section-liquality-hosted-agents] +* [Liquality Nodes][section-liquality-nodes] +* [Docker Setup Variations][section-docker-setup-variations] +* [License][section-license] + + +## Introduction + +The atomicagent service contains three utilities: `migrate`, `api`, `worker`. Each can be run separately, or as a full service. + + ## Prerequisites 1. Linux VM @@ -13,28 +30,66 @@ 4. [RPC/API endpoints for the chains you want to support](#liquality-nodes) -## Setup +## Installation + +These instructions outline the standard installation process for the atomic agent: ```bash git clone git@github.com:liquality/atomicagent.git cd atomicagent -npm ci +npm install cp sample.config.toml config.toml # copy sample config -nano config.toml # configure your agent +nano config.toml # configure your agent settings nano src/migrate/data/assets.json # add/remove assets nano src/migrate/data/markets.json # add/remove markets npm run migrate # prepare agent with assets & markets ``` +### Run Each Utility Separately + +```bash +npm run api # runs agent market maker api +npm run worker # runs the background process +``` + +### Run as a Unified Service + +``` bash +npm run api-service +``` + +> These methods utilize the `config.toml` you created at the root of the repo. + +> For Docker options, see: [Docker Setup Variations](#docker-setup-variations) + + +## Test + +### Configure + +```bash +cp sample.config.toml test.config.toml # copy sample config +nano config.toml # configure your agent as per your test environment +``` + +### Run Automated Tests + +```bash +chmod -R 777 test/docker/config +npm run docker:start +sleep 30 # let bitcoind[regtest] mine first 100 blocks +npm run test +``` + ## Liquality Hosted Agents -|Environment| Network | Endpoint | +|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 | +|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 @@ -61,36 +116,53 @@ npm run migrate # prepare agent with assets & markets | Polygon Scraper | Mainnet | https://liquality.io/polygon-mainnet-api/ | +## Docker Setup Variations -## Run! +The atomicagent service (which contains three utilities: migrate, api, worker) can be dockerized for portability and convenience. -```bash -npm run api # runs agent market maker api -npm run worker # runs the background process -``` +### Run the Atomic Agent Service Locally +To run the service (all three utilities) as a single container locally: -## Test +| Command | Description | +| --------------------- | ------------------------------------- | +| `docker:build-local` | Builds the "atomicagent-local" image. | +| `docker:run-local` | Runs the "atomicagent-local" image as a container. | +| `docker:log-local` | Prints the standard out of the running "atomicagent-local" container. | +| `docker:stop-local` | Stops the running "atomicagent-local" container. | +The config file used for these commands: `env/local/config.local.toml` -### Configure +> **NOTE:** This configuration requires you to have your own MongoDB running. -```bash -cp sample.config.toml test.config.toml # copy sample config -nano config.toml # configure your agent as per your test environment -``` +> **TIP:** You can use the `env/local/run-mongodb.yml` config to run a simple MongoDB locally. +### Run the Full Swap System -### Test! +The atomicagent service operates on multiple dependencies (for various chains/networks), as well as requiring a MongoDB to read/write data. -```bash -chmod -R 777 test/docker/config -npm run docker:start -sleep 30 # let bitcoind[regtest] mine first 100 blocks -npm run test -``` +To run the full swap system in a contained environment (for testing purposes): + +| Command | Description | +| --------------------------- | ------------------------------------- | +| `docker:start-full-system` | Builds and runs the "atomicagent-full-system" image and runs a local simulation of the supported agent services. | +| `docker:log-full-system` | Prints the standard out of the running "atomicagent-full-system" container. | +| `docker:stop-full-system` | Stops the running "atomicagent-full-system" container and the agent services. | + +The config file used for these commands: `env/tester/config.tester.toml` ## License [MIT](./LICENSE.md) + + + +[section-introduction]: #introduction +[section-prerequisites]: #prerequisites +[section-installation]: #installation +[section-test]: #test +[section-liquality-hosted-agents]: #liquality-hosted-agents +[section-liquality-nodes]: #liquality-nodes +[section-docker-setup-variations]: #docker-setup-variations +[section-license]: #license diff --git a/bin/start-api.sh b/bin/start-service.sh similarity index 67% rename from bin/start-api.sh rename to bin/start-service.sh index ba4f9ed70..2c6f4a3a8 100755 --- a/bin/start-api.sh +++ b/bin/start-service.sh @@ -5,6 +5,6 @@ echo "ENV_ALIAS: ${ENV_ALIAS}" echo "--------------------------------" echo "" -echo "Starting Atomic Agent API..." +echo "Starting the Atomic Agent service..." -npm run api +npm run api-service diff --git a/config.docker.toml b/config.docker.toml new file mode 100644 index 000000000..5eb6c191b --- /dev/null +++ b/config.docker.toml @@ -0,0 +1,97 @@ +[database] +debug = false +# uri = "mongodb://docker.for.mac.host.internal:27017/swapOrders" +uri = "mongodb://admin:admin-password@docker.for.mac.host.internal:27017/swapOrders?authSource=admin" + +[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_regtest" + 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 = "http://localhost:3002/" # vulpemventures/electrs:latest (3rd party) + [assets.BTC.batchApi] + url = "http://localhost:9090/" # electrs-batch-server.dockerfile (inside docker dir) + [assets.BTC.rpc] + url = "http://localhost:18443/" # vulpemventures/bitcoin:latest (3rd party) + user = "admin1" + password = "123" + + [assets.ETH] + network="local" + 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 = "http://localhost:8080" # ethereum-scraper + [assets.ETH.rpc] + url = "http://localhost:8545" # Infura (3rd party) + + [assets.DAI] + network="local" + 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 = "http://localhost:8080" # ethereum-scraper + [assets.DAI.rpc] + url = "http://localhost:8545" # Infura (3rd party) + + [assets.RBTC] + blockTime = "20 seconds" + network = "rsk_testnet" + defaultFee = "average" + pegWith = "BTC" + [assets.RBTC.rpc] + url = "https://public-node.testnet.rsk.co" # RSK service (3rd party) + [assets.RBTC.scraper] + url = "https://liquality.io/rsk-testnet-api/" # ethereum-scraper + [assets.RBTC.wallet] + type = "js" + mnemonic = "piece effort bind that embrace enrich remind powder sudden patient legend group" + + [assets.SOV] + blockTime = "20 seconds" + network = "rsk_testnet" + defaultFee = "average" + contractAddress = "0x6a9A07972D07E58f0daF5122D11e069288A375fB" + [assets.SOV.rpc] + url = "https://public-node.testnet.rsk.co" # Infura (3rd party) + [assets.SOV.scraper] + url="https://liquality.io/rsk-testnet-api/" # ethereum-scraper + [assets.SOV.wallet] + type = "js" + mnemonic = "piece effort bind that embrace enrich remind powder sudden patient legend group" diff --git a/env/local/config.local.toml b/env/local/config.local.toml index 44378a729..5fa463c24 100644 --- a/env/local/config.local.toml +++ b/env/local/config.local.toml @@ -1,36 +1,12 @@ [database] -# ---------------------------------------------- Connection settings for MongoDB -# Provide either (uri will take precedence): -# -# uri - A full mongodb connection uri (see: https://docs.mongodb.com/manual/reference/connection-string/) -# e.g. -# mongodb://admin:password@127.0.0.1:27017/liquality?authSource=admin -# -# -or- -# -# host - The db hostname/IP -# port - The db port (optional) -# dbname - The db name (optional) -# username - The username for auth (optional, leave blank if no auth) -# password - The password for auth (optional, leave blank if no auth) -# authdbname - The auth db name (optional with auth, leave blank if no auth) -# ------------------------------------------------------------------------------ -# Other options: -# -# debug - true|false (Enables mongodb debug) -# ------------------------------------------------------------------------------ debug = false -#uri = "mongodb://demo:demo-password@docker.for.mac.host.internal:27017/rickandmorty?authSource=test" -#uri = "mongodb://demo:demo-password@127.0.0.1:27017/rickandmorty?authSource=test" +# uri = "mongodb://127.0.0.1:27017/liquality" +# uri = "mongodb://docker.for.mac.host.internal:27017/liquality" uri = "mongodb://admin:admin-password@docker.for.mac.host.internal:27017/liquality?authSource=admin" -# uri = "mongodb://admin:admin-password@127.0.0.1:27017/liquality?authSource=admin" -#host = "docker.for.mac.host.internal" -host = "127.0.0.1" -port = "27017" -dbname = "rickandmorty" -username = "demo" -password = "demo-password" -authdbname = "test" + [database.migrate] + log = true + verbose = false + force = true [application] apiPort = 3030 @@ -54,24 +30,24 @@ defaultLockLifetimeInMs = 120000 # 2 min killswitch = 'pm2 stop "Worker"' [assets] - # [assets.BTC] - # network = "bitcoin_regtest" - # 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 = "http://localhost:3002/" # vulpemventures/electrs:latest (3rd party) - # [assets.BTC.batchApi] - # url = "http://localhost:9090/" # electrs-batch-server.dockerfile (inside docker dir) - # [assets.BTC.rpc] - # url = "http://localhost:18443/" # vulpemventures/bitcoin:latest (3rd party) - # user = "admin1" - # password = "123" + [assets.BTC] + network = "bitcoin_regtest" + 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 = "http://localhost:3002/" # vulpemventures/electrs:latest (3rd party) + [assets.BTC.batchApi] + url = "http://localhost:9090/" # electrs-batch-server.dockerfile (inside docker dir) + [assets.BTC.rpc] + url = "http://localhost:18443/" # vulpemventures/bitcoin:latest (3rd party) + user = "admin1" + password = "123" [assets.ETH] network="local" @@ -85,42 +61,42 @@ killswitch = 'pm2 stop "Worker"' [assets.ETH.rpc] url = "http://localhost:8545" # Infura (3rd party) - # [assets.DAI] - # network="local" - # 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 = "http://localhost:8080" # ethereum-scraper - # [assets.DAI.rpc] - # url = "http://localhost:8545" # Infura (3rd party) + [assets.DAI] + network="local" + 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 = "http://localhost:8080" # ethereum-scraper + [assets.DAI.rpc] + url = "http://localhost:8545" # Infura (3rd party) - # [assets.RBTC] - # blockTime = "20 seconds" - # network = "rsk_testnet" - # defaultFee = "average" - # pegWith = "BTC" - # [assets.RBTC.rpc] - # url = "https://public-node.testnet.rsk.co" # RSK service (3rd party) - # [assets.RBTC.scraper] - # url = "https://liquality.io/rsk-testnet-api/" # ethereum-scraper - # [assets.RBTC.wallet] - # type = "js" - # mnemonic = "piece effort bind that embrace enrich remind powder sudden patient legend group" + [assets.RBTC] + blockTime = "20 seconds" + network = "rsk_testnet" + defaultFee = "average" + pegWith = "BTC" + [assets.RBTC.rpc] + url = "https://public-node.testnet.rsk.co" # RSK service (3rd party) + [assets.RBTC.scraper] + url = "https://liquality.io/rsk-testnet-api/" # ethereum-scraper + [assets.RBTC.wallet] + type = "js" + mnemonic = "piece effort bind that embrace enrich remind powder sudden patient legend group" - # [assets.SOV] - # blockTime = "20 seconds" - # network = "rsk_testnet" - # defaultFee = "average" - # contractAddress = "0x6a9A07972D07E58f0daF5122D11e069288A375fB" - # [assets.SOV.rpc] - # url = "https://public-node.testnet.rsk.co" # Infura (3rd party) - # [assets.SOV.scraper] - # url="https://liquality.io/rsk-testnet-api/" # ethereum-scraper - # [assets.SOV.wallet] - # type = "js" - # mnemonic = "piece effort bind that embrace enrich remind powder sudden patient legend group" + [assets.SOV] + blockTime = "20 seconds" + network = "rsk_testnet" + defaultFee = "average" + contractAddress = "0x6a9A07972D07E58f0daF5122D11e069288A375fB" + [assets.SOV.rpc] + url = "https://public-node.testnet.rsk.co" # Infura (3rd party) + [assets.SOV.scraper] + url="https://liquality.io/rsk-testnet-api/" # ethereum-scraper + [assets.SOV.wallet] + type = "js" + mnemonic = "piece effort bind that embrace enrich remind powder sudden patient legend group" diff --git a/env/local/run-mongodb.yml b/env/local/run-mongodb.yml index dda4b3c41..62e50774e 100644 --- a/env/local/run-mongodb.yml +++ b/env/local/run-mongodb.yml @@ -9,10 +9,6 @@ services: environment: - PUID=1000 - PGID=1000 - - MONGO_INITDB_ROOT_USERNAME=root - - MONGO_INITDB_ROOT_PASSWORD=password - volumes: - - ~/mongodb/db:/data/db ports: - 27017:27017 restart: unless-stopped diff --git a/env/personal/config.personal.toml b/env/personal/config.personal.toml index a111250b7..78dfe9a3e 100644 --- a/env/personal/config.personal.toml +++ b/env/personal/config.personal.toml @@ -1,13 +1,41 @@ [database] +# ---------------------------------------------- Connection settings for MongoDB +# Provide either (uri will take precedence): +# +# uri - A full mongodb connection uri (see: https://docs.mongodb.com/manual/reference/connection-string/) +# e.g. +# mongodb://admin:password@127.0.0.1:27017/liquality?authSource=admin +# +# -or- +# +# host - The db hostname/IP +# port - The db port (optional) +# dbname - The db name (optional) +# username - The username for auth (optional, leave blank if no auth) +# password - The password for auth (optional, leave blank if no auth) +# authdbname - The auth db name (optional with auth, leave blank if no auth) +# ------------------------------------------------------------------------------ +# Other options: +# +# debug - true|false (Enables mongodb debug) +# +# [database.migrate] +# log - true|false (Enables migrator logging, for short messages, default: true) +# verbose - true|false (Enables verbose migrator logging, for debugging, default: false) +# force - true|false (Forces refresh of assets/markets data, default: false) +# ------------------------------------------------------------------------------ debug = false # uri = "mongodb://demo:demo-password@docker.for.mac.host.internal:27017/rickandmorty?authSource=test" # uri = "mongodb://admin:admin-password@docker.for.mac.host.internal:27017/liquality?authSource=admin" -# uri = "mongodb://admin:admin-password@docker.for.mac.host.internal:27017/liquality" host = "10.0.1.5" port = "27017" dbname = "liquality" username = "liquality" authdbname = "admin" + [database.migrate] + log = true + verbose = false + force = false [application] apiPort = 3030 diff --git a/env/personal/run-mongodb.yml b/env/personal/run-mongodb.yml new file mode 100644 index 000000000..dda4b3c41 --- /dev/null +++ b/env/personal/run-mongodb.yml @@ -0,0 +1,18 @@ +# Run with: docker-compose -f run-mongodb.yml up -d +# Look inside with: docker exec -it mongodb bash +version: "3.8" + +services: + mongodb: + image : mongo + container_name: mongodb + environment: + - PUID=1000 + - PGID=1000 + - MONGO_INITDB_ROOT_USERNAME=root + - MONGO_INITDB_ROOT_PASSWORD=password + volumes: + - ~/mongodb/db:/data/db + ports: + - 27017:27017 + restart: unless-stopped diff --git a/env/tester/config.tester.toml b/env/tester/config.tester.toml new file mode 100644 index 000000000..aa73b07c3 --- /dev/null +++ b/env/tester/config.tester.toml @@ -0,0 +1,102 @@ +[database] +debug = false +uri = "mongodb://localhost/liquality" +# uri = "mongodb://docker.for.mac.host.internal:27017/liquality" +# uri = "mongodb://admin:admin-password@docker.for.mac.host.internal:27017/liquality?authSource=admin" + [database.migrate] + log = true + verbose = false + force = 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_regtest" + 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 = "http://localhost:3002/" # vulpemventures/electrs:latest (3rd party) + [assets.BTC.batchApi] + url = "http://localhost:9090/" # electrs-batch-server.dockerfile (inside docker dir) + [assets.BTC.rpc] + url = "http://localhost:18443/" # vulpemventures/bitcoin:latest (3rd party) + user = "admin1" + password = "123" + + [assets.ETH] + network="local" + 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 = "http://localhost:8080" # ethereum-scraper + [assets.ETH.rpc] + url = "http://localhost:8545" # Infura (3rd party) + + [assets.DAI] + network="local" + 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 = "http://localhost:8080" # ethereum-scraper + [assets.DAI.rpc] + url = "http://localhost:8545" # Infura (3rd party) + + [assets.RBTC] + blockTime = "20 seconds" + network = "rsk_testnet" + defaultFee = "average" + pegWith = "BTC" + [assets.RBTC.rpc] + url = "https://public-node.testnet.rsk.co" # RSK service (3rd party) + [assets.RBTC.scraper] + url = "https://liquality.io/rsk-testnet-api/" # ethereum-scraper + [assets.RBTC.wallet] + type = "js" + mnemonic = "piece effort bind that embrace enrich remind powder sudden patient legend group" + + [assets.SOV] + blockTime = "20 seconds" + network = "rsk_testnet" + defaultFee = "average" + contractAddress = "0x6a9A07972D07E58f0daF5122D11e069288A375fB" + [assets.SOV.rpc] + url = "https://public-node.testnet.rsk.co" # Infura (3rd party) + [assets.SOV.scraper] + url="https://liquality.io/rsk-testnet-api/" # ethereum-scraper + [assets.SOV.wallet] + type = "js" + mnemonic = "piece effort bind that embrace enrich remind powder sudden patient legend group" diff --git a/env/tester/run-full-system.yml b/env/tester/run-full-system.yml new file mode 100644 index 000000000..5282d2546 --- /dev/null +++ b/env/tester/run-full-system.yml @@ -0,0 +1,26 @@ +# Run with: docker-compose -f run-full-system.yml up -d --build +version: "3.8" + +services: + atomicagent-full-system: + build: + context: ../../ + dockerfile: service.dockerfile + args: + ENV_ALIAS: tester + container_name: atomicagent-full-system + environment: + - MONGO_URI=mongodb://10.10.0.8:27017/liquality + ports: + - 3030:3030 + restart: unless-stopped + networks: + local: + ipv4_address: 10.10.0.6 + +networks: + local: + driver: bridge + ipam: + config: + - subnet: 10.10.0.0/24 diff --git a/original.Dockerfile b/original.Dockerfile deleted file mode 100644 index 35efc6313..000000000 --- a/original.Dockerfile +++ /dev/null @@ -1,9 +0,0 @@ -FROM node:slim - -WORKDIR /app - -ADD . /app - -RUN npm ci - -EXPOSE 3030 3031 diff --git a/package.json b/package.json index 6ac80d0c1..bbd306c2f 100644 --- a/package.json +++ b/package.json @@ -16,11 +16,15 @@ "api": "PROCESS_TYPE=api nodemon src/index.js", "worker": "PROCESS_TYPE=worker nodemon src/index.js", "migrate": "PROCESS_TYPE=migrate node src/index.js", + "api-service": "KEEP_ALIVE=true node src/index.js", "migrate-local": "CONFIG_PATH=env/local/config.local.toml PROCESS_TYPE=migrate node src/index.js", - "docker:build-local": "docker build -f api.dockerfile --build-arg ENV_ALIAS=local -t atomicagent-local . --no-cache", - "docker:run-local": "docker run --rm --name atomicagent -d -it atomicagent-local:latest", + "docker:build-local": "docker build -f service.dockerfile --build-arg ENV_ALIAS=local -t atomicagent-local . --no-cache", + "docker:run-local": "docker run --rm --name atomicagent -p 3030:3030 -d -it atomicagent-local:latest", "docker:stop-local": "docker stop atomicagent", "docker:log-local": "docker container logs -t atomicagent", + "docker:start-full-system": "COMPOSE_PROJECT_NAME=tester npm run docker:start && docker-compose -f env/tester/run-full-system.yml up -d --build", + "docker:stop-full-system": "docker stop atomicagent-full-system && COMPOSE_PROJECT_NAME=tester npm run docker:stop", + "docker:log-full-system": "docker container logs -t atomicagent-full-system", "docker:start": "docker-compose -f test/docker/docker-compose.yml up -d --force-recreate --renew-anon-volumes", "docker:stop": "docker-compose -f test/docker/docker-compose.yml down", "lint": "standard", diff --git a/api.dockerfile b/service.dockerfile similarity index 85% rename from api.dockerfile rename to service.dockerfile index 9b0106848..a6fc6301f 100644 --- a/api.dockerfile +++ b/service.dockerfile @@ -25,9 +25,9 @@ COPY LICENSE.md ./ # Load environment config COPY env/${ENV_ALIAS}/config.${ENV_ALIAS}.toml ./config.toml -# --------- -# Start API -# --------- +# ------------- +# Start Service +# ------------- EXPOSE 3030 -CMD ["./bin/start-api.sh"] +CMD ["./bin/start-service.sh"] diff --git a/src/index.js b/src/index.js index 4f2b9b23e..c44ae4206 100644 --- a/src/index.js +++ b/src/index.js @@ -11,7 +11,10 @@ const mongoConnect = require('./utils/mongoConnect') const config = require('./config') // Load db settings and establish connection -mongoConnect.connect(config.database) +const dbConfig = config.database || {} +if (process.env.MONGO_URI) dbConfig.uri = process.env.MONGO_URI // override with env var +const migrateOpts = dbConfig.migrate || {} +mongoConnect.connect(dbConfig) // Run service switch (process.env.PROCESS_TYPE) { @@ -24,9 +27,15 @@ switch (process.env.PROCESS_TYPE) { break case 'migrate': - require('./migrate').run() + require('./migrate').run(migrateOpts) break default: - throw new Error('Unknown PROCESS_TYPE') + runService() +} + +async function runService () { + await require('./migrate').run(migrateOpts) + require('./api').start() + require('./worker').start() } diff --git a/src/migrate/index.js b/src/migrate/index.js index 3eb5df962..1e3d8c5d8 100644 --- a/src/migrate/index.js +++ b/src/migrate/index.js @@ -1,19 +1,53 @@ +const objectUtils = require('lodash/object') const Asset = require('../models/Asset') const Market = require('../models/Market') const assets = require('./data/assets.json') const markets = require('./data/markets.json') +const defaultLog = true +const defaultVerbose = false +const defaultForce = false const logHeader = '[MIGRATE]' module.exports.run = async (options = {}) => { - console.log(`${logHeader} Seeding data...`) - await Asset.deleteMany({}) - const newAssets = await Asset.insertMany(assets, { ordered: false }) - console.log(`${logHeader} ${newAssets.length} assets have been set`) + console.log(`${logHeader} Running migrate with options:`, options) + const log = objectUtils.get(options, 'log', defaultLog) + const verbose = objectUtils.get(options, 'verbose', defaultVerbose) + const force = objectUtils.get(options, 'force', defaultForce) - await Market.deleteMany({}) - const newMarkets = await Market.insertMany(markets, { ordered: false }) - console.log(`${logHeader} ${newMarkets.length} markets have been set`) + const keepAlive = process.env.KEEP_ALIVE || false + console.log(`${logHeader} keep alive?`, keepAlive) - process.exit() + if (!force && await hasData({ verbose })) { + if (log) console.log(`${logHeader} Data is already seeded.`) + } else { + if (log) console.log(`${logHeader} Seeding data...`) + await Asset.deleteMany({}) + const newAssets = await Asset.insertMany(assets, { ordered: false }) + if (log) console.log(`${logHeader} ${newAssets.length} assets have been set`) + + await Market.deleteMany({}) + const newMarkets = await Market.insertMany(markets, { ordered: false }) + if (log) console.log(`${logHeader} ${newMarkets.length} markets have been set`) + } + + if (!keepAlive) process.exit() +} + +async function hasData (options = {}) { + const verbose = options.verbose + let result = true + + if (verbose) console.log(`${logHeader} Checking for existing assets`) + + const existingAssets = await Asset.find({}).exec() + + if (!existingAssets || existingAssets.length === 0) { + if (verbose) console.log('No assets found.') + result = false + } else { + if (verbose) console.log('Existing assets:', existingAssets) + } + + return result } From 5f11a3aa48275e9c8af0b889b17c5263b367b75f Mon Sep 17 00:00:00 2001 From: |M| Date: Thu, 26 Aug 2021 15:49:15 -0600 Subject: [PATCH 02/15] Fixed hostname references in config.tester.toml --- env/tester/config.tester.toml | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/env/tester/config.tester.toml b/env/tester/config.tester.toml index aa73b07c3..707a2a8c7 100644 --- a/env/tester/config.tester.toml +++ b/env/tester/config.tester.toml @@ -1,8 +1,8 @@ [database] debug = false -uri = "mongodb://localhost/liquality" -# uri = "mongodb://docker.for.mac.host.internal:27017/liquality" -# uri = "mongodb://admin:admin-password@docker.for.mac.host.internal:27017/liquality?authSource=admin" +uri = "mongodb://localhost/liqualitytest" +# uri = "mongodb://docker.for.mac.host.internal:27017/liqualitytest" +# uri = "mongodb://admin:admin-password@docker.for.mac.host.internal:27017/liqualitytest?authSource=admin" [database.migrate] log = true verbose = false @@ -41,11 +41,11 @@ killswitch = 'pm2 stop "Worker"' type = "js" mnemonic = "piece effort bind that embrace enrich remind powder sudden patient legend group" [assets.BTC.api] - url = "http://localhost:3002/" # vulpemventures/electrs:latest (3rd party) + url = "http://10.10.0.12:3002/" # vulpemventures/electrs:latest (3rd party) [assets.BTC.batchApi] - url = "http://localhost:9090/" # electrs-batch-server.dockerfile (inside docker dir) + url = "http://10.10.0.14:9090/" # electrs-batch-server.dockerfile (inside docker dir) [assets.BTC.rpc] - url = "http://localhost:18443/" # vulpemventures/bitcoin:latest (3rd party) + url = "http://10.10.0.10:18443/" # vulpemventures/bitcoin:latest (3rd party) user = "admin1" password = "123" @@ -57,9 +57,9 @@ killswitch = 'pm2 stop "Worker"' type = "js" mnemonic = "piece effort bind that embrace enrich remind powder sudden patient legend group" [assets.ETH.scraper] - url = "http://localhost:8080" # ethereum-scraper + url = "http://10.10.0.20:8080" # ethereum-scraper [assets.ETH.rpc] - url = "http://localhost:8545" # Infura (3rd party) + url = "http://10.10.0.16:8545" # Infura (3rd party) [assets.DAI] network="local" @@ -71,9 +71,9 @@ killswitch = 'pm2 stop "Worker"' type = "js" mnemonic = "piece effort bind that embrace enrich remind powder sudden patient legend group" [assets.DAI.scraper] - url = "http://localhost:8080" # ethereum-scraper + url = "http://10.10.0.20:8080" # ethereum-scraper [assets.DAI.rpc] - url = "http://localhost:8545" # Infura (3rd party) + url = "http://10.10.0.16:8545" # Infura (3rd party) [assets.RBTC] blockTime = "20 seconds" From 40df4b1d96063a77aaed946c0f1698e7e46d5a20 Mon Sep 17 00:00:00 2001 From: |M| Date: Wed, 1 Sep 2021 09:27:48 -0600 Subject: [PATCH 03/15] Support FORCE_MIGRATE env for opaque handling --- README.md | 16 ++++++++-------- package.json | 6 +++--- src/migrate/index.js | 2 +- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index f85f7021e..8a732fb0f 100644 --- a/README.md +++ b/README.md @@ -84,12 +84,12 @@ npm run test ## 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 | +|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 @@ -128,7 +128,7 @@ To run the service (all three utilities) as a single container locally: | --------------------- | ------------------------------------- | | `docker:build-local` | Builds the "atomicagent-local" image. | | `docker:run-local` | Runs the "atomicagent-local" image as a container. | -| `docker:log-local` | Prints the standard out of the running "atomicagent-local" container. | +| `docker:log-local` | Prints the standard out of the running "atomicagent-local" container (for quick validation). | | `docker:stop-local` | Stops the running "atomicagent-local" container. | The config file used for these commands: `env/local/config.local.toml` @@ -146,7 +146,7 @@ To run the full swap system in a contained environment (for testing purposes): | Command | Description | | --------------------------- | ------------------------------------- | | `docker:start-full-system` | Builds and runs the "atomicagent-full-system" image and runs a local simulation of the supported agent services. | -| `docker:log-full-system` | Prints the standard out of the running "atomicagent-full-system" container. | +| `docker:log-full-system` | Prints the standard out of the running "atomicagent-full-system" container (for quick validation). | | `docker:stop-full-system` | Stops the running "atomicagent-full-system" container and the agent services. | The config file used for these commands: `env/tester/config.tester.toml` diff --git a/package.json b/package.json index bbd306c2f..861bf4b42 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,7 @@ "scripts": { "api": "PROCESS_TYPE=api nodemon src/index.js", "worker": "PROCESS_TYPE=worker nodemon src/index.js", - "migrate": "PROCESS_TYPE=migrate node src/index.js", + "migrate": "PROCESS_TYPE=migrate FORCE_MIGRATE=true node src/index.js", "api-service": "KEEP_ALIVE=true node src/index.js", "migrate-local": "CONFIG_PATH=env/local/config.local.toml PROCESS_TYPE=migrate node src/index.js", "docker:build-local": "docker build -f service.dockerfile --build-arg ENV_ALIAS=local -t atomicagent-local . --no-cache", @@ -23,14 +23,14 @@ "docker:stop-local": "docker stop atomicagent", "docker:log-local": "docker container logs -t atomicagent", "docker:start-full-system": "COMPOSE_PROJECT_NAME=tester npm run docker:start && docker-compose -f env/tester/run-full-system.yml up -d --build", - "docker:stop-full-system": "docker stop atomicagent-full-system && COMPOSE_PROJECT_NAME=tester npm run docker:stop", + "docker:stop-full-system": "COMPOSE_PROJECT_NAME=tester docker stop atomicagent-full-system && COMPOSE_PROJECT_NAME=tester npm run docker:stop", "docker:log-full-system": "docker container logs -t atomicagent-full-system", "docker:start": "docker-compose -f test/docker/docker-compose.yml up -d --force-recreate --renew-anon-volumes", "docker:stop": "docker-compose -f test/docker/docker-compose.yml down", "lint": "standard", "flint": "standard --fix", "precommit-message-lint": "printf '\nPre-commit checks (linting)...\n' && exit 0", - "test": "DEBUG=liquality:agent* NODE_ENV=test CONFIG_PATH=test.config.toml mocha --exit --bail ./test/*.test.js", + "test": "DEBUG=liquality:agent* NODE_ENV=test CONFIG_PATH=test.config.toml FORCE_MIGRATE=true mocha --exit --bail ./test/*.test.js", "test:unit": "NODE_ENV=test mocha test/unit/**" }, "pre-commit": [ diff --git a/src/migrate/index.js b/src/migrate/index.js index 1e3d8c5d8..87c2c5e6a 100644 --- a/src/migrate/index.js +++ b/src/migrate/index.js @@ -13,7 +13,7 @@ module.exports.run = async (options = {}) => { console.log(`${logHeader} Running migrate with options:`, options) const log = objectUtils.get(options, 'log', defaultLog) const verbose = objectUtils.get(options, 'verbose', defaultVerbose) - const force = objectUtils.get(options, 'force', defaultForce) + const force = process.env.FORCE_MIGRATE || objectUtils.get(options, 'force', defaultForce) const keepAlive = process.env.KEEP_ALIVE || false console.log(`${logHeader} keep alive?`, keepAlive) From 9ebfccfa66334fbe587865160acbd26d4c14f1c0 Mon Sep 17 00:00:00 2001 From: |M| Date: Tue, 21 Sep 2021 16:53:16 -0600 Subject: [PATCH 04/15] WIP: dockerized API separately --- .gitignore | 29 ++++++++++++++++++++++++----- README.md | 15 +++++++++------ api.dockerfile | 31 +++++++++++++++++++++++++++++++ bin/start-api.sh | 11 +++++++++++ env/local/config.local.toml | 2 +- package.json | 8 ++++---- service.dockerfile | 2 -- src/index.js | 5 ++--- 8 files changed, 82 insertions(+), 21 deletions(-) create mode 100644 api.dockerfile create mode 100755 bin/start-api.sh diff --git a/.gitignore b/.gitignore index 8a7cf4376..0bd259214 100644 --- a/.gitignore +++ b/.gitignore @@ -1,10 +1,29 @@ -.env +# ------------------------------------------------------------------------------ +# Local env and config files +# ------------------------------------------------------------------------------ *config.toml !sample.config.toml !heroku.config.toml -node_modules/ -marketdata/ +.env.docker.local test/docker/config/* !test/docker/config/bitcoin.conf -docker-commands.md -.DS_Store + +# ------------------------------------------------------------------------------ +# NodeJS artifacts +# ------------------------------------------------------------------------------ +# (yarn.lock is ignored because we are using npm) +node_modules/ +npm-debug.log* +.eslintcache +yarn.lock + +# ------------------------------------------------------------------------------ +# Custom assets +# ------------------------------------------------------------------------------ +marketdata/ + +# ------------------------------------------------------------------------------ +# OS junk files +# ------------------------------------------------------------------------------ +[Tt]humbs.db +*.DS_Store diff --git a/README.md b/README.md index 8a732fb0f..709a9d0cc 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,5 @@ # 💥 Atomic Agent ![Build status](https://github.com/liquality/agent/workflows/Test,%20publish%20&%20deploy/badge.svg) -## User <-> Agent Swap Workflow - -![Workflow](diagram.png "Workflow") - ## Table of Contents @@ -14,6 +10,7 @@ * [Liquality Hosted Agents][section-liquality-hosted-agents] * [Liquality Nodes][section-liquality-nodes] * [Docker Setup Variations][section-docker-setup-variations] +* [User to Agent Swap Workflow][section-swap-workflow] * [License][section-license] @@ -128,7 +125,7 @@ To run the service (all three utilities) as a single container locally: | --------------------- | ------------------------------------- | | `docker:build-local` | Builds the "atomicagent-local" image. | | `docker:run-local` | Runs the "atomicagent-local" image as a container. | -| `docker:log-local` | Prints the standard out of the running "atomicagent-local" container (for quick validation). | +| `docker:log-local` | Prints the standard out of the running "atomicagent-local" container. | | `docker:stop-local` | Stops the running "atomicagent-local" container. | The config file used for these commands: `env/local/config.local.toml` @@ -146,12 +143,17 @@ To run the full swap system in a contained environment (for testing purposes): | Command | Description | | --------------------------- | ------------------------------------- | | `docker:start-full-system` | Builds and runs the "atomicagent-full-system" image and runs a local simulation of the supported agent services. | -| `docker:log-full-system` | Prints the standard out of the running "atomicagent-full-system" container (for quick validation). | +| `docker:log-full-system` | Prints the standard out of the running "atomicagent-full-system" container. | | `docker:stop-full-system` | Stops the running "atomicagent-full-system" container and the agent services. | The config file used for these commands: `env/tester/config.tester.toml` +## User to Agent Swap Workflow + +![Workflow](diagram.png "Workflow") + + ## License [MIT](./LICENSE.md) @@ -165,4 +167,5 @@ The config file used for these commands: `env/tester/config.tester.toml` [section-liquality-hosted-agents]: #liquality-hosted-agents [section-liquality-nodes]: #liquality-nodes [section-docker-setup-variations]: #docker-setup-variations +[section-swap-workflow]: #user-to-agent-swap-workflow [section-license]: #license diff --git a/api.dockerfile b/api.dockerfile new file mode 100644 index 000000000..468bd931c --- /dev/null +++ b/api.dockerfile @@ -0,0 +1,31 @@ +FROM node:15.7.0-alpine + +# --------------- +# Load env params +# --------------- +ARG ENV_ALIAS +ENV ENV_ALIAS ${ENV_ALIAS} + +# ------------------- +# Build app directory +# ------------------- +WORKDIR /app + +# Build dependencies +COPY package*.json ./ +RUN npm ci + +# Bundle app source +COPY bin/ ./bin +COPY src/ ./src +COPY LICENSE.md ./ + +# Load environment config +COPY env/${ENV_ALIAS}/config.${ENV_ALIAS}.toml ./config.toml + +# ------------- +# Start Service +# ------------- +EXPOSE 3030 + +CMD ["./bin/start-api.sh"] diff --git a/bin/start-api.sh b/bin/start-api.sh new file mode 100755 index 000000000..c1460ca18 --- /dev/null +++ b/bin/start-api.sh @@ -0,0 +1,11 @@ +#! /bin/sh + +echo "--------------------------------" +echo "ENV_ALIAS: ${ENV_ALIAS}" +echo "CONFIG_PATH: ${CONFIG_PATH}" +echo "--------------------------------" +echo "" + +echo "Starting the Atomic Agent API..." + +npm run api-service diff --git a/env/local/config.local.toml b/env/local/config.local.toml index 5fa463c24..b9e03300e 100644 --- a/env/local/config.local.toml +++ b/env/local/config.local.toml @@ -2,7 +2,7 @@ debug = false # uri = "mongodb://127.0.0.1:27017/liquality" # uri = "mongodb://docker.for.mac.host.internal:27017/liquality" -uri = "mongodb://admin:admin-password@docker.for.mac.host.internal:27017/liquality?authSource=admin" +uri = "mongodb://admin:admin-password@docker.for.mac.host.internal:27017/swapOrders?authSource=admin" [database.migrate] log = true verbose = false diff --git a/package.json b/package.json index 861bf4b42..10dc1367c 100644 --- a/package.json +++ b/package.json @@ -18,10 +18,10 @@ "migrate": "PROCESS_TYPE=migrate FORCE_MIGRATE=true node src/index.js", "api-service": "KEEP_ALIVE=true node src/index.js", "migrate-local": "CONFIG_PATH=env/local/config.local.toml PROCESS_TYPE=migrate node src/index.js", - "docker:build-local": "docker build -f service.dockerfile --build-arg ENV_ALIAS=local -t atomicagent-local . --no-cache", - "docker:run-local": "docker run --rm --name atomicagent -p 3030:3030 -d -it atomicagent-local:latest", - "docker:stop-local": "docker stop atomicagent", - "docker:log-local": "docker container logs -t atomicagent", + "docker:build-api-local": "docker build -f api.dockerfile --build-arg ENV_ALIAS=local -t atomicagent-api-local . --no-cache", + "docker:run-api-local": "docker run --rm --name atomicagent-api-local -p 3030:3030 -d -it atomicagent-api-local:latest", + "docker:stop-api-local": "docker stop atomicagent-api-local", + "docker:log-api-local": "docker container logs -t atomicagent-api-local", "docker:start-full-system": "COMPOSE_PROJECT_NAME=tester npm run docker:start && docker-compose -f env/tester/run-full-system.yml up -d --build", "docker:stop-full-system": "COMPOSE_PROJECT_NAME=tester docker stop atomicagent-full-system && COMPOSE_PROJECT_NAME=tester npm run docker:stop", "docker:log-full-system": "docker container logs -t atomicagent-full-system", diff --git a/service.dockerfile b/service.dockerfile index a6fc6301f..42c630671 100644 --- a/service.dockerfile +++ b/service.dockerfile @@ -5,8 +5,6 @@ FROM node:15.7.0-alpine # --------------- ARG ENV_ALIAS ENV ENV_ALIAS ${ENV_ALIAS} -ARG DB_PASSWORD -ENV DB_PASSWORD ${DB_PASSWORD} # ------------------- # Build app directory diff --git a/src/index.js b/src/index.js index c44ae4206..9b4406d9f 100644 --- a/src/index.js +++ b/src/index.js @@ -31,11 +31,10 @@ switch (process.env.PROCESS_TYPE) { break default: - runService() + runApiService() } -async function runService () { +async function runApiService () { await require('./migrate').run(migrateOpts) require('./api').start() - require('./worker').start() } From fff27502f2f157369e72c545eadd5690d1523f2b Mon Sep 17 00:00:00 2001 From: |M| Date: Tue, 21 Sep 2021 18:08:10 -0600 Subject: [PATCH 05/15] WIP: Using a /config directory for supporting mounted config files --- .gitignore | 3 +- api.dockerfile | 11 +- .../{config.local.toml => config.docker.toml} | 3 +- env/local/config.toml | 102 ++++++++++++++ env/personal/config.personal.toml | 131 ------------------ env/personal/run-mongodb.yml | 18 --- package.json | 4 +- src/config.js | 4 +- 8 files changed, 111 insertions(+), 165 deletions(-) rename env/local/{config.local.toml => config.docker.toml} (98%) create mode 100644 env/local/config.toml delete mode 100644 env/personal/config.personal.toml delete mode 100644 env/personal/run-mongodb.yml diff --git a/.gitignore b/.gitignore index 0bd259214..0974f1ff0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,10 +1,9 @@ # ------------------------------------------------------------------------------ # Local env and config files # ------------------------------------------------------------------------------ -*config.toml +/*config.toml !sample.config.toml !heroku.config.toml -.env.docker.local test/docker/config/* !test/docker/config/bitcoin.conf diff --git a/api.dockerfile b/api.dockerfile index 468bd931c..027932c7f 100644 --- a/api.dockerfile +++ b/api.dockerfile @@ -1,15 +1,9 @@ FROM node:15.7.0-alpine -# --------------- -# Load env params -# --------------- -ARG ENV_ALIAS -ENV ENV_ALIAS ${ENV_ALIAS} - # ------------------- # Build app directory # ------------------- -WORKDIR /app +WORKDIR / # Build dependencies COPY package*.json ./ @@ -20,9 +14,6 @@ COPY bin/ ./bin COPY src/ ./src COPY LICENSE.md ./ -# Load environment config -COPY env/${ENV_ALIAS}/config.${ENV_ALIAS}.toml ./config.toml - # ------------- # Start Service # ------------- diff --git a/env/local/config.local.toml b/env/local/config.docker.toml similarity index 98% rename from env/local/config.local.toml rename to env/local/config.docker.toml index b9e03300e..a586bdfe0 100644 --- a/env/local/config.local.toml +++ b/env/local/config.docker.toml @@ -5,8 +5,9 @@ debug = false uri = "mongodb://admin:admin-password@docker.for.mac.host.internal:27017/swapOrders?authSource=admin" [database.migrate] log = true - verbose = false + verbose = true force = true + fake = 'foshofodocker!' [application] apiPort = 3030 diff --git a/env/local/config.toml b/env/local/config.toml new file mode 100644 index 000000000..efcef6eeb --- /dev/null +++ b/env/local/config.toml @@ -0,0 +1,102 @@ +[database] +debug = false +# uri = "mongodb://127.0.0.1:27017/liquality" +# uri = "mongodb://docker.for.mac.host.internal:27017/liquality" +uri = "mongodb://admin:admin-password@localhost:27017/swapOrders?authSource=admin" + [database.migrate] + log = true + verbose = false + force = 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_regtest" + 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 = "http://localhost:3002/" # vulpemventures/electrs:latest (3rd party) + [assets.BTC.batchApi] + url = "http://localhost:9090/" # electrs-batch-server.dockerfile (inside docker dir) + [assets.BTC.rpc] + url = "http://localhost:18443/" # vulpemventures/bitcoin:latest (3rd party) + user = "admin1" + password = "123" + + [assets.ETH] + network="local" + 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 = "http://localhost:8080" # ethereum-scraper + [assets.ETH.rpc] + url = "http://localhost:8545" # Infura (3rd party) + + [assets.DAI] + network="local" + 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 = "http://localhost:8080" # ethereum-scraper + [assets.DAI.rpc] + url = "http://localhost:8545" # Infura (3rd party) + + [assets.RBTC] + blockTime = "20 seconds" + network = "rsk_testnet" + defaultFee = "average" + pegWith = "BTC" + [assets.RBTC.rpc] + url = "https://public-node.testnet.rsk.co" # RSK service (3rd party) + [assets.RBTC.scraper] + url = "https://liquality.io/rsk-testnet-api/" # ethereum-scraper + [assets.RBTC.wallet] + type = "js" + mnemonic = "piece effort bind that embrace enrich remind powder sudden patient legend group" + + [assets.SOV] + blockTime = "20 seconds" + network = "rsk_testnet" + defaultFee = "average" + contractAddress = "0x6a9A07972D07E58f0daF5122D11e069288A375fB" + [assets.SOV.rpc] + url = "https://public-node.testnet.rsk.co" # Infura (3rd party) + [assets.SOV.scraper] + url="https://liquality.io/rsk-testnet-api/" # ethereum-scraper + [assets.SOV.wallet] + type = "js" + mnemonic = "piece effort bind that embrace enrich remind powder sudden patient legend group" diff --git a/env/personal/config.personal.toml b/env/personal/config.personal.toml deleted file mode 100644 index 78dfe9a3e..000000000 --- a/env/personal/config.personal.toml +++ /dev/null @@ -1,131 +0,0 @@ -[database] -# ---------------------------------------------- Connection settings for MongoDB -# Provide either (uri will take precedence): -# -# uri - A full mongodb connection uri (see: https://docs.mongodb.com/manual/reference/connection-string/) -# e.g. -# mongodb://admin:password@127.0.0.1:27017/liquality?authSource=admin -# -# -or- -# -# host - The db hostname/IP -# port - The db port (optional) -# dbname - The db name (optional) -# username - The username for auth (optional, leave blank if no auth) -# password - The password for auth (optional, leave blank if no auth) -# authdbname - The auth db name (optional with auth, leave blank if no auth) -# ------------------------------------------------------------------------------ -# Other options: -# -# debug - true|false (Enables mongodb debug) -# -# [database.migrate] -# log - true|false (Enables migrator logging, for short messages, default: true) -# verbose - true|false (Enables verbose migrator logging, for debugging, default: false) -# force - true|false (Forces refresh of assets/markets data, default: false) -# ------------------------------------------------------------------------------ -debug = false -# uri = "mongodb://demo:demo-password@docker.for.mac.host.internal:27017/rickandmorty?authSource=test" -# uri = "mongodb://admin:admin-password@docker.for.mac.host.internal:27017/liquality?authSource=admin" -host = "10.0.1.5" -port = "27017" -dbname = "liquality" -username = "liquality" -authdbname = "admin" - [database.migrate] - log = true - verbose = false - force = false - -[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_regtest" - # 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 = "http://localhost:3002/" # vulpemventures/electrs:latest (3rd party) - # [assets.BTC.batchApi] - # url = "http://localhost:9090/" # electrs-batch-server.dockerfile (inside docker dir) - # [assets.BTC.rpc] - # url = "http://localhost:18443/" # vulpemventures/bitcoin:latest (3rd party) - # user = "admin1" - # password = "123" - - [assets.ETH] - network="local" - 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 = "http://localhost:8080" # ethereum-scraper - [assets.ETH.rpc] - url = "http://localhost:8545" # Infura (3rd party) - - # [assets.DAI] - # network="local" - # 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 = "http://localhost:8080" # ethereum-scraper - # [assets.DAI.rpc] - # url = "http://localhost:8545" # Infura (3rd party) - - # [assets.RBTC] - # blockTime = "20 seconds" - # network = "rsk_testnet" - # defaultFee = "average" - # pegWith = "BTC" - # [assets.RBTC.rpc] - # url = "https://public-node.testnet.rsk.co" # RSK service (3rd party) - # [assets.RBTC.scraper] - # url = "https://liquality.io/rsk-testnet-api/" # ethereum-scraper - # [assets.RBTC.wallet] - # type = "js" - # mnemonic = "piece effort bind that embrace enrich remind powder sudden patient legend group" - - # [assets.SOV] - # blockTime = "20 seconds" - # network = "rsk_testnet" - # defaultFee = "average" - # contractAddress = "0x6a9A07972D07E58f0daF5122D11e069288A375fB" - # [assets.SOV.rpc] - # url = "https://public-node.testnet.rsk.co" # Infura (3rd party) - # [assets.SOV.scraper] - # url="https://liquality.io/rsk-testnet-api/" # ethereum-scraper - # [assets.SOV.wallet] - # type = "js" - # mnemonic = "piece effort bind that embrace enrich remind powder sudden patient legend group" diff --git a/env/personal/run-mongodb.yml b/env/personal/run-mongodb.yml deleted file mode 100644 index dda4b3c41..000000000 --- a/env/personal/run-mongodb.yml +++ /dev/null @@ -1,18 +0,0 @@ -# Run with: docker-compose -f run-mongodb.yml up -d -# Look inside with: docker exec -it mongodb bash -version: "3.8" - -services: - mongodb: - image : mongo - container_name: mongodb - environment: - - PUID=1000 - - PGID=1000 - - MONGO_INITDB_ROOT_USERNAME=root - - MONGO_INITDB_ROOT_PASSWORD=password - volumes: - - ~/mongodb/db:/data/db - ports: - - 27017:27017 - restart: unless-stopped diff --git a/package.json b/package.json index 10dc1367c..7ddb86fa1 100644 --- a/package.json +++ b/package.json @@ -18,8 +18,8 @@ "migrate": "PROCESS_TYPE=migrate FORCE_MIGRATE=true node src/index.js", "api-service": "KEEP_ALIVE=true node src/index.js", "migrate-local": "CONFIG_PATH=env/local/config.local.toml PROCESS_TYPE=migrate node src/index.js", - "docker:build-api-local": "docker build -f api.dockerfile --build-arg ENV_ALIAS=local -t atomicagent-api-local . --no-cache", - "docker:run-api-local": "docker run --rm --name atomicagent-api-local -p 3030:3030 -d -it atomicagent-api-local:latest", + "docker:build-api-local": "docker build -f api.dockerfile -t atomicagent-api-local . --no-cache", + "docker:run-api-local": "docker run --rm --name atomicagent-api-local --env CONFIG_PATH=/config/config.docker.toml -v `pwd`/env/local:/config -p 3030:3030 -d -it atomicagent-api-local:latest", "docker:stop-api-local": "docker stop atomicagent-api-local", "docker:log-api-local": "docker container logs -t atomicagent-api-local", "docker:start-full-system": "COMPOSE_PROJECT_NAME=tester npm run docker:start && docker-compose -f env/tester/run-full-system.yml up -d --build", diff --git a/src/config.js b/src/config.js index 54422fc19..faf0e7001 100644 --- a/src/config.js +++ b/src/config.js @@ -3,7 +3,7 @@ const path = require('path') const toml = require('toml') if (!process.env.CONFIG_PATH) { - process.env.CONFIG_PATH = path.resolve(__dirname, '..', 'config.toml') + process.env.CONFIG_PATH = path.resolve(__dirname, '..', 'config/config.toml') } console.log(`Config file: ${process.env.CONFIG_PATH}`) @@ -11,4 +11,6 @@ console.log(`Config file: ${process.env.CONFIG_PATH}`) const configRaw = fs.readFileSync(process.env.CONFIG_PATH) const config = toml.parse(configRaw) +console.log('[DEVING] Loaded config:', config) + module.exports = config From 1dac97ea24f190fbc01e34e0ed9abbb830ea2a6d Mon Sep 17 00:00:00 2001 From: |M| Date: Tue, 21 Sep 2021 19:05:46 -0600 Subject: [PATCH 06/15] Added worker utility dockerization, renamed env to config --- .github/workflows/docker-push-to-personal.yml | 70 ------------ .gitignore | 1 + README.md | 10 -- bin/start-api.sh | 6 - bin/start-service.sh | 10 -- bin/start-worker.sh | 5 + {env => config}/local/run-mongodb.yml | 0 {env => config}/tester/config.tester.toml | 3 - {env => config}/tester/run-full-system.yml | 7 +- env/dev/config.dev.toml | 96 ---------------- env/local/config.docker.toml | 103 ------------------ env/local/config.toml | 102 ----------------- package.json | 10 +- service.dockerfile => worker.dockerfile | 15 +-- 14 files changed, 19 insertions(+), 419 deletions(-) delete mode 100644 .github/workflows/docker-push-to-personal.yml delete mode 100755 bin/start-service.sh create mode 100755 bin/start-worker.sh rename {env => config}/local/run-mongodb.yml (100%) rename {env => config}/tester/config.tester.toml (93%) rename {env => config}/tester/run-full-system.yml (79%) delete mode 100644 env/dev/config.dev.toml delete mode 100644 env/local/config.docker.toml delete mode 100644 env/local/config.toml rename service.dockerfile => worker.dockerfile (52%) diff --git a/.github/workflows/docker-push-to-personal.yml b/.github/workflows/docker-push-to-personal.yml deleted file mode 100644 index 9288dcf03..000000000 --- a/.github/workflows/docker-push-to-personal.yml +++ /dev/null @@ -1,70 +0,0 @@ -name: 'Docker build, tag, push to ECR (personal)' - -on: - push: - branches: - - dockerized - paths: - - 'env/personal/**' - - 'src/**' - - '.github/workflows/docker-push-to-personal.yml' - -env: - ENV_ALIAS: 'personal' - AWS_REGION: 'us-east-2' - IMAGE_NAME: 'atomicagent-personal' - IMAGE_TAG: 'latest' - DOCKERFILE_PATH: 'service.dockerfile' - -jobs: - docker-deploy: - name: 'Build & Deploy Image' - runs-on: ubuntu-latest - environment: personal - - defaults: - run: - shell: bash - - steps: - # Checkout the repository to the GitHub Actions runner - - name: Checkout - uses: actions/checkout@v2 - - # Load AWS credentials (this is the ecs-service service account) - - name: Load AWS creds - uses: aws-actions/configure-aws-credentials@v1 - with: - role-skip-session-tagging: true - aws-region: ${{ env.AWS_REGION }} - aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} - aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }} - role-duration-seconds: 1200 - - # Login to ECR - - name: Login to AWS ECR - id: login-ecr - uses: aws-actions/amazon-ecr-login@v1 - - # Build, tag, and push Docker image to ECR - - name: Build, tag, push image to ECR - id: build-image - env: - ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} - # IMAGE_TAG: ${{ github.sha }} - DB_PASSWORD: ${{ secrets.DB_PASSWORD }} - run: | - echo "Building and tagging Docker image ($IMAGE_NAME)" - docker build -f $DOCKERFILE_PATH --build-arg ENV_ALIAS=${ENV_ALIAS} --build-arg DB_PASSWORD=${DB_PASSWORD} -t $IMAGE_NAME . --no-cache - docker tag $IMAGE_NAME:$IMAGE_TAG $ECR_REGISTRY/$IMAGE_NAME:$IMAGE_TAG - echo "Pushing image to registry: $REGISTRY_URI/$IMAGE_NAME" - docker push $ECR_REGISTRY/$IMAGE_NAME:$IMAGE_TAG - - # Trigger update to ECS cluster - - name: Update ECS - id: update-ecs - run: | - echo "Assuming deployment role for ECS update" - source ./bin/aws-assume-role.sh "${AWS_REGION}" "${{ github.sha }}" "${{ secrets.AWS_ROLE_TO_ASSUME }}" - aws ecs update-service --cluster ${IMAGE_NAME} --service ${IMAGE_NAME} --force-new-deployment diff --git a/.gitignore b/.gitignore index 0974f1ff0..eaabfcaf5 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ # Local env and config files # ------------------------------------------------------------------------------ /*config.toml +/*config.docker.toml !sample.config.toml !heroku.config.toml test/docker/config/* diff --git a/README.md b/README.md index 709a9d0cc..d5b8a81f1 100644 --- a/README.md +++ b/README.md @@ -49,16 +49,6 @@ npm run api # runs agent market maker api npm run worker # runs the background process ``` -### Run as a Unified Service - -``` bash -npm run api-service -``` - -> These methods utilize the `config.toml` you created at the root of the repo. - -> For Docker options, see: [Docker Setup Variations](#docker-setup-variations) - ## Test diff --git a/bin/start-api.sh b/bin/start-api.sh index c1460ca18..aad7e450e 100755 --- a/bin/start-api.sh +++ b/bin/start-api.sh @@ -1,11 +1,5 @@ #! /bin/sh -echo "--------------------------------" -echo "ENV_ALIAS: ${ENV_ALIAS}" -echo "CONFIG_PATH: ${CONFIG_PATH}" -echo "--------------------------------" -echo "" - echo "Starting the Atomic Agent API..." npm run api-service diff --git a/bin/start-service.sh b/bin/start-service.sh deleted file mode 100755 index 2c6f4a3a8..000000000 --- a/bin/start-service.sh +++ /dev/null @@ -1,10 +0,0 @@ -#! /bin/sh - -echo "--------------------------------" -echo "ENV_ALIAS: ${ENV_ALIAS}" -echo "--------------------------------" -echo "" - -echo "Starting the Atomic Agent service..." - -npm run api-service diff --git a/bin/start-worker.sh b/bin/start-worker.sh new file mode 100755 index 000000000..e7261b835 --- /dev/null +++ b/bin/start-worker.sh @@ -0,0 +1,5 @@ +#! /bin/sh + +echo "Starting the Atomic Agent worker..." + +npm run worker-service diff --git a/env/local/run-mongodb.yml b/config/local/run-mongodb.yml similarity index 100% rename from env/local/run-mongodb.yml rename to config/local/run-mongodb.yml diff --git a/env/tester/config.tester.toml b/config/tester/config.tester.toml similarity index 93% rename from env/tester/config.tester.toml rename to config/tester/config.tester.toml index 707a2a8c7..8a47a2fe5 100644 --- a/env/tester/config.tester.toml +++ b/config/tester/config.tester.toml @@ -1,8 +1,5 @@ [database] debug = false -uri = "mongodb://localhost/liqualitytest" -# uri = "mongodb://docker.for.mac.host.internal:27017/liqualitytest" -# uri = "mongodb://admin:admin-password@docker.for.mac.host.internal:27017/liqualitytest?authSource=admin" [database.migrate] log = true verbose = false diff --git a/env/tester/run-full-system.yml b/config/tester/run-full-system.yml similarity index 79% rename from env/tester/run-full-system.yml rename to config/tester/run-full-system.yml index 5282d2546..632d28946 100644 --- a/env/tester/run-full-system.yml +++ b/config/tester/run-full-system.yml @@ -5,12 +5,13 @@ services: atomicagent-full-system: build: context: ../../ - dockerfile: service.dockerfile - args: - ENV_ALIAS: tester + dockerfile: api.dockerfile container_name: atomicagent-full-system environment: - MONGO_URI=mongodb://10.10.0.8:27017/liquality + - CONFIG_PATH=/config/config.tester.toml + volumes: + - ./config/tester:/config ports: - 3030:3030 restart: unless-stopped diff --git a/env/dev/config.dev.toml b/env/dev/config.dev.toml deleted file mode 100644 index fd0024856..000000000 --- a/env/dev/config.dev.toml +++ /dev/null @@ -1,96 +0,0 @@ -[database] -debug = true -uri = "" - -[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_regtest" - 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 = "http://localhost:3002/" # vulpemventures/electrs:latest (3rd party) - [assets.BTC.batchApi] - url = "http://localhost:9090/" # electrs-batch-server.dockerfile (inside docker dir) - [assets.BTC.rpc] - url = "http://localhost:18443/" # vulpemventures/bitcoin:latest (3rd party) - user = "admin1" - password = "123" - - [assets.ETH] - network="local" - 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 = "http://localhost:8080" # ethereum-scraper - [assets.ETH.rpc] - url = "http://localhost:8545" # Infura (3rd party) - - [assets.DAI] - network="local" - 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 = "http://localhost:8080" # ethereum-scraper - [assets.DAI.rpc] - url = "http://localhost:8545" # Infura (3rd party) - - [assets.RBTC] - blockTime = "20 seconds" - network = "rsk_testnet" - defaultFee = "average" - pegWith = "BTC" - [assets.RBTC.rpc] - url = "https://public-node.testnet.rsk.co" # RSK service (3rd party) - [assets.RBTC.scraper] - url = "https://liquality.io/rsk-testnet-api/" # ethereum-scraper - [assets.RBTC.wallet] - type = "js" - mnemonic = "piece effort bind that embrace enrich remind powder sudden patient legend group" - - [assets.SOV] - blockTime = "20 seconds" - network = "rsk_testnet" - defaultFee = "average" - contractAddress = "0x6a9A07972D07E58f0daF5122D11e069288A375fB" - [assets.SOV.rpc] - url = "https://public-node.testnet.rsk.co" # Infura (3rd party) - [assets.SOV.scraper] - url="https://liquality.io/rsk-testnet-api/" # ethereum-scraper - [assets.SOV.wallet] - type = "js" - mnemonic = "piece effort bind that embrace enrich remind powder sudden patient legend group" diff --git a/env/local/config.docker.toml b/env/local/config.docker.toml deleted file mode 100644 index a586bdfe0..000000000 --- a/env/local/config.docker.toml +++ /dev/null @@ -1,103 +0,0 @@ -[database] -debug = false -# uri = "mongodb://127.0.0.1:27017/liquality" -# uri = "mongodb://docker.for.mac.host.internal:27017/liquality" -uri = "mongodb://admin:admin-password@docker.for.mac.host.internal:27017/swapOrders?authSource=admin" - [database.migrate] - log = true - verbose = true - force = true - fake = 'foshofodocker!' - -[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_regtest" - 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 = "http://localhost:3002/" # vulpemventures/electrs:latest (3rd party) - [assets.BTC.batchApi] - url = "http://localhost:9090/" # electrs-batch-server.dockerfile (inside docker dir) - [assets.BTC.rpc] - url = "http://localhost:18443/" # vulpemventures/bitcoin:latest (3rd party) - user = "admin1" - password = "123" - - [assets.ETH] - network="local" - 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 = "http://localhost:8080" # ethereum-scraper - [assets.ETH.rpc] - url = "http://localhost:8545" # Infura (3rd party) - - [assets.DAI] - network="local" - 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 = "http://localhost:8080" # ethereum-scraper - [assets.DAI.rpc] - url = "http://localhost:8545" # Infura (3rd party) - - [assets.RBTC] - blockTime = "20 seconds" - network = "rsk_testnet" - defaultFee = "average" - pegWith = "BTC" - [assets.RBTC.rpc] - url = "https://public-node.testnet.rsk.co" # RSK service (3rd party) - [assets.RBTC.scraper] - url = "https://liquality.io/rsk-testnet-api/" # ethereum-scraper - [assets.RBTC.wallet] - type = "js" - mnemonic = "piece effort bind that embrace enrich remind powder sudden patient legend group" - - [assets.SOV] - blockTime = "20 seconds" - network = "rsk_testnet" - defaultFee = "average" - contractAddress = "0x6a9A07972D07E58f0daF5122D11e069288A375fB" - [assets.SOV.rpc] - url = "https://public-node.testnet.rsk.co" # Infura (3rd party) - [assets.SOV.scraper] - url="https://liquality.io/rsk-testnet-api/" # ethereum-scraper - [assets.SOV.wallet] - type = "js" - mnemonic = "piece effort bind that embrace enrich remind powder sudden patient legend group" diff --git a/env/local/config.toml b/env/local/config.toml deleted file mode 100644 index efcef6eeb..000000000 --- a/env/local/config.toml +++ /dev/null @@ -1,102 +0,0 @@ -[database] -debug = false -# uri = "mongodb://127.0.0.1:27017/liquality" -# uri = "mongodb://docker.for.mac.host.internal:27017/liquality" -uri = "mongodb://admin:admin-password@localhost:27017/swapOrders?authSource=admin" - [database.migrate] - log = true - verbose = false - force = 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_regtest" - 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 = "http://localhost:3002/" # vulpemventures/electrs:latest (3rd party) - [assets.BTC.batchApi] - url = "http://localhost:9090/" # electrs-batch-server.dockerfile (inside docker dir) - [assets.BTC.rpc] - url = "http://localhost:18443/" # vulpemventures/bitcoin:latest (3rd party) - user = "admin1" - password = "123" - - [assets.ETH] - network="local" - 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 = "http://localhost:8080" # ethereum-scraper - [assets.ETH.rpc] - url = "http://localhost:8545" # Infura (3rd party) - - [assets.DAI] - network="local" - 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 = "http://localhost:8080" # ethereum-scraper - [assets.DAI.rpc] - url = "http://localhost:8545" # Infura (3rd party) - - [assets.RBTC] - blockTime = "20 seconds" - network = "rsk_testnet" - defaultFee = "average" - pegWith = "BTC" - [assets.RBTC.rpc] - url = "https://public-node.testnet.rsk.co" # RSK service (3rd party) - [assets.RBTC.scraper] - url = "https://liquality.io/rsk-testnet-api/" # ethereum-scraper - [assets.RBTC.wallet] - type = "js" - mnemonic = "piece effort bind that embrace enrich remind powder sudden patient legend group" - - [assets.SOV] - blockTime = "20 seconds" - network = "rsk_testnet" - defaultFee = "average" - contractAddress = "0x6a9A07972D07E58f0daF5122D11e069288A375fB" - [assets.SOV.rpc] - url = "https://public-node.testnet.rsk.co" # Infura (3rd party) - [assets.SOV.scraper] - url="https://liquality.io/rsk-testnet-api/" # ethereum-scraper - [assets.SOV.wallet] - type = "js" - mnemonic = "piece effort bind that embrace enrich remind powder sudden patient legend group" diff --git a/package.json b/package.json index 7ddb86fa1..d9f77426a 100644 --- a/package.json +++ b/package.json @@ -17,12 +17,16 @@ "worker": "PROCESS_TYPE=worker nodemon src/index.js", "migrate": "PROCESS_TYPE=migrate FORCE_MIGRATE=true node src/index.js", "api-service": "KEEP_ALIVE=true node src/index.js", - "migrate-local": "CONFIG_PATH=env/local/config.local.toml PROCESS_TYPE=migrate node src/index.js", + "worker-service": "PROCESS_TYPE=worker node src/index.js", "docker:build-api-local": "docker build -f api.dockerfile -t atomicagent-api-local . --no-cache", - "docker:run-api-local": "docker run --rm --name atomicagent-api-local --env CONFIG_PATH=/config/config.docker.toml -v `pwd`/env/local:/config -p 3030:3030 -d -it atomicagent-api-local:latest", + "docker:run-api-local": "docker run --rm --name atomicagent-api-local --env CONFIG_PATH=/config/config.docker.toml -p 3030:3030 -d -it atomicagent-api-local:latest", "docker:stop-api-local": "docker stop atomicagent-api-local", "docker:log-api-local": "docker container logs -t atomicagent-api-local", - "docker:start-full-system": "COMPOSE_PROJECT_NAME=tester npm run docker:start && docker-compose -f env/tester/run-full-system.yml up -d --build", + "docker:build-worker-local": "docker build -f worker.dockerfile -t atomicagent-worker-local . --no-cache", + "docker:run-worker-local": "docker run --rm --name atomicagent-worker-local --env CONFIG_PATH=/config/config.docker.toml -d -it atomicagent-worker-local:latest", + "docker:stop-worker-local": "docker stop atomicagent-worker-local", + "docker:log-worker-local": "docker container logs -t atomicagent-worker-local", + "docker:start-full-system": "COMPOSE_PROJECT_NAME=tester npm run docker:start && docker-compose -f config/tester/run-full-system.yml up -d --build", "docker:stop-full-system": "COMPOSE_PROJECT_NAME=tester docker stop atomicagent-full-system && COMPOSE_PROJECT_NAME=tester npm run docker:stop", "docker:log-full-system": "docker container logs -t atomicagent-full-system", "docker:start": "docker-compose -f test/docker/docker-compose.yml up -d --force-recreate --renew-anon-volumes", diff --git a/service.dockerfile b/worker.dockerfile similarity index 52% rename from service.dockerfile rename to worker.dockerfile index 42c630671..5335dd4da 100644 --- a/service.dockerfile +++ b/worker.dockerfile @@ -1,15 +1,9 @@ FROM node:15.7.0-alpine -# --------------- -# Load env params -# --------------- -ARG ENV_ALIAS -ENV ENV_ALIAS ${ENV_ALIAS} - # ------------------- # Build app directory # ------------------- -WORKDIR /app +WORKDIR / # Build dependencies COPY package*.json ./ @@ -20,12 +14,7 @@ COPY bin/ ./bin COPY src/ ./src COPY LICENSE.md ./ -# Load environment config -COPY env/${ENV_ALIAS}/config.${ENV_ALIAS}.toml ./config.toml - # ------------- # Start Service # ------------- -EXPOSE 3030 - -CMD ["./bin/start-service.sh"] +CMD ["./bin/start-worker.sh"] From bb8292afbcc4596c986022f5ad3ce366f41e0b99 Mon Sep 17 00:00:00 2001 From: |M| Date: Wed, 22 Sep 2021 11:52:24 -0600 Subject: [PATCH 07/15] Setup worker scripts, replaced migrate logging with DEBUG --- .github/workflows/docker-deploy-to-github.yml | 61 +++++++++++++++++++ README.md | 39 +++++++----- config/tester/config.tester.toml | 4 -- package.json | 10 +-- sample.config.toml | 3 +- src/config.js | 2 - src/index.js | 5 +- src/migrate/index.js | 36 +++++------ 8 files changed, 108 insertions(+), 52 deletions(-) create mode 100644 .github/workflows/docker-deploy-to-github.yml diff --git a/.github/workflows/docker-deploy-to-github.yml b/.github/workflows/docker-deploy-to-github.yml new file mode 100644 index 000000000..985ca8ff3 --- /dev/null +++ b/.github/workflows/docker-deploy-to-github.yml @@ -0,0 +1,61 @@ +name: 'Docker deploy to GitHub' + +on: + push: + branches: + - dockerized + +env: + # GitHub settings + REGISTRY: ghcr.io/liquality + + # AWS settings + AWS_REGION: 'us-east-1' + + # atomicagent-api + AGENT_API_IMAGE_NAME: 'atomicagent-api' + AGENT_API_IMAGE_TAG: 'latest' + AGENT_API_DOCKERFILE_PATH: 'api.dockerfile' + + # atomicagent-worker + AGENT_WORKER_IMAGE_NAME: 'atomicagent-worker' + AGENT_WORKER_IMAGE_TAG: 'latest' + AGENT_WORKER_DOCKERFILE_PATH: 'worker.dockerfile' + +jobs: + build-and-push-image: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Log in to the Container registry + uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + # Build, tag, and push Docker image (agent api) + - name: Build, tag, push image to GitHub (agent api) + id: build-api-image + run: | + echo "Building and tagging Docker image ($AGENT_API_IMAGE_NAME)" + docker build -f $AGENT_API_DOCKERFILE_PATH -t $AGENT_API_IMAGE_NAME . --no-cache + docker tag $AGENT_API_IMAGE_NAME:$AGENT_API_IMAGE_TAG $REGISTRY/$AGENT_API_IMAGE_NAME:$AGENT_API_IMAGE_TAG + echo "Pushing image to registry as: $REGISTRY/$AGENT_API_IMAGE_NAME" + docker push $REGISTRY/$AGENT_API_IMAGE_NAME:$AGENT_API_IMAGE_TAG + + # Build, tag, and push Docker image (agent worker) + - name: Build, tag, push image to GitHub (agent worker) + id: build-worker-image + run: | + echo "Building and tagging Docker image ($AGENT_WORKER_IMAGE_NAME)" + docker build -f $AGENT_WORKER_DOCKERFILE_PATH -t $AGENT_WORKER_IMAGE_NAME . --no-cache + docker tag $AGENT_WORKER_IMAGE_NAME:$AGENT_WORKER_IMAGE_TAG $REGISTRY/$AGENT_WORKER_IMAGE_NAME:$AGENT_WORKER_IMAGE_TAG + echo "Pushing image to registry as: $REGISTRY/$AGENT_WORKER_IMAGE_NAME" + docker push $REGISTRY/$AGENT_WORKER_IMAGE_NAME:$AGENT_WORKER_IMAGE_TAG diff --git a/README.md b/README.md index d5b8a81f1..4fa345004 100644 --- a/README.md +++ b/README.md @@ -9,14 +9,14 @@ * [Test][section-test] * [Liquality Hosted Agents][section-liquality-hosted-agents] * [Liquality Nodes][section-liquality-nodes] -* [Docker Setup Variations][section-docker-setup-variations] +* [Run with Docker][section-run-with-docker] * [User to Agent Swap Workflow][section-swap-workflow] * [License][section-license] ## Introduction -The atomicagent service contains three utilities: `migrate`, `api`, `worker`. Each can be run separately, or as a full service. +The Atomic Agent service contains three utilities: `migrate`, `api`, `worker`. The API and worker utilities work together to provide the running service, while the migrate utility is utilized to initialize the database with market data. ## Prerequisites @@ -103,22 +103,31 @@ npm run test | Polygon Scraper | Mainnet | https://liquality.io/polygon-mainnet-api/ | -## Docker Setup Variations +## Run with Docker -The atomicagent service (which contains three utilities: migrate, api, worker) can be dockerized for portability and convenience. +The atomicagent service (which contains two utilities: api, worker) can each be dockerized for portability and convenience. -### Run the Atomic Agent Service Locally +### Run the Atomic Agent Utilities Locally -To run the service (all three utilities) as a single container locally: +To run the utilities locally as Docker containers, make a copy of the `sample.config.toml` at the root of the repo and name it: `config.docker.toml`. The Docker run commands provided will use this file for its configuration. -| Command | Description | -| --------------------- | ------------------------------------- | -| `docker:build-local` | Builds the "atomicagent-local" image. | -| `docker:run-local` | Runs the "atomicagent-local" image as a container. | -| `docker:log-local` | Prints the standard out of the running "atomicagent-local" container. | -| `docker:stop-local` | Stops the running "atomicagent-local" container. | +To run the API as a container locally: -The config file used for these commands: `env/local/config.local.toml` +| Command | Description | +| ------------------------- | ------------------------------------- | +| `docker:build-api-local` | Builds the "atomicagent-api-local" image. | +| `docker:run-api-local` | Runs the "atomicagent-api-local" image as a container. | +| `docker:log-api-local` | Prints the standard out of the running "atomicagent-api-local" container. | +| `docker:stop-api-local` | Stops the running "atomicagent-api-local" container. | + +To run the worker as a container locally: + +| Command | Description | +| ---------------------------- | ------------------------------------- | +| `docker:build-worker-local` | Builds the "atomicagent-worker-local" image. | +| `docker:run-worker-local` | Runs the "atomicagent-worker-local" image as a container. | +| `docker:log-worker-local` | Prints the standard out of the running "atomicagent-worker-local" container. | +| `docker:stop-worker-local` | Stops the running "atomicagent-worker-local" container. | > **NOTE:** This configuration requires you to have your own MongoDB running. @@ -136,7 +145,7 @@ To run the full swap system in a contained environment (for testing purposes): | `docker:log-full-system` | Prints the standard out of the running "atomicagent-full-system" container. | | `docker:stop-full-system` | Stops the running "atomicagent-full-system" container and the agent services. | -The config file used for these commands: `env/tester/config.tester.toml` +The config file is pre-configured for this scenario and is located at: `config/tester/config.tester.toml` ## User to Agent Swap Workflow @@ -156,6 +165,6 @@ The config file used for these commands: `env/tester/config.tester.toml` [section-test]: #test [section-liquality-hosted-agents]: #liquality-hosted-agents [section-liquality-nodes]: #liquality-nodes -[section-docker-setup-variations]: #docker-setup-variations +[section-run-with-docker]: #run-with-docker [section-swap-workflow]: #user-to-agent-swap-workflow [section-license]: #license diff --git a/config/tester/config.tester.toml b/config/tester/config.tester.toml index 8a47a2fe5..f2ef8eca7 100644 --- a/config/tester/config.tester.toml +++ b/config/tester/config.tester.toml @@ -1,9 +1,5 @@ [database] debug = false - [database.migrate] - log = true - verbose = false - force = true [application] apiPort = 3030 diff --git a/package.json b/package.json index d9f77426a..595366100 100644 --- a/package.json +++ b/package.json @@ -13,17 +13,17 @@ "node": ">=14.15.0" }, "scripts": { - "api": "PROCESS_TYPE=api nodemon src/index.js", - "worker": "PROCESS_TYPE=worker nodemon src/index.js", - "migrate": "PROCESS_TYPE=migrate FORCE_MIGRATE=true node src/index.js", + "api": "PROCESS_TYPE=api CONFIG_PATH=config.toml nodemon src/index.js", + "worker": "PROCESS_TYPE=worker CONFIG_PATH=config.toml nodemon src/index.js", + "migrate": "PROCESS_TYPE=migrate CONFIG_PATH=config.toml FORCE_MIGRATE=true node src/index.js", "api-service": "KEEP_ALIVE=true node src/index.js", "worker-service": "PROCESS_TYPE=worker node src/index.js", "docker:build-api-local": "docker build -f api.dockerfile -t atomicagent-api-local . --no-cache", - "docker:run-api-local": "docker run --rm --name atomicagent-api-local --env CONFIG_PATH=/config/config.docker.toml -p 3030:3030 -d -it atomicagent-api-local:latest", + "docker:run-api-local": "docker run --rm --name atomicagent-api-local --env CONFIG_PATH=/config/config.docker.toml -v `pwd`:/config -p 3030:3030 -d -it atomicagent-api-local:latest", "docker:stop-api-local": "docker stop atomicagent-api-local", "docker:log-api-local": "docker container logs -t atomicagent-api-local", "docker:build-worker-local": "docker build -f worker.dockerfile -t atomicagent-worker-local . --no-cache", - "docker:run-worker-local": "docker run --rm --name atomicagent-worker-local --env CONFIG_PATH=/config/config.docker.toml -d -it atomicagent-worker-local:latest", + "docker:run-worker-local": "docker run --rm --name atomicagent-worker-local --env CONFIG_PATH=/config/config.docker.toml -v `pwd`:/config -d -it atomicagent-worker-local:latest", "docker:stop-worker-local": "docker stop atomicagent-worker-local", "docker:log-worker-local": "docker container logs -t atomicagent-worker-local", "docker:start-full-system": "COMPOSE_PROJECT_NAME=tester npm run docker:start && docker-compose -f config/tester/run-full-system.yml up -d --build", diff --git a/sample.config.toml b/sample.config.toml index 5a464b3eb..12e4610ae 100644 --- a/sample.config.toml +++ b/sample.config.toml @@ -1,5 +1,6 @@ [database] -uri = "mongodb://localhost/liqualitytest" +# uri = "mongodb://docker.for.mac.host.internal:27017/swapOrders" +uri = "mongodb://localhost/swapOrders" debug = true [application] diff --git a/src/config.js b/src/config.js index faf0e7001..2a4387c43 100644 --- a/src/config.js +++ b/src/config.js @@ -11,6 +11,4 @@ console.log(`Config file: ${process.env.CONFIG_PATH}`) const configRaw = fs.readFileSync(process.env.CONFIG_PATH) const config = toml.parse(configRaw) -console.log('[DEVING] Loaded config:', config) - module.exports = config diff --git a/src/index.js b/src/index.js index 9b4406d9f..bf02e4a67 100644 --- a/src/index.js +++ b/src/index.js @@ -13,7 +13,6 @@ const config = require('./config') // Load db settings and establish connection const dbConfig = config.database || {} if (process.env.MONGO_URI) dbConfig.uri = process.env.MONGO_URI // override with env var -const migrateOpts = dbConfig.migrate || {} mongoConnect.connect(dbConfig) // Run service @@ -27,7 +26,7 @@ switch (process.env.PROCESS_TYPE) { break case 'migrate': - require('./migrate').run(migrateOpts) + require('./migrate').run() break default: @@ -35,6 +34,6 @@ switch (process.env.PROCESS_TYPE) { } async function runApiService () { - await require('./migrate').run(migrateOpts) + await require('./migrate').run() require('./api').start() } diff --git a/src/migrate/index.js b/src/migrate/index.js index 87c2c5e6a..6c5665dd5 100644 --- a/src/migrate/index.js +++ b/src/migrate/index.js @@ -1,52 +1,44 @@ -const objectUtils = require('lodash/object') +const DEBUG = require('debug')('worker') const Asset = require('../models/Asset') const Market = require('../models/Market') const assets = require('./data/assets.json') const markets = require('./data/markets.json') -const defaultLog = true -const defaultVerbose = false -const defaultForce = false -const logHeader = '[MIGRATE]' - -module.exports.run = async (options = {}) => { - console.log(`${logHeader} Running migrate with options:`, options) - const log = objectUtils.get(options, 'log', defaultLog) - const verbose = objectUtils.get(options, 'verbose', defaultVerbose) - const force = process.env.FORCE_MIGRATE || objectUtils.get(options, 'force', defaultForce) +module.exports.run = async () => { + const force = process.env.FORCE_MIGRATE + console.log('Running migrate as force?', !!force) const keepAlive = process.env.KEEP_ALIVE || false - console.log(`${logHeader} keep alive?`, keepAlive) + DEBUG(`keep alive? ${keepAlive}`) - if (!force && await hasData({ verbose })) { - if (log) console.log(`${logHeader} Data is already seeded.`) + if (!force && await hasData()) { + DEBUG('Data is already seeded.') } else { - if (log) console.log(`${logHeader} Seeding data...`) + DEBUG('Seeding data...') await Asset.deleteMany({}) const newAssets = await Asset.insertMany(assets, { ordered: false }) - if (log) console.log(`${logHeader} ${newAssets.length} assets have been set`) + DEBUG(`${newAssets.length} assets have been set`) await Market.deleteMany({}) const newMarkets = await Market.insertMany(markets, { ordered: false }) - if (log) console.log(`${logHeader} ${newMarkets.length} markets have been set`) + DEBUG(`${newMarkets.length} markets have been set`) } if (!keepAlive) process.exit() } -async function hasData (options = {}) { - const verbose = options.verbose +async function hasData () { let result = true - if (verbose) console.log(`${logHeader} Checking for existing assets`) + DEBUG('Checking for existing assets') const existingAssets = await Asset.find({}).exec() if (!existingAssets || existingAssets.length === 0) { - if (verbose) console.log('No assets found.') + DEBUG('No assets found.') result = false } else { - if (verbose) console.log('Existing assets:', existingAssets) + DEBUG('Existing assets found:', existingAssets) } return result From 873c658af29689124d2a78ab0d5d41be93482356 Mon Sep 17 00:00:00 2001 From: |M| Date: Wed, 22 Sep 2021 12:29:29 -0600 Subject: [PATCH 08/15] Only rebuild images on src changes, updated README --- .github/workflows/docker-deploy-to-github.yml | 3 +++ README.md | 8 +++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/.github/workflows/docker-deploy-to-github.yml b/.github/workflows/docker-deploy-to-github.yml index 985ca8ff3..fb3f865dd 100644 --- a/.github/workflows/docker-deploy-to-github.yml +++ b/.github/workflows/docker-deploy-to-github.yml @@ -4,6 +4,9 @@ on: push: branches: - dockerized + paths: + - 'src/**' + - '.github/workflows/docker-deploy-to-github.yml' env: # GitHub settings diff --git a/README.md b/README.md index 4fa345004..46851df26 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,7 @@ * [Introduction][section-introduction] * [Prerequisites][section-prerequisites] * [Installation][section-installation] +* [Usage][section-usage] * [Test][section-test] * [Liquality Hosted Agents][section-liquality-hosted-agents] * [Liquality Nodes][section-liquality-nodes] @@ -42,7 +43,11 @@ nano src/migrate/data/markets.json # add/remove markets npm run migrate # prepare agent with assets & markets ``` -### Run Each Utility Separately +## Usage + +Ensure you have configured all settings for your scenario within the `config.toml` file you created at the root of the repo. + +To run the utilities: ```bash npm run api # runs agent market maker api @@ -162,6 +167,7 @@ The config file is pre-configured for this scenario and is located at: `config/t [section-introduction]: #introduction [section-prerequisites]: #prerequisites [section-installation]: #installation +[section-usage]: #usage [section-test]: #test [section-liquality-hosted-agents]: #liquality-hosted-agents [section-liquality-nodes]: #liquality-nodes From 36597e1d11373c8907bb1a231ca3a21ad26de98a Mon Sep 17 00:00:00 2001 From: |M| Date: Wed, 22 Sep 2021 12:36:45 -0600 Subject: [PATCH 09/15] Fixed config directory ref in README --- README.md | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 46851df26..13d89c22c 100644 --- a/README.md +++ b/README.md @@ -116,6 +116,10 @@ The atomicagent service (which contains two utilities: api, worker) can each be To run the utilities locally as Docker containers, make a copy of the `sample.config.toml` at the root of the repo and name it: `config.docker.toml`. The Docker run commands provided will use this file for its configuration. +> **NOTE:** This configuration requires you to have your own MongoDB running. + +> **TIP:** You can use the `config/local/run-mongodb.yml` config to run a simple MongoDB locally. + To run the API as a container locally: | Command | Description | @@ -134,9 +138,6 @@ To run the worker as a container locally: | `docker:log-worker-local` | Prints the standard out of the running "atomicagent-worker-local" container. | | `docker:stop-worker-local` | Stops the running "atomicagent-worker-local" container. | -> **NOTE:** This configuration requires you to have your own MongoDB running. - -> **TIP:** You can use the `env/local/run-mongodb.yml` config to run a simple MongoDB locally. ### Run the Full Swap System @@ -144,11 +145,11 @@ The atomicagent service operates on multiple dependencies (for various chains/ne To run the full swap system in a contained environment (for testing purposes): -| Command | Description | -| --------------------------- | ------------------------------------- | -| `docker:start-full-system` | Builds and runs the "atomicagent-full-system" image and runs a local simulation of the supported agent services. | -| `docker:log-full-system` | Prints the standard out of the running "atomicagent-full-system" container. | -| `docker:stop-full-system` | Stops the running "atomicagent-full-system" container and the agent services. | +| Command | Description | +| ----------------------------- | ------------------------------------- | +| `docker:start-full-system` | Builds and runs the "atomicagent-full-system" image and runs a local simulation of the supported agent services. | +| `docker:log-full-system` | Prints the standard out of the running "atomicagent-full-system" container. | +| `docker:stop-full-system` | Stops the running "atomicagent-full-system" container and the agent services. | The config file is pre-configured for this scenario and is located at: `config/tester/config.tester.toml` @@ -164,6 +165,8 @@ The config file is pre-configured for this scenario and is located at: `config/t + + [section-introduction]: #introduction [section-prerequisites]: #prerequisites [section-installation]: #installation From e2f2db5fd0fee4b74595b582c5938fac855f87f1 Mon Sep 17 00:00:00 2001 From: |M| Date: Thu, 23 Sep 2021 09:03:00 -0600 Subject: [PATCH 10/15] Updated README with docker image location --- README.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/README.md b/README.md index 13d89c22c..f3148a2be 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,12 @@ The Atomic Agent service contains three utilities: `migrate`, `api`, `worker`. The API and worker utilities work together to provide the running service, while the migrate utility is utilized to initialize the database with market data. +The API and worker utilities are also distributed as Docker images: +* `atomicagent-api` +* `atomicagent-worker` + +> Found here: https://github.com/orgs/liquality/packages?repo_name=atomicagent + ## Prerequisites @@ -120,6 +126,15 @@ To run the utilities locally as Docker containers, make a copy of the `sample.co > **TIP:** You can use the `config/local/run-mongodb.yml` config to run a simple MongoDB locally. +Ensure you have configured your desired markets and assets to run. The migrate utility will run automatically when the container starts, if the database is empty. + +You can configure the markets and assets in the following files: + +``` +src/migrate/data/markets.json +src/migrate/data/assets.json +``` + To run the API as a container locally: | Command | Description | @@ -139,6 +154,10 @@ To run the worker as a container locally: | `docker:stop-worker-local` | Stops the running "atomicagent-worker-local" container. | +### Docker Image Settings + +[TBC] + ### Run the Full Swap System The atomicagent service operates on multiple dependencies (for various chains/networks), as well as requiring a MongoDB to read/write data. From 930d7975581089541c7ecb78fcf5b6838abd10d5 Mon Sep 17 00:00:00 2001 From: |M| Date: Mon, 4 Oct 2021 06:54:11 -0600 Subject: [PATCH 11/15] Setting docker image back to /app dir --- api.dockerfile | 2 +- config/tester/run-full-system.yml | 2 +- worker.dockerfile | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/api.dockerfile b/api.dockerfile index 027932c7f..de2e8c283 100644 --- a/api.dockerfile +++ b/api.dockerfile @@ -3,7 +3,7 @@ FROM node:15.7.0-alpine # ------------------- # Build app directory # ------------------- -WORKDIR / +WORKDIR /app # Build dependencies COPY package*.json ./ diff --git a/config/tester/run-full-system.yml b/config/tester/run-full-system.yml index 632d28946..5e941bc15 100644 --- a/config/tester/run-full-system.yml +++ b/config/tester/run-full-system.yml @@ -8,7 +8,7 @@ services: dockerfile: api.dockerfile container_name: atomicagent-full-system environment: - - MONGO_URI=mongodb://10.10.0.8:27017/liquality + - MONGO_URI=mongodb://10.10.0.8:27017/swapOrders - CONFIG_PATH=/config/config.tester.toml volumes: - ./config/tester:/config diff --git a/worker.dockerfile b/worker.dockerfile index 5335dd4da..0c4b8b3ba 100644 --- a/worker.dockerfile +++ b/worker.dockerfile @@ -3,7 +3,7 @@ FROM node:15.7.0-alpine # ------------------- # Build app directory # ------------------- -WORKDIR / +WORKDIR /app # Build dependencies COPY package*.json ./ From 36a9a88189cddab03d44925df540620f78a56c7e Mon Sep 17 00:00:00 2001 From: |M| Date: Mon, 4 Oct 2021 06:58:34 -0600 Subject: [PATCH 12/15] Trigger docker workflow when dockerfiles are updated --- .github/workflows/docker-deploy-to-github.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/docker-deploy-to-github.yml b/.github/workflows/docker-deploy-to-github.yml index fb3f865dd..d87d5e55c 100644 --- a/.github/workflows/docker-deploy-to-github.yml +++ b/.github/workflows/docker-deploy-to-github.yml @@ -5,6 +5,8 @@ on: branches: - dockerized paths: + - 'api.dockerfile' + - 'worker.dockerfile' - 'src/**' - '.github/workflows/docker-deploy-to-github.yml' From abe3917460389077ea67a0f071b36e040f39903f Mon Sep 17 00:00:00 2001 From: |M| Date: Fri, 10 Dec 2021 10:23:47 -0700 Subject: [PATCH 13/15] Updated assets and markets for migrate seeding (#403) --- src/migrate/data/assets.json | 72 +++- src/migrate/data/markets.json | 678 ++++++++++++++++++++++++++++++++-- 2 files changed, 716 insertions(+), 34 deletions(-) diff --git a/src/migrate/data/assets.json b/src/migrate/data/assets.json index 68f5628ca..c1b43c203 100644 --- a/src/migrate/data/assets.json +++ b/src/migrate/data/assets.json @@ -1,23 +1,75 @@ [ { - "code": "BTC", - "actualBalance": 0, - "min": 80000, - "max": 45000000, - "minConf": 1 + "min": 200000, + "max": 0, + "actualBalance": 191574040, + "minConf": 1, + "code": "BTC" }, { "code": "ETH", - "actualBalance": 0, - "min": 40000000000000000, - "max": 12000000000000000000, + "actualBalance": 34838098275881832000, + "min": 50000000000000000, "minConf": 1 }, { "code": "DAI", + "actualBalance": 1.1806732860914405e+23, + "min": 100000000000000000000, + "minConf": 1 + }, + { + "code": "USDC", + "actualBalance": 104467212573, + "min": 100000000, + "minConf": 1 + }, + { + "code": "USDT", + "actualBalance": 106768343029, + "min": 100000000, + "minConf": 1 + }, + { + "min": 200000, + "max": 0, "actualBalance": 0, - "min": 5000000000000000000, - "max": 2e+21, + "minConf": 1, + "code": "WBTC" + }, + { + "code": "UNI", + "actualBalance": 0, + "min": 25000000000000000000, "minConf": 1 + }, + { + "min": 2000000000000000, + "max": 0, + "actualBalance": 4379287433770149400, + "minConf": 5, + "code": "RBTC" + }, + { + "code": "NEAR", + "actualBalance": 1.324004967228864e+28, + "min": 2e+25, + "max": 2e+27, + "minConf": 10, + "24hrUsdLimit": 30000 + }, + { + "code": "MATIC", + "actualBalance": 1.7178199995924267e+22, + "min": 120000000000000000000, + "minConf": 5 + }, + { + "code": "LUNA", + "actualBalance": 5955469269, + "min": 5000000, + "max": 50000000000, + "minConf": 10, + "24hrUsdLimit": 200000 } ] diff --git a/src/migrate/data/markets.json b/src/migrate/data/markets.json index ea574b3d8..2f0c643f2 100644 --- a/src/migrate/data/markets.json +++ b/src/migrate/data/markets.json @@ -2,61 +2,691 @@ { "from": "BTC", "to": "ETH", - "rate": 42.63633734, - "spread": 0, + "rate": 11.34333882, "orderExpiresIn": 7200000, "status": "ACTIVE", - "max": 28163916, - "min": 80000 + "max": 292198427, + "min": 200000, + "minConf": 1 }, { "from": "ETH", "to": "BTC", - "rate": 0.02345417, - "spread": 0, + "rate": 0.08638944, "orderExpiresIn": 7200000, "status": "ACTIVE", - "max": 12000000000000000000, - "min": 40000000000000000 + "max": 21156992938423000000, + "min": 50000000000000000, + "minConf": 1 + }, + { + "from": "RBTC", + "to": "BTC", + "rate": 0.99, + "orderExpiresIn": 7200000, + "status": "ACTIVE", + "max": 1846495405048543500, + "min": 2000000000000000, + "minConf": 5 + }, + { + "from": "BTC", + "to": "RBTC", + "rate": 0.99, + "orderExpiresIn": 7200000, + "status": "ACTIVE", + "max": 420921801, + "min": 200000, + "minConf": 1 + }, + { + "from": "RBTC", + "to": "ETH", + "rate": 11.29489416, + "orderExpiresIn": 7200000, + "status": "ACTIVE", + "max": 2935307984845857000, + "min": 2000000000000000, + "minConf": 5 + }, + { + "from": "ETH", + "to": "RBTC", + "rate": 0.08678336, + "orderExpiresIn": 7200000, + "status": "ACTIVE", + "max": 48022901029759074000, + "min": 50000000000000000, + "minConf": 1 }, { "from": "DAI", "to": "BTC", - "rate": 0.00013726, - "spread": 0, + "rate": 0.00002005, "orderExpiresIn": 7200000, "status": "ACTIVE", - "max": 2e+21, - "min": 5000000000000000000 + "max": 9.114484532042356e+22, + "min": 100000000000000000000, + "minConf": 1 }, { "from": "BTC", "to": "DAI", - "rate": 7285.42544146, - "spread": 0, + "rate": 48867.38229649, + "orderExpiresIn": 7200000, + "status": "ACTIVE", + "max": 229830091, + "min": 200000, + "minConf": 1 + }, + { + "from": "ETH", + "to": "DAI", + "rate": 4265.4194003, + "orderExpiresIn": 7200000, + "status": "ACTIVE", + "max": 26342769696764460000, + "min": 50000000000000000, + "minConf": 1 + }, + { + "from": "DAI", + "to": "ETH", + "rate": 0.00022981, + "orderExpiresIn": 7200000, + "status": "ACTIVE", + "max": 1.4427097112184889e+23, + "min": 100000000000000000000, + "minConf": 1 + }, + { + "from": "USDC", + "to": "BTC", + "rate": 0.00002007, + "orderExpiresIn": 7200000, + "status": "ACTIVE", + "max": 91091995007, + "min": 100000000, + "minConf": 1 + }, + { + "from": "BTC", + "to": "USDC", + "rate": 48839.04655852, + "orderExpiresIn": 7200000, + "status": "ACTIVE", + "max": 203558927, + "min": 200000, + "minConf": 1 + }, + { + "from": "ETH", + "to": "USDC", + "rate": 4262.94609805, + "orderExpiresIn": 7200000, + "status": "ACTIVE", + "max": 23321544523335553000, + "min": 50000000000000000, + "minConf": 1 + }, + { + "from": "USDC", + "to": "ETH", + "rate": 0.00022994, + "orderExpiresIn": 7200000, + "status": "ACTIVE", + "max": 144187315639, + "min": 100000000, + "minConf": 1 + }, + { + "from": "USDT", + "to": "BTC", + "rate": 0.0000201, + "orderExpiresIn": 7200000, + "status": "ACTIVE", + "max": 90927801186, + "min": 100000000, + "minConf": 1 + }, + { + "from": "USDT", + "to": "ETH", + "rate": 0.00023035, + "orderExpiresIn": 7200000, + "status": "ACTIVE", + "max": 143927417212, + "min": 100000000, + "minConf": 1 + }, + { + "from": "ETH", + "to": "USDT", + "rate": 4255.26211434, + "orderExpiresIn": 7200000, + "status": "ACTIVE", + "max": 23877755161873930000, + "min": 50000000000000000, + "minConf": 1 + }, + { + "from": "BTC", + "to": "USDT", + "rate": 48751.01390933, + "orderExpiresIn": 7200000, + "status": "ACTIVE", + "max": 208353756, + "min": 200000, + "minConf": 1 + }, + { + "from": "BTC", + "to": "WBTC", + "rate": 0.99056402, + "orderExpiresIn": 7200000, + "status": "ACTIVE", + "min": 200000, + "max": 0, + "minConf": 1 + }, + { + "from": "WBTC", + "to": "BTC", + "rate": 0.98928201, + "orderExpiresIn": 7200000, + "status": "ACTIVE", + "min": 200000, + "max": 184754738, + "minConf": 1 + }, + { + "from": "WBTC", + "to": "ETH", + "rate": 11.33690778, + "orderExpiresIn": 7200000, + "status": "ACTIVE", + "max": 292443815, + "min": 200000, + "minConf": 1 + }, + { + "from": "ETH", + "to": "WBTC", + "rate": 0.08646199, + "orderExpiresIn": 7200000, + "status": "ACTIVE", + "max": 0, + "min": 50000000000000000, + "minConf": 1 + }, + { + "from": "DAI", + "to": "WBTC", + "rate": 0.00002007, + "orderExpiresIn": 7200000, + "status": "ACTIVE", + "max": 0, + "min": 100000000000000000000, + "minConf": 1 + }, + { + "from": "USDC", + "to": "WBTC", + "rate": 0.00002008, + "orderExpiresIn": 7200000, + "status": "ACTIVE", + "max": 0, + "min": 100000000, + "minConf": 1 + }, + { + "from": "USDT", + "to": "WBTC", + "rate": 0.00002012, + "orderExpiresIn": 7200000, + "status": "ACTIVE", + "max": 0, + "min": 100000000, + "minConf": 1 + }, + { + "from": "WBTC", + "to": "DAI", + "rate": 48839.55745248, + "orderExpiresIn": 7200000, + "status": "ACTIVE", + "max": 230059348, + "min": 200000, + "minConf": 1 + }, + { + "from": "WBTC", + "to": "USDC", + "rate": 48811.23784874, + "orderExpiresIn": 7200000, + "status": "ACTIVE", + "max": 203660352, + "min": 200000, + "minConf": 1 + }, + { + "from": "WBTC", + "to": "USDT", + "rate": 48723.2553249, + "orderExpiresIn": 7200000, + "status": "ACTIVE", + "max": 208561073, + "min": 200000, + "minConf": 1 + }, + { + "from": "UNI", + "to": "BTC", + "rate": 0.00034482, + "orderExpiresIn": 7200000, + "status": "ACTIVE", + "minConf": 1, + "max": 5.300724550111067e+21, + "min": 25000000000000000000 + }, + { + "from": "UNI", + "to": "ETH", + "rate": 0.00395148, + "orderExpiresIn": 7200000, + "status": "ACTIVE", + "minConf": 1, + "max": 8.390388680808333e+21, + "min": 25000000000000000000 + }, + { + "from": "UNI", + "to": "DAI", + "rate": 17.02284207, + "orderExpiresIn": 7200000, + "status": "ACTIVE", + "minConf": 1, + "max": 6.599800896817536e+21, + "min": 25000000000000000000 + }, + { + "from": "UNI", + "to": "USDC", + "rate": 17.01297138, + "orderExpiresIn": 7200000, + "status": "ACTIVE", + "minConf": 1, + "max": 5.842960737644375e+21, + "min": 25000000000000000000 + }, + { + "from": "UNI", + "to": "USDT", + "rate": 16.9823054, + "orderExpiresIn": 7200000, + "status": "ACTIVE", + "minConf": 1, + "max": 5.982448979530202e+21, + "min": 25000000000000000000 + }, + { + "from": "UNI", + "to": "WBTC", + "rate": 0.00034506, "orderExpiresIn": 7200000, "status": "ACTIVE", - "max": 27452000, - "min": 80000 + "minConf": 1, + "max": 0, + "min": 25000000000000000000 + }, + { + "from": "BTC", + "to": "UNI", + "rate": 2841.98774081, + "orderExpiresIn": 7200000, + "status": "ACTIVE", + "minConf": 1, + "max": 0, + "min": 200000 }, { "from": "ETH", + "to": "UNI", + "rate": 248.06464098, + "orderExpiresIn": 7200000, + "status": "ACTIVE", + "minConf": 1, + "max": 0, + "min": 50000000000000000 + }, + { + "from": "DAI", + "to": "UNI", + "rate": 0.05757558, + "orderExpiresIn": 7200000, + "status": "ACTIVE", + "minConf": 1, + "max": 0, + "min": 100000000000000000000 + }, + { + "from": "USDC", + "to": "UNI", + "rate": 0.05760898, + "orderExpiresIn": 7200000, + "status": "ACTIVE", + "minConf": 1, + "max": 0, + "min": 100000000 + }, + { + "from": "USDT", + "to": "UNI", + "rate": 0.05771301, + "orderExpiresIn": 7200000, + "status": "ACTIVE", + "minConf": 1, + "max": 0, + "min": 100000000 + }, + { + "from": "WBTC", + "to": "UNI", + "rate": 2840.36952715, + "orderExpiresIn": 7200000, + "status": "ACTIVE", + "minConf": 1, + "max": 0, + "min": 200000 + }, + { + "from": "RBTC", "to": "DAI", - "rate": 170.87362322, - "spread": 0, + "rate": 48658.6959664, "orderExpiresIn": 7200000, "status": "ACTIVE", - "max": 11704560000000000000, - "min": 40000000000000000 + "max": 2308617473969088500, + "min": 2000000000000000, + "minConf": 5 }, { "from": "DAI", + "to": "RBTC", + "rate": 0.00002014, + "orderExpiresIn": 7200000, + "status": "ACTIVE", + "max": 2.0688389882456096e+23, + "min": 100000000000000000000, + "minConf": 1 + }, + { + "from": "UNI", + "to": "RBTC", + "rate": 0.00034634, + "orderExpiresIn": 7200000, + "status": "ACTIVE", + "minConf": 1, + "max": 1.2276189214622561e+22, + "min": 25000000000000000000 + }, + { + "from": "NEAR", + "to": "BTC", + "rate": 0.00018429, + "orderExpiresIn": 7200000, + "status": "ACTIVE", + "min": 2e+25, + "max": 9.912817854062707e+27, + "minConf": 10 + }, + { + "from": "NEAR", + "to": "WBTC", + "rate": 0.00018452, + "orderExpiresIn": 7200000, + "status": "ACTIVE", + "min": 2e+25, + "max": 0, + "minConf": 10 + }, + { + "from": "NEAR", + "to": "RBTC", + "rate": 0.0001852, + "orderExpiresIn": 7200000, + "status": "ACTIVE", + "min": 2e+25, + "max": 2.250047601459559e+28, + "minConf": 10 + }, + { + "from": "NEAR", "to": "ETH", - "rate": 0.00585228, - "spread": 0, + "rate": 0.00211233, + "orderExpiresIn": 7200000, + "status": "ACTIVE", + "min": 2e+25, + "max": 1.5690759618259246e+28, + "minConf": 10 + }, + { + "from": "NEAR", + "to": "DAI", + "rate": 9.10269897, + "orderExpiresIn": 7200000, + "status": "ACTIVE", + "min": 2e+25, + "max": 1.234220373098393e+28, + "minConf": 10 + }, + { + "from": "NEAR", + "to": "USDT", + "rate": 9.08102262, + "orderExpiresIn": 7200000, + "status": "ACTIVE", + "min": 2e+25, + "max": 1.1187702165748382e+28, + "minConf": 10 + }, + { + "from": "NEAR", + "to": "USDC", + "rate": 9.09742077, + "orderExpiresIn": 7200000, + "status": "ACTIVE", + "min": 2e+25, + "max": 1.0926847495061596e+28, + "minConf": 10 + }, + { + "from": "BTC", + "to": "NEAR", + "rate": 5314.76528384, + "orderExpiresIn": 7200000, + "status": "ACTIVE", + "min": 200000, + "max": 36858000, + "minConf": 1 + }, + { + "from": "WBTC", + "to": "NEAR", + "rate": 5311.73908297, + "orderExpiresIn": 7200000, + "status": "ACTIVE", + "min": 200000, + "max": 36904000, + "minConf": 1 + }, + { + "from": "RBTC", + "to": "NEAR", + "rate": 5292.06877729, + "orderExpiresIn": 7200000, + "status": "ACTIVE", + "min": 2000000000000000, + "max": 370400000000000000, + "minConf": 5 + }, + { + "from": "ETH", + "to": "NEAR", + "rate": 463.90254367, + "orderExpiresIn": 7200000, + "status": "ACTIVE", + "max": 4224660000000000000, + "min": 50000000000000000, + "minConf": 1 + }, + { + "from": "DAI", + "to": "NEAR", + "rate": 0.10767136, + "orderExpiresIn": 7200000, + "status": "ACTIVE", + "max": 1.820539794e+22, + "min": 100000000000000000000, + "minConf": 1 + }, + { + "from": "USDT", + "to": "NEAR", + "rate": 0.10792837, + "orderExpiresIn": 7200000, + "status": "ACTIVE", + "max": 18162045240, + "min": 100000000, + "minConf": 1 + }, + { + "from": "USDC", + "to": "NEAR", + "rate": 0.10773383, + "orderExpiresIn": 7200000, + "status": "ACTIVE", + "max": 18194841540, + "min": 100000000, + "minConf": 1 + }, + { + "from": "MATIC", + "to": "BTC", + "rate": 0.00004433, + "orderExpiresIn": 7200000, + "status": "ACTIVE", + "minConf": 5, + "max": 4.127336888330097e+22, + "min": 120000000000000000000 + }, + { + "from": "MATIC", + "to": "DAI", + "rate": 2.18623774, + "orderExpiresIn": 7200000, + "status": "ACTIVE", + "minConf": 5, + "max": 5.138844942885938e+22, + "min": 120000000000000000000 + }, + { + "from": "MATIC", + "to": "USDC", + "rate": 2.18497005, + "orderExpiresIn": 7200000, + "status": "ACTIVE", + "minConf": 5, + "max": 4.549542036330239e+22, + "min": 120000000000000000000 + }, + { + "from": "MATIC", + "to": "USDT", + "rate": 2.18103163, + "orderExpiresIn": 7200000, + "status": "ACTIVE", + "minConf": 5, + "max": 4.658152501406346e+22, + "min": 120000000000000000000 + }, + { + "from": "MATIC", + "to": "RBTC", + "rate": 0.00004448, + "orderExpiresIn": 7200000, + "status": "ACTIVE", + "minConf": 5, + "max": 9.368380013354362e+22, + "min": 120000000000000000000 + }, + { + "from": "MATIC", + "to": "ETH", + "rate": 0.00050819, + "orderExpiresIn": 7200000, + "status": "ACTIVE", + "minConf": 5, + "max": 6.533061731939679e+22, + "min": 120000000000000000000 + }, + { + "from": "BTC", + "to": "MATIC", + "rate": 22128.75, + "orderExpiresIn": 7200000, + "status": "ACTIVE", + "minConf": 1, + "max": 73932971, + "min": 200000 + }, + { + "from": "DAI", + "to": "MATIC", + "rate": 0.4483044, + "orderExpiresIn": 7200000, + "status": "ACTIVE", + "minConf": 1, + "max": 3.646177586054124e+22, + "min": 100000000000000000000 + }, + { + "from": "USDC", + "to": "MATIC", + "rate": 0.4485645, + "orderExpiresIn": 7200000, + "status": "ACTIVE", + "minConf": 1, + "max": 36440633499, + "min": 100000000 + }, + { + "from": "USDT", + "to": "MATIC", + "rate": 0.4493745, + "orderExpiresIn": 7200000, + "status": "ACTIVE", + "minConf": 1, + "max": 36374949065, + "min": 100000000 + }, + { + "from": "RBTC", + "to": "MATIC", + "rate": 22034.25, + "orderExpiresIn": 7200000, + "status": "ACTIVE", + "minConf": 5, + "max": 741831393998749000, + "min": 2000000000000000 + }, + { + "from": "ETH", + "to": "MATIC", + "rate": 1931.5215, "orderExpiresIn": 7200000, "status": "ACTIVE", - "max": 2e+21, - "min": 5000000000000000000 + "minConf": 1, + "max": 8475523743620150000, + "min": 50000000000000000 } ] From f4c4b45e0bd2aa8725b12af0c8b48d5d530db969 Mon Sep 17 00:00:00 2001 From: |M| Date: Fri, 10 Dec 2021 10:56:20 -0700 Subject: [PATCH 14/15] Reverting assets and markets to validate test --- src/migrate/data/assets.json | 72 +--- src/migrate/data/markets.json | 678 ++-------------------------------- 2 files changed, 34 insertions(+), 716 deletions(-) diff --git a/src/migrate/data/assets.json b/src/migrate/data/assets.json index c1b43c203..68f5628ca 100644 --- a/src/migrate/data/assets.json +++ b/src/migrate/data/assets.json @@ -1,75 +1,23 @@ [ { - "min": 200000, - "max": 0, - "actualBalance": 191574040, - "minConf": 1, - "code": "BTC" + "code": "BTC", + "actualBalance": 0, + "min": 80000, + "max": 45000000, + "minConf": 1 }, { "code": "ETH", - "actualBalance": 34838098275881832000, - "min": 50000000000000000, + "actualBalance": 0, + "min": 40000000000000000, + "max": 12000000000000000000, "minConf": 1 }, { "code": "DAI", - "actualBalance": 1.1806732860914405e+23, - "min": 100000000000000000000, - "minConf": 1 - }, - { - "code": "USDC", - "actualBalance": 104467212573, - "min": 100000000, - "minConf": 1 - }, - { - "code": "USDT", - "actualBalance": 106768343029, - "min": 100000000, - "minConf": 1 - }, - { - "min": 200000, - "max": 0, "actualBalance": 0, - "minConf": 1, - "code": "WBTC" - }, - { - "code": "UNI", - "actualBalance": 0, - "min": 25000000000000000000, + "min": 5000000000000000000, + "max": 2e+21, "minConf": 1 - }, - { - "min": 2000000000000000, - "max": 0, - "actualBalance": 4379287433770149400, - "minConf": 5, - "code": "RBTC" - }, - { - "code": "NEAR", - "actualBalance": 1.324004967228864e+28, - "min": 2e+25, - "max": 2e+27, - "minConf": 10, - "24hrUsdLimit": 30000 - }, - { - "code": "MATIC", - "actualBalance": 1.7178199995924267e+22, - "min": 120000000000000000000, - "minConf": 5 - }, - { - "code": "LUNA", - "actualBalance": 5955469269, - "min": 5000000, - "max": 50000000000, - "minConf": 10, - "24hrUsdLimit": 200000 } ] diff --git a/src/migrate/data/markets.json b/src/migrate/data/markets.json index 2f0c643f2..ea574b3d8 100644 --- a/src/migrate/data/markets.json +++ b/src/migrate/data/markets.json @@ -2,691 +2,61 @@ { "from": "BTC", "to": "ETH", - "rate": 11.34333882, + "rate": 42.63633734, + "spread": 0, "orderExpiresIn": 7200000, "status": "ACTIVE", - "max": 292198427, - "min": 200000, - "minConf": 1 + "max": 28163916, + "min": 80000 }, { "from": "ETH", "to": "BTC", - "rate": 0.08638944, + "rate": 0.02345417, + "spread": 0, "orderExpiresIn": 7200000, "status": "ACTIVE", - "max": 21156992938423000000, - "min": 50000000000000000, - "minConf": 1 - }, - { - "from": "RBTC", - "to": "BTC", - "rate": 0.99, - "orderExpiresIn": 7200000, - "status": "ACTIVE", - "max": 1846495405048543500, - "min": 2000000000000000, - "minConf": 5 - }, - { - "from": "BTC", - "to": "RBTC", - "rate": 0.99, - "orderExpiresIn": 7200000, - "status": "ACTIVE", - "max": 420921801, - "min": 200000, - "minConf": 1 - }, - { - "from": "RBTC", - "to": "ETH", - "rate": 11.29489416, - "orderExpiresIn": 7200000, - "status": "ACTIVE", - "max": 2935307984845857000, - "min": 2000000000000000, - "minConf": 5 - }, - { - "from": "ETH", - "to": "RBTC", - "rate": 0.08678336, - "orderExpiresIn": 7200000, - "status": "ACTIVE", - "max": 48022901029759074000, - "min": 50000000000000000, - "minConf": 1 + "max": 12000000000000000000, + "min": 40000000000000000 }, { "from": "DAI", "to": "BTC", - "rate": 0.00002005, + "rate": 0.00013726, + "spread": 0, "orderExpiresIn": 7200000, "status": "ACTIVE", - "max": 9.114484532042356e+22, - "min": 100000000000000000000, - "minConf": 1 + "max": 2e+21, + "min": 5000000000000000000 }, { "from": "BTC", "to": "DAI", - "rate": 48867.38229649, - "orderExpiresIn": 7200000, - "status": "ACTIVE", - "max": 229830091, - "min": 200000, - "minConf": 1 - }, - { - "from": "ETH", - "to": "DAI", - "rate": 4265.4194003, - "orderExpiresIn": 7200000, - "status": "ACTIVE", - "max": 26342769696764460000, - "min": 50000000000000000, - "minConf": 1 - }, - { - "from": "DAI", - "to": "ETH", - "rate": 0.00022981, - "orderExpiresIn": 7200000, - "status": "ACTIVE", - "max": 1.4427097112184889e+23, - "min": 100000000000000000000, - "minConf": 1 - }, - { - "from": "USDC", - "to": "BTC", - "rate": 0.00002007, - "orderExpiresIn": 7200000, - "status": "ACTIVE", - "max": 91091995007, - "min": 100000000, - "minConf": 1 - }, - { - "from": "BTC", - "to": "USDC", - "rate": 48839.04655852, - "orderExpiresIn": 7200000, - "status": "ACTIVE", - "max": 203558927, - "min": 200000, - "minConf": 1 - }, - { - "from": "ETH", - "to": "USDC", - "rate": 4262.94609805, - "orderExpiresIn": 7200000, - "status": "ACTIVE", - "max": 23321544523335553000, - "min": 50000000000000000, - "minConf": 1 - }, - { - "from": "USDC", - "to": "ETH", - "rate": 0.00022994, - "orderExpiresIn": 7200000, - "status": "ACTIVE", - "max": 144187315639, - "min": 100000000, - "minConf": 1 - }, - { - "from": "USDT", - "to": "BTC", - "rate": 0.0000201, - "orderExpiresIn": 7200000, - "status": "ACTIVE", - "max": 90927801186, - "min": 100000000, - "minConf": 1 - }, - { - "from": "USDT", - "to": "ETH", - "rate": 0.00023035, - "orderExpiresIn": 7200000, - "status": "ACTIVE", - "max": 143927417212, - "min": 100000000, - "minConf": 1 - }, - { - "from": "ETH", - "to": "USDT", - "rate": 4255.26211434, - "orderExpiresIn": 7200000, - "status": "ACTIVE", - "max": 23877755161873930000, - "min": 50000000000000000, - "minConf": 1 - }, - { - "from": "BTC", - "to": "USDT", - "rate": 48751.01390933, - "orderExpiresIn": 7200000, - "status": "ACTIVE", - "max": 208353756, - "min": 200000, - "minConf": 1 - }, - { - "from": "BTC", - "to": "WBTC", - "rate": 0.99056402, - "orderExpiresIn": 7200000, - "status": "ACTIVE", - "min": 200000, - "max": 0, - "minConf": 1 - }, - { - "from": "WBTC", - "to": "BTC", - "rate": 0.98928201, - "orderExpiresIn": 7200000, - "status": "ACTIVE", - "min": 200000, - "max": 184754738, - "minConf": 1 - }, - { - "from": "WBTC", - "to": "ETH", - "rate": 11.33690778, - "orderExpiresIn": 7200000, - "status": "ACTIVE", - "max": 292443815, - "min": 200000, - "minConf": 1 - }, - { - "from": "ETH", - "to": "WBTC", - "rate": 0.08646199, - "orderExpiresIn": 7200000, - "status": "ACTIVE", - "max": 0, - "min": 50000000000000000, - "minConf": 1 - }, - { - "from": "DAI", - "to": "WBTC", - "rate": 0.00002007, - "orderExpiresIn": 7200000, - "status": "ACTIVE", - "max": 0, - "min": 100000000000000000000, - "minConf": 1 - }, - { - "from": "USDC", - "to": "WBTC", - "rate": 0.00002008, - "orderExpiresIn": 7200000, - "status": "ACTIVE", - "max": 0, - "min": 100000000, - "minConf": 1 - }, - { - "from": "USDT", - "to": "WBTC", - "rate": 0.00002012, - "orderExpiresIn": 7200000, - "status": "ACTIVE", - "max": 0, - "min": 100000000, - "minConf": 1 - }, - { - "from": "WBTC", - "to": "DAI", - "rate": 48839.55745248, - "orderExpiresIn": 7200000, - "status": "ACTIVE", - "max": 230059348, - "min": 200000, - "minConf": 1 - }, - { - "from": "WBTC", - "to": "USDC", - "rate": 48811.23784874, - "orderExpiresIn": 7200000, - "status": "ACTIVE", - "max": 203660352, - "min": 200000, - "minConf": 1 - }, - { - "from": "WBTC", - "to": "USDT", - "rate": 48723.2553249, - "orderExpiresIn": 7200000, - "status": "ACTIVE", - "max": 208561073, - "min": 200000, - "minConf": 1 - }, - { - "from": "UNI", - "to": "BTC", - "rate": 0.00034482, - "orderExpiresIn": 7200000, - "status": "ACTIVE", - "minConf": 1, - "max": 5.300724550111067e+21, - "min": 25000000000000000000 - }, - { - "from": "UNI", - "to": "ETH", - "rate": 0.00395148, - "orderExpiresIn": 7200000, - "status": "ACTIVE", - "minConf": 1, - "max": 8.390388680808333e+21, - "min": 25000000000000000000 - }, - { - "from": "UNI", - "to": "DAI", - "rate": 17.02284207, - "orderExpiresIn": 7200000, - "status": "ACTIVE", - "minConf": 1, - "max": 6.599800896817536e+21, - "min": 25000000000000000000 - }, - { - "from": "UNI", - "to": "USDC", - "rate": 17.01297138, - "orderExpiresIn": 7200000, - "status": "ACTIVE", - "minConf": 1, - "max": 5.842960737644375e+21, - "min": 25000000000000000000 - }, - { - "from": "UNI", - "to": "USDT", - "rate": 16.9823054, - "orderExpiresIn": 7200000, - "status": "ACTIVE", - "minConf": 1, - "max": 5.982448979530202e+21, - "min": 25000000000000000000 - }, - { - "from": "UNI", - "to": "WBTC", - "rate": 0.00034506, + "rate": 7285.42544146, + "spread": 0, "orderExpiresIn": 7200000, "status": "ACTIVE", - "minConf": 1, - "max": 0, - "min": 25000000000000000000 - }, - { - "from": "BTC", - "to": "UNI", - "rate": 2841.98774081, - "orderExpiresIn": 7200000, - "status": "ACTIVE", - "minConf": 1, - "max": 0, - "min": 200000 + "max": 27452000, + "min": 80000 }, { "from": "ETH", - "to": "UNI", - "rate": 248.06464098, - "orderExpiresIn": 7200000, - "status": "ACTIVE", - "minConf": 1, - "max": 0, - "min": 50000000000000000 - }, - { - "from": "DAI", - "to": "UNI", - "rate": 0.05757558, - "orderExpiresIn": 7200000, - "status": "ACTIVE", - "minConf": 1, - "max": 0, - "min": 100000000000000000000 - }, - { - "from": "USDC", - "to": "UNI", - "rate": 0.05760898, - "orderExpiresIn": 7200000, - "status": "ACTIVE", - "minConf": 1, - "max": 0, - "min": 100000000 - }, - { - "from": "USDT", - "to": "UNI", - "rate": 0.05771301, - "orderExpiresIn": 7200000, - "status": "ACTIVE", - "minConf": 1, - "max": 0, - "min": 100000000 - }, - { - "from": "WBTC", - "to": "UNI", - "rate": 2840.36952715, - "orderExpiresIn": 7200000, - "status": "ACTIVE", - "minConf": 1, - "max": 0, - "min": 200000 - }, - { - "from": "RBTC", "to": "DAI", - "rate": 48658.6959664, + "rate": 170.87362322, + "spread": 0, "orderExpiresIn": 7200000, "status": "ACTIVE", - "max": 2308617473969088500, - "min": 2000000000000000, - "minConf": 5 + "max": 11704560000000000000, + "min": 40000000000000000 }, { "from": "DAI", - "to": "RBTC", - "rate": 0.00002014, - "orderExpiresIn": 7200000, - "status": "ACTIVE", - "max": 2.0688389882456096e+23, - "min": 100000000000000000000, - "minConf": 1 - }, - { - "from": "UNI", - "to": "RBTC", - "rate": 0.00034634, - "orderExpiresIn": 7200000, - "status": "ACTIVE", - "minConf": 1, - "max": 1.2276189214622561e+22, - "min": 25000000000000000000 - }, - { - "from": "NEAR", - "to": "BTC", - "rate": 0.00018429, - "orderExpiresIn": 7200000, - "status": "ACTIVE", - "min": 2e+25, - "max": 9.912817854062707e+27, - "minConf": 10 - }, - { - "from": "NEAR", - "to": "WBTC", - "rate": 0.00018452, - "orderExpiresIn": 7200000, - "status": "ACTIVE", - "min": 2e+25, - "max": 0, - "minConf": 10 - }, - { - "from": "NEAR", - "to": "RBTC", - "rate": 0.0001852, - "orderExpiresIn": 7200000, - "status": "ACTIVE", - "min": 2e+25, - "max": 2.250047601459559e+28, - "minConf": 10 - }, - { - "from": "NEAR", "to": "ETH", - "rate": 0.00211233, - "orderExpiresIn": 7200000, - "status": "ACTIVE", - "min": 2e+25, - "max": 1.5690759618259246e+28, - "minConf": 10 - }, - { - "from": "NEAR", - "to": "DAI", - "rate": 9.10269897, - "orderExpiresIn": 7200000, - "status": "ACTIVE", - "min": 2e+25, - "max": 1.234220373098393e+28, - "minConf": 10 - }, - { - "from": "NEAR", - "to": "USDT", - "rate": 9.08102262, - "orderExpiresIn": 7200000, - "status": "ACTIVE", - "min": 2e+25, - "max": 1.1187702165748382e+28, - "minConf": 10 - }, - { - "from": "NEAR", - "to": "USDC", - "rate": 9.09742077, - "orderExpiresIn": 7200000, - "status": "ACTIVE", - "min": 2e+25, - "max": 1.0926847495061596e+28, - "minConf": 10 - }, - { - "from": "BTC", - "to": "NEAR", - "rate": 5314.76528384, - "orderExpiresIn": 7200000, - "status": "ACTIVE", - "min": 200000, - "max": 36858000, - "minConf": 1 - }, - { - "from": "WBTC", - "to": "NEAR", - "rate": 5311.73908297, - "orderExpiresIn": 7200000, - "status": "ACTIVE", - "min": 200000, - "max": 36904000, - "minConf": 1 - }, - { - "from": "RBTC", - "to": "NEAR", - "rate": 5292.06877729, - "orderExpiresIn": 7200000, - "status": "ACTIVE", - "min": 2000000000000000, - "max": 370400000000000000, - "minConf": 5 - }, - { - "from": "ETH", - "to": "NEAR", - "rate": 463.90254367, - "orderExpiresIn": 7200000, - "status": "ACTIVE", - "max": 4224660000000000000, - "min": 50000000000000000, - "minConf": 1 - }, - { - "from": "DAI", - "to": "NEAR", - "rate": 0.10767136, - "orderExpiresIn": 7200000, - "status": "ACTIVE", - "max": 1.820539794e+22, - "min": 100000000000000000000, - "minConf": 1 - }, - { - "from": "USDT", - "to": "NEAR", - "rate": 0.10792837, - "orderExpiresIn": 7200000, - "status": "ACTIVE", - "max": 18162045240, - "min": 100000000, - "minConf": 1 - }, - { - "from": "USDC", - "to": "NEAR", - "rate": 0.10773383, - "orderExpiresIn": 7200000, - "status": "ACTIVE", - "max": 18194841540, - "min": 100000000, - "minConf": 1 - }, - { - "from": "MATIC", - "to": "BTC", - "rate": 0.00004433, - "orderExpiresIn": 7200000, - "status": "ACTIVE", - "minConf": 5, - "max": 4.127336888330097e+22, - "min": 120000000000000000000 - }, - { - "from": "MATIC", - "to": "DAI", - "rate": 2.18623774, - "orderExpiresIn": 7200000, - "status": "ACTIVE", - "minConf": 5, - "max": 5.138844942885938e+22, - "min": 120000000000000000000 - }, - { - "from": "MATIC", - "to": "USDC", - "rate": 2.18497005, - "orderExpiresIn": 7200000, - "status": "ACTIVE", - "minConf": 5, - "max": 4.549542036330239e+22, - "min": 120000000000000000000 - }, - { - "from": "MATIC", - "to": "USDT", - "rate": 2.18103163, - "orderExpiresIn": 7200000, - "status": "ACTIVE", - "minConf": 5, - "max": 4.658152501406346e+22, - "min": 120000000000000000000 - }, - { - "from": "MATIC", - "to": "RBTC", - "rate": 0.00004448, - "orderExpiresIn": 7200000, - "status": "ACTIVE", - "minConf": 5, - "max": 9.368380013354362e+22, - "min": 120000000000000000000 - }, - { - "from": "MATIC", - "to": "ETH", - "rate": 0.00050819, - "orderExpiresIn": 7200000, - "status": "ACTIVE", - "minConf": 5, - "max": 6.533061731939679e+22, - "min": 120000000000000000000 - }, - { - "from": "BTC", - "to": "MATIC", - "rate": 22128.75, - "orderExpiresIn": 7200000, - "status": "ACTIVE", - "minConf": 1, - "max": 73932971, - "min": 200000 - }, - { - "from": "DAI", - "to": "MATIC", - "rate": 0.4483044, - "orderExpiresIn": 7200000, - "status": "ACTIVE", - "minConf": 1, - "max": 3.646177586054124e+22, - "min": 100000000000000000000 - }, - { - "from": "USDC", - "to": "MATIC", - "rate": 0.4485645, - "orderExpiresIn": 7200000, - "status": "ACTIVE", - "minConf": 1, - "max": 36440633499, - "min": 100000000 - }, - { - "from": "USDT", - "to": "MATIC", - "rate": 0.4493745, - "orderExpiresIn": 7200000, - "status": "ACTIVE", - "minConf": 1, - "max": 36374949065, - "min": 100000000 - }, - { - "from": "RBTC", - "to": "MATIC", - "rate": 22034.25, - "orderExpiresIn": 7200000, - "status": "ACTIVE", - "minConf": 5, - "max": 741831393998749000, - "min": 2000000000000000 - }, - { - "from": "ETH", - "to": "MATIC", - "rate": 1931.5215, + "rate": 0.00585228, + "spread": 0, "orderExpiresIn": 7200000, "status": "ACTIVE", - "minConf": 1, - "max": 8475523743620150000, - "min": 50000000000000000 + "max": 2e+21, + "min": 5000000000000000000 } ] From 3547933ac095fc221314afef7a39d767f657cb49 Mon Sep 17 00:00:00 2001 From: |M| Date: Wed, 15 Dec 2021 07:53:48 -0700 Subject: [PATCH 15/15] Updated asset support: BTC,ETH,DAI,USDC,WBTC,UNI,RBTC,MATIC --- src/migrate/data/assets.json | 65 +++- src/migrate/data/markets.json | 540 ++++++++++++++++++++++++++++++++-- 2 files changed, 570 insertions(+), 35 deletions(-) diff --git a/src/migrate/data/assets.json b/src/migrate/data/assets.json index 68f5628ca..12465cad6 100644 --- a/src/migrate/data/assets.json +++ b/src/migrate/data/assets.json @@ -1,23 +1,66 @@ [ { "code": "BTC", - "actualBalance": 0, - "min": 80000, - "max": 45000000, - "minConf": 1 + "min": 200000, + "max": 0, + "actualBalance": 247886556, + "minConf": 1, + "updatedAt": "2021-12-14T14:06:22.182Z" }, { "code": "ETH", - "actualBalance": 0, - "min": 40000000000000000, - "max": 12000000000000000000, - "minConf": 1 + "actualBalance": 56427481491786380000, + "min": 50000000000000000, + "minConf": 1, + "createdAt": "2020-04-07T18:43:23.284Z", + "updatedAt": "2021-12-14T13:50:23.261Z" }, { "code": "DAI", + "actualBalance": 1.7089336621378284e+23, + "min": 100000000000000000000, + "minConf": 1, + "createdAt": "2020-04-07T18:43:23.284Z", + "updatedAt": "2021-12-10T18:15:03.712Z" + }, + { + "code": "USDC", + "actualBalance": 104467212573, + "min": 100000000, + "minConf": 1, + "createdAt": "2020-04-07T18:43:23.284Z", + "updatedAt": "2021-11-30T15:36:53.302Z" + }, + { + "code": "WBTC", + "min": 200000, + "max": 0, + "actualBalance": 9364900, + "minConf": 1, + "updatedAt": "2021-12-14T13:46:53.153Z" + }, + { + "code": "UNI", "actualBalance": 0, - "min": 5000000000000000000, - "max": 2e+21, - "minConf": 1 + "min": 25000000000000000000, + "minConf": 1, + "createdAt": "2020-09-29T20:30:22.975Z", + "updatedAt": "2021-06-28T01:40:28.582Z" + }, + { + "code": "RBTC", + "min": 2000000000000000, + "max": 0, + "actualBalance": 8555522522403779000, + "minConf": 5, + "updatedAt": "2021-12-14T14:08:53.015Z" + }, + { + "code": "MATIC", + "actualBalance": 1.6740307252607191e+22, + "min": 120000000000000000000, + "minConf": 5, + "createdAt": "2021-06-21T14:42:10.516Z", + "updatedAt": "2021-12-14T13:28:54.066Z" } ] diff --git a/src/migrate/data/markets.json b/src/migrate/data/markets.json index ea574b3d8..b283387c7 100644 --- a/src/migrate/data/markets.json +++ b/src/migrate/data/markets.json @@ -2,61 +2,553 @@ { "from": "BTC", "to": "ETH", - "rate": 42.63633734, - "spread": 0, + "rate": 12.3040467, "orderExpiresIn": 7200000, "status": "ACTIVE", - "max": 28163916, - "min": 80000 + "max": 437237434, + "min": 200000, + "createdAt": "2020-04-07T18:43:23.301Z", + "updatedAt": "2021-12-14T14:13:58.749Z", + "minConf": 1 }, { "from": "ETH", "to": "BTC", - "rate": 0.02345417, - "spread": 0, + "rate": 0.07981121, "orderExpiresIn": 7200000, "status": "ACTIVE", - "max": 12000000000000000000, - "min": 40000000000000000 + "max": 29611725838118110000, + "min": 50000000000000000, + "createdAt": "2020-04-07T18:43:23.301Z", + "updatedAt": "2021-12-14T14:13:58.752Z", + "minConf": 1 + }, + { + "from": "RBTC", + "to": "BTC", + "rate": 0.99, + "orderExpiresIn": 7200000, + "status": "ACTIVE", + "createdAt": "2020-12-17T10:18:03.884Z", + "max": 2382598936310679600, + "min": 2000000000000000, + "minConf": 5, + "updatedAt": "2021-12-14T14:13:58.754Z" + }, + { + "from": "BTC", + "to": "RBTC", + "rate": 0.99, + "orderExpiresIn": 7200000, + "status": "ACTIVE", + "createdAt": "2020-12-17T10:18:03.875Z", + "max": 822326922, + "min": 200000, + "minConf": 1, + "updatedAt": "2021-12-14T14:13:59.220Z" + }, + { + "from": "RBTC", + "to": "ETH", + "rate": 12.23359335, + "orderExpiresIn": 7200000, + "status": "ACTIVE", + "createdAt": "2020-12-17T10:18:03.881Z", + "max": 4389700868624741000, + "min": 2000000000000000, + "minConf": 5, + "updatedAt": "2021-12-14T14:13:59.217Z" + }, + { + "from": "ETH", + "to": "RBTC", + "rate": 0.08012748, + "orderExpiresIn": 7200000, + "status": "ACTIVE", + "createdAt": "2020-12-17T10:18:03.873Z", + "max": 101746057786217090000, + "min": 50000000000000000, + "minConf": 1, + "updatedAt": "2021-12-14T14:13:59.198Z" }, { "from": "DAI", "to": "BTC", - "rate": 0.00013726, - "spread": 0, + "rate": 0.000021, + "orderExpiresIn": 7200000, + "status": "ACTIVE", + "max": 1.1255425453530648e+23, + "min": 100000000000000000000, + "createdAt": "2020-04-07T18:43:23.301Z", + "updatedAt": "2021-12-14T14:13:59.199Z", + "minConf": 1 + }, + { + "from": "BTC", + "to": "DAI", + "rate": 46767.7166693, + "orderExpiresIn": 7200000, + "status": "ACTIVE", + "max": 348755199, + "min": 200000, + "createdAt": "2020-04-07T18:43:23.301Z", + "updatedAt": "2021-12-14T14:13:59.201Z", + "minConf": 1 + }, + { + "from": "ETH", + "to": "DAI", + "rate": 3763.51559203, + "orderExpiresIn": 7200000, + "status": "ACTIVE", + "max": 43214452586448420000, + "min": 50000000000000000, + "createdAt": "2020-04-07T18:43:23.302Z", + "updatedAt": "2021-12-14T14:13:59.177Z", + "minConf": 1 + }, + { + "from": "DAI", + "to": "ETH", + "rate": 0.00026046, + "orderExpiresIn": 7200000, + "status": "ACTIVE", + "max": 2.0616668958897742e+23, + "min": 100000000000000000000, + "createdAt": "2020-04-07T18:43:23.302Z", + "updatedAt": "2021-12-14T14:13:59.180Z", + "minConf": 1 + }, + { + "from": "USDC", + "to": "BTC", + "rate": 0.00002102, + "orderExpiresIn": 7200000, + "status": "ACTIVE", + "max": 112546825954, + "min": 100000000, + "createdAt": "2020-04-07T18:43:23.302Z", + "updatedAt": "2021-12-14T14:13:59.181Z", + "minConf": 1 + }, + { + "from": "BTC", + "to": "USDC", + "rate": 46764.63, + "orderExpiresIn": 7200000, + "status": "ACTIVE", + "max": 213194253, + "min": 200000, + "createdAt": "2020-04-07T18:43:23.302Z", + "updatedAt": "2021-12-14T14:13:59.153Z", + "minConf": 1 + }, + { + "from": "ETH", + "to": "USDC", + "rate": 3763.2672, "orderExpiresIn": 7200000, "status": "ACTIVE", - "max": 2e+21, - "min": 5000000000000000000 + "max": 26434261760098050000, + "min": 50000000000000000, + "createdAt": "2020-04-07T18:43:23.302Z", + "updatedAt": "2021-12-14T14:13:59.155Z", + "minConf": 1 + }, + { + "from": "USDC", + "to": "ETH", + "rate": 0.00026063, + "orderExpiresIn": 7200000, + "status": "ACTIVE", + "max": 206166689588, + "min": 100000000, + "createdAt": "2020-04-07T18:43:23.302Z", + "updatedAt": "2021-12-14T14:13:59.157Z", + "minConf": 1 }, { "from": "BTC", + "to": "WBTC", + "rate": 0.99163744, + "orderExpiresIn": 7200000, + "status": "ACTIVE", + "min": 200000, + "max": 9003833, + "minConf": 1, + "createdAt": "2020-07-16T12:31:29.053Z", + "updatedAt": "2021-12-14T14:13:59.113Z" + }, + { + "from": "WBTC", + "to": "BTC", + "rate": 0.99028809, + "orderExpiresIn": 7200000, + "status": "ACTIVE", + "min": 200000, + "max": 238507303, + "minConf": 1, + "createdAt": "2020-07-16T12:31:29.048Z", + "updatedAt": "2021-12-14T14:13:59.115Z" + }, + { + "from": "WBTC", + "to": "ETH", + "rate": 12.28380021, + "orderExpiresIn": 7200000, + "status": "ACTIVE", + "max": 437173556, + "min": 200000, + "minConf": 1, + "createdAt": "2020-07-16T12:31:29.048Z", + "updatedAt": "2021-12-14T14:13:59.084Z" + }, + { + "from": "ETH", + "to": "WBTC", + "rate": 0.07979955, + "orderExpiresIn": 7200000, + "status": "ACTIVE", + "max": 1116675646670708700, + "min": 50000000000000000, + "minConf": 1, + "createdAt": "2020-07-17T08:15:30.095Z", + "updatedAt": "2021-12-14T14:13:59.086Z" + }, + { + "from": "DAI", + "to": "WBTC", + "rate": 0.00002099, + "orderExpiresIn": 7200000, + "status": "ACTIVE", + "max": 4.245162956570324e+21, + "min": 100000000000000000000, + "minConf": 1, + "createdAt": "2020-07-17T08:15:30.095Z", + "updatedAt": "2021-12-14T14:13:59.087Z" + }, + { + "from": "USDC", + "to": "WBTC", + "rate": 0.00002099, + "orderExpiresIn": 7200000, + "status": "ACTIVE", + "max": 4244882775, + "min": 100000000, + "minConf": 1, + "createdAt": "2020-07-17T08:15:30.089Z", + "updatedAt": "2021-12-14T14:13:59.067Z" + }, + { + "from": "USDT", + "to": "WBTC", + "rate": 0.00002099, + "orderExpiresIn": 7200000, + "status": "ACTIVE", + "max": 4244882775, + "min": 100000000, + "minConf": 1, + "createdAt": "2020-07-17T08:15:30.089Z", + "updatedAt": "2021-12-14T14:13:59.069Z" + }, + { + "from": "WBTC", + "to": "DAI", + "rate": 46690.49157244, + "orderExpiresIn": 7200000, + "status": "ACTIVE", + "max": 348091536, + "min": 200000, + "minConf": 1, + "createdAt": "2020-07-17T08:15:30.089Z", + "updatedAt": "2021-12-14T14:13:59.070Z" + }, + { + "from": "WBTC", + "to": "USDC", + "rate": 46687.41, + "orderExpiresIn": 7200000, + "status": "ACTIVE", + "max": 212788555, + "min": 200000, + "minConf": 1, + "createdAt": "2020-07-17T08:15:30.083Z", + "updatedAt": "2021-12-14T14:13:59.044Z" + }, + { + "from": "UNI", + "to": "BTC", + "rate": 0.00030606, + "orderExpiresIn": 7200000, + "status": "ACTIVE", + "minConf": 1, + "createdAt": "2020-09-29T20:30:23.222Z", + "max": 7.719261039394304e+21, + "min": 25000000000000000000, + "updatedAt": "2021-12-14T14:13:59.047Z" + }, + { + "from": "UNI", + "to": "ETH", + "rate": 0.0037958, + "orderExpiresIn": 7200000, + "status": "ACTIVE", + "minConf": 1, + "createdAt": "2020-09-29T20:30:23.220Z", + "max": 1.4140376515113715e+22, + "min": 25000000000000000000, + "updatedAt": "2021-12-14T14:13:59.017Z" + }, + { + "from": "UNI", "to": "DAI", - "rate": 7285.42544146, - "spread": 0, + "rate": 14.43515272, + "orderExpiresIn": 7200000, + "status": "ACTIVE", + "minConf": 1, + "createdAt": "2020-09-29T20:30:23.219Z", + "max": 1.1265149672306468e+22, + "min": 25000000000000000000, + "updatedAt": "2021-12-14T14:13:59.018Z" + }, + { + "from": "UNI", + "to": "USDC", + "rate": 14.4342, + "orderExpiresIn": 7200000, + "status": "ACTIVE", + "minConf": 1, + "createdAt": "2020-09-29T20:30:23.210Z", + "max": 6.886846823668121e+21, + "min": 25000000000000000000, + "updatedAt": "2021-12-14T14:13:59.005Z" + }, + { + "from": "UNI", + "to": "WBTC", + "rate": 0.00030608, "orderExpiresIn": 7200000, "status": "ACTIVE", - "max": 27452000, - "min": 80000 + "minConf": 1, + "createdAt": "2020-09-29T20:30:23.207Z", + "max": 291144223307177200000, + "min": 25000000000000000000, + "updatedAt": "2021-12-14T14:13:58.998Z" + }, + { + "from": "BTC", + "to": "UNI", + "rate": 3207.45061728, + "orderExpiresIn": 7200000, + "status": "ACTIVE", + "minConf": 1, + "createdAt": "2020-09-29T20:30:23.199Z", + "max": 0, + "min": 200000, + "updatedAt": "2021-12-14T14:13:58.996Z" }, { "from": "ETH", + "to": "UNI", + "rate": 258.11160494, + "orderExpiresIn": 7200000, + "status": "ACTIVE", + "minConf": 1, + "createdAt": "2020-09-29T20:30:23.197Z", + "max": 0, + "min": 50000000000000000, + "updatedAt": "2021-12-14T14:13:58.965Z" + }, + { + "from": "DAI", + "to": "UNI", + "rate": 0.06789675, + "orderExpiresIn": 7200000, + "status": "ACTIVE", + "minConf": 1, + "createdAt": "2020-09-29T20:30:23.195Z", + "max": 0, + "min": 100000000000000000000, + "updatedAt": "2021-12-14T14:13:58.966Z" + }, + { + "from": "USDC", + "to": "UNI", + "rate": 0.06790123, + "orderExpiresIn": 7200000, + "status": "ACTIVE", + "minConf": 1, + "createdAt": "2020-09-29T20:30:23.187Z", + "max": 0, + "min": 100000000, + "updatedAt": "2021-12-14T14:13:58.953Z" + }, + { + "from": "WBTC", + "to": "UNI", + "rate": 3202.15432099, + "orderExpiresIn": 7200000, + "status": "ACTIVE", + "minConf": 1, + "createdAt": "2020-09-29T20:30:23.183Z", + "max": 0, + "min": 200000, + "updatedAt": "2021-12-14T14:13:58.941Z" + }, + { + "from": "RBTC", "to": "DAI", - "rate": 170.87362322, - "spread": 0, + "rate": 46499.40896099, "orderExpiresIn": 7200000, "status": "ACTIVE", - "max": 11704560000000000000, - "min": 40000000000000000 + "createdAt": "2020-12-17T10:18:03.882Z", + "max": 3497506951249070000, + "min": 2000000000000000, + "minConf": 5, + "updatedAt": "2021-12-14T14:13:58.943Z" }, { "from": "DAI", + "to": "RBTC", + "rate": 0.00002108, + "orderExpiresIn": 7200000, + "status": "ACTIVE", + "createdAt": "2020-12-17T10:18:03.871Z", + "max": 3.8644431375113084e+23, + "min": 100000000000000000000, + "minConf": 1, + "updatedAt": "2021-12-14T14:13:58.944Z" + }, + { + "from": "UNI", + "to": "RBTC", + "rate": 0.00030733, + "orderExpiresIn": 7200000, + "status": "ACTIVE", + "minConf": 1, + "createdAt": "2020-09-29T20:30:23.222Z", + "max": 2.70274055446038e+22, + "min": 25000000000000000000, + "updatedAt": "2021-12-14T14:13:58.929Z" + }, + { + "from": "MATIC", + "to": "BTC", + "rate": 0.00003861, + "orderExpiresIn": 7200000, + "status": "ACTIVE", + "minConf": 5, + "createdAt": "2021-06-21T14:42:10.742Z", + "max": 6.116675323614856e+22, + "min": 120000000000000000000, + "updatedAt": "2021-12-14T14:13:58.847Z" + }, + { + "from": "MATIC", + "to": "DAI", + "rate": 1.82172023, + "orderExpiresIn": 7200000, + "status": "ACTIVE", + "minConf": 5, + "createdAt": "2021-06-21T14:42:10.735Z", + "max": 8.926407091567367e+22, + "min": 120000000000000000000, + "updatedAt": "2021-12-14T14:13:58.849Z" + }, + { + "from": "MATIC", + "to": "USDC", + "rate": 1.8216, + "orderExpiresIn": 7200000, + "status": "ACTIVE", + "minConf": 5, + "createdAt": "2021-06-21T14:42:10.741Z", + "max": 5.457077922201619e+22, + "min": 120000000000000000000, + "updatedAt": "2021-12-14T14:13:58.821Z" + }, + { + "from": "MATIC", + "to": "RBTC", + "rate": 0.00003879, + "orderExpiresIn": 7200000, + "status": "ACTIVE", + "minConf": 5, + "createdAt": "2021-06-21T14:42:10.728Z", + "max": 2.098989468548669e+23, + "min": 120000000000000000000, + "updatedAt": "2021-12-14T14:13:58.825Z" + }, + { + "from": "MATIC", "to": "ETH", - "rate": 0.00585228, - "spread": 0, + "rate": 0.00047891, + "orderExpiresIn": 7200000, + "status": "ACTIVE", + "minConf": 5, + "createdAt": "2021-06-21T14:42:10.724Z", + "max": 1.120471139068624e+23, + "min": 120000000000000000000, + "updatedAt": "2021-12-14T14:13:58.801Z" + }, + { + "from": "BTC", + "to": "MATIC", + "rate": 25415.55978261, + "orderExpiresIn": 7200000, + "status": "ACTIVE", + "minConf": 1, + "createdAt": "2021-06-21T14:42:10.711Z", + "max": 62751773, + "min": 200000, + "updatedAt": "2021-12-14T14:13:58.804Z" + }, + { + "from": "DAI", + "to": "MATIC", + "rate": 0.53800797, + "orderExpiresIn": 7200000, + "status": "ACTIVE", + "minConf": 1, + "createdAt": "2021-06-21T14:42:10.708Z", + "max": 2.9605964748882776e+22, + "min": 100000000000000000000, + "updatedAt": "2021-12-14T14:13:58.784Z" + }, + { + "from": "USDC", + "to": "MATIC", + "rate": 0.53804348, + "orderExpiresIn": 7200000, + "status": "ACTIVE", + "minConf": 1, + "createdAt": "2021-06-21T14:42:10.710Z", + "max": 29605964748, + "min": 100000000, + "updatedAt": "2021-12-14T14:13:58.785Z" + }, + { + "from": "RBTC", + "to": "MATIC", + "rate": 25269.75, + "orderExpiresIn": 7200000, + "status": "ACTIVE", + "minConf": 5, + "createdAt": "2021-06-21T14:42:10.697Z", + "max": 629955639913645300, + "min": 2000000000000000, + "updatedAt": "2021-12-14T14:13:58.765Z" + }, + { + "from": "ETH", + "to": "MATIC", + "rate": 2045.25391304, "orderExpiresIn": 7200000, "status": "ACTIVE", - "max": 2e+21, - "min": 5000000000000000000 + "minConf": 1, + "createdAt": "2021-06-21T14:42:10.700Z", + "max": 7783592763442825000, + "min": 50000000000000000, + "updatedAt": "2021-12-14T14:13:58.767Z" } ]