@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/index.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;
|
|
@@ -40973,8 +41134,13 @@ function iso(sec) {
|
|
|
40973
41134
|
return new Date(sec * 1e3).toISOString();
|
|
40974
41135
|
}
|
|
40975
41136
|
var PSM_FLOOR_TOLERANCE_BPS = 100;
|
|
41137
|
+
var CANONICAL_MAINNET_USDC = "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48";
|
|
41138
|
+
function stablecoinKindFor(network, stablecoinAddress) {
|
|
41139
|
+
if (network !== "mainnet") return "mock";
|
|
41140
|
+
return stablecoinAddress.toLowerCase() === CANONICAL_MAINNET_USDC.toLowerCase() ? "circle" : "onchain";
|
|
41141
|
+
}
|
|
40976
41142
|
function failureToError(f) {
|
|
40977
|
-
const code = f.kind === "signer-missing" ? "SIGNER_UNAVAILABLE" : f.kind === "unavailable" ? "UPSTREAM_UNAVAILABLE" : f.kind === "not-found" ? "NOT_FOUND" : "UPSTREAM_REJECTED";
|
|
41143
|
+
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";
|
|
40978
41144
|
const message = f.kind === "malformed" ? `${f.message} (upstream response failed integrity checks)` : f.message;
|
|
40979
41145
|
return boundaryError(code, message, {
|
|
40980
41146
|
source: f.source,
|
|
@@ -41450,7 +41616,7 @@ var BoundaryCore = class {
|
|
|
41450
41616
|
tokenAddress: a.tokenAddress,
|
|
41451
41617
|
spenderAddress: a.spenderAddress,
|
|
41452
41618
|
spenderContract: a.spenderContract,
|
|
41453
|
-
spenderReason: a.spenderContract === "SimplePSMV2" ?
|
|
41619
|
+
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",
|
|
41454
41620
|
before: a.before,
|
|
41455
41621
|
amountUnit: q.amountInUnit,
|
|
41456
41622
|
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."
|
|
@@ -41509,9 +41675,10 @@ var BoundaryCore = class {
|
|
|
41509
41675
|
chainId: this.deps.chainId,
|
|
41510
41676
|
psmAddress: s.psmAddress,
|
|
41511
41677
|
stablecoinAddress: s.stablecoinAddress,
|
|
41512
|
-
//
|
|
41513
|
-
// practice
|
|
41514
|
-
|
|
41678
|
+
// Labelled by the ACTUAL coin, not the network (C-49): `circle` only for canonical
|
|
41679
|
+
// mainnet USDC, `mock` for the practice token, `onchain` for any other real coin
|
|
41680
|
+
// (e.g. mainnet USDT) — a USDT swap must never render as "real USDC".
|
|
41681
|
+
stablecoinKind: stablecoinKindFor(this.deps.network, s.stablecoinAddress),
|
|
41515
41682
|
stablecoinSymbol: s.stablecoinSymbol,
|
|
41516
41683
|
stablecoinDecimals: s.stablecoinDecimals,
|
|
41517
41684
|
exchangeRate: s.exchangeRate,
|
|
@@ -44493,6 +44660,35 @@ var import_ethers9 = require("ethers");
|
|
|
44493
44660
|
// src/boundary/upstream/shared/external-bridge/card.ts
|
|
44494
44661
|
var import_ethers7 = require("ethers");
|
|
44495
44662
|
init_tx_validator();
|
|
44663
|
+
|
|
44664
|
+
// src/boundary/upstream/shared/external-bridge/card-escape.ts
|
|
44665
|
+
var MAX_VALUE_CHARS = 200;
|
|
44666
|
+
function mustEscape(code) {
|
|
44667
|
+
if (code <= 31 || code === 127) return true;
|
|
44668
|
+
if (code >= 128 && code <= 159) return true;
|
|
44669
|
+
if (code === 8232 || code === 8233) return true;
|
|
44670
|
+
if (code >= 8234 && code <= 8238) return true;
|
|
44671
|
+
if (code >= 8294 && code <= 8297) return true;
|
|
44672
|
+
return false;
|
|
44673
|
+
}
|
|
44674
|
+
function safeValue(raw) {
|
|
44675
|
+
let out = "";
|
|
44676
|
+
for (const ch of String(raw)) {
|
|
44677
|
+
const code = ch.codePointAt(0);
|
|
44678
|
+
out += mustEscape(code) ? `\\u${code.toString(16).padStart(4, "0")}` : ch;
|
|
44679
|
+
if (out.length > MAX_VALUE_CHARS) return `${out.slice(0, MAX_VALUE_CHARS)}\u2026[truncated]`;
|
|
44680
|
+
}
|
|
44681
|
+
return out;
|
|
44682
|
+
}
|
|
44683
|
+
|
|
44684
|
+
// src/boundary/upstream/shared/external-bridge/card.ts
|
|
44685
|
+
function formatBtc(sats) {
|
|
44686
|
+
const negative = sats < 0n;
|
|
44687
|
+
const abs = negative ? -sats : sats;
|
|
44688
|
+
const whole = abs / 10n ** 8n;
|
|
44689
|
+
const frac = (abs % 10n ** 8n).toString().padStart(8, "0").replace(/0+$/, "");
|
|
44690
|
+
return `${negative ? "-" : ""}${whole}${frac ? "." + frac : ""}`;
|
|
44691
|
+
}
|
|
44496
44692
|
function formatUcd(wei) {
|
|
44497
44693
|
const negative = wei < 0n;
|
|
44498
44694
|
const abs = negative ? -wei : wei;
|
|
@@ -44538,15 +44734,15 @@ function cardForTx(tx2) {
|
|
|
44538
44734
|
"Operation: create a new borrowing position (your wallet is the borrower)",
|
|
44539
44735
|
`Term: ${Number(args[4])} months`,
|
|
44540
44736
|
`Position key (PKP id): ${String(args[0])}`,
|
|
44541
|
-
`BTC vault (mainnet form): ${
|
|
44542
|
-
`BTC vault (regtest form): ${
|
|
44737
|
+
`BTC vault (mainnet form): ${safeValue(args[2])}`,
|
|
44738
|
+
`BTC vault (regtest form): ${safeValue(args[3])}`,
|
|
44543
44739
|
`Validator generation: ${Number(args[5])}`,
|
|
44544
44740
|
...head
|
|
44545
44741
|
];
|
|
44546
44742
|
case "addAddress":
|
|
44547
44743
|
return [
|
|
44548
44744
|
"Operation: allowlist a Bitcoin withdrawal destination for YOUR account",
|
|
44549
|
-
`BTC address to allowlist: ${
|
|
44745
|
+
`BTC address to allowlist: ${safeValue(args[0])}`,
|
|
44550
44746
|
"Withdrawals to this address become possible only after the registry's on-chain delay",
|
|
44551
44747
|
...head
|
|
44552
44748
|
];
|
|
@@ -44574,15 +44770,40 @@ function cardForTx(tx2) {
|
|
|
44574
44770
|
`Minimum stablecoin out \u2014 the slippage floor (smallest units): ${String(args[2])}`,
|
|
44575
44771
|
...head
|
|
44576
44772
|
];
|
|
44773
|
+
case "withdrawBTC": {
|
|
44774
|
+
const p = args[0];
|
|
44775
|
+
return [
|
|
44776
|
+
"Operation: withdraw BTC from your vault \u2014 THIS MOVES BITCOIN OUT",
|
|
44777
|
+
`Position: ${safeValue(p.positionId)}`,
|
|
44778
|
+
// The destination is the whole security question of this card. It is a caller-
|
|
44779
|
+
// supplied string, hence safeValue: see the escaping note above.
|
|
44780
|
+
`BTC sent to: ${safeValue(p.withdrawalAddress)}`,
|
|
44781
|
+
`Leaves the vault (fee included): ${formatBtc(BigInt(p.totalDeduction))} BTC (${BigInt(p.totalDeduction)} sats)`,
|
|
44782
|
+
`Collateral remaining after this: ${formatBtc(BigInt(p.newCollateral))} BTC (${BigInt(p.newCollateral)} sats)`,
|
|
44783
|
+
`Spending vault UTXO: ${safeValue(p.utxoTxid)}:${Number(p.utxoVout)}`,
|
|
44784
|
+
...head
|
|
44785
|
+
];
|
|
44786
|
+
}
|
|
44787
|
+
case "setPositionDelegate":
|
|
44788
|
+
return [
|
|
44789
|
+
"Operation: set the DELEGATE for this position \u2014 this address may act on the position on your behalf",
|
|
44790
|
+
`Position: ${safeValue(args[0])}`,
|
|
44791
|
+
`Delegate address: ${safeValue(args[1])}`,
|
|
44792
|
+
"Setting the zero address removes the current delegate",
|
|
44793
|
+
...head
|
|
44794
|
+
];
|
|
44577
44795
|
default:
|
|
44578
|
-
|
|
44796
|
+
throw new Error(
|
|
44797
|
+
`no approval card is defined for the signable function "${name}" \u2014 add a case to cardForTx before this operation can be approved`
|
|
44798
|
+
);
|
|
44579
44799
|
}
|
|
44580
44800
|
}
|
|
44581
44801
|
function cardForTypedData(action, payload) {
|
|
44582
44802
|
const m = payload.message;
|
|
44583
44803
|
return [
|
|
44584
44804
|
`Operation: ${action} \u2014 this signature AUTHORIZES the operation described below; the protocol executes it after your approval`,
|
|
44585
|
-
|
|
44805
|
+
// `detail` here is a server-composed string — same escaping rule as the tx card.
|
|
44806
|
+
...Object.entries(m).map(([k, v]) => `${safeValue(k)}: ${safeValue(v)}`),
|
|
44586
44807
|
`Signing domain: ${String(payload.domain["name"])} v${String(payload.domain["version"])} \xB7 chain ${String(payload.domain["chainId"])}`
|
|
44587
44808
|
];
|
|
44588
44809
|
}
|
|
@@ -44933,12 +45154,10 @@ init_tx_validator();
|
|
|
44933
45154
|
|
|
44934
45155
|
// src/boundary/upstream/shared/quantum.ts
|
|
44935
45156
|
var QUANTUM_WINDOW_SECONDS = 60;
|
|
44936
|
-
var AUTH_VALIDITY_WINDOWS = 3;
|
|
44937
|
-
function authValiditySec() {
|
|
44938
|
-
return QUANTUM_WINDOW_SECONDS * AUTH_VALIDITY_WINDOWS;
|
|
44939
|
-
}
|
|
44940
45157
|
function isAuthFresh(issuedAtSec, nowSec) {
|
|
44941
|
-
|
|
45158
|
+
const sq = Math.floor(issuedAtSec / QUANTUM_WINDOW_SECONDS) * QUANTUM_WINDOW_SECONDS;
|
|
45159
|
+
const cq = Math.floor(nowSec / QUANTUM_WINDOW_SECONDS) * QUANTUM_WINDOW_SECONDS;
|
|
45160
|
+
return sq === cq - QUANTUM_WINDOW_SECONDS || sq === cq || sq === cq + QUANTUM_WINDOW_SECONDS;
|
|
44942
45161
|
}
|
|
44943
45162
|
function isStrictCurrentQuantum(issuedAtSec, nowSec) {
|
|
44944
45163
|
return issuedAtSec <= nowSec && Math.floor(issuedAtSec / QUANTUM_WINDOW_SECONDS) === Math.floor(nowSec / QUANTUM_WINDOW_SECONDS);
|
|
@@ -44979,7 +45198,7 @@ var SafeCeremony = class {
|
|
|
44979
45198
|
if (!auth.ok) return auth.refusal;
|
|
44980
45199
|
if (!isAuthFresh(issuedAtSec, surface.nowSec())) {
|
|
44981
45200
|
return this.refuse(
|
|
44982
|
-
`${p.action}: the owners' authorization expired \u2014 issued
|
|
45201
|
+
`${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`
|
|
44983
45202
|
);
|
|
44984
45203
|
}
|
|
44985
45204
|
const raw = await executor.signTransaction({
|
|
@@ -51698,7 +51917,6 @@ var init_deployment_addresses = __esm2({
|
|
|
51698
51917
|
PositionDelegateRegistry: "0x482369De283622E7b05731875ec137d4E3D208F9",
|
|
51699
51918
|
FeeRecipientRegistry: "0x95795F8403DDb629E8527B2934C4e71f5fC0C374",
|
|
51700
51919
|
BitcoinWithdrawalAddressRegistry: "0x6376D392097F0A81e51BD83960A97EA20eaf1dbe",
|
|
51701
|
-
CarryAgentRegistry: "0x5595CB538D44E6Cf179D20364fD631D0477e69f7",
|
|
51702
51920
|
AgentDelegationRegistry: "0x6AE7fc6bE0925126b9D25b1B7Ce5AD5d127ec025",
|
|
51703
51921
|
DHAgentDelegate: "0xa5A14489ae883960df6E1463A41a47aBE9Ecc5AF",
|
|
51704
51922
|
AgentModuleFactory: "0x1Fd3aCa2C030Cf77ce28Af9694D3Bb3034ACa2E5"
|
|
@@ -51968,8 +52186,6 @@ var init_deployment_addresses = __esm2({
|
|
|
51968
52186
|
OPERATION_AUTHORIZATION_REGISTRY_IMPL: "0xe0D981B60351f0f8fFDA2b50C8180Fb37CeF3883",
|
|
51969
52187
|
BITCOIN_WITHDRAWAL_ADDRESS_REGISTRY: "0x6376D392097F0A81e51BD83960A97EA20eaf1dbe",
|
|
51970
52188
|
BITCOIN_WITHDRAWAL_ADDRESS_REGISTRY_IMPL: "0x76E0a2c9d89562fD7c50b5f554d7fa25957e39Db",
|
|
51971
|
-
CARRY_AGENT_REGISTRY: "0x5595CB538D44E6Cf179D20364fD631D0477e69f7",
|
|
51972
|
-
CARRY_AGENT_REGISTRY_IMPL: "0x1b11a3D5e46F3672E643c997f0d569DFf0b64a01",
|
|
51973
52189
|
AGENT_DELEGATION_REGISTRY: "0x6AE7fc6bE0925126b9D25b1B7Ce5AD5d127ec025",
|
|
51974
52190
|
AGENT_DELEGATION_REGISTRY_IMPL: "0xE931E4b9ceF2A48Ac7D57192da4B523756cFC310",
|
|
51975
52191
|
DH_AGENT_DELEGATE: "0xa5A14489ae883960df6E1463A41a47aBE9Ecc5AF"
|
|
@@ -52001,7 +52217,6 @@ var init_deployment_addresses = __esm2({
|
|
|
52001
52217
|
PositionDelegateRegistry: "0x482369De283622E7b05731875ec137d4E3D208F9",
|
|
52002
52218
|
FeeRecipientRegistry: "0x95795F8403DDb629E8527B2934C4e71f5fC0C374",
|
|
52003
52219
|
BitcoinWithdrawalAddressRegistry: "0x6376D392097F0A81e51BD83960A97EA20eaf1dbe",
|
|
52004
|
-
CarryAgentRegistry: "0x5595CB538D44E6Cf179D20364fD631D0477e69f7",
|
|
52005
52220
|
AgentDelegationRegistry: "0x6AE7fc6bE0925126b9D25b1B7Ce5AD5d127ec025",
|
|
52006
52221
|
DHAgentDelegate: "0xa5A14489ae883960df6E1463A41a47aBE9Ecc5AF",
|
|
52007
52222
|
AgentModuleFactory: "0x1Fd3aCa2C030Cf77ce28Af9694D3Bb3034ACa2E5"
|
|
@@ -52976,113 +53191,113 @@ var require_pkg_src2 = __commonJS2({
|
|
|
52976
53191
|
deployedAt: 1784569687492,
|
|
52977
53192
|
size: 4140,
|
|
52978
53193
|
hash: "4c0d65bf1f33cdac22a78fd8c4764319cc3fe00650e0fe7fa8a6090d9a318a7b",
|
|
52979
|
-
validatorWalletAddress: "
|
|
53194
|
+
validatorWalletAddress: "0xefb258d455a31d061bbeb3de3d2143bdfcb67a6c",
|
|
52980
53195
|
pkp: {
|
|
52981
53196
|
publicKey: "0x04ec0e3acc40884e3f366ca469d08899eb640ad5259fa196b0238075086208a9f8732a3175704f35f0bcc28e07406cfb24c254efd1e7355640577330f0d2dd755f",
|
|
52982
|
-
ethAddress: "
|
|
53197
|
+
ethAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C"
|
|
52983
53198
|
}
|
|
52984
53199
|
},
|
|
52985
53200
|
btcTransactionSigner: {
|
|
52986
|
-
cid: "
|
|
53201
|
+
cid: "QmULkz7hwwqsyLwY23U14dnartdVuSNMrykt69PaNiAq7U",
|
|
52987
53202
|
authorizedCidHex: cidToHex(
|
|
52988
|
-
"
|
|
53203
|
+
"QmULkz7hwwqsyLwY23U14dnartdVuSNMrykt69PaNiAq7U"
|
|
52989
53204
|
),
|
|
52990
53205
|
name: "Btc Transaction Signer",
|
|
52991
53206
|
description: "Production Btc Transaction Signer",
|
|
52992
53207
|
version: "1.1.1",
|
|
52993
53208
|
deployed: true,
|
|
52994
|
-
deployedAt:
|
|
52995
|
-
size:
|
|
52996
|
-
hash: "
|
|
53209
|
+
deployedAt: 1790246185256,
|
|
53210
|
+
size: 73313,
|
|
53211
|
+
hash: "d8b6bc646ba33fee7d46c8e9b281de776081ea6f182f56fd15d4c52aaf3dd030"
|
|
52997
53212
|
},
|
|
52998
53213
|
ucdMintValidator: {
|
|
52999
|
-
cid: "
|
|
53214
|
+
cid: "QmcxVSn9saEPGBS6mqPhNefgW83V2qeZjjXbhwYLP373xe",
|
|
53000
53215
|
authorizedCidHex: cidToHex(
|
|
53001
|
-
"
|
|
53216
|
+
"QmcxVSn9saEPGBS6mqPhNefgW83V2qeZjjXbhwYLP373xe"
|
|
53002
53217
|
),
|
|
53003
53218
|
name: "Ucd Mint Validator",
|
|
53004
53219
|
description: "Production Ucd Mint Validator",
|
|
53005
|
-
version: "1.
|
|
53220
|
+
version: "1.3.0",
|
|
53006
53221
|
deployed: true,
|
|
53007
|
-
deployedAt:
|
|
53008
|
-
size:
|
|
53009
|
-
hash: "
|
|
53010
|
-
validatorWalletAddress: "
|
|
53222
|
+
deployedAt: 1790246219868,
|
|
53223
|
+
size: 90022,
|
|
53224
|
+
hash: "65e8cb778c2b767ae6eb37cb5db7b4c5a3f2468d508463c847c83c1b6825fadd",
|
|
53225
|
+
validatorWalletAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C",
|
|
53011
53226
|
pkp: {
|
|
53012
53227
|
publicKey: "0x041ab17cd91fc5c0b761eea6092d032807561b621b82c488826776e04a9158d61ba64d809a4729f0501289d980732cb06d8dfd06999dd9c8efd2f495dad78b31bb",
|
|
53013
|
-
ethAddress: "
|
|
53228
|
+
ethAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C"
|
|
53014
53229
|
}
|
|
53015
53230
|
},
|
|
53016
53231
|
processPaymentValidator: {
|
|
53017
|
-
cid: "
|
|
53232
|
+
cid: "QmWFbxJkfxhCtES4wrePWQkYtjhtrP1tohvn9d1r9N5Hd8",
|
|
53018
53233
|
authorizedCidHex: cidToHex(
|
|
53019
|
-
"
|
|
53234
|
+
"QmWFbxJkfxhCtES4wrePWQkYtjhtrP1tohvn9d1r9N5Hd8"
|
|
53020
53235
|
),
|
|
53021
53236
|
name: "Process Payment Validator",
|
|
53022
53237
|
description: "Production Process Payment Validator",
|
|
53023
53238
|
version: "1.2.1",
|
|
53024
53239
|
deployed: true,
|
|
53025
|
-
deployedAt:
|
|
53026
|
-
size:
|
|
53027
|
-
hash: "
|
|
53028
|
-
validatorWalletAddress: "
|
|
53240
|
+
deployedAt: 1790246225795,
|
|
53241
|
+
size: 85107,
|
|
53242
|
+
hash: "25ecf952c4c44c40b0920b92d57906e7010ed9a38e2ba41ccdee6d3377c2b596",
|
|
53243
|
+
validatorWalletAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C",
|
|
53029
53244
|
pkp: {
|
|
53030
53245
|
publicKey: "0x04cfccb9b6c7addc79469c0e9fafebef4c70801302c62cdb26b610723a9b8527d23f98a40158c7340d83fd0e62d02b5ec74c12f7a86d98e8c6973b4811110f19ad",
|
|
53031
|
-
ethAddress: "
|
|
53246
|
+
ethAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C"
|
|
53032
53247
|
}
|
|
53033
53248
|
},
|
|
53034
53249
|
extendPositionValidator: {
|
|
53035
|
-
cid: "
|
|
53250
|
+
cid: "QmZ3g7g5DkgU1gEYpFjprQf3sctUHtGjNQVYezw2bnPGEX",
|
|
53036
53251
|
authorizedCidHex: cidToHex(
|
|
53037
|
-
"
|
|
53252
|
+
"QmZ3g7g5DkgU1gEYpFjprQf3sctUHtGjNQVYezw2bnPGEX"
|
|
53038
53253
|
),
|
|
53039
53254
|
name: "Extend Position Validator",
|
|
53040
53255
|
description: "Production Extend Position Validator",
|
|
53041
53256
|
version: "1.2.1",
|
|
53042
53257
|
deployed: true,
|
|
53043
|
-
deployedAt:
|
|
53044
|
-
size:
|
|
53045
|
-
hash: "
|
|
53046
|
-
validatorWalletAddress: "
|
|
53258
|
+
deployedAt: 1790246231975,
|
|
53259
|
+
size: 82853,
|
|
53260
|
+
hash: "25d4887b7f646649db2bb7f2bfb77d039db83228a6c454377ca26c779b0903cc",
|
|
53261
|
+
validatorWalletAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C",
|
|
53047
53262
|
pkp: {
|
|
53048
53263
|
publicKey: "0x04e52338f6a0c3362800f1a94c4c8f08be5030dde0fa217388c53d1c1a4790f4443c9f2886b2d2d8f4b75a9a156e9b028011b1a1cf7648da0e556aa980ec692836",
|
|
53049
|
-
ethAddress: "
|
|
53264
|
+
ethAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C"
|
|
53050
53265
|
}
|
|
53051
53266
|
},
|
|
53052
53267
|
btcWithdrawal: {
|
|
53053
|
-
cid: "
|
|
53268
|
+
cid: "QmbRaaMQr1jCctDGe8mPADsUz1rkb4frT1YqSKroiXjzyP",
|
|
53054
53269
|
authorizedCidHex: cidToHex(
|
|
53055
|
-
"
|
|
53270
|
+
"QmbRaaMQr1jCctDGe8mPADsUz1rkb4frT1YqSKroiXjzyP"
|
|
53056
53271
|
),
|
|
53057
53272
|
name: "Btc Withdrawal",
|
|
53058
53273
|
description: "Production Btc Withdrawal",
|
|
53059
53274
|
version: "1.2.7",
|
|
53060
53275
|
deployed: true,
|
|
53061
|
-
deployedAt:
|
|
53062
|
-
size:
|
|
53063
|
-
hash: "
|
|
53064
|
-
validatorWalletAddress: "
|
|
53276
|
+
deployedAt: 1790246239599,
|
|
53277
|
+
size: 101228,
|
|
53278
|
+
hash: "2ed25eca6cc80a43061b7ad119737af48158fdb61d59f10cd06cea51b607f112",
|
|
53279
|
+
validatorWalletAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C",
|
|
53065
53280
|
pkp: {
|
|
53066
53281
|
publicKey: "0x043616787c5432415c24378c4ef48de2bcd6bb7b575b837e3cff09171802662da7105d79586c7659677a0ecbaddac4cce06cb2a11f69a16fa0c4d7002ac7d51a4d",
|
|
53067
|
-
ethAddress: "
|
|
53282
|
+
ethAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C"
|
|
53068
53283
|
}
|
|
53069
53284
|
},
|
|
53070
53285
|
liquidationValidator: {
|
|
53071
|
-
cid: "
|
|
53286
|
+
cid: "QmTs2w8gfAwWZLbzJZg2CZmiLhVXS5kbMgaj42Zuxfodpb",
|
|
53072
53287
|
authorizedCidHex: cidToHex(
|
|
53073
|
-
"
|
|
53288
|
+
"QmTs2w8gfAwWZLbzJZg2CZmiLhVXS5kbMgaj42Zuxfodpb"
|
|
53074
53289
|
),
|
|
53075
53290
|
name: "Liquidation Validator",
|
|
53076
53291
|
description: "Production Liquidation Validator",
|
|
53077
53292
|
version: "1.2.1",
|
|
53078
53293
|
deployed: true,
|
|
53079
|
-
deployedAt:
|
|
53080
|
-
size:
|
|
53081
|
-
hash: "
|
|
53082
|
-
validatorWalletAddress: "
|
|
53294
|
+
deployedAt: 1790246247904,
|
|
53295
|
+
size: 70308,
|
|
53296
|
+
hash: "582ccf0ec7f715195e20fdc885996743cb42125b64173424e360ee63db62bbd8",
|
|
53297
|
+
validatorWalletAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C",
|
|
53083
53298
|
pkp: {
|
|
53084
53299
|
publicKey: "0x041a241de58976c13e3d7ca5a18e494f7330151e3818706135d50176e78ffb673e58b11f0b67a87c73fade6c6b27d6e7a7377ea9f4c10bf31880f1d725f18cc6f8",
|
|
53085
|
-
ethAddress: "
|
|
53300
|
+
ethAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C"
|
|
53086
53301
|
}
|
|
53087
53302
|
},
|
|
53088
53303
|
priceOracle: {
|
|
@@ -53097,28 +53312,28 @@ var require_pkg_src2 = __commonJS2({
|
|
|
53097
53312
|
deployedAt: 1781116663270,
|
|
53098
53313
|
size: 8695,
|
|
53099
53314
|
hash: "ba20ade60a7fa5acd80dadfafa179c507388cfe6ce48a22a672d70b317ffcc74",
|
|
53100
|
-
validatorWalletAddress: "
|
|
53315
|
+
validatorWalletAddress: "0xefb258d455a31d061bbeb3de3d2143bdfcb67a6c",
|
|
53101
53316
|
pkp: {
|
|
53102
53317
|
publicKey: "0x043beaa1da47875601a8d6f430b1438ee2d4732eefd06e5c63a474bbdaf9e7df1797b1b951e041b627c2bf839788164825324c9cbd1e2d6f740fdd4bff69b1900b",
|
|
53103
|
-
ethAddress: "
|
|
53318
|
+
ethAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C"
|
|
53104
53319
|
}
|
|
53105
53320
|
},
|
|
53106
53321
|
loanVaultBtcBalance: {
|
|
53107
|
-
cid: "
|
|
53322
|
+
cid: "QmZ27xCzuoaAhWxRsMPsUQkp45a8WPBb21uhxwchw3LG5W",
|
|
53108
53323
|
authorizedCidHex: cidToHex(
|
|
53109
|
-
"
|
|
53324
|
+
"QmZ27xCzuoaAhWxRsMPsUQkp45a8WPBb21uhxwchw3LG5W"
|
|
53110
53325
|
),
|
|
53111
53326
|
name: "Loan Vault Btc Balance",
|
|
53112
53327
|
description: "Production Loan Vault Btc Balance",
|
|
53113
53328
|
version: "1.2.1",
|
|
53114
53329
|
deployed: true,
|
|
53115
|
-
deployedAt:
|
|
53116
|
-
size:
|
|
53117
|
-
hash: "
|
|
53118
|
-
validatorWalletAddress: "
|
|
53330
|
+
deployedAt: 1790179961079,
|
|
53331
|
+
size: 60046,
|
|
53332
|
+
hash: "922e86c0a667fe0c0945771f84aa6b9fe08be9c96dd2f73a9c5cb257d24e22b0",
|
|
53333
|
+
validatorWalletAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C",
|
|
53119
53334
|
pkp: {
|
|
53120
53335
|
publicKey: "0x043616787c5432415c24378c4ef48de2bcd6bb7b575b837e3cff09171802662da7105d79586c7659677a0ecbaddac4cce06cb2a11f69a16fa0c4d7002ac7d51a4d",
|
|
53121
|
-
ethAddress: "
|
|
53336
|
+
ethAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C"
|
|
53122
53337
|
}
|
|
53123
53338
|
},
|
|
53124
53339
|
// btc-address-balance (Option B) — address-only signed total balance via
|
|
@@ -53128,21 +53343,21 @@ var require_pkg_src2 = __commonJS2({
|
|
|
53128
53343
|
// Requires BitcoinProviderRegistry.addAllowedCid(chainId, keccak256(utf8(cid)))
|
|
53129
53344
|
// on each target chain (the action decrypts registry slots). No OAR entry.
|
|
53130
53345
|
btcAddressBalance: {
|
|
53131
|
-
cid: "
|
|
53346
|
+
cid: "QmVVjB6zCBiXFKffhQPYUAZhj7TXduuvcrPqKtHa3DMXhN",
|
|
53132
53347
|
authorizedCidHex: cidToHex(
|
|
53133
|
-
"
|
|
53348
|
+
"QmVVjB6zCBiXFKffhQPYUAZhj7TXduuvcrPqKtHa3DMXhN"
|
|
53134
53349
|
),
|
|
53135
53350
|
name: "Btc Address Balance",
|
|
53136
53351
|
description: "Address-only signed total BTC balance via registry consensus (no positionId, no price)",
|
|
53137
53352
|
version: "0.2.1",
|
|
53138
53353
|
deployed: true,
|
|
53139
|
-
deployedAt:
|
|
53140
|
-
size:
|
|
53141
|
-
hash: "
|
|
53142
|
-
validatorWalletAddress: "
|
|
53354
|
+
deployedAt: 1790179971315,
|
|
53355
|
+
size: 30295,
|
|
53356
|
+
hash: "2c67d9cfa4d50e835fbb28ae50e80217ceb2be3bb862c89290aadf43fdc739c9",
|
|
53357
|
+
validatorWalletAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C",
|
|
53143
53358
|
pkp: {
|
|
53144
53359
|
publicKey: "0x0498cbb31facfa26e3ec83ccdabfe4fe341ca0282e0c3cb81da7113723b9726e1e49efa92165cc3faa66ced4454cea56dbab12267852d6525a55d7c4f128b912cd",
|
|
53145
|
-
ethAddress: "
|
|
53360
|
+
ethAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C"
|
|
53146
53361
|
}
|
|
53147
53362
|
},
|
|
53148
53363
|
alwaysSigner: {
|
|
@@ -53172,48 +53387,48 @@ var require_pkg_src2 = __commonJS2({
|
|
|
53172
53387
|
hash: "03ee5be239c91c735d2c95db89a0d1b77e602cfc18af8eb64b3281fddcd90a72"
|
|
53173
53388
|
},
|
|
53174
53389
|
agentModuleExecutor: {
|
|
53175
|
-
cid: "
|
|
53390
|
+
cid: "QmSwPPvQhT7UhcuVA2m3UxGhVj5WqMpDvYNKU1228QLFsX",
|
|
53176
53391
|
authorizedCidHex: cidToHex(
|
|
53177
|
-
"
|
|
53392
|
+
"QmSwPPvQhT7UhcuVA2m3UxGhVj5WqMpDvYNKU1228QLFsX"
|
|
53178
53393
|
),
|
|
53179
53394
|
name: "Agent Module Executor",
|
|
53180
53395
|
description: "Production Agent Module Executor",
|
|
53181
53396
|
version: "1.1.1",
|
|
53182
53397
|
deployed: true,
|
|
53183
|
-
deployedAt:
|
|
53184
|
-
size:
|
|
53185
|
-
hash: "
|
|
53398
|
+
deployedAt: 1790179978959,
|
|
53399
|
+
size: 14688,
|
|
53400
|
+
hash: "8edb9b12c784c8d7d153cce97235584c24665a788767ae68713dce91109ab35e"
|
|
53186
53401
|
},
|
|
53187
53402
|
staleSpendRecoveryValidator: {
|
|
53188
|
-
cid: "
|
|
53403
|
+
cid: "Qmarj59zdSSgivkimryrdvnyZqH5YpTimKj1LivXNBHmNz",
|
|
53189
53404
|
authorizedCidHex: cidToHex(
|
|
53190
|
-
"
|
|
53405
|
+
"Qmarj59zdSSgivkimryrdvnyZqH5YpTimKj1LivXNBHmNz"
|
|
53191
53406
|
),
|
|
53192
53407
|
name: "Stale Spend Recovery Validator",
|
|
53193
53408
|
description: "Production Stale Spend Recovery Validator",
|
|
53194
53409
|
version: "1.1.2",
|
|
53195
53410
|
deployed: true,
|
|
53196
|
-
deployedAt:
|
|
53197
|
-
size:
|
|
53198
|
-
hash: "
|
|
53199
|
-
validatorWalletAddress: "
|
|
53411
|
+
deployedAt: 1790246256280,
|
|
53412
|
+
size: 48143,
|
|
53413
|
+
hash: "ec9236bcbe0af24d3e1844791fc8fe37371bbecd8ce95d02e13f7c6e1fc7d94c",
|
|
53414
|
+
validatorWalletAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C",
|
|
53200
53415
|
pkp: {
|
|
53201
53416
|
publicKey: "0x046da0ad6da7dd4a0063cbeac6f2bdb6a9889c2178b23470833356a8ee5630f7f0eee0db348d9d9aaaadd23eccf0063c8f68ee5e446abe30b882bf1de4c932bc21",
|
|
53202
|
-
ethAddress: "
|
|
53417
|
+
ethAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C"
|
|
53203
53418
|
}
|
|
53204
53419
|
},
|
|
53205
53420
|
btcUtxoInvalidator: {
|
|
53206
|
-
cid: "
|
|
53421
|
+
cid: "QmbS44bGcmKYF64Cu35qzsk9sxiU4Umde8Z3q24ZnEbQvX",
|
|
53207
53422
|
authorizedCidHex: cidToHex(
|
|
53208
|
-
"
|
|
53423
|
+
"QmbS44bGcmKYF64Cu35qzsk9sxiU4Umde8Z3q24ZnEbQvX"
|
|
53209
53424
|
),
|
|
53210
53425
|
name: "Btc Utxo Invalidator",
|
|
53211
53426
|
description: "Production Btc Utxo Invalidator",
|
|
53212
53427
|
version: "1.0.0",
|
|
53213
53428
|
deployed: true,
|
|
53214
|
-
deployedAt:
|
|
53215
|
-
size:
|
|
53216
|
-
hash: "
|
|
53429
|
+
deployedAt: 1790246264563,
|
|
53430
|
+
size: 69219,
|
|
53431
|
+
hash: "bda048d8cd6b5a39c2774bcf1320e82d1eea935c2a521006fb8b887e13b6dd8d"
|
|
53217
53432
|
}
|
|
53218
53433
|
};
|
|
53219
53434
|
function getDeploymentsForNetwork(network) {
|
|
@@ -53981,7 +54196,10 @@ ${errorReport}`);
|
|
|
53981
54196
|
BTCSpendAuthorizer: "0xfBbF108486fa07F1B06a811C5b66ed68DD9c508a",
|
|
53982
54197
|
BitcoinProviderRegistry: "0x4ab3Fb96e02893Ed6FAa61bad1918390c8DbbFFC",
|
|
53983
54198
|
LITActionValidator: "0xD2c5d59c2CC5c409AC65ce0A817236aeC6869512",
|
|
53984
|
-
PositionDelegateRegistry: "0xf0aa2678aD4F60f49e8F7725089B5E86B7F8FE4C"
|
|
54199
|
+
PositionDelegateRegistry: "0xf0aa2678aD4F60f49e8F7725089B5E86B7F8FE4C",
|
|
54200
|
+
TermManagerModule: "0xDB99CdF883ffa38acD099bC39F8d1f4508c9239E",
|
|
54201
|
+
UCDController: "0x4b4f8063048bCD59D469219E3f07C6aaDF4f6157",
|
|
54202
|
+
LiquidationManagerModule: "0x74B28695352E7bf736D6c9F76ccb7B4439477De9"
|
|
53985
54203
|
},
|
|
53986
54204
|
11155111: {
|
|
53987
54205
|
PositionManager: "0x68e0507D982AEBF1D1C1Af8FBbd842327e2deeFF",
|
|
@@ -53989,7 +54207,10 @@ ${errorReport}`);
|
|
|
53989
54207
|
BTCSpendAuthorizer: "0xd7E9Eb5eE53f1d9ee55Dc162bBC7486bE437B6bD",
|
|
53990
54208
|
BitcoinProviderRegistry: "0xbfA0c48B070D0a9A9CD27469AeacFD2d4261cEE2",
|
|
53991
54209
|
LITActionValidator: "0x54eECd7C90F8A8fac27749Ba30BbE8AFBAccc856",
|
|
53992
|
-
PositionDelegateRegistry: "0x482369De283622E7b05731875ec137d4E3D208F9"
|
|
54210
|
+
PositionDelegateRegistry: "0x482369De283622E7b05731875ec137d4E3D208F9",
|
|
54211
|
+
TermManagerModule: "0x94Adc6F9558368B1482197584f1fc7133Ecf835b",
|
|
54212
|
+
UCDController: "0x360Bde4e489ee94E26601B206932De09EE60FF04",
|
|
54213
|
+
LiquidationManagerModule: "0xC4AB00f39e7ceD812F5C67058C9fa44e15d40e76"
|
|
53993
54214
|
}
|
|
53994
54215
|
};
|
|
53995
54216
|
function getPinnedContractAddresses(chainId) {
|
|
@@ -54175,10 +54396,10 @@ ${errorReport}`);
|
|
|
54175
54396
|
};
|
|
54176
54397
|
}
|
|
54177
54398
|
const ratioBigInt = collateralValueUsd * UCD_TOKEN_DECIMALS * 10000n / ucdDebt;
|
|
54178
|
-
const
|
|
54399
|
+
const collateralRatioBps2 = Number(ratioBigInt);
|
|
54179
54400
|
return {
|
|
54180
54401
|
collateralValueUsd,
|
|
54181
|
-
collateralRatioBps
|
|
54402
|
+
collateralRatioBps: collateralRatioBps2
|
|
54182
54403
|
};
|
|
54183
54404
|
}
|
|
54184
54405
|
function hasSufficientCollateralForDebt(collateralValueUsd, currentDebt, additionalDebt, requiredRatioBps) {
|
|
@@ -55032,6 +55253,17 @@ ${auth.clientId}`;
|
|
|
55032
55253
|
);
|
|
55033
55254
|
}
|
|
55034
55255
|
}
|
|
55256
|
+
var TIP_READ_FAILURE_PREFIX = "Bitcoin tip-height read failed";
|
|
55257
|
+
var BitcoinTipUnreadableError = class extends Error {
|
|
55258
|
+
constructor(message) {
|
|
55259
|
+
super(message);
|
|
55260
|
+
this.isBitcoinTipUnreadable = true;
|
|
55261
|
+
this.name = "BitcoinTipUnreadableError";
|
|
55262
|
+
}
|
|
55263
|
+
};
|
|
55264
|
+
function isBitcoinTipUnreadableError(error) {
|
|
55265
|
+
return typeof error === "object" && error !== null && error.isBitcoinTipUnreadable === true;
|
|
55266
|
+
}
|
|
55035
55267
|
var BitcoinDataProvider = class {
|
|
55036
55268
|
constructor(config) {
|
|
55037
55269
|
this.config = config;
|
|
@@ -55483,27 +55715,12 @@ ${auth.clientId}`;
|
|
|
55483
55715
|
if (!data.status.confirmed || !data.status.block_height) {
|
|
55484
55716
|
return { txid: data.txid ?? txid, confirmations: 0 };
|
|
55485
55717
|
}
|
|
55486
|
-
|
|
55487
|
-
|
|
55488
|
-
|
|
55489
|
-
|
|
55490
|
-
|
|
55491
|
-
|
|
55492
|
-
return { txid: data.txid ?? txid, confirmations: 1 };
|
|
55493
|
-
}
|
|
55494
|
-
const tipBody = (await tipResp.text()).trim();
|
|
55495
|
-
const tipHeight = Number.parseInt(tipBody, 10);
|
|
55496
|
-
if (!Number.isFinite(tipHeight) || tipHeight <= 0) {
|
|
55497
|
-
return { txid: data.txid ?? txid, confirmations: 1 };
|
|
55498
|
-
}
|
|
55499
|
-
const depth = tipHeight - data.status.block_height + 1;
|
|
55500
|
-
return {
|
|
55501
|
-
txid: data.txid ?? txid,
|
|
55502
|
-
confirmations: depth > 0 ? depth : 0
|
|
55503
|
-
};
|
|
55504
|
-
} catch {
|
|
55505
|
-
return { txid: data.txid ?? txid, confirmations: 1 };
|
|
55506
|
-
}
|
|
55718
|
+
const tipHeight = await this.fetchTipHeight(controller.signal);
|
|
55719
|
+
const depth = tipHeight - data.status.block_height + 1;
|
|
55720
|
+
return {
|
|
55721
|
+
txid: data.txid ?? txid,
|
|
55722
|
+
confirmations: depth > 0 ? depth : 0
|
|
55723
|
+
};
|
|
55507
55724
|
}
|
|
55508
55725
|
return null;
|
|
55509
55726
|
} catch (error) {
|
|
@@ -55511,12 +55728,55 @@ ${auth.clientId}`;
|
|
|
55511
55728
|
if (isAbortError(error)) {
|
|
55512
55729
|
throw new Error(`Request timeout after ${this.timeout}ms`);
|
|
55513
55730
|
}
|
|
55731
|
+
if (isBitcoinTipUnreadableError(error)) {
|
|
55732
|
+
throw error;
|
|
55733
|
+
}
|
|
55514
55734
|
if (getUnknownErrorMessage(error).includes("404")) {
|
|
55515
55735
|
return null;
|
|
55516
55736
|
}
|
|
55517
55737
|
throw error;
|
|
55518
55738
|
}
|
|
55519
55739
|
}
|
|
55740
|
+
/**
|
|
55741
|
+
* Current chain tip height from THIS provider — or throw.
|
|
55742
|
+
*
|
|
55743
|
+
* Every exit is a throw naming the provider and the precise failure, because
|
|
55744
|
+
* the only alternative is inventing a confirmation depth (see the call site).
|
|
55745
|
+
* The single `try` exists solely to attach that name to a transport-level
|
|
55746
|
+
* rejection (DNS, TLS, connection reset, abort); it re-throws the cause
|
|
55747
|
+
* verbatim inside the message and never substitutes a value — authorized for
|
|
55748
|
+
* this case by the Batch 2 plan, §C2.
|
|
55749
|
+
*
|
|
55750
|
+
* @param signal - The caller's AbortSignal, so this read shares the same
|
|
55751
|
+
* timeout budget as the transaction fetch it serves.
|
|
55752
|
+
*/
|
|
55753
|
+
async fetchTipHeight(signal) {
|
|
55754
|
+
const endpoint = `${this.config.providerUrl}/blocks/tip/height`;
|
|
55755
|
+
let tipResp;
|
|
55756
|
+
try {
|
|
55757
|
+
tipResp = await fetch(endpoint, {
|
|
55758
|
+
signal,
|
|
55759
|
+
headers: await this.withAuth()
|
|
55760
|
+
});
|
|
55761
|
+
} catch (error) {
|
|
55762
|
+
throw new BitcoinTipUnreadableError(
|
|
55763
|
+
`${TIP_READ_FAILURE_PREFIX}: GET ${endpoint} threw \u2014 ${getUnknownErrorMessage(error)}`
|
|
55764
|
+
);
|
|
55765
|
+
}
|
|
55766
|
+
if (!tipResp.ok) {
|
|
55767
|
+
throw new BitcoinTipUnreadableError(
|
|
55768
|
+
`${TIP_READ_FAILURE_PREFIX}: GET ${endpoint} \u2192 ${tipResp.status} ${tipResp.statusText}`
|
|
55769
|
+
);
|
|
55770
|
+
}
|
|
55771
|
+
const tipBody = (await tipResp.text()).trim();
|
|
55772
|
+
const tipHeight = Number.parseInt(tipBody, 10);
|
|
55773
|
+
if (!Number.isFinite(tipHeight) || tipHeight <= 0) {
|
|
55774
|
+
throw new BitcoinTipUnreadableError(
|
|
55775
|
+
`${TIP_READ_FAILURE_PREFIX}: GET ${endpoint} returned an unusable tip height "${tipBody.slice(0, 64)}"`
|
|
55776
|
+
);
|
|
55777
|
+
}
|
|
55778
|
+
return tipHeight;
|
|
55779
|
+
}
|
|
55520
55780
|
/**
|
|
55521
55781
|
* Get outputs (vouts) of a Bitcoin transaction
|
|
55522
55782
|
*
|
|
@@ -56154,10 +56414,13 @@ ${auth.clientId}`;
|
|
|
56154
56414
|
* only on unanimity. The confirmed-balance consensus the validators run
|
|
56155
56415
|
* covers `chain_stats` only, so without this the primary provider alone
|
|
56156
56416
|
* could fabricate an unconfirmed UTXO plus a self-consistent parent proof
|
|
56157
|
-
* and inflate the signed balance. Any
|
|
56158
|
-
*
|
|
56159
|
-
*
|
|
56160
|
-
*
|
|
56417
|
+
* and inflate the signed balance. Any verdict disagreement THROWS
|
|
56418
|
+
* (fail-closed) — exclusion on a suppressed proof would deflate the balance
|
|
56419
|
+
* and open a wrongful-liquidation window, so neither direction may proceed
|
|
56420
|
+
* without agreement. A provider that cannot state the chain tip — and only
|
|
56421
|
+
* that failure — is dropped from the quorum rather than aborting the read (it
|
|
56422
|
+
* never counts as agreeing), and falling below `minConsensusProviders`
|
|
56423
|
+
* survivors throws — see `verifyParentIsSelfSpendConsensus`.
|
|
56161
56424
|
*
|
|
56162
56425
|
* The same per-provider `/tx` fetch also returns the parent's outputs, and
|
|
56163
56426
|
* every provider must corroborate each claimed UTXO (index, vault address,
|
|
@@ -56252,10 +56515,26 @@ ${auth.clientId}`;
|
|
|
56252
56515
|
}
|
|
56253
56516
|
/**
|
|
56254
56517
|
* Run the self-spend proof against every configured provider and require
|
|
56255
|
-
* unanimity
|
|
56256
|
-
*
|
|
56518
|
+
* unanimity AMONG THE PROVIDERS THAT ANSWERED. Fail-closed on disagreement:
|
|
56519
|
+
* a verdict mismatch throws and aborts the balance calculation — see
|
|
56257
56520
|
* classifySelfChange for why exclusion is not a safe fallback here.
|
|
56258
56521
|
*
|
|
56522
|
+
* Quorum semantics (2026-09-23, plan C2). ONE failure class is tolerated: a
|
|
56523
|
+
* provider that could not state the chain tip (`BitcoinTipUnreadableError`).
|
|
56524
|
+
* It is ABSENT from the quorum — never counted as agreeing, never allowed to
|
|
56525
|
+
* decide the verdict — and the policy floor, not "at least one", decides when
|
|
56526
|
+
* that absence is fatal: below `minConsensusProviders` surviving readings
|
|
56527
|
+
* there is no cross-check left to trust, and the read fails loudly naming
|
|
56528
|
+
* every provider that dropped out.
|
|
56529
|
+
*
|
|
56530
|
+
* Why only that class. `getTransaction` now throws on an unreadable tip
|
|
56531
|
+
* instead of fabricating `confirmations: 1`; without this carve-out one flaky
|
|
56532
|
+
* `/blocks/tip/height` endpoint would take every balance and spend path down
|
|
56533
|
+
* with it. Every OTHER failure remains fatal, as before: a provider that
|
|
56534
|
+
* answers "I have never seen that transaction" is making a claim about the
|
|
56535
|
+
* chain rather than suffering an outage, and that shape is precisely the
|
|
56536
|
+
* fabricated-UTXO signature the fail-closed rule exists to catch.
|
|
56537
|
+
*
|
|
56259
56538
|
* When the parent IS a unanimous self-spend, every provider's view of the
|
|
56260
56539
|
* parent's OUTPUTS must additionally corroborate the primary's claimed
|
|
56261
56540
|
* UTXOs (index exists, pays the vault, exact value). Without this, a
|
|
@@ -56280,32 +56559,52 @@ ${auth.clientId}`;
|
|
|
56280
56559
|
)
|
|
56281
56560
|
)
|
|
56282
56561
|
);
|
|
56283
|
-
const
|
|
56284
|
-
|
|
56285
|
-
|
|
56286
|
-
|
|
56287
|
-
|
|
56562
|
+
const answered = [];
|
|
56563
|
+
const absences = [];
|
|
56564
|
+
const failures = [];
|
|
56565
|
+
settled.forEach((result, i) => {
|
|
56566
|
+
if (result.status === "fulfilled") {
|
|
56567
|
+
answered.push({ index: i, evaluation: result.value });
|
|
56568
|
+
return;
|
|
56569
|
+
}
|
|
56570
|
+
const described = `${providerName(i)} \u2192 ${result.reason?.message ?? String(result.reason)}`;
|
|
56571
|
+
if (isBitcoinTipUnreadableError(result.reason)) {
|
|
56572
|
+
absences.push(described);
|
|
56573
|
+
return;
|
|
56574
|
+
}
|
|
56575
|
+
failures.push(described);
|
|
56576
|
+
});
|
|
56288
56577
|
if (failures.length > 0) {
|
|
56289
56578
|
throw new Error(
|
|
56290
56579
|
`Self-change classification failed for tx ${parentTxid} on ${failures.length}/${providerConfigs.length} provider(s): ${failures.join("; ")}`
|
|
56291
56580
|
);
|
|
56292
56581
|
}
|
|
56293
|
-
const
|
|
56294
|
-
|
|
56295
|
-
|
|
56296
|
-
|
|
56297
|
-
|
|
56298
|
-
|
|
56582
|
+
const floor = Math.max(1, this.minConsensusProviders);
|
|
56583
|
+
if (answered.length < floor) {
|
|
56584
|
+
throw new Error(
|
|
56585
|
+
`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("; ")}`
|
|
56586
|
+
);
|
|
56587
|
+
}
|
|
56588
|
+
if (absences.length > 0) {
|
|
56589
|
+
litDebugLog(
|
|
56590
|
+
`[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("; ")}`
|
|
56591
|
+
);
|
|
56592
|
+
}
|
|
56593
|
+
const first = answered[0];
|
|
56594
|
+
const disagreements = answered.slice(1).filter((a) => a.evaluation.selfSpend !== first.evaluation.selfSpend).map(
|
|
56595
|
+
(a) => `${providerName(first.index)}=${first.evaluation.selfSpend} vs ${providerName(a.index)}=${a.evaluation.selfSpend}`
|
|
56299
56596
|
);
|
|
56300
56597
|
if (disagreements.length > 0) {
|
|
56301
56598
|
throw new Error(
|
|
56302
56599
|
`Self-change consensus mismatch for tx ${parentTxid}: ${disagreements.join("; ")}. A provider may be compromised or out of sync; refusing to sign.`
|
|
56303
56600
|
);
|
|
56304
56601
|
}
|
|
56305
|
-
if (!
|
|
56602
|
+
if (!first.evaluation.selfSpend) {
|
|
56306
56603
|
return false;
|
|
56307
56604
|
}
|
|
56308
|
-
const outputMismatches =
|
|
56605
|
+
const outputMismatches = answered.map(
|
|
56606
|
+
(a) => a.evaluation.outputMismatch ? `${providerName(a.index)} \u2192 ${a.evaluation.outputMismatch}` : null
|
|
56607
|
+
).filter((m) => m !== null);
|
|
56309
56608
|
if (outputMismatches.length > 0) {
|
|
56310
56609
|
throw new Error(
|
|
56311
56610
|
`Self-change output claim mismatch for tx ${parentTxid}: ${outputMismatches.join("; ")}. The reported UTXO set contradicts the parent transaction; refusing to sign.`
|
|
@@ -56548,16 +56847,6 @@ ${auth.clientId}`;
|
|
|
56548
56847
|
minConfirmations
|
|
56549
56848
|
);
|
|
56550
56849
|
const authorizedSpends = await this.getAuthorizedSpendsFromContract(positionId);
|
|
56551
|
-
for (const spend of authorizedSpends) {
|
|
56552
|
-
const utxoStillExists = utxoSet.utxos.some(
|
|
56553
|
-
(utxo) => utxo.txid === spend.txid && utxo.vout === spend.vout
|
|
56554
|
-
);
|
|
56555
|
-
if (utxoStillExists) {
|
|
56556
|
-
throw new Error(
|
|
56557
|
-
`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.`
|
|
56558
|
-
);
|
|
56559
|
-
}
|
|
56560
|
-
}
|
|
56561
56850
|
const authorizedBalance = authorizedSpends.reduce(
|
|
56562
56851
|
(sum, spend) => sum + spend.satoshis,
|
|
56563
56852
|
0n
|
|
@@ -56853,7 +57142,13 @@ ${auth.clientId}`;
|
|
|
56853
57142
|
allowDevSinglePriceProvider: false,
|
|
56854
57143
|
minBitcoinBalanceConfirmations: 1,
|
|
56855
57144
|
minBitcoinSpendConfirmations: 1,
|
|
56856
|
-
|
|
57145
|
+
// 2 since 2026-09-23. It was 1 because Sepolia ran a single faucet provider
|
|
57146
|
+
// "by design", so the consensus floor was documented as a mainnet-only
|
|
57147
|
+
// guarantee. The registry now holds two, and leaving the floor at 1 meant
|
|
57148
|
+
// Sepolia could never exercise the multi-provider agreement the stale-spend
|
|
57149
|
+
// and balance paths rely on — the one environment where that logic is
|
|
57150
|
+
// supposed to be proved before mainnet.
|
|
57151
|
+
minConsensusProviders: 2
|
|
56857
57152
|
},
|
|
56858
57153
|
[
|
|
56859
57154
|
"ethereum"
|
|
@@ -57162,7 +57457,6 @@ function getSepoliaConfig() {
|
|
|
57162
57457
|
feeRecipientRegistry: SEPOLIA_CONTRACTS.FeeRecipientRegistry || "",
|
|
57163
57458
|
positionDelegateRegistry: SEPOLIA_CONTRACTS.PositionDelegateRegistry || "",
|
|
57164
57459
|
bitcoinWithdrawalAddressRegistry: SEPOLIA_CONTRACTS.BitcoinWithdrawalAddressRegistry || "",
|
|
57165
|
-
carryAgentRegistry: SEPOLIA_CONTRACTS.CarryAgentRegistry || "",
|
|
57166
57460
|
agentDelegationRegistry: SEPOLIA_CONTRACTS.AgentDelegationRegistry || "",
|
|
57167
57461
|
dhAgentDelegate: SEPOLIA_CONTRACTS.DHAgentDelegate || "",
|
|
57168
57462
|
agentModuleFactory: SEPOLIA_CONTRACTS.AgentModuleFactory || ""
|
|
@@ -57216,7 +57510,6 @@ function getMainnetConfig() {
|
|
|
57216
57510
|
feeRecipientRegistry: MAINNET_CONTRACTS.FeeRecipientRegistry || "",
|
|
57217
57511
|
positionDelegateRegistry: MAINNET_CONTRACTS.PositionDelegateRegistry || "",
|
|
57218
57512
|
bitcoinWithdrawalAddressRegistry: MAINNET_CONTRACTS.BitcoinWithdrawalAddressRegistry || "",
|
|
57219
|
-
carryAgentRegistry: MAINNET_CONTRACTS.CarryAgentRegistry || "",
|
|
57220
57513
|
agentDelegationRegistry: MAINNET_CONTRACTS.AgentDelegationRegistry || "",
|
|
57221
57514
|
dhAgentDelegate: MAINNET_CONTRACTS.DHAgentDelegate || "",
|
|
57222
57515
|
// Empty on mainnet until the factory is deployed there — the ceremony is Sepolia-only.
|
|
@@ -58289,6 +58582,51 @@ async function resolveAuthorizationInput(provider, signer, ctx) {
|
|
|
58289
58582
|
}
|
|
58290
58583
|
return { timestamp: result.timestamp, signature: result.signature };
|
|
58291
58584
|
}
|
|
58585
|
+
var BECH32_CHARSET = "qpzry9x8gf2tvdw0s3jn54khce6mua7l";
|
|
58586
|
+
function segwitProgramShape(address) {
|
|
58587
|
+
const lower2 = address.trim().toLowerCase();
|
|
58588
|
+
if (!/^(bc1|tb1|bcrt1)/.test(lower2))
|
|
58589
|
+
return null;
|
|
58590
|
+
const sep = lower2.lastIndexOf("1");
|
|
58591
|
+
const data = lower2.slice(sep + 1);
|
|
58592
|
+
if (data.length < 8)
|
|
58593
|
+
return null;
|
|
58594
|
+
const version2 = BECH32_CHARSET.indexOf(data[0]);
|
|
58595
|
+
if (version2 < 0)
|
|
58596
|
+
return null;
|
|
58597
|
+
const programChars = data.length - 1 - 6;
|
|
58598
|
+
return { version: version2, programBytes: Math.floor(programChars * 5 / 8) };
|
|
58599
|
+
}
|
|
58600
|
+
function dustLimitForAddress(address) {
|
|
58601
|
+
const shape = segwitProgramShape(address);
|
|
58602
|
+
if (shape === null)
|
|
58603
|
+
return 546;
|
|
58604
|
+
if (shape.version === 0 && shape.programBytes === 20)
|
|
58605
|
+
return 294;
|
|
58606
|
+
if (shape.version === 0 && shape.programBytes === 32)
|
|
58607
|
+
return 330;
|
|
58608
|
+
if (shape.version === 1 && shape.programBytes === 32)
|
|
58609
|
+
return 330;
|
|
58610
|
+
return 546;
|
|
58611
|
+
}
|
|
58612
|
+
function destinationDustShortfall(targetAmount, networkFee, destination) {
|
|
58613
|
+
const limit = dustLimitForAddress(destination);
|
|
58614
|
+
return targetAmount - networkFee < limit ? limit : null;
|
|
58615
|
+
}
|
|
58616
|
+
function calculateMintFee(params) {
|
|
58617
|
+
const { mintAmount, mintTimestamp, originationFeeBps, previousExpiryAt, selectedTerm, totalTerm } = params;
|
|
58618
|
+
let mintFee = mintAmount * BigInt(originationFeeBps) / 10000n;
|
|
58619
|
+
if (previousExpiryAt > 0 && mintTimestamp < previousExpiryAt) {
|
|
58620
|
+
const tailSeconds = BigInt(previousExpiryAt) - BigInt(mintTimestamp);
|
|
58621
|
+
const originalTermMonths = totalTerm - selectedTerm;
|
|
58622
|
+
const originalTermSeconds = BigInt(
|
|
58623
|
+
originalTermMonths === 12 ? 365 * 86400 : originalTermMonths * 30 * 86400
|
|
58624
|
+
);
|
|
58625
|
+
const tailFee = tailSeconds * BigInt(originationFeeBps) * mintAmount / (10000n * originalTermSeconds);
|
|
58626
|
+
mintFee = mintFee + tailFee;
|
|
58627
|
+
}
|
|
58628
|
+
return mintFee;
|
|
58629
|
+
}
|
|
58292
58630
|
function baseMintFeeWei(mintAmountWei, originationFeeBps) {
|
|
58293
58631
|
if (mintAmountWei < 0n)
|
|
58294
58632
|
throw new Error("baseMintFeeWei: mintAmountWei cannot be negative");
|
|
@@ -58307,20 +58645,34 @@ function debtAfterMintExceedsLoanCap(params) {
|
|
|
58307
58645
|
}
|
|
58308
58646
|
return currentDebtWei + mintAmountWei + mintFeeWei > maxLoanWei;
|
|
58309
58647
|
}
|
|
58310
|
-
function
|
|
58311
|
-
|
|
58312
|
-
|
|
58313
|
-
throw new Error("maxPrincipalWithinLoanCap: amounts cannot be negative");
|
|
58648
|
+
function collateralRatioBps(sats, price8, debtWei) {
|
|
58649
|
+
if (sats < 0n || price8 < 0n) {
|
|
58650
|
+
throw new Error("collateralRatioBps: sats and price cannot be negative");
|
|
58314
58651
|
}
|
|
58315
|
-
if (
|
|
58316
|
-
throw new Error(
|
|
58317
|
-
`maxPrincipalWithinLoanCap: originationFeeBps must be an integer in [0, 10000] (got ${String(originationFeeBps)})`
|
|
58318
|
-
);
|
|
58652
|
+
if (debtWei <= 0n) {
|
|
58653
|
+
throw new Error("collateralRatioBps: debt must be positive");
|
|
58319
58654
|
}
|
|
58320
|
-
|
|
58321
|
-
|
|
58322
|
-
|
|
58323
|
-
|
|
58655
|
+
return sats * price8 * 100n * 10000n / debtWei;
|
|
58656
|
+
}
|
|
58657
|
+
function collateralRatioPercentString(sats, price8, debtWei) {
|
|
58658
|
+
const bps = collateralRatioBps(sats, price8, debtWei);
|
|
58659
|
+
return `${bps / 100n}.${(bps % 100n).toString().padStart(2, "0")}`;
|
|
58660
|
+
}
|
|
58661
|
+
function maxPrincipalForFee(room, fee) {
|
|
58662
|
+
if (room < 0n)
|
|
58663
|
+
throw new Error("maxPrincipalForFee: room cannot be negative");
|
|
58664
|
+
if (fee(0n) !== 0n)
|
|
58665
|
+
throw new Error("maxPrincipalForFee: fee(0) must be 0");
|
|
58666
|
+
let lo = 0n;
|
|
58667
|
+
let hi = room;
|
|
58668
|
+
while (lo < hi) {
|
|
58669
|
+
const mid = (lo + hi + 1n) / 2n;
|
|
58670
|
+
if (mid + fee(mid) <= room)
|
|
58671
|
+
lo = mid;
|
|
58672
|
+
else
|
|
58673
|
+
hi = mid - 1n;
|
|
58674
|
+
}
|
|
58675
|
+
return lo;
|
|
58324
58676
|
}
|
|
58325
58677
|
function buildLoginDomain(chainId) {
|
|
58326
58678
|
return {
|
|
@@ -70483,9 +70835,17 @@ async function mintAgentPkp(params) {
|
|
|
70483
70835
|
}
|
|
70484
70836
|
var AGENT_STATUS = { None: 0, Active: 1, Revoked: 2 };
|
|
70485
70837
|
function planAgentBinding(params) {
|
|
70486
|
-
const { isActive, record, nowSeconds } = params;
|
|
70838
|
+
const { isActive, paused, record, nowSeconds } = params;
|
|
70839
|
+
if (typeof paused !== "boolean") {
|
|
70840
|
+
throw new Error("planAgentBinding: `paused` must be read from the registry (boolean required)");
|
|
70841
|
+
}
|
|
70487
70842
|
if (isActive)
|
|
70488
70843
|
return { kind: "reuse", agent: record.agent };
|
|
70844
|
+
if (paused) {
|
|
70845
|
+
throw new Error(
|
|
70846
|
+
"AgentDelegationRegistry is paused \u2014 agent delegation cannot be changed until it is unpaused."
|
|
70847
|
+
);
|
|
70848
|
+
}
|
|
70489
70849
|
const status = Number(record.status);
|
|
70490
70850
|
if (status === AGENT_STATUS.None || status === AGENT_STATUS.Revoked) {
|
|
70491
70851
|
return { kind: "register" };
|
|
@@ -70495,7 +70855,7 @@ function planAgentBinding(params) {
|
|
|
70495
70855
|
}
|
|
70496
70856
|
if (Number(record.validUntil) > nowSeconds) {
|
|
70497
70857
|
throw new Error(
|
|
70498
|
-
"AgentDelegationRegistry
|
|
70858
|
+
"AgentDelegationRegistry returned an inconsistent read (an unexpired, unpaused Active agent reported inactive); retry."
|
|
70499
70859
|
);
|
|
70500
70860
|
}
|
|
70501
70861
|
return { kind: "rotate" };
|
|
@@ -71664,7 +72024,7 @@ function normalizeBigNumberish(value) {
|
|
|
71664
72024
|
}
|
|
71665
72025
|
return value;
|
|
71666
72026
|
}
|
|
71667
|
-
if (typeof value === "object" && value !== null && "toString" in value && typeof value.toString === "function") {
|
|
72027
|
+
if (typeof value === "object" && value !== null && "toString" in value && typeof value.toString === "function" && value.toString !== Object.prototype.toString) {
|
|
71668
72028
|
const result = value.toString();
|
|
71669
72029
|
if (typeof result === "object" && result !== null && "_hex" in result) {
|
|
71670
72030
|
const resultObj = result;
|
|
@@ -73086,12 +73446,21 @@ var DiamondHandsSDK = class _DiamondHandsSDK {
|
|
|
73086
73446
|
maxLoanWei: maxLoanValueWei
|
|
73087
73447
|
})) {
|
|
73088
73448
|
const debtAfterWei = currentDebtWei + requestAmountWei + baseFeeWei;
|
|
73449
|
+
const suggestionStamp = calculateNextQuantumTimestamp();
|
|
73450
|
+
const room = maxLoanValueWei > currentDebtWei ? maxLoanValueWei - currentDebtWei : 0n;
|
|
73089
73451
|
const maxPrincipalUcd = Number(
|
|
73090
|
-
|
|
73091
|
-
|
|
73092
|
-
|
|
73093
|
-
|
|
73094
|
-
|
|
73452
|
+
maxPrincipalForFee(
|
|
73453
|
+
room,
|
|
73454
|
+
(principal) => calculateMintFee({
|
|
73455
|
+
mintAmount: principal,
|
|
73456
|
+
mintTimestamp: suggestionStamp,
|
|
73457
|
+
originationFeeBps: positionTerm.originationFeeBps,
|
|
73458
|
+
expiryAt: Number(position2.expiryAt),
|
|
73459
|
+
previousExpiryAt: Number(position2.previousExpiryAt),
|
|
73460
|
+
selectedTerm: Number(position2.selectedTerm),
|
|
73461
|
+
totalTerm: Number(position2.totalTerm)
|
|
73462
|
+
})
|
|
73463
|
+
) / BigInt(10 ** 18)
|
|
73095
73464
|
);
|
|
73096
73465
|
return {
|
|
73097
73466
|
success: false,
|
|
@@ -74169,11 +74538,7 @@ Message: ${causeMessage}${quantumContext}${loanCapDiagnostics}${mintDebtDiagnost
|
|
|
74169
74538
|
const debt = positionDetails.debt || positionDetails.ucdDebt || "0";
|
|
74170
74539
|
const btcPrice2 = litActionResult.btcPrice || "0";
|
|
74171
74540
|
const btcVaultBalance = litActionResult.btcAmountSats || positionDetails.btcVaultBalance || "0";
|
|
74172
|
-
const
|
|
74173
|
-
const btcAmount = Number(btcVaultBalance) / 1e8;
|
|
74174
|
-
const btcValueUSD = btcAmount * usdPricePerBTC;
|
|
74175
|
-
const debtUSD = Number(debt) / 1e18;
|
|
74176
|
-
const ratio = debtUSD > 0 ? (btcValueUSD / debtUSD * 100).toFixed(2) : "0.00";
|
|
74541
|
+
const ratio = BigInt(debt) > 0n ? collateralRatioPercentString(BigInt(btcVaultBalance), BigInt(btcPrice2), BigInt(debt)) : "0.00";
|
|
74177
74542
|
const message = formatLiquidationSkippedMessage(
|
|
74178
74543
|
request.positionId,
|
|
74179
74544
|
ratio,
|
|
@@ -74662,14 +75027,15 @@ Message: ${causeMessage}${quantumContext}${loanCapDiagnostics}${mintDebtDiagnost
|
|
|
74662
75027
|
}
|
|
74663
75028
|
const debt = positionDetails.debt || positionDetails.ucdDebt || "0";
|
|
74664
75029
|
const btcPrice2 = litActionResult.btcPrice || "0";
|
|
74665
|
-
const
|
|
75030
|
+
const btcVaultBalance = litActionResult.btcAmountSats || positionDetails.btcVaultBalance || "0";
|
|
75031
|
+
const ratio = BigInt(debt) > 0n ? collateralRatioPercentString(BigInt(btcVaultBalance), BigInt(btcPrice2), BigInt(debt)) : "0.00";
|
|
74666
75032
|
const message = formatLiquidationSuccessMessage(
|
|
74667
75033
|
request.positionId,
|
|
74668
75034
|
ratio,
|
|
74669
75035
|
`${liquidationThreshold / 100}`,
|
|
74670
75036
|
// Convert to percentage
|
|
74671
75037
|
positionDetails.btcVault || "unknown",
|
|
74672
|
-
|
|
75038
|
+
btcVaultBalance,
|
|
74673
75039
|
debt,
|
|
74674
75040
|
btcPrice2
|
|
74675
75041
|
);
|
|
@@ -77153,6 +77519,17 @@ Message: ${causeMessage}${quantumContext}${loanCapDiagnostics}${mintDebtDiagnost
|
|
|
77153
77519
|
error: `networkFee=${request.networkFee} is \u2265 50% of targetAmount=${request.targetAmount}. Refusing to broadcast \u2014 real Bitcoin fees are typically <1% of value.`
|
|
77154
77520
|
};
|
|
77155
77521
|
}
|
|
77522
|
+
const destinationDustLimit = destinationDustShortfall(
|
|
77523
|
+
request.targetAmount,
|
|
77524
|
+
request.networkFee,
|
|
77525
|
+
request.destination
|
|
77526
|
+
);
|
|
77527
|
+
if (destinationDustLimit !== null) {
|
|
77528
|
+
return {
|
|
77529
|
+
success: false,
|
|
77530
|
+
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.`
|
|
77531
|
+
};
|
|
77532
|
+
}
|
|
77156
77533
|
const [txid, voutStr] = request.utxoIdentifier.split(":");
|
|
77157
77534
|
const vout = parseInt(voutStr || "0", 10);
|
|
77158
77535
|
if (!txid || isNaN(vout)) {
|
|
@@ -78628,8 +79005,9 @@ Message: ${causeMessage}${quantumContext}${loanCapDiagnostics}${mintDebtDiagnost
|
|
|
78628
79005
|
const user = await signer.getAddress();
|
|
78629
79006
|
const registry = AgentDelegationRegistry__factory.connect(addr, signer);
|
|
78630
79007
|
let agentAddress;
|
|
78631
|
-
const [isActive, record, latestBlock] = await Promise.all([
|
|
79008
|
+
const [isActive, paused, record, latestBlock] = await Promise.all([
|
|
78632
79009
|
registry.isAgentActive(user),
|
|
79010
|
+
registry.paused(),
|
|
78633
79011
|
registry.agentOf(user),
|
|
78634
79012
|
this.getProviderOrThrow().getBlock("latest")
|
|
78635
79013
|
]);
|
|
@@ -78641,7 +79019,7 @@ Message: ${causeMessage}${quantumContext}${loanCapDiagnostics}${mintDebtDiagnost
|
|
|
78641
79019
|
/* HIGH */
|
|
78642
79020
|
});
|
|
78643
79021
|
}
|
|
78644
|
-
const plan = planAgentBinding({ isActive, record, nowSeconds: latestBlock.timestamp });
|
|
79022
|
+
const plan = planAgentBinding({ isActive, paused, record, nowSeconds: latestBlock.timestamp });
|
|
78645
79023
|
if (plan.kind === "reuse") {
|
|
78646
79024
|
agentAddress = plan.agent;
|
|
78647
79025
|
} else {
|
|
@@ -82106,11 +82484,16 @@ var RealUpstreamPlugin = class {
|
|
|
82106
82484
|
this.src("subgraph")
|
|
82107
82485
|
);
|
|
82108
82486
|
},
|
|
82109
|
-
getPositionEvents: async () =>
|
|
82110
|
-
|
|
82111
|
-
|
|
82112
|
-
|
|
82113
|
-
|
|
82487
|
+
getPositionEvents: async () => (
|
|
82488
|
+
// PERMANENT capability gap, not a transient outage: the real adapter has no indexer
|
|
82489
|
+
// projection for event history, and this build never will. `unsupported` →
|
|
82490
|
+
// NOT_IMPLEMENTED so the guide does not tell the model to retry it (C-44).
|
|
82491
|
+
upFail({
|
|
82492
|
+
kind: "unsupported",
|
|
82493
|
+
source: "subgraph",
|
|
82494
|
+
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"
|
|
82495
|
+
})
|
|
82496
|
+
)
|
|
82114
82497
|
};
|
|
82115
82498
|
this.chain = {
|
|
82116
82499
|
getPositionDetails: (id) => this.chainRead(() => this.readPositionDetails(id)),
|
|
@@ -83553,6 +83936,8 @@ var SignatureBridge = class {
|
|
|
83553
83936
|
wcTransport = null;
|
|
83554
83937
|
/** True while a WalletConnect session is THE wallet — ceremonies route over WC. */
|
|
83555
83938
|
wcActive = false;
|
|
83939
|
+
/** Page session that most recently asked for a pairing QR — see `serveWcPairing`. */
|
|
83940
|
+
pairingSessionId = null;
|
|
83556
83941
|
keystoreUnlock;
|
|
83557
83942
|
unlockToken = null;
|
|
83558
83943
|
unlockSession = null;
|
|
@@ -83683,7 +84068,8 @@ var SignatureBridge = class {
|
|
|
83683
84068
|
...handlers?.finalize ? { finalize: handlers.finalize } : {},
|
|
83684
84069
|
owner: this.wcActive ? "wc" : "page",
|
|
83685
84070
|
dispatched: false,
|
|
83686
|
-
lastAttachedMs: now
|
|
84071
|
+
lastAttachedMs: now,
|
|
84072
|
+
finalizedBy: null
|
|
83687
84073
|
};
|
|
83688
84074
|
this.pending.set(request.id, entry);
|
|
83689
84075
|
if (entry.owner === "wc") {
|
|
@@ -83716,7 +84102,8 @@ var SignatureBridge = class {
|
|
|
83716
84102
|
// ceremony could not reach quorum through the very pages it is broadcast to.
|
|
83717
84103
|
owner: "both",
|
|
83718
84104
|
dispatched: false,
|
|
83719
|
-
lastAttachedMs: now
|
|
84105
|
+
lastAttachedMs: now,
|
|
84106
|
+
finalizedBy: null
|
|
83720
84107
|
};
|
|
83721
84108
|
this.pending.set(request.id, entry);
|
|
83722
84109
|
this.pushEntry(entry);
|
|
@@ -83814,7 +84201,7 @@ var SignatureBridge = class {
|
|
|
83814
84201
|
* receives nothing cannot show anything. Distinct from `attachedNow()`, which counts
|
|
83815
84202
|
* WalletConnect and must stay global for the connector's eviction predicate. */
|
|
83816
84203
|
pageAttached() {
|
|
83817
|
-
for (const s of this.sessions.values()) if (
|
|
84204
|
+
for (const s of this.sessions.values()) if (s.sse && this.authorized(s)) return true;
|
|
83818
84205
|
return false;
|
|
83819
84206
|
}
|
|
83820
84207
|
/** Attachment for ONE entry — the wallet that entry is actually waiting on. The global
|
|
@@ -83831,6 +84218,7 @@ var SignatureBridge = class {
|
|
|
83831
84218
|
* the deadline is checked first so expiry semantics stay pinned (T-EXT-03). */
|
|
83832
84219
|
sweep() {
|
|
83833
84220
|
const now = this.clock();
|
|
84221
|
+
this.evictDeadSessions();
|
|
83834
84222
|
for (const entry of this.pending.values()) {
|
|
83835
84223
|
if (entry.settled) continue;
|
|
83836
84224
|
if (now >= entry.deadlineMs) {
|
|
@@ -83943,12 +84331,13 @@ var SignatureBridge = class {
|
|
|
83943
84331
|
this.deny(res, 403, "this approval link has expired \u2014 ask for a fresh one (signer_setup status) and reopen");
|
|
83944
84332
|
return;
|
|
83945
84333
|
}
|
|
84334
|
+
this.makeRoomForSession();
|
|
83946
84335
|
if (this.sessions.size >= MAX_SESSIONS) {
|
|
83947
84336
|
this.deny(res, 429, `too many open approval pages (${MAX_SESSIONS}) \u2014 close one and retry`);
|
|
83948
84337
|
return;
|
|
83949
84338
|
}
|
|
83950
84339
|
const sessionId = (0, import_node_crypto7.randomBytes)(24).toString("hex");
|
|
83951
|
-
this.sessions.set(sessionId, { wallet: null, sse: null, refused: null });
|
|
84340
|
+
this.sessions.set(sessionId, { wallet: null, sse: null, refused: null, lastSeenMs: this.clock(), wcPaired: false });
|
|
83952
84341
|
const page = htmlPageSecurityHeaders();
|
|
83953
84342
|
res.writeHead(200, { "Content-Type": "text/html; charset=utf-8", "Cache-Control": "no-store", ...page.headers });
|
|
83954
84343
|
res.end(renderApprovalPage(sessionId, page.nonce));
|
|
@@ -83963,6 +84352,7 @@ var SignatureBridge = class {
|
|
|
83963
84352
|
* fresh pairing URI. A wallet approving the pairing becomes THE wallet. */
|
|
83964
84353
|
async serveWcPairing(url2, res) {
|
|
83965
84354
|
if (!this.checkSession(url2.searchParams.get("s"), res)) return;
|
|
84355
|
+
this.pairingSessionId = url2.searchParams.get("s");
|
|
83966
84356
|
if (!this.wcConfig) {
|
|
83967
84357
|
this.deny(res, 404, "WalletConnect is not configured (set DH_WC_PROJECT_ID)");
|
|
83968
84358
|
return;
|
|
@@ -83986,6 +84376,10 @@ var SignatureBridge = class {
|
|
|
83986
84376
|
}
|
|
83987
84377
|
this.wcActive = info !== null;
|
|
83988
84378
|
this.wallet = info ? { account: info.account, chainId: info.chainId } : null;
|
|
84379
|
+
if (info && this.pairingSessionId) {
|
|
84380
|
+
const paired = this.sessions.get(this.pairingSessionId);
|
|
84381
|
+
if (paired) paired.wcPaired = true;
|
|
84382
|
+
}
|
|
83989
84383
|
if (info === null) {
|
|
83990
84384
|
for (const entry of this.pending.values()) {
|
|
83991
84385
|
if (!entry.settled && !entry.collect) {
|
|
@@ -84063,9 +84457,7 @@ var SignatureBridge = class {
|
|
|
84063
84457
|
res.write(":connected\n\n");
|
|
84064
84458
|
session.sse?.end();
|
|
84065
84459
|
session.sse = res;
|
|
84066
|
-
|
|
84067
|
-
if (!entry.settled) res.write(this.wireFor(entry));
|
|
84068
|
-
}
|
|
84460
|
+
this.replayPending(session);
|
|
84069
84461
|
const keepAlive = setInterval(() => res.write(":ka\n\n"), 2e4);
|
|
84070
84462
|
keepAlive.unref();
|
|
84071
84463
|
res.on("close", () => {
|
|
@@ -84090,6 +84482,7 @@ var SignatureBridge = class {
|
|
|
84090
84482
|
}
|
|
84091
84483
|
session.wallet = { account, chainId };
|
|
84092
84484
|
this.wallet = { account, chainId };
|
|
84485
|
+
this.replayPending(session);
|
|
84093
84486
|
this.ok(res);
|
|
84094
84487
|
}
|
|
84095
84488
|
/** C-47: the single predicate every wallet account is admitted through. There are THREE
|
|
@@ -84173,7 +84566,9 @@ var SignatureBridge = class {
|
|
|
84173
84566
|
/** Click-time re-stamp (A0.9): returns the FRESH personal-sign payload for a pending
|
|
84174
84567
|
* request. Idempotent for requests without a finalize handler (payload as enqueued). */
|
|
84175
84568
|
async onFinalize(body, res) {
|
|
84176
|
-
|
|
84569
|
+
const sessionId = String(body["sessionId"] ?? "");
|
|
84570
|
+
const session = this.decidingSessionOf(body["sessionId"], res);
|
|
84571
|
+
if (!session) return;
|
|
84177
84572
|
const entry = this.pending.get(String(body["requestId"] ?? ""));
|
|
84178
84573
|
if (!entry || entry.settled) {
|
|
84179
84574
|
this.deny(res, 404, "unknown or already-settled requestId");
|
|
@@ -84187,6 +84582,12 @@ var SignatureBridge = class {
|
|
|
84187
84582
|
this.deny(res, 409, "a mobile wallet is holding this approval \u2014 it is read-only here; approve or decline it in the wallet");
|
|
84188
84583
|
return;
|
|
84189
84584
|
}
|
|
84585
|
+
const holder = entry.finalizedBy ? this.sessions.get(entry.finalizedBy) : void 0;
|
|
84586
|
+
if (entry.finalizedBy && entry.finalizedBy !== sessionId && holder?.sse) {
|
|
84587
|
+
this.deny(res, 409, "another approval page is signing this request \u2014 approve it there, or close that page and retry");
|
|
84588
|
+
return;
|
|
84589
|
+
}
|
|
84590
|
+
entry.finalizedBy = sessionId;
|
|
84190
84591
|
if (entry.finalize) {
|
|
84191
84592
|
let fresh;
|
|
84192
84593
|
try {
|
|
@@ -84206,7 +84607,7 @@ var SignatureBridge = class {
|
|
|
84206
84607
|
res.end(JSON.stringify({ request: entry.request }));
|
|
84207
84608
|
}
|
|
84208
84609
|
onResult(body, res) {
|
|
84209
|
-
if (!this.
|
|
84610
|
+
if (!this.decidingSessionOf(body["sessionId"], res)) return;
|
|
84210
84611
|
const entry = this.pending.get(String(body["requestId"] ?? ""));
|
|
84211
84612
|
if (!entry || entry.settled) {
|
|
84212
84613
|
this.deny(res, 404, "unknown or already-settled requestId");
|
|
@@ -84279,7 +84680,7 @@ var SignatureBridge = class {
|
|
|
84279
84680
|
/** Broadcast a pending entry to EVERY open page (multi-owner links — plan 06 §1.5). */
|
|
84280
84681
|
pushEntry(entry) {
|
|
84281
84682
|
const data = this.wireFor(entry);
|
|
84282
|
-
for (const s of this.sessions.values()) if (
|
|
84683
|
+
for (const s of this.sessions.values()) if (this.authorized(s)) s.sse?.write(data);
|
|
84283
84684
|
}
|
|
84284
84685
|
/** Progress goes out as a NAMED event so `es.onmessage` request handling never sees it. */
|
|
84285
84686
|
pushProgress(payload) {
|
|
@@ -84287,7 +84688,51 @@ var SignatureBridge = class {
|
|
|
84287
84688
|
data: ${JSON.stringify(payload)}
|
|
84288
84689
|
|
|
84289
84690
|
`;
|
|
84290
|
-
for (const s of this.sessions.values()) if (
|
|
84691
|
+
for (const s of this.sessions.values()) if (this.authorized(s)) s.sse?.write(data);
|
|
84692
|
+
}
|
|
84693
|
+
/** Replay every undecided card to ONE session — used when a session becomes authorized
|
|
84694
|
+
* (hello) after its stream was already open, which is the ordinary page order: the page
|
|
84695
|
+
* attaches its EventSource, then the wallet prompt resolves. Without this the newly
|
|
84696
|
+
* connected page would sit blank until the next push. */
|
|
84697
|
+
replayPending(session) {
|
|
84698
|
+
if (!session.sse || !this.authorized(session)) return;
|
|
84699
|
+
for (const entry of this.pending.values()) {
|
|
84700
|
+
if (!entry.settled) session.sse.write(this.wireFor(entry));
|
|
84701
|
+
}
|
|
84702
|
+
}
|
|
84703
|
+
/** Retire quarantined sessions that hold no stream. Always safe: a refused session is
|
|
84704
|
+
* denied on every route anyway, so keeping it costs a slot and buys nothing. */
|
|
84705
|
+
evictDeadSessions() {
|
|
84706
|
+
for (const [id, s] of this.sessions) if (s.refused && !s.sse) this.sessions.delete(id);
|
|
84707
|
+
}
|
|
84708
|
+
/**
|
|
84709
|
+
* Free a slot for an incoming page load when the ceiling is reached.
|
|
84710
|
+
*
|
|
84711
|
+
* MAX_SESSIONS was a ceiling with NO eviction — nothing but `close()` ever removed a
|
|
84712
|
+
* session — and every page load mints one (a reload is a new session). A long-lived
|
|
84713
|
+
* hosted bridge therefore reached 16 through ordinary use and 429'd the user out of
|
|
84714
|
+
* approving their own ceremonies, permanently, with "close one and retry" as the advice
|
|
84715
|
+
* for pages that were already closed.
|
|
84716
|
+
*
|
|
84717
|
+
* Eviction is ON DEMAND and never touches a session with a live SSE stream: that stream
|
|
84718
|
+
* is a page open in a browser right now, and the C1 contract is that live sessions
|
|
84719
|
+
* survive. Among the streamless it takes the least recently seen — the closed tab.
|
|
84720
|
+
*/
|
|
84721
|
+
makeRoomForSession() {
|
|
84722
|
+
this.evictDeadSessions();
|
|
84723
|
+
while (this.sessions.size >= MAX_SESSIONS) {
|
|
84724
|
+
let oldestId = null;
|
|
84725
|
+
let oldestSeen = Infinity;
|
|
84726
|
+
for (const [id, s] of this.sessions) {
|
|
84727
|
+
if (s.sse) continue;
|
|
84728
|
+
if (s.lastSeenMs < oldestSeen) {
|
|
84729
|
+
oldestSeen = s.lastSeenMs;
|
|
84730
|
+
oldestId = id;
|
|
84731
|
+
}
|
|
84732
|
+
}
|
|
84733
|
+
if (oldestId === null) return;
|
|
84734
|
+
this.sessions.delete(oldestId);
|
|
84735
|
+
}
|
|
84291
84736
|
}
|
|
84292
84737
|
/**
|
|
84293
84738
|
* C-47: `this.wallet` is DERIVED, never guessed.
|
|
@@ -84330,12 +84775,46 @@ data: ${JSON.stringify(payload)}
|
|
|
84330
84775
|
}
|
|
84331
84776
|
this.rebuildSharedWallet();
|
|
84332
84777
|
}
|
|
84778
|
+
/**
|
|
84779
|
+
* A session that may SEE cards and DECIDE them — one where a PERSON has proven to be at
|
|
84780
|
+
* the page: `hello` with an admissible account, or a WalletConnect pairing a wallet
|
|
84781
|
+
* actually answered (`wcPaired`).
|
|
84782
|
+
*
|
|
84783
|
+
* `sessionOf` only ever asked "does this session id exist and is it un-quarantined". A
|
|
84784
|
+
* session id is minted by LOADING the page, and on the hosted tier the mount URL travels
|
|
84785
|
+
* through the conversation by design — so anyone holding it could mint a session, never
|
|
84786
|
+
* connect a wallet, and still receive every approval card on /events (the card is the
|
|
84787
|
+
* operation in readable form: position, destination, amounts) and still POST /result to
|
|
84788
|
+
* decline, or /finalize to re-stamp, someone else's ceremony. Quarantine never caught
|
|
84789
|
+
* them: it fires on an OFFERED account, and they offered none.
|
|
84790
|
+
*
|
|
84791
|
+
* Opening the stream without a wallet stays legal — that is how the real page bootstraps
|
|
84792
|
+
* before the user connects. It simply receives nothing and decides nothing until it has
|
|
84793
|
+
* connected. Requesting a pairing is likewise not enough: anyone with the link can ask
|
|
84794
|
+
* for a QR, so only a pairing a WALLET ANSWERED counts.
|
|
84795
|
+
*/
|
|
84796
|
+
authorized(session) {
|
|
84797
|
+
if (session.refused) return false;
|
|
84798
|
+
if (session.wallet) return this.accountRefusal(session.wallet.account) === null;
|
|
84799
|
+
return session.wcPaired;
|
|
84800
|
+
}
|
|
84801
|
+
/** `sessionOf`, plus the wallet binding above — for the routes that decide a ceremony. */
|
|
84802
|
+
decidingSessionOf(candidate, res) {
|
|
84803
|
+
const session = this.sessionOf(candidate, res);
|
|
84804
|
+
if (!session) return null;
|
|
84805
|
+
if (!this.authorized(session)) {
|
|
84806
|
+
this.deny(res, 403, "connect your wallet on this page before approving, declining or finalizing a request");
|
|
84807
|
+
return null;
|
|
84808
|
+
}
|
|
84809
|
+
return session;
|
|
84810
|
+
}
|
|
84333
84811
|
sessionOf(candidate, res) {
|
|
84334
84812
|
const session = typeof candidate === "string" ? this.sessions.get(candidate) ?? null : null;
|
|
84335
84813
|
if (!session) {
|
|
84336
84814
|
this.deny(res, 403, "missing or wrong session");
|
|
84337
84815
|
return null;
|
|
84338
84816
|
}
|
|
84817
|
+
session.lastSeenMs = this.clock();
|
|
84339
84818
|
if (session.refused) {
|
|
84340
84819
|
this.deny(res, 403, session.refused);
|
|
84341
84820
|
return null;
|
|
@@ -85028,8 +85507,13 @@ function authorizationModeBullets(d) {
|
|
|
85028
85507
|
that one \u2014 say it before the popup. Walkthrough: \`guide connect-wallet\`.`);
|
|
85029
85508
|
}
|
|
85030
85509
|
if (offers(d, "keystore")) {
|
|
85031
|
-
bullets.push(` - \`keystore\` \u2014 a local encrypted keystore signs
|
|
85032
|
-
Real adapter and mock
|
|
85510
|
+
bullets.push(` - \`keystore\` \u2014 a local encrypted keystore signs AUTOMATICALLY, with no per-operation
|
|
85511
|
+
human prompt. Real adapter and mock. Say this plainly when the user picks it: the
|
|
85512
|
+
password is asked ONCE, at unlock; after that the key signs every write this session
|
|
85513
|
+
without a popup, an approval page or any second human step. The \`confirmed: true\` gate
|
|
85514
|
+
is the ASSISTANT's \u2014 it is not the user seeing and approving the operation \u2014 so in this
|
|
85515
|
+
mode you must show the operation and get a real answer before you set it. A user who
|
|
85516
|
+
wants to inspect each operation as it signs wants \`external\`.`);
|
|
85033
85517
|
}
|
|
85034
85518
|
if (offers(d, "safe") || offers(d, "safe-module")) {
|
|
85035
85519
|
bullets.push(` - \`safe\` / \`safe-module\` \u2014 PRACTICE-ONLY today: on the real adapter these modes
|
|
@@ -85040,6 +85524,9 @@ function authorizationModeBullets(d) {
|
|
|
85040
85524
|
}
|
|
85041
85525
|
return bullets.join("\n");
|
|
85042
85526
|
}
|
|
85527
|
+
function readsNeedSignIn(d) {
|
|
85528
|
+
return offers(d, "keystore") ? "On the real adapter a read is NOT a free pass: `position_list {borrower}`, `protocol_status` and `protocol_terms` need a signing identity \u2014 the keystore (the env pair or `unlock-keystore`) or a wallet `connect` \u2014 and refuse on a fresh session until one is connected. Only the practice (mock) world reads without one; there is no signer-less public read on the real adapter." : "On this hosted connector a read is NOT a free pass: even `position_list {borrower}`, `protocol_status` and `protocol_terms` run only AFTER the wallet sign-in that connecting performs (`signer_setup` action `connect`) \u2014 a fresh session refuses them until then. There is no separate keystore step and no signer-less public read here.";
|
|
85529
|
+
}
|
|
85043
85530
|
function keystoreAbsenceParagraph(d) {
|
|
85044
85531
|
if (offers(d, "keystore")) return "";
|
|
85045
85532
|
return `
|
|
@@ -85083,9 +85570,11 @@ install matrix. ${connectorInstallNote(d)}
|
|
|
85083
85570
|
|
|
85084
85571
|
Nothing needs a config file. Three steps:
|
|
85085
85572
|
|
|
85086
|
-
**1. Know your world.** Read \`boundary://info\` (its \`capabilities\` block)
|
|
85087
|
-
|
|
85088
|
-
signer modes exist
|
|
85573
|
+
**1. Know your world.** Read \`boundary://info\` (its \`capabilities\` block) \u2014 that
|
|
85574
|
+
resource always answers, with no sign-in \u2014 and tell the user what THIS deployment is:
|
|
85575
|
+
${worldAxes(d)}; which signer modes exist. ${readsNeedSignIn(d)} So the live reads
|
|
85576
|
+
(\`protocol_status\`, current terms via \`protocol_terms\`) come right after step 2, not
|
|
85577
|
+
before it.
|
|
85089
85578
|
|
|
85090
85579
|
**2. Choose HOW to authorize operations** (the user's choice, made by talking):
|
|
85091
85580
|
- **"Use my own wallet"** \u2192 call \`signer_setup\` action \`use\`, mode \`external\` \u2014 works
|
|
@@ -85105,8 +85594,9 @@ ${offers(d, "safe") || offers(d, "safe-module") ? `- **Safe / delegation modes (
|
|
|
85105
85594
|
surface is the wallet ceremony and nothing else; \`signer_setup\` lists no other mode.
|
|
85106
85595
|
\`guide safe\` and \`guide delegation\` state what exists elsewhere.`}
|
|
85107
85596
|
- Not sure? \`signer_setup\` action \`status\` explains what is active and what is missing.
|
|
85108
|
-
- **
|
|
85109
|
-
\`position_list {borrower}\`
|
|
85597
|
+
- **A read is not a signer-less shortcut:** the sign-in in step 2 is what turns reads ON.
|
|
85598
|
+
Until then \`position_list {borrower}\`, \`protocol_status\` and \`protocol_terms\` refuse
|
|
85599
|
+
on the real adapter \u2014 do step 2 first, then reads work.
|
|
85110
85600
|
${d.networks.length > 1 ? `- **Wrong network?** On the real adapter the user can switch sepolia \u2194 mainnet by
|
|
85111
85601
|
talking (\`network_switch\`, human-confirmed) \u2014 see \`guide switch-network\`. State
|
|
85112
85602
|
the money reality after any switch.` : `- **Wrong network?** This deployment is rolled out to ${d.networks[0]} alone \u2014
|
|
@@ -85595,7 +86085,12 @@ ${wrongNetworkTroubleshootingRow(d)}
|
|
|
85595
86085
|
owed, wrong position state, or the USER DECLINED in the wallet. The message says which.
|
|
85596
86086
|
A decline is not an error to fix \u2014 it is the user's decision.
|
|
85597
86087
|
- **UPSTREAM_UNAVAILABLE** \u2014 a data source or the signature bridge is unreachable/expired.
|
|
85598
|
-
Usually transient; re-check with \`protocol_status\` and retry once.
|
|
86088
|
+
Usually transient; re-check with \`protocol_status\` and retry once. (A PERMANENT gap
|
|
86089
|
+
answers \`NOT_IMPLEMENTED\`, below \u2014 that one is not retryable.)
|
|
86090
|
+
- **NOT_IMPLEMENTED** \u2014 a capability this adapter does NOT implement in this build, and never
|
|
86091
|
+
will \u2014 PERMANENT, not a transient outage, so do NOT retry it. \`position_events\` on the
|
|
86092
|
+
real adapter is the case: there is no indexer projection for event history here. Say the
|
|
86093
|
+
history is unavailable on this deployment and move on; the practice (mock) world has it.
|
|
85599
86094
|
- **NOT_FOUND** \u2014 the position id doesn't exist in this world (check \`position_list\`).
|
|
85600
86095
|
- **STATE_DIVERGENCE / STALE_DATA warnings** \u2014 sources disagree or lag; the envelope says
|
|
85601
86096
|
which source and when from. Prefer chain-sourced values; re-read before acting.
|
|
@@ -85829,7 +86324,7 @@ function requireConfirmation(confirmed, actionLabel) {
|
|
|
85829
86324
|
type: "text",
|
|
85830
86325
|
text: `CONFIRMATION REQUIRED \u2014 refusing to run "${actionLabel}".
|
|
85831
86326
|
This is an irreversible, fund-moving action. A human must explicitly authorize it.
|
|
85832
|
-
|
|
86327
|
+
Show the user what this operation does \u2014 amounts, destination, and that it cannot be undone \u2014 and re-invoke with confirmed: true ONLY after they answer. Do not set confirmed on your own, and do not treat an earlier approval of a different operation as covering this one. If the signer is a keystore, no wallet prompt will follow: this is the only place a human is asked.`
|
|
85833
86328
|
}
|
|
85834
86329
|
],
|
|
85835
86330
|
isError: true
|
|
@@ -86266,7 +86761,7 @@ function registerPositionTools(server, getB) {
|
|
|
86266
86761
|
"position_events",
|
|
86267
86762
|
{
|
|
86268
86763
|
title: "Get a position's event history",
|
|
86269
|
-
description: "Return mint, payment, withdrawal, renewal, and liquidation events for a position (indexer view).",
|
|
86764
|
+
description: "Return mint, payment, withdrawal, renewal, and liquidation events for a position (indexer view). NOT IMPLEMENTED on the real protocol adapter in this build \u2014 it answers NOT_IMPLEMENTED there (a PERMANENT gap, not a transient outage: do not retry). Available on the practice (mock) adapter.",
|
|
86270
86765
|
inputSchema: {
|
|
86271
86766
|
id: positionIdSchema2
|
|
86272
86767
|
}
|
|
@@ -86812,7 +87307,7 @@ function registerGuidePrompts(server, deployment = LOCAL_GUIDE_DEPLOYMENT) {
|
|
|
86812
87307
|
role: "user",
|
|
86813
87308
|
content: {
|
|
86814
87309
|
type: "text",
|
|
86815
|
-
text: "I'm new to Diamond Hands. FIRST read boundary://info and its capabilities block \u2014 it is the truth about this session: the network, practice vs real money, whether writes are enabled (and the true reason when not), and which signer modes exist here. Never promise anything it does not list. Then read the guide topics 'getting-started' and 'first-setup' (guide tool), check protocol_status, and walk me through setup step by step IN MY LANGUAGE: tell me plainly whether this is practice or real money. BRANCH on capabilities: if no signer mode is available or writes are disabled,
|
|
87310
|
+
text: "I'm new to Diamond Hands. FIRST read boundary://info and its capabilities block \u2014 it is the truth about this session: the network, practice vs real money, whether writes are enabled (and the true reason when not), and which signer modes exist here. Never promise anything it does not list. Then read the guide topics 'getting-started' and 'first-setup' (guide tool), check protocol_status, and walk me through setup step by step IN MY LANGUAGE: tell me plainly whether this is practice or real money. BRANCH on capabilities: if no signer mode is available or writes are disabled, say the true reason \u2014 and note that on the real adapter even a read (position_list, protocol_status, protocol_terms) needs the wallet sign-in that connecting performs first; there is no signer-less read path, so guide me to sign in before expecting any read to return; " + onboardAuthorizationLine(deployment) + "Ask before every operation; never assume confirmation."
|
|
86816
87311
|
}
|
|
86817
87312
|
}
|
|
86818
87313
|
]
|
|
@@ -87000,7 +87495,7 @@ function registerProtocolResources(server, getB) {
|
|
|
87000
87495
|
"protocol://psm",
|
|
87001
87496
|
{
|
|
87002
87497
|
title: "PSM status (UCD \u2194 USDC exchange)",
|
|
87003
|
-
description: "Live SimplePSMV2 state as {data, warnings, source}. `data` carries network + chainId + psmAddress (the money surface names its chain) and `stablecoins`: EVERY coin this PSM supports, each with its own stablecoinKind (mock = practice token with a public self-serve mint; circle = real USDC), pause + redeemEnabled switches, live reserves, and per-direction fees (WITH their token), min/max (WITH their units \u2014 to-ucd caps in the stablecoin's smallest units, from-ucd caps in UCD wei) and per-block volume caps ('uncapped' when the on-chain cap is 0). This is where a caller learns the coin names that `psm_quote` and `psm_swap` require.",
|
|
87498
|
+
description: "Live SimplePSMV2 state as {data, warnings, source}. `data` carries network + chainId + psmAddress (the money surface names its chain) and `stablecoins`: EVERY coin this PSM supports, each with its own stablecoinKind (mock = practice token with a public self-serve mint; circle = canonical mainnet USDC, i.e. real Circle USDC; onchain = any OTHER real coin such as mainnet USDT \u2014 real and on-chain, but NOT Circle USDC), pause + redeemEnabled switches, live reserves, and per-direction fees (WITH their token), min/max (WITH their units \u2014 to-ucd caps in the stablecoin's smallest units, from-ucd caps in UCD wei) and per-block volume caps ('uncapped' when the on-chain cap is 0). This is where a caller learns the coin names that `psm_quote` and `psm_swap` require.",
|
|
87004
87499
|
mimeType: "application/json"
|
|
87005
87500
|
},
|
|
87006
87501
|
async (uri) => {
|
|
@@ -87062,7 +87557,7 @@ function registerBoundaryInfoResource(server, getB) {
|
|
|
87062
87557
|
}
|
|
87063
87558
|
|
|
87064
87559
|
// src/version.ts
|
|
87065
|
-
var SERVER_VERSION = "0.5.
|
|
87560
|
+
var SERVER_VERSION = "0.5.20";
|
|
87066
87561
|
|
|
87067
87562
|
// src/server.ts
|
|
87068
87563
|
var SERVER_INSTRUCTIONS = "Diamond Hands MCP \u2014 Bitcoin-collateralized borrowing. Before promising ANY flow, read the boundary://info resource and honor its `capabilities` block: it states which network this server is on, whether money is real (practiceWorld), whether writes are enabled (and the true reason when they are not), and which signer modes this build actually offers \u2014 never describe a flow outside it. State the network and whether funds are real when the user first acts. Authorization is chosen by conversation via the signer_setup tool (when listed); writes always require confirmed:true after showing the human-readable card. For walkthroughs consult the guide tool / guide:// resources instead of inventing steps; when a tool refuses, relay its stated reason and remedy \u2014 do not improvise alternatives. When a network_switch tool is listed, the network can change mid-session \u2014 after ANY switch, re-read boundary://info and state the new network and money reality to the user before doing anything else. When the user asks to disconnect / log out / sign out / forget or remove their wallet, call signer_setup action 'disconnect' (the full flush) \u2014 never treat 'reset-borrower' as a disconnect; it only swaps identity. READING DATA: a payload's fields and notes are authoritative \u2014 state what they say, never speculate past them, and when the data does not carry something, say 'the data does not carry X'. Field meanings live in guide topic 'reading-data'; `reading` notes inside a result are interpretation instructions for that exact payload \u2014 follow them over any prior assumption.";
|