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