From 92eccff5ccbd29b50d3b310b23f4fcb40db49878 Mon Sep 17 00:00:00 2001 From: Dennis Reimann Date: Fri, 4 Dec 2020 11:47:35 +0100 Subject: [PATCH 01/15] Update README.md --- README.md | 64 +++++++++++++++++++++++++++++-------------------------- 1 file changed, 34 insertions(+), 30 deletions(-) diff --git a/README.md b/README.md index 8f87dd8..8085e57 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,40 @@ Generate a new API key dedicated for stacking using the "Query Funds" and "Modif Only check the "Withdraw Funds" option if you plan to automatically withdraw Bitcoin from Kraken. See details below. -## 📦 Setup +## ⚡️ RaspiBlitz Integration + +This script ships with the [RaspiBlitz](https://github.com/rootzoll/raspiblitz) (v1.6 and above). + +You can enable it via the Console of your RaspiBlitz. +Leave the main menu via the last option "Console" and use the following commands: + +```sh +# enable the script +./config.scripts/bonus.stacking-sats-kraken.sh on + +# switch to the stackingsats user +sudo su - stackingsats + +# edit your configuration (see "Setup" above) +nano /mnt/hdd/app-data/stacking-sats-kraken/.env + +# follow the instructions from the first step to set up a cronjob +crontab -e +``` + +Here is an example for a daily cronjob at 6:15am ... + +```sh +SHELL=/bin/bash +PATH=/bin:/usr/sbin:/usr/bin:/usr/local/bin +15 6 * * * /home/stackingsats/stacksats.sh > /dev/null 2>&1 +``` + +**Note:** Do not run `npm` directly on the RaspiBlitz, like show in the examples below. Please use the `stacksats.sh` shell script instead, as this loads your configuration. + +- - - + +## 📦 Custom Setup Prerequisite: At least the current LTS version of [Node.js](https://nodejs.org/). @@ -173,32 +206,3 @@ Just set up a second cron job which executes the withdrawal script. If you are using the aforementioned `stacksats.sh` script you can withdraw via this command: `stacksats.sh withdraw` - -## ⚡️ RaspiBlitz Integration - -This script ships with the [RaspiBlitz](https://github.com/rootzoll/raspiblitz) (v1.6 and above). - -You can enable it via the Console of your RaspiBlitz. -Leave the main menu via the last option "Console" and use the following commands: - -```sh -# enable the script -./config.scripts/bonus.stacking-sats-kraken.sh on - -# switch to the stackingsats user -sudo su - stackingsats - -# edit your configuration (see "Setup" above) -nano /mnt/hdd/app-data/stacking-sats-kraken/.env - -# follow the instructions from the first step to set up a cronjob -crontab -e -``` - -Here is an example for a daily cronjob at 6:15am ... - -```sh -SHELL=/bin/bash -PATH=/bin:/usr/sbin:/usr/bin:/usr/local/bin -15 6 * * * /home/stackingsats/stacksats.sh > /dev/null 2>&1 -``` From 4e034228210e23c2f1a8c1ae6cdf533df62892e3 Mon Sep 17 00:00:00 2001 From: Christoph Stenglein <9399034+cstenglein@users.noreply.github.com> Date: Tue, 8 Dec 2020 15:49:39 +0000 Subject: [PATCH 02/15] Update kraken-api; remove deprecation warning in example script (#6) * Update kraken-api; remove deprecation warning in example script * Update package.json Co-authored-by: Dennis Reimann Co-authored-by: Dennis Reimann --- README.md | 3 - package-lock.json | 297 +++++++++++++++++++++++++++++----------------- package.json | 2 +- 3 files changed, 190 insertions(+), 112 deletions(-) diff --git a/README.md b/README.md index 8085e57..25ec794 100644 --- a/README.md +++ b/README.md @@ -120,9 +120,6 @@ Here's a sample `stacksats.sh` script: #!/bin/bash set -e -# hide deprecation warning -export NODE_OPTIONS="--no-deprecation" - export KRAKEN_API_KEY="apiKeyFromTheKrakenSettings" export KRAKEN_API_SECRET="privateKeyFromTheKrakenSettings" export KRAKEN_API_FIAT="USD" diff --git a/package-lock.json b/package-lock.json index f3d6725..f3d9c6e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4,156 +4,237 @@ "lockfileVersion": 1, "requires": true, "dependencies": { - "decompress-response": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/decompress-response/-/decompress-response-3.3.0.tgz", - "integrity": "sha1-gKTdMjdIOEv6JICDYirt7Jgq3/M=", + "@sindresorhus/is": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/@sindresorhus/is/-/is-4.0.0.tgz", + "integrity": "sha512-FyD2meJpDPjyNQejSjvnhpgI/azsQkA4lGbuu5BQZfjvJ9cbRZXzeWL2HceCekW4lixO9JPesIIQkSoLjeJHNQ==" + }, + "@szmarczak/http-timer": { + "version": "4.0.5", + "resolved": "https://registry.npmjs.org/@szmarczak/http-timer/-/http-timer-4.0.5.tgz", + "integrity": "sha512-PyRA9sm1Yayuj5OIoJ1hGt2YISX45w9WcFbh6ddT0Z/0yaFxOtGLInr4jUfU1EAFVs0Yfyfev4RNwBlUaHdlDQ==", + "requires": { + "defer-to-connect": "^2.0.0" + } + }, + "@types/cacheable-request": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/@types/cacheable-request/-/cacheable-request-6.0.1.tgz", + "integrity": "sha512-ykFq2zmBGOCbpIXtoVbz4SKY5QriWPh3AjyU4G74RYbtt5yOc5OfaY75ftjg7mikMOla1CTGpX3lLbuJh8DTrQ==", + "requires": { + "@types/http-cache-semantics": "*", + "@types/keyv": "*", + "@types/node": "*", + "@types/responselike": "*" + } + }, + "@types/http-cache-semantics": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/@types/http-cache-semantics/-/http-cache-semantics-4.0.0.tgz", + "integrity": "sha512-c3Xy026kOF7QOTn00hbIllV1dLR9hG9NkSrLQgCVs8NF6sBU+VGWjD3wLPhmh1TYAc7ugCFsvHYMN4VcBN1U1A==" + }, + "@types/keyv": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/@types/keyv/-/keyv-3.1.1.tgz", + "integrity": "sha512-MPtoySlAZQ37VoLaPcTHCu1RWJ4llDkULYZIzOYxlhxBqYPB0RsRlmMU0R6tahtFe27mIdkHV+551ZWV4PLmVw==", + "requires": { + "@types/node": "*" + } + }, + "@types/node": { + "version": "14.14.10", + "resolved": "https://registry.npmjs.org/@types/node/-/node-14.14.10.tgz", + "integrity": "sha512-J32dgx2hw8vXrSbu4ZlVhn1Nm3GbeCFNw2FWL8S5QKucHGY0cyNwjdQdO+KMBZ4wpmC7KhLCiNsdk1RFRIYUQQ==" + }, + "@types/responselike": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/@types/responselike/-/responselike-1.0.0.tgz", + "integrity": "sha512-85Y2BjiufFzaMIlvJDvTTB8Fxl2xfLo4HgmHzVBz08w4wDePCTjYw66PdrolO0kzli3yam/YCgRufyo1DdQVTA==", + "requires": { + "@types/node": "*" + } + }, + "cacheable-lookup": { + "version": "5.0.3", + "resolved": "https://registry.npmjs.org/cacheable-lookup/-/cacheable-lookup-5.0.3.tgz", + "integrity": "sha512-W+JBqF9SWe18A72XFzN/V/CULFzPm7sBXzzR6ekkE+3tLG72wFZrBiBZhrZuDoYexop4PHJVdFAKb/Nj9+tm9w==" + }, + "cacheable-request": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/cacheable-request/-/cacheable-request-7.0.1.tgz", + "integrity": "sha512-lt0mJ6YAnsrBErpTMWeu5kl/tg9xMAWjavYTN6VQXM1A/teBITuNcccXsCxF0tDQQJf9DfAaX5O4e0zp0KlfZw==", + "requires": { + "clone-response": "^1.0.2", + "get-stream": "^5.1.0", + "http-cache-semantics": "^4.0.0", + "keyv": "^4.0.0", + "lowercase-keys": "^2.0.0", + "normalize-url": "^4.1.0", + "responselike": "^2.0.0" + } + }, + "clone-response": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/clone-response/-/clone-response-1.0.2.tgz", + "integrity": "sha1-0dyXOSAxTfZ/vrlCI7TuNQI56Ws=", "requires": { "mimic-response": "^1.0.0" } }, - "duplexer3": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/duplexer3/-/duplexer3-0.1.4.tgz", - "integrity": "sha1-7gHdHKwO08vH/b6jfcCo8c4ALOI=" + "decompress-response": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/decompress-response/-/decompress-response-6.0.0.tgz", + "integrity": "sha512-aW35yZM6Bb/4oJlZncMH2LCoZtJXTRxES17vE3hoRiowU2kWHaJKFkSBDnDR+cm9J+9QhXmREyIfv0pji9ejCQ==", + "requires": { + "mimic-response": "^3.1.0" + }, + "dependencies": { + "mimic-response": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-3.1.0.tgz", + "integrity": "sha512-z0yWI+4FDrrweS8Zmt4Ej5HdJmky15+L2e6Wgn3+iK5fWzb6T3fhNFq2+MeTRb064c6Wr4N/wv0DzQTjNzHNGQ==" + } + } + }, + "defer-to-connect": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/defer-to-connect/-/defer-to-connect-2.0.0.tgz", + "integrity": "sha512-bYL2d05vOSf1JEZNx5vSAtPuBMkX8K9EUutg7zlKvTqKXHt7RhWJFbmd7qakVuf13i+IkGmp6FwSsONOf6VYIg==" + }, + "end-of-stream": { + "version": "1.4.4", + "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.4.tgz", + "integrity": "sha512-+uw1inIHVPQoaVuHzRyXd21icM+cnt4CzD5rW+NC1wjOUSTOs+Te7FOv7AhN7vS9x/oIyhLP5PR1H+phQAHu5Q==", + "requires": { + "once": "^1.4.0" + } }, "get-stream": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz", - "integrity": "sha1-jpQ9E1jcN1VQVOy+LtsFqhdO3hQ=" + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-5.2.0.tgz", + "integrity": "sha512-nBF+F1rAZVCu/p7rjzgA+Yb4lfYXrpl7a6VmJrU8wF9I1CKvP/QwPNZHnOlwbTkY6dvtFIzFMSyQXbLoTQPRpA==", + "requires": { + "pump": "^3.0.0" + } }, "got": { - "version": "7.1.0", - "resolved": "https://registry.npmjs.org/got/-/got-7.1.0.tgz", - "integrity": "sha512-Y5WMo7xKKq1muPsxD+KmrR8DH5auG7fBdDVueZwETwV6VytKyU9OX/ddpq2/1hp1vIPvVb4T81dKQz3BivkNLw==", + "version": "11.8.0", + "resolved": "https://registry.npmjs.org/got/-/got-11.8.0.tgz", + "integrity": "sha512-k9noyoIIY9EejuhaBNLyZ31D5328LeqnyPNXJQb2XlJZcKakLqN5m6O/ikhq/0lw56kUYS54fVm+D1x57YC9oQ==", "requires": { - "decompress-response": "^3.2.0", - "duplexer3": "^0.1.4", - "get-stream": "^3.0.0", - "is-plain-obj": "^1.1.0", - "is-retry-allowed": "^1.0.0", - "is-stream": "^1.0.0", - "isurl": "^1.0.0-alpha5", - "lowercase-keys": "^1.0.0", - "p-cancelable": "^0.3.0", - "p-timeout": "^1.1.1", - "safe-buffer": "^5.0.1", - "timed-out": "^4.0.0", - "url-parse-lax": "^1.0.0", - "url-to-options": "^1.0.1" + "@sindresorhus/is": "^4.0.0", + "@szmarczak/http-timer": "^4.0.5", + "@types/cacheable-request": "^6.0.1", + "@types/responselike": "^1.0.0", + "cacheable-lookup": "^5.0.3", + "cacheable-request": "^7.0.1", + "decompress-response": "^6.0.0", + "http2-wrapper": "^1.0.0-beta.5.2", + "lowercase-keys": "^2.0.0", + "p-cancelable": "^2.0.0", + "responselike": "^2.0.0" } }, - "has-symbol-support-x": { - "version": "1.4.2", - "resolved": "https://registry.npmjs.org/has-symbol-support-x/-/has-symbol-support-x-1.4.2.tgz", - "integrity": "sha512-3ToOva++HaW+eCpgqZrCfN51IPB+7bJNVT6CUATzueB5Heb8o6Nam0V3HG5dlDvZU1Gn5QLcbahiKw/XVk5JJw==" + "http-cache-semantics": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/http-cache-semantics/-/http-cache-semantics-4.1.0.tgz", + "integrity": "sha512-carPklcUh7ROWRK7Cv27RPtdhYhUsela/ue5/jKzjegVvXDqM2ILE9Q2BGn9JZJh1g87cp56su/FgQSzcWS8cQ==" }, - "has-to-string-tag-x": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/has-to-string-tag-x/-/has-to-string-tag-x-1.4.1.tgz", - "integrity": "sha512-vdbKfmw+3LoOYVr+mtxHaX5a96+0f3DljYd8JOqvOLsf5mw2Otda2qCDT9qRqLAhrjyQ0h7ual5nOiASpsGNFw==", + "http2-wrapper": { + "version": "1.0.0-beta.5.2", + "resolved": "https://registry.npmjs.org/http2-wrapper/-/http2-wrapper-1.0.0-beta.5.2.tgz", + "integrity": "sha512-xYz9goEyBnC8XwXDTuC/MZ6t+MrKVQZOk4s7+PaDkwIsQd8IwqvM+0M6bA/2lvG8GHXcPdf+MejTUeO2LCPCeQ==", "requires": { - "has-symbol-support-x": "^1.4.1" + "quick-lru": "^5.1.1", + "resolve-alpn": "^1.0.0" } }, - "is-object": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/is-object/-/is-object-1.0.1.tgz", - "integrity": "sha1-iVJojF7C/9awPsyF52ngKQMINHA=" + "json-buffer": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/json-buffer/-/json-buffer-3.0.1.tgz", + "integrity": "sha512-4bV5BfR2mqfQTJm+V5tPPdf+ZpuhiIvTuAB5g8kcrXOZpTT/QwwVRWBywX1ozr6lEuPdbHxwaJlm9G6mI2sfSQ==" }, - "is-plain-obj": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-1.1.0.tgz", - "integrity": "sha1-caUMhCnfync8kqOQpKA7OfzVHT4=" - }, - "is-retry-allowed": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/is-retry-allowed/-/is-retry-allowed-1.2.0.tgz", - "integrity": "sha512-RUbUeKwvm3XG2VYamhJL1xFktgjvPzL0Hq8C+6yrWIswDy3BIXGqCxhxkc30N9jqK311gVU137K8Ei55/zVJRg==" - }, - "is-stream": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-1.1.0.tgz", - "integrity": "sha1-EtSj3U5o4Lec6428hBc66A2RykQ=" - }, - "isurl": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/isurl/-/isurl-1.0.0.tgz", - "integrity": "sha512-1P/yWsxPlDtn7QeRD+ULKQPaIaN6yF368GZ2vDfv0AL0NwpStafjWCDDdn0k8wgFMWpVAqG7oJhxHnlud42i9w==", + "keyv": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/keyv/-/keyv-4.0.3.tgz", + "integrity": "sha512-zdGa2TOpSZPq5mU6iowDARnMBZgtCqJ11dJROFi6tg6kTn4nuUdU09lFyLFSaHrWqpIJ+EBq4E8/Dc0Vx5vLdA==", "requires": { - "has-to-string-tag-x": "^1.2.0", - "is-object": "^1.0.1" + "json-buffer": "3.0.1" } }, "kraken-api": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/kraken-api/-/kraken-api-1.0.0.tgz", - "integrity": "sha512-JAfLh9Laks+2KZTM/WW+bpy+iZfImUok0aeLBOb0ehwTEGvcBWWAXlmkthhJXfUTSoOIHuoqqToC94+iBeBBAg==", + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/kraken-api/-/kraken-api-1.0.1.tgz", + "integrity": "sha512-cOdQCobNlskn1hzFBZDwIliFYP+bAv2SUITG6oGWdVNHnxflcZo4hb/oY/t+RKkKtp95KTL+8R1iSZYQS4ZDwA==", "requires": { - "got": "^7.1.0", - "qs": ">=6.4.0" + "got": "^11.1.4", + "qs": "^6.9.4" } }, "lowercase-keys": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/lowercase-keys/-/lowercase-keys-1.0.1.tgz", - "integrity": "sha512-G2Lj61tXDnVFFOi8VZds+SoQjtQC3dgokKdDG2mTm1tx4m50NUHBOZSBwQQHyy0V12A0JTG4icfZQH+xPyh8VA==" + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/lowercase-keys/-/lowercase-keys-2.0.0.tgz", + "integrity": "sha512-tqNXrS78oMOE73NMxK4EMLQsQowWf8jKooH9g7xPavRT706R6bkQJ6DY2Te7QukaZsulxa30wQ7bk0pm4XiHmA==" }, "mimic-response": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-1.0.1.tgz", "integrity": "sha512-j5EctnkH7amfV/q5Hgmoal1g2QHFJRraOtmx0JpIqkxhBhI/lJSl1nMpQ45hVarwNETOoWEimndZ4QK0RHxuxQ==" }, - "p-cancelable": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/p-cancelable/-/p-cancelable-0.3.0.tgz", - "integrity": "sha512-RVbZPLso8+jFeq1MfNvgXtCRED2raz/dKpacfTNxsx6pLEpEomM7gah6VeHSYV3+vo0OAi4MkArtQcWWXuQoyw==" + "normalize-url": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/normalize-url/-/normalize-url-4.5.0.tgz", + "integrity": "sha512-2s47yzUxdexf1OhyRi4Em83iQk0aPvwTddtFz4hnSSw9dCEsLEGf6SwIO8ss/19S9iBb5sJaOuTvTGDeZI00BQ==" }, - "p-finally": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/p-finally/-/p-finally-1.0.0.tgz", - "integrity": "sha1-P7z7FbiZpEEjs0ttzBi3JDNqLK4=" - }, - "p-timeout": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/p-timeout/-/p-timeout-1.2.1.tgz", - "integrity": "sha1-XrOzU7f86Z8QGhA4iAuwVOu+o4Y=", + "once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", "requires": { - "p-finally": "^1.0.0" + "wrappy": "1" } }, - "prepend-http": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/prepend-http/-/prepend-http-1.0.4.tgz", - "integrity": "sha1-1PRWKwzjaW5BrFLQ4ALlemNdxtw=" + "p-cancelable": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/p-cancelable/-/p-cancelable-2.0.0.tgz", + "integrity": "sha512-wvPXDmbMmu2ksjkB4Z3nZWTSkJEb9lqVdMaCKpZUGJG9TMiNp9XcbG3fn9fPKjem04fJMJnXoyFPk2FmgiaiNg==" + }, + "pump": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/pump/-/pump-3.0.0.tgz", + "integrity": "sha512-LwZy+p3SFs1Pytd/jYct4wpv49HiYCqd9Rlc5ZVdk0V+8Yzv6jR5Blk3TRmPL1ft69TxP0IMZGJ+WPFU2BFhww==", + "requires": { + "end-of-stream": "^1.1.0", + "once": "^1.3.1" + } }, "qs": { - "version": "6.9.3", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.9.3.tgz", - "integrity": "sha512-EbZYNarm6138UKKq46tdx08Yo/q9ZhFoAXAI1meAFd2GtbRDhbZY2WQSICskT0c5q99aFzLG1D4nvTk9tqfXIw==" + "version": "6.9.4", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.9.4.tgz", + "integrity": "sha512-A1kFqHekCTM7cz0udomYUoYNWjBebHm/5wzU/XqrBRBNWectVH0QIiN+NEcZ0Dte5hvzHwbr8+XQmguPhJ6WdQ==" }, - "safe-buffer": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.0.tgz", - "integrity": "sha512-fZEwUGbVl7kouZs1jCdMLdt95hdIv0ZeHg6L7qPeciMZhZ+/gdesW4wgTARkrFWEpspjEATAzUGPG8N2jJiwbg==" + "quick-lru": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/quick-lru/-/quick-lru-5.1.1.tgz", + "integrity": "sha512-WuyALRjWPDGtt/wzJiadO5AXY+8hZ80hVpe6MyivgraREW751X3SbhRvG3eLKOYN+8VEvqLcf3wdnt44Z4S4SA==" }, - "timed-out": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/timed-out/-/timed-out-4.0.1.tgz", - "integrity": "sha1-8y6srFoXW+ol1/q1Zas+2HQe9W8=" - }, - "url-parse-lax": { + "resolve-alpn": { "version": "1.0.0", - "resolved": "https://registry.npmjs.org/url-parse-lax/-/url-parse-lax-1.0.0.tgz", - "integrity": "sha1-evjzA2Rem9eaJy56FKxovAYJ2nM=", + "resolved": "https://registry.npmjs.org/resolve-alpn/-/resolve-alpn-1.0.0.tgz", + "integrity": "sha512-rTuiIEqFmGxne4IovivKSDzld2lWW9QCjqv80SYjPgf+gS35eaCAjaP54CCwGAwBtnCsvNLYtqxe1Nw+i6JEmA==" + }, + "responselike": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/responselike/-/responselike-2.0.0.tgz", + "integrity": "sha512-xH48u3FTB9VsZw7R+vvgaKeLKzT6jOogbQhEe/jewwnZgzPcnyWui2Av6JpoYZF/91uueC+lqhWqeURw5/qhCw==", "requires": { - "prepend-http": "^1.0.1" + "lowercase-keys": "^2.0.0" } }, - "url-to-options": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/url-to-options/-/url-to-options-1.0.1.tgz", - "integrity": "sha1-FQWgOiiaSMvXpDTvuu7FBV9WM6k=" + "wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" } } } diff --git a/package.json b/package.json index 61017fb..c34b241 100644 --- a/package.json +++ b/package.json @@ -13,6 +13,6 @@ "test:withdraw": "node index.js --cmd=withdraw --validate" }, "dependencies": { - "kraken-api": "1.0.0" + "kraken-api": "1.0.1" } } From 27217fa9bc6959f805d946352d47e649d959eb2c Mon Sep 17 00:00:00 2001 From: Dennis Reimann Date: Tue, 8 Dec 2020 16:51:06 +0100 Subject: [PATCH 03/15] Add package meta fields --- package.json | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/package.json b/package.json index c34b241..1b46f67 100644 --- a/package.json +++ b/package.json @@ -4,8 +4,14 @@ "version": "0.3.0", "description": "Use the Kraken API to stack sats", "author": "Dennis Reimann ", + "homepage": "https://github.com/dennisreimann/stacking-sats-kraken", + "bugs": "https://github.com/dennisreimann/stacking-sats-kraken/issues", + "funding": "https://github.com/dennisreimann/stacking-sats-kraken?sponsor=1", "license": "MIT", "main": "stack.js", + "engines": { + "node": ">=14.15" + }, "scripts": { "stack": "node index.js --cmd=stack", "withdraw": "node index.js --cmd=withdraw", From ed7c7a4d0448226289577f9a2353f438bd0eade8 Mon Sep 17 00:00:00 2001 From: Dennis Reimann Date: Tue, 8 Dec 2020 16:40:20 +0100 Subject: [PATCH 04/15] Update lockfile --- package-lock.json | 292 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 291 insertions(+), 1 deletion(-) diff --git a/package-lock.json b/package-lock.json index f3d9c6e..61efe9f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,8 +1,298 @@ { "name": "stacking-sats-kraken", "version": "0.3.0", - "lockfileVersion": 1, + "lockfileVersion": 2, "requires": true, + "packages": { + "": { + "version": "0.3.0", + "license": "MIT", + "dependencies": { + "kraken-api": "1.0.1" + } + }, + "node_modules/@sindresorhus/is": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/@sindresorhus/is/-/is-4.0.0.tgz", + "integrity": "sha512-FyD2meJpDPjyNQejSjvnhpgI/azsQkA4lGbuu5BQZfjvJ9cbRZXzeWL2HceCekW4lixO9JPesIIQkSoLjeJHNQ==", + "engines": { + "node": ">=10" + } + }, + "node_modules/@szmarczak/http-timer": { + "version": "4.0.5", + "resolved": "https://registry.npmjs.org/@szmarczak/http-timer/-/http-timer-4.0.5.tgz", + "integrity": "sha512-PyRA9sm1Yayuj5OIoJ1hGt2YISX45w9WcFbh6ddT0Z/0yaFxOtGLInr4jUfU1EAFVs0Yfyfev4RNwBlUaHdlDQ==", + "dependencies": { + "defer-to-connect": "^2.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/@types/cacheable-request": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/@types/cacheable-request/-/cacheable-request-6.0.1.tgz", + "integrity": "sha512-ykFq2zmBGOCbpIXtoVbz4SKY5QriWPh3AjyU4G74RYbtt5yOc5OfaY75ftjg7mikMOla1CTGpX3lLbuJh8DTrQ==", + "dependencies": { + "@types/http-cache-semantics": "*", + "@types/keyv": "*", + "@types/node": "*", + "@types/responselike": "*" + } + }, + "node_modules/@types/http-cache-semantics": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/@types/http-cache-semantics/-/http-cache-semantics-4.0.0.tgz", + "integrity": "sha512-c3Xy026kOF7QOTn00hbIllV1dLR9hG9NkSrLQgCVs8NF6sBU+VGWjD3wLPhmh1TYAc7ugCFsvHYMN4VcBN1U1A==" + }, + "node_modules/@types/keyv": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/@types/keyv/-/keyv-3.1.1.tgz", + "integrity": "sha512-MPtoySlAZQ37VoLaPcTHCu1RWJ4llDkULYZIzOYxlhxBqYPB0RsRlmMU0R6tahtFe27mIdkHV+551ZWV4PLmVw==", + "dependencies": { + "@types/node": "*" + } + }, + "node_modules/@types/node": { + "version": "14.14.10", + "resolved": "https://registry.npmjs.org/@types/node/-/node-14.14.10.tgz", + "integrity": "sha512-J32dgx2hw8vXrSbu4ZlVhn1Nm3GbeCFNw2FWL8S5QKucHGY0cyNwjdQdO+KMBZ4wpmC7KhLCiNsdk1RFRIYUQQ==" + }, + "node_modules/@types/responselike": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/@types/responselike/-/responselike-1.0.0.tgz", + "integrity": "sha512-85Y2BjiufFzaMIlvJDvTTB8Fxl2xfLo4HgmHzVBz08w4wDePCTjYw66PdrolO0kzli3yam/YCgRufyo1DdQVTA==", + "dependencies": { + "@types/node": "*" + } + }, + "node_modules/cacheable-lookup": { + "version": "5.0.3", + "resolved": "https://registry.npmjs.org/cacheable-lookup/-/cacheable-lookup-5.0.3.tgz", + "integrity": "sha512-W+JBqF9SWe18A72XFzN/V/CULFzPm7sBXzzR6ekkE+3tLG72wFZrBiBZhrZuDoYexop4PHJVdFAKb/Nj9+tm9w==", + "engines": { + "node": ">=10" + } + }, + "node_modules/cacheable-request": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/cacheable-request/-/cacheable-request-7.0.1.tgz", + "integrity": "sha512-lt0mJ6YAnsrBErpTMWeu5kl/tg9xMAWjavYTN6VQXM1A/teBITuNcccXsCxF0tDQQJf9DfAaX5O4e0zp0KlfZw==", + "dependencies": { + "clone-response": "^1.0.2", + "get-stream": "^5.1.0", + "http-cache-semantics": "^4.0.0", + "keyv": "^4.0.0", + "lowercase-keys": "^2.0.0", + "normalize-url": "^4.1.0", + "responselike": "^2.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/clone-response": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/clone-response/-/clone-response-1.0.2.tgz", + "integrity": "sha1-0dyXOSAxTfZ/vrlCI7TuNQI56Ws=", + "dependencies": { + "mimic-response": "^1.0.0" + } + }, + "node_modules/decompress-response": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/decompress-response/-/decompress-response-6.0.0.tgz", + "integrity": "sha512-aW35yZM6Bb/4oJlZncMH2LCoZtJXTRxES17vE3hoRiowU2kWHaJKFkSBDnDR+cm9J+9QhXmREyIfv0pji9ejCQ==", + "dependencies": { + "mimic-response": "^3.1.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/decompress-response/node_modules/mimic-response": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-3.1.0.tgz", + "integrity": "sha512-z0yWI+4FDrrweS8Zmt4Ej5HdJmky15+L2e6Wgn3+iK5fWzb6T3fhNFq2+MeTRb064c6Wr4N/wv0DzQTjNzHNGQ==", + "engines": { + "node": ">=10" + } + }, + "node_modules/defer-to-connect": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/defer-to-connect/-/defer-to-connect-2.0.0.tgz", + "integrity": "sha512-bYL2d05vOSf1JEZNx5vSAtPuBMkX8K9EUutg7zlKvTqKXHt7RhWJFbmd7qakVuf13i+IkGmp6FwSsONOf6VYIg==", + "engines": { + "node": ">=10" + } + }, + "node_modules/end-of-stream": { + "version": "1.4.4", + "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.4.tgz", + "integrity": "sha512-+uw1inIHVPQoaVuHzRyXd21icM+cnt4CzD5rW+NC1wjOUSTOs+Te7FOv7AhN7vS9x/oIyhLP5PR1H+phQAHu5Q==", + "dependencies": { + "once": "^1.4.0" + } + }, + "node_modules/get-stream": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-5.2.0.tgz", + "integrity": "sha512-nBF+F1rAZVCu/p7rjzgA+Yb4lfYXrpl7a6VmJrU8wF9I1CKvP/QwPNZHnOlwbTkY6dvtFIzFMSyQXbLoTQPRpA==", + "dependencies": { + "pump": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/got": { + "version": "11.8.0", + "resolved": "https://registry.npmjs.org/got/-/got-11.8.0.tgz", + "integrity": "sha512-k9noyoIIY9EejuhaBNLyZ31D5328LeqnyPNXJQb2XlJZcKakLqN5m6O/ikhq/0lw56kUYS54fVm+D1x57YC9oQ==", + "dependencies": { + "@sindresorhus/is": "^4.0.0", + "@szmarczak/http-timer": "^4.0.5", + "@types/cacheable-request": "^6.0.1", + "@types/responselike": "^1.0.0", + "cacheable-lookup": "^5.0.3", + "cacheable-request": "^7.0.1", + "decompress-response": "^6.0.0", + "http2-wrapper": "^1.0.0-beta.5.2", + "lowercase-keys": "^2.0.0", + "p-cancelable": "^2.0.0", + "responselike": "^2.0.0" + }, + "engines": { + "node": ">=10.19.0" + } + }, + "node_modules/http-cache-semantics": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/http-cache-semantics/-/http-cache-semantics-4.1.0.tgz", + "integrity": "sha512-carPklcUh7ROWRK7Cv27RPtdhYhUsela/ue5/jKzjegVvXDqM2ILE9Q2BGn9JZJh1g87cp56su/FgQSzcWS8cQ==" + }, + "node_modules/http2-wrapper": { + "version": "1.0.0-beta.5.2", + "resolved": "https://registry.npmjs.org/http2-wrapper/-/http2-wrapper-1.0.0-beta.5.2.tgz", + "integrity": "sha512-xYz9goEyBnC8XwXDTuC/MZ6t+MrKVQZOk4s7+PaDkwIsQd8IwqvM+0M6bA/2lvG8GHXcPdf+MejTUeO2LCPCeQ==", + "dependencies": { + "quick-lru": "^5.1.1", + "resolve-alpn": "^1.0.0" + }, + "engines": { + "node": ">=10.19.0" + } + }, + "node_modules/json-buffer": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/json-buffer/-/json-buffer-3.0.1.tgz", + "integrity": "sha512-4bV5BfR2mqfQTJm+V5tPPdf+ZpuhiIvTuAB5g8kcrXOZpTT/QwwVRWBywX1ozr6lEuPdbHxwaJlm9G6mI2sfSQ==" + }, + "node_modules/keyv": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/keyv/-/keyv-4.0.3.tgz", + "integrity": "sha512-zdGa2TOpSZPq5mU6iowDARnMBZgtCqJ11dJROFi6tg6kTn4nuUdU09lFyLFSaHrWqpIJ+EBq4E8/Dc0Vx5vLdA==", + "dependencies": { + "json-buffer": "3.0.1" + } + }, + "node_modules/kraken-api": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/kraken-api/-/kraken-api-1.0.1.tgz", + "integrity": "sha512-cOdQCobNlskn1hzFBZDwIliFYP+bAv2SUITG6oGWdVNHnxflcZo4hb/oY/t+RKkKtp95KTL+8R1iSZYQS4ZDwA==", + "dependencies": { + "got": "^11.1.4", + "qs": "^6.9.4" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/lowercase-keys": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/lowercase-keys/-/lowercase-keys-2.0.0.tgz", + "integrity": "sha512-tqNXrS78oMOE73NMxK4EMLQsQowWf8jKooH9g7xPavRT706R6bkQJ6DY2Te7QukaZsulxa30wQ7bk0pm4XiHmA==", + "engines": { + "node": ">=8" + } + }, + "node_modules/mimic-response": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-1.0.1.tgz", + "integrity": "sha512-j5EctnkH7amfV/q5Hgmoal1g2QHFJRraOtmx0JpIqkxhBhI/lJSl1nMpQ45hVarwNETOoWEimndZ4QK0RHxuxQ==", + "engines": { + "node": ">=4" + } + }, + "node_modules/normalize-url": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/normalize-url/-/normalize-url-4.5.0.tgz", + "integrity": "sha512-2s47yzUxdexf1OhyRi4Em83iQk0aPvwTddtFz4hnSSw9dCEsLEGf6SwIO8ss/19S9iBb5sJaOuTvTGDeZI00BQ==", + "engines": { + "node": ">=8" + } + }, + "node_modules/once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "dependencies": { + "wrappy": "1" + } + }, + "node_modules/p-cancelable": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/p-cancelable/-/p-cancelable-2.0.0.tgz", + "integrity": "sha512-wvPXDmbMmu2ksjkB4Z3nZWTSkJEb9lqVdMaCKpZUGJG9TMiNp9XcbG3fn9fPKjem04fJMJnXoyFPk2FmgiaiNg==", + "engines": { + "node": ">=8" + } + }, + "node_modules/pump": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/pump/-/pump-3.0.0.tgz", + "integrity": "sha512-LwZy+p3SFs1Pytd/jYct4wpv49HiYCqd9Rlc5ZVdk0V+8Yzv6jR5Blk3TRmPL1ft69TxP0IMZGJ+WPFU2BFhww==", + "dependencies": { + "end-of-stream": "^1.1.0", + "once": "^1.3.1" + } + }, + "node_modules/qs": { + "version": "6.9.4", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.9.4.tgz", + "integrity": "sha512-A1kFqHekCTM7cz0udomYUoYNWjBebHm/5wzU/XqrBRBNWectVH0QIiN+NEcZ0Dte5hvzHwbr8+XQmguPhJ6WdQ==", + "engines": { + "node": ">=0.6" + } + }, + "node_modules/quick-lru": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/quick-lru/-/quick-lru-5.1.1.tgz", + "integrity": "sha512-WuyALRjWPDGtt/wzJiadO5AXY+8hZ80hVpe6MyivgraREW751X3SbhRvG3eLKOYN+8VEvqLcf3wdnt44Z4S4SA==", + "engines": { + "node": ">=10" + } + }, + "node_modules/resolve-alpn": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/resolve-alpn/-/resolve-alpn-1.0.0.tgz", + "integrity": "sha512-rTuiIEqFmGxne4IovivKSDzld2lWW9QCjqv80SYjPgf+gS35eaCAjaP54CCwGAwBtnCsvNLYtqxe1Nw+i6JEmA==" + }, + "node_modules/responselike": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/responselike/-/responselike-2.0.0.tgz", + "integrity": "sha512-xH48u3FTB9VsZw7R+vvgaKeLKzT6jOogbQhEe/jewwnZgzPcnyWui2Av6JpoYZF/91uueC+lqhWqeURw5/qhCw==", + "dependencies": { + "lowercase-keys": "^2.0.0" + } + }, + "node_modules/wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" + } + }, "dependencies": { "@sindresorhus/is": { "version": "4.0.0", From dde741ed35b820057aafce1f2900540bcfe5d2dd Mon Sep 17 00:00:00 2001 From: Dennis Reimann Date: Tue, 8 Dec 2020 16:55:08 +0100 Subject: [PATCH 05/15] Fix shell script example --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index 25ec794..51aa85e 100644 --- a/README.md +++ b/README.md @@ -129,8 +129,7 @@ export KRAKEN_WITHDRAW_KEY="descriptionOfWithdrawalAddress" export KRAKEN_DRY_RUN_PLACE_NO_ORDER=1 # run script -BASE_DIR=$(cd `dirname $0` && pwd) -cd $BASE_DIR/stacking-sats-kraken +cd $(cd `dirname $0` && pwd) cmd=${1:-"stack"} if [[ "${KRAKEN_DRY_RUN_PLACE_NO_ORDER}" ]]; then From e50c80cdbf2c204be81b1edfaaa227c69590851f Mon Sep 17 00:00:00 2001 From: Dennis Reimann Date: Thu, 10 Dec 2020 14:57:46 +0100 Subject: [PATCH 06/15] Update raspiblitz script path and instructions --- README.md | 58 +++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 37 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index 51aa85e..87c0307 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,27 @@ Generate a new API key dedicated for stacking using the "Query Funds" and "Modif Only check the "Withdraw Funds" option if you plan to automatically withdraw Bitcoin from Kraken. See details below. +## ⚙️ Configuration + +These are the environment variables used by the script: + +```sh +# used to authenticate with Kraken +KRAKEN_API_KEY="apiKeyFromTheKrakenSettings" +KRAKEN_API_SECRET="privateKeyFromTheKrakenSettings" + +# used for buying +KRAKEN_API_FIAT="USD" # the governmental shitcoin you are selling +KRAKEN_BUY_AMOUNT=21 # fiat amount you trade for the future of money + +# used for withdrawal +KRAKEN_MAX_REL_FEE=0.5 # maximum fee in % that you are willing to pay +KRAKEN_WITHDRAW_KEY="descriptionOfWithdrawalAddress" + +# remove this line after verifying everything works +KRAKEN_DRY_RUN_PLACE_NO_ORDER=1 +``` + ## ⚡️ RaspiBlitz Integration This script ships with the [RaspiBlitz](https://github.com/rootzoll/raspiblitz) (v1.6 and above). @@ -37,7 +58,7 @@ Leave the main menu via the last option "Console" and use the following commands # switch to the stackingsats user sudo su - stackingsats -# edit your configuration (see "Setup" above) +# edit your configuration (see the "Configuration" section above) nano /mnt/hdd/app-data/stacking-sats-kraken/.env # follow the instructions from the first step to set up a cronjob @@ -49,10 +70,21 @@ Here is an example for a daily cronjob at 6:15am ... ```sh SHELL=/bin/bash PATH=/bin:/usr/sbin:/usr/bin:/usr/local/bin -15 6 * * * /home/stackingsats/stacksats.sh > /dev/null 2>&1 +15 6 * * * /home/stackingsats/stacking-sats-kraken/stacksats.sh > /dev/null 2>&1 ``` -**Note:** Do not run `npm` directly on the RaspiBlitz, like show in the examples below. Please use the `stacksats.sh` shell script instead, as this loads your configuration. +**Note:** Do not run `npm` directly on the RaspiBlitz, like show in the examples below. +Please use the `/home/stackingsats/stacking-sats-kraken/stacksats.sh` shell script instead, as this loads your configuration. + +To run the script manually, switch to the `stackingsats` user and use this command: + +```sh +# switch to the stackingsats user +sudo su - stackingsats + +# run the script +./stacking-sats-kraken/stacksats.sh +``` - - - @@ -66,24 +98,8 @@ Install the dependencies: npm install ``` -Setup the environment variables for the script: - -```sh -# used to authenticate with Kraken -export KRAKEN_API_KEY="apiKeyFromTheKrakenSettings" -export KRAKEN_API_SECRET="privateKeyFromTheKrakenSettings" - -# used for buying -export KRAKEN_API_FIAT="USD" # the governmental shitcoin you are selling -export KRAKEN_BUY_AMOUNT=21 # fiat amount you trade for the future of money - -# used for withdrawal -export KRAKEN_MAX_REL_FEE=0.5 # maximum fee in % that you are willing to pay -export KRAKEN_WITHDRAW_KEY="descriptionOfWithdrawalAddress" - -# remove this line after verifying everything works -export KRAKEN_DRY_RUN_PLACE_NO_ORDER=1 -``` +Setup the environment variables for the script. +See the [config section above](#-configuration). Use a dry run to test the script and see the output without placing an order: From 4517af870afd66ec69ab232ffa6fd4904a21f2e0 Mon Sep 17 00:00:00 2001 From: Dennis Reimann Date: Tue, 2 Mar 2021 19:26:31 +0100 Subject: [PATCH 07/15] Add market buy option --- README.md | 2 ++ commands/stack.js | 5 +++-- commands/withdraw.js | 2 +- index.js | 7 ++++++- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 87c0307..cf77f1c 100644 --- a/README.md +++ b/README.md @@ -33,6 +33,7 @@ KRAKEN_API_KEY="apiKeyFromTheKrakenSettings" KRAKEN_API_SECRET="privateKeyFromTheKrakenSettings" # used for buying +KRAKEN_ORDER_TYPE="market" # "limit" (default) or "market" KRAKEN_API_FIAT="USD" # the governmental shitcoin you are selling KRAKEN_BUY_AMOUNT=21 # fiat amount you trade for the future of money @@ -138,6 +139,7 @@ set -e export KRAKEN_API_KEY="apiKeyFromTheKrakenSettings" export KRAKEN_API_SECRET="privateKeyFromTheKrakenSettings" +export KRAKEN_ORDER_TYPE="market" export KRAKEN_API_FIAT="USD" export KRAKEN_BUY_AMOUNT=21 export KRAKEN_MAX_REL_FEE=0.5 diff --git a/commands/stack.js b/commands/stack.js index 7d223c6..727a320 100644 --- a/commands/stack.js +++ b/commands/stack.js @@ -1,5 +1,6 @@ -module.exports = async (kraken, validate, getEnv) => { +module.exports = async (kraken, validate, { getEnv, getEnvOpt }) => { const [fiat, amount] = getEnv('KRAKEN_API_FIAT', 'KRAKEN_BUY_AMOUNT') + const ordertype = getEnvOpt('KRAKEN_ORDER_TYPE', 'limit', ['limit', 'market']) // https://www.kraken.com/features/api const crypto = 'XBT' @@ -24,7 +25,7 @@ module.exports = async (kraken, validate, getEnv) => { console.log('📉 Bid:', bid, fiat, '\n') // Place order - const details = { pair, type: 'buy', ordertype: 'limit', price, volume } + const details = { pair, type: 'buy', ordertype, price, volume } if (validate) details.validate = true const { result: { descr: { order }, txid } } = await kraken.api('AddOrder', details) diff --git a/commands/withdraw.js b/commands/withdraw.js index 154f4cc..e88c656 100644 --- a/commands/withdraw.js +++ b/commands/withdraw.js @@ -1,4 +1,4 @@ -module.exports = async (kraken, validate, getEnv) => { +module.exports = async (kraken, validate, { getEnv }) => { const [maxFee, key] = getEnv('KRAKEN_MAX_REL_FEE', 'KRAKEN_WITHDRAW_KEY') // https://api.kraken.com/0/private/WithdrawInfo diff --git a/index.js b/index.js index 7569f4f..a37667b 100644 --- a/index.js +++ b/index.js @@ -6,6 +6,11 @@ const getEnv = (...vars) => vars.map(name => { assert(value, `Provide the ${name} environment variable.`) return value }) +const getEnvOpt = (varname, defaultValue, allowedValues) => { + const value = process.env[varname] || defaultValue + if (allowedValues) assert(allowedValues.includes(value), `The ${varname} environment variable must be one of ${allowedValues.map(v => `"${v}"`).join(", ")}.`) + return value +} const command = process.argv[2].replace('--cmd=', '') const validate = process.argv.includes('--validate') || process.env['KRAKEN_DRY_RUN_PLACE_NO_ORDER'] @@ -15,7 +20,7 @@ const validate = process.argv.includes('--validate') || process.env['KRAKEN_DRY_ const kraken = new Kraken(apiKey, secret) const cmd = require(`./commands/${command}`) - await cmd(kraken, validate, getEnv) + await cmd(kraken, validate, { getEnv, getEnvOpt }) if (validate) console.log('\n🚨 THIS WAS JUST A VALIDATION RUN!') } catch (err) { From 89f7d4b02088a80e323c7061186b851879b718ee Mon Sep 17 00:00:00 2001 From: Dennis Reimann Date: Tue, 2 Mar 2021 19:28:34 +0100 Subject: [PATCH 08/15] 0.4.0 --- package-lock.json | 4 ++-- package.json | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/package-lock.json b/package-lock.json index 61efe9f..c763e42 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,11 +1,11 @@ { "name": "stacking-sats-kraken", - "version": "0.3.0", + "version": "0.4.0", "lockfileVersion": 2, "requires": true, "packages": { "": { - "version": "0.3.0", + "version": "0.4.0", "license": "MIT", "dependencies": { "kraken-api": "1.0.1" diff --git a/package.json b/package.json index 1b46f67..963f2e6 100644 --- a/package.json +++ b/package.json @@ -1,12 +1,14 @@ { "private": true, "name": "stacking-sats-kraken", - "version": "0.3.0", + "version": "0.4.0", "description": "Use the Kraken API to stack sats", "author": "Dennis Reimann ", "homepage": "https://github.com/dennisreimann/stacking-sats-kraken", "bugs": "https://github.com/dennisreimann/stacking-sats-kraken/issues", - "funding": "https://github.com/dennisreimann/stacking-sats-kraken?sponsor=1", + "funding": { + "url": "https://github.com/dennisreimann/stacking-sats-kraken?sponsor=1" + }, "license": "MIT", "main": "stack.js", "engines": { From 62409bb4a2513fc926ca1b5e5dc0fd0f61908775 Mon Sep 17 00:00:00 2001 From: sstoefe <45008800+sstoefe@users.noreply.github.com> Date: Sat, 3 Apr 2021 18:33:35 +0200 Subject: [PATCH 09/15] Trading agreement fix for Germans (#7) As a German trying to place an order via the API you will get an exception: 'EOrder:Trading agreement required'. You have to set the 'trading_agreement' parameter to 'agree' (see https://support.kraken.com/hc/en-us/articles/360000920026--Trading-agreement-required-error-for-German-residents). --- README.md | 4 ++++ commands/stack.js | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/README.md b/README.md index cf77f1c..bd86893 100644 --- a/README.md +++ b/README.md @@ -41,6 +41,10 @@ KRAKEN_BUY_AMOUNT=21 # fiat amount you trade for the future of money KRAKEN_MAX_REL_FEE=0.5 # maximum fee in % that you are willing to pay KRAKEN_WITHDRAW_KEY="descriptionOfWithdrawalAddress" +# set this if you live in Germany and get the 'EOrder:Trading agreement required' error +# see https://support.kraken.com/hc/en-us/articles/360000920026--Trading-agreement-required-error-for-German-residents +KRAKEN_GERMANY_TRADING_AGREEMENT="agree" + # remove this line after verifying everything works KRAKEN_DRY_RUN_PLACE_NO_ORDER=1 ``` diff --git a/commands/stack.js b/commands/stack.js index 727a320..a79d101 100644 --- a/commands/stack.js +++ b/commands/stack.js @@ -1,6 +1,10 @@ module.exports = async (kraken, validate, { getEnv, getEnvOpt }) => { const [fiat, amount] = getEnv('KRAKEN_API_FIAT', 'KRAKEN_BUY_AMOUNT') const ordertype = getEnvOpt('KRAKEN_ORDER_TYPE', 'limit', ['limit', 'market']) + // if living in Germany, one needs to add an additional parameter to explicitly agree to the trade + // if the parameter is not set one will get the following error: EOrder:Trading agreement required + // see https://support.kraken.com/hc/en-us/articles/360000920026--Trading-agreement-required-error-for-German-residents + const trading_agreement = getEnvOpt('KRAKEN_GERMANY_TRADING_AGREEMENT', '', ['agree', '']) // https://www.kraken.com/features/api const crypto = 'XBT' @@ -27,6 +31,7 @@ module.exports = async (kraken, validate, { getEnv, getEnvOpt }) => { // Place order const details = { pair, type: 'buy', ordertype, price, volume } if (validate) details.validate = true + if (trading_agreement) details.trading_agreement = trading_agreement const { result: { descr: { order }, txid } } = await kraken.api('AddOrder', details) From 5f44df78d161e62d8652f6baa386866914a0e7fe Mon Sep 17 00:00:00 2001 From: Dennis Reimann Date: Sat, 3 Apr 2021 18:43:21 +0200 Subject: [PATCH 10/15] Remove version requirement --- package.json | 3 --- 1 file changed, 3 deletions(-) diff --git a/package.json b/package.json index 963f2e6..2420f3c 100644 --- a/package.json +++ b/package.json @@ -11,9 +11,6 @@ }, "license": "MIT", "main": "stack.js", - "engines": { - "node": ">=14.15" - }, "scripts": { "stack": "node index.js --cmd=stack", "withdraw": "node index.js --cmd=withdraw", From a2cf01202d5689b714e457521d52b90e2444de7f Mon Sep 17 00:00:00 2001 From: Dennis Reimann Date: Sat, 3 Apr 2021 18:43:32 +0200 Subject: [PATCH 11/15] 0.4.1 --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index c763e42..f7ce046 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,11 +1,11 @@ { "name": "stacking-sats-kraken", - "version": "0.4.0", + "version": "0.4.1", "lockfileVersion": 2, "requires": true, "packages": { "": { - "version": "0.4.0", + "version": "0.4.1", "license": "MIT", "dependencies": { "kraken-api": "1.0.1" diff --git a/package.json b/package.json index 2420f3c..305c9e7 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "private": true, "name": "stacking-sats-kraken", - "version": "0.4.0", + "version": "0.4.1", "description": "Use the Kraken API to stack sats", "author": "Dennis Reimann ", "homepage": "https://github.com/dennisreimann/stacking-sats-kraken", From e907387b123ecf47af9de411a070831fba08bb9a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20St=C3=B6ferle?= <45008800+sstoefe@users.noreply.github.com> Date: Sat, 3 Apr 2021 20:47:12 +0200 Subject: [PATCH 12/15] Set Fee currency (#8) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fees are by default paid with the fiat money. This means that you bought crypto for the specified amount (e.g. 25 USD) and the fees are charged separately. When you want to spend 100 USD over 4 weeks, meaning 1 order per week, the last order won't be placed since there is not enough fiat money left. In my case I wanted to spend 100 EUR a month, meaning 25 € once per week. When testing it the first time I was charged 25,065 EUR. By setting the fee to XBT instead of EUR, I can run the script 4 times a month. --- README.md | 1 + commands/stack.js | 13 ++++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index bd86893..043fb25 100644 --- a/README.md +++ b/README.md @@ -36,6 +36,7 @@ KRAKEN_API_SECRET="privateKeyFromTheKrakenSettings" KRAKEN_ORDER_TYPE="market" # "limit" (default) or "market" KRAKEN_API_FIAT="USD" # the governmental shitcoin you are selling KRAKEN_BUY_AMOUNT=21 # fiat amount you trade for the future of money +KRAKEN_FEE_CURRENCY="XBT" # pay fee in this currency, e.g. buying XBT for USD and paying fee in XBT # used for withdrawal KRAKEN_MAX_REL_FEE=0.5 # maximum fee in % that you are willing to pay diff --git a/commands/stack.js b/commands/stack.js index a79d101..552ea42 100644 --- a/commands/stack.js +++ b/commands/stack.js @@ -1,5 +1,5 @@ module.exports = async (kraken, validate, { getEnv, getEnvOpt }) => { - const [fiat, amount] = getEnv('KRAKEN_API_FIAT', 'KRAKEN_BUY_AMOUNT') + const [fiat, amount, feeCurrency] = getEnv('KRAKEN_API_FIAT', 'KRAKEN_BUY_AMOUNT', 'KRAKEN_FEE_CURRENCY') const ordertype = getEnvOpt('KRAKEN_ORDER_TYPE', 'limit', ['limit', 'market']) // if living in Germany, one needs to add an additional parameter to explicitly agree to the trade // if the parameter is not set one will get the following error: EOrder:Trading agreement required @@ -10,6 +10,16 @@ module.exports = async (kraken, validate, { getEnv, getEnvOpt }) => { const crypto = 'XBT' const pair = `${crypto}${fiat}` + // for explanation of oflags see https://www.kraken.com/features/api#add-standard-order + var fee = "" + if (feeCurrency == crypto) { + fee = "fcib" + } else if (feeCurrency == fiat) { + fee = "fciq" + } else { + fee = "" + } + // Fetch and display information const { result: balance } = await kraken.api('Balance') const { result: ticker } = await kraken.api('Ticker', { pair }) @@ -32,6 +42,7 @@ module.exports = async (kraken, validate, { getEnv, getEnvOpt }) => { const details = { pair, type: 'buy', ordertype, price, volume } if (validate) details.validate = true if (trading_agreement) details.trading_agreement = trading_agreement + if (fee) details.oflags = fee const { result: { descr: { order }, txid } } = await kraken.api('AddOrder', details) From add9855f8b2b022aaebcd2b38eec8e225075f89d Mon Sep 17 00:00:00 2001 From: Dennis Reimann Date: Sat, 3 Apr 2021 20:48:26 +0200 Subject: [PATCH 13/15] 0.4.2 --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index f7ce046..26e0825 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,11 +1,11 @@ { "name": "stacking-sats-kraken", - "version": "0.4.1", + "version": "0.4.2", "lockfileVersion": 2, "requires": true, "packages": { "": { - "version": "0.4.1", + "version": "0.4.2", "license": "MIT", "dependencies": { "kraken-api": "1.0.1" diff --git a/package.json b/package.json index 305c9e7..3f18923 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "private": true, "name": "stacking-sats-kraken", - "version": "0.4.1", + "version": "0.4.2", "description": "Use the Kraken API to stack sats", "author": "Dennis Reimann ", "homepage": "https://github.com/dennisreimann/stacking-sats-kraken", From 177874217ded1d7ced687b3143b48221177551ad Mon Sep 17 00:00:00 2001 From: Dennis Reimann Date: Wed, 21 Apr 2021 11:41:38 +0200 Subject: [PATCH 14/15] Increase request timeout https://support.kraken.com/hc/en-us/articles/360000914386-How-can-I-avoid-excessive-timeouts- --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index a37667b..0375381 100644 --- a/index.js +++ b/index.js @@ -17,7 +17,7 @@ const validate = process.argv.includes('--validate') || process.env['KRAKEN_DRY_ ;(async () => { try { const [apiKey, secret] = getEnv('KRAKEN_API_KEY', 'KRAKEN_API_SECRET') - const kraken = new Kraken(apiKey, secret) + const kraken = new Kraken(apiKey, secret, { timeout: 30000 }) const cmd = require(`./commands/${command}`) await cmd(kraken, validate, { getEnv, getEnvOpt }) From 0a9ddef452debac2c324b0d53bd296d818c4ba87 Mon Sep 17 00:00:00 2001 From: Dennis Reimann Date: Wed, 21 Apr 2021 11:43:05 +0200 Subject: [PATCH 15/15] 0.4.3 --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 26e0825..2ad90cf 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,11 +1,11 @@ { "name": "stacking-sats-kraken", - "version": "0.4.2", + "version": "0.4.3", "lockfileVersion": 2, "requires": true, "packages": { "": { - "version": "0.4.2", + "version": "0.4.3", "license": "MIT", "dependencies": { "kraken-api": "1.0.1" diff --git a/package.json b/package.json index 3f18923..8ea7026 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "private": true, "name": "stacking-sats-kraken", - "version": "0.4.2", + "version": "0.4.3", "description": "Use the Kraken API to stack sats", "author": "Dennis Reimann ", "homepage": "https://github.com/dennisreimann/stacking-sats-kraken",