@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/connector.js
CHANGED
|
@@ -14571,113 +14571,113 @@ var require_pkg_src = __commonJS({
|
|
|
14571
14571
|
deployedAt: 1784569687492,
|
|
14572
14572
|
size: 4140,
|
|
14573
14573
|
hash: "4c0d65bf1f33cdac22a78fd8c4764319cc3fe00650e0fe7fa8a6090d9a318a7b",
|
|
14574
|
-
validatorWalletAddress: "
|
|
14574
|
+
validatorWalletAddress: "0xefb258d455a31d061bbeb3de3d2143bdfcb67a6c",
|
|
14575
14575
|
pkp: {
|
|
14576
14576
|
publicKey: "0x04ec0e3acc40884e3f366ca469d08899eb640ad5259fa196b0238075086208a9f8732a3175704f35f0bcc28e07406cfb24c254efd1e7355640577330f0d2dd755f",
|
|
14577
|
-
ethAddress: "
|
|
14577
|
+
ethAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C"
|
|
14578
14578
|
}
|
|
14579
14579
|
},
|
|
14580
14580
|
btcTransactionSigner: {
|
|
14581
|
-
cid: "
|
|
14581
|
+
cid: "QmULkz7hwwqsyLwY23U14dnartdVuSNMrykt69PaNiAq7U",
|
|
14582
14582
|
authorizedCidHex: cidToHex(
|
|
14583
|
-
"
|
|
14583
|
+
"QmULkz7hwwqsyLwY23U14dnartdVuSNMrykt69PaNiAq7U"
|
|
14584
14584
|
),
|
|
14585
14585
|
name: "Btc Transaction Signer",
|
|
14586
14586
|
description: "Production Btc Transaction Signer",
|
|
14587
14587
|
version: "1.1.1",
|
|
14588
14588
|
deployed: true,
|
|
14589
|
-
deployedAt:
|
|
14590
|
-
size:
|
|
14591
|
-
hash: "
|
|
14589
|
+
deployedAt: 1790246185256,
|
|
14590
|
+
size: 73313,
|
|
14591
|
+
hash: "d8b6bc646ba33fee7d46c8e9b281de776081ea6f182f56fd15d4c52aaf3dd030"
|
|
14592
14592
|
},
|
|
14593
14593
|
ucdMintValidator: {
|
|
14594
|
-
cid: "
|
|
14594
|
+
cid: "QmcxVSn9saEPGBS6mqPhNefgW83V2qeZjjXbhwYLP373xe",
|
|
14595
14595
|
authorizedCidHex: cidToHex(
|
|
14596
|
-
"
|
|
14596
|
+
"QmcxVSn9saEPGBS6mqPhNefgW83V2qeZjjXbhwYLP373xe"
|
|
14597
14597
|
),
|
|
14598
14598
|
name: "Ucd Mint Validator",
|
|
14599
14599
|
description: "Production Ucd Mint Validator",
|
|
14600
|
-
version: "1.
|
|
14600
|
+
version: "1.3.0",
|
|
14601
14601
|
deployed: true,
|
|
14602
|
-
deployedAt:
|
|
14603
|
-
size:
|
|
14604
|
-
hash: "
|
|
14605
|
-
validatorWalletAddress: "
|
|
14602
|
+
deployedAt: 1790246219868,
|
|
14603
|
+
size: 90022,
|
|
14604
|
+
hash: "65e8cb778c2b767ae6eb37cb5db7b4c5a3f2468d508463c847c83c1b6825fadd",
|
|
14605
|
+
validatorWalletAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C",
|
|
14606
14606
|
pkp: {
|
|
14607
14607
|
publicKey: "0x041ab17cd91fc5c0b761eea6092d032807561b621b82c488826776e04a9158d61ba64d809a4729f0501289d980732cb06d8dfd06999dd9c8efd2f495dad78b31bb",
|
|
14608
|
-
ethAddress: "
|
|
14608
|
+
ethAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C"
|
|
14609
14609
|
}
|
|
14610
14610
|
},
|
|
14611
14611
|
processPaymentValidator: {
|
|
14612
|
-
cid: "
|
|
14612
|
+
cid: "QmWFbxJkfxhCtES4wrePWQkYtjhtrP1tohvn9d1r9N5Hd8",
|
|
14613
14613
|
authorizedCidHex: cidToHex(
|
|
14614
|
-
"
|
|
14614
|
+
"QmWFbxJkfxhCtES4wrePWQkYtjhtrP1tohvn9d1r9N5Hd8"
|
|
14615
14615
|
),
|
|
14616
14616
|
name: "Process Payment Validator",
|
|
14617
14617
|
description: "Production Process Payment Validator",
|
|
14618
14618
|
version: "1.2.1",
|
|
14619
14619
|
deployed: true,
|
|
14620
|
-
deployedAt:
|
|
14621
|
-
size:
|
|
14622
|
-
hash: "
|
|
14623
|
-
validatorWalletAddress: "
|
|
14620
|
+
deployedAt: 1790246225795,
|
|
14621
|
+
size: 85107,
|
|
14622
|
+
hash: "25ecf952c4c44c40b0920b92d57906e7010ed9a38e2ba41ccdee6d3377c2b596",
|
|
14623
|
+
validatorWalletAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C",
|
|
14624
14624
|
pkp: {
|
|
14625
14625
|
publicKey: "0x04cfccb9b6c7addc79469c0e9fafebef4c70801302c62cdb26b610723a9b8527d23f98a40158c7340d83fd0e62d02b5ec74c12f7a86d98e8c6973b4811110f19ad",
|
|
14626
|
-
ethAddress: "
|
|
14626
|
+
ethAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C"
|
|
14627
14627
|
}
|
|
14628
14628
|
},
|
|
14629
14629
|
extendPositionValidator: {
|
|
14630
|
-
cid: "
|
|
14630
|
+
cid: "QmZ3g7g5DkgU1gEYpFjprQf3sctUHtGjNQVYezw2bnPGEX",
|
|
14631
14631
|
authorizedCidHex: cidToHex(
|
|
14632
|
-
"
|
|
14632
|
+
"QmZ3g7g5DkgU1gEYpFjprQf3sctUHtGjNQVYezw2bnPGEX"
|
|
14633
14633
|
),
|
|
14634
14634
|
name: "Extend Position Validator",
|
|
14635
14635
|
description: "Production Extend Position Validator",
|
|
14636
14636
|
version: "1.2.1",
|
|
14637
14637
|
deployed: true,
|
|
14638
|
-
deployedAt:
|
|
14639
|
-
size:
|
|
14640
|
-
hash: "
|
|
14641
|
-
validatorWalletAddress: "
|
|
14638
|
+
deployedAt: 1790246231975,
|
|
14639
|
+
size: 82853,
|
|
14640
|
+
hash: "25d4887b7f646649db2bb7f2bfb77d039db83228a6c454377ca26c779b0903cc",
|
|
14641
|
+
validatorWalletAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C",
|
|
14642
14642
|
pkp: {
|
|
14643
14643
|
publicKey: "0x04e52338f6a0c3362800f1a94c4c8f08be5030dde0fa217388c53d1c1a4790f4443c9f2886b2d2d8f4b75a9a156e9b028011b1a1cf7648da0e556aa980ec692836",
|
|
14644
|
-
ethAddress: "
|
|
14644
|
+
ethAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C"
|
|
14645
14645
|
}
|
|
14646
14646
|
},
|
|
14647
14647
|
btcWithdrawal: {
|
|
14648
|
-
cid: "
|
|
14648
|
+
cid: "QmbRaaMQr1jCctDGe8mPADsUz1rkb4frT1YqSKroiXjzyP",
|
|
14649
14649
|
authorizedCidHex: cidToHex(
|
|
14650
|
-
"
|
|
14650
|
+
"QmbRaaMQr1jCctDGe8mPADsUz1rkb4frT1YqSKroiXjzyP"
|
|
14651
14651
|
),
|
|
14652
14652
|
name: "Btc Withdrawal",
|
|
14653
14653
|
description: "Production Btc Withdrawal",
|
|
14654
14654
|
version: "1.2.7",
|
|
14655
14655
|
deployed: true,
|
|
14656
|
-
deployedAt:
|
|
14657
|
-
size:
|
|
14658
|
-
hash: "
|
|
14659
|
-
validatorWalletAddress: "
|
|
14656
|
+
deployedAt: 1790246239599,
|
|
14657
|
+
size: 101228,
|
|
14658
|
+
hash: "2ed25eca6cc80a43061b7ad119737af48158fdb61d59f10cd06cea51b607f112",
|
|
14659
|
+
validatorWalletAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C",
|
|
14660
14660
|
pkp: {
|
|
14661
14661
|
publicKey: "0x043616787c5432415c24378c4ef48de2bcd6bb7b575b837e3cff09171802662da7105d79586c7659677a0ecbaddac4cce06cb2a11f69a16fa0c4d7002ac7d51a4d",
|
|
14662
|
-
ethAddress: "
|
|
14662
|
+
ethAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C"
|
|
14663
14663
|
}
|
|
14664
14664
|
},
|
|
14665
14665
|
liquidationValidator: {
|
|
14666
|
-
cid: "
|
|
14666
|
+
cid: "QmTs2w8gfAwWZLbzJZg2CZmiLhVXS5kbMgaj42Zuxfodpb",
|
|
14667
14667
|
authorizedCidHex: cidToHex(
|
|
14668
|
-
"
|
|
14668
|
+
"QmTs2w8gfAwWZLbzJZg2CZmiLhVXS5kbMgaj42Zuxfodpb"
|
|
14669
14669
|
),
|
|
14670
14670
|
name: "Liquidation Validator",
|
|
14671
14671
|
description: "Production Liquidation Validator",
|
|
14672
14672
|
version: "1.2.1",
|
|
14673
14673
|
deployed: true,
|
|
14674
|
-
deployedAt:
|
|
14675
|
-
size:
|
|
14676
|
-
hash: "
|
|
14677
|
-
validatorWalletAddress: "
|
|
14674
|
+
deployedAt: 1790246247904,
|
|
14675
|
+
size: 70308,
|
|
14676
|
+
hash: "582ccf0ec7f715195e20fdc885996743cb42125b64173424e360ee63db62bbd8",
|
|
14677
|
+
validatorWalletAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C",
|
|
14678
14678
|
pkp: {
|
|
14679
14679
|
publicKey: "0x041a241de58976c13e3d7ca5a18e494f7330151e3818706135d50176e78ffb673e58b11f0b67a87c73fade6c6b27d6e7a7377ea9f4c10bf31880f1d725f18cc6f8",
|
|
14680
|
-
ethAddress: "
|
|
14680
|
+
ethAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C"
|
|
14681
14681
|
}
|
|
14682
14682
|
},
|
|
14683
14683
|
priceOracle: {
|
|
@@ -14692,28 +14692,28 @@ var require_pkg_src = __commonJS({
|
|
|
14692
14692
|
deployedAt: 1781116663270,
|
|
14693
14693
|
size: 8695,
|
|
14694
14694
|
hash: "ba20ade60a7fa5acd80dadfafa179c507388cfe6ce48a22a672d70b317ffcc74",
|
|
14695
|
-
validatorWalletAddress: "
|
|
14695
|
+
validatorWalletAddress: "0xefb258d455a31d061bbeb3de3d2143bdfcb67a6c",
|
|
14696
14696
|
pkp: {
|
|
14697
14697
|
publicKey: "0x043beaa1da47875601a8d6f430b1438ee2d4732eefd06e5c63a474bbdaf9e7df1797b1b951e041b627c2bf839788164825324c9cbd1e2d6f740fdd4bff69b1900b",
|
|
14698
|
-
ethAddress: "
|
|
14698
|
+
ethAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C"
|
|
14699
14699
|
}
|
|
14700
14700
|
},
|
|
14701
14701
|
loanVaultBtcBalance: {
|
|
14702
|
-
cid: "
|
|
14702
|
+
cid: "QmZ27xCzuoaAhWxRsMPsUQkp45a8WPBb21uhxwchw3LG5W",
|
|
14703
14703
|
authorizedCidHex: cidToHex(
|
|
14704
|
-
"
|
|
14704
|
+
"QmZ27xCzuoaAhWxRsMPsUQkp45a8WPBb21uhxwchw3LG5W"
|
|
14705
14705
|
),
|
|
14706
14706
|
name: "Loan Vault Btc Balance",
|
|
14707
14707
|
description: "Production Loan Vault Btc Balance",
|
|
14708
14708
|
version: "1.2.1",
|
|
14709
14709
|
deployed: true,
|
|
14710
|
-
deployedAt:
|
|
14711
|
-
size:
|
|
14712
|
-
hash: "
|
|
14713
|
-
validatorWalletAddress: "
|
|
14710
|
+
deployedAt: 1790179961079,
|
|
14711
|
+
size: 60046,
|
|
14712
|
+
hash: "922e86c0a667fe0c0945771f84aa6b9fe08be9c96dd2f73a9c5cb257d24e22b0",
|
|
14713
|
+
validatorWalletAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C",
|
|
14714
14714
|
pkp: {
|
|
14715
14715
|
publicKey: "0x043616787c5432415c24378c4ef48de2bcd6bb7b575b837e3cff09171802662da7105d79586c7659677a0ecbaddac4cce06cb2a11f69a16fa0c4d7002ac7d51a4d",
|
|
14716
|
-
ethAddress: "
|
|
14716
|
+
ethAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C"
|
|
14717
14717
|
}
|
|
14718
14718
|
},
|
|
14719
14719
|
// btc-address-balance (Option B) — address-only signed total balance via
|
|
@@ -14723,21 +14723,21 @@ var require_pkg_src = __commonJS({
|
|
|
14723
14723
|
// Requires BitcoinProviderRegistry.addAllowedCid(chainId, keccak256(utf8(cid)))
|
|
14724
14724
|
// on each target chain (the action decrypts registry slots). No OAR entry.
|
|
14725
14725
|
btcAddressBalance: {
|
|
14726
|
-
cid: "
|
|
14726
|
+
cid: "QmVVjB6zCBiXFKffhQPYUAZhj7TXduuvcrPqKtHa3DMXhN",
|
|
14727
14727
|
authorizedCidHex: cidToHex(
|
|
14728
|
-
"
|
|
14728
|
+
"QmVVjB6zCBiXFKffhQPYUAZhj7TXduuvcrPqKtHa3DMXhN"
|
|
14729
14729
|
),
|
|
14730
14730
|
name: "Btc Address Balance",
|
|
14731
14731
|
description: "Address-only signed total BTC balance via registry consensus (no positionId, no price)",
|
|
14732
14732
|
version: "0.2.1",
|
|
14733
14733
|
deployed: true,
|
|
14734
|
-
deployedAt:
|
|
14735
|
-
size:
|
|
14736
|
-
hash: "
|
|
14737
|
-
validatorWalletAddress: "
|
|
14734
|
+
deployedAt: 1790179971315,
|
|
14735
|
+
size: 30295,
|
|
14736
|
+
hash: "2c67d9cfa4d50e835fbb28ae50e80217ceb2be3bb862c89290aadf43fdc739c9",
|
|
14737
|
+
validatorWalletAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C",
|
|
14738
14738
|
pkp: {
|
|
14739
14739
|
publicKey: "0x0498cbb31facfa26e3ec83ccdabfe4fe341ca0282e0c3cb81da7113723b9726e1e49efa92165cc3faa66ced4454cea56dbab12267852d6525a55d7c4f128b912cd",
|
|
14740
|
-
ethAddress: "
|
|
14740
|
+
ethAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C"
|
|
14741
14741
|
}
|
|
14742
14742
|
},
|
|
14743
14743
|
alwaysSigner: {
|
|
@@ -14767,48 +14767,48 @@ var require_pkg_src = __commonJS({
|
|
|
14767
14767
|
hash: "03ee5be239c91c735d2c95db89a0d1b77e602cfc18af8eb64b3281fddcd90a72"
|
|
14768
14768
|
},
|
|
14769
14769
|
agentModuleExecutor: {
|
|
14770
|
-
cid: "
|
|
14770
|
+
cid: "QmSwPPvQhT7UhcuVA2m3UxGhVj5WqMpDvYNKU1228QLFsX",
|
|
14771
14771
|
authorizedCidHex: cidToHex(
|
|
14772
|
-
"
|
|
14772
|
+
"QmSwPPvQhT7UhcuVA2m3UxGhVj5WqMpDvYNKU1228QLFsX"
|
|
14773
14773
|
),
|
|
14774
14774
|
name: "Agent Module Executor",
|
|
14775
14775
|
description: "Production Agent Module Executor",
|
|
14776
14776
|
version: "1.1.1",
|
|
14777
14777
|
deployed: true,
|
|
14778
|
-
deployedAt:
|
|
14779
|
-
size:
|
|
14780
|
-
hash: "
|
|
14778
|
+
deployedAt: 1790179978959,
|
|
14779
|
+
size: 14688,
|
|
14780
|
+
hash: "8edb9b12c784c8d7d153cce97235584c24665a788767ae68713dce91109ab35e"
|
|
14781
14781
|
},
|
|
14782
14782
|
staleSpendRecoveryValidator: {
|
|
14783
|
-
cid: "
|
|
14783
|
+
cid: "Qmarj59zdSSgivkimryrdvnyZqH5YpTimKj1LivXNBHmNz",
|
|
14784
14784
|
authorizedCidHex: cidToHex(
|
|
14785
|
-
"
|
|
14785
|
+
"Qmarj59zdSSgivkimryrdvnyZqH5YpTimKj1LivXNBHmNz"
|
|
14786
14786
|
),
|
|
14787
14787
|
name: "Stale Spend Recovery Validator",
|
|
14788
14788
|
description: "Production Stale Spend Recovery Validator",
|
|
14789
14789
|
version: "1.1.2",
|
|
14790
14790
|
deployed: true,
|
|
14791
|
-
deployedAt:
|
|
14792
|
-
size:
|
|
14793
|
-
hash: "
|
|
14794
|
-
validatorWalletAddress: "
|
|
14791
|
+
deployedAt: 1790246256280,
|
|
14792
|
+
size: 48143,
|
|
14793
|
+
hash: "ec9236bcbe0af24d3e1844791fc8fe37371bbecd8ce95d02e13f7c6e1fc7d94c",
|
|
14794
|
+
validatorWalletAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C",
|
|
14795
14795
|
pkp: {
|
|
14796
14796
|
publicKey: "0x046da0ad6da7dd4a0063cbeac6f2bdb6a9889c2178b23470833356a8ee5630f7f0eee0db348d9d9aaaadd23eccf0063c8f68ee5e446abe30b882bf1de4c932bc21",
|
|
14797
|
-
ethAddress: "
|
|
14797
|
+
ethAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C"
|
|
14798
14798
|
}
|
|
14799
14799
|
},
|
|
14800
14800
|
btcUtxoInvalidator: {
|
|
14801
|
-
cid: "
|
|
14801
|
+
cid: "QmbS44bGcmKYF64Cu35qzsk9sxiU4Umde8Z3q24ZnEbQvX",
|
|
14802
14802
|
authorizedCidHex: cidToHex(
|
|
14803
|
-
"
|
|
14803
|
+
"QmbS44bGcmKYF64Cu35qzsk9sxiU4Umde8Z3q24ZnEbQvX"
|
|
14804
14804
|
),
|
|
14805
14805
|
name: "Btc Utxo Invalidator",
|
|
14806
14806
|
description: "Production Btc Utxo Invalidator",
|
|
14807
14807
|
version: "1.0.0",
|
|
14808
14808
|
deployed: true,
|
|
14809
|
-
deployedAt:
|
|
14810
|
-
size:
|
|
14811
|
-
hash: "
|
|
14809
|
+
deployedAt: 1790246264563,
|
|
14810
|
+
size: 69219,
|
|
14811
|
+
hash: "bda048d8cd6b5a39c2774bcf1320e82d1eea935c2a521006fb8b887e13b6dd8d"
|
|
14812
14812
|
}
|
|
14813
14813
|
};
|
|
14814
14814
|
function getDeploymentsForNetwork(network) {
|
|
@@ -15574,7 +15574,10 @@ ${errorReport}`);
|
|
|
15574
15574
|
BTCSpendAuthorizer: "0xfBbF108486fa07F1B06a811C5b66ed68DD9c508a",
|
|
15575
15575
|
BitcoinProviderRegistry: "0x4ab3Fb96e02893Ed6FAa61bad1918390c8DbbFFC",
|
|
15576
15576
|
LITActionValidator: "0xD2c5d59c2CC5c409AC65ce0A817236aeC6869512",
|
|
15577
|
-
PositionDelegateRegistry: "0xf0aa2678aD4F60f49e8F7725089B5E86B7F8FE4C"
|
|
15577
|
+
PositionDelegateRegistry: "0xf0aa2678aD4F60f49e8F7725089B5E86B7F8FE4C",
|
|
15578
|
+
TermManagerModule: "0xDB99CdF883ffa38acD099bC39F8d1f4508c9239E",
|
|
15579
|
+
UCDController: "0x4b4f8063048bCD59D469219E3f07C6aaDF4f6157",
|
|
15580
|
+
LiquidationManagerModule: "0x74B28695352E7bf736D6c9F76ccb7B4439477De9"
|
|
15578
15581
|
},
|
|
15579
15582
|
11155111: {
|
|
15580
15583
|
PositionManager: "0x68e0507D982AEBF1D1C1Af8FBbd842327e2deeFF",
|
|
@@ -15582,7 +15585,10 @@ ${errorReport}`);
|
|
|
15582
15585
|
BTCSpendAuthorizer: "0xd7E9Eb5eE53f1d9ee55Dc162bBC7486bE437B6bD",
|
|
15583
15586
|
BitcoinProviderRegistry: "0xbfA0c48B070D0a9A9CD27469AeacFD2d4261cEE2",
|
|
15584
15587
|
LITActionValidator: "0x54eECd7C90F8A8fac27749Ba30BbE8AFBAccc856",
|
|
15585
|
-
PositionDelegateRegistry: "0x482369De283622E7b05731875ec137d4E3D208F9"
|
|
15588
|
+
PositionDelegateRegistry: "0x482369De283622E7b05731875ec137d4E3D208F9",
|
|
15589
|
+
TermManagerModule: "0x94Adc6F9558368B1482197584f1fc7133Ecf835b",
|
|
15590
|
+
UCDController: "0x360Bde4e489ee94E26601B206932De09EE60FF04",
|
|
15591
|
+
LiquidationManagerModule: "0xC4AB00f39e7ceD812F5C67058C9fa44e15d40e76"
|
|
15586
15592
|
}
|
|
15587
15593
|
};
|
|
15588
15594
|
function getPinnedContractAddresses(chainId) {
|
|
@@ -15768,10 +15774,10 @@ ${errorReport}`);
|
|
|
15768
15774
|
};
|
|
15769
15775
|
}
|
|
15770
15776
|
const ratioBigInt = collateralValueUsd * UCD_TOKEN_DECIMALS * 10000n / ucdDebt;
|
|
15771
|
-
const
|
|
15777
|
+
const collateralRatioBps2 = Number(ratioBigInt);
|
|
15772
15778
|
return {
|
|
15773
15779
|
collateralValueUsd,
|
|
15774
|
-
collateralRatioBps
|
|
15780
|
+
collateralRatioBps: collateralRatioBps2
|
|
15775
15781
|
};
|
|
15776
15782
|
}
|
|
15777
15783
|
function hasSufficientCollateralForDebt(collateralValueUsd, currentDebt, additionalDebt, requiredRatioBps) {
|
|
@@ -16616,6 +16622,17 @@ ${auth.clientId}`;
|
|
|
16616
16622
|
);
|
|
16617
16623
|
}
|
|
16618
16624
|
}
|
|
16625
|
+
var TIP_READ_FAILURE_PREFIX = "Bitcoin tip-height read failed";
|
|
16626
|
+
var BitcoinTipUnreadableError = class extends Error {
|
|
16627
|
+
constructor(message) {
|
|
16628
|
+
super(message);
|
|
16629
|
+
this.isBitcoinTipUnreadable = true;
|
|
16630
|
+
this.name = "BitcoinTipUnreadableError";
|
|
16631
|
+
}
|
|
16632
|
+
};
|
|
16633
|
+
function isBitcoinTipUnreadableError(error) {
|
|
16634
|
+
return typeof error === "object" && error !== null && error.isBitcoinTipUnreadable === true;
|
|
16635
|
+
}
|
|
16619
16636
|
var BitcoinDataProvider = class {
|
|
16620
16637
|
constructor(config) {
|
|
16621
16638
|
this.config = config;
|
|
@@ -17067,27 +17084,12 @@ ${auth.clientId}`;
|
|
|
17067
17084
|
if (!data.status.confirmed || !data.status.block_height) {
|
|
17068
17085
|
return { txid: data.txid ?? txid, confirmations: 0 };
|
|
17069
17086
|
}
|
|
17070
|
-
|
|
17071
|
-
|
|
17072
|
-
|
|
17073
|
-
|
|
17074
|
-
|
|
17075
|
-
|
|
17076
|
-
return { txid: data.txid ?? txid, confirmations: 1 };
|
|
17077
|
-
}
|
|
17078
|
-
const tipBody = (await tipResp.text()).trim();
|
|
17079
|
-
const tipHeight = Number.parseInt(tipBody, 10);
|
|
17080
|
-
if (!Number.isFinite(tipHeight) || tipHeight <= 0) {
|
|
17081
|
-
return { txid: data.txid ?? txid, confirmations: 1 };
|
|
17082
|
-
}
|
|
17083
|
-
const depth = tipHeight - data.status.block_height + 1;
|
|
17084
|
-
return {
|
|
17085
|
-
txid: data.txid ?? txid,
|
|
17086
|
-
confirmations: depth > 0 ? depth : 0
|
|
17087
|
-
};
|
|
17088
|
-
} catch {
|
|
17089
|
-
return { txid: data.txid ?? txid, confirmations: 1 };
|
|
17090
|
-
}
|
|
17087
|
+
const tipHeight = await this.fetchTipHeight(controller.signal);
|
|
17088
|
+
const depth = tipHeight - data.status.block_height + 1;
|
|
17089
|
+
return {
|
|
17090
|
+
txid: data.txid ?? txid,
|
|
17091
|
+
confirmations: depth > 0 ? depth : 0
|
|
17092
|
+
};
|
|
17091
17093
|
}
|
|
17092
17094
|
return null;
|
|
17093
17095
|
} catch (error) {
|
|
@@ -17095,12 +17097,55 @@ ${auth.clientId}`;
|
|
|
17095
17097
|
if (isAbortError(error)) {
|
|
17096
17098
|
throw new Error(`Request timeout after ${this.timeout}ms`);
|
|
17097
17099
|
}
|
|
17100
|
+
if (isBitcoinTipUnreadableError(error)) {
|
|
17101
|
+
throw error;
|
|
17102
|
+
}
|
|
17098
17103
|
if (getUnknownErrorMessage(error).includes("404")) {
|
|
17099
17104
|
return null;
|
|
17100
17105
|
}
|
|
17101
17106
|
throw error;
|
|
17102
17107
|
}
|
|
17103
17108
|
}
|
|
17109
|
+
/**
|
|
17110
|
+
* Current chain tip height from THIS provider — or throw.
|
|
17111
|
+
*
|
|
17112
|
+
* Every exit is a throw naming the provider and the precise failure, because
|
|
17113
|
+
* the only alternative is inventing a confirmation depth (see the call site).
|
|
17114
|
+
* The single `try` exists solely to attach that name to a transport-level
|
|
17115
|
+
* rejection (DNS, TLS, connection reset, abort); it re-throws the cause
|
|
17116
|
+
* verbatim inside the message and never substitutes a value — authorized for
|
|
17117
|
+
* this case by the Batch 2 plan, §C2.
|
|
17118
|
+
*
|
|
17119
|
+
* @param signal - The caller's AbortSignal, so this read shares the same
|
|
17120
|
+
* timeout budget as the transaction fetch it serves.
|
|
17121
|
+
*/
|
|
17122
|
+
async fetchTipHeight(signal) {
|
|
17123
|
+
const endpoint = `${this.config.providerUrl}/blocks/tip/height`;
|
|
17124
|
+
let tipResp;
|
|
17125
|
+
try {
|
|
17126
|
+
tipResp = await fetch(endpoint, {
|
|
17127
|
+
signal,
|
|
17128
|
+
headers: await this.withAuth()
|
|
17129
|
+
});
|
|
17130
|
+
} catch (error) {
|
|
17131
|
+
throw new BitcoinTipUnreadableError(
|
|
17132
|
+
`${TIP_READ_FAILURE_PREFIX}: GET ${endpoint} threw \u2014 ${getUnknownErrorMessage(error)}`
|
|
17133
|
+
);
|
|
17134
|
+
}
|
|
17135
|
+
if (!tipResp.ok) {
|
|
17136
|
+
throw new BitcoinTipUnreadableError(
|
|
17137
|
+
`${TIP_READ_FAILURE_PREFIX}: GET ${endpoint} \u2192 ${tipResp.status} ${tipResp.statusText}`
|
|
17138
|
+
);
|
|
17139
|
+
}
|
|
17140
|
+
const tipBody = (await tipResp.text()).trim();
|
|
17141
|
+
const tipHeight = Number.parseInt(tipBody, 10);
|
|
17142
|
+
if (!Number.isFinite(tipHeight) || tipHeight <= 0) {
|
|
17143
|
+
throw new BitcoinTipUnreadableError(
|
|
17144
|
+
`${TIP_READ_FAILURE_PREFIX}: GET ${endpoint} returned an unusable tip height "${tipBody.slice(0, 64)}"`
|
|
17145
|
+
);
|
|
17146
|
+
}
|
|
17147
|
+
return tipHeight;
|
|
17148
|
+
}
|
|
17104
17149
|
/**
|
|
17105
17150
|
* Get outputs (vouts) of a Bitcoin transaction
|
|
17106
17151
|
*
|
|
@@ -17735,10 +17780,13 @@ ${auth.clientId}`;
|
|
|
17735
17780
|
* only on unanimity. The confirmed-balance consensus the validators run
|
|
17736
17781
|
* covers `chain_stats` only, so without this the primary provider alone
|
|
17737
17782
|
* could fabricate an unconfirmed UTXO plus a self-consistent parent proof
|
|
17738
|
-
* and inflate the signed balance. Any
|
|
17739
|
-
*
|
|
17740
|
-
*
|
|
17741
|
-
*
|
|
17783
|
+
* and inflate the signed balance. Any verdict disagreement THROWS
|
|
17784
|
+
* (fail-closed) — exclusion on a suppressed proof would deflate the balance
|
|
17785
|
+
* and open a wrongful-liquidation window, so neither direction may proceed
|
|
17786
|
+
* without agreement. A provider that cannot state the chain tip — and only
|
|
17787
|
+
* that failure — is dropped from the quorum rather than aborting the read (it
|
|
17788
|
+
* never counts as agreeing), and falling below `minConsensusProviders`
|
|
17789
|
+
* survivors throws — see `verifyParentIsSelfSpendConsensus`.
|
|
17742
17790
|
*
|
|
17743
17791
|
* The same per-provider `/tx` fetch also returns the parent's outputs, and
|
|
17744
17792
|
* every provider must corroborate each claimed UTXO (index, vault address,
|
|
@@ -17833,10 +17881,26 @@ ${auth.clientId}`;
|
|
|
17833
17881
|
}
|
|
17834
17882
|
/**
|
|
17835
17883
|
* Run the self-spend proof against every configured provider and require
|
|
17836
|
-
* unanimity
|
|
17837
|
-
*
|
|
17884
|
+
* unanimity AMONG THE PROVIDERS THAT ANSWERED. Fail-closed on disagreement:
|
|
17885
|
+
* a verdict mismatch throws and aborts the balance calculation — see
|
|
17838
17886
|
* classifySelfChange for why exclusion is not a safe fallback here.
|
|
17839
17887
|
*
|
|
17888
|
+
* Quorum semantics (2026-09-23, plan C2). ONE failure class is tolerated: a
|
|
17889
|
+
* provider that could not state the chain tip (`BitcoinTipUnreadableError`).
|
|
17890
|
+
* It is ABSENT from the quorum — never counted as agreeing, never allowed to
|
|
17891
|
+
* decide the verdict — and the policy floor, not "at least one", decides when
|
|
17892
|
+
* that absence is fatal: below `minConsensusProviders` surviving readings
|
|
17893
|
+
* there is no cross-check left to trust, and the read fails loudly naming
|
|
17894
|
+
* every provider that dropped out.
|
|
17895
|
+
*
|
|
17896
|
+
* Why only that class. `getTransaction` now throws on an unreadable tip
|
|
17897
|
+
* instead of fabricating `confirmations: 1`; without this carve-out one flaky
|
|
17898
|
+
* `/blocks/tip/height` endpoint would take every balance and spend path down
|
|
17899
|
+
* with it. Every OTHER failure remains fatal, as before: a provider that
|
|
17900
|
+
* answers "I have never seen that transaction" is making a claim about the
|
|
17901
|
+
* chain rather than suffering an outage, and that shape is precisely the
|
|
17902
|
+
* fabricated-UTXO signature the fail-closed rule exists to catch.
|
|
17903
|
+
*
|
|
17840
17904
|
* When the parent IS a unanimous self-spend, every provider's view of the
|
|
17841
17905
|
* parent's OUTPUTS must additionally corroborate the primary's claimed
|
|
17842
17906
|
* UTXOs (index exists, pays the vault, exact value). Without this, a
|
|
@@ -17861,32 +17925,52 @@ ${auth.clientId}`;
|
|
|
17861
17925
|
)
|
|
17862
17926
|
)
|
|
17863
17927
|
);
|
|
17864
|
-
const
|
|
17865
|
-
|
|
17866
|
-
|
|
17867
|
-
|
|
17868
|
-
|
|
17928
|
+
const answered = [];
|
|
17929
|
+
const absences = [];
|
|
17930
|
+
const failures = [];
|
|
17931
|
+
settled.forEach((result, i) => {
|
|
17932
|
+
if (result.status === "fulfilled") {
|
|
17933
|
+
answered.push({ index: i, evaluation: result.value });
|
|
17934
|
+
return;
|
|
17935
|
+
}
|
|
17936
|
+
const described = `${providerName(i)} \u2192 ${result.reason?.message ?? String(result.reason)}`;
|
|
17937
|
+
if (isBitcoinTipUnreadableError(result.reason)) {
|
|
17938
|
+
absences.push(described);
|
|
17939
|
+
return;
|
|
17940
|
+
}
|
|
17941
|
+
failures.push(described);
|
|
17942
|
+
});
|
|
17869
17943
|
if (failures.length > 0) {
|
|
17870
17944
|
throw new Error(
|
|
17871
17945
|
`Self-change classification failed for tx ${parentTxid} on ${failures.length}/${providerConfigs.length} provider(s): ${failures.join("; ")}`
|
|
17872
17946
|
);
|
|
17873
17947
|
}
|
|
17874
|
-
const
|
|
17875
|
-
|
|
17876
|
-
|
|
17877
|
-
|
|
17878
|
-
|
|
17879
|
-
|
|
17948
|
+
const floor = Math.max(1, this.minConsensusProviders);
|
|
17949
|
+
if (answered.length < floor) {
|
|
17950
|
+
throw new Error(
|
|
17951
|
+
`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("; ")}`
|
|
17952
|
+
);
|
|
17953
|
+
}
|
|
17954
|
+
if (absences.length > 0) {
|
|
17955
|
+
litDebugLog(
|
|
17956
|
+
`[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("; ")}`
|
|
17957
|
+
);
|
|
17958
|
+
}
|
|
17959
|
+
const first = answered[0];
|
|
17960
|
+
const disagreements = answered.slice(1).filter((a) => a.evaluation.selfSpend !== first.evaluation.selfSpend).map(
|
|
17961
|
+
(a) => `${providerName(first.index)}=${first.evaluation.selfSpend} vs ${providerName(a.index)}=${a.evaluation.selfSpend}`
|
|
17880
17962
|
);
|
|
17881
17963
|
if (disagreements.length > 0) {
|
|
17882
17964
|
throw new Error(
|
|
17883
17965
|
`Self-change consensus mismatch for tx ${parentTxid}: ${disagreements.join("; ")}. A provider may be compromised or out of sync; refusing to sign.`
|
|
17884
17966
|
);
|
|
17885
17967
|
}
|
|
17886
|
-
if (!
|
|
17968
|
+
if (!first.evaluation.selfSpend) {
|
|
17887
17969
|
return false;
|
|
17888
17970
|
}
|
|
17889
|
-
const outputMismatches =
|
|
17971
|
+
const outputMismatches = answered.map(
|
|
17972
|
+
(a) => a.evaluation.outputMismatch ? `${providerName(a.index)} \u2192 ${a.evaluation.outputMismatch}` : null
|
|
17973
|
+
).filter((m) => m !== null);
|
|
17890
17974
|
if (outputMismatches.length > 0) {
|
|
17891
17975
|
throw new Error(
|
|
17892
17976
|
`Self-change output claim mismatch for tx ${parentTxid}: ${outputMismatches.join("; ")}. The reported UTXO set contradicts the parent transaction; refusing to sign.`
|
|
@@ -18129,16 +18213,6 @@ ${auth.clientId}`;
|
|
|
18129
18213
|
minConfirmations
|
|
18130
18214
|
);
|
|
18131
18215
|
const authorizedSpends = await this.getAuthorizedSpendsFromContract(positionId);
|
|
18132
|
-
for (const spend of authorizedSpends) {
|
|
18133
|
-
const utxoStillExists = utxoSet.utxos.some(
|
|
18134
|
-
(utxo) => utxo.txid === spend.txid && utxo.vout === spend.vout
|
|
18135
|
-
);
|
|
18136
|
-
if (utxoStillExists) {
|
|
18137
|
-
throw new Error(
|
|
18138
|
-
`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.`
|
|
18139
|
-
);
|
|
18140
|
-
}
|
|
18141
|
-
}
|
|
18142
18216
|
const authorizedBalance = authorizedSpends.reduce(
|
|
18143
18217
|
(sum, spend) => sum + spend.satoshis,
|
|
18144
18218
|
0n
|
|
@@ -18434,7 +18508,13 @@ ${auth.clientId}`;
|
|
|
18434
18508
|
allowDevSinglePriceProvider: false,
|
|
18435
18509
|
minBitcoinBalanceConfirmations: 1,
|
|
18436
18510
|
minBitcoinSpendConfirmations: 1,
|
|
18437
|
-
|
|
18511
|
+
// 2 since 2026-09-23. It was 1 because Sepolia ran a single faucet provider
|
|
18512
|
+
// "by design", so the consensus floor was documented as a mainnet-only
|
|
18513
|
+
// guarantee. The registry now holds two, and leaving the floor at 1 meant
|
|
18514
|
+
// Sepolia could never exercise the multi-provider agreement the stale-spend
|
|
18515
|
+
// and balance paths rely on — the one environment where that logic is
|
|
18516
|
+
// supposed to be proved before mainnet.
|
|
18517
|
+
minConsensusProviders: 2
|
|
18438
18518
|
},
|
|
18439
18519
|
[
|
|
18440
18520
|
"ethereum"
|
|
@@ -24043,9 +24123,35 @@ var require_fetch_lit_action_from_ipfs = __commonJS({
|
|
|
24043
24123
|
return mod && mod.__esModule ? mod : { "default": mod };
|
|
24044
24124
|
};
|
|
24045
24125
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
24126
|
+
exports2.computeCidV0 = computeCidV0;
|
|
24046
24127
|
exports2.fetchLitActionCodeFromIpfs = fetchLitActionCodeFromIpfs;
|
|
24047
24128
|
var axios_1 = __importDefault(require_axios());
|
|
24129
|
+
var ethers_1 = require("ethers");
|
|
24048
24130
|
var ipfsCodeCache = /* @__PURE__ */ new Map();
|
|
24131
|
+
var CIDV0 = /^Qm[1-9A-HJ-NP-Za-km-z]{44}$/;
|
|
24132
|
+
var SINGLE_BLOCK_MAX_BYTES = 262144;
|
|
24133
|
+
function varint(n) {
|
|
24134
|
+
const out = [];
|
|
24135
|
+
while (n >= 128) {
|
|
24136
|
+
out.push(n & 127 | 128);
|
|
24137
|
+
n >>>= 7;
|
|
24138
|
+
}
|
|
24139
|
+
out.push(n);
|
|
24140
|
+
return out;
|
|
24141
|
+
}
|
|
24142
|
+
function computeCidV0(content) {
|
|
24143
|
+
const n = varint(content.length);
|
|
24144
|
+
const unixfs = new Uint8Array([8, 2, 18, ...n, ...content, 24, ...n]);
|
|
24145
|
+
const node = new Uint8Array([10, ...varint(unixfs.length), ...unixfs]);
|
|
24146
|
+
return (0, ethers_1.encodeBase58)(new Uint8Array([18, 32, ...(0, ethers_1.getBytes)((0, ethers_1.sha256)(node))]));
|
|
24147
|
+
}
|
|
24148
|
+
function responseBytes(data) {
|
|
24149
|
+
if (data instanceof Uint8Array)
|
|
24150
|
+
return data;
|
|
24151
|
+
if (data instanceof ArrayBuffer)
|
|
24152
|
+
return new Uint8Array(data);
|
|
24153
|
+
return null;
|
|
24154
|
+
}
|
|
24049
24155
|
var GATEWAY_TIMEOUT_MS = 2e4;
|
|
24050
24156
|
var buildGatewayList = (cid, pinataJwt) => {
|
|
24051
24157
|
const gateways = [];
|
|
@@ -24066,6 +24172,9 @@ var require_fetch_lit_action_from_ipfs = __commonJS({
|
|
|
24066
24172
|
}
|
|
24067
24173
|
return cached;
|
|
24068
24174
|
}
|
|
24175
|
+
if (!CIDV0.test(cid)) {
|
|
24176
|
+
throw new Error(`Refusing to fetch LIT Action for ${cid}: only CIDv0 (Qm\u2026) content can be verified`);
|
|
24177
|
+
}
|
|
24069
24178
|
const pinataJwt = options.pinataJwt ?? process.env.PINATA_JWT;
|
|
24070
24179
|
const extraGateways = options.extraGateways?.map((t) => ({ url: t.replace("{cid}", cid) })) ?? [];
|
|
24071
24180
|
const gateways = [...extraGateways, ...buildGatewayList(cid, pinataJwt)];
|
|
@@ -24077,19 +24186,32 @@ var require_fetch_lit_action_from_ipfs = __commonJS({
|
|
|
24077
24186
|
}
|
|
24078
24187
|
const response = await axios_1.default.get(gateway.url, {
|
|
24079
24188
|
timeout: GATEWAY_TIMEOUT_MS,
|
|
24189
|
+
responseType: "arraybuffer",
|
|
24080
24190
|
headers: {
|
|
24081
24191
|
Accept: "text/plain, application/javascript, text/javascript",
|
|
24082
24192
|
...gateway.headers
|
|
24083
24193
|
}
|
|
24084
24194
|
});
|
|
24085
|
-
|
|
24086
|
-
|
|
24087
|
-
|
|
24088
|
-
|
|
24089
|
-
ipfsCodeCache.set(cid, response.data);
|
|
24090
|
-
return response.data;
|
|
24195
|
+
const bytes = responseBytes(response.data);
|
|
24196
|
+
if (!bytes || bytes.length === 0) {
|
|
24197
|
+
failures.push(`${gateway.url}: HTTP ${response.status} returned ${bytes ? "an empty body" : typeof response.data}, expected bytes`);
|
|
24198
|
+
continue;
|
|
24091
24199
|
}
|
|
24092
|
-
|
|
24200
|
+
if (bytes.length > SINGLE_BLOCK_MAX_BYTES) {
|
|
24201
|
+
failures.push(`${gateway.url}: ${bytes.length} bytes exceeds the single-block CIDv0 limit (${SINGLE_BLOCK_MAX_BYTES}); content cannot be verified`);
|
|
24202
|
+
continue;
|
|
24203
|
+
}
|
|
24204
|
+
const actualCid = computeCidV0(bytes);
|
|
24205
|
+
if (actualCid !== cid) {
|
|
24206
|
+
failures.push(`${gateway.url}: content hashes to ${actualCid}, not the requested CID`);
|
|
24207
|
+
continue;
|
|
24208
|
+
}
|
|
24209
|
+
const code = new TextDecoder("utf-8", { fatal: true }).decode(bytes);
|
|
24210
|
+
if (options.debug) {
|
|
24211
|
+
console.log(`\u2705 [fetchLitActionCodeFromIpfs] Fetched and verified from ${gateway.url}`);
|
|
24212
|
+
}
|
|
24213
|
+
ipfsCodeCache.set(cid, code);
|
|
24214
|
+
return code;
|
|
24093
24215
|
} catch (error) {
|
|
24094
24216
|
const message = error instanceof Error ? error.message : String(error);
|
|
24095
24217
|
failures.push(`${gateway.url}: ${message}`);
|
|
@@ -25577,6 +25699,53 @@ var require_pkp_signer_module = __commonJS({
|
|
|
25577
25699
|
}
|
|
25578
25700
|
});
|
|
25579
25701
|
|
|
25702
|
+
// node_modules/@gvnrdao/dh-lit-ops/dist/modules/mainnet-validator-wallets.js
|
|
25703
|
+
var require_mainnet_validator_wallets = __commonJS({
|
|
25704
|
+
"node_modules/@gvnrdao/dh-lit-ops/dist/modules/mainnet-validator-wallets.js"(exports2) {
|
|
25705
|
+
"use strict";
|
|
25706
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
25707
|
+
exports2.MAINNET_OP_VALIDATOR_WALLETS = exports2.SEPOLIA_DEFAULT_VALIDATOR_WALLET = exports2.NON_MAINNET_CHAIN_IDS = void 0;
|
|
25708
|
+
exports2.resolveMainnetValidatorWallet = resolveMainnetValidatorWallet;
|
|
25709
|
+
exports2.NON_MAINNET_CHAIN_IDS = /* @__PURE__ */ new Set([
|
|
25710
|
+
11155111,
|
|
25711
|
+
// Sepolia
|
|
25712
|
+
1337,
|
|
25713
|
+
// Hardhat (DH local deployment chainId)
|
|
25714
|
+
31337
|
|
25715
|
+
// Hardhat (default)
|
|
25716
|
+
]);
|
|
25717
|
+
exports2.SEPOLIA_DEFAULT_VALIDATOR_WALLET = "0xefb258d455a31d061bbeb3de3d2143bdfcb67a6c";
|
|
25718
|
+
exports2.MAINNET_OP_VALIDATOR_WALLETS = {
|
|
25719
|
+
ucdMintValidator: "0x19C8FeE0f8f4b6F9Aa8e521D4CC62F4697CF85af",
|
|
25720
|
+
processPaymentValidator: "0x01480725c1fA026fd4A6bfA3100c691aeC955135",
|
|
25721
|
+
extendPositionValidator: "0xcE08AF213D8d95ad3dD317276F9e93Ab2eD75030",
|
|
25722
|
+
btcWithdrawal: "0x69dCd1204CDB31437CaF7114f74422390b472d3A",
|
|
25723
|
+
loanVaultBtcBalance: "0xc3d549EEb62721750Ff6518f6730Ab0e8D0Fea97",
|
|
25724
|
+
liquidationValidator: "0x66B30C19173005A51f21e2e4180FD7BC8c1d485b",
|
|
25725
|
+
// Non-OAR: verified on-chain by BTCSpendAuthorizer.staleSpendValidatorAddress (set via
|
|
25726
|
+
// AdminModule to this PKP's derived signer). Self-deriving Safe-owned PKP; seed == signer.
|
|
25727
|
+
staleSpendRecoveryValidator: "0x58F9144cF9781c15C061ba86901905a5a19F7661",
|
|
25728
|
+
// Non-OAR: no on-chain consumer verifies these signatures. The Sepolia seed has no key
|
|
25729
|
+
// derivation registered on the mainnet Lit account, so they reuse the Safe-owned
|
|
25730
|
+
// pkp-validator PKP (live derivation, group 2). See
|
|
25731
|
+
// docs/INCIDENT_2026-09-21_MAINNET_PKP_DERIVATION_DECRYPT.md.
|
|
25732
|
+
btcAddressBalance: "0x19524aE4e514a0f08A542596c2DA0B2262c61f48",
|
|
25733
|
+
priceOracle: "0x19524aE4e514a0f08A542596c2DA0B2262c61f48"
|
|
25734
|
+
};
|
|
25735
|
+
function resolveMainnetValidatorWallet(args) {
|
|
25736
|
+
const { registryKey, chainId, wallet } = args;
|
|
25737
|
+
const isNonMainnetChain = Number.isFinite(chainId) && exports2.NON_MAINNET_CHAIN_IDS.has(chainId);
|
|
25738
|
+
if (isNonMainnetChain || !wallet || wallet.toLowerCase() !== exports2.SEPOLIA_DEFAULT_VALIDATOR_WALLET) {
|
|
25739
|
+
return wallet;
|
|
25740
|
+
}
|
|
25741
|
+
if (!registryKey || !Object.prototype.hasOwnProperty.call(exports2.MAINNET_OP_VALIDATOR_WALLETS, registryKey)) {
|
|
25742
|
+
return wallet;
|
|
25743
|
+
}
|
|
25744
|
+
return exports2.MAINNET_OP_VALIDATOR_WALLETS[registryKey];
|
|
25745
|
+
}
|
|
25746
|
+
}
|
|
25747
|
+
});
|
|
25748
|
+
|
|
25580
25749
|
// node_modules/@gvnrdao/dh-lit-ops/dist/utils/async-request.util.js
|
|
25581
25750
|
var require_async_request_util = __commonJS({
|
|
25582
25751
|
"node_modules/@gvnrdao/dh-lit-ops/dist/utils/async-request.util.js"(exports2) {
|
|
@@ -25604,7 +25773,9 @@ var require_async_request_util = __commonJS({
|
|
|
25604
25773
|
});
|
|
25605
25774
|
if (!submitResponse.ok) {
|
|
25606
25775
|
const errorText = await submitResponse.text();
|
|
25607
|
-
|
|
25776
|
+
const retryAfter = submitResponse.status === 429 ? submitResponse.headers.get("retry-after") : null;
|
|
25777
|
+
const retryHint = retryAfter && /^\d+$/.test(retryAfter.trim()) ? ` Retry after ${retryAfter.trim()}s.` : "";
|
|
25778
|
+
throw new Error(`Failed to submit request (${submitResponse.status}): ${errorText}${retryHint}`);
|
|
25608
25779
|
}
|
|
25609
25780
|
const submitEnvelope = await submitResponse.json();
|
|
25610
25781
|
if (!submitEnvelope.success || !submitEnvelope.data?.ticketId) {
|
|
@@ -25882,6 +26053,7 @@ var require_lit_ops_module = __commonJS({
|
|
|
25882
26053
|
var pkp_manager_module_1 = require_pkp_manager_module();
|
|
25883
26054
|
var pkp_minter_module_1 = require_pkp_minter_module();
|
|
25884
26055
|
var pkp_signer_module_1 = require_pkp_signer_module();
|
|
26056
|
+
var mainnet_validator_wallets_1 = require_mainnet_validator_wallets();
|
|
25885
26057
|
var async_request_util_1 = require_async_request_util();
|
|
25886
26058
|
var crypto_1 = require("crypto");
|
|
25887
26059
|
var lit_core_lit_action_client_1 = require_lit_core_lit_action_client();
|
|
@@ -25894,26 +26066,6 @@ var require_lit_ops_module = __commonJS({
|
|
|
25894
26066
|
{ name: "borrower", type: "address" }
|
|
25895
26067
|
]
|
|
25896
26068
|
};
|
|
25897
|
-
var NON_MAINNET_CHAIN_IDS = /* @__PURE__ */ new Set([
|
|
25898
|
-
11155111,
|
|
25899
|
-
// Sepolia
|
|
25900
|
-
1337,
|
|
25901
|
-
// Hardhat (DH local deployment chainId)
|
|
25902
|
-
31337
|
|
25903
|
-
// Hardhat (default)
|
|
25904
|
-
]);
|
|
25905
|
-
var SEPOLIA_DEFAULT_VALIDATOR_WALLET = "0x82db9f515957aa380b596c6ea2bd30cef181f236";
|
|
25906
|
-
var MAINNET_OP_VALIDATOR_WALLETS = {
|
|
25907
|
-
ucdMintValidator: "0x19C8FeE0f8f4b6F9Aa8e521D4CC62F4697CF85af",
|
|
25908
|
-
processPaymentValidator: "0x01480725c1fA026fd4A6bfA3100c691aeC955135",
|
|
25909
|
-
extendPositionValidator: "0xcE08AF213D8d95ad3dD317276F9e93Ab2eD75030",
|
|
25910
|
-
btcWithdrawal: "0x69dCd1204CDB31437CaF7114f74422390b472d3A",
|
|
25911
|
-
loanVaultBtcBalance: "0xc3d549EEb62721750Ff6518f6730Ab0e8D0Fea97",
|
|
25912
|
-
liquidationValidator: "0x66B30C19173005A51f21e2e4180FD7BC8c1d485b",
|
|
25913
|
-
// Non-OAR: verified on-chain by BTCSpendAuthorizer.staleSpendValidatorAddress (set via
|
|
25914
|
-
// AdminModule to this PKP's derived signer). Self-deriving Safe-owned PKP; seed == signer.
|
|
25915
|
-
staleSpendRecoveryValidator: "0x58F9144cF9781c15C061ba86901905a5a19F7661"
|
|
25916
|
-
};
|
|
25917
26069
|
function resolvePkpValidationRegistryAddress(config) {
|
|
25918
26070
|
const fromConfig = config.pkpValidationRegistryAddress;
|
|
25919
26071
|
return fromConfig || process.env.PKP_VALIDATION_REGISTRY_ADDRESS || process.env.PKP_VALIDATION_REGISTRY;
|
|
@@ -27154,17 +27306,18 @@ var require_lit_ops_module = __commonJS({
|
|
|
27154
27306
|
let effectiveValidatorWallet = litActionInfo.validatorWalletAddress;
|
|
27155
27307
|
const jp = jsParams;
|
|
27156
27308
|
const resolvedChainId = Number(jp.chainId ?? jp.auth?.chainId ?? jp.authMessage?.chainId ?? this.config.chainId);
|
|
27157
|
-
const
|
|
27158
|
-
|
|
27159
|
-
|
|
27160
|
-
|
|
27161
|
-
|
|
27162
|
-
|
|
27163
|
-
|
|
27164
|
-
|
|
27165
|
-
|
|
27166
|
-
effectiveValidatorWallet
|
|
27309
|
+
const reg = (0, dh_lit_actions_1.getDeploymentsForNetwork)(this.config.network);
|
|
27310
|
+
const registryKey = Object.keys(reg).find((k) => reg[k]?.cid === litActionInfo.cid);
|
|
27311
|
+
const mainnetWallet = (0, mainnet_validator_wallets_1.resolveMainnetValidatorWallet)({
|
|
27312
|
+
registryKey,
|
|
27313
|
+
chainId: resolvedChainId,
|
|
27314
|
+
wallet: effectiveValidatorWallet
|
|
27315
|
+
});
|
|
27316
|
+
if (mainnetWallet !== effectiveValidatorWallet) {
|
|
27317
|
+
if (this.config.debug) {
|
|
27318
|
+
console.log(`[${label}] mainnet validator remap (${registryKey}, chainId=${Number.isFinite(resolvedChainId) ? resolvedChainId : "unknown\u2192mainnet"}): ${effectiveValidatorWallet} -> ${mainnetWallet}`);
|
|
27167
27319
|
}
|
|
27320
|
+
effectiveValidatorWallet = mainnetWallet;
|
|
27168
27321
|
}
|
|
27169
27322
|
if (process.env.LIT_LANE_VALIDATOR_WALLET_OVERRIDE) {
|
|
27170
27323
|
if (process.env.LIT_LANE_GUARD !== "1") {
|
|
@@ -28331,7 +28484,11 @@ var require_lit_ops_module = __commonJS({
|
|
|
28331
28484
|
error: "sign=true requires price oracle PKP in registry (ethAddress/publicKey) or options.pkpId (Lit jsParams pkpId)"
|
|
28332
28485
|
};
|
|
28333
28486
|
}
|
|
28334
|
-
priceOracleParams.pkpId =
|
|
28487
|
+
priceOracleParams.pkpId = (0, mainnet_validator_wallets_1.resolveMainnetValidatorWallet)({
|
|
28488
|
+
registryKey: "priceOracle",
|
|
28489
|
+
chainId: Number(this.config.chainId),
|
|
28490
|
+
wallet: resolvedPkpId
|
|
28491
|
+
});
|
|
28335
28492
|
}
|
|
28336
28493
|
if (this.config.debug) {
|
|
28337
28494
|
console.log("\u{1F4B0} Calling Price Oracle LIT Action:");
|
|
@@ -40556,7 +40713,7 @@ var require_dist3 = __commonJS({
|
|
|
40556
40713
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports3, p)) __createBinding(exports3, m, p);
|
|
40557
40714
|
};
|
|
40558
40715
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
40559
|
-
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;
|
|
40716
|
+
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;
|
|
40560
40717
|
__exportStar(require_interfaces(), exports2);
|
|
40561
40718
|
var dh_lit_actions_1 = require_pkg_src();
|
|
40562
40719
|
Object.defineProperty(exports2, "getDeploymentsForNetwork", { enumerable: true, get: function() {
|
|
@@ -40569,6 +40726,10 @@ var require_dist3 = __commonJS({
|
|
|
40569
40726
|
Object.defineProperty(exports2, "LitOps", { enumerable: true, get: function() {
|
|
40570
40727
|
return lit_ops_module_1.LitOps;
|
|
40571
40728
|
} });
|
|
40729
|
+
var mainnet_validator_wallets_1 = require_mainnet_validator_wallets();
|
|
40730
|
+
Object.defineProperty(exports2, "resolveMainnetValidatorWallet", { enumerable: true, get: function() {
|
|
40731
|
+
return mainnet_validator_wallets_1.resolveMainnetValidatorWallet;
|
|
40732
|
+
} });
|
|
40572
40733
|
var auth_manager_module_1 = require_auth_manager_module();
|
|
40573
40734
|
Object.defineProperty(exports2, "LitAuthManager", { enumerable: true, get: function() {
|
|
40574
40735
|
return auth_manager_module_1.LitAuthManager;
|
|
@@ -40919,6 +41080,7 @@ function renderLandingPage(input) {
|
|
|
40919
41080
|
|
|
40920
41081
|
// src/util/page-headers.ts
|
|
40921
41082
|
var import_node_crypto = require("crypto");
|
|
41083
|
+
var STRICT_TRANSPORT_SECURITY = { name: "Strict-Transport-Security", value: "max-age=31536000; includeSubDomains" };
|
|
40922
41084
|
function htmlPageSecurityHeaders(extra) {
|
|
40923
41085
|
const nonce = (0, import_node_crypto.randomBytes)(16).toString("base64");
|
|
40924
41086
|
const base = [
|
|
@@ -40946,7 +41108,7 @@ function htmlPageSecurityHeaders(extra) {
|
|
|
40946
41108
|
}
|
|
40947
41109
|
|
|
40948
41110
|
// src/version.ts
|
|
40949
|
-
var SERVER_VERSION = "0.5.
|
|
41111
|
+
var SERVER_VERSION = "0.5.20";
|
|
40950
41112
|
|
|
40951
41113
|
// src/connector/siwe-oauth.ts
|
|
40952
41114
|
var import_node_crypto2 = require("crypto");
|
|
@@ -41156,6 +41318,7 @@ var SiweOAuthProvider = class {
|
|
|
41156
41318
|
this.flows.set(flowId, { clientId: client.client_id, params, createdAt: this.clock() });
|
|
41157
41319
|
const page = htmlPageSecurityHeaders();
|
|
41158
41320
|
for (const [name, value] of Object.entries(page.headers)) res.setHeader(name, value);
|
|
41321
|
+
res.setHeader(STRICT_TRANSPORT_SECURITY.name, STRICT_TRANSPORT_SECURITY.value);
|
|
41159
41322
|
res.status(200).type("html").send(
|
|
41160
41323
|
renderSiwePage({
|
|
41161
41324
|
flowId,
|
|
@@ -41756,8 +41919,13 @@ function iso(sec) {
|
|
|
41756
41919
|
return new Date(sec * 1e3).toISOString();
|
|
41757
41920
|
}
|
|
41758
41921
|
var PSM_FLOOR_TOLERANCE_BPS = 100;
|
|
41922
|
+
var CANONICAL_MAINNET_USDC = "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48";
|
|
41923
|
+
function stablecoinKindFor(network, stablecoinAddress) {
|
|
41924
|
+
if (network !== "mainnet") return "mock";
|
|
41925
|
+
return stablecoinAddress.toLowerCase() === CANONICAL_MAINNET_USDC.toLowerCase() ? "circle" : "onchain";
|
|
41926
|
+
}
|
|
41759
41927
|
function failureToError(f) {
|
|
41760
|
-
const code = f.kind === "signer-missing" ? "SIGNER_UNAVAILABLE" : f.kind === "unavailable" ? "UPSTREAM_UNAVAILABLE" : f.kind === "not-found" ? "NOT_FOUND" : "UPSTREAM_REJECTED";
|
|
41928
|
+
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";
|
|
41761
41929
|
const message = f.kind === "malformed" ? `${f.message} (upstream response failed integrity checks)` : f.message;
|
|
41762
41930
|
return boundaryError(code, message, {
|
|
41763
41931
|
source: f.source,
|
|
@@ -42233,7 +42401,7 @@ var BoundaryCore = class {
|
|
|
42233
42401
|
tokenAddress: a.tokenAddress,
|
|
42234
42402
|
spenderAddress: a.spenderAddress,
|
|
42235
42403
|
spenderContract: a.spenderContract,
|
|
42236
|
-
spenderReason: a.spenderContract === "SimplePSMV2" ?
|
|
42404
|
+
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",
|
|
42237
42405
|
before: a.before,
|
|
42238
42406
|
amountUnit: q.amountInUnit,
|
|
42239
42407
|
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."
|
|
@@ -42292,9 +42460,10 @@ var BoundaryCore = class {
|
|
|
42292
42460
|
chainId: this.deps.chainId,
|
|
42293
42461
|
psmAddress: s.psmAddress,
|
|
42294
42462
|
stablecoinAddress: s.stablecoinAddress,
|
|
42295
|
-
//
|
|
42296
|
-
// practice
|
|
42297
|
-
|
|
42463
|
+
// Labelled by the ACTUAL coin, not the network (C-49): `circle` only for canonical
|
|
42464
|
+
// mainnet USDC, `mock` for the practice token, `onchain` for any other real coin
|
|
42465
|
+
// (e.g. mainnet USDT) — a USDT swap must never render as "real USDC".
|
|
42466
|
+
stablecoinKind: stablecoinKindFor(this.deps.network, s.stablecoinAddress),
|
|
42298
42467
|
stablecoinSymbol: s.stablecoinSymbol,
|
|
42299
42468
|
stablecoinDecimals: s.stablecoinDecimals,
|
|
42300
42469
|
exchangeRate: s.exchangeRate,
|
|
@@ -45285,6 +45454,35 @@ var import_ethers10 = require("ethers");
|
|
|
45285
45454
|
// src/boundary/upstream/shared/external-bridge/card.ts
|
|
45286
45455
|
var import_ethers8 = require("ethers");
|
|
45287
45456
|
init_tx_validator();
|
|
45457
|
+
|
|
45458
|
+
// src/boundary/upstream/shared/external-bridge/card-escape.ts
|
|
45459
|
+
var MAX_VALUE_CHARS = 200;
|
|
45460
|
+
function mustEscape(code) {
|
|
45461
|
+
if (code <= 31 || code === 127) return true;
|
|
45462
|
+
if (code >= 128 && code <= 159) return true;
|
|
45463
|
+
if (code === 8232 || code === 8233) return true;
|
|
45464
|
+
if (code >= 8234 && code <= 8238) return true;
|
|
45465
|
+
if (code >= 8294 && code <= 8297) return true;
|
|
45466
|
+
return false;
|
|
45467
|
+
}
|
|
45468
|
+
function safeValue(raw) {
|
|
45469
|
+
let out = "";
|
|
45470
|
+
for (const ch of String(raw)) {
|
|
45471
|
+
const code = ch.codePointAt(0);
|
|
45472
|
+
out += mustEscape(code) ? `\\u${code.toString(16).padStart(4, "0")}` : ch;
|
|
45473
|
+
if (out.length > MAX_VALUE_CHARS) return `${out.slice(0, MAX_VALUE_CHARS)}\u2026[truncated]`;
|
|
45474
|
+
}
|
|
45475
|
+
return out;
|
|
45476
|
+
}
|
|
45477
|
+
|
|
45478
|
+
// src/boundary/upstream/shared/external-bridge/card.ts
|
|
45479
|
+
function formatBtc(sats) {
|
|
45480
|
+
const negative = sats < 0n;
|
|
45481
|
+
const abs = negative ? -sats : sats;
|
|
45482
|
+
const whole = abs / 10n ** 8n;
|
|
45483
|
+
const frac = (abs % 10n ** 8n).toString().padStart(8, "0").replace(/0+$/, "");
|
|
45484
|
+
return `${negative ? "-" : ""}${whole}${frac ? "." + frac : ""}`;
|
|
45485
|
+
}
|
|
45288
45486
|
function formatUcd(wei) {
|
|
45289
45487
|
const negative = wei < 0n;
|
|
45290
45488
|
const abs = negative ? -wei : wei;
|
|
@@ -45330,15 +45528,15 @@ function cardForTx(tx2) {
|
|
|
45330
45528
|
"Operation: create a new borrowing position (your wallet is the borrower)",
|
|
45331
45529
|
`Term: ${Number(args[4])} months`,
|
|
45332
45530
|
`Position key (PKP id): ${String(args[0])}`,
|
|
45333
|
-
`BTC vault (mainnet form): ${
|
|
45334
|
-
`BTC vault (regtest form): ${
|
|
45531
|
+
`BTC vault (mainnet form): ${safeValue(args[2])}`,
|
|
45532
|
+
`BTC vault (regtest form): ${safeValue(args[3])}`,
|
|
45335
45533
|
`Validator generation: ${Number(args[5])}`,
|
|
45336
45534
|
...head
|
|
45337
45535
|
];
|
|
45338
45536
|
case "addAddress":
|
|
45339
45537
|
return [
|
|
45340
45538
|
"Operation: allowlist a Bitcoin withdrawal destination for YOUR account",
|
|
45341
|
-
`BTC address to allowlist: ${
|
|
45539
|
+
`BTC address to allowlist: ${safeValue(args[0])}`,
|
|
45342
45540
|
"Withdrawals to this address become possible only after the registry's on-chain delay",
|
|
45343
45541
|
...head
|
|
45344
45542
|
];
|
|
@@ -45366,15 +45564,40 @@ function cardForTx(tx2) {
|
|
|
45366
45564
|
`Minimum stablecoin out \u2014 the slippage floor (smallest units): ${String(args[2])}`,
|
|
45367
45565
|
...head
|
|
45368
45566
|
];
|
|
45567
|
+
case "withdrawBTC": {
|
|
45568
|
+
const p = args[0];
|
|
45569
|
+
return [
|
|
45570
|
+
"Operation: withdraw BTC from your vault \u2014 THIS MOVES BITCOIN OUT",
|
|
45571
|
+
`Position: ${safeValue(p.positionId)}`,
|
|
45572
|
+
// The destination is the whole security question of this card. It is a caller-
|
|
45573
|
+
// supplied string, hence safeValue: see the escaping note above.
|
|
45574
|
+
`BTC sent to: ${safeValue(p.withdrawalAddress)}`,
|
|
45575
|
+
`Leaves the vault (fee included): ${formatBtc(BigInt(p.totalDeduction))} BTC (${BigInt(p.totalDeduction)} sats)`,
|
|
45576
|
+
`Collateral remaining after this: ${formatBtc(BigInt(p.newCollateral))} BTC (${BigInt(p.newCollateral)} sats)`,
|
|
45577
|
+
`Spending vault UTXO: ${safeValue(p.utxoTxid)}:${Number(p.utxoVout)}`,
|
|
45578
|
+
...head
|
|
45579
|
+
];
|
|
45580
|
+
}
|
|
45581
|
+
case "setPositionDelegate":
|
|
45582
|
+
return [
|
|
45583
|
+
"Operation: set the DELEGATE for this position \u2014 this address may act on the position on your behalf",
|
|
45584
|
+
`Position: ${safeValue(args[0])}`,
|
|
45585
|
+
`Delegate address: ${safeValue(args[1])}`,
|
|
45586
|
+
"Setting the zero address removes the current delegate",
|
|
45587
|
+
...head
|
|
45588
|
+
];
|
|
45369
45589
|
default:
|
|
45370
|
-
|
|
45590
|
+
throw new Error(
|
|
45591
|
+
`no approval card is defined for the signable function "${name}" \u2014 add a case to cardForTx before this operation can be approved`
|
|
45592
|
+
);
|
|
45371
45593
|
}
|
|
45372
45594
|
}
|
|
45373
45595
|
function cardForTypedData(action, payload) {
|
|
45374
45596
|
const m = payload.message;
|
|
45375
45597
|
return [
|
|
45376
45598
|
`Operation: ${action} \u2014 this signature AUTHORIZES the operation described below; the protocol executes it after your approval`,
|
|
45377
|
-
|
|
45599
|
+
// `detail` here is a server-composed string — same escaping rule as the tx card.
|
|
45600
|
+
...Object.entries(m).map(([k, v]) => `${safeValue(k)}: ${safeValue(v)}`),
|
|
45378
45601
|
`Signing domain: ${String(payload.domain["name"])} v${String(payload.domain["version"])} \xB7 chain ${String(payload.domain["chainId"])}`
|
|
45379
45602
|
];
|
|
45380
45603
|
}
|
|
@@ -45725,12 +45948,10 @@ init_tx_validator();
|
|
|
45725
45948
|
|
|
45726
45949
|
// src/boundary/upstream/shared/quantum.ts
|
|
45727
45950
|
var QUANTUM_WINDOW_SECONDS = 60;
|
|
45728
|
-
var AUTH_VALIDITY_WINDOWS = 3;
|
|
45729
|
-
function authValiditySec() {
|
|
45730
|
-
return QUANTUM_WINDOW_SECONDS * AUTH_VALIDITY_WINDOWS;
|
|
45731
|
-
}
|
|
45732
45951
|
function isAuthFresh(issuedAtSec, nowSec) {
|
|
45733
|
-
|
|
45952
|
+
const sq = Math.floor(issuedAtSec / QUANTUM_WINDOW_SECONDS) * QUANTUM_WINDOW_SECONDS;
|
|
45953
|
+
const cq = Math.floor(nowSec / QUANTUM_WINDOW_SECONDS) * QUANTUM_WINDOW_SECONDS;
|
|
45954
|
+
return sq === cq - QUANTUM_WINDOW_SECONDS || sq === cq || sq === cq + QUANTUM_WINDOW_SECONDS;
|
|
45734
45955
|
}
|
|
45735
45956
|
function isStrictCurrentQuantum(issuedAtSec, nowSec) {
|
|
45736
45957
|
return issuedAtSec <= nowSec && Math.floor(issuedAtSec / QUANTUM_WINDOW_SECONDS) === Math.floor(nowSec / QUANTUM_WINDOW_SECONDS);
|
|
@@ -45771,7 +45992,7 @@ var SafeCeremony = class {
|
|
|
45771
45992
|
if (!auth.ok) return auth.refusal;
|
|
45772
45993
|
if (!isAuthFresh(issuedAtSec, surface.nowSec())) {
|
|
45773
45994
|
return this.refuse(
|
|
45774
|
-
`${p.action}: the owners' authorization expired \u2014 issued
|
|
45995
|
+
`${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`
|
|
45775
45996
|
);
|
|
45776
45997
|
}
|
|
45777
45998
|
const raw = await executor.signTransaction({
|
|
@@ -52490,7 +52711,6 @@ var init_deployment_addresses = __esm2({
|
|
|
52490
52711
|
PositionDelegateRegistry: "0x482369De283622E7b05731875ec137d4E3D208F9",
|
|
52491
52712
|
FeeRecipientRegistry: "0x95795F8403DDb629E8527B2934C4e71f5fC0C374",
|
|
52492
52713
|
BitcoinWithdrawalAddressRegistry: "0x6376D392097F0A81e51BD83960A97EA20eaf1dbe",
|
|
52493
|
-
CarryAgentRegistry: "0x5595CB538D44E6Cf179D20364fD631D0477e69f7",
|
|
52494
52714
|
AgentDelegationRegistry: "0x6AE7fc6bE0925126b9D25b1B7Ce5AD5d127ec025",
|
|
52495
52715
|
DHAgentDelegate: "0xa5A14489ae883960df6E1463A41a47aBE9Ecc5AF",
|
|
52496
52716
|
AgentModuleFactory: "0x1Fd3aCa2C030Cf77ce28Af9694D3Bb3034ACa2E5"
|
|
@@ -52760,8 +52980,6 @@ var init_deployment_addresses = __esm2({
|
|
|
52760
52980
|
OPERATION_AUTHORIZATION_REGISTRY_IMPL: "0xe0D981B60351f0f8fFDA2b50C8180Fb37CeF3883",
|
|
52761
52981
|
BITCOIN_WITHDRAWAL_ADDRESS_REGISTRY: "0x6376D392097F0A81e51BD83960A97EA20eaf1dbe",
|
|
52762
52982
|
BITCOIN_WITHDRAWAL_ADDRESS_REGISTRY_IMPL: "0x76E0a2c9d89562fD7c50b5f554d7fa25957e39Db",
|
|
52763
|
-
CARRY_AGENT_REGISTRY: "0x5595CB538D44E6Cf179D20364fD631D0477e69f7",
|
|
52764
|
-
CARRY_AGENT_REGISTRY_IMPL: "0x1b11a3D5e46F3672E643c997f0d569DFf0b64a01",
|
|
52765
52983
|
AGENT_DELEGATION_REGISTRY: "0x6AE7fc6bE0925126b9D25b1B7Ce5AD5d127ec025",
|
|
52766
52984
|
AGENT_DELEGATION_REGISTRY_IMPL: "0xE931E4b9ceF2A48Ac7D57192da4B523756cFC310",
|
|
52767
52985
|
DH_AGENT_DELEGATE: "0xa5A14489ae883960df6E1463A41a47aBE9Ecc5AF"
|
|
@@ -52793,7 +53011,6 @@ var init_deployment_addresses = __esm2({
|
|
|
52793
53011
|
PositionDelegateRegistry: "0x482369De283622E7b05731875ec137d4E3D208F9",
|
|
52794
53012
|
FeeRecipientRegistry: "0x95795F8403DDb629E8527B2934C4e71f5fC0C374",
|
|
52795
53013
|
BitcoinWithdrawalAddressRegistry: "0x6376D392097F0A81e51BD83960A97EA20eaf1dbe",
|
|
52796
|
-
CarryAgentRegistry: "0x5595CB538D44E6Cf179D20364fD631D0477e69f7",
|
|
52797
53014
|
AgentDelegationRegistry: "0x6AE7fc6bE0925126b9D25b1B7Ce5AD5d127ec025",
|
|
52798
53015
|
DHAgentDelegate: "0xa5A14489ae883960df6E1463A41a47aBE9Ecc5AF",
|
|
52799
53016
|
AgentModuleFactory: "0x1Fd3aCa2C030Cf77ce28Af9694D3Bb3034ACa2E5"
|
|
@@ -53768,113 +53985,113 @@ var require_pkg_src2 = __commonJS2({
|
|
|
53768
53985
|
deployedAt: 1784569687492,
|
|
53769
53986
|
size: 4140,
|
|
53770
53987
|
hash: "4c0d65bf1f33cdac22a78fd8c4764319cc3fe00650e0fe7fa8a6090d9a318a7b",
|
|
53771
|
-
validatorWalletAddress: "
|
|
53988
|
+
validatorWalletAddress: "0xefb258d455a31d061bbeb3de3d2143bdfcb67a6c",
|
|
53772
53989
|
pkp: {
|
|
53773
53990
|
publicKey: "0x04ec0e3acc40884e3f366ca469d08899eb640ad5259fa196b0238075086208a9f8732a3175704f35f0bcc28e07406cfb24c254efd1e7355640577330f0d2dd755f",
|
|
53774
|
-
ethAddress: "
|
|
53991
|
+
ethAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C"
|
|
53775
53992
|
}
|
|
53776
53993
|
},
|
|
53777
53994
|
btcTransactionSigner: {
|
|
53778
|
-
cid: "
|
|
53995
|
+
cid: "QmULkz7hwwqsyLwY23U14dnartdVuSNMrykt69PaNiAq7U",
|
|
53779
53996
|
authorizedCidHex: cidToHex(
|
|
53780
|
-
"
|
|
53997
|
+
"QmULkz7hwwqsyLwY23U14dnartdVuSNMrykt69PaNiAq7U"
|
|
53781
53998
|
),
|
|
53782
53999
|
name: "Btc Transaction Signer",
|
|
53783
54000
|
description: "Production Btc Transaction Signer",
|
|
53784
54001
|
version: "1.1.1",
|
|
53785
54002
|
deployed: true,
|
|
53786
|
-
deployedAt:
|
|
53787
|
-
size:
|
|
53788
|
-
hash: "
|
|
54003
|
+
deployedAt: 1790246185256,
|
|
54004
|
+
size: 73313,
|
|
54005
|
+
hash: "d8b6bc646ba33fee7d46c8e9b281de776081ea6f182f56fd15d4c52aaf3dd030"
|
|
53789
54006
|
},
|
|
53790
54007
|
ucdMintValidator: {
|
|
53791
|
-
cid: "
|
|
54008
|
+
cid: "QmcxVSn9saEPGBS6mqPhNefgW83V2qeZjjXbhwYLP373xe",
|
|
53792
54009
|
authorizedCidHex: cidToHex(
|
|
53793
|
-
"
|
|
54010
|
+
"QmcxVSn9saEPGBS6mqPhNefgW83V2qeZjjXbhwYLP373xe"
|
|
53794
54011
|
),
|
|
53795
54012
|
name: "Ucd Mint Validator",
|
|
53796
54013
|
description: "Production Ucd Mint Validator",
|
|
53797
|
-
version: "1.
|
|
54014
|
+
version: "1.3.0",
|
|
53798
54015
|
deployed: true,
|
|
53799
|
-
deployedAt:
|
|
53800
|
-
size:
|
|
53801
|
-
hash: "
|
|
53802
|
-
validatorWalletAddress: "
|
|
54016
|
+
deployedAt: 1790246219868,
|
|
54017
|
+
size: 90022,
|
|
54018
|
+
hash: "65e8cb778c2b767ae6eb37cb5db7b4c5a3f2468d508463c847c83c1b6825fadd",
|
|
54019
|
+
validatorWalletAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C",
|
|
53803
54020
|
pkp: {
|
|
53804
54021
|
publicKey: "0x041ab17cd91fc5c0b761eea6092d032807561b621b82c488826776e04a9158d61ba64d809a4729f0501289d980732cb06d8dfd06999dd9c8efd2f495dad78b31bb",
|
|
53805
|
-
ethAddress: "
|
|
54022
|
+
ethAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C"
|
|
53806
54023
|
}
|
|
53807
54024
|
},
|
|
53808
54025
|
processPaymentValidator: {
|
|
53809
|
-
cid: "
|
|
54026
|
+
cid: "QmWFbxJkfxhCtES4wrePWQkYtjhtrP1tohvn9d1r9N5Hd8",
|
|
53810
54027
|
authorizedCidHex: cidToHex(
|
|
53811
|
-
"
|
|
54028
|
+
"QmWFbxJkfxhCtES4wrePWQkYtjhtrP1tohvn9d1r9N5Hd8"
|
|
53812
54029
|
),
|
|
53813
54030
|
name: "Process Payment Validator",
|
|
53814
54031
|
description: "Production Process Payment Validator",
|
|
53815
54032
|
version: "1.2.1",
|
|
53816
54033
|
deployed: true,
|
|
53817
|
-
deployedAt:
|
|
53818
|
-
size:
|
|
53819
|
-
hash: "
|
|
53820
|
-
validatorWalletAddress: "
|
|
54034
|
+
deployedAt: 1790246225795,
|
|
54035
|
+
size: 85107,
|
|
54036
|
+
hash: "25ecf952c4c44c40b0920b92d57906e7010ed9a38e2ba41ccdee6d3377c2b596",
|
|
54037
|
+
validatorWalletAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C",
|
|
53821
54038
|
pkp: {
|
|
53822
54039
|
publicKey: "0x04cfccb9b6c7addc79469c0e9fafebef4c70801302c62cdb26b610723a9b8527d23f98a40158c7340d83fd0e62d02b5ec74c12f7a86d98e8c6973b4811110f19ad",
|
|
53823
|
-
ethAddress: "
|
|
54040
|
+
ethAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C"
|
|
53824
54041
|
}
|
|
53825
54042
|
},
|
|
53826
54043
|
extendPositionValidator: {
|
|
53827
|
-
cid: "
|
|
54044
|
+
cid: "QmZ3g7g5DkgU1gEYpFjprQf3sctUHtGjNQVYezw2bnPGEX",
|
|
53828
54045
|
authorizedCidHex: cidToHex(
|
|
53829
|
-
"
|
|
54046
|
+
"QmZ3g7g5DkgU1gEYpFjprQf3sctUHtGjNQVYezw2bnPGEX"
|
|
53830
54047
|
),
|
|
53831
54048
|
name: "Extend Position Validator",
|
|
53832
54049
|
description: "Production Extend Position Validator",
|
|
53833
54050
|
version: "1.2.1",
|
|
53834
54051
|
deployed: true,
|
|
53835
|
-
deployedAt:
|
|
53836
|
-
size:
|
|
53837
|
-
hash: "
|
|
53838
|
-
validatorWalletAddress: "
|
|
54052
|
+
deployedAt: 1790246231975,
|
|
54053
|
+
size: 82853,
|
|
54054
|
+
hash: "25d4887b7f646649db2bb7f2bfb77d039db83228a6c454377ca26c779b0903cc",
|
|
54055
|
+
validatorWalletAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C",
|
|
53839
54056
|
pkp: {
|
|
53840
54057
|
publicKey: "0x04e52338f6a0c3362800f1a94c4c8f08be5030dde0fa217388c53d1c1a4790f4443c9f2886b2d2d8f4b75a9a156e9b028011b1a1cf7648da0e556aa980ec692836",
|
|
53841
|
-
ethAddress: "
|
|
54058
|
+
ethAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C"
|
|
53842
54059
|
}
|
|
53843
54060
|
},
|
|
53844
54061
|
btcWithdrawal: {
|
|
53845
|
-
cid: "
|
|
54062
|
+
cid: "QmbRaaMQr1jCctDGe8mPADsUz1rkb4frT1YqSKroiXjzyP",
|
|
53846
54063
|
authorizedCidHex: cidToHex(
|
|
53847
|
-
"
|
|
54064
|
+
"QmbRaaMQr1jCctDGe8mPADsUz1rkb4frT1YqSKroiXjzyP"
|
|
53848
54065
|
),
|
|
53849
54066
|
name: "Btc Withdrawal",
|
|
53850
54067
|
description: "Production Btc Withdrawal",
|
|
53851
54068
|
version: "1.2.7",
|
|
53852
54069
|
deployed: true,
|
|
53853
|
-
deployedAt:
|
|
53854
|
-
size:
|
|
53855
|
-
hash: "
|
|
53856
|
-
validatorWalletAddress: "
|
|
54070
|
+
deployedAt: 1790246239599,
|
|
54071
|
+
size: 101228,
|
|
54072
|
+
hash: "2ed25eca6cc80a43061b7ad119737af48158fdb61d59f10cd06cea51b607f112",
|
|
54073
|
+
validatorWalletAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C",
|
|
53857
54074
|
pkp: {
|
|
53858
54075
|
publicKey: "0x043616787c5432415c24378c4ef48de2bcd6bb7b575b837e3cff09171802662da7105d79586c7659677a0ecbaddac4cce06cb2a11f69a16fa0c4d7002ac7d51a4d",
|
|
53859
|
-
ethAddress: "
|
|
54076
|
+
ethAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C"
|
|
53860
54077
|
}
|
|
53861
54078
|
},
|
|
53862
54079
|
liquidationValidator: {
|
|
53863
|
-
cid: "
|
|
54080
|
+
cid: "QmTs2w8gfAwWZLbzJZg2CZmiLhVXS5kbMgaj42Zuxfodpb",
|
|
53864
54081
|
authorizedCidHex: cidToHex(
|
|
53865
|
-
"
|
|
54082
|
+
"QmTs2w8gfAwWZLbzJZg2CZmiLhVXS5kbMgaj42Zuxfodpb"
|
|
53866
54083
|
),
|
|
53867
54084
|
name: "Liquidation Validator",
|
|
53868
54085
|
description: "Production Liquidation Validator",
|
|
53869
54086
|
version: "1.2.1",
|
|
53870
54087
|
deployed: true,
|
|
53871
|
-
deployedAt:
|
|
53872
|
-
size:
|
|
53873
|
-
hash: "
|
|
53874
|
-
validatorWalletAddress: "
|
|
54088
|
+
deployedAt: 1790246247904,
|
|
54089
|
+
size: 70308,
|
|
54090
|
+
hash: "582ccf0ec7f715195e20fdc885996743cb42125b64173424e360ee63db62bbd8",
|
|
54091
|
+
validatorWalletAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C",
|
|
53875
54092
|
pkp: {
|
|
53876
54093
|
publicKey: "0x041a241de58976c13e3d7ca5a18e494f7330151e3818706135d50176e78ffb673e58b11f0b67a87c73fade6c6b27d6e7a7377ea9f4c10bf31880f1d725f18cc6f8",
|
|
53877
|
-
ethAddress: "
|
|
54094
|
+
ethAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C"
|
|
53878
54095
|
}
|
|
53879
54096
|
},
|
|
53880
54097
|
priceOracle: {
|
|
@@ -53889,28 +54106,28 @@ var require_pkg_src2 = __commonJS2({
|
|
|
53889
54106
|
deployedAt: 1781116663270,
|
|
53890
54107
|
size: 8695,
|
|
53891
54108
|
hash: "ba20ade60a7fa5acd80dadfafa179c507388cfe6ce48a22a672d70b317ffcc74",
|
|
53892
|
-
validatorWalletAddress: "
|
|
54109
|
+
validatorWalletAddress: "0xefb258d455a31d061bbeb3de3d2143bdfcb67a6c",
|
|
53893
54110
|
pkp: {
|
|
53894
54111
|
publicKey: "0x043beaa1da47875601a8d6f430b1438ee2d4732eefd06e5c63a474bbdaf9e7df1797b1b951e041b627c2bf839788164825324c9cbd1e2d6f740fdd4bff69b1900b",
|
|
53895
|
-
ethAddress: "
|
|
54112
|
+
ethAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C"
|
|
53896
54113
|
}
|
|
53897
54114
|
},
|
|
53898
54115
|
loanVaultBtcBalance: {
|
|
53899
|
-
cid: "
|
|
54116
|
+
cid: "QmZ27xCzuoaAhWxRsMPsUQkp45a8WPBb21uhxwchw3LG5W",
|
|
53900
54117
|
authorizedCidHex: cidToHex(
|
|
53901
|
-
"
|
|
54118
|
+
"QmZ27xCzuoaAhWxRsMPsUQkp45a8WPBb21uhxwchw3LG5W"
|
|
53902
54119
|
),
|
|
53903
54120
|
name: "Loan Vault Btc Balance",
|
|
53904
54121
|
description: "Production Loan Vault Btc Balance",
|
|
53905
54122
|
version: "1.2.1",
|
|
53906
54123
|
deployed: true,
|
|
53907
|
-
deployedAt:
|
|
53908
|
-
size:
|
|
53909
|
-
hash: "
|
|
53910
|
-
validatorWalletAddress: "
|
|
54124
|
+
deployedAt: 1790179961079,
|
|
54125
|
+
size: 60046,
|
|
54126
|
+
hash: "922e86c0a667fe0c0945771f84aa6b9fe08be9c96dd2f73a9c5cb257d24e22b0",
|
|
54127
|
+
validatorWalletAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C",
|
|
53911
54128
|
pkp: {
|
|
53912
54129
|
publicKey: "0x043616787c5432415c24378c4ef48de2bcd6bb7b575b837e3cff09171802662da7105d79586c7659677a0ecbaddac4cce06cb2a11f69a16fa0c4d7002ac7d51a4d",
|
|
53913
|
-
ethAddress: "
|
|
54130
|
+
ethAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C"
|
|
53914
54131
|
}
|
|
53915
54132
|
},
|
|
53916
54133
|
// btc-address-balance (Option B) — address-only signed total balance via
|
|
@@ -53920,21 +54137,21 @@ var require_pkg_src2 = __commonJS2({
|
|
|
53920
54137
|
// Requires BitcoinProviderRegistry.addAllowedCid(chainId, keccak256(utf8(cid)))
|
|
53921
54138
|
// on each target chain (the action decrypts registry slots). No OAR entry.
|
|
53922
54139
|
btcAddressBalance: {
|
|
53923
|
-
cid: "
|
|
54140
|
+
cid: "QmVVjB6zCBiXFKffhQPYUAZhj7TXduuvcrPqKtHa3DMXhN",
|
|
53924
54141
|
authorizedCidHex: cidToHex(
|
|
53925
|
-
"
|
|
54142
|
+
"QmVVjB6zCBiXFKffhQPYUAZhj7TXduuvcrPqKtHa3DMXhN"
|
|
53926
54143
|
),
|
|
53927
54144
|
name: "Btc Address Balance",
|
|
53928
54145
|
description: "Address-only signed total BTC balance via registry consensus (no positionId, no price)",
|
|
53929
54146
|
version: "0.2.1",
|
|
53930
54147
|
deployed: true,
|
|
53931
|
-
deployedAt:
|
|
53932
|
-
size:
|
|
53933
|
-
hash: "
|
|
53934
|
-
validatorWalletAddress: "
|
|
54148
|
+
deployedAt: 1790179971315,
|
|
54149
|
+
size: 30295,
|
|
54150
|
+
hash: "2c67d9cfa4d50e835fbb28ae50e80217ceb2be3bb862c89290aadf43fdc739c9",
|
|
54151
|
+
validatorWalletAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C",
|
|
53935
54152
|
pkp: {
|
|
53936
54153
|
publicKey: "0x0498cbb31facfa26e3ec83ccdabfe4fe341ca0282e0c3cb81da7113723b9726e1e49efa92165cc3faa66ced4454cea56dbab12267852d6525a55d7c4f128b912cd",
|
|
53937
|
-
ethAddress: "
|
|
54154
|
+
ethAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C"
|
|
53938
54155
|
}
|
|
53939
54156
|
},
|
|
53940
54157
|
alwaysSigner: {
|
|
@@ -53964,48 +54181,48 @@ var require_pkg_src2 = __commonJS2({
|
|
|
53964
54181
|
hash: "03ee5be239c91c735d2c95db89a0d1b77e602cfc18af8eb64b3281fddcd90a72"
|
|
53965
54182
|
},
|
|
53966
54183
|
agentModuleExecutor: {
|
|
53967
|
-
cid: "
|
|
54184
|
+
cid: "QmSwPPvQhT7UhcuVA2m3UxGhVj5WqMpDvYNKU1228QLFsX",
|
|
53968
54185
|
authorizedCidHex: cidToHex(
|
|
53969
|
-
"
|
|
54186
|
+
"QmSwPPvQhT7UhcuVA2m3UxGhVj5WqMpDvYNKU1228QLFsX"
|
|
53970
54187
|
),
|
|
53971
54188
|
name: "Agent Module Executor",
|
|
53972
54189
|
description: "Production Agent Module Executor",
|
|
53973
54190
|
version: "1.1.1",
|
|
53974
54191
|
deployed: true,
|
|
53975
|
-
deployedAt:
|
|
53976
|
-
size:
|
|
53977
|
-
hash: "
|
|
54192
|
+
deployedAt: 1790179978959,
|
|
54193
|
+
size: 14688,
|
|
54194
|
+
hash: "8edb9b12c784c8d7d153cce97235584c24665a788767ae68713dce91109ab35e"
|
|
53978
54195
|
},
|
|
53979
54196
|
staleSpendRecoveryValidator: {
|
|
53980
|
-
cid: "
|
|
54197
|
+
cid: "Qmarj59zdSSgivkimryrdvnyZqH5YpTimKj1LivXNBHmNz",
|
|
53981
54198
|
authorizedCidHex: cidToHex(
|
|
53982
|
-
"
|
|
54199
|
+
"Qmarj59zdSSgivkimryrdvnyZqH5YpTimKj1LivXNBHmNz"
|
|
53983
54200
|
),
|
|
53984
54201
|
name: "Stale Spend Recovery Validator",
|
|
53985
54202
|
description: "Production Stale Spend Recovery Validator",
|
|
53986
54203
|
version: "1.1.2",
|
|
53987
54204
|
deployed: true,
|
|
53988
|
-
deployedAt:
|
|
53989
|
-
size:
|
|
53990
|
-
hash: "
|
|
53991
|
-
validatorWalletAddress: "
|
|
54205
|
+
deployedAt: 1790246256280,
|
|
54206
|
+
size: 48143,
|
|
54207
|
+
hash: "ec9236bcbe0af24d3e1844791fc8fe37371bbecd8ce95d02e13f7c6e1fc7d94c",
|
|
54208
|
+
validatorWalletAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C",
|
|
53992
54209
|
pkp: {
|
|
53993
54210
|
publicKey: "0x046da0ad6da7dd4a0063cbeac6f2bdb6a9889c2178b23470833356a8ee5630f7f0eee0db348d9d9aaaadd23eccf0063c8f68ee5e446abe30b882bf1de4c932bc21",
|
|
53994
|
-
ethAddress: "
|
|
54211
|
+
ethAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C"
|
|
53995
54212
|
}
|
|
53996
54213
|
},
|
|
53997
54214
|
btcUtxoInvalidator: {
|
|
53998
|
-
cid: "
|
|
54215
|
+
cid: "QmbS44bGcmKYF64Cu35qzsk9sxiU4Umde8Z3q24ZnEbQvX",
|
|
53999
54216
|
authorizedCidHex: cidToHex(
|
|
54000
|
-
"
|
|
54217
|
+
"QmbS44bGcmKYF64Cu35qzsk9sxiU4Umde8Z3q24ZnEbQvX"
|
|
54001
54218
|
),
|
|
54002
54219
|
name: "Btc Utxo Invalidator",
|
|
54003
54220
|
description: "Production Btc Utxo Invalidator",
|
|
54004
54221
|
version: "1.0.0",
|
|
54005
54222
|
deployed: true,
|
|
54006
|
-
deployedAt:
|
|
54007
|
-
size:
|
|
54008
|
-
hash: "
|
|
54223
|
+
deployedAt: 1790246264563,
|
|
54224
|
+
size: 69219,
|
|
54225
|
+
hash: "bda048d8cd6b5a39c2774bcf1320e82d1eea935c2a521006fb8b887e13b6dd8d"
|
|
54009
54226
|
}
|
|
54010
54227
|
};
|
|
54011
54228
|
function getDeploymentsForNetwork(network) {
|
|
@@ -54773,7 +54990,10 @@ ${errorReport}`);
|
|
|
54773
54990
|
BTCSpendAuthorizer: "0xfBbF108486fa07F1B06a811C5b66ed68DD9c508a",
|
|
54774
54991
|
BitcoinProviderRegistry: "0x4ab3Fb96e02893Ed6FAa61bad1918390c8DbbFFC",
|
|
54775
54992
|
LITActionValidator: "0xD2c5d59c2CC5c409AC65ce0A817236aeC6869512",
|
|
54776
|
-
PositionDelegateRegistry: "0xf0aa2678aD4F60f49e8F7725089B5E86B7F8FE4C"
|
|
54993
|
+
PositionDelegateRegistry: "0xf0aa2678aD4F60f49e8F7725089B5E86B7F8FE4C",
|
|
54994
|
+
TermManagerModule: "0xDB99CdF883ffa38acD099bC39F8d1f4508c9239E",
|
|
54995
|
+
UCDController: "0x4b4f8063048bCD59D469219E3f07C6aaDF4f6157",
|
|
54996
|
+
LiquidationManagerModule: "0x74B28695352E7bf736D6c9F76ccb7B4439477De9"
|
|
54777
54997
|
},
|
|
54778
54998
|
11155111: {
|
|
54779
54999
|
PositionManager: "0x68e0507D982AEBF1D1C1Af8FBbd842327e2deeFF",
|
|
@@ -54781,7 +55001,10 @@ ${errorReport}`);
|
|
|
54781
55001
|
BTCSpendAuthorizer: "0xd7E9Eb5eE53f1d9ee55Dc162bBC7486bE437B6bD",
|
|
54782
55002
|
BitcoinProviderRegistry: "0xbfA0c48B070D0a9A9CD27469AeacFD2d4261cEE2",
|
|
54783
55003
|
LITActionValidator: "0x54eECd7C90F8A8fac27749Ba30BbE8AFBAccc856",
|
|
54784
|
-
PositionDelegateRegistry: "0x482369De283622E7b05731875ec137d4E3D208F9"
|
|
55004
|
+
PositionDelegateRegistry: "0x482369De283622E7b05731875ec137d4E3D208F9",
|
|
55005
|
+
TermManagerModule: "0x94Adc6F9558368B1482197584f1fc7133Ecf835b",
|
|
55006
|
+
UCDController: "0x360Bde4e489ee94E26601B206932De09EE60FF04",
|
|
55007
|
+
LiquidationManagerModule: "0xC4AB00f39e7ceD812F5C67058C9fa44e15d40e76"
|
|
54785
55008
|
}
|
|
54786
55009
|
};
|
|
54787
55010
|
function getPinnedContractAddresses(chainId) {
|
|
@@ -54967,10 +55190,10 @@ ${errorReport}`);
|
|
|
54967
55190
|
};
|
|
54968
55191
|
}
|
|
54969
55192
|
const ratioBigInt = collateralValueUsd * UCD_TOKEN_DECIMALS * 10000n / ucdDebt;
|
|
54970
|
-
const
|
|
55193
|
+
const collateralRatioBps2 = Number(ratioBigInt);
|
|
54971
55194
|
return {
|
|
54972
55195
|
collateralValueUsd,
|
|
54973
|
-
collateralRatioBps
|
|
55196
|
+
collateralRatioBps: collateralRatioBps2
|
|
54974
55197
|
};
|
|
54975
55198
|
}
|
|
54976
55199
|
function hasSufficientCollateralForDebt(collateralValueUsd, currentDebt, additionalDebt, requiredRatioBps) {
|
|
@@ -55824,6 +56047,17 @@ ${auth.clientId}`;
|
|
|
55824
56047
|
);
|
|
55825
56048
|
}
|
|
55826
56049
|
}
|
|
56050
|
+
var TIP_READ_FAILURE_PREFIX = "Bitcoin tip-height read failed";
|
|
56051
|
+
var BitcoinTipUnreadableError = class extends Error {
|
|
56052
|
+
constructor(message) {
|
|
56053
|
+
super(message);
|
|
56054
|
+
this.isBitcoinTipUnreadable = true;
|
|
56055
|
+
this.name = "BitcoinTipUnreadableError";
|
|
56056
|
+
}
|
|
56057
|
+
};
|
|
56058
|
+
function isBitcoinTipUnreadableError(error) {
|
|
56059
|
+
return typeof error === "object" && error !== null && error.isBitcoinTipUnreadable === true;
|
|
56060
|
+
}
|
|
55827
56061
|
var BitcoinDataProvider = class {
|
|
55828
56062
|
constructor(config) {
|
|
55829
56063
|
this.config = config;
|
|
@@ -56275,27 +56509,12 @@ ${auth.clientId}`;
|
|
|
56275
56509
|
if (!data.status.confirmed || !data.status.block_height) {
|
|
56276
56510
|
return { txid: data.txid ?? txid, confirmations: 0 };
|
|
56277
56511
|
}
|
|
56278
|
-
|
|
56279
|
-
|
|
56280
|
-
|
|
56281
|
-
|
|
56282
|
-
|
|
56283
|
-
|
|
56284
|
-
return { txid: data.txid ?? txid, confirmations: 1 };
|
|
56285
|
-
}
|
|
56286
|
-
const tipBody = (await tipResp.text()).trim();
|
|
56287
|
-
const tipHeight = Number.parseInt(tipBody, 10);
|
|
56288
|
-
if (!Number.isFinite(tipHeight) || tipHeight <= 0) {
|
|
56289
|
-
return { txid: data.txid ?? txid, confirmations: 1 };
|
|
56290
|
-
}
|
|
56291
|
-
const depth = tipHeight - data.status.block_height + 1;
|
|
56292
|
-
return {
|
|
56293
|
-
txid: data.txid ?? txid,
|
|
56294
|
-
confirmations: depth > 0 ? depth : 0
|
|
56295
|
-
};
|
|
56296
|
-
} catch {
|
|
56297
|
-
return { txid: data.txid ?? txid, confirmations: 1 };
|
|
56298
|
-
}
|
|
56512
|
+
const tipHeight = await this.fetchTipHeight(controller.signal);
|
|
56513
|
+
const depth = tipHeight - data.status.block_height + 1;
|
|
56514
|
+
return {
|
|
56515
|
+
txid: data.txid ?? txid,
|
|
56516
|
+
confirmations: depth > 0 ? depth : 0
|
|
56517
|
+
};
|
|
56299
56518
|
}
|
|
56300
56519
|
return null;
|
|
56301
56520
|
} catch (error) {
|
|
@@ -56303,12 +56522,55 @@ ${auth.clientId}`;
|
|
|
56303
56522
|
if (isAbortError(error)) {
|
|
56304
56523
|
throw new Error(`Request timeout after ${this.timeout}ms`);
|
|
56305
56524
|
}
|
|
56525
|
+
if (isBitcoinTipUnreadableError(error)) {
|
|
56526
|
+
throw error;
|
|
56527
|
+
}
|
|
56306
56528
|
if (getUnknownErrorMessage(error).includes("404")) {
|
|
56307
56529
|
return null;
|
|
56308
56530
|
}
|
|
56309
56531
|
throw error;
|
|
56310
56532
|
}
|
|
56311
56533
|
}
|
|
56534
|
+
/**
|
|
56535
|
+
* Current chain tip height from THIS provider — or throw.
|
|
56536
|
+
*
|
|
56537
|
+
* Every exit is a throw naming the provider and the precise failure, because
|
|
56538
|
+
* the only alternative is inventing a confirmation depth (see the call site).
|
|
56539
|
+
* The single `try` exists solely to attach that name to a transport-level
|
|
56540
|
+
* rejection (DNS, TLS, connection reset, abort); it re-throws the cause
|
|
56541
|
+
* verbatim inside the message and never substitutes a value — authorized for
|
|
56542
|
+
* this case by the Batch 2 plan, §C2.
|
|
56543
|
+
*
|
|
56544
|
+
* @param signal - The caller's AbortSignal, so this read shares the same
|
|
56545
|
+
* timeout budget as the transaction fetch it serves.
|
|
56546
|
+
*/
|
|
56547
|
+
async fetchTipHeight(signal) {
|
|
56548
|
+
const endpoint = `${this.config.providerUrl}/blocks/tip/height`;
|
|
56549
|
+
let tipResp;
|
|
56550
|
+
try {
|
|
56551
|
+
tipResp = await fetch(endpoint, {
|
|
56552
|
+
signal,
|
|
56553
|
+
headers: await this.withAuth()
|
|
56554
|
+
});
|
|
56555
|
+
} catch (error) {
|
|
56556
|
+
throw new BitcoinTipUnreadableError(
|
|
56557
|
+
`${TIP_READ_FAILURE_PREFIX}: GET ${endpoint} threw \u2014 ${getUnknownErrorMessage(error)}`
|
|
56558
|
+
);
|
|
56559
|
+
}
|
|
56560
|
+
if (!tipResp.ok) {
|
|
56561
|
+
throw new BitcoinTipUnreadableError(
|
|
56562
|
+
`${TIP_READ_FAILURE_PREFIX}: GET ${endpoint} \u2192 ${tipResp.status} ${tipResp.statusText}`
|
|
56563
|
+
);
|
|
56564
|
+
}
|
|
56565
|
+
const tipBody = (await tipResp.text()).trim();
|
|
56566
|
+
const tipHeight = Number.parseInt(tipBody, 10);
|
|
56567
|
+
if (!Number.isFinite(tipHeight) || tipHeight <= 0) {
|
|
56568
|
+
throw new BitcoinTipUnreadableError(
|
|
56569
|
+
`${TIP_READ_FAILURE_PREFIX}: GET ${endpoint} returned an unusable tip height "${tipBody.slice(0, 64)}"`
|
|
56570
|
+
);
|
|
56571
|
+
}
|
|
56572
|
+
return tipHeight;
|
|
56573
|
+
}
|
|
56312
56574
|
/**
|
|
56313
56575
|
* Get outputs (vouts) of a Bitcoin transaction
|
|
56314
56576
|
*
|
|
@@ -56946,10 +57208,13 @@ ${auth.clientId}`;
|
|
|
56946
57208
|
* only on unanimity. The confirmed-balance consensus the validators run
|
|
56947
57209
|
* covers `chain_stats` only, so without this the primary provider alone
|
|
56948
57210
|
* could fabricate an unconfirmed UTXO plus a self-consistent parent proof
|
|
56949
|
-
* and inflate the signed balance. Any
|
|
56950
|
-
*
|
|
56951
|
-
*
|
|
56952
|
-
*
|
|
57211
|
+
* and inflate the signed balance. Any verdict disagreement THROWS
|
|
57212
|
+
* (fail-closed) — exclusion on a suppressed proof would deflate the balance
|
|
57213
|
+
* and open a wrongful-liquidation window, so neither direction may proceed
|
|
57214
|
+
* without agreement. A provider that cannot state the chain tip — and only
|
|
57215
|
+
* that failure — is dropped from the quorum rather than aborting the read (it
|
|
57216
|
+
* never counts as agreeing), and falling below `minConsensusProviders`
|
|
57217
|
+
* survivors throws — see `verifyParentIsSelfSpendConsensus`.
|
|
56953
57218
|
*
|
|
56954
57219
|
* The same per-provider `/tx` fetch also returns the parent's outputs, and
|
|
56955
57220
|
* every provider must corroborate each claimed UTXO (index, vault address,
|
|
@@ -57044,10 +57309,26 @@ ${auth.clientId}`;
|
|
|
57044
57309
|
}
|
|
57045
57310
|
/**
|
|
57046
57311
|
* Run the self-spend proof against every configured provider and require
|
|
57047
|
-
* unanimity
|
|
57048
|
-
*
|
|
57312
|
+
* unanimity AMONG THE PROVIDERS THAT ANSWERED. Fail-closed on disagreement:
|
|
57313
|
+
* a verdict mismatch throws and aborts the balance calculation — see
|
|
57049
57314
|
* classifySelfChange for why exclusion is not a safe fallback here.
|
|
57050
57315
|
*
|
|
57316
|
+
* Quorum semantics (2026-09-23, plan C2). ONE failure class is tolerated: a
|
|
57317
|
+
* provider that could not state the chain tip (`BitcoinTipUnreadableError`).
|
|
57318
|
+
* It is ABSENT from the quorum — never counted as agreeing, never allowed to
|
|
57319
|
+
* decide the verdict — and the policy floor, not "at least one", decides when
|
|
57320
|
+
* that absence is fatal: below `minConsensusProviders` surviving readings
|
|
57321
|
+
* there is no cross-check left to trust, and the read fails loudly naming
|
|
57322
|
+
* every provider that dropped out.
|
|
57323
|
+
*
|
|
57324
|
+
* Why only that class. `getTransaction` now throws on an unreadable tip
|
|
57325
|
+
* instead of fabricating `confirmations: 1`; without this carve-out one flaky
|
|
57326
|
+
* `/blocks/tip/height` endpoint would take every balance and spend path down
|
|
57327
|
+
* with it. Every OTHER failure remains fatal, as before: a provider that
|
|
57328
|
+
* answers "I have never seen that transaction" is making a claim about the
|
|
57329
|
+
* chain rather than suffering an outage, and that shape is precisely the
|
|
57330
|
+
* fabricated-UTXO signature the fail-closed rule exists to catch.
|
|
57331
|
+
*
|
|
57051
57332
|
* When the parent IS a unanimous self-spend, every provider's view of the
|
|
57052
57333
|
* parent's OUTPUTS must additionally corroborate the primary's claimed
|
|
57053
57334
|
* UTXOs (index exists, pays the vault, exact value). Without this, a
|
|
@@ -57072,32 +57353,52 @@ ${auth.clientId}`;
|
|
|
57072
57353
|
)
|
|
57073
57354
|
)
|
|
57074
57355
|
);
|
|
57075
|
-
const
|
|
57076
|
-
|
|
57077
|
-
|
|
57078
|
-
|
|
57079
|
-
|
|
57356
|
+
const answered = [];
|
|
57357
|
+
const absences = [];
|
|
57358
|
+
const failures = [];
|
|
57359
|
+
settled.forEach((result, i) => {
|
|
57360
|
+
if (result.status === "fulfilled") {
|
|
57361
|
+
answered.push({ index: i, evaluation: result.value });
|
|
57362
|
+
return;
|
|
57363
|
+
}
|
|
57364
|
+
const described = `${providerName(i)} \u2192 ${result.reason?.message ?? String(result.reason)}`;
|
|
57365
|
+
if (isBitcoinTipUnreadableError(result.reason)) {
|
|
57366
|
+
absences.push(described);
|
|
57367
|
+
return;
|
|
57368
|
+
}
|
|
57369
|
+
failures.push(described);
|
|
57370
|
+
});
|
|
57080
57371
|
if (failures.length > 0) {
|
|
57081
57372
|
throw new Error(
|
|
57082
57373
|
`Self-change classification failed for tx ${parentTxid} on ${failures.length}/${providerConfigs.length} provider(s): ${failures.join("; ")}`
|
|
57083
57374
|
);
|
|
57084
57375
|
}
|
|
57085
|
-
const
|
|
57086
|
-
|
|
57087
|
-
|
|
57088
|
-
|
|
57089
|
-
|
|
57090
|
-
|
|
57376
|
+
const floor = Math.max(1, this.minConsensusProviders);
|
|
57377
|
+
if (answered.length < floor) {
|
|
57378
|
+
throw new Error(
|
|
57379
|
+
`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("; ")}`
|
|
57380
|
+
);
|
|
57381
|
+
}
|
|
57382
|
+
if (absences.length > 0) {
|
|
57383
|
+
litDebugLog(
|
|
57384
|
+
`[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("; ")}`
|
|
57385
|
+
);
|
|
57386
|
+
}
|
|
57387
|
+
const first = answered[0];
|
|
57388
|
+
const disagreements = answered.slice(1).filter((a) => a.evaluation.selfSpend !== first.evaluation.selfSpend).map(
|
|
57389
|
+
(a) => `${providerName(first.index)}=${first.evaluation.selfSpend} vs ${providerName(a.index)}=${a.evaluation.selfSpend}`
|
|
57091
57390
|
);
|
|
57092
57391
|
if (disagreements.length > 0) {
|
|
57093
57392
|
throw new Error(
|
|
57094
57393
|
`Self-change consensus mismatch for tx ${parentTxid}: ${disagreements.join("; ")}. A provider may be compromised or out of sync; refusing to sign.`
|
|
57095
57394
|
);
|
|
57096
57395
|
}
|
|
57097
|
-
if (!
|
|
57396
|
+
if (!first.evaluation.selfSpend) {
|
|
57098
57397
|
return false;
|
|
57099
57398
|
}
|
|
57100
|
-
const outputMismatches =
|
|
57399
|
+
const outputMismatches = answered.map(
|
|
57400
|
+
(a) => a.evaluation.outputMismatch ? `${providerName(a.index)} \u2192 ${a.evaluation.outputMismatch}` : null
|
|
57401
|
+
).filter((m) => m !== null);
|
|
57101
57402
|
if (outputMismatches.length > 0) {
|
|
57102
57403
|
throw new Error(
|
|
57103
57404
|
`Self-change output claim mismatch for tx ${parentTxid}: ${outputMismatches.join("; ")}. The reported UTXO set contradicts the parent transaction; refusing to sign.`
|
|
@@ -57340,16 +57641,6 @@ ${auth.clientId}`;
|
|
|
57340
57641
|
minConfirmations
|
|
57341
57642
|
);
|
|
57342
57643
|
const authorizedSpends = await this.getAuthorizedSpendsFromContract(positionId);
|
|
57343
|
-
for (const spend of authorizedSpends) {
|
|
57344
|
-
const utxoStillExists = utxoSet.utxos.some(
|
|
57345
|
-
(utxo) => utxo.txid === spend.txid && utxo.vout === spend.vout
|
|
57346
|
-
);
|
|
57347
|
-
if (utxoStillExists) {
|
|
57348
|
-
throw new Error(
|
|
57349
|
-
`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.`
|
|
57350
|
-
);
|
|
57351
|
-
}
|
|
57352
|
-
}
|
|
57353
57644
|
const authorizedBalance = authorizedSpends.reduce(
|
|
57354
57645
|
(sum, spend) => sum + spend.satoshis,
|
|
57355
57646
|
0n
|
|
@@ -57645,7 +57936,13 @@ ${auth.clientId}`;
|
|
|
57645
57936
|
allowDevSinglePriceProvider: false,
|
|
57646
57937
|
minBitcoinBalanceConfirmations: 1,
|
|
57647
57938
|
minBitcoinSpendConfirmations: 1,
|
|
57648
|
-
|
|
57939
|
+
// 2 since 2026-09-23. It was 1 because Sepolia ran a single faucet provider
|
|
57940
|
+
// "by design", so the consensus floor was documented as a mainnet-only
|
|
57941
|
+
// guarantee. The registry now holds two, and leaving the floor at 1 meant
|
|
57942
|
+
// Sepolia could never exercise the multi-provider agreement the stale-spend
|
|
57943
|
+
// and balance paths rely on — the one environment where that logic is
|
|
57944
|
+
// supposed to be proved before mainnet.
|
|
57945
|
+
minConsensusProviders: 2
|
|
57649
57946
|
},
|
|
57650
57947
|
[
|
|
57651
57948
|
"ethereum"
|
|
@@ -57954,7 +58251,6 @@ function getSepoliaConfig() {
|
|
|
57954
58251
|
feeRecipientRegistry: SEPOLIA_CONTRACTS.FeeRecipientRegistry || "",
|
|
57955
58252
|
positionDelegateRegistry: SEPOLIA_CONTRACTS.PositionDelegateRegistry || "",
|
|
57956
58253
|
bitcoinWithdrawalAddressRegistry: SEPOLIA_CONTRACTS.BitcoinWithdrawalAddressRegistry || "",
|
|
57957
|
-
carryAgentRegistry: SEPOLIA_CONTRACTS.CarryAgentRegistry || "",
|
|
57958
58254
|
agentDelegationRegistry: SEPOLIA_CONTRACTS.AgentDelegationRegistry || "",
|
|
57959
58255
|
dhAgentDelegate: SEPOLIA_CONTRACTS.DHAgentDelegate || "",
|
|
57960
58256
|
agentModuleFactory: SEPOLIA_CONTRACTS.AgentModuleFactory || ""
|
|
@@ -58008,7 +58304,6 @@ function getMainnetConfig() {
|
|
|
58008
58304
|
feeRecipientRegistry: MAINNET_CONTRACTS.FeeRecipientRegistry || "",
|
|
58009
58305
|
positionDelegateRegistry: MAINNET_CONTRACTS.PositionDelegateRegistry || "",
|
|
58010
58306
|
bitcoinWithdrawalAddressRegistry: MAINNET_CONTRACTS.BitcoinWithdrawalAddressRegistry || "",
|
|
58011
|
-
carryAgentRegistry: MAINNET_CONTRACTS.CarryAgentRegistry || "",
|
|
58012
58307
|
agentDelegationRegistry: MAINNET_CONTRACTS.AgentDelegationRegistry || "",
|
|
58013
58308
|
dhAgentDelegate: MAINNET_CONTRACTS.DHAgentDelegate || "",
|
|
58014
58309
|
// Empty on mainnet until the factory is deployed there — the ceremony is Sepolia-only.
|
|
@@ -59081,6 +59376,51 @@ async function resolveAuthorizationInput(provider, signer, ctx) {
|
|
|
59081
59376
|
}
|
|
59082
59377
|
return { timestamp: result.timestamp, signature: result.signature };
|
|
59083
59378
|
}
|
|
59379
|
+
var BECH32_CHARSET = "qpzry9x8gf2tvdw0s3jn54khce6mua7l";
|
|
59380
|
+
function segwitProgramShape(address) {
|
|
59381
|
+
const lower2 = address.trim().toLowerCase();
|
|
59382
|
+
if (!/^(bc1|tb1|bcrt1)/.test(lower2))
|
|
59383
|
+
return null;
|
|
59384
|
+
const sep = lower2.lastIndexOf("1");
|
|
59385
|
+
const data = lower2.slice(sep + 1);
|
|
59386
|
+
if (data.length < 8)
|
|
59387
|
+
return null;
|
|
59388
|
+
const version2 = BECH32_CHARSET.indexOf(data[0]);
|
|
59389
|
+
if (version2 < 0)
|
|
59390
|
+
return null;
|
|
59391
|
+
const programChars = data.length - 1 - 6;
|
|
59392
|
+
return { version: version2, programBytes: Math.floor(programChars * 5 / 8) };
|
|
59393
|
+
}
|
|
59394
|
+
function dustLimitForAddress(address) {
|
|
59395
|
+
const shape = segwitProgramShape(address);
|
|
59396
|
+
if (shape === null)
|
|
59397
|
+
return 546;
|
|
59398
|
+
if (shape.version === 0 && shape.programBytes === 20)
|
|
59399
|
+
return 294;
|
|
59400
|
+
if (shape.version === 0 && shape.programBytes === 32)
|
|
59401
|
+
return 330;
|
|
59402
|
+
if (shape.version === 1 && shape.programBytes === 32)
|
|
59403
|
+
return 330;
|
|
59404
|
+
return 546;
|
|
59405
|
+
}
|
|
59406
|
+
function destinationDustShortfall(targetAmount, networkFee, destination) {
|
|
59407
|
+
const limit = dustLimitForAddress(destination);
|
|
59408
|
+
return targetAmount - networkFee < limit ? limit : null;
|
|
59409
|
+
}
|
|
59410
|
+
function calculateMintFee(params) {
|
|
59411
|
+
const { mintAmount, mintTimestamp, originationFeeBps, previousExpiryAt, selectedTerm, totalTerm } = params;
|
|
59412
|
+
let mintFee = mintAmount * BigInt(originationFeeBps) / 10000n;
|
|
59413
|
+
if (previousExpiryAt > 0 && mintTimestamp < previousExpiryAt) {
|
|
59414
|
+
const tailSeconds = BigInt(previousExpiryAt) - BigInt(mintTimestamp);
|
|
59415
|
+
const originalTermMonths = totalTerm - selectedTerm;
|
|
59416
|
+
const originalTermSeconds = BigInt(
|
|
59417
|
+
originalTermMonths === 12 ? 365 * 86400 : originalTermMonths * 30 * 86400
|
|
59418
|
+
);
|
|
59419
|
+
const tailFee = tailSeconds * BigInt(originationFeeBps) * mintAmount / (10000n * originalTermSeconds);
|
|
59420
|
+
mintFee = mintFee + tailFee;
|
|
59421
|
+
}
|
|
59422
|
+
return mintFee;
|
|
59423
|
+
}
|
|
59084
59424
|
function baseMintFeeWei(mintAmountWei, originationFeeBps) {
|
|
59085
59425
|
if (mintAmountWei < 0n)
|
|
59086
59426
|
throw new Error("baseMintFeeWei: mintAmountWei cannot be negative");
|
|
@@ -59099,20 +59439,34 @@ function debtAfterMintExceedsLoanCap(params) {
|
|
|
59099
59439
|
}
|
|
59100
59440
|
return currentDebtWei + mintAmountWei + mintFeeWei > maxLoanWei;
|
|
59101
59441
|
}
|
|
59102
|
-
function
|
|
59103
|
-
|
|
59104
|
-
|
|
59105
|
-
throw new Error("maxPrincipalWithinLoanCap: amounts cannot be negative");
|
|
59442
|
+
function collateralRatioBps(sats, price8, debtWei) {
|
|
59443
|
+
if (sats < 0n || price8 < 0n) {
|
|
59444
|
+
throw new Error("collateralRatioBps: sats and price cannot be negative");
|
|
59106
59445
|
}
|
|
59107
|
-
if (
|
|
59108
|
-
throw new Error(
|
|
59109
|
-
`maxPrincipalWithinLoanCap: originationFeeBps must be an integer in [0, 10000] (got ${String(originationFeeBps)})`
|
|
59110
|
-
);
|
|
59446
|
+
if (debtWei <= 0n) {
|
|
59447
|
+
throw new Error("collateralRatioBps: debt must be positive");
|
|
59111
59448
|
}
|
|
59112
|
-
|
|
59113
|
-
|
|
59114
|
-
|
|
59115
|
-
|
|
59449
|
+
return sats * price8 * 100n * 10000n / debtWei;
|
|
59450
|
+
}
|
|
59451
|
+
function collateralRatioPercentString(sats, price8, debtWei) {
|
|
59452
|
+
const bps = collateralRatioBps(sats, price8, debtWei);
|
|
59453
|
+
return `${bps / 100n}.${(bps % 100n).toString().padStart(2, "0")}`;
|
|
59454
|
+
}
|
|
59455
|
+
function maxPrincipalForFee(room, fee) {
|
|
59456
|
+
if (room < 0n)
|
|
59457
|
+
throw new Error("maxPrincipalForFee: room cannot be negative");
|
|
59458
|
+
if (fee(0n) !== 0n)
|
|
59459
|
+
throw new Error("maxPrincipalForFee: fee(0) must be 0");
|
|
59460
|
+
let lo = 0n;
|
|
59461
|
+
let hi = room;
|
|
59462
|
+
while (lo < hi) {
|
|
59463
|
+
const mid = (lo + hi + 1n) / 2n;
|
|
59464
|
+
if (mid + fee(mid) <= room)
|
|
59465
|
+
lo = mid;
|
|
59466
|
+
else
|
|
59467
|
+
hi = mid - 1n;
|
|
59468
|
+
}
|
|
59469
|
+
return lo;
|
|
59116
59470
|
}
|
|
59117
59471
|
function buildLoginDomain(chainId) {
|
|
59118
59472
|
return {
|
|
@@ -71275,9 +71629,17 @@ async function mintAgentPkp(params) {
|
|
|
71275
71629
|
}
|
|
71276
71630
|
var AGENT_STATUS = { None: 0, Active: 1, Revoked: 2 };
|
|
71277
71631
|
function planAgentBinding(params) {
|
|
71278
|
-
const { isActive, record, nowSeconds } = params;
|
|
71632
|
+
const { isActive, paused, record, nowSeconds } = params;
|
|
71633
|
+
if (typeof paused !== "boolean") {
|
|
71634
|
+
throw new Error("planAgentBinding: `paused` must be read from the registry (boolean required)");
|
|
71635
|
+
}
|
|
71279
71636
|
if (isActive)
|
|
71280
71637
|
return { kind: "reuse", agent: record.agent };
|
|
71638
|
+
if (paused) {
|
|
71639
|
+
throw new Error(
|
|
71640
|
+
"AgentDelegationRegistry is paused \u2014 agent delegation cannot be changed until it is unpaused."
|
|
71641
|
+
);
|
|
71642
|
+
}
|
|
71281
71643
|
const status = Number(record.status);
|
|
71282
71644
|
if (status === AGENT_STATUS.None || status === AGENT_STATUS.Revoked) {
|
|
71283
71645
|
return { kind: "register" };
|
|
@@ -71287,7 +71649,7 @@ function planAgentBinding(params) {
|
|
|
71287
71649
|
}
|
|
71288
71650
|
if (Number(record.validUntil) > nowSeconds) {
|
|
71289
71651
|
throw new Error(
|
|
71290
|
-
"AgentDelegationRegistry
|
|
71652
|
+
"AgentDelegationRegistry returned an inconsistent read (an unexpired, unpaused Active agent reported inactive); retry."
|
|
71291
71653
|
);
|
|
71292
71654
|
}
|
|
71293
71655
|
return { kind: "rotate" };
|
|
@@ -72456,7 +72818,7 @@ function normalizeBigNumberish(value) {
|
|
|
72456
72818
|
}
|
|
72457
72819
|
return value;
|
|
72458
72820
|
}
|
|
72459
|
-
if (typeof value === "object" && value !== null && "toString" in value && typeof value.toString === "function") {
|
|
72821
|
+
if (typeof value === "object" && value !== null && "toString" in value && typeof value.toString === "function" && value.toString !== Object.prototype.toString) {
|
|
72460
72822
|
const result = value.toString();
|
|
72461
72823
|
if (typeof result === "object" && result !== null && "_hex" in result) {
|
|
72462
72824
|
const resultObj = result;
|
|
@@ -73878,12 +74240,21 @@ var DiamondHandsSDK = class _DiamondHandsSDK {
|
|
|
73878
74240
|
maxLoanWei: maxLoanValueWei
|
|
73879
74241
|
})) {
|
|
73880
74242
|
const debtAfterWei = currentDebtWei + requestAmountWei + baseFeeWei;
|
|
74243
|
+
const suggestionStamp = calculateNextQuantumTimestamp();
|
|
74244
|
+
const room = maxLoanValueWei > currentDebtWei ? maxLoanValueWei - currentDebtWei : 0n;
|
|
73881
74245
|
const maxPrincipalUcd = Number(
|
|
73882
|
-
|
|
73883
|
-
|
|
73884
|
-
|
|
73885
|
-
|
|
73886
|
-
|
|
74246
|
+
maxPrincipalForFee(
|
|
74247
|
+
room,
|
|
74248
|
+
(principal) => calculateMintFee({
|
|
74249
|
+
mintAmount: principal,
|
|
74250
|
+
mintTimestamp: suggestionStamp,
|
|
74251
|
+
originationFeeBps: positionTerm.originationFeeBps,
|
|
74252
|
+
expiryAt: Number(position2.expiryAt),
|
|
74253
|
+
previousExpiryAt: Number(position2.previousExpiryAt),
|
|
74254
|
+
selectedTerm: Number(position2.selectedTerm),
|
|
74255
|
+
totalTerm: Number(position2.totalTerm)
|
|
74256
|
+
})
|
|
74257
|
+
) / BigInt(10 ** 18)
|
|
73887
74258
|
);
|
|
73888
74259
|
return {
|
|
73889
74260
|
success: false,
|
|
@@ -74961,11 +75332,7 @@ Message: ${causeMessage}${quantumContext}${loanCapDiagnostics}${mintDebtDiagnost
|
|
|
74961
75332
|
const debt = positionDetails.debt || positionDetails.ucdDebt || "0";
|
|
74962
75333
|
const btcPrice2 = litActionResult.btcPrice || "0";
|
|
74963
75334
|
const btcVaultBalance = litActionResult.btcAmountSats || positionDetails.btcVaultBalance || "0";
|
|
74964
|
-
const
|
|
74965
|
-
const btcAmount = Number(btcVaultBalance) / 1e8;
|
|
74966
|
-
const btcValueUSD = btcAmount * usdPricePerBTC;
|
|
74967
|
-
const debtUSD = Number(debt) / 1e18;
|
|
74968
|
-
const ratio = debtUSD > 0 ? (btcValueUSD / debtUSD * 100).toFixed(2) : "0.00";
|
|
75335
|
+
const ratio = BigInt(debt) > 0n ? collateralRatioPercentString(BigInt(btcVaultBalance), BigInt(btcPrice2), BigInt(debt)) : "0.00";
|
|
74969
75336
|
const message = formatLiquidationSkippedMessage(
|
|
74970
75337
|
request.positionId,
|
|
74971
75338
|
ratio,
|
|
@@ -75454,14 +75821,15 @@ Message: ${causeMessage}${quantumContext}${loanCapDiagnostics}${mintDebtDiagnost
|
|
|
75454
75821
|
}
|
|
75455
75822
|
const debt = positionDetails.debt || positionDetails.ucdDebt || "0";
|
|
75456
75823
|
const btcPrice2 = litActionResult.btcPrice || "0";
|
|
75457
|
-
const
|
|
75824
|
+
const btcVaultBalance = litActionResult.btcAmountSats || positionDetails.btcVaultBalance || "0";
|
|
75825
|
+
const ratio = BigInt(debt) > 0n ? collateralRatioPercentString(BigInt(btcVaultBalance), BigInt(btcPrice2), BigInt(debt)) : "0.00";
|
|
75458
75826
|
const message = formatLiquidationSuccessMessage(
|
|
75459
75827
|
request.positionId,
|
|
75460
75828
|
ratio,
|
|
75461
75829
|
`${liquidationThreshold / 100}`,
|
|
75462
75830
|
// Convert to percentage
|
|
75463
75831
|
positionDetails.btcVault || "unknown",
|
|
75464
|
-
|
|
75832
|
+
btcVaultBalance,
|
|
75465
75833
|
debt,
|
|
75466
75834
|
btcPrice2
|
|
75467
75835
|
);
|
|
@@ -77945,6 +78313,17 @@ Message: ${causeMessage}${quantumContext}${loanCapDiagnostics}${mintDebtDiagnost
|
|
|
77945
78313
|
error: `networkFee=${request.networkFee} is \u2265 50% of targetAmount=${request.targetAmount}. Refusing to broadcast \u2014 real Bitcoin fees are typically <1% of value.`
|
|
77946
78314
|
};
|
|
77947
78315
|
}
|
|
78316
|
+
const destinationDustLimit = destinationDustShortfall(
|
|
78317
|
+
request.targetAmount,
|
|
78318
|
+
request.networkFee,
|
|
78319
|
+
request.destination
|
|
78320
|
+
);
|
|
78321
|
+
if (destinationDustLimit !== null) {
|
|
78322
|
+
return {
|
|
78323
|
+
success: false,
|
|
78324
|
+
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.`
|
|
78325
|
+
};
|
|
78326
|
+
}
|
|
77948
78327
|
const [txid, voutStr] = request.utxoIdentifier.split(":");
|
|
77949
78328
|
const vout = parseInt(voutStr || "0", 10);
|
|
77950
78329
|
if (!txid || isNaN(vout)) {
|
|
@@ -79420,8 +79799,9 @@ Message: ${causeMessage}${quantumContext}${loanCapDiagnostics}${mintDebtDiagnost
|
|
|
79420
79799
|
const user = await signer.getAddress();
|
|
79421
79800
|
const registry = AgentDelegationRegistry__factory.connect(addr, signer);
|
|
79422
79801
|
let agentAddress;
|
|
79423
|
-
const [isActive, record, latestBlock] = await Promise.all([
|
|
79802
|
+
const [isActive, paused, record, latestBlock] = await Promise.all([
|
|
79424
79803
|
registry.isAgentActive(user),
|
|
79804
|
+
registry.paused(),
|
|
79425
79805
|
registry.agentOf(user),
|
|
79426
79806
|
this.getProviderOrThrow().getBlock("latest")
|
|
79427
79807
|
]);
|
|
@@ -79433,7 +79813,7 @@ Message: ${causeMessage}${quantumContext}${loanCapDiagnostics}${mintDebtDiagnost
|
|
|
79433
79813
|
/* HIGH */
|
|
79434
79814
|
});
|
|
79435
79815
|
}
|
|
79436
|
-
const plan = planAgentBinding({ isActive, record, nowSeconds: latestBlock.timestamp });
|
|
79816
|
+
const plan = planAgentBinding({ isActive, paused, record, nowSeconds: latestBlock.timestamp });
|
|
79437
79817
|
if (plan.kind === "reuse") {
|
|
79438
79818
|
agentAddress = plan.agent;
|
|
79439
79819
|
} else {
|
|
@@ -82898,11 +83278,16 @@ var RealUpstreamPlugin = class {
|
|
|
82898
83278
|
this.src("subgraph")
|
|
82899
83279
|
);
|
|
82900
83280
|
},
|
|
82901
|
-
getPositionEvents: async () =>
|
|
82902
|
-
|
|
82903
|
-
|
|
82904
|
-
|
|
82905
|
-
|
|
83281
|
+
getPositionEvents: async () => (
|
|
83282
|
+
// PERMANENT capability gap, not a transient outage: the real adapter has no indexer
|
|
83283
|
+
// projection for event history, and this build never will. `unsupported` →
|
|
83284
|
+
// NOT_IMPLEMENTED so the guide does not tell the model to retry it (C-44).
|
|
83285
|
+
upFail({
|
|
83286
|
+
kind: "unsupported",
|
|
83287
|
+
source: "subgraph",
|
|
83288
|
+
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"
|
|
83289
|
+
})
|
|
83290
|
+
)
|
|
82906
83291
|
};
|
|
82907
83292
|
this.chain = {
|
|
82908
83293
|
getPositionDetails: (id) => this.chainRead(() => this.readPositionDetails(id)),
|
|
@@ -84317,6 +84702,8 @@ var SignatureBridge = class {
|
|
|
84317
84702
|
wcTransport = null;
|
|
84318
84703
|
/** True while a WalletConnect session is THE wallet — ceremonies route over WC. */
|
|
84319
84704
|
wcActive = false;
|
|
84705
|
+
/** Page session that most recently asked for a pairing QR — see `serveWcPairing`. */
|
|
84706
|
+
pairingSessionId = null;
|
|
84320
84707
|
keystoreUnlock;
|
|
84321
84708
|
unlockToken = null;
|
|
84322
84709
|
unlockSession = null;
|
|
@@ -84447,7 +84834,8 @@ var SignatureBridge = class {
|
|
|
84447
84834
|
...handlers?.finalize ? { finalize: handlers.finalize } : {},
|
|
84448
84835
|
owner: this.wcActive ? "wc" : "page",
|
|
84449
84836
|
dispatched: false,
|
|
84450
|
-
lastAttachedMs: now
|
|
84837
|
+
lastAttachedMs: now,
|
|
84838
|
+
finalizedBy: null
|
|
84451
84839
|
};
|
|
84452
84840
|
this.pending.set(request.id, entry);
|
|
84453
84841
|
if (entry.owner === "wc") {
|
|
@@ -84480,7 +84868,8 @@ var SignatureBridge = class {
|
|
|
84480
84868
|
// ceremony could not reach quorum through the very pages it is broadcast to.
|
|
84481
84869
|
owner: "both",
|
|
84482
84870
|
dispatched: false,
|
|
84483
|
-
lastAttachedMs: now
|
|
84871
|
+
lastAttachedMs: now,
|
|
84872
|
+
finalizedBy: null
|
|
84484
84873
|
};
|
|
84485
84874
|
this.pending.set(request.id, entry);
|
|
84486
84875
|
this.pushEntry(entry);
|
|
@@ -84578,7 +84967,7 @@ var SignatureBridge = class {
|
|
|
84578
84967
|
* receives nothing cannot show anything. Distinct from `attachedNow()`, which counts
|
|
84579
84968
|
* WalletConnect and must stay global for the connector's eviction predicate. */
|
|
84580
84969
|
pageAttached() {
|
|
84581
|
-
for (const s of this.sessions.values()) if (
|
|
84970
|
+
for (const s of this.sessions.values()) if (s.sse && this.authorized(s)) return true;
|
|
84582
84971
|
return false;
|
|
84583
84972
|
}
|
|
84584
84973
|
/** Attachment for ONE entry — the wallet that entry is actually waiting on. The global
|
|
@@ -84595,6 +84984,7 @@ var SignatureBridge = class {
|
|
|
84595
84984
|
* the deadline is checked first so expiry semantics stay pinned (T-EXT-03). */
|
|
84596
84985
|
sweep() {
|
|
84597
84986
|
const now = this.clock();
|
|
84987
|
+
this.evictDeadSessions();
|
|
84598
84988
|
for (const entry of this.pending.values()) {
|
|
84599
84989
|
if (entry.settled) continue;
|
|
84600
84990
|
if (now >= entry.deadlineMs) {
|
|
@@ -84707,12 +85097,13 @@ var SignatureBridge = class {
|
|
|
84707
85097
|
this.deny(res, 403, "this approval link has expired \u2014 ask for a fresh one (signer_setup status) and reopen");
|
|
84708
85098
|
return;
|
|
84709
85099
|
}
|
|
85100
|
+
this.makeRoomForSession();
|
|
84710
85101
|
if (this.sessions.size >= MAX_SESSIONS) {
|
|
84711
85102
|
this.deny(res, 429, `too many open approval pages (${MAX_SESSIONS}) \u2014 close one and retry`);
|
|
84712
85103
|
return;
|
|
84713
85104
|
}
|
|
84714
85105
|
const sessionId = (0, import_node_crypto8.randomBytes)(24).toString("hex");
|
|
84715
|
-
this.sessions.set(sessionId, { wallet: null, sse: null, refused: null });
|
|
85106
|
+
this.sessions.set(sessionId, { wallet: null, sse: null, refused: null, lastSeenMs: this.clock(), wcPaired: false });
|
|
84716
85107
|
const page = htmlPageSecurityHeaders();
|
|
84717
85108
|
res.writeHead(200, { "Content-Type": "text/html; charset=utf-8", "Cache-Control": "no-store", ...page.headers });
|
|
84718
85109
|
res.end(renderApprovalPage(sessionId, page.nonce));
|
|
@@ -84727,6 +85118,7 @@ var SignatureBridge = class {
|
|
|
84727
85118
|
* fresh pairing URI. A wallet approving the pairing becomes THE wallet. */
|
|
84728
85119
|
async serveWcPairing(url2, res) {
|
|
84729
85120
|
if (!this.checkSession(url2.searchParams.get("s"), res)) return;
|
|
85121
|
+
this.pairingSessionId = url2.searchParams.get("s");
|
|
84730
85122
|
if (!this.wcConfig) {
|
|
84731
85123
|
this.deny(res, 404, "WalletConnect is not configured (set DH_WC_PROJECT_ID)");
|
|
84732
85124
|
return;
|
|
@@ -84750,6 +85142,10 @@ var SignatureBridge = class {
|
|
|
84750
85142
|
}
|
|
84751
85143
|
this.wcActive = info !== null;
|
|
84752
85144
|
this.wallet = info ? { account: info.account, chainId: info.chainId } : null;
|
|
85145
|
+
if (info && this.pairingSessionId) {
|
|
85146
|
+
const paired = this.sessions.get(this.pairingSessionId);
|
|
85147
|
+
if (paired) paired.wcPaired = true;
|
|
85148
|
+
}
|
|
84753
85149
|
if (info === null) {
|
|
84754
85150
|
for (const entry of this.pending.values()) {
|
|
84755
85151
|
if (!entry.settled && !entry.collect) {
|
|
@@ -84827,9 +85223,7 @@ var SignatureBridge = class {
|
|
|
84827
85223
|
res.write(":connected\n\n");
|
|
84828
85224
|
session.sse?.end();
|
|
84829
85225
|
session.sse = res;
|
|
84830
|
-
|
|
84831
|
-
if (!entry.settled) res.write(this.wireFor(entry));
|
|
84832
|
-
}
|
|
85226
|
+
this.replayPending(session);
|
|
84833
85227
|
const keepAlive = setInterval(() => res.write(":ka\n\n"), 2e4);
|
|
84834
85228
|
keepAlive.unref();
|
|
84835
85229
|
res.on("close", () => {
|
|
@@ -84854,6 +85248,7 @@ var SignatureBridge = class {
|
|
|
84854
85248
|
}
|
|
84855
85249
|
session.wallet = { account, chainId };
|
|
84856
85250
|
this.wallet = { account, chainId };
|
|
85251
|
+
this.replayPending(session);
|
|
84857
85252
|
this.ok(res);
|
|
84858
85253
|
}
|
|
84859
85254
|
/** C-47: the single predicate every wallet account is admitted through. There are THREE
|
|
@@ -84937,7 +85332,9 @@ var SignatureBridge = class {
|
|
|
84937
85332
|
/** Click-time re-stamp (A0.9): returns the FRESH personal-sign payload for a pending
|
|
84938
85333
|
* request. Idempotent for requests without a finalize handler (payload as enqueued). */
|
|
84939
85334
|
async onFinalize(body, res) {
|
|
84940
|
-
|
|
85335
|
+
const sessionId = String(body["sessionId"] ?? "");
|
|
85336
|
+
const session = this.decidingSessionOf(body["sessionId"], res);
|
|
85337
|
+
if (!session) return;
|
|
84941
85338
|
const entry = this.pending.get(String(body["requestId"] ?? ""));
|
|
84942
85339
|
if (!entry || entry.settled) {
|
|
84943
85340
|
this.deny(res, 404, "unknown or already-settled requestId");
|
|
@@ -84951,6 +85348,12 @@ var SignatureBridge = class {
|
|
|
84951
85348
|
this.deny(res, 409, "a mobile wallet is holding this approval \u2014 it is read-only here; approve or decline it in the wallet");
|
|
84952
85349
|
return;
|
|
84953
85350
|
}
|
|
85351
|
+
const holder = entry.finalizedBy ? this.sessions.get(entry.finalizedBy) : void 0;
|
|
85352
|
+
if (entry.finalizedBy && entry.finalizedBy !== sessionId && holder?.sse) {
|
|
85353
|
+
this.deny(res, 409, "another approval page is signing this request \u2014 approve it there, or close that page and retry");
|
|
85354
|
+
return;
|
|
85355
|
+
}
|
|
85356
|
+
entry.finalizedBy = sessionId;
|
|
84954
85357
|
if (entry.finalize) {
|
|
84955
85358
|
let fresh;
|
|
84956
85359
|
try {
|
|
@@ -84970,7 +85373,7 @@ var SignatureBridge = class {
|
|
|
84970
85373
|
res.end(JSON.stringify({ request: entry.request }));
|
|
84971
85374
|
}
|
|
84972
85375
|
onResult(body, res) {
|
|
84973
|
-
if (!this.
|
|
85376
|
+
if (!this.decidingSessionOf(body["sessionId"], res)) return;
|
|
84974
85377
|
const entry = this.pending.get(String(body["requestId"] ?? ""));
|
|
84975
85378
|
if (!entry || entry.settled) {
|
|
84976
85379
|
this.deny(res, 404, "unknown or already-settled requestId");
|
|
@@ -85043,7 +85446,7 @@ var SignatureBridge = class {
|
|
|
85043
85446
|
/** Broadcast a pending entry to EVERY open page (multi-owner links — plan 06 §1.5). */
|
|
85044
85447
|
pushEntry(entry) {
|
|
85045
85448
|
const data = this.wireFor(entry);
|
|
85046
|
-
for (const s of this.sessions.values()) if (
|
|
85449
|
+
for (const s of this.sessions.values()) if (this.authorized(s)) s.sse?.write(data);
|
|
85047
85450
|
}
|
|
85048
85451
|
/** Progress goes out as a NAMED event so `es.onmessage` request handling never sees it. */
|
|
85049
85452
|
pushProgress(payload) {
|
|
@@ -85051,7 +85454,51 @@ var SignatureBridge = class {
|
|
|
85051
85454
|
data: ${JSON.stringify(payload)}
|
|
85052
85455
|
|
|
85053
85456
|
`;
|
|
85054
|
-
for (const s of this.sessions.values()) if (
|
|
85457
|
+
for (const s of this.sessions.values()) if (this.authorized(s)) s.sse?.write(data);
|
|
85458
|
+
}
|
|
85459
|
+
/** Replay every undecided card to ONE session — used when a session becomes authorized
|
|
85460
|
+
* (hello) after its stream was already open, which is the ordinary page order: the page
|
|
85461
|
+
* attaches its EventSource, then the wallet prompt resolves. Without this the newly
|
|
85462
|
+
* connected page would sit blank until the next push. */
|
|
85463
|
+
replayPending(session) {
|
|
85464
|
+
if (!session.sse || !this.authorized(session)) return;
|
|
85465
|
+
for (const entry of this.pending.values()) {
|
|
85466
|
+
if (!entry.settled) session.sse.write(this.wireFor(entry));
|
|
85467
|
+
}
|
|
85468
|
+
}
|
|
85469
|
+
/** Retire quarantined sessions that hold no stream. Always safe: a refused session is
|
|
85470
|
+
* denied on every route anyway, so keeping it costs a slot and buys nothing. */
|
|
85471
|
+
evictDeadSessions() {
|
|
85472
|
+
for (const [id, s] of this.sessions) if (s.refused && !s.sse) this.sessions.delete(id);
|
|
85473
|
+
}
|
|
85474
|
+
/**
|
|
85475
|
+
* Free a slot for an incoming page load when the ceiling is reached.
|
|
85476
|
+
*
|
|
85477
|
+
* MAX_SESSIONS was a ceiling with NO eviction — nothing but `close()` ever removed a
|
|
85478
|
+
* session — and every page load mints one (a reload is a new session). A long-lived
|
|
85479
|
+
* hosted bridge therefore reached 16 through ordinary use and 429'd the user out of
|
|
85480
|
+
* approving their own ceremonies, permanently, with "close one and retry" as the advice
|
|
85481
|
+
* for pages that were already closed.
|
|
85482
|
+
*
|
|
85483
|
+
* Eviction is ON DEMAND and never touches a session with a live SSE stream: that stream
|
|
85484
|
+
* is a page open in a browser right now, and the C1 contract is that live sessions
|
|
85485
|
+
* survive. Among the streamless it takes the least recently seen — the closed tab.
|
|
85486
|
+
*/
|
|
85487
|
+
makeRoomForSession() {
|
|
85488
|
+
this.evictDeadSessions();
|
|
85489
|
+
while (this.sessions.size >= MAX_SESSIONS) {
|
|
85490
|
+
let oldestId = null;
|
|
85491
|
+
let oldestSeen = Infinity;
|
|
85492
|
+
for (const [id, s] of this.sessions) {
|
|
85493
|
+
if (s.sse) continue;
|
|
85494
|
+
if (s.lastSeenMs < oldestSeen) {
|
|
85495
|
+
oldestSeen = s.lastSeenMs;
|
|
85496
|
+
oldestId = id;
|
|
85497
|
+
}
|
|
85498
|
+
}
|
|
85499
|
+
if (oldestId === null) return;
|
|
85500
|
+
this.sessions.delete(oldestId);
|
|
85501
|
+
}
|
|
85055
85502
|
}
|
|
85056
85503
|
/**
|
|
85057
85504
|
* C-47: `this.wallet` is DERIVED, never guessed.
|
|
@@ -85094,12 +85541,46 @@ data: ${JSON.stringify(payload)}
|
|
|
85094
85541
|
}
|
|
85095
85542
|
this.rebuildSharedWallet();
|
|
85096
85543
|
}
|
|
85544
|
+
/**
|
|
85545
|
+
* A session that may SEE cards and DECIDE them — one where a PERSON has proven to be at
|
|
85546
|
+
* the page: `hello` with an admissible account, or a WalletConnect pairing a wallet
|
|
85547
|
+
* actually answered (`wcPaired`).
|
|
85548
|
+
*
|
|
85549
|
+
* `sessionOf` only ever asked "does this session id exist and is it un-quarantined". A
|
|
85550
|
+
* session id is minted by LOADING the page, and on the hosted tier the mount URL travels
|
|
85551
|
+
* through the conversation by design — so anyone holding it could mint a session, never
|
|
85552
|
+
* connect a wallet, and still receive every approval card on /events (the card is the
|
|
85553
|
+
* operation in readable form: position, destination, amounts) and still POST /result to
|
|
85554
|
+
* decline, or /finalize to re-stamp, someone else's ceremony. Quarantine never caught
|
|
85555
|
+
* them: it fires on an OFFERED account, and they offered none.
|
|
85556
|
+
*
|
|
85557
|
+
* Opening the stream without a wallet stays legal — that is how the real page bootstraps
|
|
85558
|
+
* before the user connects. It simply receives nothing and decides nothing until it has
|
|
85559
|
+
* connected. Requesting a pairing is likewise not enough: anyone with the link can ask
|
|
85560
|
+
* for a QR, so only a pairing a WALLET ANSWERED counts.
|
|
85561
|
+
*/
|
|
85562
|
+
authorized(session) {
|
|
85563
|
+
if (session.refused) return false;
|
|
85564
|
+
if (session.wallet) return this.accountRefusal(session.wallet.account) === null;
|
|
85565
|
+
return session.wcPaired;
|
|
85566
|
+
}
|
|
85567
|
+
/** `sessionOf`, plus the wallet binding above — for the routes that decide a ceremony. */
|
|
85568
|
+
decidingSessionOf(candidate, res) {
|
|
85569
|
+
const session = this.sessionOf(candidate, res);
|
|
85570
|
+
if (!session) return null;
|
|
85571
|
+
if (!this.authorized(session)) {
|
|
85572
|
+
this.deny(res, 403, "connect your wallet on this page before approving, declining or finalizing a request");
|
|
85573
|
+
return null;
|
|
85574
|
+
}
|
|
85575
|
+
return session;
|
|
85576
|
+
}
|
|
85097
85577
|
sessionOf(candidate, res) {
|
|
85098
85578
|
const session = typeof candidate === "string" ? this.sessions.get(candidate) ?? null : null;
|
|
85099
85579
|
if (!session) {
|
|
85100
85580
|
this.deny(res, 403, "missing or wrong session");
|
|
85101
85581
|
return null;
|
|
85102
85582
|
}
|
|
85583
|
+
session.lastSeenMs = this.clock();
|
|
85103
85584
|
if (session.refused) {
|
|
85104
85585
|
this.deny(res, 403, session.refused);
|
|
85105
85586
|
return null;
|
|
@@ -85792,8 +86273,13 @@ function authorizationModeBullets(d) {
|
|
|
85792
86273
|
that one \u2014 say it before the popup. Walkthrough: \`guide connect-wallet\`.`);
|
|
85793
86274
|
}
|
|
85794
86275
|
if (offers(d, "keystore")) {
|
|
85795
|
-
bullets.push(` - \`keystore\` \u2014 a local encrypted keystore signs
|
|
85796
|
-
Real adapter and mock
|
|
86276
|
+
bullets.push(` - \`keystore\` \u2014 a local encrypted keystore signs AUTOMATICALLY, with no per-operation
|
|
86277
|
+
human prompt. Real adapter and mock. Say this plainly when the user picks it: the
|
|
86278
|
+
password is asked ONCE, at unlock; after that the key signs every write this session
|
|
86279
|
+
without a popup, an approval page or any second human step. The \`confirmed: true\` gate
|
|
86280
|
+
is the ASSISTANT's \u2014 it is not the user seeing and approving the operation \u2014 so in this
|
|
86281
|
+
mode you must show the operation and get a real answer before you set it. A user who
|
|
86282
|
+
wants to inspect each operation as it signs wants \`external\`.`);
|
|
85797
86283
|
}
|
|
85798
86284
|
if (offers(d, "safe") || offers(d, "safe-module")) {
|
|
85799
86285
|
bullets.push(` - \`safe\` / \`safe-module\` \u2014 PRACTICE-ONLY today: on the real adapter these modes
|
|
@@ -85804,6 +86290,9 @@ function authorizationModeBullets(d) {
|
|
|
85804
86290
|
}
|
|
85805
86291
|
return bullets.join("\n");
|
|
85806
86292
|
}
|
|
86293
|
+
function readsNeedSignIn(d) {
|
|
86294
|
+
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.";
|
|
86295
|
+
}
|
|
85807
86296
|
function keystoreAbsenceParagraph(d) {
|
|
85808
86297
|
if (offers(d, "keystore")) return "";
|
|
85809
86298
|
return `
|
|
@@ -85847,9 +86336,11 @@ install matrix. ${connectorInstallNote(d)}
|
|
|
85847
86336
|
|
|
85848
86337
|
Nothing needs a config file. Three steps:
|
|
85849
86338
|
|
|
85850
|
-
**1. Know your world.** Read \`boundary://info\` (its \`capabilities\` block)
|
|
85851
|
-
|
|
85852
|
-
signer modes exist
|
|
86339
|
+
**1. Know your world.** Read \`boundary://info\` (its \`capabilities\` block) \u2014 that
|
|
86340
|
+
resource always answers, with no sign-in \u2014 and tell the user what THIS deployment is:
|
|
86341
|
+
${worldAxes(d)}; which signer modes exist. ${readsNeedSignIn(d)} So the live reads
|
|
86342
|
+
(\`protocol_status\`, current terms via \`protocol_terms\`) come right after step 2, not
|
|
86343
|
+
before it.
|
|
85853
86344
|
|
|
85854
86345
|
**2. Choose HOW to authorize operations** (the user's choice, made by talking):
|
|
85855
86346
|
- **"Use my own wallet"** \u2192 call \`signer_setup\` action \`use\`, mode \`external\` \u2014 works
|
|
@@ -85869,8 +86360,9 @@ ${offers(d, "safe") || offers(d, "safe-module") ? `- **Safe / delegation modes (
|
|
|
85869
86360
|
surface is the wallet ceremony and nothing else; \`signer_setup\` lists no other mode.
|
|
85870
86361
|
\`guide safe\` and \`guide delegation\` state what exists elsewhere.`}
|
|
85871
86362
|
- Not sure? \`signer_setup\` action \`status\` explains what is active and what is missing.
|
|
85872
|
-
- **
|
|
85873
|
-
\`position_list {borrower}\`
|
|
86363
|
+
- **A read is not a signer-less shortcut:** the sign-in in step 2 is what turns reads ON.
|
|
86364
|
+
Until then \`position_list {borrower}\`, \`protocol_status\` and \`protocol_terms\` refuse
|
|
86365
|
+
on the real adapter \u2014 do step 2 first, then reads work.
|
|
85874
86366
|
${d.networks.length > 1 ? `- **Wrong network?** On the real adapter the user can switch sepolia \u2194 mainnet by
|
|
85875
86367
|
talking (\`network_switch\`, human-confirmed) \u2014 see \`guide switch-network\`. State
|
|
85876
86368
|
the money reality after any switch.` : `- **Wrong network?** This deployment is rolled out to ${d.networks[0]} alone \u2014
|
|
@@ -86359,7 +86851,12 @@ ${wrongNetworkTroubleshootingRow(d)}
|
|
|
86359
86851
|
owed, wrong position state, or the USER DECLINED in the wallet. The message says which.
|
|
86360
86852
|
A decline is not an error to fix \u2014 it is the user's decision.
|
|
86361
86853
|
- **UPSTREAM_UNAVAILABLE** \u2014 a data source or the signature bridge is unreachable/expired.
|
|
86362
|
-
Usually transient; re-check with \`protocol_status\` and retry once.
|
|
86854
|
+
Usually transient; re-check with \`protocol_status\` and retry once. (A PERMANENT gap
|
|
86855
|
+
answers \`NOT_IMPLEMENTED\`, below \u2014 that one is not retryable.)
|
|
86856
|
+
- **NOT_IMPLEMENTED** \u2014 a capability this adapter does NOT implement in this build, and never
|
|
86857
|
+
will \u2014 PERMANENT, not a transient outage, so do NOT retry it. \`position_events\` on the
|
|
86858
|
+
real adapter is the case: there is no indexer projection for event history here. Say the
|
|
86859
|
+
history is unavailable on this deployment and move on; the practice (mock) world has it.
|
|
86363
86860
|
- **NOT_FOUND** \u2014 the position id doesn't exist in this world (check \`position_list\`).
|
|
86364
86861
|
- **STATE_DIVERGENCE / STALE_DATA warnings** \u2014 sources disagree or lag; the envelope says
|
|
86365
86862
|
which source and when from. Prefer chain-sourced values; re-read before acting.
|
|
@@ -86593,7 +87090,7 @@ function requireConfirmation(confirmed, actionLabel) {
|
|
|
86593
87090
|
type: "text",
|
|
86594
87091
|
text: `CONFIRMATION REQUIRED \u2014 refusing to run "${actionLabel}".
|
|
86595
87092
|
This is an irreversible, fund-moving action. A human must explicitly authorize it.
|
|
86596
|
-
|
|
87093
|
+
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.`
|
|
86597
87094
|
}
|
|
86598
87095
|
],
|
|
86599
87096
|
isError: true
|
|
@@ -87030,7 +87527,7 @@ function registerPositionTools(server, getB) {
|
|
|
87030
87527
|
"position_events",
|
|
87031
87528
|
{
|
|
87032
87529
|
title: "Get a position's event history",
|
|
87033
|
-
description: "Return mint, payment, withdrawal, renewal, and liquidation events for a position (indexer view).",
|
|
87530
|
+
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.",
|
|
87034
87531
|
inputSchema: {
|
|
87035
87532
|
id: positionIdSchema2
|
|
87036
87533
|
}
|
|
@@ -87576,7 +88073,7 @@ function registerGuidePrompts(server, deployment = LOCAL_GUIDE_DEPLOYMENT) {
|
|
|
87576
88073
|
role: "user",
|
|
87577
88074
|
content: {
|
|
87578
88075
|
type: "text",
|
|
87579
|
-
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,
|
|
88076
|
+
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."
|
|
87580
88077
|
}
|
|
87581
88078
|
}
|
|
87582
88079
|
]
|
|
@@ -87764,7 +88261,7 @@ function registerProtocolResources(server, getB) {
|
|
|
87764
88261
|
"protocol://psm",
|
|
87765
88262
|
{
|
|
87766
88263
|
title: "PSM status (UCD \u2194 USDC exchange)",
|
|
87767
|
-
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.",
|
|
88264
|
+
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.",
|
|
87768
88265
|
mimeType: "application/json"
|
|
87769
88266
|
},
|
|
87770
88267
|
async (uri) => {
|
|
@@ -88248,6 +88745,10 @@ function composeConnector(opts, rawPublicOrigin) {
|
|
|
88248
88745
|
}
|
|
88249
88746
|
const app = (0, import_express.default)();
|
|
88250
88747
|
app.set("trust proxy", trustProxyHops);
|
|
88748
|
+
app.use((_req, res, next) => {
|
|
88749
|
+
res.setHeader(STRICT_TRANSPORT_SECURITY.name, STRICT_TRANSPORT_SECURITY.value);
|
|
88750
|
+
next();
|
|
88751
|
+
});
|
|
88251
88752
|
app.use((_req, res, next) => {
|
|
88252
88753
|
if (!allowGlobal()) {
|
|
88253
88754
|
deny(res, 429, `rate limit: this connector exceeded ${globalPerMin} requests/minute across all clients \u2014 a shared-capacity protection; wait for the minute window to pass and retry`);
|
|
@@ -88255,6 +88756,31 @@ function composeConnector(opts, rawPublicOrigin) {
|
|
|
88255
88756
|
}
|
|
88256
88757
|
next();
|
|
88257
88758
|
});
|
|
88759
|
+
const expectedHost = opts.publicOrigin ? new URL(publicOrigin).host.toLowerCase() : null;
|
|
88760
|
+
app.use((req, res, next) => {
|
|
88761
|
+
if (expectedHost === null) {
|
|
88762
|
+
next();
|
|
88763
|
+
return;
|
|
88764
|
+
}
|
|
88765
|
+
const p = (req.originalUrl ?? req.url).split("?")[0].toLowerCase();
|
|
88766
|
+
const sensitive = ["/mcp", "/token", "/register", "/revoke", "/authorize"].some(
|
|
88767
|
+
(r) => p === r || p.startsWith(`${r}/`)
|
|
88768
|
+
);
|
|
88769
|
+
if (!sensitive) {
|
|
88770
|
+
next();
|
|
88771
|
+
return;
|
|
88772
|
+
}
|
|
88773
|
+
const host = (req.headers.host ?? "").toLowerCase();
|
|
88774
|
+
if (host !== expectedHost) {
|
|
88775
|
+
deny(
|
|
88776
|
+
res,
|
|
88777
|
+
421,
|
|
88778
|
+
`misdirected request: this connector serves ${expectedHost} \u2014 the request arrived on Host '${req.headers.host ?? "(none)"}'. Use the canonical origin advertised in the discovery documents.`
|
|
88779
|
+
);
|
|
88780
|
+
return;
|
|
88781
|
+
}
|
|
88782
|
+
next();
|
|
88783
|
+
});
|
|
88258
88784
|
app.use((req, res, next) => {
|
|
88259
88785
|
const path5 = (req.originalUrl ?? req.url).split("?")[0];
|
|
88260
88786
|
if (path5 === "/mcp" || path5.startsWith("/approval/")) {
|