@argonprotocol/mainchain 1.3.1 → 1.3.3

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.
@@ -56,7 +56,7 @@ var WageProtector = class _WageProtector {
56
56
  new _WageProtector({
57
57
  argonUsdTargetPrice: cpi.value.argonUsdTargetPrice.toBigInt(),
58
58
  argonUsdPrice: cpi.value.argonUsdPrice.toBigInt(),
59
- finalizedBlock: Buffer.from(finalizedBlock),
59
+ finalizedBlock: new Uint8Array(finalizedBlock),
60
60
  tick: cpi.value.tick.toBigInt()
61
61
  })
62
62
  );
@@ -81,9 +81,29 @@ var WageProtector = class _WageProtector {
81
81
  }
82
82
  };
83
83
 
84
+ // src/config.ts
85
+ var config = {};
86
+ function getEnvVar(key) {
87
+ if (typeof process !== "undefined" && process.env) {
88
+ return process.env[key];
89
+ }
90
+ return void 0;
91
+ }
92
+ function setConfig(newConfig) {
93
+ config = { ...config, ...newConfig };
94
+ }
95
+ function getConfig() {
96
+ return {
97
+ debug: config.debug ?? getEnvVar("DEBUG") === "true",
98
+ keysVersion: config.keysVersion ?? (getEnvVar("KEYS_VERSION") ? parseInt(getEnvVar("KEYS_VERSION")) : void 0),
99
+ keysMnemonic: config.keysMnemonic ?? getEnvVar("KEYS_MNEMONIC"),
100
+ subaccountRange: config.subaccountRange ?? getEnvVar("SUBACCOUNT_RANGE") ?? "0-9"
101
+ };
102
+ }
103
+
84
104
  // src/TxSubmitter.ts
