From 727caaf3b4701191fc5d1b4b09e347ee46357a1b Mon Sep 17 00:00:00 2001 From: Drew Aquino Date: Thu, 22 Jul 2021 08:52:16 -0700 Subject: [PATCH] added dotenv to automate reading .env file, updated readme --- .gitignore | 3 +++ README.md | 21 +++++++++++++-------- package.json | 1 + src/index.ts | 2 ++ src/liquidate.ts | 2 ++ src/partial.ts | 2 ++ yarn.lock | 9 +++++++-- 7 files changed, 30 insertions(+), 10 deletions(-) diff --git a/.gitignore b/.gitignore index de4d1f0..c084c43 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,5 @@ dist node_modules + +.env +.DS_Store diff --git a/README.md b/README.md index 3627a4a..5e2eb84 100644 --- a/README.md +++ b/README.md @@ -11,14 +11,19 @@ To run the liquidator you will need: ### Setup Make sure to edit the .env file to look something like this: ``` -export CLUSTER="mainnet-beta" -export CLUSTER_URL="https://solana-api.projectserum.com" -export KEYPAIR=~/.config/solana/id.json -export NODE_ENV=production -export TARGETS="0.1 2.0 100.0 500.0" -export GROUP_NAME="BTC_ETH_SOL_SRM_USDT" -export CHECK_INTERVAL="1000.0" -export FILTER_ACCOUNTS=true +CLUSTER="mainnet-beta" +CLUSTER_URL="https://solana-api.projectserum.com" +KEYPAIR=${HOME}/.config/solana/id.json +NODE_ENV=production +TARGETS="0.1 2.0 100.0 500.0" +GROUP_NAME="BTC_ETH_SOL_SRM_USDC" +CHECK_INTERVAL="1000.0" +FILTER_ACCOUNTS=true +``` + +Replace `${HOME}` with your actual path to home. For example, +``` +KEYPAIR=/Users/john/.config/solana/id.json ``` TARGETS represents the amounts of each token the partial liquidator should try to maintain diff --git a/package.json b/package.json index 9d97308..b299411 100644 --- a/package.json +++ b/package.json @@ -23,6 +23,7 @@ "@typescript-eslint/parser": "^4.6.0", "babel-eslint": "^10.0.3", "cross-env": "^7.0.2", + "dotenv": "^10.0.0", "eslint": "^7.6.0", "eslint-config-prettier": "^6.11.0", "jest": "^26.4.0", diff --git a/src/index.ts b/src/index.ts index a89e860..02c2b3f 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,3 +1,5 @@ +import * as Env from 'dotenv'; +Env.config(); import { IDS, MangoClient, MarginAccount, NUM_MARKETS } from '@blockworks-foundation/mango-client'; import { Account, Connection, PublicKey } from '@solana/web3.js'; diff --git a/src/liquidate.ts b/src/liquidate.ts index 82e77a5..13de699 100644 --- a/src/liquidate.ts +++ b/src/liquidate.ts @@ -1,3 +1,5 @@ +import * as Env from 'dotenv'; +Env.config(); import { findLargestTokenAccountForOwner, getMultipleAccounts, diff --git a/src/partial.ts b/src/partial.ts index e3cef53..7358df4 100644 --- a/src/partial.ts +++ b/src/partial.ts @@ -1,3 +1,5 @@ +import * as Env from 'dotenv'; +Env.config(); import { findLargestTokenAccountForOwner, getMultipleAccounts, diff --git a/yarn.lock b/yarn.lock index cc7bb8e..c4f8149 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1246,9 +1246,9 @@ boolbase@~1.0.0: resolved "https://registry.yarnpkg.com/boolbase/-/boolbase-1.0.0.tgz#68dff5fbe60c51eb37725ea9e3ed310dcc1e776e" integrity sha1-aN/1++YMUes3cl6p4+0xDcwed24= -"borsh@git+https://github.com/defactojob/borsh-js.git#field-mapper": +"borsh@https://github.com/defactojob/borsh-js#field-mapper": version "0.3.1" - resolved "git+https://github.com/defactojob/borsh-js.git#33a0d24af281112c0a48efb3fa503f3212443de9" + resolved "https://github.com/defactojob/borsh-js#33a0d24af281112c0a48efb3fa503f3212443de9" dependencies: "@types/bn.js" "^4.11.5" bn.js "^5.0.0" @@ -1853,6 +1853,11 @@ dotenv@8.2.0: resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-8.2.0.tgz#97e619259ada750eea3e4ea3e26bceea5424b16a" integrity sha512-8sJ78ElpbDJBHNeBzUbUVLsqKdccaa/BXF1uPTw3GrvQTBgrQrtObr2mUrE38vzYd8cEv+m/JBfDLioYcfXoaw== +dotenv@^10.0.0: + version "10.0.0" + resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-10.0.0.tgz#3d4227b8fb95f81096cdd2b66653fb2c7085ba81" + integrity sha512-rlBi9d8jpv9Sf1klPjNfFAuWDjKLwTIJJ/VxtoTwIR6hnZxcEOQCZg2oIL3MWBYw5GpUDKOEnND7LXTbIpQ03Q== + ecc-jsbn@~0.1.1: version "0.1.2" resolved "https://registry.yarnpkg.com/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz#3a83a904e54353287874c564b7549386849a98c9"