@gvnrdao/dh-mcp 0.5.19 → 0.5.20
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/dist/boundary.js +848 -369
- package/dist/connector-embed.js +908 -382
- package/dist/connector.js +908 -382
- package/dist/index.js +877 -382
- package/package.json +2 -2
package/dist/boundary.js
CHANGED
|
@@ -14450,113 +14450,113 @@ var require_pkg_src = __commonJS({
|
|
|
14450
14450
|
deployedAt: 1784569687492,
|
|
14451
14451
|
size: 4140,
|
|
14452
14452
|
hash: "4c0d65bf1f33cdac22a78fd8c4764319cc3fe00650e0fe7fa8a6090d9a318a7b",
|
|
14453
|
-
validatorWalletAddress: "
|
|
14453
|
+
validatorWalletAddress: "0xefb258d455a31d061bbeb3de3d2143bdfcb67a6c",
|
|
14454
14454
|
pkp: {
|
|
14455
14455
|
publicKey: "0x04ec0e3acc40884e3f366ca469d08899eb640ad5259fa196b0238075086208a9f8732a3175704f35f0bcc28e07406cfb24c254efd1e7355640577330f0d2dd755f",
|
|
14456
|
-
ethAddress: "
|
|
14456
|
+
ethAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C"
|
|
14457
14457
|
}
|
|
14458
14458
|
},
|
|
14459
14459
|
btcTransactionSigner: {
|
|
14460
|
-
cid: "
|
|
14460
|
+
cid: "QmULkz7hwwqsyLwY23U14dnartdVuSNMrykt69PaNiAq7U",
|
|
14461
14461
|
authorizedCidHex: cidToHex(
|
|
14462
|
-
"
|
|
14462
|
+
"QmULkz7hwwqsyLwY23U14dnartdVuSNMrykt69PaNiAq7U"
|
|
14463
14463
|
),
|
|
14464
14464
|
name: "Btc Transaction Signer",
|
|
14465
14465
|
description: "Production Btc Transaction Signer",
|
|
14466
14466
|
version: "1.1.1",
|
|
14467
14467
|
deployed: true,
|
|
14468
|
-
deployedAt:
|
|
14469
|
-
size:
|
|
14470
|
-
hash: "
|
|
14468
|
+
deployedAt: 1790246185256,
|
|
14469
|
+
size: 73313,
|
|
14470
|
+
hash: "d8b6bc646ba33fee7d46c8e9b281de776081ea6f182f56fd15d4c52aaf3dd030"
|
|
14471
14471
|
},
|
|
14472
14472
|
ucdMintValidator: {
|
|
14473
|
-
cid: "
|
|
14473
|
+
cid: "QmcxVSn9saEPGBS6mqPhNefgW83V2qeZjjXbhwYLP373xe",
|
|
14474
14474
|
authorizedCidHex: cidToHex(
|
|
14475
|
-
"
|
|
14475
|
+
"QmcxVSn9saEPGBS6mqPhNefgW83V2qeZjjXbhwYLP373xe"
|
|
14476
14476
|
),
|
|
14477
14477
|
name: "Ucd Mint Validator",
|
|
14478
14478
|
description: "Production Ucd Mint Validator",
|
|
14479
|
-
version: "1.
|
|
14479
|
+
version: "1.3.0",
|
|
14480
14480
|
deployed: true,
|
|
14481
|
-
deployedAt:
|
|
14482
|
-
size:
|
|
14483
|
-
hash: "
|
|
14484
|
-
validatorWalletAddress: "
|
|
14481
|
+
deployedAt: 1790246219868,
|
|
14482
|
+
size: 90022,
|
|
14483
|
+
hash: "65e8cb778c2b767ae6eb37cb5db7b4c5a3f2468d508463c847c83c1b6825fadd",
|
|
14484
|
+
validatorWalletAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C",
|
|
14485
14485
|
pkp: {
|
|
14486
14486
|
publicKey: "0x041ab17cd91fc5c0b761eea6092d032807561b621b82c488826776e04a9158d61ba64d809a4729f0501289d980732cb06d8dfd06999dd9c8efd2f495dad78b31bb",
|
|
14487
|
-
ethAddress: "
|
|
14487
|
+
ethAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C"
|
|
14488
14488
|
}
|
|
14489
14489
|
},
|
|
14490
14490
|
processPaymentValidator: {
|
|
14491
|
-
cid: "
|
|
14491
|
+
cid: "QmWFbxJkfxhCtES4wrePWQkYtjhtrP1tohvn9d1r9N5Hd8",
|
|
14492
14492
|
authorizedCidHex: cidToHex(
|
|
14493
|
-
"
|
|
14493
|
+
"QmWFbxJkfxhCtES4wrePWQkYtjhtrP1tohvn9d1r9N5Hd8"
|
|
14494
14494
|
),
|
|
14495
14495
|
name: "Process Payment Validator",
|
|
14496
14496
|
description: "Production Process Payment Validator",
|
|
14497
14497
|
version: "1.2.1",
|
|
14498
14498
|
deployed: true,
|
|
14499
|
-
deployedAt:
|
|
14500
|
-
size:
|
|
14501
|
-
hash: "
|
|
14502
|
-
validatorWalletAddress: "
|
|
14499
|
+
deployedAt: 1790246225795,
|
|
14500
|
+
size: 85107,
|
|
14501
|
+
hash: "25ecf952c4c44c40b0920b92d57906e7010ed9a38e2ba41ccdee6d3377c2b596",
|
|
14502
|
+
validatorWalletAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C",
|
|
14503
14503
|
pkp: {
|
|
14504
14504
|
publicKey: "0x04cfccb9b6c7addc79469c0e9fafebef4c70801302c62cdb26b610723a9b8527d23f98a40158c7340d83fd0e62d02b5ec74c12f7a86d98e8c6973b4811110f19ad",
|
|
14505
|
-
ethAddress: "
|
|
14505
|
+
ethAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C"
|
|
14506
14506
|
}
|
|
14507
14507
|
},
|
|
14508
14508
|
extendPositionValidator: {
|
|
14509
|
-
cid: "
|
|
14509
|
+
cid: "QmZ3g7g5DkgU1gEYpFjprQf3sctUHtGjNQVYezw2bnPGEX",
|
|
14510
14510
|
authorizedCidHex: cidToHex(
|
|
14511
|
-
"
|
|
14511
|
+
"QmZ3g7g5DkgU1gEYpFjprQf3sctUHtGjNQVYezw2bnPGEX"
|
|
14512
14512
|
),
|
|
14513
14513
|
name: "Extend Position Validator",
|
|
14514
14514
|
description: "Production Extend Position Validator",
|
|
14515
14515
|
version: "1.2.1",
|
|
14516
14516
|
deployed: true,
|
|
14517
|
-
deployedAt:
|
|
14518
|
-
size:
|
|
14519
|
-
hash: "
|
|
14520
|
-
validatorWalletAddress: "
|
|
14517
|
+
deployedAt: 1790246231975,
|
|
14518
|
+
size: 82853,
|
|
14519
|
+
hash: "25d4887b7f646649db2bb7f2bfb77d039db83228a6c454377ca26c779b0903cc",
|
|
14520
|
+
validatorWalletAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C",
|
|
14521
14521
|
pkp: {
|
|
14522
14522
|
publicKey: "0x04e52338f6a0c3362800f1a94c4c8f08be5030dde0fa217388c53d1c1a4790f4443c9f2886b2d2d8f4b75a9a156e9b028011b1a1cf7648da0e556aa980ec692836",
|
|
14523
|
-
ethAddress: "
|
|
14523
|
+
ethAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C"
|
|
14524
14524
|
}
|
|
14525
14525
|
},
|
|
14526
14526
|
btcWithdrawal: {
|
|
14527
|
-
cid: "
|
|
14527
|
+
cid: "QmbRaaMQr1jCctDGe8mPADsUz1rkb4frT1YqSKroiXjzyP",
|
|
14528
14528
|
authorizedCidHex: cidToHex(
|
|
14529
|
-
"
|
|
14529
|
+
"QmbRaaMQr1jCctDGe8mPADsUz1rkb4frT1YqSKroiXjzyP"
|
|
14530
14530
|
),
|
|
14531
14531
|
name: "Btc Withdrawal",
|
|
14532
14532
|
description: "Production Btc Withdrawal",
|
|
14533
14533
|
version: "1.2.7",
|
|
14534
14534
|
deployed: true,
|
|
14535
|
-
deployedAt:
|
|
14536
|
-
size:
|
|
14537
|
-
hash: "
|
|
14538
|
-
validatorWalletAddress: "
|
|
14535
|
+
deployedAt: 1790246239599,
|
|
14536
|
+
size: 101228,
|
|
14537
|
+
hash: "2ed25eca6cc80a43061b7ad119737af48158fdb61d59f10cd06cea51b607f112",
|
|
14538
|
+
validatorWalletAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C",
|
|
14539
14539
|
pkp: {
|
|
14540
14540
|
publicKey: "0x043616787c5432415c24378c4ef48de2bcd6bb7b575b837e3cff09171802662da7105d79586c7659677a0ecbaddac4cce06cb2a11f69a16fa0c4d7002ac7d51a4d",
|
|
14541
|
-
ethAddress: "
|
|
14541
|
+
ethAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C"
|
|
14542
14542
|
}
|
|
14543
14543
|
},
|
|
14544
14544
|
liquidationValidator: {
|
|
14545
|
-
cid: "
|
|
14545
|
+
cid: "QmTs2w8gfAwWZLbzJZg2CZmiLhVXS5kbMgaj42Zuxfodpb",
|
|
14546
14546
|
authorizedCidHex: cidToHex(
|
|
14547
|
-
"
|
|
14547
|
+
"QmTs2w8gfAwWZLbzJZg2CZmiLhVXS5kbMgaj42Zuxfodpb"
|
|
14548
14548
|
),
|
|
14549
14549
|
name: "Liquidation Validator",
|
|
14550
14550
|
description: "Production Liquidation Validator",
|
|
14551
14551
|
version: "1.2.1",
|
|
14552
14552
|
deployed: true,
|
|
14553
|
-
deployedAt:
|
|
14554
|
-
size:
|
|
14555
|
-
hash: "
|
|
14556
|
-
validatorWalletAddress: "
|
|
14553
|
+
deployedAt: 1790246247904,
|
|
14554
|
+
size: 70308,
|
|
14555
|
+
hash: "582ccf0ec7f715195e20fdc885996743cb42125b64173424e360ee63db62bbd8",
|
|
14556
|
+
validatorWalletAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C",
|
|
14557
14557
|
pkp: {
|
|
14558
14558
|
publicKey: "0x041a241de58976c13e3d7ca5a18e494f7330151e3818706135d50176e78ffb673e58b11f0b67a87c73fade6c6b27d6e7a7377ea9f4c10bf31880f1d725f18cc6f8",
|
|
14559
|
-
ethAddress: "
|
|
14559
|
+
ethAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C"
|
|
14560
14560
|
}
|
|
14561
14561
|
},
|
|
14562
14562
|
priceOracle: {
|
|
@@ -14571,28 +14571,28 @@ var require_pkg_src = __commonJS({
|
|
|
14571
14571
|
deployedAt: 1781116663270,
|
|
14572
14572
|
size: 8695,
|
|
14573
14573
|
hash: "ba20ade60a7fa5acd80dadfafa179c507388cfe6ce48a22a672d70b317ffcc74",
|
|
14574
|
-
validatorWalletAddress: "
|
|
14574
|
+
validatorWalletAddress: "0xefb258d455a31d061bbeb3de3d2143bdfcb67a6c",
|
|
14575
14575
|
pkp: {
|
|
14576
14576
|
publicKey: "0x043beaa1da47875601a8d6f430b1438ee2d4732eefd06e5c63a474bbdaf9e7df1797b1b951e041b627c2bf839788164825324c9cbd1e2d6f740fdd4bff69b1900b",
|
|
14577
|
-
ethAddress: "
|
|
14577
|
+
ethAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C"
|
|
14578
14578
|
}
|
|
14579
14579
|
},
|
|
14580
14580
|
loanVaultBtcBalance: {
|
|
14581
|
-
cid: "
|
|
14581
|
+
cid: "QmZ27xCzuoaAhWxRsMPsUQkp45a8WPBb21uhxwchw3LG5W",
|
|
14582
14582
|
authorizedCidHex: cidToHex(
|
|
14583
|
-
"
|
|
14583
|
+
"QmZ27xCzuoaAhWxRsMPsUQkp45a8WPBb21uhxwchw3LG5W"
|
|
14584
14584
|
),
|
|
14585
14585
|
name: "Loan Vault Btc Balance",
|
|
14586
14586
|
description: "Production Loan Vault Btc Balance",
|
|
14587
14587
|
version: "1.2.1",
|
|
14588
14588
|
deployed: true,
|
|
14589
|
-
deployedAt:
|
|
14590
|
-
size:
|
|
14591
|
-
hash: "
|
|
14592
|
-
validatorWalletAddress: "
|
|
14589
|
+
deployedAt: 1790179961079,
|
|
14590
|
+
size: 60046,
|
|
14591
|
+
hash: "922e86c0a667fe0c0945771f84aa6b9fe08be9c96dd2f73a9c5cb257d24e22b0",
|
|
14592
|
+
validatorWalletAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C",
|
|
14593
14593
|
pkp: {
|
|
14594
14594
|
publicKey: "0x043616787c5432415c24378c4ef48de2bcd6bb7b575b837e3cff09171802662da7105d79586c7659677a0ecbaddac4cce06cb2a11f69a16fa0c4d7002ac7d51a4d",
|
|
14595
|
-
ethAddress: "
|
|
14595
|
+
ethAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C"
|
|
14596
14596
|
}
|
|
14597
14597
|
},
|
|
14598
14598
|
// btc-address-balance (Option B) — address-only signed total balance via
|
|
@@ -14602,21 +14602,21 @@ var require_pkg_src = __commonJS({
|
|
|
14602
14602
|
// Requires BitcoinProviderRegistry.addAllowedCid(chainId, keccak256(utf8(cid)))
|
|
14603
14603
|
// on each target chain (the action decrypts registry slots). No OAR entry.
|
|
14604
14604
|
btcAddressBalance: {
|
|
14605
|
-
cid: "
|
|
14605
|
+
cid: "QmVVjB6zCBiXFKffhQPYUAZhj7TXduuvcrPqKtHa3DMXhN",
|
|
14606
14606
|
authorizedCidHex: cidToHex(
|
|
14607
|
-
"
|
|
14607
|
+
"QmVVjB6zCBiXFKffhQPYUAZhj7TXduuvcrPqKtHa3DMXhN"
|
|
14608
14608
|
),
|
|
14609
14609
|
name: "Btc Address Balance",
|
|
14610
14610
|
description: "Address-only signed total BTC balance via registry consensus (no positionId, no price)",
|
|
14611
14611
|
version: "0.2.1",
|
|
14612
14612
|
deployed: true,
|
|
14613
|
-
deployedAt:
|
|
14614
|
-
size:
|
|
14615
|
-
hash: "
|
|
14616
|
-
validatorWalletAddress: "
|
|
14613
|
+
deployedAt: 1790179971315,
|
|
14614
|
+
size: 30295,
|
|
14615
|
+
hash: "2c67d9cfa4d50e835fbb28ae50e80217ceb2be3bb862c89290aadf43fdc739c9",
|
|
14616
|
+
validatorWalletAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C",
|
|
14617
14617
|
pkp: {
|
|
14618
14618
|
publicKey: "0x0498cbb31facfa26e3ec83ccdabfe4fe341ca0282e0c3cb81da7113723b9726e1e49efa92165cc3faa66ced4454cea56dbab12267852d6525a55d7c4f128b912cd",
|
|
14619
|
-
ethAddress: "
|
|
14619
|
+
ethAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C"
|
|
14620
14620
|
}
|
|
14621
14621
|
},
|
|
14622
14622
|
alwaysSigner: {
|
|
@@ -14646,48 +14646,48 @@ var require_pkg_src = __commonJS({
|
|
|
14646
14646
|
hash: "03ee5be239c91c735d2c95db89a0d1b77e602cfc18af8eb64b3281fddcd90a72"
|
|
14647
14647
|
},
|
|
14648
14648
|
agentModuleExecutor: {
|
|
14649
|
-
cid: "
|
|
14649
|
+
cid: "QmSwPPvQhT7UhcuVA2m3UxGhVj5WqMpDvYNKU1228QLFsX",
|
|
14650
14650
|
authorizedCidHex: cidToHex(
|
|
14651
|
-
"
|
|
14651
|
+
"QmSwPPvQhT7UhcuVA2m3UxGhVj5WqMpDvYNKU1228QLFsX"
|
|
14652
14652
|
),
|
|
14653
14653
|
name: "Agent Module Executor",
|
|
14654
14654
|
description: "Production Agent Module Executor",
|
|
14655
14655
|
version: "1.1.1",
|
|
14656
14656
|
deployed: true,
|
|
14657
|
-
deployedAt:
|
|
14658
|
-
size:
|
|
14659
|
-
hash: "
|
|
14657
|
+
deployedAt: 1790179978959,
|
|
14658
|
+
size: 14688,
|
|
14659
|
+
hash: "8edb9b12c784c8d7d153cce97235584c24665a788767ae68713dce91109ab35e"
|
|
14660
14660
|
},
|
|
14661
14661
|
staleSpendRecoveryValidator: {
|
|
14662
|
-
cid: "
|
|
14662
|
+
cid: "Qmarj59zdSSgivkimryrdvnyZqH5YpTimKj1LivXNBHmNz",
|
|
14663
14663
|
authorizedCidHex: cidToHex(
|
|
14664
|
-
"
|
|
14664
|
+
"Qmarj59zdSSgivkimryrdvnyZqH5YpTimKj1LivXNBHmNz"
|
|
14665
14665
|
),
|
|
14666
14666
|
name: "Stale Spend Recovery Validator",
|
|
14667
14667
|
description: "Production Stale Spend Recovery Validator",
|
|
14668
14668
|
version: "1.1.2",
|
|
14669
14669
|
deployed: true,
|
|
14670
|
-
deployedAt:
|
|
14671
|
-
size:
|
|
14672
|
-
hash: "
|
|
14673
|
-
validatorWalletAddress: "
|
|
14670
|
+
deployedAt: 1790246256280,
|
|
14671
|
+
size: 48143,
|
|
14672
|
+
hash: "ec9236bcbe0af24d3e1844791fc8fe37371bbecd8ce95d02e13f7c6e1fc7d94c",
|
|
14673
|
+
validatorWalletAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C",
|
|
14674
14674
|
pkp: {
|
|
14675
14675
|
publicKey: "0x046da0ad6da7dd4a0063cbeac6f2bdb6a9889c2178b23470833356a8ee5630f7f0eee0db348d9d9aaaadd23eccf0063c8f68ee5e446abe30b882bf1de4c932bc21",
|
|
14676
|
-
ethAddress: "
|
|
14676
|
+
ethAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C"
|
|
14677
14677
|
}
|
|
14678
14678
|
},
|
|
14679
14679
|
btcUtxoInvalidator: {
|
|
14680
|
-
cid: "
|
|
14680
|
+
cid: "QmbS44bGcmKYF64Cu35qzsk9sxiU4Umde8Z3q24ZnEbQvX",
|
|
14681
14681
|
authorizedCidHex: cidToHex(
|
|
14682
|
-
"
|
|
14682
|
+
"QmbS44bGcmKYF64Cu35qzsk9sxiU4Umde8Z3q24ZnEbQvX"
|
|
14683
14683
|
),
|
|
14684
14684
|
name: "Btc Utxo Invalidator",
|
|
14685
14685
|
description: "Production Btc Utxo Invalidator",
|
|
14686
14686
|
version: "1.0.0",
|
|
14687
14687
|
deployed: true,
|
|
14688
|
-
deployedAt:
|
|
14689
|
-
size:
|
|
14690
|
-
hash: "
|
|
14688
|
+
deployedAt: 1790246264563,
|
|
14689
|
+
size: 69219,
|
|
14690
|
+
hash: "bda048d8cd6b5a39c2774bcf1320e82d1eea935c2a521006fb8b887e13b6dd8d"
|
|
14691
14691
|
}
|
|
14692
14692
|
};
|
|
14693
14693
|
function getDeploymentsForNetwork(network) {
|
|
@@ -15453,7 +15453,10 @@ ${errorReport}`);
|
|
|
15453
15453
|
BTCSpendAuthorizer: "0xfBbF108486fa07F1B06a811C5b66ed68DD9c508a",
|
|
15454
15454
|
BitcoinProviderRegistry: "0x4ab3Fb96e02893Ed6FAa61bad1918390c8DbbFFC",
|
|
15455
15455
|
LITActionValidator: "0xD2c5d59c2CC5c409AC65ce0A817236aeC6869512",
|
|
15456
|
-
PositionDelegateRegistry: "0xf0aa2678aD4F60f49e8F7725089B5E86B7F8FE4C"
|
|
15456
|
+
PositionDelegateRegistry: "0xf0aa2678aD4F60f49e8F7725089B5E86B7F8FE4C",
|
|
15457
|
+
TermManagerModule: "0xDB99CdF883ffa38acD099bC39F8d1f4508c9239E",
|
|
15458
|
+
UCDController: "0x4b4f8063048bCD59D469219E3f07C6aaDF4f6157",
|
|
15459
|
+
LiquidationManagerModule: "0x74B28695352E7bf736D6c9F76ccb7B4439477De9"
|
|
15457
15460
|
},
|
|
15458
15461
|
11155111: {
|
|
15459
15462
|
PositionManager: "0x68e0507D982AEBF1D1C1Af8FBbd842327e2deeFF",
|
|
@@ -15461,7 +15464,10 @@ ${errorReport}`);
|
|
|
15461
15464
|
BTCSpendAuthorizer: "0xd7E9Eb5eE53f1d9ee55Dc162bBC7486bE437B6bD",
|
|
15462
15465
|
BitcoinProviderRegistry: "0xbfA0c48B070D0a9A9CD27469AeacFD2d4261cEE2",
|
|
15463
15466
|
LITActionValidator: "0x54eECd7C90F8A8fac27749Ba30BbE8AFBAccc856",
|
|
15464
|
-
PositionDelegateRegistry: "0x482369De283622E7b05731875ec137d4E3D208F9"
|
|
15467
|
+
PositionDelegateRegistry: "0x482369De283622E7b05731875ec137d4E3D208F9",
|
|
15468
|
+
TermManagerModule: "0x94Adc6F9558368B1482197584f1fc7133Ecf835b",
|
|
15469
|
+
UCDController: "0x360Bde4e489ee94E26601B206932De09EE60FF04",
|
|
15470
|
+
LiquidationManagerModule: "0xC4AB00f39e7ceD812F5C67058C9fa44e15d40e76"
|
|
15465
15471
|
}
|
|
15466
15472
|
};
|
|
15467
15473
|
function getPinnedContractAddresses(chainId) {
|
|
@@ -15647,10 +15653,10 @@ ${errorReport}`);
|
|
|
15647
15653
|
};
|
|
15648
15654
|
}
|
|
15649
15655
|
const ratioBigInt = collateralValueUsd * UCD_TOKEN_DECIMALS * 10000n / ucdDebt;
|
|
15650
|
-
const
|
|
15656
|
+
const collateralRatioBps2 = Number(ratioBigInt);
|
|
15651
15657
|
return {
|
|
15652
15658
|
collateralValueUsd,
|
|
15653
|
-
collateralRatioBps
|
|
15659
|
+
collateralRatioBps: collateralRatioBps2
|
|
15654
15660
|
};
|
|
15655
15661
|
}
|
|
15656
15662
|
function hasSufficientCollateralForDebt(collateralValueUsd, currentDebt, additionalDebt, requiredRatioBps) {
|
|
@@ -16495,6 +16501,17 @@ ${auth.clientId}`;
|
|
|
16495
16501
|
);
|
|
16496
16502
|
}
|
|
16497
16503
|
}
|
|
16504
|
+
var TIP_READ_FAILURE_PREFIX = "Bitcoin tip-height read failed";
|
|
16505
|
+
var BitcoinTipUnreadableError = class extends Error {
|
|
16506
|
+
constructor(message) {
|
|
16507
|
+
super(message);
|
|
16508
|
+
this.isBitcoinTipUnreadable = true;
|
|
16509
|
+
this.name = "BitcoinTipUnreadableError";
|
|
16510
|
+
}
|
|
16511
|
+
};
|
|
16512
|
+
function isBitcoinTipUnreadableError(error) {
|
|
16513
|
+
return typeof error === "object" && error !== null && error.isBitcoinTipUnreadable === true;
|
|
16514
|
+
}
|
|
16498
16515
|
var BitcoinDataProvider = class {
|
|
16499
16516
|
constructor(config) {
|
|
16500
16517
|
this.config = config;
|
|
@@ -16946,27 +16963,12 @@ ${auth.clientId}`;
|
|
|
16946
16963
|
if (!data.status.confirmed || !data.status.block_height) {
|
|
16947
16964
|
return { txid: data.txid ?? txid, confirmations: 0 };
|
|
16948
16965
|
}
|
|
16949
|
-
|
|
16950
|
-
|
|
16951
|
-
|
|
16952
|
-
|
|
16953
|
-
|
|
16954
|
-
|
|
16955
|
-
return { txid: data.txid ?? txid, confirmations: 1 };
|
|
16956
|
-
}
|
|
16957
|
-
const tipBody = (await tipResp.text()).trim();
|
|
16958
|
-
const tipHeight = Number.parseInt(tipBody, 10);
|
|
16959
|
-
if (!Number.isFinite(tipHeight) || tipHeight <= 0) {
|
|
16960
|
-
return { txid: data.txid ?? txid, confirmations: 1 };
|
|
16961
|
-
}
|
|
16962
|
-
const depth = tipHeight - data.status.block_height + 1;
|
|
16963
|
-
return {
|
|
16964
|
-
txid: data.txid ?? txid,
|
|
16965
|
-
confirmations: depth > 0 ? depth : 0
|
|
16966
|
-
};
|
|
16967
|
-
} catch {
|
|
16968
|
-
return { txid: data.txid ?? txid, confirmations: 1 };
|
|
16969
|
-
}
|
|
16966
|
+
const tipHeight = await this.fetchTipHeight(controller.signal);
|
|
16967
|
+
const depth = tipHeight - data.status.block_height + 1;
|
|
16968
|
+
return {
|
|
16969
|
+
txid: data.txid ?? txid,
|
|
16970
|
+
confirmations: depth > 0 ? depth : 0
|
|
16971
|
+
};
|
|
16970
16972
|
}
|
|
16971
16973
|
return null;
|
|
16972
16974
|
} catch (error) {
|
|
@@ -16974,12 +16976,55 @@ ${auth.clientId}`;
|
|
|
16974
16976
|
if (isAbortError(error)) {
|
|
16975
16977
|
throw new Error(`Request timeout after ${this.timeout}ms`);
|
|
16976
16978
|
}
|
|
16979
|
+
if (isBitcoinTipUnreadableError(error)) {
|
|
16980
|
+
throw error;
|
|
16981
|
+
}
|
|
16977
16982
|
if (getUnknownErrorMessage(error).includes("404")) {
|
|
16978
16983
|
return null;
|
|
16979
16984
|
}
|
|
16980
16985
|
throw error;
|
|
16981
16986
|
}
|
|
16982
16987
|
}
|
|
16988
|
+
/**
|
|
16989
|
+
* Current chain tip height from THIS provider — or throw.
|
|
16990
|
+
*
|
|
16991
|
+
* Every exit is a throw naming the provider and the precise failure, because
|
|
16992
|
+
* the only alternative is inventing a confirmation depth (see the call site).
|
|
16993
|
+
* The single `try` exists solely to attach that name to a transport-level
|
|
16994
|
+
* rejection (DNS, TLS, connection reset, abort); it re-throws the cause
|
|
16995
|
+
* verbatim inside the message and never substitutes a value — authorized for
|
|
16996
|
+
* this case by the Batch 2 plan, §C2.
|
|
16997
|
+
*
|
|
16998
|
+
* @param signal - The caller's AbortSignal, so this read shares the same
|
|
16999
|
+
* timeout budget as the transaction fetch it serves.
|
|
17000
|
+
*/
|
|
17001
|
+
async fetchTipHeight(signal) {
|
|
17002
|
+
const endpoint = `${this.config.providerUrl}/blocks/tip/height`;
|
|
17003
|
+
let tipResp;
|
|
17004
|
+
try {
|
|
17005
|
+
tipResp = await fetch(endpoint, {
|
|
17006
|
+
signal,
|
|
17007
|
+
headers: await this.withAuth()
|
|
17008
|
+
});
|
|
17009
|
+
} catch (error) {
|
|
17010
|
+
throw new BitcoinTipUnreadableError(
|
|
17011
|
+
`${TIP_READ_FAILURE_PREFIX}: GET ${endpoint} threw \u2014 ${getUnknownErrorMessage(error)}`
|
|
17012
|
+
);
|
|
17013
|
+
}
|
|
17014
|
+
if (!tipResp.ok) {
|
|
17015
|
+
throw new BitcoinTipUnreadableError(
|
|
17016
|
+
`${TIP_READ_FAILURE_PREFIX}: GET ${endpoint} \u2192 ${tipResp.status} ${tipResp.statusText}`
|
|
17017
|
+
);
|
|
17018
|
+
}
|
|
17019
|
+
const tipBody = (await tipResp.text()).trim();
|
|
17020
|
+
const tipHeight = Number.parseInt(tipBody, 10);
|
|
17021
|
+
if (!Number.isFinite(tipHeight) || tipHeight <= 0) {
|
|
17022
|
+
throw new BitcoinTipUnreadableError(
|
|
17023
|
+
`${TIP_READ_FAILURE_PREFIX}: GET ${endpoint} returned an unusable tip height "${tipBody.slice(0, 64)}"`
|
|
17024
|
+
);
|
|
17025
|
+
}
|
|
17026
|
+
return tipHeight;
|
|
17027
|
+
}
|
|
16983
17028
|
/**
|
|
16984
17029
|
* Get outputs (vouts) of a Bitcoin transaction
|
|
16985
17030
|
*
|
|
@@ -17614,10 +17659,13 @@ ${auth.clientId}`;
|
|
|
17614
17659
|
* only on unanimity. The confirmed-balance consensus the validators run
|
|
17615
17660
|
* covers `chain_stats` only, so without this the primary provider alone
|
|
17616
17661
|
* could fabricate an unconfirmed UTXO plus a self-consistent parent proof
|
|
17617
|
-
* and inflate the signed balance. Any
|
|
17618
|
-
*
|
|
17619
|
-
*
|
|
17620
|
-
*
|
|
17662
|
+
* and inflate the signed balance. Any verdict disagreement THROWS
|
|
17663
|
+
* (fail-closed) — exclusion on a suppressed proof would deflate the balance
|
|
17664
|
+
* and open a wrongful-liquidation window, so neither direction may proceed
|
|
17665
|
+
* without agreement. A provider that cannot state the chain tip — and only
|
|
17666
|
+
* that failure — is dropped from the quorum rather than aborting the read (it
|
|
17667
|
+
* never counts as agreeing), and falling below `minConsensusProviders`
|
|
17668
|
+
* survivors throws — see `verifyParentIsSelfSpendConsensus`.
|
|
17621
17669
|
*
|
|
17622
17670
|
* The same per-provider `/tx` fetch also returns the parent's outputs, and
|
|
17623
17671
|
* every provider must corroborate each claimed UTXO (index, vault address,
|
|
@@ -17712,10 +17760,26 @@ ${auth.clientId}`;
|
|
|
17712
17760
|
}
|
|
17713
17761
|
/**
|
|
17714
17762
|
* Run the self-spend proof against every configured provider and require
|
|
17715
|
-
* unanimity
|
|
17716
|
-
*
|
|
17763
|
+
* unanimity AMONG THE PROVIDERS THAT ANSWERED. Fail-closed on disagreement:
|
|
17764
|
+
* a verdict mismatch throws and aborts the balance calculation — see
|
|
17717
17765
|
* classifySelfChange for why exclusion is not a safe fallback here.
|
|
17718
17766
|
*
|
|
17767
|
+
* Quorum semantics (2026-09-23, plan C2). ONE failure class is tolerated: a
|
|
17768
|
+
* provider that could not state the chain tip (`BitcoinTipUnreadableError`).
|
|
17769
|
+
* It is ABSENT from the quorum — never counted as agreeing, never allowed to
|
|
17770
|
+
* decide the verdict — and the policy floor, not "at least one", decides when
|
|
17771
|
+
* that absence is fatal: below `minConsensusProviders` surviving readings
|
|
17772
|
+
* there is no cross-check left to trust, and the read fails loudly naming
|
|
17773
|
+
* every provider that dropped out.
|
|
17774
|
+
*
|
|
17775
|
+
* Why only that class. `getTransaction` now throws on an unreadable tip
|
|
17776
|
+
* instead of fabricating `confirmations: 1`; without this carve-out one flaky
|
|
17777
|
+
* `/blocks/tip/height` endpoint would take every balance and spend path down
|
|
17778
|
+
* with it. Every OTHER failure remains fatal, as before: a provider that
|
|
17779
|
+
* answers "I have never seen that transaction" is making a claim about the
|
|
17780
|
+
* chain rather than suffering an outage, and that shape is precisely the
|
|
17781
|
+
* fabricated-UTXO signature the fail-closed rule exists to catch.
|
|
17782
|
+
*
|
|
17719
17783
|
* When the parent IS a unanimous self-spend, every provider's view of the
|
|
17720
17784
|
* parent's OUTPUTS must additionally corroborate the primary's claimed
|
|
17721
17785
|
* UTXOs (index exists, pays the vault, exact value). Without this, a
|
|
@@ -17740,32 +17804,52 @@ ${auth.clientId}`;
|
|
|
17740
17804
|
)
|
|
17741
17805
|
)
|
|
17742
17806
|
);
|
|
17743
|
-
const
|
|
17744
|
-
|
|
17745
|
-
|
|
17746
|
-
|
|
17747
|
-
|
|
17807
|
+
const answered = [];
|
|
17808
|
+
const absences = [];
|
|
17809
|
+
const failures = [];
|
|
17810
|
+
settled.forEach((result, i) => {
|
|
17811
|
+
if (result.status === "fulfilled") {
|
|
17812
|
+
answered.push({ index: i, evaluation: result.value });
|
|
17813
|
+
return;
|
|
17814
|
+
}
|
|
17815
|
+
const described = `${providerName(i)} \u2192 ${result.reason?.message ?? String(result.reason)}`;
|
|
17816
|
+
if (isBitcoinTipUnreadableError(result.reason)) {
|
|
17817
|
+
absences.push(described);
|
|
17818
|
+
return;
|
|
17819
|
+
}
|
|
17820
|
+
failures.push(described);
|
|
17821
|
+
});
|
|
17748
17822
|
if (failures.length > 0) {
|
|
17749
17823
|
throw new Error(
|
|
17750
17824
|
`Self-change classification failed for tx ${parentTxid} on ${failures.length}/${providerConfigs.length} provider(s): ${failures.join("; ")}`
|
|
17751
17825
|
);
|
|
17752
17826
|
}
|
|
17753
|
-
const
|
|
17754
|
-
|
|
17755
|
-
|
|
17756
|
-
|
|
17757
|
-
|
|
17758
|
-
|
|
17827
|
+
const floor = Math.max(1, this.minConsensusProviders);
|
|
17828
|
+
if (answered.length < floor) {
|
|
17829
|
+
throw new Error(
|
|
17830
|
+
`Self-change classification for tx ${parentTxid}: only ${answered.length}/${providerConfigs.length} provider(s) could state a confirmation depth, below this chain's floor of ${floor}. Unreadable tips: ${absences.join("; ")}`
|
|
17831
|
+
);
|
|
17832
|
+
}
|
|
17833
|
+
if (absences.length > 0) {
|
|
17834
|
+
litDebugLog(
|
|
17835
|
+
`[VaultBalance] self-change: tx ${parentTxid} classified on a reduced quorum \u2014 ${answered.length}/${providerConfigs.length} provider(s) answered (floor ${floor}); dropped for an unreadable chain tip: ${absences.join("; ")}`
|
|
17836
|
+
);
|
|
17837
|
+
}
|
|
17838
|
+
const first = answered[0];
|
|
17839
|
+
const disagreements = answered.slice(1).filter((a) => a.evaluation.selfSpend !== first.evaluation.selfSpend).map(
|
|
17840
|
+
(a) => `${providerName(first.index)}=${first.evaluation.selfSpend} vs ${providerName(a.index)}=${a.evaluation.selfSpend}`
|
|
17759
17841
|
);
|
|
17760
17842
|
if (disagreements.length > 0) {
|
|
17761
17843
|
throw new Error(
|
|
17762
17844
|
`Self-change consensus mismatch for tx ${parentTxid}: ${disagreements.join("; ")}. A provider may be compromised or out of sync; refusing to sign.`
|
|
17763
17845
|
);
|
|
17764
17846
|
}
|
|
17765
|
-
if (!
|
|
17847
|
+
if (!first.evaluation.selfSpend) {
|
|
17766
17848
|
return false;
|
|
17767
17849
|
}
|
|
17768
|
-
const outputMismatches =
|
|
17850
|
+
const outputMismatches = answered.map(
|
|
17851
|
+
(a) => a.evaluation.outputMismatch ? `${providerName(a.index)} \u2192 ${a.evaluation.outputMismatch}` : null
|
|
17852
|
+
).filter((m) => m !== null);
|
|
17769
17853
|
if (outputMismatches.length > 0) {
|
|
17770
17854
|
throw new Error(
|
|
17771
17855
|
`Self-change output claim mismatch for tx ${parentTxid}: ${outputMismatches.join("; ")}. The reported UTXO set contradicts the parent transaction; refusing to sign.`
|
|
@@ -18008,16 +18092,6 @@ ${auth.clientId}`;
|
|
|
18008
18092
|
minConfirmations
|
|
18009
18093
|
);
|
|
18010
18094
|
const authorizedSpends = await this.getAuthorizedSpendsFromContract(positionId);
|
|
18011
|
-
for (const spend of authorizedSpends) {
|
|
18012
|
-
const utxoStillExists = utxoSet.utxos.some(
|
|
18013
|
-
(utxo) => utxo.txid === spend.txid && utxo.vout === spend.vout
|
|
18014
|
-
);
|
|
18015
|
-
if (utxoStillExists) {
|
|
18016
|
-
throw new Error(
|
|
18017
|
-
`Authorized UTXO ${spend.txid}:${spend.vout} not yet spent. Transaction was authorized in smart contract but not signed and broadcasted to Bitcoin network. Complete the transaction by signing and broadcasting it.`
|
|
18018
|
-
);
|
|
18019
|
-
}
|
|
18020
|
-
}
|
|
18021
18095
|
const authorizedBalance = authorizedSpends.reduce(
|
|
18022
18096
|
(sum, spend) => sum + spend.satoshis,
|
|
18023
18097
|
0n
|
|
@@ -18313,7 +18387,13 @@ ${auth.clientId}`;
|
|
|
18313
18387
|
allowDevSinglePriceProvider: false,
|
|
18314
18388
|
minBitcoinBalanceConfirmations: 1,
|
|
18315
18389
|
minBitcoinSpendConfirmations: 1,
|
|
18316
|
-
|
|
18390
|
+
// 2 since 2026-09-23. It was 1 because Sepolia ran a single faucet provider
|
|
18391
|
+
// "by design", so the consensus floor was documented as a mainnet-only
|
|
18392
|
+
// guarantee. The registry now holds two, and leaving the floor at 1 meant
|
|
18393
|
+
// Sepolia could never exercise the multi-provider agreement the stale-spend
|
|
18394
|
+
// and balance paths rely on — the one environment where that logic is
|
|
18395
|
+
// supposed to be proved before mainnet.
|
|
18396
|
+
minConsensusProviders: 2
|
|
18317
18397
|
},
|
|
18318
18398
|
[
|
|
18319
18399
|
"ethereum"
|
|
@@ -23922,9 +24002,35 @@ var require_fetch_lit_action_from_ipfs = __commonJS({
|
|
|
23922
24002
|
return mod && mod.__esModule ? mod : { "default": mod };
|
|
23923
24003
|
};
|
|
23924
24004
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
24005
|
+
exports2.computeCidV0 = computeCidV0;
|
|
23925
24006
|
exports2.fetchLitActionCodeFromIpfs = fetchLitActionCodeFromIpfs;
|
|
23926
24007
|
var axios_1 = __importDefault(require_axios());
|
|
24008
|
+
var ethers_1 = require("ethers");
|
|
23927
24009
|
var ipfsCodeCache = /* @__PURE__ */ new Map();
|
|
24010
|
+
var CIDV0 = /^Qm[1-9A-HJ-NP-Za-km-z]{44}$/;
|
|
24011
|
+
var SINGLE_BLOCK_MAX_BYTES = 262144;
|
|
24012
|
+
function varint(n) {
|
|
24013
|
+
const out = [];
|
|
24014
|
+
while (n >= 128) {
|
|
24015
|
+
out.push(n & 127 | 128);
|
|
24016
|
+
n >>>= 7;
|
|
24017
|
+
}
|
|
24018
|
+
out.push(n);
|
|
24019
|
+
return out;
|
|
24020
|
+
}
|
|
24021
|
+
function computeCidV0(content) {
|
|
24022
|
+
const n = varint(content.length);
|
|
24023
|
+
const unixfs = new Uint8Array([8, 2, 18, ...n, ...content, 24, ...n]);
|
|
24024
|
+
const node = new Uint8Array([10, ...varint(unixfs.length), ...unixfs]);
|
|
24025
|
+
return (0, ethers_1.encodeBase58)(new Uint8Array([18, 32, ...(0, ethers_1.getBytes)((0, ethers_1.sha256)(node))]));
|
|
24026
|
+
}
|
|
24027
|
+
function responseBytes(data) {
|
|
24028
|
+
if (data instanceof Uint8Array)
|
|
24029
|
+
return data;
|
|
24030
|
+
if (data instanceof ArrayBuffer)
|
|
24031
|
+
return new Uint8Array(data);
|
|
24032
|
+
return null;
|
|
24033
|
+
}
|
|
23928
24034
|
var GATEWAY_TIMEOUT_MS = 2e4;
|
|
23929
24035
|
var buildGatewayList = (cid, pinataJwt) => {
|
|
23930
24036
|
const gateways = [];
|
|
@@ -23945,6 +24051,9 @@ var require_fetch_lit_action_from_ipfs = __commonJS({
|
|
|
23945
24051
|
}
|
|
23946
24052
|
return cached;
|
|
23947
24053
|
}
|
|
24054
|
+
if (!CIDV0.test(cid)) {
|
|
24055
|
+
throw new Error(`Refusing to fetch LIT Action for ${cid}: only CIDv0 (Qm\u2026) content can be verified`);
|
|
24056
|
+
}
|
|
23948
24057
|
const pinataJwt = options.pinataJwt ?? process.env.PINATA_JWT;
|
|
23949
24058
|
const extraGateways = options.extraGateways?.map((t) => ({ url: t.replace("{cid}", cid) })) ?? [];
|
|
23950
24059
|
const gateways = [...extraGateways, ...buildGatewayList(cid, pinataJwt)];
|
|
@@ -23956,19 +24065,32 @@ var require_fetch_lit_action_from_ipfs = __commonJS({
|
|
|
23956
24065
|
}
|
|
23957
24066
|
const response = await axios_1.default.get(gateway.url, {
|
|
23958
24067
|
timeout: GATEWAY_TIMEOUT_MS,
|
|
24068
|
+
responseType: "arraybuffer",
|
|
23959
24069
|
headers: {
|
|
23960
24070
|
Accept: "text/plain, application/javascript, text/javascript",
|
|
23961
24071
|
...gateway.headers
|
|
23962
24072
|
}
|
|
23963
24073
|
});
|
|
23964
|
-
|
|
23965
|
-
|
|
23966
|
-
|
|
23967
|
-
|
|
23968
|
-
ipfsCodeCache.set(cid, response.data);
|
|
23969
|
-
return response.data;
|
|
24074
|
+
const bytes = responseBytes(response.data);
|
|
24075
|
+
if (!bytes || bytes.length === 0) {
|
|
24076
|
+
failures.push(`${gateway.url}: HTTP ${response.status} returned ${bytes ? "an empty body" : typeof response.data}, expected bytes`);
|
|
24077
|
+
continue;
|
|
23970
24078
|
}
|
|
23971
|
-
|
|
24079
|
+
if (bytes.length > SINGLE_BLOCK_MAX_BYTES) {
|
|
24080
|
+
failures.push(`${gateway.url}: ${bytes.length} bytes exceeds the single-block CIDv0 limit (${SINGLE_BLOCK_MAX_BYTES}); content cannot be verified`);
|
|
24081
|
+
continue;
|
|
24082
|
+
}
|
|
24083
|
+
const actualCid = computeCidV0(bytes);
|
|
24084
|
+
if (actualCid !== cid) {
|
|
24085
|
+
failures.push(`${gateway.url}: content hashes to ${actualCid}, not the requested CID`);
|
|
24086
|
+
continue;
|
|
24087
|
+
}
|
|
24088
|
+
const code = new TextDecoder("utf-8", { fatal: true }).decode(bytes);
|
|
24089
|
+
if (options.debug) {
|
|
24090
|
+
console.log(`\u2705 [fetchLitActionCodeFromIpfs] Fetched and verified from ${gateway.url}`);
|
|
24091
|
+
}
|
|
24092
|
+
ipfsCodeCache.set(cid, code);
|
|
24093
|
+
return code;
|
|
23972
24094
|
} catch (error) {
|
|
23973
24095
|
const message = error instanceof Error ? error.message : String(error);
|
|
23974
24096
|
failures.push(`${gateway.url}: ${message}`);
|
|
@@ -25456,6 +25578,53 @@ var require_pkp_signer_module = __commonJS({
|
|
|
25456
25578
|
}
|
|
25457
25579
|
});
|
|
25458
25580
|
|
|
25581
|
+
// node_modules/@gvnrdao/dh-lit-ops/dist/modules/mainnet-validator-wallets.js
|
|
25582
|
+
var require_mainnet_validator_wallets = __commonJS({
|
|
25583
|
+
"node_modules/@gvnrdao/dh-lit-ops/dist/modules/mainnet-validator-wallets.js"(exports2) {
|
|
25584
|
+
"use strict";
|
|
25585
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
25586
|
+
exports2.MAINNET_OP_VALIDATOR_WALLETS = exports2.SEPOLIA_DEFAULT_VALIDATOR_WALLET = exports2.NON_MAINNET_CHAIN_IDS = void 0;
|
|
25587
|
+
exports2.resolveMainnetValidatorWallet = resolveMainnetValidatorWallet;
|
|
25588
|
+
exports2.NON_MAINNET_CHAIN_IDS = /* @__PURE__ */ new Set([
|
|
25589
|
+
11155111,
|
|
25590
|
+
// Sepolia
|
|
25591
|
+
1337,
|
|
25592
|
+
// Hardhat (DH local deployment chainId)
|
|
25593
|
+
31337
|
|
25594
|
+
// Hardhat (default)
|
|
25595
|
+
]);
|
|
25596
|
+
exports2.SEPOLIA_DEFAULT_VALIDATOR_WALLET = "0xefb258d455a31d061bbeb3de3d2143bdfcb67a6c";
|
|
25597
|
+
exports2.MAINNET_OP_VALIDATOR_WALLETS = {
|
|
25598
|
+
ucdMintValidator: "0x19C8FeE0f8f4b6F9Aa8e521D4CC62F4697CF85af",
|
|
25599
|
+
processPaymentValidator: "0x01480725c1fA026fd4A6bfA3100c691aeC955135",
|
|
25600
|
+
extendPositionValidator: "0xcE08AF213D8d95ad3dD317276F9e93Ab2eD75030",
|
|
25601
|
+
btcWithdrawal: "0x69dCd1204CDB31437CaF7114f74422390b472d3A",
|
|
25602
|
+
loanVaultBtcBalance: "0xc3d549EEb62721750Ff6518f6730Ab0e8D0Fea97",
|
|
25603
|
+
liquidationValidator: "0x66B30C19173005A51f21e2e4180FD7BC8c1d485b",
|
|
25604
|
+
// Non-OAR: verified on-chain by BTCSpendAuthorizer.staleSpendValidatorAddress (set via
|
|
25605
|
+
// AdminModule to this PKP's derived signer). Self-deriving Safe-owned PKP; seed == signer.
|
|
25606
|
+
staleSpendRecoveryValidator: "0x58F9144cF9781c15C061ba86901905a5a19F7661",
|
|
25607
|
+
// Non-OAR: no on-chain consumer verifies these signatures. The Sepolia seed has no key
|
|
25608
|
+
// derivation registered on the mainnet Lit account, so they reuse the Safe-owned
|
|
25609
|
+
// pkp-validator PKP (live derivation, group 2). See
|
|
25610
|
+
// docs/INCIDENT_2026-09-21_MAINNET_PKP_DERIVATION_DECRYPT.md.
|
|
25611
|
+
btcAddressBalance: "0x19524aE4e514a0f08A542596c2DA0B2262c61f48",
|
|
25612
|
+
priceOracle: "0x19524aE4e514a0f08A542596c2DA0B2262c61f48"
|
|
25613
|
+
};
|
|
25614
|
+
function resolveMainnetValidatorWallet(args) {
|
|
25615
|
+
const { registryKey, chainId, wallet } = args;
|
|
25616
|
+
const isNonMainnetChain = Number.isFinite(chainId) && exports2.NON_MAINNET_CHAIN_IDS.has(chainId);
|
|
25617
|
+
if (isNonMainnetChain || !wallet || wallet.toLowerCase() !== exports2.SEPOLIA_DEFAULT_VALIDATOR_WALLET) {
|
|
25618
|
+
return wallet;
|
|
25619
|
+
}
|
|
25620
|
+
if (!registryKey || !Object.prototype.hasOwnProperty.call(exports2.MAINNET_OP_VALIDATOR_WALLETS, registryKey)) {
|
|
25621
|
+
return wallet;
|
|
25622
|
+
}
|
|
25623
|
+
return exports2.MAINNET_OP_VALIDATOR_WALLETS[registryKey];
|
|
25624
|
+
}
|
|
25625
|
+
}
|
|
25626
|
+
});
|
|
25627
|
+
|
|
25459
25628
|
// node_modules/@gvnrdao/dh-lit-ops/dist/utils/async-request.util.js
|
|
25460
25629
|
var require_async_request_util = __commonJS({
|
|
25461
25630
|
"node_modules/@gvnrdao/dh-lit-ops/dist/utils/async-request.util.js"(exports2) {
|
|
@@ -25483,7 +25652,9 @@ var require_async_request_util = __commonJS({
|
|
|
25483
25652
|
});
|
|
25484
25653
|
if (!submitResponse.ok) {
|
|
25485
25654
|
const errorText = await submitResponse.text();
|
|
25486
|
-
|
|
25655
|
+
const retryAfter = submitResponse.status === 429 ? submitResponse.headers.get("retry-after") : null;
|
|
25656
|
+
const retryHint = retryAfter && /^\d+$/.test(retryAfter.trim()) ? ` Retry after ${retryAfter.trim()}s.` : "";
|
|
25657
|
+
throw new Error(`Failed to submit request (${submitResponse.status}): ${errorText}${retryHint}`);
|
|
25487
25658
|
}
|
|
25488
25659
|
const submitEnvelope = await submitResponse.json();
|
|
25489
25660
|
if (!submitEnvelope.success || !submitEnvelope.data?.ticketId) {
|
|
@@ -25761,6 +25932,7 @@ var require_lit_ops_module = __commonJS({
|
|
|
25761
25932
|
var pkp_manager_module_1 = require_pkp_manager_module();
|
|
25762
25933
|
var pkp_minter_module_1 = require_pkp_minter_module();
|
|
25763
25934
|
var pkp_signer_module_1 = require_pkp_signer_module();
|
|
25935
|
+
var mainnet_validator_wallets_1 = require_mainnet_validator_wallets();
|
|
25764
25936
|
var async_request_util_1 = require_async_request_util();
|
|
25765
25937
|
var crypto_1 = require("crypto");
|
|
25766
25938
|
var lit_core_lit_action_client_1 = require_lit_core_lit_action_client();
|
|
@@ -25773,26 +25945,6 @@ var require_lit_ops_module = __commonJS({
|
|
|
25773
25945
|
{ name: "borrower", type: "address" }
|
|
25774
25946
|
]
|
|
25775
25947
|
};
|
|
25776
|
-
var NON_MAINNET_CHAIN_IDS = /* @__PURE__ */ new Set([
|
|
25777
|
-
11155111,
|
|
25778
|
-
// Sepolia
|
|
25779
|
-
1337,
|
|
25780
|
-
// Hardhat (DH local deployment chainId)
|
|
25781
|
-
31337
|
|
25782
|
-
// Hardhat (default)
|
|
25783
|
-
]);
|
|
25784
|
-
var SEPOLIA_DEFAULT_VALIDATOR_WALLET = "0x82db9f515957aa380b596c6ea2bd30cef181f236";
|
|
25785
|
-
var MAINNET_OP_VALIDATOR_WALLETS = {
|
|
25786
|
-
ucdMintValidator: "0x19C8FeE0f8f4b6F9Aa8e521D4CC62F4697CF85af",
|
|
25787
|
-
processPaymentValidator: "0x01480725c1fA026fd4A6bfA3100c691aeC955135",
|
|
25788
|
-
extendPositionValidator: "0xcE08AF213D8d95ad3dD317276F9e93Ab2eD75030",
|
|
25789
|
-
btcWithdrawal: "0x69dCd1204CDB31437CaF7114f74422390b472d3A",
|
|
25790
|
-
loanVaultBtcBalance: "0xc3d549EEb62721750Ff6518f6730Ab0e8D0Fea97",
|
|
25791
|
-
liquidationValidator: "0x66B30C19173005A51f21e2e4180FD7BC8c1d485b",
|
|
25792
|
-
// Non-OAR: verified on-chain by BTCSpendAuthorizer.staleSpendValidatorAddress (set via
|
|
25793
|
-
// AdminModule to this PKP's derived signer). Self-deriving Safe-owned PKP; seed == signer.
|
|
25794
|
-
staleSpendRecoveryValidator: "0x58F9144cF9781c15C061ba86901905a5a19F7661"
|
|
25795
|
-
};
|
|
25796
25948
|
function resolvePkpValidationRegistryAddress(config) {
|
|
25797
25949
|
const fromConfig = config.pkpValidationRegistryAddress;
|
|
25798
25950
|
return fromConfig || process.env.PKP_VALIDATION_REGISTRY_ADDRESS || process.env.PKP_VALIDATION_REGISTRY;
|
|
@@ -27033,17 +27185,18 @@ var require_lit_ops_module = __commonJS({
|
|
|
27033
27185
|
let effectiveValidatorWallet = litActionInfo.validatorWalletAddress;
|
|
27034
27186
|
const jp = jsParams;
|
|
27035
27187
|
const resolvedChainId = Number(jp.chainId ?? jp.auth?.chainId ?? jp.authMessage?.chainId ?? this.config.chainId);
|
|
27036
|
-
const
|
|
27037
|
-
|
|
27038
|
-
|
|
27039
|
-
|
|
27040
|
-
|
|
27041
|
-
|
|
27042
|
-
|
|
27043
|
-
|
|
27044
|
-
|
|
27045
|
-
effectiveValidatorWallet
|
|
27188
|
+
const reg = (0, dh_lit_actions_1.getDeploymentsForNetwork)(this.config.network);
|
|
27189
|
+
const registryKey = Object.keys(reg).find((k) => reg[k]?.cid === litActionInfo.cid);
|
|
27190
|
+
const mainnetWallet = (0, mainnet_validator_wallets_1.resolveMainnetValidatorWallet)({
|
|
27191
|
+
registryKey,
|
|
27192
|
+
chainId: resolvedChainId,
|
|
27193
|
+
wallet: effectiveValidatorWallet
|
|
27194
|
+
});
|
|
27195
|
+
if (mainnetWallet !== effectiveValidatorWallet) {
|
|
27196
|
+
if (this.config.debug) {
|
|
27197
|
+
console.log(`[${label}] mainnet validator remap (${registryKey}, chainId=${Number.isFinite(resolvedChainId) ? resolvedChainId : "unknown\u2192mainnet"}): ${effectiveValidatorWallet} -> ${mainnetWallet}`);
|
|
27046
27198
|
}
|
|
27199
|
+
effectiveValidatorWallet = mainnetWallet;
|
|
27047
27200
|
}
|
|
27048
27201
|
if (process.env.LIT_LANE_VALIDATOR_WALLET_OVERRIDE) {
|
|
27049
27202
|
if (process.env.LIT_LANE_GUARD !== "1") {
|
|
@@ -28210,7 +28363,11 @@ var require_lit_ops_module = __commonJS({
|
|
|
28210
28363
|
error: "sign=true requires price oracle PKP in registry (ethAddress/publicKey) or options.pkpId (Lit jsParams pkpId)"
|
|
28211
28364
|
};
|
|
28212
28365
|
}
|
|
28213
|
-
priceOracleParams.pkpId =
|
|
28366
|
+
priceOracleParams.pkpId = (0, mainnet_validator_wallets_1.resolveMainnetValidatorWallet)({
|
|
28367
|
+
registryKey: "priceOracle",
|
|
28368
|
+
chainId: Number(this.config.chainId),
|
|
28369
|
+
wallet: resolvedPkpId
|
|
28370
|
+
});
|
|
28214
28371
|
}
|
|
28215
28372
|
if (this.config.debug) {
|
|
28216
28373
|
console.log("\u{1F4B0} Calling Price Oracle LIT Action:");
|
|
@@ -40435,7 +40592,7 @@ var require_dist3 = __commonJS({
|
|
|
40435
40592
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports3, p)) __createBinding(exports3, m, p);
|
|
40436
40593
|
};
|
|
40437
40594
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
40438
|
-
exports2.default = exports2.broadcastSignedBitcoinTransaction = exports2.convertEthereumSignatureToBitcoinDER = exports2.CORE_API_TRANSPORT_FAILURE_MARKER = exports2.isCoreApiTransportError = exports2.describeErrorWithCause = exports2.normalizeCoreLitActionResult = exports2.executeLitActionViaCoreApi = exports2.fetchLitActionCodeFromIpfs = exports2.redactPositionIdForLog = exports2.asyncRequest = exports2.TaskQueue = exports2.TicketManager = exports2.PKPSigner = exports2.PKPAuthorizerUtils = exports2.PKPAuthorizer = exports2.PKPMinterUtils = exports2.PKPMinter = exports2.PKPManager = exports2.LitActionExecutor = exports2.LitAuthManager = exports2.LitOps = exports2.cidToHex = exports2.getDeploymentsForNetwork = void 0;
|
|
40595
|
+
exports2.default = exports2.broadcastSignedBitcoinTransaction = exports2.convertEthereumSignatureToBitcoinDER = exports2.CORE_API_TRANSPORT_FAILURE_MARKER = exports2.isCoreApiTransportError = exports2.describeErrorWithCause = exports2.normalizeCoreLitActionResult = exports2.executeLitActionViaCoreApi = exports2.fetchLitActionCodeFromIpfs = exports2.redactPositionIdForLog = exports2.asyncRequest = exports2.TaskQueue = exports2.TicketManager = exports2.PKPSigner = exports2.PKPAuthorizerUtils = exports2.PKPAuthorizer = exports2.PKPMinterUtils = exports2.PKPMinter = exports2.PKPManager = exports2.LitActionExecutor = exports2.LitAuthManager = exports2.resolveMainnetValidatorWallet = exports2.LitOps = exports2.cidToHex = exports2.getDeploymentsForNetwork = void 0;
|
|
40439
40596
|
__exportStar(require_interfaces(), exports2);
|
|
40440
40597
|
var dh_lit_actions_1 = require_pkg_src();
|
|
40441
40598
|
Object.defineProperty(exports2, "getDeploymentsForNetwork", { enumerable: true, get: function() {
|
|
@@ -40448,6 +40605,10 @@ var require_dist3 = __commonJS({
|
|
|
40448
40605
|
Object.defineProperty(exports2, "LitOps", { enumerable: true, get: function() {
|
|
40449
40606
|
return lit_ops_module_1.LitOps;
|
|
40450
40607
|
} });
|
|
40608
|
+
var mainnet_validator_wallets_1 = require_mainnet_validator_wallets();
|
|
40609
|
+
Object.defineProperty(exports2, "resolveMainnetValidatorWallet", { enumerable: true, get: function() {
|
|
40610
|
+
return mainnet_validator_wallets_1.resolveMainnetValidatorWallet;
|
|
40611
|
+
} });
|
|
40451
40612
|
var auth_manager_module_1 = require_auth_manager_module();
|
|
40452
40613
|
Object.defineProperty(exports2, "LitAuthManager", { enumerable: true, get: function() {
|
|
40453
40614
|
return auth_manager_module_1.LitAuthManager;
|
|
@@ -40750,8 +40911,13 @@ function iso(sec) {
|
|
|
40750
40911
|
return new Date(sec * 1e3).toISOString();
|
|
40751
40912
|
}
|
|
40752
40913
|
var PSM_FLOOR_TOLERANCE_BPS = 100;
|
|
40914
|
+
var CANONICAL_MAINNET_USDC = "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48";
|
|
40915
|
+
function stablecoinKindFor(network, stablecoinAddress) {
|
|
40916
|
+
if (network !== "mainnet") return "mock";
|
|
40917
|
+
return stablecoinAddress.toLowerCase() === CANONICAL_MAINNET_USDC.toLowerCase() ? "circle" : "onchain";
|
|
40918
|
+
}
|
|
40753
40919
|
function failureToError(f) {
|
|
40754
|
-
const code = f.kind === "signer-missing" ? "SIGNER_UNAVAILABLE" : f.kind === "unavailable" ? "UPSTREAM_UNAVAILABLE" : f.kind === "not-found" ? "NOT_FOUND" : "UPSTREAM_REJECTED";
|
|
40920
|
+
const code = f.kind === "signer-missing" ? "SIGNER_UNAVAILABLE" : f.kind === "unavailable" ? "UPSTREAM_UNAVAILABLE" : f.kind === "unsupported" ? "NOT_IMPLEMENTED" : f.kind === "not-found" ? "NOT_FOUND" : "UPSTREAM_REJECTED";
|
|
40755
40921
|
const message = f.kind === "malformed" ? `${f.message} (upstream response failed integrity checks)` : f.message;
|
|
40756
40922
|
return boundaryError(code, message, {
|
|
40757
40923
|
source: f.source,
|
|
@@ -41227,7 +41393,7 @@ var BoundaryCore = class {
|
|
|
41227
41393
|
tokenAddress: a.tokenAddress,
|
|
41228
41394
|
spenderAddress: a.spenderAddress,
|
|
41229
41395
|
spenderContract: a.spenderContract,
|
|
41230
|
-
spenderReason: a.spenderContract === "SimplePSMV2" ?
|
|
41396
|
+
spenderReason: a.spenderContract === "SimplePSMV2" ? `the PSM contract itself pulls the ${a.tokenSymbol} it converts (transferFrom), so the ${a.tokenSymbol} allowance goes to the PSM` : "the PSM burns your UCD THROUGH the UCDController (controller.burnFromPsm), so the UCD allowance goes to the UCDController \u2014 a different contract than the PSM, by design",
|
|
41231
41397
|
before: a.before,
|
|
41232
41398
|
amountUnit: q.amountInUnit,
|
|
41233
41399
|
basis: "approvals are planned against the allowance read before signing: none when it already covers the amount; an exact approve when it is 0; a partial allowance is reset to 0 first (some tokens refuse a non-zero \u2192 non-zero approve). Every approve is EXACTLY the input amount \u2014 never unlimited."
|
|
@@ -41286,9 +41452,10 @@ var BoundaryCore = class {
|
|
|
41286
41452
|
chainId: this.deps.chainId,
|
|
41287
41453
|
psmAddress: s.psmAddress,
|
|
41288
41454
|
stablecoinAddress: s.stablecoinAddress,
|
|
41289
|
-
//
|
|
41290
|
-
// practice
|
|
41291
|
-
|
|
41455
|
+
// Labelled by the ACTUAL coin, not the network (C-49): `circle` only for canonical
|
|
41456
|
+
// mainnet USDC, `mock` for the practice token, `onchain` for any other real coin
|
|
41457
|
+
// (e.g. mainnet USDT) — a USDT swap must never render as "real USDC".
|
|
41458
|
+
stablecoinKind: stablecoinKindFor(this.deps.network, s.stablecoinAddress),
|
|
41292
41459
|
stablecoinSymbol: s.stablecoinSymbol,
|
|
41293
41460
|
stablecoinDecimals: s.stablecoinDecimals,
|
|
41294
41461
|
exchangeRate: s.exchangeRate,
|
|
@@ -44270,6 +44437,35 @@ var import_ethers9 = require("ethers");
|
|
|
44270
44437
|
// src/boundary/upstream/shared/external-bridge/card.ts
|
|
44271
44438
|
var import_ethers7 = require("ethers");
|
|
44272
44439
|
init_tx_validator();
|
|
44440
|
+
|
|
44441
|
+
// src/boundary/upstream/shared/external-bridge/card-escape.ts
|
|
44442
|
+
var MAX_VALUE_CHARS = 200;
|
|
44443
|
+
function mustEscape(code) {
|
|
44444
|
+
if (code <= 31 || code === 127) return true;
|
|
44445
|
+
if (code >= 128 && code <= 159) return true;
|
|
44446
|
+
if (code === 8232 || code === 8233) return true;
|
|
44447
|
+
if (code >= 8234 && code <= 8238) return true;
|
|
44448
|
+
if (code >= 8294 && code <= 8297) return true;
|
|
44449
|
+
return false;
|
|
44450
|
+
}
|
|
44451
|
+
function safeValue(raw) {
|
|
44452
|
+
let out = "";
|
|
44453
|
+
for (const ch of String(raw)) {
|
|
44454
|
+
const code = ch.codePointAt(0);
|
|
44455
|
+
out += mustEscape(code) ? `\\u${code.toString(16).padStart(4, "0")}` : ch;
|
|
44456
|
+
if (out.length > MAX_VALUE_CHARS) return `${out.slice(0, MAX_VALUE_CHARS)}\u2026[truncated]`;
|
|
44457
|
+
}
|
|
44458
|
+
return out;
|
|
44459
|
+
}
|
|
44460
|
+
|
|
44461
|
+
// src/boundary/upstream/shared/external-bridge/card.ts
|
|
44462
|
+
function formatBtc(sats) {
|
|
44463
|
+
const negative = sats < 0n;
|
|
44464
|
+
const abs = negative ? -sats : sats;
|
|
44465
|
+
const whole = abs / 10n ** 8n;
|
|
44466
|
+
const frac = (abs % 10n ** 8n).toString().padStart(8, "0").replace(/0+$/, "");
|
|
44467
|
+
return `${negative ? "-" : ""}${whole}${frac ? "." + frac : ""}`;
|
|
44468
|
+
}
|
|
44273
44469
|
function formatUcd(wei) {
|
|
44274
44470
|
const negative = wei < 0n;
|
|
44275
44471
|
const abs = negative ? -wei : wei;
|
|
@@ -44315,15 +44511,15 @@ function cardForTx(tx2) {
|
|
|
44315
44511
|
"Operation: create a new borrowing position (your wallet is the borrower)",
|
|
44316
44512
|
`Term: ${Number(args[4])} months`,
|
|
44317
44513
|
`Position key (PKP id): ${String(args[0])}`,
|
|
44318
|
-
`BTC vault (mainnet form): ${
|
|
44319
|
-
`BTC vault (regtest form): ${
|
|
44514
|
+
`BTC vault (mainnet form): ${safeValue(args[2])}`,
|
|
44515
|
+
`BTC vault (regtest form): ${safeValue(args[3])}`,
|
|
44320
44516
|
`Validator generation: ${Number(args[5])}`,
|
|
44321
44517
|
...head
|
|
44322
44518
|
];
|
|
44323
44519
|
case "addAddress":
|
|
44324
44520
|
return [
|
|
44325
44521
|
"Operation: allowlist a Bitcoin withdrawal destination for YOUR account",
|
|
44326
|
-
`BTC address to allowlist: ${
|
|
44522
|
+
`BTC address to allowlist: ${safeValue(args[0])}`,
|
|
44327
44523
|
"Withdrawals to this address become possible only after the registry's on-chain delay",
|
|
44328
44524
|
...head
|
|
44329
44525
|
];
|
|
@@ -44351,15 +44547,40 @@ function cardForTx(tx2) {
|
|
|
44351
44547
|
`Minimum stablecoin out \u2014 the slippage floor (smallest units): ${String(args[2])}`,
|
|
44352
44548
|
...head
|
|
44353
44549
|
];
|
|
44550
|
+
case "withdrawBTC": {
|
|
44551
|
+
const p = args[0];
|
|
44552
|
+
return [
|
|
44553
|
+
"Operation: withdraw BTC from your vault \u2014 THIS MOVES BITCOIN OUT",
|
|
44554
|
+
`Position: ${safeValue(p.positionId)}`,
|
|
44555
|
+
// The destination is the whole security question of this card. It is a caller-
|
|
44556
|
+
// supplied string, hence safeValue: see the escaping note above.
|
|
44557
|
+
`BTC sent to: ${safeValue(p.withdrawalAddress)}`,
|
|
44558
|
+
`Leaves the vault (fee included): ${formatBtc(BigInt(p.totalDeduction))} BTC (${BigInt(p.totalDeduction)} sats)`,
|
|
44559
|
+
`Collateral remaining after this: ${formatBtc(BigInt(p.newCollateral))} BTC (${BigInt(p.newCollateral)} sats)`,
|
|
44560
|
+
`Spending vault UTXO: ${safeValue(p.utxoTxid)}:${Number(p.utxoVout)}`,
|
|
44561
|
+
...head
|
|
44562
|
+
];
|
|
44563
|
+
}
|
|
44564
|
+
case "setPositionDelegate":
|
|
44565
|
+
return [
|
|
44566
|
+
"Operation: set the DELEGATE for this position \u2014 this address may act on the position on your behalf",
|
|
44567
|
+
`Position: ${safeValue(args[0])}`,
|
|
44568
|
+
`Delegate address: ${safeValue(args[1])}`,
|
|
44569
|
+
"Setting the zero address removes the current delegate",
|
|
44570
|
+
...head
|
|
44571
|
+
];
|
|
44354
44572
|
default:
|
|
44355
|
-
|
|
44573
|
+
throw new Error(
|
|
44574
|
+
`no approval card is defined for the signable function "${name}" \u2014 add a case to cardForTx before this operation can be approved`
|
|
44575
|
+
);
|
|
44356
44576
|
}
|
|
44357
44577
|
}
|
|
44358
44578
|
function cardForTypedData(action, payload) {
|
|
44359
44579
|
const m = payload.message;
|
|
44360
44580
|
return [
|
|
44361
44581
|
`Operation: ${action} \u2014 this signature AUTHORIZES the operation described below; the protocol executes it after your approval`,
|
|
44362
|
-
|
|
44582
|
+
// `detail` here is a server-composed string — same escaping rule as the tx card.
|
|
44583
|
+
...Object.entries(m).map(([k, v]) => `${safeValue(k)}: ${safeValue(v)}`),
|
|
44363
44584
|
`Signing domain: ${String(payload.domain["name"])} v${String(payload.domain["version"])} \xB7 chain ${String(payload.domain["chainId"])}`
|
|
44364
44585
|
];
|
|
44365
44586
|
}
|
|
@@ -44710,12 +44931,10 @@ init_tx_validator();
|
|
|
44710
44931
|
|
|
44711
44932
|
// src/boundary/upstream/shared/quantum.ts
|
|
44712
44933
|
var QUANTUM_WINDOW_SECONDS = 60;
|
|
44713
|
-
var AUTH_VALIDITY_WINDOWS = 3;
|
|
44714
|
-
function authValiditySec() {
|
|
44715
|
-
return QUANTUM_WINDOW_SECONDS * AUTH_VALIDITY_WINDOWS;
|
|
44716
|
-
}
|
|
44717
44934
|
function isAuthFresh(issuedAtSec, nowSec) {
|
|
44718
|
-
|
|
44935
|
+
const sq = Math.floor(issuedAtSec / QUANTUM_WINDOW_SECONDS) * QUANTUM_WINDOW_SECONDS;
|
|
44936
|
+
const cq = Math.floor(nowSec / QUANTUM_WINDOW_SECONDS) * QUANTUM_WINDOW_SECONDS;
|
|
44937
|
+
return sq === cq - QUANTUM_WINDOW_SECONDS || sq === cq || sq === cq + QUANTUM_WINDOW_SECONDS;
|
|
44719
44938
|
}
|
|
44720
44939
|
function isStrictCurrentQuantum(issuedAtSec, nowSec) {
|
|
44721
44940
|
return issuedAtSec <= nowSec && Math.floor(issuedAtSec / QUANTUM_WINDOW_SECONDS) === Math.floor(nowSec / QUANTUM_WINDOW_SECONDS);
|
|
@@ -44756,7 +44975,7 @@ var SafeCeremony = class {
|
|
|
44756
44975
|
if (!auth.ok) return auth.refusal;
|
|
44757
44976
|
if (!isAuthFresh(issuedAtSec, surface.nowSec())) {
|
|
44758
44977
|
return this.refuse(
|
|
44759
|
-
`${p.action}: the owners' authorization expired \u2014 issued
|
|
44978
|
+
`${p.action}: the owners' authorization expired \u2014 issued outside the past/current/next quantum window (${QUANTUM_WINDOW_SECONDS}s quanta); gather the owners and sign again`
|
|
44760
44979
|
);
|
|
44761
44980
|
}
|
|
44762
44981
|
const raw = await executor.signTransaction({
|
|
@@ -51475,7 +51694,6 @@ var init_deployment_addresses = __esm2({
|
|
|
51475
51694
|
PositionDelegateRegistry: "0x482369De283622E7b05731875ec137d4E3D208F9",
|
|
51476
51695
|
FeeRecipientRegistry: "0x95795F8403DDb629E8527B2934C4e71f5fC0C374",
|
|
51477
51696
|
BitcoinWithdrawalAddressRegistry: "0x6376D392097F0A81e51BD83960A97EA20eaf1dbe",
|
|
51478
|
-
CarryAgentRegistry: "0x5595CB538D44E6Cf179D20364fD631D0477e69f7",
|
|
51479
51697
|
AgentDelegationRegistry: "0x6AE7fc6bE0925126b9D25b1B7Ce5AD5d127ec025",
|
|
51480
51698
|
DHAgentDelegate: "0xa5A14489ae883960df6E1463A41a47aBE9Ecc5AF",
|
|
51481
51699
|
AgentModuleFactory: "0x1Fd3aCa2C030Cf77ce28Af9694D3Bb3034ACa2E5"
|
|
@@ -51745,8 +51963,6 @@ var init_deployment_addresses = __esm2({
|
|
|
51745
51963
|
OPERATION_AUTHORIZATION_REGISTRY_IMPL: "0xe0D981B60351f0f8fFDA2b50C8180Fb37CeF3883",
|
|
51746
51964
|
BITCOIN_WITHDRAWAL_ADDRESS_REGISTRY: "0x6376D392097F0A81e51BD83960A97EA20eaf1dbe",
|
|
51747
51965
|
BITCOIN_WITHDRAWAL_ADDRESS_REGISTRY_IMPL: "0x76E0a2c9d89562fD7c50b5f554d7fa25957e39Db",
|
|
51748
|
-
CARRY_AGENT_REGISTRY: "0x5595CB538D44E6Cf179D20364fD631D0477e69f7",
|
|
51749
|
-
CARRY_AGENT_REGISTRY_IMPL: "0x1b11a3D5e46F3672E643c997f0d569DFf0b64a01",
|
|
51750
51966
|
AGENT_DELEGATION_REGISTRY: "0x6AE7fc6bE0925126b9D25b1B7Ce5AD5d127ec025",
|
|
51751
51967
|
AGENT_DELEGATION_REGISTRY_IMPL: "0xE931E4b9ceF2A48Ac7D57192da4B523756cFC310",
|
|
51752
51968
|
DH_AGENT_DELEGATE: "0xa5A14489ae883960df6E1463A41a47aBE9Ecc5AF"
|
|
@@ -51778,7 +51994,6 @@ var init_deployment_addresses = __esm2({
|
|
|
51778
51994
|
PositionDelegateRegistry: "0x482369De283622E7b05731875ec137d4E3D208F9",
|
|
51779
51995
|
FeeRecipientRegistry: "0x95795F8403DDb629E8527B2934C4e71f5fC0C374",
|
|
51780
51996
|
BitcoinWithdrawalAddressRegistry: "0x6376D392097F0A81e51BD83960A97EA20eaf1dbe",
|
|
51781
|
-
CarryAgentRegistry: "0x5595CB538D44E6Cf179D20364fD631D0477e69f7",
|
|
51782
51997
|
AgentDelegationRegistry: "0x6AE7fc6bE0925126b9D25b1B7Ce5AD5d127ec025",
|
|
51783
51998
|
DHAgentDelegate: "0xa5A14489ae883960df6E1463A41a47aBE9Ecc5AF",
|
|
51784
51999
|
AgentModuleFactory: "0x1Fd3aCa2C030Cf77ce28Af9694D3Bb3034ACa2E5"
|
|
@@ -52753,113 +52968,113 @@ var require_pkg_src2 = __commonJS2({
|
|
|
52753
52968
|
deployedAt: 1784569687492,
|
|
52754
52969
|
size: 4140,
|
|
52755
52970
|
hash: "4c0d65bf1f33cdac22a78fd8c4764319cc3fe00650e0fe7fa8a6090d9a318a7b",
|
|
52756
|
-
validatorWalletAddress: "
|
|
52971
|
+
validatorWalletAddress: "0xefb258d455a31d061bbeb3de3d2143bdfcb67a6c",
|
|
52757
52972
|
pkp: {
|
|
52758
52973
|
publicKey: "0x04ec0e3acc40884e3f366ca469d08899eb640ad5259fa196b0238075086208a9f8732a3175704f35f0bcc28e07406cfb24c254efd1e7355640577330f0d2dd755f",
|
|
52759
|
-
ethAddress: "
|
|
52974
|
+
ethAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C"
|
|
52760
52975
|
}
|
|
52761
52976
|
},
|
|
52762
52977
|
btcTransactionSigner: {
|
|
52763
|
-
cid: "
|
|
52978
|
+
cid: "QmULkz7hwwqsyLwY23U14dnartdVuSNMrykt69PaNiAq7U",
|
|
52764
52979
|
authorizedCidHex: cidToHex(
|
|
52765
|
-
"
|
|
52980
|
+
"QmULkz7hwwqsyLwY23U14dnartdVuSNMrykt69PaNiAq7U"
|
|
52766
52981
|
),
|
|
52767
52982
|
name: "Btc Transaction Signer",
|
|
52768
52983
|
description: "Production Btc Transaction Signer",
|
|
52769
52984
|
version: "1.1.1",
|
|
52770
52985
|
deployed: true,
|
|
52771
|
-
deployedAt:
|
|
52772
|
-
size:
|
|
52773
|
-
hash: "
|
|
52986
|
+
deployedAt: 1790246185256,
|
|
52987
|
+
size: 73313,
|
|
52988
|
+
hash: "d8b6bc646ba33fee7d46c8e9b281de776081ea6f182f56fd15d4c52aaf3dd030"
|
|
52774
52989
|
},
|
|
52775
52990
|
ucdMintValidator: {
|
|
52776
|
-
cid: "
|
|
52991
|
+
cid: "QmcxVSn9saEPGBS6mqPhNefgW83V2qeZjjXbhwYLP373xe",
|
|
52777
52992
|
authorizedCidHex: cidToHex(
|
|
52778
|
-
"
|
|
52993
|
+
"QmcxVSn9saEPGBS6mqPhNefgW83V2qeZjjXbhwYLP373xe"
|
|
52779
52994
|
),
|
|
52780
52995
|
name: "Ucd Mint Validator",
|
|
52781
52996
|
description: "Production Ucd Mint Validator",
|
|
52782
|
-
version: "1.
|
|
52997
|
+
version: "1.3.0",
|
|
52783
52998
|
deployed: true,
|
|
52784
|
-
deployedAt:
|
|
52785
|
-
size:
|
|
52786
|
-
hash: "
|
|
52787
|
-
validatorWalletAddress: "
|
|
52999
|
+
deployedAt: 1790246219868,
|
|
53000
|
+
size: 90022,
|
|
53001
|
+
hash: "65e8cb778c2b767ae6eb37cb5db7b4c5a3f2468d508463c847c83c1b6825fadd",
|
|
53002
|
+
validatorWalletAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C",
|
|
52788
53003
|
pkp: {
|
|
52789
53004
|
publicKey: "0x041ab17cd91fc5c0b761eea6092d032807561b621b82c488826776e04a9158d61ba64d809a4729f0501289d980732cb06d8dfd06999dd9c8efd2f495dad78b31bb",
|
|
52790
|
-
ethAddress: "
|
|
53005
|
+
ethAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C"
|
|
52791
53006
|
}
|
|
52792
53007
|
},
|
|
52793
53008
|
processPaymentValidator: {
|
|
52794
|
-
cid: "
|
|
53009
|
+
cid: "QmWFbxJkfxhCtES4wrePWQkYtjhtrP1tohvn9d1r9N5Hd8",
|
|
52795
53010
|
authorizedCidHex: cidToHex(
|
|
52796
|
-
"
|
|
53011
|
+
"QmWFbxJkfxhCtES4wrePWQkYtjhtrP1tohvn9d1r9N5Hd8"
|
|
52797
53012
|
),
|
|
52798
53013
|
name: "Process Payment Validator",
|
|
52799
53014
|
description: "Production Process Payment Validator",
|
|
52800
53015
|
version: "1.2.1",
|
|
52801
53016
|
deployed: true,
|
|
52802
|
-
deployedAt:
|
|
52803
|
-
size:
|
|
52804
|
-
hash: "
|
|
52805
|
-
validatorWalletAddress: "
|
|
53017
|
+
deployedAt: 1790246225795,
|
|
53018
|
+
size: 85107,
|
|
53019
|
+
hash: "25ecf952c4c44c40b0920b92d57906e7010ed9a38e2ba41ccdee6d3377c2b596",
|
|
53020
|
+
validatorWalletAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C",
|
|
52806
53021
|
pkp: {
|
|
52807
53022
|
publicKey: "0x04cfccb9b6c7addc79469c0e9fafebef4c70801302c62cdb26b610723a9b8527d23f98a40158c7340d83fd0e62d02b5ec74c12f7a86d98e8c6973b4811110f19ad",
|
|
52808
|
-
ethAddress: "
|
|
53023
|
+
ethAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C"
|
|
52809
53024
|
}
|
|
52810
53025
|
},
|
|
52811
53026
|
extendPositionValidator: {
|
|
52812
|
-
cid: "
|
|
53027
|
+
cid: "QmZ3g7g5DkgU1gEYpFjprQf3sctUHtGjNQVYezw2bnPGEX",
|
|
52813
53028
|
authorizedCidHex: cidToHex(
|
|
52814
|
-
"
|
|
53029
|
+
"QmZ3g7g5DkgU1gEYpFjprQf3sctUHtGjNQVYezw2bnPGEX"
|
|
52815
53030
|
),
|
|
52816
53031
|
name: "Extend Position Validator",
|
|
52817
53032
|
description: "Production Extend Position Validator",
|
|
52818
53033
|
version: "1.2.1",
|
|
52819
53034
|
deployed: true,
|
|
52820
|
-
deployedAt:
|
|
52821
|
-
size:
|
|
52822
|
-
hash: "
|
|
52823
|
-
validatorWalletAddress: "
|
|
53035
|
+
deployedAt: 1790246231975,
|
|
53036
|
+
size: 82853,
|
|
53037
|
+
hash: "25d4887b7f646649db2bb7f2bfb77d039db83228a6c454377ca26c779b0903cc",
|
|
53038
|
+
validatorWalletAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C",
|
|
52824
53039
|
pkp: {
|
|
52825
53040
|
publicKey: "0x04e52338f6a0c3362800f1a94c4c8f08be5030dde0fa217388c53d1c1a4790f4443c9f2886b2d2d8f4b75a9a156e9b028011b1a1cf7648da0e556aa980ec692836",
|
|
52826
|
-
ethAddress: "
|
|
53041
|
+
ethAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C"
|
|
52827
53042
|
}
|
|
52828
53043
|
},
|
|
52829
53044
|
btcWithdrawal: {
|
|
52830
|
-
cid: "
|
|
53045
|
+
cid: "QmbRaaMQr1jCctDGe8mPADsUz1rkb4frT1YqSKroiXjzyP",
|
|
52831
53046
|
authorizedCidHex: cidToHex(
|
|
52832
|
-
"
|
|
53047
|
+
"QmbRaaMQr1jCctDGe8mPADsUz1rkb4frT1YqSKroiXjzyP"
|
|
52833
53048
|
),
|
|
52834
53049
|
name: "Btc Withdrawal",
|
|
52835
53050
|
description: "Production Btc Withdrawal",
|
|
52836
53051
|
version: "1.2.7",
|
|
52837
53052
|
deployed: true,
|
|
52838
|
-
deployedAt:
|
|
52839
|
-
size:
|
|
52840
|
-
hash: "
|
|
52841
|
-
validatorWalletAddress: "
|
|
53053
|
+
deployedAt: 1790246239599,
|
|
53054
|
+
size: 101228,
|
|
53055
|
+
hash: "2ed25eca6cc80a43061b7ad119737af48158fdb61d59f10cd06cea51b607f112",
|
|
53056
|
+
validatorWalletAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C",
|
|
52842
53057
|
pkp: {
|
|
52843
53058
|
publicKey: "0x043616787c5432415c24378c4ef48de2bcd6bb7b575b837e3cff09171802662da7105d79586c7659677a0ecbaddac4cce06cb2a11f69a16fa0c4d7002ac7d51a4d",
|
|
52844
|
-
ethAddress: "
|
|
53059
|
+
ethAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C"
|
|
52845
53060
|
}
|
|
52846
53061
|
},
|
|
52847
53062
|
liquidationValidator: {
|
|
52848
|
-
cid: "
|
|
53063
|
+
cid: "QmTs2w8gfAwWZLbzJZg2CZmiLhVXS5kbMgaj42Zuxfodpb",
|
|
52849
53064
|
authorizedCidHex: cidToHex(
|
|
52850
|
-
"
|
|
53065
|
+
"QmTs2w8gfAwWZLbzJZg2CZmiLhVXS5kbMgaj42Zuxfodpb"
|
|
52851
53066
|
),
|
|
52852
53067
|
name: "Liquidation Validator",
|
|
52853
53068
|
description: "Production Liquidation Validator",
|
|
52854
53069
|
version: "1.2.1",
|
|
52855
53070
|
deployed: true,
|
|
52856
|
-
deployedAt:
|
|
52857
|
-
size:
|
|
52858
|
-
hash: "
|
|
52859
|
-
validatorWalletAddress: "
|
|
53071
|
+
deployedAt: 1790246247904,
|
|
53072
|
+
size: 70308,
|
|
53073
|
+
hash: "582ccf0ec7f715195e20fdc885996743cb42125b64173424e360ee63db62bbd8",
|
|
53074
|
+
validatorWalletAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C",
|
|
52860
53075
|
pkp: {
|
|
52861
53076
|
publicKey: "0x041a241de58976c13e3d7ca5a18e494f7330151e3818706135d50176e78ffb673e58b11f0b67a87c73fade6c6b27d6e7a7377ea9f4c10bf31880f1d725f18cc6f8",
|
|
52862
|
-
ethAddress: "
|
|
53077
|
+
ethAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C"
|
|
52863
53078
|
}
|
|
52864
53079
|
},
|
|
52865
53080
|
priceOracle: {
|
|
@@ -52874,28 +53089,28 @@ var require_pkg_src2 = __commonJS2({
|
|
|
52874
53089
|
deployedAt: 1781116663270,
|
|
52875
53090
|
size: 8695,
|
|
52876
53091
|
hash: "ba20ade60a7fa5acd80dadfafa179c507388cfe6ce48a22a672d70b317ffcc74",
|
|
52877
|
-
validatorWalletAddress: "
|
|
53092
|
+
validatorWalletAddress: "0xefb258d455a31d061bbeb3de3d2143bdfcb67a6c",
|
|
52878
53093
|
pkp: {
|
|
52879
53094
|
publicKey: "0x043beaa1da47875601a8d6f430b1438ee2d4732eefd06e5c63a474bbdaf9e7df1797b1b951e041b627c2bf839788164825324c9cbd1e2d6f740fdd4bff69b1900b",
|
|
52880
|
-
ethAddress: "
|
|
53095
|
+
ethAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C"
|
|
52881
53096
|
}
|
|
52882
53097
|
},
|
|
52883
53098
|
loanVaultBtcBalance: {
|
|
52884
|
-
cid: "
|
|
53099
|
+
cid: "QmZ27xCzuoaAhWxRsMPsUQkp45a8WPBb21uhxwchw3LG5W",
|
|
52885
53100
|
authorizedCidHex: cidToHex(
|
|
52886
|
-
"
|
|
53101
|
+
"QmZ27xCzuoaAhWxRsMPsUQkp45a8WPBb21uhxwchw3LG5W"
|
|
52887
53102
|
),
|
|
52888
53103
|
name: "Loan Vault Btc Balance",
|
|
52889
53104
|
description: "Production Loan Vault Btc Balance",
|
|
52890
53105
|
version: "1.2.1",
|
|
52891
53106
|
deployed: true,
|
|
52892
|
-
deployedAt:
|
|
52893
|
-
size:
|
|
52894
|
-
hash: "
|
|
52895
|
-
validatorWalletAddress: "
|
|
53107
|
+
deployedAt: 1790179961079,
|
|
53108
|
+
size: 60046,
|
|
53109
|
+
hash: "922e86c0a667fe0c0945771f84aa6b9fe08be9c96dd2f73a9c5cb257d24e22b0",
|
|
53110
|
+
validatorWalletAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C",
|
|
52896
53111
|
pkp: {
|
|
52897
53112
|
publicKey: "0x043616787c5432415c24378c4ef48de2bcd6bb7b575b837e3cff09171802662da7105d79586c7659677a0ecbaddac4cce06cb2a11f69a16fa0c4d7002ac7d51a4d",
|
|
52898
|
-
ethAddress: "
|
|
53113
|
+
ethAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C"
|
|
52899
53114
|
}
|
|
52900
53115
|
},
|
|
52901
53116
|
// btc-address-balance (Option B) — address-only signed total balance via
|
|
@@ -52905,21 +53120,21 @@ var require_pkg_src2 = __commonJS2({
|
|
|
52905
53120
|
// Requires BitcoinProviderRegistry.addAllowedCid(chainId, keccak256(utf8(cid)))
|
|
52906
53121
|
// on each target chain (the action decrypts registry slots). No OAR entry.
|
|
52907
53122
|
btcAddressBalance: {
|
|
52908
|
-
cid: "
|
|
53123
|
+
cid: "QmVVjB6zCBiXFKffhQPYUAZhj7TXduuvcrPqKtHa3DMXhN",
|
|
52909
53124
|
authorizedCidHex: cidToHex(
|
|
52910
|
-
"
|
|
53125
|
+
"QmVVjB6zCBiXFKffhQPYUAZhj7TXduuvcrPqKtHa3DMXhN"
|
|
52911
53126
|
),
|
|
52912
53127
|
name: "Btc Address Balance",
|
|
52913
53128
|
description: "Address-only signed total BTC balance via registry consensus (no positionId, no price)",
|
|
52914
53129
|
version: "0.2.1",
|
|
52915
53130
|
deployed: true,
|
|
52916
|
-
deployedAt:
|
|
52917
|
-
size:
|
|
52918
|
-
hash: "
|
|
52919
|
-
validatorWalletAddress: "
|
|
53131
|
+
deployedAt: 1790179971315,
|
|
53132
|
+
size: 30295,
|
|
53133
|
+
hash: "2c67d9cfa4d50e835fbb28ae50e80217ceb2be3bb862c89290aadf43fdc739c9",
|
|
53134
|
+
validatorWalletAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C",
|
|
52920
53135
|
pkp: {
|
|
52921
53136
|
publicKey: "0x0498cbb31facfa26e3ec83ccdabfe4fe341ca0282e0c3cb81da7113723b9726e1e49efa92165cc3faa66ced4454cea56dbab12267852d6525a55d7c4f128b912cd",
|
|
52922
|
-
ethAddress: "
|
|
53137
|
+
ethAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C"
|
|
52923
53138
|
}
|
|
52924
53139
|
},
|
|
52925
53140
|
alwaysSigner: {
|
|
@@ -52949,48 +53164,48 @@ var require_pkg_src2 = __commonJS2({
|
|
|
52949
53164
|
hash: "03ee5be239c91c735d2c95db89a0d1b77e602cfc18af8eb64b3281fddcd90a72"
|
|
52950
53165
|
},
|
|
52951
53166
|
agentModuleExecutor: {
|
|
52952
|
-
cid: "
|
|
53167
|
+
cid: "QmSwPPvQhT7UhcuVA2m3UxGhVj5WqMpDvYNKU1228QLFsX",
|
|
52953
53168
|
authorizedCidHex: cidToHex(
|
|
52954
|
-
"
|
|
53169
|
+
"QmSwPPvQhT7UhcuVA2m3UxGhVj5WqMpDvYNKU1228QLFsX"
|
|
52955
53170
|
),
|
|
52956
53171
|
name: "Agent Module Executor",
|
|
52957
53172
|
description: "Production Agent Module Executor",
|
|
52958
53173
|
version: "1.1.1",
|
|
52959
53174
|
deployed: true,
|
|
52960
|
-
deployedAt:
|
|
52961
|
-
size:
|
|
52962
|
-
hash: "
|
|
53175
|
+
deployedAt: 1790179978959,
|
|
53176
|
+
size: 14688,
|
|
53177
|
+
hash: "8edb9b12c784c8d7d153cce97235584c24665a788767ae68713dce91109ab35e"
|
|
52963
53178
|
},
|
|
52964
53179
|
staleSpendRecoveryValidator: {
|
|
52965
|
-
cid: "
|
|
53180
|
+
cid: "Qmarj59zdSSgivkimryrdvnyZqH5YpTimKj1LivXNBHmNz",
|
|
52966
53181
|
authorizedCidHex: cidToHex(
|
|
52967
|
-
"
|
|
53182
|
+
"Qmarj59zdSSgivkimryrdvnyZqH5YpTimKj1LivXNBHmNz"
|
|
52968
53183
|
),
|
|
52969
53184
|
name: "Stale Spend Recovery Validator",
|
|
52970
53185
|
description: "Production Stale Spend Recovery Validator",
|
|
52971
53186
|
version: "1.1.2",
|
|
52972
53187
|
deployed: true,
|
|
52973
|
-
deployedAt:
|
|
52974
|
-
size:
|
|
52975
|
-
hash: "
|
|
52976
|
-
validatorWalletAddress: "
|
|
53188
|
+
deployedAt: 1790246256280,
|
|
53189
|
+
size: 48143,
|
|
53190
|
+
hash: "ec9236bcbe0af24d3e1844791fc8fe37371bbecd8ce95d02e13f7c6e1fc7d94c",
|
|
53191
|
+
validatorWalletAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C",
|
|
52977
53192
|
pkp: {
|
|
52978
53193
|
publicKey: "0x046da0ad6da7dd4a0063cbeac6f2bdb6a9889c2178b23470833356a8ee5630f7f0eee0db348d9d9aaaadd23eccf0063c8f68ee5e446abe30b882bf1de4c932bc21",
|
|
52979
|
-
ethAddress: "
|
|
53194
|
+
ethAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C"
|
|
52980
53195
|
}
|
|
52981
53196
|
},
|
|
52982
53197
|
btcUtxoInvalidator: {
|
|
52983
|
-
cid: "
|
|
53198
|
+
cid: "QmbS44bGcmKYF64Cu35qzsk9sxiU4Umde8Z3q24ZnEbQvX",
|
|
52984
53199
|
authorizedCidHex: cidToHex(
|
|
52985
|
-
"
|
|
53200
|
+
"QmbS44bGcmKYF64Cu35qzsk9sxiU4Umde8Z3q24ZnEbQvX"
|
|
52986
53201
|
),
|
|
52987
53202
|
name: "Btc Utxo Invalidator",
|
|
52988
53203
|
description: "Production Btc Utxo Invalidator",
|
|
52989
53204
|
version: "1.0.0",
|
|
52990
53205
|
deployed: true,
|
|
52991
|
-
deployedAt:
|
|
52992
|
-
size:
|
|
52993
|
-
hash: "
|
|
53206
|
+
deployedAt: 1790246264563,
|
|
53207
|
+
size: 69219,
|
|
53208
|
+
hash: "bda048d8cd6b5a39c2774bcf1320e82d1eea935c2a521006fb8b887e13b6dd8d"
|
|
52994
53209
|
}
|
|
52995
53210
|
};
|
|
52996
53211
|
function getDeploymentsForNetwork(network) {
|
|
@@ -53758,7 +53973,10 @@ ${errorReport}`);
|
|
|
53758
53973
|
BTCSpendAuthorizer: "0xfBbF108486fa07F1B06a811C5b66ed68DD9c508a",
|
|
53759
53974
|
BitcoinProviderRegistry: "0x4ab3Fb96e02893Ed6FAa61bad1918390c8DbbFFC",
|
|
53760
53975
|
LITActionValidator: "0xD2c5d59c2CC5c409AC65ce0A817236aeC6869512",
|
|
53761
|
-
PositionDelegateRegistry: "0xf0aa2678aD4F60f49e8F7725089B5E86B7F8FE4C"
|
|
53976
|
+
PositionDelegateRegistry: "0xf0aa2678aD4F60f49e8F7725089B5E86B7F8FE4C",
|
|
53977
|
+
TermManagerModule: "0xDB99CdF883ffa38acD099bC39F8d1f4508c9239E",
|
|
53978
|
+
UCDController: "0x4b4f8063048bCD59D469219E3f07C6aaDF4f6157",
|
|
53979
|
+
LiquidationManagerModule: "0x74B28695352E7bf736D6c9F76ccb7B4439477De9"
|
|
53762
53980
|
},
|
|
53763
53981
|
11155111: {
|
|
53764
53982
|
PositionManager: "0x68e0507D982AEBF1D1C1Af8FBbd842327e2deeFF",
|
|
@@ -53766,7 +53984,10 @@ ${errorReport}`);
|
|
|
53766
53984
|
BTCSpendAuthorizer: "0xd7E9Eb5eE53f1d9ee55Dc162bBC7486bE437B6bD",
|
|
53767
53985
|
BitcoinProviderRegistry: "0xbfA0c48B070D0a9A9CD27469AeacFD2d4261cEE2",
|
|
53768
53986
|
LITActionValidator: "0x54eECd7C90F8A8fac27749Ba30BbE8AFBAccc856",
|
|
53769
|
-
PositionDelegateRegistry: "0x482369De283622E7b05731875ec137d4E3D208F9"
|
|
53987
|
+
PositionDelegateRegistry: "0x482369De283622E7b05731875ec137d4E3D208F9",
|
|
53988
|
+
TermManagerModule: "0x94Adc6F9558368B1482197584f1fc7133Ecf835b",
|
|
53989
|
+
UCDController: "0x360Bde4e489ee94E26601B206932De09EE60FF04",
|
|
53990
|
+
LiquidationManagerModule: "0xC4AB00f39e7ceD812F5C67058C9fa44e15d40e76"
|
|
53770
53991
|
}
|
|
53771
53992
|
};
|
|
53772
53993
|
function getPinnedContractAddresses(chainId) {
|
|
@@ -53952,10 +54173,10 @@ ${errorReport}`);
|
|
|
53952
54173
|
};
|
|
53953
54174
|
}
|
|
53954
54175
|
const ratioBigInt = collateralValueUsd * UCD_TOKEN_DECIMALS * 10000n / ucdDebt;
|
|
53955
|
-
const
|
|
54176
|
+
const collateralRatioBps2 = Number(ratioBigInt);
|
|
53956
54177
|
return {
|
|
53957
54178
|
collateralValueUsd,
|
|
53958
|
-
collateralRatioBps
|
|
54179
|
+
collateralRatioBps: collateralRatioBps2
|
|
53959
54180
|
};
|
|
53960
54181
|
}
|
|
53961
54182
|
function hasSufficientCollateralForDebt(collateralValueUsd, currentDebt, additionalDebt, requiredRatioBps) {
|
|
@@ -54809,6 +55030,17 @@ ${auth.clientId}`;
|
|
|
54809
55030
|
);
|
|
54810
55031
|
}
|
|
54811
55032
|
}
|
|
55033
|
+
var TIP_READ_FAILURE_PREFIX = "Bitcoin tip-height read failed";
|
|
55034
|
+
var BitcoinTipUnreadableError = class extends Error {
|
|
55035
|
+
constructor(message) {
|
|
55036
|
+
super(message);
|
|
55037
|
+
this.isBitcoinTipUnreadable = true;
|
|
55038
|
+
this.name = "BitcoinTipUnreadableError";
|
|
55039
|
+
}
|
|
55040
|
+
};
|
|
55041
|
+
function isBitcoinTipUnreadableError(error) {
|
|
55042
|
+
return typeof error === "object" && error !== null && error.isBitcoinTipUnreadable === true;
|
|
55043
|
+
}
|
|
54812
55044
|
var BitcoinDataProvider = class {
|
|
54813
55045
|
constructor(config) {
|
|
54814
55046
|
this.config = config;
|
|
@@ -55260,27 +55492,12 @@ ${auth.clientId}`;
|
|
|
55260
55492
|
if (!data.status.confirmed || !data.status.block_height) {
|
|
55261
55493
|
return { txid: data.txid ?? txid, confirmations: 0 };
|
|
55262
55494
|
}
|
|
55263
|
-
|
|
55264
|
-
|
|
55265
|
-
|
|
55266
|
-
|
|
55267
|
-
|
|
55268
|
-
|
|
55269
|
-
return { txid: data.txid ?? txid, confirmations: 1 };
|
|
55270
|
-
}
|
|
55271
|
-
const tipBody = (await tipResp.text()).trim();
|
|
55272
|
-
const tipHeight = Number.parseInt(tipBody, 10);
|
|
55273
|
-
if (!Number.isFinite(tipHeight) || tipHeight <= 0) {
|
|
55274
|
-
return { txid: data.txid ?? txid, confirmations: 1 };
|
|
55275
|
-
}
|
|
55276
|
-
const depth = tipHeight - data.status.block_height + 1;
|
|
55277
|
-
return {
|
|
55278
|
-
txid: data.txid ?? txid,
|
|
55279
|
-
confirmations: depth > 0 ? depth : 0
|
|
55280
|
-
};
|
|
55281
|
-
} catch {
|
|
55282
|
-
return { txid: data.txid ?? txid, confirmations: 1 };
|
|
55283
|
-
}
|
|
55495
|
+
const tipHeight = await this.fetchTipHeight(controller.signal);
|
|
55496
|
+
const depth = tipHeight - data.status.block_height + 1;
|
|
55497
|
+
return {
|
|
55498
|
+
txid: data.txid ?? txid,
|
|
55499
|
+
confirmations: depth > 0 ? depth : 0
|
|
55500
|
+
};
|
|
55284
55501
|
}
|
|
55285
55502
|
return null;
|
|
55286
55503
|
} catch (error) {
|
|
@@ -55288,12 +55505,55 @@ ${auth.clientId}`;
|
|
|
55288
55505
|
if (isAbortError(error)) {
|
|
55289
55506
|
throw new Error(`Request timeout after ${this.timeout}ms`);
|
|
55290
55507
|
}
|
|
55508
|
+
if (isBitcoinTipUnreadableError(error)) {
|
|
55509
|
+
throw error;
|
|
55510
|
+
}
|
|
55291
55511
|
if (getUnknownErrorMessage(error).includes("404")) {
|
|
55292
55512
|
return null;
|
|
55293
55513
|
}
|
|
55294
55514
|
throw error;
|
|
55295
55515
|
}
|
|
55296
55516
|
}
|
|
55517
|
+
/**
|
|
55518
|
+
* Current chain tip height from THIS provider — or throw.
|
|
55519
|
+
*
|
|
55520
|
+
* Every exit is a throw naming the provider and the precise failure, because
|
|
55521
|
+
* the only alternative is inventing a confirmation depth (see the call site).
|
|
55522
|
+
* The single `try` exists solely to attach that name to a transport-level
|
|
55523
|
+
* rejection (DNS, TLS, connection reset, abort); it re-throws the cause
|
|
55524
|
+
* verbatim inside the message and never substitutes a value — authorized for
|
|
55525
|
+
* this case by the Batch 2 plan, §C2.
|
|
55526
|
+
*
|
|
55527
|
+
* @param signal - The caller's AbortSignal, so this read shares the same
|
|
55528
|
+
* timeout budget as the transaction fetch it serves.
|
|
55529
|
+
*/
|
|
55530
|
+
async fetchTipHeight(signal) {
|
|
55531
|
+
const endpoint = `${this.config.providerUrl}/blocks/tip/height`;
|
|
55532
|
+
let tipResp;
|
|
55533
|
+
try {
|
|
55534
|
+
tipResp = await fetch(endpoint, {
|
|
55535
|
+
signal,
|
|
55536
|
+
headers: await this.withAuth()
|
|
55537
|
+
});
|
|
55538
|
+
} catch (error) {
|
|
55539
|
+
throw new BitcoinTipUnreadableError(
|
|
55540
|
+
`${TIP_READ_FAILURE_PREFIX}: GET ${endpoint} threw \u2014 ${getUnknownErrorMessage(error)}`
|
|
55541
|
+
);
|
|
55542
|
+
}
|
|
55543
|
+
if (!tipResp.ok) {
|
|
55544
|
+
throw new BitcoinTipUnreadableError(
|
|
55545
|
+
`${TIP_READ_FAILURE_PREFIX}: GET ${endpoint} \u2192 ${tipResp.status} ${tipResp.statusText}`
|
|
55546
|
+
);
|
|
55547
|
+
}
|
|
55548
|
+
const tipBody = (await tipResp.text()).trim();
|
|
55549
|
+
const tipHeight = Number.parseInt(tipBody, 10);
|
|
55550
|
+
if (!Number.isFinite(tipHeight) || tipHeight <= 0) {
|
|
55551
|
+
throw new BitcoinTipUnreadableError(
|
|
55552
|
+
`${TIP_READ_FAILURE_PREFIX}: GET ${endpoint} returned an unusable tip height "${tipBody.slice(0, 64)}"`
|
|
55553
|
+
);
|
|
55554
|
+
}
|
|
55555
|
+
return tipHeight;
|
|
55556
|
+
}
|
|
55297
55557
|
/**
|
|
55298
55558
|
* Get outputs (vouts) of a Bitcoin transaction
|
|
55299
55559
|
*
|
|
@@ -55931,10 +56191,13 @@ ${auth.clientId}`;
|
|
|
55931
56191
|
* only on unanimity. The confirmed-balance consensus the validators run
|
|
55932
56192
|
* covers `chain_stats` only, so without this the primary provider alone
|
|
55933
56193
|
* could fabricate an unconfirmed UTXO plus a self-consistent parent proof
|
|
55934
|
-
* and inflate the signed balance. Any
|
|
55935
|
-
*
|
|
55936
|
-
*
|
|
55937
|
-
*
|
|
56194
|
+
* and inflate the signed balance. Any verdict disagreement THROWS
|
|
56195
|
+
* (fail-closed) — exclusion on a suppressed proof would deflate the balance
|
|
56196
|
+
* and open a wrongful-liquidation window, so neither direction may proceed
|
|
56197
|
+
* without agreement. A provider that cannot state the chain tip — and only
|
|
56198
|
+
* that failure — is dropped from the quorum rather than aborting the read (it
|
|
56199
|
+
* never counts as agreeing), and falling below `minConsensusProviders`
|
|
56200
|
+
* survivors throws — see `verifyParentIsSelfSpendConsensus`.
|
|
55938
56201
|
*
|
|
55939
56202
|
* The same per-provider `/tx` fetch also returns the parent's outputs, and
|
|
55940
56203
|
* every provider must corroborate each claimed UTXO (index, vault address,
|
|
@@ -56029,10 +56292,26 @@ ${auth.clientId}`;
|
|
|
56029
56292
|
}
|
|
56030
56293
|
/**
|
|
56031
56294
|
* Run the self-spend proof against every configured provider and require
|
|
56032
|
-
* unanimity
|
|
56033
|
-
*
|
|
56295
|
+
* unanimity AMONG THE PROVIDERS THAT ANSWERED. Fail-closed on disagreement:
|
|
56296
|
+
* a verdict mismatch throws and aborts the balance calculation — see
|
|
56034
56297
|
* classifySelfChange for why exclusion is not a safe fallback here.
|
|
56035
56298
|
*
|
|
56299
|
+
* Quorum semantics (2026-09-23, plan C2). ONE failure class is tolerated: a
|
|
56300
|
+
* provider that could not state the chain tip (`BitcoinTipUnreadableError`).
|
|
56301
|
+
* It is ABSENT from the quorum — never counted as agreeing, never allowed to
|
|
56302
|
+
* decide the verdict — and the policy floor, not "at least one", decides when
|
|
56303
|
+
* that absence is fatal: below `minConsensusProviders` surviving readings
|
|
56304
|
+
* there is no cross-check left to trust, and the read fails loudly naming
|
|
56305
|
+
* every provider that dropped out.
|
|
56306
|
+
*
|
|
56307
|
+
* Why only that class. `getTransaction` now throws on an unreadable tip
|
|
56308
|
+
* instead of fabricating `confirmations: 1`; without this carve-out one flaky
|
|
56309
|
+
* `/blocks/tip/height` endpoint would take every balance and spend path down
|
|
56310
|
+
* with it. Every OTHER failure remains fatal, as before: a provider that
|
|
56311
|
+
* answers "I have never seen that transaction" is making a claim about the
|
|
56312
|
+
* chain rather than suffering an outage, and that shape is precisely the
|
|
56313
|
+
* fabricated-UTXO signature the fail-closed rule exists to catch.
|
|
56314
|
+
*
|
|
56036
56315
|
* When the parent IS a unanimous self-spend, every provider's view of the
|
|
56037
56316
|
* parent's OUTPUTS must additionally corroborate the primary's claimed
|
|
56038
56317
|
* UTXOs (index exists, pays the vault, exact value). Without this, a
|
|
@@ -56057,32 +56336,52 @@ ${auth.clientId}`;
|
|
|
56057
56336
|
)
|
|
56058
56337
|
)
|
|
56059
56338
|
);
|
|
56060
|
-
const
|
|
56061
|
-
|
|
56062
|
-
|
|
56063
|
-
|
|
56064
|
-
|
|
56339
|
+
const answered = [];
|
|
56340
|
+
const absences = [];
|
|
56341
|
+
const failures = [];
|
|
56342
|
+
settled.forEach((result, i) => {
|
|
56343
|
+
if (result.status === "fulfilled") {
|
|
56344
|
+
answered.push({ index: i, evaluation: result.value });
|
|
56345
|
+
return;
|
|
56346
|
+
}
|
|
56347
|
+
const described = `${providerName(i)} \u2192 ${result.reason?.message ?? String(result.reason)}`;
|
|
56348
|
+
if (isBitcoinTipUnreadableError(result.reason)) {
|
|
56349
|
+
absences.push(described);
|
|
56350
|
+
return;
|
|
56351
|
+
}
|
|
56352
|
+
failures.push(described);
|
|
56353
|
+
});
|
|
56065
56354
|
if (failures.length > 0) {
|
|
56066
56355
|
throw new Error(
|
|
56067
56356
|
`Self-change classification failed for tx ${parentTxid} on ${failures.length}/${providerConfigs.length} provider(s): ${failures.join("; ")}`
|
|
56068
56357
|
);
|
|
56069
56358
|
}
|
|
56070
|
-
const
|
|
56071
|
-
|
|
56072
|
-
|
|
56073
|
-
|
|
56074
|
-
|
|
56075
|
-
|
|
56359
|
+
const floor = Math.max(1, this.minConsensusProviders);
|
|
56360
|
+
if (answered.length < floor) {
|
|
56361
|
+
throw new Error(
|
|
56362
|
+
`Self-change classification for tx ${parentTxid}: only ${answered.length}/${providerConfigs.length} provider(s) could state a confirmation depth, below this chain's floor of ${floor}. Unreadable tips: ${absences.join("; ")}`
|
|
56363
|
+
);
|
|
56364
|
+
}
|
|
56365
|
+
if (absences.length > 0) {
|
|
56366
|
+
litDebugLog(
|
|
56367
|
+
`[VaultBalance] self-change: tx ${parentTxid} classified on a reduced quorum \u2014 ${answered.length}/${providerConfigs.length} provider(s) answered (floor ${floor}); dropped for an unreadable chain tip: ${absences.join("; ")}`
|
|
56368
|
+
);
|
|
56369
|
+
}
|
|
56370
|
+
const first = answered[0];
|
|
56371
|
+
const disagreements = answered.slice(1).filter((a) => a.evaluation.selfSpend !== first.evaluation.selfSpend).map(
|
|
56372
|
+
(a) => `${providerName(first.index)}=${first.evaluation.selfSpend} vs ${providerName(a.index)}=${a.evaluation.selfSpend}`
|
|
56076
56373
|
);
|
|
56077
56374
|
if (disagreements.length > 0) {
|
|
56078
56375
|
throw new Error(
|
|
56079
56376
|
`Self-change consensus mismatch for tx ${parentTxid}: ${disagreements.join("; ")}. A provider may be compromised or out of sync; refusing to sign.`
|
|
56080
56377
|
);
|
|
56081
56378
|
}
|
|
56082
|
-
if (!
|
|
56379
|
+
if (!first.evaluation.selfSpend) {
|
|
56083
56380
|
return false;
|
|
56084
56381
|
}
|
|
56085
|
-
const outputMismatches =
|
|
56382
|
+
const outputMismatches = answered.map(
|
|
56383
|
+
(a) => a.evaluation.outputMismatch ? `${providerName(a.index)} \u2192 ${a.evaluation.outputMismatch}` : null
|
|
56384
|
+
).filter((m) => m !== null);
|
|
56086
56385
|
if (outputMismatches.length > 0) {
|
|
56087
56386
|
throw new Error(
|
|
56088
56387
|
`Self-change output claim mismatch for tx ${parentTxid}: ${outputMismatches.join("; ")}. The reported UTXO set contradicts the parent transaction; refusing to sign.`
|
|
@@ -56325,16 +56624,6 @@ ${auth.clientId}`;
|
|
|
56325
56624
|
minConfirmations
|
|
56326
56625
|
);
|
|
56327
56626
|
const authorizedSpends = await this.getAuthorizedSpendsFromContract(positionId);
|
|
56328
|
-
for (const spend of authorizedSpends) {
|
|
56329
|
-
const utxoStillExists = utxoSet.utxos.some(
|
|
56330
|
-
(utxo) => utxo.txid === spend.txid && utxo.vout === spend.vout
|
|
56331
|
-
);
|
|
56332
|
-
if (utxoStillExists) {
|
|
56333
|
-
throw new Error(
|
|
56334
|
-
`Authorized UTXO ${spend.txid}:${spend.vout} not yet spent. Transaction was authorized in smart contract but not signed and broadcasted to Bitcoin network. Complete the transaction by signing and broadcasting it.`
|
|
56335
|
-
);
|
|
56336
|
-
}
|
|
56337
|
-
}
|
|
56338
56627
|
const authorizedBalance = authorizedSpends.reduce(
|
|
56339
56628
|
(sum, spend) => sum + spend.satoshis,
|
|
56340
56629
|
0n
|
|
@@ -56630,7 +56919,13 @@ ${auth.clientId}`;
|
|
|
56630
56919
|
allowDevSinglePriceProvider: false,
|
|
56631
56920
|
minBitcoinBalanceConfirmations: 1,
|
|
56632
56921
|
minBitcoinSpendConfirmations: 1,
|
|
56633
|
-
|
|
56922
|
+
// 2 since 2026-09-23. It was 1 because Sepolia ran a single faucet provider
|
|
56923
|
+
// "by design", so the consensus floor was documented as a mainnet-only
|
|
56924
|
+
// guarantee. The registry now holds two, and leaving the floor at 1 meant
|
|
56925
|
+
// Sepolia could never exercise the multi-provider agreement the stale-spend
|
|
56926
|
+
// and balance paths rely on — the one environment where that logic is
|
|
56927
|
+
// supposed to be proved before mainnet.
|
|
56928
|
+
minConsensusProviders: 2
|
|
56634
56929
|
},
|
|
56635
56930
|
[
|
|
56636
56931
|
"ethereum"
|
|
@@ -56939,7 +57234,6 @@ function getSepoliaConfig() {
|
|
|
56939
57234
|
feeRecipientRegistry: SEPOLIA_CONTRACTS.FeeRecipientRegistry || "",
|
|
56940
57235
|
positionDelegateRegistry: SEPOLIA_CONTRACTS.PositionDelegateRegistry || "",
|
|
56941
57236
|
bitcoinWithdrawalAddressRegistry: SEPOLIA_CONTRACTS.BitcoinWithdrawalAddressRegistry || "",
|
|
56942
|
-
carryAgentRegistry: SEPOLIA_CONTRACTS.CarryAgentRegistry || "",
|
|
56943
57237
|
agentDelegationRegistry: SEPOLIA_CONTRACTS.AgentDelegationRegistry || "",
|
|
56944
57238
|
dhAgentDelegate: SEPOLIA_CONTRACTS.DHAgentDelegate || "",
|
|
56945
57239
|
agentModuleFactory: SEPOLIA_CONTRACTS.AgentModuleFactory || ""
|
|
@@ -56993,7 +57287,6 @@ function getMainnetConfig() {
|
|
|
56993
57287
|
feeRecipientRegistry: MAINNET_CONTRACTS.FeeRecipientRegistry || "",
|
|
56994
57288
|
positionDelegateRegistry: MAINNET_CONTRACTS.PositionDelegateRegistry || "",
|
|
56995
57289
|
bitcoinWithdrawalAddressRegistry: MAINNET_CONTRACTS.BitcoinWithdrawalAddressRegistry || "",
|
|
56996
|
-
carryAgentRegistry: MAINNET_CONTRACTS.CarryAgentRegistry || "",
|
|
56997
57290
|
agentDelegationRegistry: MAINNET_CONTRACTS.AgentDelegationRegistry || "",
|
|
56998
57291
|
dhAgentDelegate: MAINNET_CONTRACTS.DHAgentDelegate || "",
|
|
56999
57292
|
// Empty on mainnet until the factory is deployed there — the ceremony is Sepolia-only.
|
|
@@ -58066,6 +58359,51 @@ async function resolveAuthorizationInput(provider, signer, ctx) {
|
|
|
58066
58359
|
}
|
|
58067
58360
|
return { timestamp: result.timestamp, signature: result.signature };
|
|
58068
58361
|
}
|
|
58362
|
+
var BECH32_CHARSET = "qpzry9x8gf2tvdw0s3jn54khce6mua7l";
|
|
58363
|
+
function segwitProgramShape(address) {
|
|
58364
|
+
const lower2 = address.trim().toLowerCase();
|
|
58365
|
+
if (!/^(bc1|tb1|bcrt1)/.test(lower2))
|
|
58366
|
+
return null;
|
|
58367
|
+
const sep = lower2.lastIndexOf("1");
|
|
58368
|
+
const data = lower2.slice(sep + 1);
|
|
58369
|
+
if (data.length < 8)
|
|
58370
|
+
return null;
|
|
58371
|
+
const version2 = BECH32_CHARSET.indexOf(data[0]);
|
|
58372
|
+
if (version2 < 0)
|
|
58373
|
+
return null;
|
|
58374
|
+
const programChars = data.length - 1 - 6;
|
|
58375
|
+
return { version: version2, programBytes: Math.floor(programChars * 5 / 8) };
|
|
58376
|
+
}
|
|
58377
|
+
function dustLimitForAddress(address) {
|
|
58378
|
+
const shape = segwitProgramShape(address);
|
|
58379
|
+
if (shape === null)
|
|
58380
|
+
return 546;
|
|
58381
|
+
if (shape.version === 0 && shape.programBytes === 20)
|
|
58382
|
+
return 294;
|
|
58383
|
+
if (shape.version === 0 && shape.programBytes === 32)
|
|
58384
|
+
return 330;
|
|
58385
|
+
if (shape.version === 1 && shape.programBytes === 32)
|
|
58386
|
+
return 330;
|
|
58387
|
+
return 546;
|
|
58388
|
+
}
|
|
58389
|
+
function destinationDustShortfall(targetAmount, networkFee, destination) {
|
|
58390
|
+
const limit = dustLimitForAddress(destination);
|
|
58391
|
+
return targetAmount - networkFee < limit ? limit : null;
|
|
58392
|
+
}
|
|
58393
|
+
function calculateMintFee(params) {
|
|
58394
|
+
const { mintAmount, mintTimestamp, originationFeeBps, previousExpiryAt, selectedTerm, totalTerm } = params;
|
|
58395
|
+
let mintFee = mintAmount * BigInt(originationFeeBps) / 10000n;
|
|
58396
|
+
if (previousExpiryAt > 0 && mintTimestamp < previousExpiryAt) {
|
|
58397
|
+
const tailSeconds = BigInt(previousExpiryAt) - BigInt(mintTimestamp);
|
|
58398
|
+
const originalTermMonths = totalTerm - selectedTerm;
|
|
58399
|
+
const originalTermSeconds = BigInt(
|
|
58400
|
+
originalTermMonths === 12 ? 365 * 86400 : originalTermMonths * 30 * 86400
|
|
58401
|
+
);
|
|
58402
|
+
const tailFee = tailSeconds * BigInt(originationFeeBps) * mintAmount / (10000n * originalTermSeconds);
|
|
58403
|
+
mintFee = mintFee + tailFee;
|
|
58404
|
+
}
|
|
58405
|
+
return mintFee;
|
|
58406
|
+
}
|
|
58069
58407
|
function baseMintFeeWei(mintAmountWei, originationFeeBps) {
|
|
58070
58408
|
if (mintAmountWei < 0n)
|
|
58071
58409
|
throw new Error("baseMintFeeWei: mintAmountWei cannot be negative");
|
|
@@ -58084,20 +58422,34 @@ function debtAfterMintExceedsLoanCap(params) {
|
|
|
58084
58422
|
}
|
|
58085
58423
|
return currentDebtWei + mintAmountWei + mintFeeWei > maxLoanWei;
|
|
58086
58424
|
}
|
|
58087
|
-
function
|
|
58088
|
-
|
|
58089
|
-
|
|
58090
|
-
throw new Error("maxPrincipalWithinLoanCap: amounts cannot be negative");
|
|
58425
|
+
function collateralRatioBps(sats, price8, debtWei) {
|
|
58426
|
+
if (sats < 0n || price8 < 0n) {
|
|
58427
|
+
throw new Error("collateralRatioBps: sats and price cannot be negative");
|
|
58091
58428
|
}
|
|
58092
|
-
if (
|
|
58093
|
-
throw new Error(
|
|
58094
|
-
`maxPrincipalWithinLoanCap: originationFeeBps must be an integer in [0, 10000] (got ${String(originationFeeBps)})`
|
|
58095
|
-
);
|
|
58429
|
+
if (debtWei <= 0n) {
|
|
58430
|
+
throw new Error("collateralRatioBps: debt must be positive");
|
|
58096
58431
|
}
|
|
58097
|
-
|
|
58098
|
-
|
|
58099
|
-
|
|
58100
|
-
|
|
58432
|
+
return sats * price8 * 100n * 10000n / debtWei;
|
|
58433
|
+
}
|
|
58434
|
+
function collateralRatioPercentString(sats, price8, debtWei) {
|
|
58435
|
+
const bps = collateralRatioBps(sats, price8, debtWei);
|
|
58436
|
+
return `${bps / 100n}.${(bps % 100n).toString().padStart(2, "0")}`;
|
|
58437
|
+
}
|
|
58438
|
+
function maxPrincipalForFee(room, fee) {
|
|
58439
|
+
if (room < 0n)
|
|
58440
|
+
throw new Error("maxPrincipalForFee: room cannot be negative");
|
|
58441
|
+
if (fee(0n) !== 0n)
|
|
58442
|
+
throw new Error("maxPrincipalForFee: fee(0) must be 0");
|
|
58443
|
+
let lo = 0n;
|
|
58444
|
+
let hi = room;
|
|
58445
|
+
while (lo < hi) {
|
|
58446
|
+
const mid = (lo + hi + 1n) / 2n;
|
|
58447
|
+
if (mid + fee(mid) <= room)
|
|
58448
|
+
lo = mid;
|
|
58449
|
+
else
|
|
58450
|
+
hi = mid - 1n;
|
|
58451
|
+
}
|
|
58452
|
+
return lo;
|
|
58101
58453
|
}
|
|
58102
58454
|
function buildLoginDomain(chainId) {
|
|
58103
58455
|
return {
|
|
@@ -70260,9 +70612,17 @@ async function mintAgentPkp(params) {
|
|
|
70260
70612
|
}
|
|
70261
70613
|
var AGENT_STATUS = { None: 0, Active: 1, Revoked: 2 };
|
|
70262
70614
|
function planAgentBinding(params) {
|
|
70263
|
-
const { isActive, record, nowSeconds } = params;
|
|
70615
|
+
const { isActive, paused, record, nowSeconds } = params;
|
|
70616
|
+
if (typeof paused !== "boolean") {
|
|
70617
|
+
throw new Error("planAgentBinding: `paused` must be read from the registry (boolean required)");
|
|
70618
|
+
}
|
|
70264
70619
|
if (isActive)
|
|
70265
70620
|
return { kind: "reuse", agent: record.agent };
|
|
70621
|
+
if (paused) {
|
|
70622
|
+
throw new Error(
|
|
70623
|
+
"AgentDelegationRegistry is paused \u2014 agent delegation cannot be changed until it is unpaused."
|
|
70624
|
+
);
|
|
70625
|
+
}
|
|
70266
70626
|
const status = Number(record.status);
|
|
70267
70627
|
if (status === AGENT_STATUS.None || status === AGENT_STATUS.Revoked) {
|
|
70268
70628
|
return { kind: "register" };
|
|
@@ -70272,7 +70632,7 @@ function planAgentBinding(params) {
|
|
|
70272
70632
|
}
|
|
70273
70633
|
if (Number(record.validUntil) > nowSeconds) {
|
|
70274
70634
|
throw new Error(
|
|
70275
|
-
"AgentDelegationRegistry
|
|
70635
|
+
"AgentDelegationRegistry returned an inconsistent read (an unexpired, unpaused Active agent reported inactive); retry."
|
|
70276
70636
|
);
|
|
70277
70637
|
}
|
|
70278
70638
|
return { kind: "rotate" };
|
|
@@ -71441,7 +71801,7 @@ function normalizeBigNumberish(value) {
|
|
|
71441
71801
|
}
|
|
71442
71802
|
return value;
|
|
71443
71803
|
}
|
|
71444
|
-
if (typeof value === "object" && value !== null && "toString" in value && typeof value.toString === "function") {
|
|
71804
|
+
if (typeof value === "object" && value !== null && "toString" in value && typeof value.toString === "function" && value.toString !== Object.prototype.toString) {
|
|
71445
71805
|
const result = value.toString();
|
|
71446
71806
|
if (typeof result === "object" && result !== null && "_hex" in result) {
|
|
71447
71807
|
const resultObj = result;
|
|
@@ -72863,12 +73223,21 @@ var DiamondHandsSDK = class _DiamondHandsSDK {
|
|
|
72863
73223
|
maxLoanWei: maxLoanValueWei
|
|
72864
73224
|
})) {
|
|
72865
73225
|
const debtAfterWei = currentDebtWei + requestAmountWei + baseFeeWei;
|
|
73226
|
+
const suggestionStamp = calculateNextQuantumTimestamp();
|
|
73227
|
+
const room = maxLoanValueWei > currentDebtWei ? maxLoanValueWei - currentDebtWei : 0n;
|
|
72866
73228
|
const maxPrincipalUcd = Number(
|
|
72867
|
-
|
|
72868
|
-
|
|
72869
|
-
|
|
72870
|
-
|
|
72871
|
-
|
|
73229
|
+
maxPrincipalForFee(
|
|
73230
|
+
room,
|
|
73231
|
+
(principal) => calculateMintFee({
|
|
73232
|
+
mintAmount: principal,
|
|
73233
|
+
mintTimestamp: suggestionStamp,
|
|
73234
|
+
originationFeeBps: positionTerm.originationFeeBps,
|
|
73235
|
+
expiryAt: Number(position2.expiryAt),
|
|
73236
|
+
previousExpiryAt: Number(position2.previousExpiryAt),
|
|
73237
|
+
selectedTerm: Number(position2.selectedTerm),
|
|
73238
|
+
totalTerm: Number(position2.totalTerm)
|
|
73239
|
+
})
|
|
73240
|
+
) / BigInt(10 ** 18)
|
|
72872
73241
|
);
|
|
72873
73242
|
return {
|
|
72874
73243
|
success: false,
|
|
@@ -73946,11 +74315,7 @@ Message: ${causeMessage}${quantumContext}${loanCapDiagnostics}${mintDebtDiagnost
|
|
|
73946
74315
|
const debt = positionDetails.debt || positionDetails.ucdDebt || "0";
|
|
73947
74316
|
const btcPrice2 = litActionResult.btcPrice || "0";
|
|
73948
74317
|
const btcVaultBalance = litActionResult.btcAmountSats || positionDetails.btcVaultBalance || "0";
|
|
73949
|
-
const
|
|
73950
|
-
const btcAmount = Number(btcVaultBalance) / 1e8;
|
|
73951
|
-
const btcValueUSD = btcAmount * usdPricePerBTC;
|
|
73952
|
-
const debtUSD = Number(debt) / 1e18;
|
|
73953
|
-
const ratio = debtUSD > 0 ? (btcValueUSD / debtUSD * 100).toFixed(2) : "0.00";
|
|
74318
|
+
const ratio = BigInt(debt) > 0n ? collateralRatioPercentString(BigInt(btcVaultBalance), BigInt(btcPrice2), BigInt(debt)) : "0.00";
|
|
73954
74319
|
const message = formatLiquidationSkippedMessage(
|
|
73955
74320
|
request.positionId,
|
|
73956
74321
|
ratio,
|
|
@@ -74439,14 +74804,15 @@ Message: ${causeMessage}${quantumContext}${loanCapDiagnostics}${mintDebtDiagnost
|
|
|
74439
74804
|
}
|
|
74440
74805
|
const debt = positionDetails.debt || positionDetails.ucdDebt || "0";
|
|
74441
74806
|
const btcPrice2 = litActionResult.btcPrice || "0";
|
|
74442
|
-
const
|
|
74807
|
+
const btcVaultBalance = litActionResult.btcAmountSats || positionDetails.btcVaultBalance || "0";
|
|
74808
|
+
const ratio = BigInt(debt) > 0n ? collateralRatioPercentString(BigInt(btcVaultBalance), BigInt(btcPrice2), BigInt(debt)) : "0.00";
|
|
74443
74809
|
const message = formatLiquidationSuccessMessage(
|
|
74444
74810
|
request.positionId,
|
|
74445
74811
|
ratio,
|
|
74446
74812
|
`${liquidationThreshold / 100}`,
|
|
74447
74813
|
// Convert to percentage
|
|
74448
74814
|
positionDetails.btcVault || "unknown",
|
|
74449
|
-
|
|
74815
|
+
btcVaultBalance,
|
|
74450
74816
|
debt,
|
|
74451
74817
|
btcPrice2
|
|
74452
74818
|
);
|
|
@@ -76930,6 +77296,17 @@ Message: ${causeMessage}${quantumContext}${loanCapDiagnostics}${mintDebtDiagnost
|
|
|
76930
77296
|
error: `networkFee=${request.networkFee} is \u2265 50% of targetAmount=${request.targetAmount}. Refusing to broadcast \u2014 real Bitcoin fees are typically <1% of value.`
|
|
76931
77297
|
};
|
|
76932
77298
|
}
|
|
77299
|
+
const destinationDustLimit = destinationDustShortfall(
|
|
77300
|
+
request.targetAmount,
|
|
77301
|
+
request.networkFee,
|
|
77302
|
+
request.destination
|
|
77303
|
+
);
|
|
77304
|
+
if (destinationDustLimit !== null) {
|
|
77305
|
+
return {
|
|
77306
|
+
success: false,
|
|
77307
|
+
error: `Destination would receive ${request.targetAmount - request.networkFee} sats (targetAmount=${request.targetAmount} \u2212 networkFee=${request.networkFee}), below the ${destinationDustLimit}-sat dust limit for ${request.destination}; the transaction would not relay.`
|
|
77308
|
+
};
|
|
77309
|
+
}
|
|
76933
77310
|
const [txid, voutStr] = request.utxoIdentifier.split(":");
|
|
76934
77311
|
const vout = parseInt(voutStr || "0", 10);
|
|
76935
77312
|
if (!txid || isNaN(vout)) {
|
|
@@ -78405,8 +78782,9 @@ Message: ${causeMessage}${quantumContext}${loanCapDiagnostics}${mintDebtDiagnost
|
|
|
78405
78782
|
const user = await signer.getAddress();
|
|
78406
78783
|
const registry = AgentDelegationRegistry__factory.connect(addr, signer);
|
|
78407
78784
|
let agentAddress;
|
|
78408
|
-
const [isActive, record, latestBlock] = await Promise.all([
|
|
78785
|
+
const [isActive, paused, record, latestBlock] = await Promise.all([
|
|
78409
78786
|
registry.isAgentActive(user),
|
|
78787
|
+
registry.paused(),
|
|
78410
78788
|
registry.agentOf(user),
|
|
78411
78789
|
this.getProviderOrThrow().getBlock("latest")
|
|
78412
78790
|
]);
|
|
@@ -78418,7 +78796,7 @@ Message: ${causeMessage}${quantumContext}${loanCapDiagnostics}${mintDebtDiagnost
|
|
|
78418
78796
|
/* HIGH */
|
|
78419
78797
|
});
|
|
78420
78798
|
}
|
|
78421
|
-
const plan = planAgentBinding({ isActive, record, nowSeconds: latestBlock.timestamp });
|
|
78799
|
+
const plan = planAgentBinding({ isActive, paused, record, nowSeconds: latestBlock.timestamp });
|
|
78422
78800
|
if (plan.kind === "reuse") {
|
|
78423
78801
|
agentAddress = plan.agent;
|
|
78424
78802
|
} else {
|
|
@@ -81883,11 +82261,16 @@ var RealUpstreamPlugin = class {
|
|
|
81883
82261
|
this.src("subgraph")
|
|
81884
82262
|
);
|
|
81885
82263
|
},
|
|
81886
|
-
getPositionEvents: async () =>
|
|
81887
|
-
|
|
81888
|
-
|
|
81889
|
-
|
|
81890
|
-
|
|
82264
|
+
getPositionEvents: async () => (
|
|
82265
|
+
// PERMANENT capability gap, not a transient outage: the real adapter has no indexer
|
|
82266
|
+
// projection for event history, and this build never will. `unsupported` →
|
|
82267
|
+
// NOT_IMPLEMENTED so the guide does not tell the model to retry it (C-44).
|
|
82268
|
+
upFail({
|
|
82269
|
+
kind: "unsupported",
|
|
82270
|
+
source: "subgraph",
|
|
82271
|
+
message: "event history is not implemented on the real adapter in this build (no indexer projection) \u2014 this is a permanent capability gap, not a transient outage; do not retry"
|
|
82272
|
+
})
|
|
82273
|
+
)
|
|
81891
82274
|
};
|
|
81892
82275
|
this.chain = {
|
|
81893
82276
|
getPositionDetails: (id) => this.chainRead(() => this.readPositionDetails(id)),
|
|
@@ -83330,6 +83713,8 @@ var SignatureBridge = class {
|
|
|
83330
83713
|
wcTransport = null;
|
|
83331
83714
|
/** True while a WalletConnect session is THE wallet — ceremonies route over WC. */
|
|
83332
83715
|
wcActive = false;
|
|
83716
|
+
/** Page session that most recently asked for a pairing QR — see `serveWcPairing`. */
|
|
83717
|
+
pairingSessionId = null;
|
|
83333
83718
|
keystoreUnlock;
|
|
83334
83719
|
unlockToken = null;
|
|
83335
83720
|
unlockSession = null;
|
|
@@ -83460,7 +83845,8 @@ var SignatureBridge = class {
|
|
|
83460
83845
|
...handlers?.finalize ? { finalize: handlers.finalize } : {},
|
|
83461
83846
|
owner: this.wcActive ? "wc" : "page",
|
|
83462
83847
|
dispatched: false,
|
|
83463
|
-
lastAttachedMs: now
|
|
83848
|
+
lastAttachedMs: now,
|
|
83849
|
+
finalizedBy: null
|
|
83464
83850
|
};
|
|
83465
83851
|
this.pending.set(request.id, entry);
|
|
83466
83852
|
if (entry.owner === "wc") {
|
|
@@ -83493,7 +83879,8 @@ var SignatureBridge = class {
|
|
|
83493
83879
|
// ceremony could not reach quorum through the very pages it is broadcast to.
|
|
83494
83880
|
owner: "both",
|
|
83495
83881
|
dispatched: false,
|
|
83496
|
-
lastAttachedMs: now
|
|
83882
|
+
lastAttachedMs: now,
|
|
83883
|
+
finalizedBy: null
|
|
83497
83884
|
};
|
|
83498
83885
|
this.pending.set(request.id, entry);
|
|
83499
83886
|
this.pushEntry(entry);
|
|
@@ -83591,7 +83978,7 @@ var SignatureBridge = class {
|
|
|
83591
83978
|
* receives nothing cannot show anything. Distinct from `attachedNow()`, which counts
|
|
83592
83979
|
* WalletConnect and must stay global for the connector's eviction predicate. */
|
|
83593
83980
|
pageAttached() {
|
|
83594
|
-
for (const s of this.sessions.values()) if (
|
|
83981
|
+
for (const s of this.sessions.values()) if (s.sse && this.authorized(s)) return true;
|
|
83595
83982
|
return false;
|
|
83596
83983
|
}
|
|
83597
83984
|
/** Attachment for ONE entry — the wallet that entry is actually waiting on. The global
|
|
@@ -83608,6 +83995,7 @@ var SignatureBridge = class {
|
|
|
83608
83995
|
* the deadline is checked first so expiry semantics stay pinned (T-EXT-03). */
|
|
83609
83996
|
sweep() {
|
|
83610
83997
|
const now = this.clock();
|
|
83998
|
+
this.evictDeadSessions();
|
|
83611
83999
|
for (const entry of this.pending.values()) {
|
|
83612
84000
|
if (entry.settled) continue;
|
|
83613
84001
|
if (now >= entry.deadlineMs) {
|
|
@@ -83720,12 +84108,13 @@ var SignatureBridge = class {
|
|
|
83720
84108
|
this.deny(res, 403, "this approval link has expired \u2014 ask for a fresh one (signer_setup status) and reopen");
|
|
83721
84109
|
return;
|
|
83722
84110
|
}
|
|
84111
|
+
this.makeRoomForSession();
|
|
83723
84112
|
if (this.sessions.size >= MAX_SESSIONS) {
|
|
83724
84113
|
this.deny(res, 429, `too many open approval pages (${MAX_SESSIONS}) \u2014 close one and retry`);
|
|
83725
84114
|
return;
|
|
83726
84115
|
}
|
|
83727
84116
|
const sessionId = (0, import_node_crypto7.randomBytes)(24).toString("hex");
|
|
83728
|
-
this.sessions.set(sessionId, { wallet: null, sse: null, refused: null });
|
|
84117
|
+
this.sessions.set(sessionId, { wallet: null, sse: null, refused: null, lastSeenMs: this.clock(), wcPaired: false });
|
|
83729
84118
|
const page = htmlPageSecurityHeaders();
|
|
83730
84119
|
res.writeHead(200, { "Content-Type": "text/html; charset=utf-8", "Cache-Control": "no-store", ...page.headers });
|
|
83731
84120
|
res.end(renderApprovalPage(sessionId, page.nonce));
|
|
@@ -83740,6 +84129,7 @@ var SignatureBridge = class {
|
|
|
83740
84129
|
* fresh pairing URI. A wallet approving the pairing becomes THE wallet. */
|
|
83741
84130
|
async serveWcPairing(url2, res) {
|
|
83742
84131
|
if (!this.checkSession(url2.searchParams.get("s"), res)) return;
|
|
84132
|
+
this.pairingSessionId = url2.searchParams.get("s");
|
|
83743
84133
|
if (!this.wcConfig) {
|
|
83744
84134
|
this.deny(res, 404, "WalletConnect is not configured (set DH_WC_PROJECT_ID)");
|
|
83745
84135
|
return;
|
|
@@ -83763,6 +84153,10 @@ var SignatureBridge = class {
|
|
|
83763
84153
|
}
|
|
83764
84154
|
this.wcActive = info !== null;
|
|
83765
84155
|
this.wallet = info ? { account: info.account, chainId: info.chainId } : null;
|
|
84156
|
+
if (info && this.pairingSessionId) {
|
|
84157
|
+
const paired = this.sessions.get(this.pairingSessionId);
|
|
84158
|
+
if (paired) paired.wcPaired = true;
|
|
84159
|
+
}
|
|
83766
84160
|
if (info === null) {
|
|
83767
84161
|
for (const entry of this.pending.values()) {
|
|
83768
84162
|
if (!entry.settled && !entry.collect) {
|
|
@@ -83840,9 +84234,7 @@ var SignatureBridge = class {
|
|
|
83840
84234
|
res.write(":connected\n\n");
|
|
83841
84235
|
session.sse?.end();
|
|
83842
84236
|
session.sse = res;
|
|
83843
|
-
|
|
83844
|
-
if (!entry.settled) res.write(this.wireFor(entry));
|
|
83845
|
-
}
|
|
84237
|
+
this.replayPending(session);
|
|
83846
84238
|
const keepAlive = setInterval(() => res.write(":ka\n\n"), 2e4);
|
|
83847
84239
|
keepAlive.unref();
|
|
83848
84240
|
res.on("close", () => {
|
|
@@ -83867,6 +84259,7 @@ var SignatureBridge = class {
|
|
|
83867
84259
|
}
|
|
83868
84260
|
session.wallet = { account, chainId };
|
|
83869
84261
|
this.wallet = { account, chainId };
|
|
84262
|
+
this.replayPending(session);
|
|
83870
84263
|
this.ok(res);
|
|
83871
84264
|
}
|
|
83872
84265
|
/** C-47: the single predicate every wallet account is admitted through. There are THREE
|
|
@@ -83950,7 +84343,9 @@ var SignatureBridge = class {
|
|
|
83950
84343
|
/** Click-time re-stamp (A0.9): returns the FRESH personal-sign payload for a pending
|
|
83951
84344
|
* request. Idempotent for requests without a finalize handler (payload as enqueued). */
|
|
83952
84345
|
async onFinalize(body, res) {
|
|
83953
|
-
|
|
84346
|
+
const sessionId = String(body["sessionId"] ?? "");
|
|
84347
|
+
const session = this.decidingSessionOf(body["sessionId"], res);
|
|
84348
|
+
if (!session) return;
|
|
83954
84349
|
const entry = this.pending.get(String(body["requestId"] ?? ""));
|
|
83955
84350
|
if (!entry || entry.settled) {
|
|
83956
84351
|
this.deny(res, 404, "unknown or already-settled requestId");
|
|
@@ -83964,6 +84359,12 @@ var SignatureBridge = class {
|
|
|
83964
84359
|
this.deny(res, 409, "a mobile wallet is holding this approval \u2014 it is read-only here; approve or decline it in the wallet");
|
|
83965
84360
|
return;
|
|
83966
84361
|
}
|
|
84362
|
+
const holder = entry.finalizedBy ? this.sessions.get(entry.finalizedBy) : void 0;
|
|
84363
|
+
if (entry.finalizedBy && entry.finalizedBy !== sessionId && holder?.sse) {
|
|
84364
|
+
this.deny(res, 409, "another approval page is signing this request \u2014 approve it there, or close that page and retry");
|
|
84365
|
+
return;
|
|
84366
|
+
}
|
|
84367
|
+
entry.finalizedBy = sessionId;
|
|
83967
84368
|
if (entry.finalize) {
|
|
83968
84369
|
let fresh;
|
|
83969
84370
|
try {
|
|
@@ -83983,7 +84384,7 @@ var SignatureBridge = class {
|
|
|
83983
84384
|
res.end(JSON.stringify({ request: entry.request }));
|
|
83984
84385
|
}
|
|
83985
84386
|
onResult(body, res) {
|
|
83986
|
-
if (!this.
|
|
84387
|
+
if (!this.decidingSessionOf(body["sessionId"], res)) return;
|
|
83987
84388
|
const entry = this.pending.get(String(body["requestId"] ?? ""));
|
|
83988
84389
|
if (!entry || entry.settled) {
|
|
83989
84390
|
this.deny(res, 404, "unknown or already-settled requestId");
|
|
@@ -84056,7 +84457,7 @@ var SignatureBridge = class {
|
|
|
84056
84457
|
/** Broadcast a pending entry to EVERY open page (multi-owner links — plan 06 §1.5). */
|
|
84057
84458
|
pushEntry(entry) {
|
|
84058
84459
|
const data = this.wireFor(entry);
|
|
84059
|
-
for (const s of this.sessions.values()) if (
|
|
84460
|
+
for (const s of this.sessions.values()) if (this.authorized(s)) s.sse?.write(data);
|
|
84060
84461
|
}
|
|
84061
84462
|
/** Progress goes out as a NAMED event so `es.onmessage` request handling never sees it. */
|
|
84062
84463
|
pushProgress(payload) {
|
|
@@ -84064,7 +84465,51 @@ var SignatureBridge = class {
|
|
|
84064
84465
|
data: ${JSON.stringify(payload)}
|
|
84065
84466
|
|
|
84066
84467
|
`;
|
|
84067
|
-
for (const s of this.sessions.values()) if (
|
|
84468
|
+
for (const s of this.sessions.values()) if (this.authorized(s)) s.sse?.write(data);
|
|
84469
|
+
}
|
|
84470
|
+
/** Replay every undecided card to ONE session — used when a session becomes authorized
|
|
84471
|
+
* (hello) after its stream was already open, which is the ordinary page order: the page
|
|
84472
|
+
* attaches its EventSource, then the wallet prompt resolves. Without this the newly
|
|
84473
|
+
* connected page would sit blank until the next push. */
|
|
84474
|
+
replayPending(session) {
|
|
84475
|
+
if (!session.sse || !this.authorized(session)) return;
|
|
84476
|
+
for (const entry of this.pending.values()) {
|
|
84477
|
+
if (!entry.settled) session.sse.write(this.wireFor(entry));
|
|
84478
|
+
}
|
|
84479
|
+
}
|
|
84480
|
+
/** Retire quarantined sessions that hold no stream. Always safe: a refused session is
|
|
84481
|
+
* denied on every route anyway, so keeping it costs a slot and buys nothing. */
|
|
84482
|
+
evictDeadSessions() {
|
|
84483
|
+
for (const [id, s] of this.sessions) if (s.refused && !s.sse) this.sessions.delete(id);
|
|
84484
|
+
}
|
|
84485
|
+
/**
|
|
84486
|
+
* Free a slot for an incoming page load when the ceiling is reached.
|
|
84487
|
+
*
|
|
84488
|
+
* MAX_SESSIONS was a ceiling with NO eviction — nothing but `close()` ever removed a
|
|
84489
|
+
* session — and every page load mints one (a reload is a new session). A long-lived
|
|
84490
|
+
* hosted bridge therefore reached 16 through ordinary use and 429'd the user out of
|
|
84491
|
+
* approving their own ceremonies, permanently, with "close one and retry" as the advice
|
|
84492
|
+
* for pages that were already closed.
|
|
84493
|
+
*
|
|
84494
|
+
* Eviction is ON DEMAND and never touches a session with a live SSE stream: that stream
|
|
84495
|
+
* is a page open in a browser right now, and the C1 contract is that live sessions
|
|
84496
|
+
* survive. Among the streamless it takes the least recently seen — the closed tab.
|
|
84497
|
+
*/
|
|
84498
|
+
makeRoomForSession() {
|
|
84499
|
+
this.evictDeadSessions();
|
|
84500
|
+
while (this.sessions.size >= MAX_SESSIONS) {
|
|
84501
|
+
let oldestId = null;
|
|
84502
|
+
let oldestSeen = Infinity;
|
|
84503
|
+
for (const [id, s] of this.sessions) {
|
|
84504
|
+
if (s.sse) continue;
|
|
84505
|
+
if (s.lastSeenMs < oldestSeen) {
|
|
84506
|
+
oldestSeen = s.lastSeenMs;
|
|
84507
|
+
oldestId = id;
|
|
84508
|
+
}
|
|
84509
|
+
}
|
|
84510
|
+
if (oldestId === null) return;
|
|
84511
|
+
this.sessions.delete(oldestId);
|
|
84512
|
+
}
|
|
84068
84513
|
}
|
|
84069
84514
|
/**
|
|
84070
84515
|
* C-47: `this.wallet` is DERIVED, never guessed.
|
|
@@ -84107,12 +84552,46 @@ data: ${JSON.stringify(payload)}
|
|
|
84107
84552
|
}
|
|
84108
84553
|
this.rebuildSharedWallet();
|
|
84109
84554
|
}
|
|
84555
|
+
/**
|
|
84556
|
+
* A session that may SEE cards and DECIDE them — one where a PERSON has proven to be at
|
|
84557
|
+
* the page: `hello` with an admissible account, or a WalletConnect pairing a wallet
|
|
84558
|
+
* actually answered (`wcPaired`).
|
|
84559
|
+
*
|
|
84560
|
+
* `sessionOf` only ever asked "does this session id exist and is it un-quarantined". A
|
|
84561
|
+
* session id is minted by LOADING the page, and on the hosted tier the mount URL travels
|
|
84562
|
+
* through the conversation by design — so anyone holding it could mint a session, never
|
|
84563
|
+
* connect a wallet, and still receive every approval card on /events (the card is the
|
|
84564
|
+
* operation in readable form: position, destination, amounts) and still POST /result to
|
|
84565
|
+
* decline, or /finalize to re-stamp, someone else's ceremony. Quarantine never caught
|
|
84566
|
+
* them: it fires on an OFFERED account, and they offered none.
|
|
84567
|
+
*
|
|
84568
|
+
* Opening the stream without a wallet stays legal — that is how the real page bootstraps
|
|
84569
|
+
* before the user connects. It simply receives nothing and decides nothing until it has
|
|
84570
|
+
* connected. Requesting a pairing is likewise not enough: anyone with the link can ask
|
|
84571
|
+
* for a QR, so only a pairing a WALLET ANSWERED counts.
|
|
84572
|
+
*/
|
|
84573
|
+
authorized(session) {
|
|
84574
|
+
if (session.refused) return false;
|
|
84575
|
+
if (session.wallet) return this.accountRefusal(session.wallet.account) === null;
|
|
84576
|
+
return session.wcPaired;
|
|
84577
|
+
}
|
|
84578
|
+
/** `sessionOf`, plus the wallet binding above — for the routes that decide a ceremony. */
|
|
84579
|
+
decidingSessionOf(candidate, res) {
|
|
84580
|
+
const session = this.sessionOf(candidate, res);
|
|
84581
|
+
if (!session) return null;
|
|
84582
|
+
if (!this.authorized(session)) {
|
|
84583
|
+
this.deny(res, 403, "connect your wallet on this page before approving, declining or finalizing a request");
|
|
84584
|
+
return null;
|
|
84585
|
+
}
|
|
84586
|
+
return session;
|
|
84587
|
+
}
|
|
84110
84588
|
sessionOf(candidate, res) {
|
|
84111
84589
|
const session = typeof candidate === "string" ? this.sessions.get(candidate) ?? null : null;
|
|
84112
84590
|
if (!session) {
|
|
84113
84591
|
this.deny(res, 403, "missing or wrong session");
|
|
84114
84592
|
return null;
|
|
84115
84593
|
}
|
|
84594
|
+
session.lastSeenMs = this.clock();
|
|
84116
84595
|
if (session.refused) {
|
|
84117
84596
|
this.deny(res, 403, session.refused);
|
|
84118
84597
|
return null;
|