85
105
  function logExtrinsicResult(result) {
86
- if (process.env.DEBUG) {
106
+ if (getConfig().debug) {
87
107
  const json = result.status.toJSON();
88
108
  const status = Object.keys(json)[0];
89
109
  console.debug('Transaction update: "%s"', status, json[status]);
@@ -113,8 +133,10 @@ var TxSubmitter = class {
113
133
  return { canAfford, availableBalance, txFee: fees };
114
134
  }
115
135
  async submit(options = {}) {
116
- const { logResults } = options;
136
+ const { logResults, waitForBlock, useLatestNonce, ...apiOptions } = options;
137
+ await waitForLoad();
117
138
  const result = new TxResult(this.client, logResults);
139
+ result.onResultCallback = options.onResultCallback;
118
140
  let toHuman = this.tx.toHuman().method;
119
141
  let txString = [];
120
142
  let api = formatCall(toHuman);
@@ -132,12 +154,12 @@ var TxSubmitter = class {
132
154
  args.push(toHuman.args);
133
155
  }
134
156
  args.unshift(txString.join("->"));
135
- if (options.useLatestNonce && !options.nonce) {
136
- options.nonce = await this.client.rpc.system.accountNextIndex(this.pair.address);
157
+ if (useLatestNonce && !apiOptions.nonce) {
158
+ apiOptions.nonce = await this.client.rpc.system.accountNextIndex(this.pair.address);
137
159
  }
138
- console.log("Submitting transaction:", ...args);
139
- await this.tx.signAndSend(this.pair, options, result.onResult.bind(result));
140
- if (options.waitForBlock) {
160
+ console.log("Submitting transaction from %s:", this.pair.address, ...args);
161
+ await this.tx.signAndSend(this.pair, apiOptions, result.onResult.bind(result));
162
+ if (waitForBlock) {
141
163
  await result.inBlockPromise;
142
164
  }
143
165
  return result;
@@ -180,6 +202,7 @@ var TxResult = class {
180
202
  * The fee tip paid for the transaction.
181
203
  */
182
204
  finalFeeTip;
205
+ onResultCallback;
183
206
  inBlockResolve;
184
207
  inBlockReject;
185
208
  finalizedResolve;
@@ -191,7 +214,7 @@ var TxResult = class {
191
214
  }
192
215
  const { events, status, dispatchError, isFinalized } = result;
193
216
  if (status.isInBlock) {
194
- this.includedInBlock = Buffer.from(status.asInBlock);
217
+ this.includedInBlock = new Uint8Array(status.asInBlock);
195
218
  let encounteredError = dispatchError;
196
219
  let batchErrorIndex;
197
220
  for (const event of events) {
@@ -211,12 +234,13 @@ var TxResult = class {
211
234
  const error = dispatchErrorToExtrinsicError(this.client, encounteredError, batchErrorIndex);
212
235
  this.reject(error);
213
236
  } else {
214
- this.inBlockResolve(Buffer.from(status.asInBlock));
237
+ this.inBlockResolve(new Uint8Array(status.asInBlock));
215
238
  }
216
239
  }
217
240
  if (isFinalized) {
218
241
  this.finalizedResolve(status.asFinalized);
219
242
  }
243
+ this.onResultCallback?.(result);
220
244
  }
221
245
  reject(error) {
222
246
  this.inBlockReject(error);
@@ -226,6 +250,7 @@ var TxResult = class {
226
250
 
227
251
  // src/utils.ts
228
252
  import BigNumber, * as BN from "bignumber.js";
253
+ import { hexToU8a } from "@polkadot/util";
229
254
  var { ROUND_FLOOR } = BN;
230
255
  var MICROGONS_PER_ARGON = 1e6;
231
256
  function formatArgons(x) {
@@ -271,10 +296,11 @@ async function gettersToObject(obj) {
271
296
  }
272
297
  return result;
273
298
  }
274
- function toFixedNumber(value, base) {
275
- const decimalFactor = new BigNumber(10).pow(base);
276
- const rawValue = new BigNumber(value.toString());
277
- return BigInt(rawValue.times(decimalFactor).toFixed(0, ROUND_FLOOR));
299
+ function toFixedNumber(value, decimals) {
300
+ const factor = new BigNumber(10).pow(decimals);
301
+ const bn = new BigNumber(value);
302
+ const int = bn.times(factor).integerValue(BigNumber.ROUND_DOWN);
303
+ return BigInt(int.toFixed(0));
278
304
  }
279
305
  function convertNumberToFixedU128(value) {
280
306
  return toFixedNumber(value, 18);
@@ -356,8 +382,12 @@ var JsonExt = class {
356
382
  if (typeof v === "bigint") {
357
383
  return `${v}n`;
358
384
  }
359
- if (Buffer.isBuffer(v)) {
360
- return Buffer.from(v).toJSON();
385
+ if (v instanceof Uint8Array) {
386
+ return {
387
+ type: "Buffer",
388
+ data: Array.from(v)
389
+ // Convert Uint8Array to an array of numbers
390
+ };
361
391
  }
362
392
  return v;
363
393
  },
@@ -370,7 +400,7 @@ var JsonExt = class {
370
400
  return BigInt(v.slice(0, -1));
371
401
  }
372
402
  if (typeof v === "object" && v !== null && v.type === "Buffer" && Array.isArray(v.data)) {
373
- return Buffer.from(v.data);
403
+ return hexToU8a(v.data);
374
404
  }
375
405
  return v;
376
406
  });
@@ -412,9 +442,6 @@ var AccountRegistry = class _AccountRegistry {
412
442
  static factory = (name) => new _AccountRegistry(name);
413
443
  };
414
444
 
415
- // src/Accountset.ts
416
- import * as process2 from "node:process";
417
-
418
445
  // src/BlockWatch.ts
419
446
  function getTickFromHeader(client, header) {
420
447
  for (const x of header.digest.logs) {
@@ -628,13 +655,13 @@ var FrameCalculator = class {
628
655
  slotBiddingStartAfterTicks: x.slotBiddingStartAfterTicks.toNumber()
629
656
  }));
630
657
  this.genesisTick ??= await client.query.ticks.genesisTick().then((x) => x.toNumber());
631
- const config = this.miningConfig;
658
+ const config2 = this.miningConfig;
632
659
  const genesisTick = this.genesisTick;
633
660
  return {
634
- ticksBetweenFrames: config.ticksBetweenSlots,
635
- slotBiddingStartAfterTicks: config.slotBiddingStartAfterTicks,
661
+ ticksBetweenFrames: config2.ticksBetweenSlots,
662
+ slotBiddingStartAfterTicks: config2.slotBiddingStartAfterTicks,
636
663
  genesisTick,
637
- biddingStartTick: genesisTick + config.slotBiddingStartAfterTicks
664
+ biddingStartTick: genesisTick + config2.slotBiddingStartAfterTicks
638
665
  };
639
666
  }
640
667
  };
@@ -645,10 +672,10 @@ var AccountMiners = class _AccountMiners {
645
672
  this.accountset = accountset;
646
673
  this.options = options;
647
674
  this.frameCalculator = new FrameCalculator();
648
- for (const seat of registeredMiners) {
649
- this.trackedAccountsByAddress[seat.address] = {
650
- startingFrameId: seat.startingFrameId,
651
- subaccountIndex: seat.subaccountIndex
675
+ for (const miner of registeredMiners) {
676
+ this.trackedAccountsByAddress[miner.address] = {
677
+ startingFrameId: miner.seat.startingFrameId,
678
+ subaccountIndex: miner.subaccountIndex
652
679
  };
653
680
  }
654
681
  }
@@ -760,6 +787,7 @@ var AccountMiners = class _AccountMiners {
760
787
  };
761
788
 
762
789
  // src/Accountset.ts
790
+ import { u8aToHex } from "@polkadot/util";
763
791
  var Accountset = class {
764
792
  txSubmitterPair;
765
793
  isProxy = false;
@@ -882,7 +910,7 @@ var Accountset = class {
882
910
  const index = indexRaw.toNumber();
883
911
  const bidAmount = bidAmountsByFrame[frameId]?.[index];
884
912
  addressToMiningIndex[address] = {
885
- frameId,
913
+ startingFrameId: frameId,
886
914
  index,
887
915
  bidAmount: bidAmount ?? 0n
888
916
  };
@@ -892,7 +920,7 @@ var Accountset = class {
892
920
  const cohort = addressToMiningIndex[address];
893
921
  let isLastDay = false;
894
922
  if (cohort !== void 0) {
895
- isLastDay = nextFrameId.toNumber() - cohort.frameId === 10;
923
+ isLastDay = nextFrameId.toNumber() - cohort.startingFrameId === 10;
896
924
  }
897
925
  return {
898
926
  address,
@@ -1021,11 +1049,9 @@ var Accountset = class {
1021
1049
  await client.disconnect();
1022
1050
  }
1023
1051
  keys(keysVersion) {
1024
- let version = keysVersion ?? 0;
1025
- if (process2.env.KEYS_VERSION) {
1026
- version = parseInt(process2.env.KEYS_VERSION) ?? 0;
1027
- }
1028
- const seedMnemonic = this.sessionKeyMnemonic ?? process2.env.KEYS_MNEMONIC;
1052
+ const config2 = getConfig();
1053
+ let version = keysVersion ?? config2.keysVersion ?? 0;
1054
+ const seedMnemonic = this.sessionKeyMnemonic ?? config2.keysMnemonic;
1029
1055
  if (!seedMnemonic) {
1030
1056
  throw new Error("KEYS_MNEMONIC environment variable not set. Cannot derive keys.");
1031
1057
  }
@@ -1040,12 +1066,12 @@ var Accountset = class {
1040
1066
  return {
1041
1067
  seal: {
1042
1068
  privateKey: blockSealKey,
1043
- publicKey: `0x${Buffer.from(blockSealAccount.publicKey).toString("hex")}`,
1069
+ publicKey: u8aToHex(blockSealAccount.publicKey),
1044
1070
  rawPublicKey: blockSealAccount.publicKey
1045
1071
  },
1046
1072
  gran: {
1047
1073
  privateKey: granKey,
1048
- publicKey: `0x${Buffer.from(grandpaAccount.publicKey).toString("hex")}`,
1074
+ publicKey: u8aToHex(grandpaAccount.publicKey),
1049
1075
  rawPublicKey: grandpaAccount.publicKey
1050
1076
  }
1051
1077
  };
@@ -1148,10 +1174,11 @@ var Accountset = class {
1148
1174
  };
1149
1175
  function getDefaultSubaccountRange() {
1150
1176
  try {
1151
- return parseSubaccountRange(process2.env.SUBACCOUNT_RANGE ?? "0-9");
1177
+ const config2 = getConfig();
1178
+ return parseSubaccountRange(config2.subaccountRange ?? "0-9");
1152
1179
  } catch {
1153
1180
  console.error(
1154
- "Failed to parse SUBACCOUNT_RANGE environment variable. Defaulting to 0-9. Please check the format of the SUBACCOUNT_RANGE variable."
1181
+ "Failed to parse SUBACCOUNT_RANGE configuration. Defaulting to 0-9. Please check the format of the subaccountRange config value."
1155
1182
  );
1156
1183
  return Array.from({ length: 10 }, (_, i) => i);
1157
1184
  }
@@ -1190,7 +1217,7 @@ var MiningBids = class {
1190
1217
  nextCohort = [];
1191
1218
  async maxCohortSize() {
1192
1219
  const client = await this.client;
1193
- return client.consts.miningSlot.maxCohortSize.toNumber();
1220
+ return client.query.miningSlot.nextCohortSize().then((x) => x.toNumber());
1194
1221
  }
1195
1222
  async onCohortChange(options) {
1196
1223
  const { onBiddingStart, onBiddingEnd } = options;
@@ -1265,10 +1292,30 @@ var MiningBids = class {
1265
1292
  // src/Vault.ts
1266
1293
  import BigNumber2, * as BN2 from "bignumber.js";
1267
1294
  import bs58check from "bs58check";
1295
+ import { hexToU8a as hexToU8a2 } from "@polkadot/util";
1268
1296
  var { ROUND_FLOOR: ROUND_FLOOR2 } = BN2;
1269
1297
  var Vault = class _Vault {
1270
1298
  constructor(id, vault, tickDuration) {
1271
1299
  this.tickDuration = tickDuration;
1300
+ this.vaultId = id;
1301
+ this.load(vault);
1302
+ this.openedTick = vault.openedTick.toNumber();
1303
+ this.openedDate = new Date(this.openedTick * this.tickDuration);
1304
+ }
1305
+ securitization;
1306
+ securitizationRatio;
1307
+ argonsLocked;
1308
+ argonsPendingActivation;
1309
+ argonsScheduledForRelease = /* @__PURE__ */ new Map();
1310
+ terms;
1311
+ operatorAccountId;
1312
+ isClosed;
1313
+ vaultId;
1314
+ pendingTerms;
1315
+ pendingTermsChangeTick;
1316
+ openedDate;
1317
+ openedTick;
1318
+ load(vault) {
1272
1319
  this.securitization = vault.securitization.toBigInt();
1273
1320
  this.securitizationRatio = convertFixedU128ToBigNumber(vault.securitizationRatio.toBigInt());
1274
1321
  this.argonsLocked = vault.argonsLocked.toBigInt();
@@ -1290,7 +1337,6 @@ var Vault = class _Vault {
1290
1337
  };
1291
1338
  this.operatorAccountId = vault.operatorAccountId.toString();
1292
1339
  this.isClosed = vault.isClosed.valueOf();
1293
- this.vaultId = id;
1294
1340
  if (vault.pendingTerms.isSome) {
1295
1341
  const [tickApply, terms] = vault.pendingTerms.value;
1296
1342
  this.pendingTermsChangeTick = tickApply.toNumber();
@@ -1304,22 +1350,7 @@ var Vault = class _Vault {
1304
1350
  )
1305
1351
  };
1306
1352
  }
1307
- this.openedTick = vault.openedTick.toNumber();
1308
- this.openedDate = new Date(this.openedTick * tickDuration);
1309
1353
  }
1310
- securitization;
1311
- securitizationRatio;
1312
- argonsLocked;
1313
- argonsPendingActivation;
1314
- argonsScheduledForRelease = /* @__PURE__ */ new Map();
1315
- terms;
1316
- operatorAccountId;
1317
- isClosed;
1318
- vaultId;
1319
- pendingTerms;
1320
- pendingTermsChangeTick;
1321
- openedDate;
1322
- openedTick;
1323
1354
  availableBitcoinSpace() {
1324
1355
  const recoverySecuritization = this.recoverySecuritization();
1325
1356
  const reLockable = this.getRelockCapacity();
@@ -1356,48 +1387,83 @@ var Vault = class _Vault {
1356
1387
  const fee = this.terms.bitcoinAnnualPercentRate.multipliedBy(Number(amount)).integerValue(BigNumber2.ROUND_CEIL);
1357
1388
  return BigInt(fee.toString()) + this.terms.bitcoinBaseFee;
1358
1389
  }
1359
- static async get(client, vaultId) {
1390
+ static async get(client, vaultId, tickDurationMillis) {
1360
1391
  const rawVault = await client.query.vaults.vaultsById(vaultId);
1361
1392
  if (rawVault.isNone) {
1362
1393
  throw new Error(`Vault with id ${vaultId} not found`);
1363
1394
  }
1364
- const tickDuration = await client.query.ticks.genesisTicker().then((x) => x.tickDurationMillis.toNumber());
1395
+ const tickDuration = tickDurationMillis ?? await client.query.ticks.genesisTicker().then((x) => x.tickDurationMillis.toNumber());
1365
1396
  return new _Vault(vaultId, rawVault.unwrap(), tickDuration);
1366
1397
  }
1367
- static async create(client, keypair, args, config = {}) {
1368
- const { securitization, securitizationRatio, annualPercentRate, baseFee, bitcoinXpub, tip } = args;
1369
- let xpubBytes = Buffer.from(bitcoinXpub, "hex");
1398
+ static async create(client, keypair, args, config2 = {}) {
1399
+ const {
1400
+ securitization,
1401
+ securitizationRatio,
1402
+ annualPercentRate,
1403
+ baseFee,
1404
+ bitcoinXpub,
1405
+ tip,
1406
+ doNotExceedBalance,
1407
+ progressCallback
1408
+ } = args;
1409
+ let xpubBytes = hexToU8a2(bitcoinXpub);
1370
1410
  if (xpubBytes.length !== 78) {
1371
1411
  if (bitcoinXpub.startsWith("xpub") || bitcoinXpub.startsWith("tpub") || bitcoinXpub.startsWith("zpub")) {
1372
1412
  const bytes = bs58check.decode(bitcoinXpub);
1373
1413
  if (bytes.length !== 78) {
1374
1414
  throw new Error("Invalid Bitcoin xpub key length, must be 78 bytes");
1375
1415
  }
1376
- xpubBytes = Buffer.from(bytes);
1416
+ xpubBytes = bytes;
1417
+ }
1418
+ }
1419
+ let vaultParams = {
1420
+ terms: {
1421
+ // convert to fixed u128
1422
+ bitcoinAnnualPercentRate: toFixedNumber(annualPercentRate, 18),
1423
+ bitcoinBaseFee: BigInt(baseFee),
1424
+ liquidityPoolProfitSharing: toFixedNumber(args.liquidityPoolProfitSharing, 6)
1425
+ },
1426
+ securitizationRatio: toFixedNumber(securitizationRatio, 18),
1427
+ securitization: BigInt(securitization),
1428
+ bitcoinXpubkey: xpubBytes
1429
+ };
1430
+ let tx = new TxSubmitter(client, client.tx.vaults.create(vaultParams), keypair);
1431
+ if (doNotExceedBalance) {
1432
+ const finalTip = tip ?? 0n;
1433
+ let txFee = await tx.feeEstimate(finalTip);
1434
+ while (txFee + finalTip + vaultParams.securitization > doNotExceedBalance) {
1435
+ vaultParams.securitization = doNotExceedBalance - txFee - finalTip;
1436
+ tx.tx = client.tx.vaults.create(vaultParams);
1437
+ txFee = await tx.feeEstimate(finalTip);
1377
1438
  }
1378
1439
  }
1379
- const tx = new TxSubmitter(
1380
- client,
1381
- client.tx.vaults.create({
1382
- terms: {
1383
- // convert to fixed u128
1384
- bitcoinAnnualPercentRate: toFixedNumber(annualPercentRate, 18),
1385
- bitcoinBaseFee: BigInt(baseFee),
1386
- liquidityPoolProfitSharing: toFixedNumber(args.liquidityPoolProfitSharing, 6)
1387
- },
1388
- securitizationRatio: toFixedNumber(securitizationRatio, 18),
1389
- securitization: BigInt(securitization),
1390
- bitcoinXpubkey: xpubBytes
1391
- }),
1392
- keypair
1393
- );
1394
1440
  const canAfford = await tx.canAfford({ tip, unavailableBalance: BigInt(securitization) });
1395
1441
  if (!canAfford.canAfford) {
1396
1442
  throw new Error(
1397
1443
  `Insufficient balance to create vault. Required: ${formatArgons(securitization)}, Available: ${formatArgons(canAfford.availableBalance)}`
1398
1444
  );
1399
1445
  }
1400
- const result = await tx.submit({ waitForBlock: true, tip });
1446
+ const result = await tx.submit({
1447
+ tip,
1448
+ useLatestNonce: true,
1449
+ waitForBlock: true,
1450
+ onResultCallback(result2) {
1451
+ let percent = 0;
1452
+ if (result2.status.isInvalid || result2.status.isDropped || result2.status.isUsurped || result2.status.isRetracted) {
1453
+ percent = 1;
1454
+ } else if (result2.status.isReady) {
1455
+ percent = 0;
1456
+ } else if (result2.status.isBroadcast) {
1457
+ percent = 0.5;
1458
+ } else if (result2.status.isInBlock) {
1459
+ percent = 1;
1460
+ } else if (result2.status.isFinalized) {
1461
+ percent = 1.1;
1462
+ }
1463
+ progressCallback?.(percent, result2.status);
1464
+ }
1465
+ });
1466
+ await result.inBlockPromise;
1401
1467
  let vaultId;
1402
1468
  for (const event of result.events) {
1403
1469
  if (client.events.vaults.VaultCreated.is(event)) {
@@ -1412,8 +1478,9 @@ var Vault = class _Vault {
1412
1478
  if (rawVault.isNone) {
1413
1479
  throw new Error("Vault creation failed, vault not found");
1414
1480
  }
1415
- const tickDuration = config.tickDurationMillis ?? await client.query.ticks.genesisTicker().then((x) => x.tickDurationMillis.toNumber());
1416
- return new _Vault(vaultId, rawVault.unwrap(), tickDuration);
1481
+ const tickDuration = config2.tickDurationMillis ?? await client.query.ticks.genesisTicker().then((x) => x.tickDurationMillis.toNumber());
1482
+ const vault = new _Vault(vaultId, rawVault.unwrap(), tickDuration);
1483
+ return { vault, txResult: result };
1417
1484
  }
1418
1485
  };
1419
1486
 
@@ -1465,7 +1532,7 @@ var VaultMonitor = class {
1465
1532
  const client = await this.mainchain;
1466
1533
  this.tickDuration = (await client.query.ticks.genesisTicker()).tickDurationMillis.toNumber();
1467
1534
  const blockHeader = await client.rpc.chain.getHeader();
1468
- const blockHash = Buffer.from(blockHeader.hash);
1535
+ const blockHash = new Uint8Array(blockHeader.hash);
1469
1536
  console.log(
1470
1537
  `${justPrint ? "Run" : "Started"} at block ${blockHeader.number} - ${blockHeader.hash.toHuman()}`
1471
1538
  );
@@ -1590,143 +1657,6 @@ var VaultMonitor = class {
1590
1657
  }
1591
1658
  };
1592
1659
 
1593
- // src/CohortBidderHistory.ts
1594
- var CohortBidderHistory = class _CohortBidderHistory {
1595
- constructor(cohortStartingFrameId, subaccounts) {
1596
- this.cohortStartingFrameId = cohortStartingFrameId;
1597
- this.subaccounts = subaccounts;
1598
- this.maxSeatsInPlay = this.subaccounts.length;
1599
- this.subaccounts.forEach((x) => {
1600
- this.myAddresses.add(x.address);
1601
- });
1602
- }
1603
- bidHistory = [];
1604
- stats = {
1605
- // number of seats won
1606
- seatsWon: 0,
1607
- // sum of argons bid in successful bids
1608
- totalArgonsBid: 0n,
1609
- // total number of bids placed (includes 1 per seat)
1610
- bidsAttempted: 0,
1611
- // fees including the tip
1612
- fees: 0n,
1613
- // Max bid per seat
1614
- maxBidPerSeat: 0n,
1615
- // The cost in argonots of each seat
1616
- argonotsPerSeat: 0n,
1617
- // The argonot price in USD for cost basis
1618
- argonotUsdPrice: 0,
1619
- // The cohort expected argons per block
1620
- cohortArgonsPerBlock: 0n,
1621
- // The last block that bids are synced to
1622
- lastBlockNumber: 0
1623
- };
1624
- lastBids = [];
1625
- myAddresses = /* @__PURE__ */ new Set();
1626
- maxSeatsInPlay = 0;
1627
- async init(client) {
1628
- if (!this.stats.argonotsPerSeat) {
1629
- const startingStats = await _CohortBidderHistory.getStartingData(client);
1630
- Object.assign(this.stats, startingStats);
1631
- }
1632
- }
1633
- maybeReducingSeats(maxSeats, reason, historyEntry) {
1634
- if (this.maxSeatsInPlay > maxSeats) {
1635
- historyEntry.maxSeatsReductionReason = reason;
1636
- }
1637
- this.maxSeatsInPlay = maxSeats;
1638
- historyEntry.maxSeatsInPlay = maxSeats;
1639
- }
1640
- trackChange(next, blockNumber, tick, isLastEntry = false) {
1641
- let winningBids = 0;
1642
- let totalArgonsBid = 0n;
1643
- const nextEntrants = [];
1644
- for (const x of next) {
1645
- const bid = x.bid.toBigInt();
1646
- const address = x.accountId.toHuman();
1647
- nextEntrants.push({ address, bid });
1648
- if (this.myAddresses.has(address)) {
1649
- winningBids++;
1650
- totalArgonsBid += bid;
1651
- }
1652
- }
1653
- this.stats.seatsWon = winningBids;
1654
- this.stats.totalArgonsBid = totalArgonsBid;
1655
- this.stats.lastBlockNumber = Math.max(blockNumber, this.stats.lastBlockNumber);
1656
- const historyEntry = {
1657
- cohortStartingFrameId: this.cohortStartingFrameId,
1658
- blockNumber,
1659
- tick,
1660
- bidChanges: [],
1661
- winningSeats: winningBids,
1662
- maxSeatsInPlay: this.maxSeatsInPlay
1663
- };
1664
- const hasDiffs = JsonExt.stringify(nextEntrants) !== JsonExt.stringify(this.lastBids);
1665
- if (!isLastEntry || hasDiffs) {
1666
- this.bidHistory.unshift(historyEntry);
1667
- }
1668
- if (hasDiffs) {
1669
- nextEntrants.forEach(({ address, bid }, i) => {
1670
- const prevBidIndex = this.lastBids.findIndex((y) => y.address === address);
1671
- const entry = {
1672
- address,
1673
- bidAmount: bid,
1674
- bidPosition: i,
1675
- prevPosition: prevBidIndex === -1 ? null : prevBidIndex
1676
- };
1677
- if (prevBidIndex !== -1) {
1678
- const prevBidAmount = this.lastBids[prevBidIndex].bid;
1679
- if (prevBidAmount !== bid) {
1680
- entry.prevBidAmount = prevBidAmount;
1681
- }
1682
- }
1683
- historyEntry.bidChanges.push(entry);
1684
- });
1685
- this.lastBids.forEach(({ address, bid }, i) => {
1686
- const nextBid = nextEntrants.some((y) => y.address === address);
1687
- if (!nextBid) {
1688
- historyEntry.bidChanges.push({
1689
- address,
1690
- bidAmount: bid,
1691
- bidPosition: null,
1692
- prevPosition: i
1693
- });
1694
- }
1695
- });
1696
- this.lastBids = nextEntrants;
1697
- }
1698
- return historyEntry;
1699
- }
1700
- onBidResult(historyEntry, param) {
1701
- const { txFeePlusTip, bidPerSeat, bidsAttempted, successfulBids, blockNumber, bidError } = param;
1702
- this.stats.fees += txFeePlusTip;
1703
- this.stats.bidsAttempted += bidsAttempted;
1704
- if (bidPerSeat > this.stats.maxBidPerSeat) {
1705
- this.stats.maxBidPerSeat = bidPerSeat;
1706
- }
1707
- if (blockNumber !== void 0) {
1708
- this.stats.lastBlockNumber = Math.max(blockNumber, this.stats.lastBlockNumber);
1709
- }
1710
- if (historyEntry.myBidsPlaced) {
1711
- historyEntry.myBidsPlaced.failureReason = bidError;
1712
- historyEntry.myBidsPlaced.successfulBids = successfulBids;
1713
- historyEntry.myBidsPlaced.txFeePlusTip = txFeePlusTip;
1714
- }
1715
- }
1716
- static async getStartingData(api) {
1717
- const argonotPrice = await api.query.priceIndex.current();
1718
- let argonotUsdPrice = 0;
1719
- if (argonotPrice.isSome) {
1720
- argonotUsdPrice = convertFixedU128ToBigNumber(
1721
- argonotPrice.unwrap().argonotUsdPrice.toBigInt()
1722
- ).toNumber();
1723
- }
1724
- const argonotsPerSeat = await api.query.miningSlot.argonotsPerMiningSeat().then((x) => x.toBigInt());
1725
- const cohortArgonsPerBlock = await api.query.blockRewards.argonsPerBlock().then((x) => x.toBigInt());
1726
- return { argonotsPerSeat, argonotUsdPrice, cohortArgonsPerBlock };
1727
- }
1728
- };
1729
-
1730
1660
  // src/CohortBidder.ts
1731
1661
  var CohortBidder = class {
1732
1662
  constructor(accountset, cohortStartingFrameId, subaccounts, options) {
@@ -1734,7 +1664,6 @@ var CohortBidder = class {
1734
1664
  this.cohortStartingFrameId = cohortStartingFrameId;
1735
1665
  this.subaccounts = subaccounts;
1736
1666
  this.options = options;
1737
- this.history = new CohortBidderHistory(cohortStartingFrameId, subaccounts);
1738
1667
  this.subaccounts.forEach((x) => {
1739
1668
  this.myAddresses.add(x.address);
1740
1669
  });
@@ -1742,23 +1671,52 @@ var CohortBidder = class {
1742
1671
  get client() {
1743
1672
  return this.accountset.client;
1744
1673
  }
1745
- get stats() {
1746
- return this.history.stats;
1747
- }
1748
- get bidHistory() {
1749
- return this.history.bidHistory;
1750
- }
1674
+ txFees = 0n;
1675
+ winningBids = [];
1751
1676
  unsubscribe;
1752
1677
  pendingRequest;
1753
1678
  retryTimeout;
1754
1679
  isStopped = false;
1755
1680
  needsRebid = false;
1756
1681
  lastBidTime = 0;
1757
- history;
1758
1682
  millisPerTick;
1683
+ minIncrement = 10000n;
1684
+ nextCohortSize;
1685
+ lastBidBlockNumber = 0;
1759
1686
  myAddresses = /* @__PURE__ */ new Set();
1687
+ async start() {
1688
+ console.log(`Starting cohort ${this.cohortStartingFrameId} bidder`, {
1689
+ maxBid: formatArgons(this.options.maxBid),
1690
+ minBid: formatArgons(this.options.minBid),
1691
+ bidIncrement: formatArgons(this.options.bidIncrement),
1692
+ maxBudget: formatArgons(this.options.maxBudget),
1693
+ bidDelay: this.options.bidDelay,
1694
+ subaccounts: this.subaccounts
1695
+ });
1696
+ const client = await this.client;
1697
+ this.minIncrement = client.consts.miningSlot.bidIncrements.toBigInt();
1698
+ this.nextCohortSize = await client.query.miningSlot.nextCohortSize().then((x) => x.toNumber());
1699
+ if (this.subaccounts.length > this.nextCohortSize) {
1700
+ console.info(
1701
+ `Cohort size ${this.nextCohortSize} is less than provided subaccounts ${this.subaccounts.length}.`
1702
+ );
1703
+ this.subaccounts.length = this.nextCohortSize;
1704
+ }
1705
+ this.millisPerTick = await client.query.ticks.genesisTicker().then((x) => x.tickDurationMillis.toNumber());
1706
+ this.unsubscribe = await client.queryMulti(
1707
+ [
1708
+ client.query.miningSlot.bidsForNextSlotCohort,
1709
+ client.query.miningSlot.nextFrameId
1710
+ ],
1711
+ async ([bids, nextFrameId]) => {
1712
+ if (nextFrameId.toNumber() === this.cohortStartingFrameId) {
1713
+ await this.checkWinningBids(bids);
1714
+ }
1715
+ }
1716
+ );
1717
+ }
1760
1718
  async stop() {
1761
- if (this.isStopped) return this.stats;
1719
+ if (this.isStopped) return this.winningBids;
1762
1720
  this.isStopped = true;
1763
1721
  console.log("Stopping bidder for cohort", this.cohortStartingFrameId);
1764
1722
  clearTimeout(this.retryTimeout);
@@ -1783,79 +1741,47 @@ var CohortBidder = class {
1783
1741
  }
1784
1742
  void await this.pendingRequest;
1785
1743
  let header = await client.rpc.chain.getHeader();
1744
+ let api = await client.at(header.hash);
1786
1745
  while (true) {
1787
- const api2 = await client.at(header.hash);
1788
- const cohortStartingFrameId = await api2.query.miningSlot.nextFrameId();
1746
+ const cohortStartingFrameId = await api.query.miningSlot.nextFrameId();
1789
1747
  if (cohortStartingFrameId.toNumber() === this.cohortStartingFrameId) {
1790
1748
  break;
1791
1749
  }
1792
1750
  header = await client.rpc.chain.getHeader(header.parentHash);
1751
+ api = await client.at(header.hash);
1793
1752
  }
1794
- const api = await client.at(header.hash);
1795
- const tick = await api.query.ticks.currentTick().then((x) => x.toNumber());
1796
1753
  const bids = await api.query.miningSlot.bidsForNextSlotCohort();
1797
- this.history.trackChange(bids, header.number.toNumber(), tick, true);
1754
+ this.updateSeatsWon(bids);
1798
1755
  console.log("Bidder stopped", {
1799
1756
  cohortStartingFrameId: this.cohortStartingFrameId,
1800
1757
  blockNumber: header.number.toNumber(),
1801
- tick,
1802
- bids: bids.map((x) => ({
1803
- address: x.accountId.toHuman(),
1804
- bid: x.bid.toBigInt()
1805
- }))
1758
+ bids: this.winningBids
1806
1759
  });
1807
- return this.stats;
1808
- }
1809
- async start() {
1810
- console.log(`Starting cohort ${this.cohortStartingFrameId} bidder`, {
1811
- maxBid: formatArgons(this.options.maxBid),
1812
- minBid: formatArgons(this.options.minBid),
1813
- bidIncrement: formatArgons(this.options.bidIncrement),
1814
- maxBudget: formatArgons(this.options.maxBudget),
1815
- bidDelay: this.options.bidDelay,
1816
- subaccounts: this.subaccounts
1817
- });
1818
- const client = await this.client;
1819
- await this.history.init(client);
1820
- this.millisPerTick ??= await client.query.ticks.genesisTicker().then((x) => x.tickDurationMillis.toNumber());
1821
- this.unsubscribe = await client.queryMulti(
1822
- [
1823
- client.query.miningSlot.bidsForNextSlotCohort,
1824
- client.query.miningSlot.nextFrameId
1825
- ],
1826
- async ([bids, nextFrameId]) => {
1827
- if (nextFrameId.toNumber() === this.cohortStartingFrameId) {
1828
- await this.checkWinningBids(bids);
1829
- }
1830
- }
1831
- );
1760
+ return this.winningBids;
1832
1761
  }
1833
1762
  async checkWinningBids(bids) {
1834
1763
  if (this.isStopped) return;
1835
1764
  clearTimeout(this.retryTimeout);
1765
+ this.updateSeatsWon(bids);
1766
+ const winningBids = this.winningBids.length;
1767
+ this.needsRebid = winningBids < this.subaccounts.length;
1836
1768
  const client = await this.client;
1837
1769
  const bestBlock = await client.rpc.chain.getBlockHash();
1838
1770
  const api = await client.at(bestBlock);
1839
1771
  const blockNumber = await api.query.system.number().then((x) => x.toNumber());
1840
- if (this.bidHistory[0]?.blockNumber >= blockNumber) {
1841
- return;
1842
- }
1843
- const tick = await api.query.ticks.currentTick().then((x) => x.toNumber());
1844
- const historyEntry = this.history.trackChange(bids, blockNumber, tick);
1772
+ if (this.lastBidBlockNumber >= blockNumber) return;
1845
1773
  if (this.pendingRequest) return;
1846
1774
  const ticksSinceLastBid = Math.floor((Date.now() - this.lastBidTime) / this.millisPerTick);
1847
- if (ticksSinceLastBid < this.options.bidDelay) {
1775
+ if (ticksSinceLastBid < this.options.bidDelay && this.needsRebid) {
1848
1776
  this.retryTimeout = setTimeout(() => void this.checkCurrentSeats(), this.millisPerTick);
1849
1777
  return;
1850
1778
  }
1779
+ if (!this.needsRebid) return;
1851
1780
  console.log(
1852
1781
  "Checking bids for cohort",
1853
1782
  this.cohortStartingFrameId,
1854
1783
  this.subaccounts.map((x) => x.index)
1855
1784
  );
1856
- const winningBids = historyEntry.winningSeats;
1857
- this.needsRebid = winningBids < this.subaccounts.length;
1858
- if (!this.needsRebid) return;
1859
1785
  const winningAddresses = new Set(bids.map((x) => x.accountId.toHuman()));
1860
1786
  let lowestBid = -this.options.bidIncrement;
1861
1787
  if (bids.length) {
@@ -1866,7 +1792,6 @@ var CohortBidder = class {
1866
1792
  }
1867
1793
  }
1868
1794
  }
1869
- const MIN_INCREMENT = 10000n;
1870
1795
  let nextBid = lowestBid + this.options.bidIncrement;
1871
1796
  if (nextBid < this.options.minBid) {
1872
1797
  nextBid = this.options.minBid;
@@ -1895,10 +1820,9 @@ var CohortBidder = class {
1895
1820
  console.log(
1896
1821
  `Can't bid ${formatArgons(nextBid)}. Current lowest bid is ${formatArgons(lowestBid)}.`
1897
1822
  );
1898
- this.history.maybeReducingSeats(winningBids, "MaxBidTooLow" /* MaxBidTooLow */, historyEntry);
1899
1823
  return;
1900
1824
  }
1901
- if (nextBid - lowestBid < MIN_INCREMENT) {
1825
+ if (nextBid - lowestBid < Number(this.minIncrement)) {
1902
1826
  console.log(
1903
1827
  `Can't make any more bids for ${this.cohortStartingFrameId} with given constraints.`,
1904
1828
  {
@@ -1907,14 +1831,11 @@ var CohortBidder = class {
1907
1831
  maxBid: formatArgons(this.options.maxBid)
1908
1832
  }
1909
1833
  );
1910
- this.history.maybeReducingSeats(winningBids, "MaxBidTooLow" /* MaxBidTooLow */, historyEntry);
1911
1834
  return;
1912
1835
  }
1913
1836
  const seatsInBudget = nextBid === 0n ? this.subaccounts.length : Number(budgetForSeats / nextBid);
1914
1837
  let accountsToUse = [...this.subaccounts];
1915
1838
  if (accountsToUse.length > seatsInBudget) {
1916
- const reason = availableBalanceForBids - feePlusTip < nextBid * BigInt(seatsInBudget) ? "InsufficientFunds" /* InsufficientFunds */ : "MaxBudgetTooLow" /* MaxBudgetTooLow */;
1917
- this.history.maybeReducingSeats(seatsInBudget, reason, historyEntry);
1918
1839
  accountsToUse.sort((a, b) => {
1919
1840
  const isWinningA = winningAddresses.has(a.address);
1920
1841
  const isWinningB = winningAddresses.has(b.address);
@@ -1927,19 +1848,11 @@ var CohortBidder = class {
1927
1848
  accountsToUse.length = seatsInBudget;
1928
1849
  }
1929
1850
  if (accountsToUse.length > winningBids) {
1930
- historyEntry.myBidsPlaced = {
1931
- bids: accountsToUse.length,
1932
- bidPerSeat: nextBid,
1933
- txFeePlusTip: feePlusTip,
1934
- successfulBids: 0
1935
- };
1936
- this.pendingRequest = this.bid(nextBid, accountsToUse, historyEntry);
1937
- } else if (historyEntry.bidChanges.length === 0) {
1938
- this.history.bidHistory.shift();
1851
+ this.pendingRequest = this.bid(nextBid, accountsToUse);
1939
1852
  }
1940
1853
  this.needsRebid = false;
1941
1854
  }
1942
- async bid(bidPerSeat, subaccounts, historyEntry) {
1855
+ async bid(bidPerSeat, subaccounts) {
1943
1856
  const prevLastBidTime = this.lastBidTime;
1944
1857
  try {
1945
1858
  this.lastBidTime = Date.now();
@@ -1960,14 +1873,10 @@ var CohortBidder = class {
1960
1873
  blockNumber = await api.query.system.number().then((x) => x.toNumber());
1961
1874
  }
1962
1875
  const successfulBids = txResult.batchInterruptedIndex ?? subaccounts.length;
1963
- this.history.onBidResult(historyEntry, {
1964
- blockNumber,
1965
- successfulBids,
1966
- bidPerSeat,
1967
- txFeePlusTip: txResult.finalFee ?? 0n,
1968
- bidsAttempted: subaccounts.length,
1969
- bidError
1970
- });
1876
+ this.txFees += txResult.finalFee ?? 0n;
1877
+ if (blockNumber !== void 0) {
1878
+ this.lastBidBlockNumber = Math.max(blockNumber, this.lastBidBlockNumber);
1879
+ }
1971
1880
  console.log("Done creating bids for cohort", {
1972
1881
  successfulBids,
1973
1882
  bidPerSeat,
@@ -1987,6 +1896,16 @@ var CohortBidder = class {
1987
1896
  await this.checkCurrentSeats();
1988
1897
  }
1989
1898
  }
1899
+ updateSeatsWon(next) {
1900
+ this.winningBids.length = 0;
1901
+ for (const x of next) {
1902
+ const bid = x.bid.toBigInt();
1903
+ const address = x.accountId.toHuman();
1904
+ if (this.myAddresses.has(address)) {
1905
+ this.winningBids.push({ address, bid });
1906
+ }
1907
+ }
1908
+ }
1990
1909
  async checkCurrentSeats() {
1991
1910
  const client = await this.client;
1992
1911
  const bids = await client.query.miningSlot.bidsForNextSlotCohort();
@@ -2059,7 +1978,7 @@ var BidPool = class {
2059
1978
  }
2060
1979
  async loadAt(blockHash) {
2061
1980
  const client = await this.client;
2062
- blockHash ??= Buffer.from((await client.rpc.chain.getHeader()).hash);
1981
+ blockHash ??= new Uint8Array((await client.rpc.chain.getHeader()).hash);
2063
1982
  const api = await client.at(blockHash);
2064
1983
  const rawVaultIds = await api.query.vaults.vaultsById.keys();
2065
1984
  const vaultIds = rawVaultIds.map((x) => x.args[0].toNumber());
@@ -2328,6 +2247,7 @@ Raising Funds (Frame ${this.nextFrameId + 1}):`);
2328
2247
  };
2329
2248
 
2330
2249
  // src/BitcoinLocks.ts
2250
+ import { hexToU8a as hexToU8a3, u8aToHex as u8aToHex2 } from "@polkadot/util";
2331
2251
  var SATS_PER_BTC = 100000000n;
2332
2252
  var BitcoinLocks = class _BitcoinLocks {
2333
2253
  constructor(client) {
@@ -2387,7 +2307,7 @@ var BitcoinLocks = class _BitcoinLocks {
2387
2307
  async getUtxoRef(utxoId, atHeight) {
2388
2308
  let client = await this.client;
2389
2309
  if (atHeight !== void 0) {
2390
- const blockHash = await client.query.system.blockHash(atHeight);
2310
+ const blockHash = await client.rpc.chain.getBlockHash(atHeight);
2391
2311
  client = await client.at(blockHash);
2392
2312
  }
2393
2313
  const refRaw = await client.query.bitcoinUtxos.utxoIdToRef(utxoId);
@@ -2395,15 +2315,15 @@ var BitcoinLocks = class _BitcoinLocks {
2395
2315
  return;
2396
2316
  }
2397
2317
  const ref = refRaw.unwrap();
2398
- const txid = Buffer.from(ref.txid).toString("hex");
2399
- const btcTxid = Buffer.from(ref.txid.reverse()).toString("hex");
2318
+ const txid = u8aToHex2(ref.txid);
2319
+ const bitcoinTxid = u8aToHex2(ref.txid.reverse());
2400
2320
  const vout = ref.outputIndex.toNumber();
2401
- return { txid: `0x${txid}`, vout, bitcoinTxid: `0x${btcTxid}` };
2321
+ return { txid, vout, bitcoinTxid };
2402
2322
  }
2403
2323
  async getReleaseRequest(utxoId, atHeight) {
2404
2324
  let client = await this.client;
2405
2325
  if (atHeight !== void 0) {
2406
- const blockHash = await client.query.system.blockHash(atHeight);
2326
+ const blockHash = await client.rpc.chain.getBlockHash(atHeight);
2407
2327
  client = await client.at(blockHash);
2408
2328
  }
2409
2329
  const locksPendingRelease = await client.query.bitcoinLocks.locksPendingReleaseByUtxoId();
@@ -2423,15 +2343,15 @@ var BitcoinLocks = class _BitcoinLocks {
2423
2343
  async submitVaultSignature(args) {
2424
2344
  const { utxoId, vaultSignature, argonKeyring } = args;
2425
2345
  const client = await this.client;
2426
- if (!vaultSignature || vaultSignature.byteLength < 71 || vaultSignature.byteLength > 73) {
2346
+ if (!vaultSignature || vaultSignature.byteLength < 70 || vaultSignature.byteLength > 73) {
2427
2347
  throw new Error(
2428
- `Invalid vault signature length: ${vaultSignature.byteLength}. Must be 71-73 bytes.`
2348
+ `Invalid vault signature length: ${vaultSignature.byteLength}. Must be 70-73 bytes.`
2429
2349
  );
2430
2350
  }
2431
- const signature = `0x${vaultSignature.toString("hex")}`;
2351
+ const signature = u8aToHex2(vaultSignature);
2432
2352
  const tx = client.tx.bitcoinLocks.cosignRelease(utxoId, signature);
2433
2353
  const submitter = new TxSubmitter(client, tx, argonKeyring);
2434
- return await submitter.submit({ waitForBlock: true });
2354
+ return await submitter.submit();
2435
2355
  }
2436
2356
  async getBitcoinLock(utxoId) {
2437
2357
  const client = await this.client;
@@ -2452,7 +2372,7 @@ var BitcoinLocks = class _BitcoinLocks {
2452
2372
  const ownerPubkey = utxo.ownerPubkey.toHex();
2453
2373
  const [fingerprint, cosign_hd_index, claim_hd_index] = utxo.vaultXpubSources;
2454
2374
  const vaultXpubSources = {
2455
- parentFingerprint: Buffer.from(fingerprint),
2375
+ parentFingerprint: new Uint8Array(fingerprint),
2456
2376
  cosignHdIndex: cosign_hd_index.toNumber(),
2457
2377
  claimHdIndex: claim_hd_index.toNumber()
2458
2378
  };
@@ -2534,7 +2454,7 @@ var BitcoinLocks = class _BitcoinLocks {
2534
2454
  await new Promise((resolve) => setTimeout(resolve, 1e3));
2535
2455
  continue;
2536
2456
  }
2537
- const hash = await client.query.system.blockHash(atHeight).then((x) => x.toHex());
2457
+ const hash = await client.rpc.chain.getBlockHash(atHeight).then((x) => x.toHex());
2538
2458
  if (hash === "0x0000000000000000000000000000000000000000000000000000000000000000") {
2539
2459
  console.warn(`Block hash not found for height ${atHeight}. Retrying...`);
2540
2460
  await new Promise((resolve) => setTimeout(resolve, 1e3));
@@ -2556,7 +2476,7 @@ var BitcoinLocks = class _BitcoinLocks {
2556
2476
  if (client.events.bitcoinLocks.BitcoinUtxoCosigned.is(event.event)) {
2557
2477
  const { utxoId: id, signature } = event.event.data;
2558
2478
  if (id.toNumber() === utxoId) {
2559
- return Buffer.from(signature);
2479
+ return new Uint8Array(signature);
2560
2480
  }
2561
2481
  }
2562
2482
  }
@@ -2744,7 +2664,7 @@ var BitcoinLocks = class _BitcoinLocks {
2744
2664
  const vaults = new VaultMonitor(accountset, {
2745
2665
  bitcoinSpaceAvailable: argonAmount
2746
2666
  });
2747
- const bitcoinXpubBuffer = Buffer.from(bitcoinXpub.replace(/^0x(.+)/, "$1"), "hex");
2667
+ const bitcoinXpubBuffer = hexToU8a3(bitcoinXpub);
2748
2668
  return new Promise(async (resolve, reject) => {
2749
2669
  vaults.events.on("bitcoin-space-above", async (vaultId, amount) => {
2750
2670
  const vault = vaults.vaultsById[vaultId];
@@ -2801,9 +2721,32 @@ function createKeyringPair(opts) {
2801
2721
  }
2802
2722
 
2803
2723
  // src/index.ts
2804
- export * from "@polkadot/types";
2805
- export * from "@polkadot/types/interfaces";
2806
- export * from "@polkadot/types-codec/types";
2724
+ import { u8aToHex as u8aToHex3, hexToU8a as hexToU8a4, u8aEq } from "@polkadot/util";
2725
+ import { GenericEvent as GenericEvent2, GenericBlock, GenericAddress } from "@polkadot/types/generic";
2726
+ import {
2727
+ BTreeMap,
2728
+ Bytes,
2729
+ Compact,
2730
+ Enum,
2731
+ Null,
2732
+ Option as Option2,
2733
+ Result,
2734
+ Bool,
2735
+ Tuple,
2736
+ Range,
2737
+ Struct,
2738
+ Text,
2739
+ U256,
2740
+ U8aFixed,
2741
+ Vec,
2742
+ bool,
2743
+ i128,
2744
+ u128,
2745
+ u16,
2746
+ u32,
2747
+ u64,
2748
+ u8
2749
+ } from "@polkadot/types-codec";
2807
2750
  async function waitForLoad() {
2808
2751
  await cryptoWaitReady();
2809
2752
  }
@@ -2819,6 +2762,8 @@ async function getClient(host) {
2819
2762
 
2820
2763
  export {
2821
2764
  WageProtector,
2765
+ setConfig,
2766
+ getConfig,
2822
2767
  TxSubmitter,
2823
2768
  MICROGONS_PER_ARGON,
2824
2769
  formatArgons,
@@ -2849,7 +2794,6 @@ export {
2849
2794
  MiningBids,
2850
2795
  Vault,
2851
2796
  VaultMonitor,
2852
- CohortBidderHistory,
2853
2797
  CohortBidder,
2854
2798
  BidPool,
2855
2799
  SATS_PER_BTC,
@@ -2860,6 +2804,34 @@ export {
2860
2804
  decodeAddress,
2861
2805
  mnemonicGenerate,
2862
2806
  waitForLoad,
2863
- getClient
2807
+ getClient,
2808
+ u8aToHex3 as u8aToHex,
2809
+ hexToU8a4 as hexToU8a,
2810
+ u8aEq,
2811
+ GenericEvent2 as GenericEvent,
2812
+ GenericBlock,
2813
+ GenericAddress,
2814
+ BTreeMap,
2815
+ Bytes,
2816
+ Compact,
2817
+ Enum,
2818
+ Null,
2819
+ Option2 as Option,
2820
+ Result,
2821
+ Bool,
2822
+ Tuple,
2823
+ Range,
2824
+ Struct,
2825
+ Text,
2826
+ U256,
2827
+ U8aFixed,
2828
+ Vec,
2829
+ bool,
2830
+ i128,
2831
+ u128,
2832
+ u16,
2833
+ u32,
2834
+ u64,
2835
+ u8
2864
2836
  };
2865
- //# sourceMappingURL=chunk-CGXT6XF7.js.map
2837
+ //# sourceMappingURL=chunk-FCT7GMFN.js.map