@secondlayer/stacks 2.16.0 → 2.18.0

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.
@@ -27,7 +27,9 @@ __export(exports_pox5, {
27
27
  bondPeriodToBurnHeight: () => bondPeriodToBurnHeight,
28
28
  assertPox5Active: () => assertPox5Active,
29
29
  POX5_SIGNER_DOMAIN: () => POX5_SIGNER_DOMAIN,
30
+ POX5_EVENT_TOPICS: () => POX5_EVENT_TOPICS,
30
31
  POX5_CONTRACT_NAME: () => POX5_CONTRACT_NAME,
32
+ POX5_CONTRACT_ID_MAINNET: () => POX5_CONTRACT_ID_MAINNET,
31
33
  POX5_ACTIVATION_BURN_HEIGHT_MAINNET: () => POX5_ACTIVATION_BURN_HEIGHT_MAINNET,
32
34
  MAX_NUM_CYCLES: () => MAX_NUM_CYCLES,
33
35
  C_SCRIPT_NUM_MAX: () => C_SCRIPT_NUM_MAX,
@@ -39,6 +41,28 @@ module.exports = __toCommonJS(exports_pox5);
39
41
 
40
42
  // src/pox5/constants.ts
41
43
  var POX5_CONTRACT_NAME = "pox-5";
44
+ var POX5_CONTRACT_ID_MAINNET = `SP000000000000000000002Q6VF78.${POX5_CONTRACT_NAME}`;
45
+ var POX5_EVENT_TOPICS = [
46
+ "set-bond-admin",
47
+ "set-pause-admin",
48
+ "pause-rewards",
49
+ "setup-bond",
50
+ "add-to-allowlist",
51
+ "register-for-bond",
52
+ "update-bond-registration",
53
+ "register-signer",
54
+ "stake",
55
+ "stake-update",
56
+ "announce-l1-early-exit",
57
+ "unstake-sbtc",
58
+ "unstake",
59
+ "calculate-rewards",
60
+ "bond-distribution",
61
+ "claim-rewards",
62
+ "claim-staker-rewards-for-signer",
63
+ "grant-signer-key",
64
+ "revoke-signer-grant"
65
+ ];
42
66
  var POX5_ACTIVATION_BURN_HEIGHT_MAINNET = 960230;
43
67
  var BOND_LENGTH_CYCLES = 12;
44
68
  var BOND_GAP_CYCLES = 2;
@@ -227,6 +251,539 @@ function verifySignerGrant(opts) {
227
251
  return false;
228
252
  }
229
253
  }
254
+ // src/pox5/abi.ts
255
+ var optionalSignerCalldata = {
256
+ optional: { buff: { length: 500 } }
257
+ };
258
+ var earnedRewardsTuple = {
259
+ tuple: [
260
+ { name: "earned", type: "uint128" },
261
+ { name: "rewards-per-token", type: "uint128" }
262
+ ]
263
+ };
264
+ var l1LockupOutputTuple = {
265
+ tuple: [
266
+ { name: "amount", type: "uint128" },
267
+ { name: "header", type: { buff: { length: 80 } } },
268
+ { name: "height", type: "uint128" },
269
+ {
270
+ name: "leaf-hashes",
271
+ type: { list: { type: { buff: { length: 32 } }, length: 14 } }
272
+ },
273
+ { name: "output-index", type: "uint128" },
274
+ { name: "tx", type: { buff: { length: 1e5 } } },
275
+ { name: "tx-count", type: "uint128" },
276
+ { name: "tx-index", type: "uint128" },
277
+ { name: "unlock-burn-height", type: "uint128" }
278
+ ]
279
+ };
280
+ var POX5_ABI = {
281
+ functions: [
282
+ {
283
+ name: "current-pox-reward-cycle",
284
+ access: "read-only",
285
+ args: [],
286
+ outputs: "uint128"
287
+ },
288
+ {
289
+ name: "get-bond-allowance",
290
+ access: "read-only",
291
+ args: [
292
+ { name: "bond-index", type: "uint128" },
293
+ { name: "staker", type: "principal" }
294
+ ],
295
+ outputs: { optional: "uint128" }
296
+ },
297
+ {
298
+ name: "get-bond-l1-unlock-height",
299
+ access: "read-only",
300
+ args: [{ name: "bond-index", type: "uint128" }],
301
+ outputs: "uint128"
302
+ },
303
+ {
304
+ name: "get-bond-membership",
305
+ access: "read-only",
306
+ args: [{ name: "staker", type: "principal" }],
307
+ outputs: {
308
+ optional: {
309
+ tuple: [
310
+ { name: "amount-sats", type: "uint128" },
311
+ { name: "amount-ustx", type: "uint128" },
312
+ { name: "bond-index", type: "uint128" },
313
+ { name: "is-l1-lock", type: "bool" },
314
+ { name: "signer", type: "principal" }
315
+ ]
316
+ }
317
+ }
318
+ },
319
+ {
320
+ name: "get-first-pox-5-reward-cycle",
321
+ access: "read-only",
322
+ args: [],
323
+ outputs: "uint128"
324
+ },
325
+ {
326
+ name: "get-protocol-bond",
327
+ access: "read-only",
328
+ args: [{ name: "bond-index", type: "uint128" }],
329
+ outputs: {
330
+ optional: {
331
+ tuple: [
332
+ { name: "early-unlock-bytes", type: { buff: { length: 683 } } },
333
+ { name: "min-ustx-ratio", type: "uint128" },
334
+ { name: "stx-value-ratio", type: "uint128" },
335
+ { name: "target-rate", type: "uint128" }
336
+ ]
337
+ }
338
+ }
339
+ },
340
+ {
341
+ name: "get-signer-info",
342
+ access: "read-only",
343
+ args: [{ name: "signer", type: "principal" }],
344
+ outputs: { optional: { buff: { length: 33 } } }
345
+ },
346
+ {
347
+ name: "get-staker-custodied-sbtc",
348
+ access: "read-only",
349
+ args: [{ name: "staker", type: "principal" }],
350
+ outputs: "uint128"
351
+ },
352
+ {
353
+ name: "get-staker-info",
354
+ access: "read-only",
355
+ args: [{ name: "staker", type: "principal" }],
356
+ outputs: {
357
+ optional: {
358
+ tuple: [
359
+ { name: "amount-ustx", type: "uint128" },
360
+ { name: "first-reward-cycle", type: "uint128" },
361
+ { name: "num-cycles", type: "uint128" },
362
+ { name: "signer", type: "principal" }
363
+ ]
364
+ }
365
+ }
366
+ },
367
+ {
368
+ name: "get-total-sbtc-staked-for-bond",
369
+ access: "read-only",
370
+ args: [{ name: "bond-index", type: "uint128" }],
371
+ outputs: "uint128"
372
+ },
373
+ {
374
+ name: "has-announced-l1-early-exit",
375
+ access: "read-only",
376
+ args: [
377
+ { name: "bond-index", type: "uint128" },
378
+ { name: "staker", type: "principal" }
379
+ ],
380
+ outputs: "bool"
381
+ },
382
+ {
383
+ name: "verify-signer-key-grant",
384
+ access: "read-only",
385
+ args: [
386
+ { name: "signer-manager", type: "principal" },
387
+ { name: "signer-key", type: { buff: { length: 33 } } }
388
+ ],
389
+ outputs: { response: { ok: "bool", error: "uint128" } }
390
+ },
391
+ {
392
+ name: "announce-l1-early-exit",
393
+ access: "public",
394
+ args: [
395
+ { name: "staker", type: "principal" },
396
+ { name: "old-signer-manager", type: "trait_reference" }
397
+ ],
398
+ outputs: {
399
+ response: {
400
+ ok: {
401
+ tuple: [
402
+ { name: "amount-sats-released", type: "uint128" },
403
+ { name: "bond-index", type: "uint128" },
404
+ { name: "signer", type: "principal" },
405
+ { name: "staker", type: "principal" }
406
+ ]
407
+ },
408
+ error: "uint128"
409
+ }
410
+ }
411
+ },
412
+ {
413
+ name: "calculate-rewards",
414
+ access: "public",
415
+ args: [
416
+ {
417
+ name: "bond-periods",
418
+ type: { list: { type: "uint128", length: 6 } }
419
+ }
420
+ ],
421
+ outputs: {
422
+ response: {
423
+ ok: {
424
+ tuple: [
425
+ { name: "accrued-rewards-per-ustx", type: "uint128" },
426
+ {
427
+ name: "bond-periods",
428
+ type: { list: { type: "uint128", length: 6 } }
429
+ },
430
+ { name: "calculation-height", type: "uint128" },
431
+ { name: "cumulative-rewards-per-ustx", type: "uint128" },
432
+ { name: "cycle-staked-ustx", type: "uint128" },
433
+ { name: "gross-accrued-rewards", type: "uint128" },
434
+ { name: "reserve-balance", type: "uint128" },
435
+ { name: "reserve-deposit", type: "uint128" },
436
+ { name: "stx-cycle", type: "uint128" },
437
+ { name: "total-bond-rewards", type: "uint128" },
438
+ { name: "total-stx-staker-rewards", type: "uint128" }
439
+ ]
440
+ },
441
+ error: "uint128"
442
+ }
443
+ }
444
+ },
445
+ {
446
+ name: "claim-rewards",
447
+ access: "public",
448
+ args: [
449
+ {
450
+ name: "bond-periods",
451
+ type: { list: { type: "uint128", length: 6 } }
452
+ },
453
+ { name: "reward-cycle", type: "uint128" }
454
+ ],
455
+ outputs: {
456
+ response: {
457
+ ok: {
458
+ tuple: [
459
+ {
460
+ name: "bond-rewards",
461
+ type: {
462
+ list: {
463
+ type: {
464
+ tuple: [
465
+ { name: "bond-index", type: "uint128" },
466
+ { name: "earned", type: "uint128" },
467
+ { name: "rewards-per-token", type: "uint128" }
468
+ ]
469
+ },
470
+ length: 6
471
+ }
472
+ }
473
+ },
474
+ { name: "bond-totals", type: "uint128" },
475
+ { name: "stx-rewards", type: earnedRewardsTuple },
476
+ { name: "total-rewards", type: "uint128" }
477
+ ]
478
+ },
479
+ error: "uint128"
480
+ }
481
+ }
482
+ },
483
+ {
484
+ name: "claim-staker-rewards-for-signer",
485
+ access: "public",
486
+ args: [
487
+ { name: "staker", type: "principal" },
488
+ { name: "reward-cycle", type: "uint128" },
489
+ { name: "bond-index", type: { optional: "uint128" } }
490
+ ],
491
+ outputs: {
492
+ response: { ok: earnedRewardsTuple, error: "uint128" }
493
+ }
494
+ },
495
+ {
496
+ name: "grant-signer-key",
497
+ access: "public",
498
+ args: [
499
+ { name: "signer-key", type: { buff: { length: 33 } } },
500
+ { name: "signer-manager", type: "principal" },
501
+ { name: "auth-id", type: "uint128" },
502
+ { name: "signer-sig", type: { buff: { length: 65 } } }
503
+ ],
504
+ outputs: {
505
+ response: {
506
+ ok: {
507
+ tuple: [
508
+ { name: "auth-id", type: "uint128" },
509
+ { name: "signer-key", type: { buff: { length: 33 } } },
510
+ { name: "signer-manager", type: "principal" }
511
+ ]
512
+ },
513
+ error: "uint128"
514
+ }
515
+ }
516
+ },
517
+ {
518
+ name: "register-for-bond",
519
+ access: "public",
520
+ args: [
521
+ { name: "bond-index", type: "uint128" },
522
+ { name: "signer-manager", type: "trait_reference" },
523
+ { name: "amount-ustx", type: "uint128" },
524
+ {
525
+ name: "btc-lockup",
526
+ type: {
527
+ response: {
528
+ ok: {
529
+ tuple: [
530
+ {
531
+ name: "outputs",
532
+ type: { list: { type: l1LockupOutputTuple, length: 10 } }
533
+ },
534
+ {
535
+ name: "staker-unlock-bytes",
536
+ type: { buff: { length: 683 } }
537
+ }
538
+ ]
539
+ },
540
+ error: "uint128"
541
+ }
542
+ }
543
+ },
544
+ { name: "signer-calldata", type: optionalSignerCalldata }
545
+ ],
546
+ outputs: {
547
+ response: {
548
+ ok: {
549
+ tuple: [
550
+ { name: "amount-ustx", type: "uint128" },
551
+ { name: "bond-index", type: "uint128" },
552
+ {
553
+ name: "btc-lockup",
554
+ type: {
555
+ tuple: [
556
+ {
557
+ name: "txs",
558
+ type: {
559
+ optional: {
560
+ list: {
561
+ type: {
562
+ tuple: [
563
+ { name: "output-index", type: "uint128" },
564
+ {
565
+ name: "txid",
566
+ type: { buff: { length: 32 } }
567
+ }
568
+ ]
569
+ },
570
+ length: 10
571
+ }
572
+ }
573
+ }
574
+ },
575
+ {
576
+ name: "type",
577
+ type: { "string-ascii": { length: 2 } }
578
+ }
579
+ ]
580
+ }
581
+ },
582
+ { name: "first-reward-cycle", type: "uint128" },
583
+ { name: "is-l1-lock", type: "bool" },
584
+ { name: "sats-total", type: "uint128" },
585
+ { name: "signer", type: "principal" },
586
+ { name: "staker", type: "principal" },
587
+ { name: "unlock-burn-height", type: "uint128" },
588
+ { name: "unlock-cycle", type: "uint128" }
589
+ ]
590
+ },
591
+ error: "uint128"
592
+ }
593
+ }
594
+ },
595
+ {
596
+ name: "revoke-signer-grant",
597
+ access: "public",
598
+ args: [
599
+ { name: "signer-manager", type: "principal" },
600
+ { name: "signer-key", type: { buff: { length: 33 } } }
601
+ ],
602
+ outputs: {
603
+ response: {
604
+ ok: {
605
+ tuple: [
606
+ { name: "existed", type: "bool" },
607
+ { name: "signer-key", type: { buff: { length: 33 } } },
608
+ { name: "signer-manager", type: "principal" }
609
+ ]
610
+ },
611
+ error: "uint128"
612
+ }
613
+ }
614
+ },
615
+ {
616
+ name: "setup-bond",
617
+ access: "public",
618
+ args: [
619
+ { name: "bond-index", type: "uint128" },
620
+ { name: "target-rate", type: "uint128" },
621
+ { name: "stx-value-ratio", type: "uint128" },
622
+ { name: "min-ustx-ratio", type: "uint128" },
623
+ { name: "early-unlock-bytes", type: { buff: { length: 683 } } },
624
+ {
625
+ name: "allowlist",
626
+ type: {
627
+ list: {
628
+ type: {
629
+ tuple: [
630
+ { name: "max-sats", type: "uint128" },
631
+ { name: "staker", type: "principal" }
632
+ ]
633
+ },
634
+ length: 1000
635
+ }
636
+ }
637
+ }
638
+ ],
639
+ outputs: {
640
+ response: {
641
+ ok: {
642
+ tuple: [
643
+ { name: "bond-index", type: "uint128" },
644
+ {
645
+ name: "early-unlock-bytes",
646
+ type: { buff: { length: 683 } }
647
+ },
648
+ { name: "max-allocation-sats", type: "uint128" },
649
+ { name: "min-ustx-ratio", type: "uint128" },
650
+ { name: "stx-value-ratio", type: "uint128" },
651
+ { name: "target-rate", type: "uint128" }
652
+ ]
653
+ },
654
+ error: "uint128"
655
+ }
656
+ }
657
+ },
658
+ {
659
+ name: "stake",
660
+ access: "public",
661
+ args: [
662
+ { name: "signer-manager", type: "trait_reference" },
663
+ { name: "amount-ustx", type: "uint128" },
664
+ { name: "num-cycles", type: "uint128" },
665
+ { name: "start-burn-ht", type: "uint128" },
666
+ { name: "signer-calldata", type: optionalSignerCalldata }
667
+ ],
668
+ outputs: {
669
+ response: {
670
+ ok: {
671
+ tuple: [
672
+ { name: "amount-ustx", type: "uint128" },
673
+ { name: "first-reward-cycle", type: "uint128" },
674
+ { name: "num-cycles", type: "uint128" },
675
+ { name: "signer", type: "principal" },
676
+ { name: "staker", type: "principal" },
677
+ { name: "unlock-burn-height", type: "uint128" },
678
+ { name: "unlock-cycle", type: "uint128" }
679
+ ]
680
+ },
681
+ error: "uint128"
682
+ }
683
+ }
684
+ },
685
+ {
686
+ name: "stake-update",
687
+ access: "public",
688
+ args: [
689
+ { name: "signer-manager", type: "trait_reference" },
690
+ { name: "old-signer-manager", type: "trait_reference" },
691
+ { name: "cycles-to-extend", type: "uint128" },
692
+ { name: "amount-increase", type: "uint128" },
693
+ { name: "signer-calldata", type: optionalSignerCalldata }
694
+ ],
695
+ outputs: {
696
+ response: {
697
+ ok: {
698
+ tuple: [
699
+ { name: "amount-increase", type: "uint128" },
700
+ { name: "amount-ustx", type: "uint128" },
701
+ { name: "cycles-to-extend", type: "uint128" },
702
+ { name: "num-cycles", type: "uint128" },
703
+ { name: "old-signer", type: "principal" },
704
+ { name: "prev-unlock-height", type: "uint128" },
705
+ { name: "signer", type: "principal" },
706
+ { name: "staker", type: "principal" },
707
+ { name: "unlock-burn-height", type: "uint128" },
708
+ { name: "unlock-cycle", type: "uint128" }
709
+ ]
710
+ },
711
+ error: "uint128"
712
+ }
713
+ }
714
+ },
715
+ {
716
+ name: "unstake",
717
+ access: "public",
718
+ args: [{ name: "old-signer-manager", type: "trait_reference" }],
719
+ outputs: {
720
+ response: {
721
+ ok: {
722
+ tuple: [
723
+ { name: "amount-ustx", type: "uint128" },
724
+ { name: "first-reward-cycle", type: "uint128" },
725
+ { name: "signer", type: "principal" },
726
+ { name: "staker", type: "principal" },
727
+ { name: "unlock-burn-height", type: "uint128" },
728
+ { name: "unlock-cycle", type: "uint128" }
729
+ ]
730
+ },
731
+ error: "uint128"
732
+ }
733
+ }
734
+ },
735
+ {
736
+ name: "unstake-sbtc",
737
+ access: "public",
738
+ args: [
739
+ { name: "signer-manager", type: "trait_reference" },
740
+ { name: "amount-to-withdrawal-sats", type: "uint128" }
741
+ ],
742
+ outputs: {
743
+ response: {
744
+ ok: {
745
+ tuple: [
746
+ { name: "amount-withdrawn-sats", type: "uint128" },
747
+ { name: "bond-index", type: "uint128" },
748
+ { name: "new-amount-sats", type: "uint128" },
749
+ { name: "signer", type: "principal" },
750
+ { name: "staker", type: "principal" }
751
+ ]
752
+ },
753
+ error: "uint128"
754
+ }
755
+ }
756
+ },
757
+ {
758
+ name: "update-bond-registration",
759
+ access: "public",
760
+ args: [
761
+ { name: "signer-manager", type: "trait_reference" },
762
+ { name: "old-signer-manager", type: "trait_reference" },
763
+ { name: "signer-calldata", type: optionalSignerCalldata }
764
+ ],
765
+ outputs: {
766
+ response: {
767
+ ok: {
768
+ tuple: [
769
+ { name: "amount-sats", type: "uint128" },
770
+ { name: "amount-ustx", type: "uint128" },
771
+ { name: "bond-index", type: "uint128" },
772
+ { name: "first-reward-cycle", type: "uint128" },
773
+ { name: "is-l1-lock", type: "bool" },
774
+ { name: "num-cycles", type: "uint128" },
775
+ { name: "old-signer", type: "principal" },
776
+ { name: "signer", type: "principal" },
777
+ { name: "staker", type: "principal" }
778
+ ]
779
+ },
780
+ error: "uint128"
781
+ }
782
+ }
783
+ }
784
+ ]
785
+ };
786
+
230
787
  // src/pox5/actions.ts
231
788
  function pox5ContractId(client) {
232
789
  const boot = client.chain?.bootAddress;
@@ -234,45 +791,35 @@ function pox5ContractId(client) {
234
791
  throw new Error("Client must have a chain with a bootAddress");
235
792
  return `${boot}.${POX5_CONTRACT_NAME}`;
236
793
  }
237
- function call(client, functionName, functionArgs, options = {}) {
238
- return callContract(client, {
239
- contract: pox5ContractId(client),
240
- functionName,
241
- functionArgs,
242
- ...options
243
- });
244
- }
245
- function read(client, functionName, functionArgs = []) {
794
+ function getPox5Contract(client) {
246
795
  const [address, name] = pox5ContractId(client).split(".");
247
- return readContract(client, {
248
- contract: `${address}.${name}`,
249
- functionName,
250
- args: functionArgs
251
- });
796
+ return getContract({ client, address, name, abi: POX5_ABI });
252
797
  }
253
- function bufferCV(input) {
254
- return typeof input === "string" ? Cl.bufferFromHex(input) : Cl.buffer(input);
798
+ function toBytes2(input) {
799
+ return typeof input === "string" ? hexToBytes(input) : input;
255
800
  }
256
- function btcLockupCV(lockup) {
257
- if ("sbtcSats" in lockup)
258
- return Cl.error(Cl.uint(lockup.sbtcSats));
259
- return Cl.ok(Cl.tuple({
260
- outputs: Cl.list(lockup.l1Outputs.map((o) => Cl.tuple({
261
- height: Cl.uint(o.height),
262
- tx: bufferCV(o.tx),
263
- "output-index": Cl.uint(o.outputIndex),
264
- header: bufferCV(o.header),
265
- "leaf-hashes": Cl.list(o.leafHashes.map(bufferCV)),
266
- "tx-count": Cl.uint(o.txCount),
267
- "tx-index": Cl.uint(o.txIndex),
268
- amount: Cl.uint(o.amount),
269
- "unlock-burn-height": Cl.uint(o.unlockBurnHeight)
270
- }))),
271
- "staker-unlock-bytes": bufferCV(lockup.stakerUnlockBytes)
272
- }));
801
+ function optionalBytes(input) {
802
+ return input === undefined ? null : toBytes2(input);
273
803
  }
274
- function optionalBuffer(input) {
275
- return input === undefined ? Cl.none() : Cl.some(bufferCV(input));
804
+ function btcLockupArg(lockup) {
805
+ if ("sbtcSats" in lockup)
806
+ return { err: intToBigInt(lockup.sbtcSats) };
807
+ return {
808
+ ok: {
809
+ outputs: lockup.l1Outputs.map((o) => ({
810
+ height: intToBigInt(o.height),
811
+ tx: toBytes2(o.tx),
812
+ outputIndex: intToBigInt(o.outputIndex),
813
+ header: toBytes2(o.header),
814
+ leafHashes: o.leafHashes.map(toBytes2),
815
+ txCount: intToBigInt(o.txCount),
816
+ txIndex: intToBigInt(o.txIndex),
817
+ amount: intToBigInt(o.amount),
818
+ unlockBurnHeight: intToBigInt(o.unlockBurnHeight)
819
+ })),
820
+ stakerUnlockBytes: toBytes2(lockup.stakerUnlockBytes)
821
+ }
822
+ };
276
823
  }
277
824
  function setupBond(client, params) {
278
825
  const {
@@ -284,17 +831,17 @@ function setupBond(client, params) {
284
831
  allowlist,
285
832
  ...tx
286
833
  } = params;
287
- return call(client, "setup-bond", [
288
- Cl.uint(bondIndex),
289
- Cl.uint(targetRate),
290
- Cl.uint(stxValueRatio),
291
- Cl.uint(minUstxRatio),
292
- bufferCV(earlyUnlockBytes),
293
- Cl.list(allowlist.map((a) => Cl.tuple({
294
- staker: Cl.principal(a.staker),
295
- "max-sats": Cl.uint(a.maxSats)
296
- })))
297
- ], tx);
834
+ return getPox5Contract(client).call.setupBond({
835
+ bondIndex: intToBigInt(bondIndex),
836
+ targetRate: intToBigInt(targetRate),
837
+ stxValueRatio: intToBigInt(stxValueRatio),
838
+ minUstxRatio: intToBigInt(minUstxRatio),
839
+ earlyUnlockBytes: toBytes2(earlyUnlockBytes),
840
+ allowlist: allowlist.map((a) => ({
841
+ staker: a.staker,
842
+ maxSats: intToBigInt(a.maxSats)
843
+ }))
844
+ }, tx);
298
845
  }
299
846
  function registerForBond(client, params) {
300
847
  const {
@@ -305,21 +852,21 @@ function registerForBond(client, params) {
305
852
  signerCalldata,
306
853
  ...tx
307
854
  } = params;
308
- return call(client, "register-for-bond", [
309
- Cl.uint(bondIndex),
310
- Cl.principal(signerManager),
311
- Cl.uint(amountUstx),
312
- btcLockupCV(btcLockup),
313
- optionalBuffer(signerCalldata)
314
- ], tx);
855
+ return getPox5Contract(client).call.registerForBond({
856
+ bondIndex: intToBigInt(bondIndex),
857
+ signerManager,
858
+ amountUstx: intToBigInt(amountUstx),
859
+ btcLockup: btcLockupArg(btcLockup),
860
+ signerCalldata: optionalBytes(signerCalldata)
861
+ }, tx);
315
862
  }
316
863
  function updateBondRegistration(client, params) {
317
864
  const { signerManager, oldSignerManager, signerCalldata, ...tx } = params;
318
- return call(client, "update-bond-registration", [
319
- Cl.principal(signerManager),
320
- Cl.principal(oldSignerManager),
321
- optionalBuffer(signerCalldata)
322
- ], tx);
865
+ return getPox5Contract(client).call.updateBondRegistration({
866
+ signerManager,
867
+ oldSignerManager,
868
+ signerCalldata: optionalBytes(signerCalldata)
869
+ }, tx);
323
870
  }
324
871
  function stake(client, params) {
325
872
  const {
@@ -330,13 +877,13 @@ function stake(client, params) {
330
877
  signerCalldata,
331
878
  ...tx
332
879
  } = params;
333
- return call(client, "stake", [
334
- Cl.principal(signerManager),
335
- Cl.uint(amountUstx),
336
- Cl.uint(numCycles),
337
- Cl.uint(startBurnHeight),
338
- optionalBuffer(signerCalldata)
339
- ], tx);
880
+ return getPox5Contract(client).call.stake({
881
+ signerManager,
882
+ amountUstx: intToBigInt(amountUstx),
883
+ numCycles: intToBigInt(numCycles),
884
+ startBurnHt: intToBigInt(startBurnHeight),
885
+ signerCalldata: optionalBytes(signerCalldata)
886
+ }, tx);
340
887
  }
341
888
  function stakeUpdate(client, params) {
342
889
  const {
@@ -347,99 +894,114 @@ function stakeUpdate(client, params) {
347
894
  signerCalldata,
348
895
  ...tx
349
896
  } = params;
350
- return call(client, "stake-update", [
351
- Cl.principal(signerManager),
352
- Cl.principal(oldSignerManager),
353
- Cl.uint(cyclesToExtend),
354
- Cl.uint(amountIncrease),
355
- optionalBuffer(signerCalldata)
356
- ], tx);
897
+ return getPox5Contract(client).call.stakeUpdate({
898
+ signerManager,
899
+ oldSignerManager,
900
+ cyclesToExtend: intToBigInt(cyclesToExtend),
901
+ amountIncrease: intToBigInt(amountIncrease),
902
+ signerCalldata: optionalBytes(signerCalldata)
903
+ }, tx);
357
904
  }
358
905
  function unstake(client, params) {
359
906
  const { oldSignerManager, ...tx } = params;
360
- return call(client, "unstake", [Cl.principal(oldSignerManager)], tx);
907
+ return getPox5Contract(client).call.unstake({ oldSignerManager }, tx);
361
908
  }
362
909
  function unstakeSbtc(client, params) {
363
910
  const { signerManager, amountSats, ...tx } = params;
364
- return call(client, "unstake-sbtc", [Cl.principal(signerManager), Cl.uint(amountSats)], tx);
911
+ return getPox5Contract(client).call.unstakeSbtc({ signerManager, amountToWithdrawalSats: intToBigInt(amountSats) }, tx);
365
912
  }
366
913
  function announceL1EarlyExit(client, params) {
367
914
  const { staker, oldSignerManager, ...tx } = params;
368
- return call(client, "announce-l1-early-exit", [Cl.principal(staker), Cl.principal(oldSignerManager)], tx);
915
+ return getPox5Contract(client).call.announceL1EarlyExit({ staker, oldSignerManager }, tx);
369
916
  }
370
917
  function calculateRewards(client, params) {
371
918
  const { bondPeriods, ...tx } = params;
372
- return call(client, "calculate-rewards", [Cl.list(bondPeriods.map((p) => Cl.uint(p)))], tx);
919
+ return getPox5Contract(client).call.calculateRewards({ bondPeriods: bondPeriods.map(intToBigInt) }, tx);
373
920
  }
374
921
  function claimRewards(client, params) {
375
922
  const { bondPeriods, rewardCycle, ...tx } = params;
376
- return call(client, "claim-rewards", [Cl.list(bondPeriods.map((p) => Cl.uint(p))), Cl.uint(rewardCycle)], tx);
923
+ return getPox5Contract(client).call.claimRewards({
924
+ bondPeriods: bondPeriods.map(intToBigInt),
925
+ rewardCycle: intToBigInt(rewardCycle)
926
+ }, tx);
377
927
  }
378
928
  function claimStakerRewardsForSigner(client, params) {
379
929
  const { staker, rewardCycle, bondIndex, ...tx } = params;
380
- return call(client, "claim-staker-rewards-for-signer", [
381
- Cl.principal(staker),
382
- Cl.uint(rewardCycle),
383
- bondIndex === undefined ? Cl.none() : Cl.some(Cl.uint(bondIndex))
384
- ], tx);
930
+ return getPox5Contract(client).call.claimStakerRewardsForSigner({
931
+ staker,
932
+ rewardCycle: intToBigInt(rewardCycle),
933
+ bondIndex: bondIndex === undefined ? null : intToBigInt(bondIndex)
934
+ }, tx);
385
935
  }
386
936
  function grantSignerKey(client, params) {
387
937
  const { signerKey, signerManager, authId, signerSig, ...tx } = params;
388
- return call(client, "grant-signer-key", [
389
- bufferCV(signerKey),
390
- Cl.principal(signerManager),
391
- Cl.uint(authId),
392
- bufferCV(signerSig)
393
- ], tx);
938
+ return getPox5Contract(client).call.grantSignerKey({
939
+ signerKey: toBytes2(signerKey),
940
+ signerManager,
941
+ authId: intToBigInt(authId),
942
+ signerSig: toBytes2(signerSig)
943
+ }, tx);
394
944
  }
395
945
  function revokeSignerGrant(client, params) {
396
946
  const { signerManager, signerKey, ...tx } = params;
397
- return call(client, "revoke-signer-grant", [Cl.principal(signerManager), bufferCV(signerKey)], tx);
947
+ return getPox5Contract(client).call.revokeSignerGrant({ signerManager, signerKey: toBytes2(signerKey) }, tx);
398
948
  }
399
- function getStakerInfo(client, staker) {
400
- return read(client, "get-staker-info", [Cl.principal(staker)]);
949
+ async function getStakerInfo(client, staker) {
950
+ return await getPox5Contract(client).read.getStakerInfo({
951
+ staker
952
+ });
401
953
  }
402
- function getBondMembership(client, staker) {
403
- return read(client, "get-bond-membership", [Cl.principal(staker)]);
954
+ async function getBondMembership(client, staker) {
955
+ return await getPox5Contract(client).read.getBondMembership({
956
+ staker
957
+ });
404
958
  }
405
- function getProtocolBond(client, bondIndex) {
406
- return read(client, "get-protocol-bond", [Cl.uint(bondIndex)]);
959
+ async function getProtocolBond(client, bondIndex) {
960
+ return await getPox5Contract(client).read.getProtocolBond({
961
+ bondIndex: intToBigInt(bondIndex)
962
+ });
407
963
  }
408
- function getBondAllowance(client, bondIndex, staker) {
409
- return read(client, "get-bond-allowance", [
410
- Cl.uint(bondIndex),
411
- Cl.principal(staker)
412
- ]);
964
+ async function getBondAllowance(client, bondIndex, staker) {
965
+ return await getPox5Contract(client).read.getBondAllowance({
966
+ bondIndex: intToBigInt(bondIndex),
967
+ staker
968
+ });
413
969
  }
414
970
  function getTotalSbtcStakedForBond(client, bondIndex) {
415
- return read(client, "get-total-sbtc-staked-for-bond", [Cl.uint(bondIndex)]);
971
+ return getPox5Contract(client).read.getTotalSbtcStakedForBond({
972
+ bondIndex: intToBigInt(bondIndex)
973
+ });
416
974
  }
417
975
  function getStakerCustodiedSbtc(client, staker) {
418
- return read(client, "get-staker-custodied-sbtc", [Cl.principal(staker)]);
976
+ return getPox5Contract(client).read.getStakerCustodiedSbtc({ staker });
419
977
  }
420
978
  function hasAnnouncedL1EarlyExit(client, bondIndex, staker) {
421
- return read(client, "has-announced-l1-early-exit", [
422
- Cl.uint(bondIndex),
423
- Cl.principal(staker)
424
- ]);
979
+ return getPox5Contract(client).read.hasAnnouncedL1EarlyExit({
980
+ bondIndex: intToBigInt(bondIndex),
981
+ staker
982
+ });
425
983
  }
426
984
  function getBondL1UnlockHeight(client, bondIndex) {
427
- return read(client, "get-bond-l1-unlock-height", [Cl.uint(bondIndex)]);
985
+ return getPox5Contract(client).read.getBondL1UnlockHeight({
986
+ bondIndex: intToBigInt(bondIndex)
987
+ });
428
988
  }
429
- function getSignerInfo(client, signer) {
430
- return read(client, "get-signer-info", [Cl.principal(signer)]);
989
+ async function getSignerInfo(client, signer) {
990
+ return await getPox5Contract(client).read.getSignerInfo({
991
+ signer
992
+ });
431
993
  }
432
994
  function verifySignerKeyGrantOnChain(client, signerManager, signerKey) {
433
- return read(client, "verify-signer-key-grant", [
434
- Cl.principal(signerManager),
435
- bufferCV(signerKey)
436
- ]);
995
+ return getPox5Contract(client).read.verifySignerKeyGrant({
996
+ signerManager,
997
+ signerKey: toBytes2(signerKey)
998
+ });
437
999
  }
438
1000
  function getCurrentRewardCycle(client) {
439
- return read(client, "current-pox-reward-cycle");
1001
+ return getPox5Contract(client).read.currentPoxRewardCycle({});
440
1002
  }
441
1003
  function getFirstPox5RewardCycle(client) {
442
- return read(client, "get-first-pox-5-reward-cycle");
1004
+ return getPox5Contract(client).read.getFirstPox5RewardCycle({});
443
1005
  }
444
1006
  // src/pox5/extension.ts
445
1007
  async function getStakerState(client, staker) {
@@ -509,5 +1071,5 @@ function pox5() {
509
1071
  });
510
1072
  }
511
1073
 
512
- //# debugId=9EC46D11CA68C21664756E2164756E21
1074
+ //# debugId=534EC1ABFA62C92564756E2164756E21
513
1075
  //# sourceMappingURL=index.cjs.map