@argonprotocol/mainchain 1.1.0-rc.6 → 1.1.0-rc.8
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 +89 -1
- package/lib/cli.cjs +521 -282
- package/lib/cli.cjs.map +1 -1
- package/lib/cli.js +521 -282
- package/lib/cli.js.map +1 -1
- package/lib/clis/index.cjs +521 -282
- package/lib/clis/index.cjs.map +1 -1
- package/lib/clis/index.d.cts +2 -0
- package/lib/clis/index.d.ts +2 -0
- package/lib/clis/index.js +521 -282
- package/lib/clis/index.js.map +1 -1
- package/lib/index.cjs +488 -262
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +305 -203
- package/lib/index.d.ts +305 -203
- package/lib/index.js +485 -262
- package/lib/index.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -57,6 +57,93 @@ interface IArgonCpiSnapshot {
|
|
|
57
57
|
}
|
|
58
58
|
```
|
|
59
59
|
|
|
60
|
+
## Library Classes
|
|
61
|
+
|
|
62
|
+
The library has a few classes that are used to interact with the Argon Protocol.
|
|
63
|
+
|
|
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/).
|
|
66
|
+
|
|
67
|
+
`Accountset.ts` - manage subaccounts from a single keypair
|
|
68
|
+
|
|
69
|
+
```typescript
|
|
70
|
+
import {
|
|
71
|
+
Accountset,
|
|
72
|
+
getClient,
|
|
73
|
+
type KeyringPair,
|
|
74
|
+
mnemonicGenerate,
|
|
75
|
+
} from '@argonprotocol/mainchain';
|
|
76
|
+
import { keyringFromFile } from '@argonprotocol/mainchain/clis';
|
|
77
|
+
import { existsSync, promises as fs } from 'node:fs';
|
|
78
|
+
|
|
79
|
+
const mnemonicFile = './sessionKeyMnemonic.key';
|
|
80
|
+
// generate keys that are used to sign blocks.
|
|
81
|
+
if (!existsSync(mnemonicFile)) {
|
|
82
|
+
const sessionKeyMnemonic = mnemonicGenerate();
|
|
83
|
+
await fs.writeFile(sessionKeyMnemonic, 'utf8');
|
|
84
|
+
}
|
|
85
|
+
const sessionKeyMnemonic = await fs.readFile(mnemonicFile, 'utf8');
|
|
86
|
+
const seedAccount = await keyringFromFile({
|
|
87
|
+
filePath: '<path to file>',
|
|
88
|
+
passphrase: 'my password',
|
|
89
|
+
});
|
|
90
|
+
const mainchainUrl = 'wss://rpc.argon.network';
|
|
91
|
+
const client = getClient(mainchainUrl);
|
|
92
|
+
this.accountset = new Accountset({
|
|
93
|
+
client,
|
|
94
|
+
seedAccount,
|
|
95
|
+
sessionKeyMnemonic,
|
|
96
|
+
subaccountRange: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
// register your keys on your miner
|
|
100
|
+
await this.accountset.registerKeys(localRpcUrl);
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
`BidPool.ts` - monitor mining bid pools
|
|
104
|
+
|
|
105
|
+
`BitcoinLocks.ts` - wait for bitcoin space, create bitcoin transactions and look up market pricing
|
|
106
|
+
|
|
107
|
+
`CohortBidder.ts` - create a bidding bot
|
|
108
|
+
|
|
109
|
+
```typescript
|
|
110
|
+
import { CohortBidder } from '@argonprotocol/mainchain';
|
|
111
|
+
|
|
112
|
+
// on new bidding
|
|
113
|
+
const subaccounts = await accountset.getAvailableMinerAccounts(5);
|
|
114
|
+
const cohortBidder = new CohortBidder(accountset, cohortId, subaccounts, {
|
|
115
|
+
maxSeats: 5,
|
|
116
|
+
// a budget not to exceed
|
|
117
|
+
maxBudget: 100_000_000,
|
|
118
|
+
// only spend max 1 argon per seat
|
|
119
|
+
maxBid: 1_000_000,
|
|
120
|
+
// start bidding at 0.5 argons
|
|
121
|
+
minBid: 500_000,
|
|
122
|
+
// increment by 0.01 argons each bid
|
|
123
|
+
bidIncrement: 10_000,
|
|
124
|
+
// wait 10 minutes between bids
|
|
125
|
+
bidDelay: 10,
|
|
126
|
+
});
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
`MiningBids.ts` - subscribe to the next bidding cohorts
|
|
130
|
+
|
|
131
|
+
```typescript
|
|
132
|
+
import { MiningBids } from '@argonprotocol/mainchain';
|
|
133
|
+
|
|
134
|
+
const miningBids = new MiningBids(client);
|
|
135
|
+
const { unsubscribe } = await miningBids.onCohortChange({
|
|
136
|
+
async onBiddingStart(cohortId) {
|
|
137
|
+
// ...
|
|
138
|
+
},
|
|
139
|
+
async onBiddingEnd(cohortId) {
|
|
140
|
+
// ...
|
|
141
|
+
},
|
|
142
|
+
});
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
`Vault.ts + VaultMonitor.ts` - watch vaults for available funds/opportunities and calculate fees
|
|
146
|
+
|
|
60
147
|
## Cli
|
|
61
148
|
|
|
62
149
|
To use this CLI, the easiest way is to define an .env file with the following variables (you can also provide these to
|
|
@@ -128,6 +215,7 @@ Options:
|
|
|
128
215
|
--account-file-path <jsonPath> The path to your json seed file from polkadotjs (env: ACCOUNT_JSON_PATH)
|
|
129
216
|
--account-suri <secretUri> A secret uri (suri) to use for the account (env: ACCOUNT_SURI)
|
|
130
217
|
--account-passphrase <password> The password for your seed file (env: ACCOUNT_PASSPHRASE)
|
|
218
|
+
--account-passphrase-file <path> A password for your seed file contained in a file
|
|
131
219
|
-s, --subaccounts <range> Restrict this operation to a subset of the subaccounts (eg, 0-10) (env: SUBACCOUNT_RANGE)
|
|
132
220
|
-h, --help display help for command
|
|
133
221
|
|
|
@@ -146,7 +234,7 @@ Create a dynamic bid for a mining seat, maxed at 10 argons per seat. Without a b
|
|
|
146
234
|
eg, 10 seats).
|
|
147
235
|
|
|
148
236
|
```bash
|
|
149
|
-
npx @argonprotocol/mainchain --env=accounts/.env.bob mining bid --min-
|
|
237
|
+
npx @argonprotocol/mainchain --env=accounts/.env.bob mining bid --min-bid=1 --max-bid=10 --bid-increment=0.1
|
|
150
238
|
```
|
|
151
239
|
|
|
152
240
|
### Subaccounts
|