@argonprotocol/mainchain 1.2.0 → 1.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,8 +1,11 @@
1
- This is a Node.js client for the Argon Protocol (https://argonprotocol.org). It has the following core features:
1
+ This is a Node.js client for the Argon Protocol (https://argonprotocol.org). It has the following
2
+ core features:
2
3
 
3
4
  1. A typescript generated RPC client for the Argon Protocol.
4
- 2. A CLI for interacting with a subset of the Argon Protocol (Mining Bidding, Vaults, Liquidity Pools, Bitcoin)
5
- 3. A "Wage Protector" class that can be used to protect wages against inflation or deflation of the Argon.
5
+ 2. A CLI for interacting with a subset of the Argon Protocol (Mining Bidding, Vaults, Liquidity
6
+ Pools, Bitcoin)
7
+ 3. A "Wage Protector" class that can be used to protect wages against inflation or deflation of the
8
+ Argon.
6
9
 
7
10
  ## Installation
8
11
 
@@ -12,13 +15,13 @@ npm install @argonprotocol/mainchain
12
15
 
13
16
  ## Client Usage
14
17
 
15
- To create a client, you can use the `getClient(host)` function in the main module. This will return a client object that
16
- is typed to the argon apis.
18
+ To create a client, you can use the `getClient(host)` function in the main module. This will return
19
+ a client object that is typed to the argon apis.
17
20
 
18
21
  ## Wage Protector
19
22
 
20
- If you want to protect wages against inflation or deflation of the Argon, there is a `WageProtector` class that can be
21
- used. You can use it a single time:
23
+ If you want to protect wages against inflation or deflation of the Argon, there is a `WageProtector`
24
+ class that can be used. You can use it a single time:
22
25
 
23
26
  ```javascript
24
27
  const { WageProtector } = require('@argonprotocol/mainchain');
@@ -32,17 +35,13 @@ Or you can subscribe to changes (for instance, to track a series of valid cpi ad
32
35
  ```javascript
33
36
  const { WageProtector } = require('@argonprotocol/mainchain');
34
37
  const basePrice = 1_000_000n; // 1 Argon
35
- const { unsubscribe } = await WageProtector.subscribe(
36
- client,
37
- protectedPrice => {
38
- console.log(
39
- `Protected price: ${protectedPrice.getProtectedWage(basePrice)}`,
40
- );
41
- },
42
- );
38
+ const { unsubscribe } = await WageProtector.subscribe(client, protectedPrice => {
39
+ console.log(`Protected price: ${protectedPrice.getProtectedWage(basePrice)}`);
40
+ });
43
41
  ```
44
42
 
45
- Each `WageProtector` instance has the details of the Argon Target Price and USD price at the time of creation.
43
+ Each `WageProtector` instance has the details of the Argon Target Price and USD price at the time of
44
+ creation.
46
45
 
47
46
  ```typescript
48
47
  interface IArgonCpiSnapshot {
@@ -61,8 +60,8 @@ interface IArgonCpiSnapshot {
61
60
 
62
61
  The library has a few classes that are used to interact with the Argon Protocol.
63
62
 
64
- `clis` - this is a collection of cli commands and helpers. Included here are two helpers to read and store encrypted
65
- wallets from Polkadot.js or a wallet like [Talisman](https://talisman.xyz/).
63
+ `clis` - this is a collection of cli commands and helpers. Included here are two helpers to read and
64
+ store encrypted wallets from Polkadot.js or a wallet like [Talisman](https://talisman.xyz/).
66
65
 
67
66
  `Accountset.ts` - manage subaccounts from a single keypair
68
67
 
@@ -146,8 +145,8 @@ const { unsubscribe } = await miningBids.onCohortChange({
146
145
 
147
146
  ## Cli
148
147
 
149
- To use this CLI, the easiest way is to define an .env file with the following variables (you can also provide these to
150
- each command).
148
+ To use this CLI, the easiest way is to define an .env file with the following variables (you can
149
+ also provide these to each command).
151
150
 
152
151
  ```env
153
152
  MAINCHAIN_URL=ws://localhost:9944
@@ -160,8 +159,8 @@ KEYS_MNEMONIC=# a mnemonic for the keys to generate
160
159
 
161
160
  ### Setup
162
161
 
163
- To perform actions like `bidding on mining seats`, this cli will need to run for a long period of time. The easiest way
164
- to do so is to install it alongside a full node. This gives you a server that:
162
+ To perform actions like `bidding on mining seats`, this cli will need to run for a long period of
163
+ time. The easiest way to do so is to install it alongside a full node. This gives you a server that:
165
164
 
166
165
  1. Will stay alive.
167
166
  2. Can have signing keys installed without exposing apis.
@@ -179,7 +178,8 @@ Or with an exported Polkadotjs account (eg, from Talisman, Polkadot Extension, e
179
178
  npx @argonprotocol/mainchain accounts create --path=.env.bob --account-file-path=./bob.json --account-passphrase=1234 --register-keys=http://localhost:9944
180
179
  ```
181
180
 
182
- This will register your keys with the local node and serve as your `--env` file for the rest of the commands.
181
+ This will register your keys with the local node and serve as your `--env` file for the rest of the
182
+ commands.
183
183
 
184
184
  ### Exporting PolkadotJs Keys
185
185
 
@@ -190,19 +190,22 @@ You can export encrypted json accounts from Polkadot.js to use in this tool.
190
190
  3. Click on the "Export Account" button.
191
191
  4. Enter a password to encrypt the JSON file.
192
192
  5. Move the file to somewhere accessible from where this tool is run (or to mounted docker volumes).
193
- 6. Ensure your `.env.<account>` file has a relative path to this JSON file and the password you used to encrypt it.
193
+ 6. Ensure your `.env.<account>` file has a relative path to this JSON file and the password you used
194
+ to encrypt it.
194
195
 
195
196
  ### Security Concerns (Bid Proxy Account)
196
197
 
197
- You might find the idea of putting an account on your server with the private key to be too risky. You can optionally
198
- create a proxy account for your bidder script using `npx @argonprotocol/mainchain mining create-bid-proxy`. You will
199
- need to run this from a machine with access to your full account keys (either via export or Polkadotjs directly). This
200
- will create a new `env`account file with the proxy details, which you'll use as your env file for the rest of the
201
- commands. The proxy will only be able to make `bid` calls and will not be able to transfer funds or do anything else
202
- with the account. This is a good way to limit the exposure of your main account keys.
198
+ You might find the idea of putting an account on your server with the private key to be too risky.
199
+ You can optionally create a proxy account for your bidder script using
200
+ `npx @argonprotocol/mainchain mining create-bid-proxy`. You will need to run this from a machine
201
+ with access to your full account keys (either via export or Polkadotjs directly). This will create a
202
+ new `env`account file with the proxy details, which you'll use as your env file for the rest of the
203
+ commands. The proxy will only be able to make `bid` calls and will not be able to transfer funds or
204
+ do anything else with the account. This is a good way to limit the exposure of your main account
205
+ keys.
203
206
 
204
- NOTE: you will still pay fees from your proxy account, so ensure you keep this account loaded up with fees. This is a
205
- major downside to this approach that we are still seeking to solve.
207
+ NOTE: you will still pay fees from your proxy account, so ensure you keep this account loaded up
208
+ with fees. This is a major downside to this approach that we are still seeking to solve.
206
209
 
207
210
  ### Commands
208
211
 
@@ -230,8 +233,8 @@ Commands:
230
233
 
231
234
  ### Example Commands
232
235
 
233
- Create a dynamic bid for a mining seat, maxed at 10 argons per seat. Without a budget, this will use up to 100 argons (
234
- eg, 10 seats).
236
+ Create a dynamic bid for a mining seat, maxed at 10 argons per seat. Without a budget, this will use
237
+ up to 100 argons ( eg, 10 seats).
235
238
 
236
239
  ```bash
237
240
  npx @argonprotocol/mainchain --env=accounts/.env.bob mining bid --min-bid=1 --max-bid=10 --bid-increment=0.1
@@ -239,6 +242,7 @@ npx @argonprotocol/mainchain --env=accounts/.env.bob mining bid --min-bid=1 --ma
239
242
 
240
243
  ### Subaccounts
241
244
 
242
- If you want to work with subaccounts during `consolidate` or setup of an account you can use the `-s, --subaccounts`
243
- flag to specify which subaccount to work with. `-s=0-9` is the default. You can also use `-s=0,1,2` to specify a list of
244
- subaccounts. You can also use `-s=0-2,4` to specify a range and a list of subaccounts.
245
+ If you want to work with subaccounts during `consolidate` or setup of an account you can use the
246
+ `-s, --subaccounts` flag to specify which subaccount to work with. `-s=0-9` is the default. You can
247
+ also use `-s=0,1,2` to specify a list of subaccounts. You can also use `-s=0-2,4` to specify a range
248
+ and a list of subaccounts.