@gvnrdao/dh-mcp 0.5.18 → 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/index.js CHANGED
@@ -14450,113 +14450,113 @@ var require_pkg_src = __commonJS({
14450
14450
  deployedAt: 1784569687492,
14451
14451
  size: 4140,
14452
14452
  hash: "4c0d65bf1f33cdac22a78fd8c4764319cc3fe00650e0fe7fa8a6090d9a318a7b",
14453
- validatorWalletAddress: "0x82db9f515957aa380b596c6ea2bd30cef181f236",
14453
+ validatorWalletAddress: "0xefb258d455a31d061bbeb3de3d2143bdfcb67a6c",
14454
14454
  pkp: {
14455
14455
  publicKey: "0x04ec0e3acc40884e3f366ca469d08899eb640ad5259fa196b0238075086208a9f8732a3175704f35f0bcc28e07406cfb24c254efd1e7355640577330f0d2dd755f",
14456
- ethAddress: "0xc7e1588Db94Bbe92Ab209B833235144Fc5b97607"
14456
+ ethAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C"
14457
14457
  }
14458
14458
  },
14459
14459
  btcTransactionSigner: {
14460
- cid: "QmVi1BYdxvCX3QUhXwPtP6FjWMzqSPtXzrS54YsXjTgjYf",
14460
+ cid: "QmULkz7hwwqsyLwY23U14dnartdVuSNMrykt69PaNiAq7U",
14461
14461
  authorizedCidHex: cidToHex(
14462
- "QmVi1BYdxvCX3QUhXwPtP6FjWMzqSPtXzrS54YsXjTgjYf"
14462
+ "QmULkz7hwwqsyLwY23U14dnartdVuSNMrykt69PaNiAq7U"
14463
14463
  ),
14464
14464
  name: "Btc Transaction Signer",
14465
14465
  description: "Production Btc Transaction Signer",
14466
14466
  version: "1.1.1",
14467
14467
  deployed: true,
14468
- deployedAt: 1787923905597,
14469
- size: 70646,
14470
- hash: "37c3bb72a660c8275d92e1b73f9482742d86b64789480b9246304c0ca1bab47a"
14468
+ deployedAt: 1790246185256,
14469
+ size: 73313,
14470
+ hash: "d8b6bc646ba33fee7d46c8e9b281de776081ea6f182f56fd15d4c52aaf3dd030"
14471
14471
  },
14472
14472
  ucdMintValidator: {
14473
- cid: "QmUWR5fLiyimLT9TPXpYx3HgwNwkvR6MxjZ7hdeYCFodbc",
14473
+ cid: "QmcxVSn9saEPGBS6mqPhNefgW83V2qeZjjXbhwYLP373xe",
14474
14474
  authorizedCidHex: cidToHex(
14475
- "QmUWR5fLiyimLT9TPXpYx3HgwNwkvR6MxjZ7hdeYCFodbc"
14475
+ "QmcxVSn9saEPGBS6mqPhNefgW83V2qeZjjXbhwYLP373xe"
14476
14476
  ),
14477
14477
  name: "Ucd Mint Validator",
14478
14478
  description: "Production Ucd Mint Validator",
14479
- version: "1.2.1",
14479
+ version: "1.3.0",
14480
14480
  deployed: true,
14481
- deployedAt: 1787923919527,
14482
- size: 86197,
14483
- hash: "c2d80939746cc37f65ef2f63c6a3215b929214a63f10c78144e1f5c98320dabf",
14484
- validatorWalletAddress: "0x82DB9F515957aA380B596C6eA2Bd30CEF181f236",
14481
+ deployedAt: 1790246219868,
14482
+ size: 90022,
14483
+ hash: "65e8cb778c2b767ae6eb37cb5db7b4c5a3f2468d508463c847c83c1b6825fadd",
14484
+ validatorWalletAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C",
14485
14485
  pkp: {
14486
14486
  publicKey: "0x041ab17cd91fc5c0b761eea6092d032807561b621b82c488826776e04a9158d61ba64d809a4729f0501289d980732cb06d8dfd06999dd9c8efd2f495dad78b31bb",
14487
- ethAddress: "0xc7e1588Db94Bbe92Ab209B833235144Fc5b97607"
14487
+ ethAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C"
14488
14488
  }
14489
14489
  },
14490
14490
  processPaymentValidator: {
14491
- cid: "QmXmXuMRAjMLdgKGyTf9KQdGwYrDp8DxkiF44TvSXDf7wF",
14491
+ cid: "QmWFbxJkfxhCtES4wrePWQkYtjhtrP1tohvn9d1r9N5Hd8",
14492
14492
  authorizedCidHex: cidToHex(
14493
- "QmXmXuMRAjMLdgKGyTf9KQdGwYrDp8DxkiF44TvSXDf7wF"
14493
+ "QmWFbxJkfxhCtES4wrePWQkYtjhtrP1tohvn9d1r9N5Hd8"
14494
14494
  ),
14495
14495
  name: "Process Payment Validator",
14496
14496
  description: "Production Process Payment Validator",
14497
14497
  version: "1.2.1",
14498
14498
  deployed: true,
14499
- deployedAt: 1787923987153,
14500
- size: 82217,
14501
- hash: "13defa19614215ab3b1fe88955d69e530d13a09475396af932fe0e213637da2f",
14502
- validatorWalletAddress: "0x82DB9F515957aA380B596C6eA2Bd30CEF181f236",
14499
+ deployedAt: 1790246225795,
14500
+ size: 85107,
14501
+ hash: "25ecf952c4c44c40b0920b92d57906e7010ed9a38e2ba41ccdee6d3377c2b596",
14502
+ validatorWalletAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C",
14503
14503
  pkp: {
14504
14504
  publicKey: "0x04cfccb9b6c7addc79469c0e9fafebef4c70801302c62cdb26b610723a9b8527d23f98a40158c7340d83fd0e62d02b5ec74c12f7a86d98e8c6973b4811110f19ad",
14505
- ethAddress: "0xc7e1588Db94Bbe92Ab209B833235144Fc5b97607"
14505
+ ethAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C"
14506
14506
  }
14507
14507
  },
14508
14508
  extendPositionValidator: {
14509
- cid: "QmU8h99EEVEsQkxroXiYqLsKZw9gNjE6N5CcTpE9aUc12m",
14509
+ cid: "QmZ3g7g5DkgU1gEYpFjprQf3sctUHtGjNQVYezw2bnPGEX",
14510
14510
  authorizedCidHex: cidToHex(
14511
- "QmU8h99EEVEsQkxroXiYqLsKZw9gNjE6N5CcTpE9aUc12m"
14511
+ "QmZ3g7g5DkgU1gEYpFjprQf3sctUHtGjNQVYezw2bnPGEX"
14512
14512
  ),
14513
14513
  name: "Extend Position Validator",
14514
14514
  description: "Production Extend Position Validator",
14515
14515
  version: "1.2.1",
14516
14516
  deployed: true,
14517
- deployedAt: 1787923999294,
14518
- size: 79975,
14519
- hash: "31c1aaf883ef22f37681ddb0a4a949be5c05304b6aef178989475a2da935ef9a",
14520
- validatorWalletAddress: "0x82DB9F515957aA380B596C6eA2Bd30CEF181f236",
14517
+ deployedAt: 1790246231975,
14518
+ size: 82853,
14519
+ hash: "25d4887b7f646649db2bb7f2bfb77d039db83228a6c454377ca26c779b0903cc",
14520
+ validatorWalletAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C",
14521
14521
  pkp: {
14522
14522
  publicKey: "0x04e52338f6a0c3362800f1a94c4c8f08be5030dde0fa217388c53d1c1a4790f4443c9f2886b2d2d8f4b75a9a156e9b028011b1a1cf7648da0e556aa980ec692836",
14523
- ethAddress: "0xc7e1588Db94Bbe92Ab209B833235144Fc5b97607"
14523
+ ethAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C"
14524
14524
  }
14525
14525
  },
14526
14526
  btcWithdrawal: {
14527
- cid: "QmZQWET9pzrVD4gwQuSzYZmqa24JrUNtnnGFDd513sxMCY",
14527
+ cid: "QmbRaaMQr1jCctDGe8mPADsUz1rkb4frT1YqSKroiXjzyP",
14528
14528
  authorizedCidHex: cidToHex(
14529
- "QmZQWET9pzrVD4gwQuSzYZmqa24JrUNtnnGFDd513sxMCY"
14529
+ "QmbRaaMQr1jCctDGe8mPADsUz1rkb4frT1YqSKroiXjzyP"
14530
14530
  ),
14531
14531
  name: "Btc Withdrawal",
14532
14532
  description: "Production Btc Withdrawal",
14533
14533
  version: "1.2.7",
14534
14534
  deployed: true,
14535
- deployedAt: 1787924017769,
14536
- size: 100069,
14537
- hash: "4f8e27414e4da235e63d6ae1325c63f3d2fb956464515a21aa007a99935f0f13",
14538
- validatorWalletAddress: "0x82DB9F515957aA380B596C6eA2Bd30CEF181f236",
14535
+ deployedAt: 1790246239599,
14536
+ size: 101228,
14537
+ hash: "2ed25eca6cc80a43061b7ad119737af48158fdb61d59f10cd06cea51b607f112",
14538
+ validatorWalletAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C",
14539
14539
  pkp: {
14540
14540
  publicKey: "0x043616787c5432415c24378c4ef48de2bcd6bb7b575b837e3cff09171802662da7105d79586c7659677a0ecbaddac4cce06cb2a11f69a16fa0c4d7002ac7d51a4d",
14541
- ethAddress: "0xc7e1588Db94Bbe92Ab209B833235144Fc5b97607"
14541
+ ethAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C"
14542
14542
  }
14543
14543
  },
14544
14544
  liquidationValidator: {
14545
- cid: "Qme6aGADhiszkQbZL977E6nmBacd2PEB7K9Hs8puVrscNx",
14545
+ cid: "QmTs2w8gfAwWZLbzJZg2CZmiLhVXS5kbMgaj42Zuxfodpb",
14546
14546
  authorizedCidHex: cidToHex(
14547
- "Qme6aGADhiszkQbZL977E6nmBacd2PEB7K9Hs8puVrscNx"
14547
+ "QmTs2w8gfAwWZLbzJZg2CZmiLhVXS5kbMgaj42Zuxfodpb"
14548
14548
  ),
14549
14549
  name: "Liquidation Validator",
14550
14550
  description: "Production Liquidation Validator",
14551
14551
  version: "1.2.1",
14552
14552
  deployed: true,
14553
- deployedAt: 1785173262533,
14554
- size: 66846,
14555
- hash: "b35ee7706d733d625faa4dbe37f73c8e20f0c1befa897cd7875e827de52003de",
14556
- validatorWalletAddress: "0x82DB9F515957aA380B596C6eA2Bd30CEF181f236",
14553
+ deployedAt: 1790246247904,
14554
+ size: 70308,
14555
+ hash: "582ccf0ec7f715195e20fdc885996743cb42125b64173424e360ee63db62bbd8",
14556
+ validatorWalletAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C",
14557
14557
  pkp: {
14558
14558
  publicKey: "0x041a241de58976c13e3d7ca5a18e494f7330151e3818706135d50176e78ffb673e58b11f0b67a87c73fade6c6b27d6e7a7377ea9f4c10bf31880f1d725f18cc6f8",
14559
- ethAddress: "0xc7e1588Db94Bbe92Ab209B833235144Fc5b97607"
14559
+ ethAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C"
14560
14560
  }
14561
14561
  },
14562
14562
  priceOracle: {
@@ -14571,28 +14571,28 @@ var require_pkg_src = __commonJS({
14571
14571
  deployedAt: 1781116663270,
14572
14572
  size: 8695,
14573
14573
  hash: "ba20ade60a7fa5acd80dadfafa179c507388cfe6ce48a22a672d70b317ffcc74",
14574
- validatorWalletAddress: "0x82db9f515957aa380b596c6ea2bd30cef181f236",
14574
+ validatorWalletAddress: "0xefb258d455a31d061bbeb3de3d2143bdfcb67a6c",
14575
14575
  pkp: {
14576
14576
  publicKey: "0x043beaa1da47875601a8d6f430b1438ee2d4732eefd06e5c63a474bbdaf9e7df1797b1b951e041b627c2bf839788164825324c9cbd1e2d6f740fdd4bff69b1900b",
14577
- ethAddress: "0xc7e1588Db94Bbe92Ab209B833235144Fc5b97607"
14577
+ ethAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C"
14578
14578
  }
14579
14579
  },
14580
14580
  loanVaultBtcBalance: {
14581
- cid: "QmaeQoHYvcMYobNbu9hQavGDudi8AXoW9tg3YHrvy1g2A4",
14581
+ cid: "QmZ27xCzuoaAhWxRsMPsUQkp45a8WPBb21uhxwchw3LG5W",
14582
14582
  authorizedCidHex: cidToHex(
14583
- "QmaeQoHYvcMYobNbu9hQavGDudi8AXoW9tg3YHrvy1g2A4"
14583
+ "QmZ27xCzuoaAhWxRsMPsUQkp45a8WPBb21uhxwchw3LG5W"
14584
14584
  ),
14585
14585
  name: "Loan Vault Btc Balance",
14586
14586
  description: "Production Loan Vault Btc Balance",
14587
14587
  version: "1.2.1",
14588
14588
  deployed: true,
14589
- deployedAt: 1785173271802,
14590
- size: 56800,
14591
- hash: "a059133214e6ba0a73d655a15600c4b33e361fb340c98f8eecaf8ab7b95aaf83",
14592
- validatorWalletAddress: "0x82DB9F515957aA380B596C6eA2Bd30CEF181f236",
14589
+ deployedAt: 1790179961079,
14590
+ size: 60046,
14591
+ hash: "922e86c0a667fe0c0945771f84aa6b9fe08be9c96dd2f73a9c5cb257d24e22b0",
14592
+ validatorWalletAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C",
14593
14593
  pkp: {
14594
14594
  publicKey: "0x043616787c5432415c24378c4ef48de2bcd6bb7b575b837e3cff09171802662da7105d79586c7659677a0ecbaddac4cce06cb2a11f69a16fa0c4d7002ac7d51a4d",
14595
- ethAddress: "0xc7e1588Db94Bbe92Ab209B833235144Fc5b97607"
14595
+ ethAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C"
14596
14596
  }
14597
14597
  },
14598
14598
  // btc-address-balance (Option B) — address-only signed total balance via
@@ -14602,21 +14602,21 @@ var require_pkg_src = __commonJS({
14602
14602
  // Requires BitcoinProviderRegistry.addAllowedCid(chainId, keccak256(utf8(cid)))
14603
14603
  // on each target chain (the action decrypts registry slots). No OAR entry.
14604
14604
  btcAddressBalance: {
14605
- cid: "QmUXUtU9r1HhQVYgkXPN5s19SKXanhn4pMsCtFEP3GK4Kj",
14605
+ cid: "QmVVjB6zCBiXFKffhQPYUAZhj7TXduuvcrPqKtHa3DMXhN",
14606
14606
  authorizedCidHex: cidToHex(
14607
- "QmUXUtU9r1HhQVYgkXPN5s19SKXanhn4pMsCtFEP3GK4Kj"
14607
+ "QmVVjB6zCBiXFKffhQPYUAZhj7TXduuvcrPqKtHa3DMXhN"
14608
14608
  ),
14609
14609
  name: "Btc Address Balance",
14610
14610
  description: "Address-only signed total BTC balance via registry consensus (no positionId, no price)",
14611
14611
  version: "0.2.1",
14612
14612
  deployed: true,
14613
- deployedAt: 1785173280221,
14614
- size: 27309,
14615
- hash: "f0d08938713d9d89a56a3a386cacbc2b57afd5ad367ea82d827d40e1bfc70989",
14616
- validatorWalletAddress: "0x82DB9F515957aA380B596C6eA2Bd30CEF181f236",
14613
+ deployedAt: 1790179971315,
14614
+ size: 30295,
14615
+ hash: "2c67d9cfa4d50e835fbb28ae50e80217ceb2be3bb862c89290aadf43fdc739c9",
14616
+ validatorWalletAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C",
14617
14617
  pkp: {
14618
14618
  publicKey: "0x0498cbb31facfa26e3ec83ccdabfe4fe341ca0282e0c3cb81da7113723b9726e1e49efa92165cc3faa66ced4454cea56dbab12267852d6525a55d7c4f128b912cd",
14619
- ethAddress: "0xc7e1588Db94Bbe92Ab209B833235144Fc5b97607"
14619
+ ethAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C"
14620
14620
  }
14621
14621
  },
14622
14622
  alwaysSigner: {
@@ -14646,48 +14646,48 @@ var require_pkg_src = __commonJS({
14646
14646
  hash: "03ee5be239c91c735d2c95db89a0d1b77e602cfc18af8eb64b3281fddcd90a72"
14647
14647
  },
14648
14648
  agentModuleExecutor: {
14649
- cid: "QmcD65vuremot5fsHVgp9JBAmei6gAaEtm5mdtLP7Yt9Kf",
14649
+ cid: "QmSwPPvQhT7UhcuVA2m3UxGhVj5WqMpDvYNKU1228QLFsX",
14650
14650
  authorizedCidHex: cidToHex(
14651
- "QmcD65vuremot5fsHVgp9JBAmei6gAaEtm5mdtLP7Yt9Kf"
14651
+ "QmSwPPvQhT7UhcuVA2m3UxGhVj5WqMpDvYNKU1228QLFsX"
14652
14652
  ),
14653
14653
  name: "Agent Module Executor",
14654
14654
  description: "Production Agent Module Executor",
14655
14655
  version: "1.1.1",
14656
14656
  deployed: true,
14657
- deployedAt: 1787924032013,
14658
- size: 13878,
14659
- hash: "a7f0204700912e26e5a354bee13a1242a2baa218643b3bb22d28481f67f9baf4"
14657
+ deployedAt: 1790179978959,
14658
+ size: 14688,
14659
+ hash: "8edb9b12c784c8d7d153cce97235584c24665a788767ae68713dce91109ab35e"
14660
14660
  },
14661
14661
  staleSpendRecoveryValidator: {
14662
- cid: "QmNuwo4PT4AikAmhMdZgPWCb2mJDwWa9TnUqrqvofjbrT8",
14662
+ cid: "Qmarj59zdSSgivkimryrdvnyZqH5YpTimKj1LivXNBHmNz",
14663
14663
  authorizedCidHex: cidToHex(
14664
- "QmNuwo4PT4AikAmhMdZgPWCb2mJDwWa9TnUqrqvofjbrT8"
14664
+ "Qmarj59zdSSgivkimryrdvnyZqH5YpTimKj1LivXNBHmNz"
14665
14665
  ),
14666
14666
  name: "Stale Spend Recovery Validator",
14667
14667
  description: "Production Stale Spend Recovery Validator",
14668
14668
  version: "1.1.2",
14669
14669
  deployed: true,
14670
- deployedAt: 1787924048772,
14671
- size: 41424,
14672
- hash: "3c5f028d2bef4344768462993616d45e30d9d44ef126e04d6eb579821d57d99c",
14673
- validatorWalletAddress: "0x82DB9F515957aA380B596C6eA2Bd30CEF181f236",
14670
+ deployedAt: 1790246256280,
14671
+ size: 48143,
14672
+ hash: "ec9236bcbe0af24d3e1844791fc8fe37371bbecd8ce95d02e13f7c6e1fc7d94c",
14673
+ validatorWalletAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C",
14674
14674
  pkp: {
14675
14675
  publicKey: "0x046da0ad6da7dd4a0063cbeac6f2bdb6a9889c2178b23470833356a8ee5630f7f0eee0db348d9d9aaaadd23eccf0063c8f68ee5e446abe30b882bf1de4c932bc21",
14676
- ethAddress: "0xc7e1588Db94Bbe92Ab209B833235144Fc5b97607"
14676
+ ethAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C"
14677
14677
  }
14678
14678
  },
14679
14679
  btcUtxoInvalidator: {
14680
- cid: "QmaNGeWut7EiGwW4zUc2sFSt7RY5NWFgxYboyG333TwrJf",
14680
+ cid: "QmbS44bGcmKYF64Cu35qzsk9sxiU4Umde8Z3q24ZnEbQvX",
14681
14681
  authorizedCidHex: cidToHex(
14682
- "QmaNGeWut7EiGwW4zUc2sFSt7RY5NWFgxYboyG333TwrJf"
14682
+ "QmbS44bGcmKYF64Cu35qzsk9sxiU4Umde8Z3q24ZnEbQvX"
14683
14683
  ),
14684
14684
  name: "Btc Utxo Invalidator",
14685
14685
  description: "Production Btc Utxo Invalidator",
14686
14686
  version: "1.0.0",
14687
14687
  deployed: true,
14688
- deployedAt: 1787924133241,
14689
- size: 66026,
14690
- hash: "603bc50920d7f1dee77086f2c518d9e2922ab3858a419d3fbea8221ea3a6d9e9"
14688
+ deployedAt: 1790246264563,
14689
+ size: 69219,
14690
+ hash: "bda048d8cd6b5a39c2774bcf1320e82d1eea935c2a521006fb8b887e13b6dd8d"
14691
14691
  }
14692
14692
  };
14693
14693
  function getDeploymentsForNetwork(network) {
@@ -15431,7 +15431,7 @@ ${errorReport}`);
15431
15431
  }
15432
15432
  init_debug_logger();
15433
15433
  init_session_signature_cache();
15434
- var import_ethers52 = require("ethers");
15434
+ var import_ethers53 = require("ethers");
15435
15435
  var EXPIRED_LOAN_MIN_LIQUIDATION_THRESHOLD_BPS = 11e3;
15436
15436
  var GRACE_PERIOD_DAYS = 30;
15437
15437
  var SATOSHIS_PER_BITCOIN = 100000000n;
@@ -15453,7 +15453,10 @@ ${errorReport}`);
15453
15453
  BTCSpendAuthorizer: "0xfBbF108486fa07F1B06a811C5b66ed68DD9c508a",
15454
15454
  BitcoinProviderRegistry: "0x4ab3Fb96e02893Ed6FAa61bad1918390c8DbbFFC",
15455
15455
  LITActionValidator: "0xD2c5d59c2CC5c409AC65ce0A817236aeC6869512",
15456
- PositionDelegateRegistry: "0xf0aa2678aD4F60f49e8F7725089B5E86B7F8FE4C"
15456
+ PositionDelegateRegistry: "0xf0aa2678aD4F60f49e8F7725089B5E86B7F8FE4C",
15457
+ TermManagerModule: "0xDB99CdF883ffa38acD099bC39F8d1f4508c9239E",
15458
+ UCDController: "0x4b4f8063048bCD59D469219E3f07C6aaDF4f6157",
15459
+ LiquidationManagerModule: "0x74B28695352E7bf736D6c9F76ccb7B4439477De9"
15457
15460
  },
15458
15461
  11155111: {
15459
15462
  PositionManager: "0x68e0507D982AEBF1D1C1Af8FBbd842327e2deeFF",
@@ -15461,7 +15464,10 @@ ${errorReport}`);
15461
15464
  BTCSpendAuthorizer: "0xd7E9Eb5eE53f1d9ee55Dc162bBC7486bE437B6bD",
15462
15465
  BitcoinProviderRegistry: "0xbfA0c48B070D0a9A9CD27469AeacFD2d4261cEE2",
15463
15466
  LITActionValidator: "0x54eECd7C90F8A8fac27749Ba30BbE8AFBAccc856",
15464
- PositionDelegateRegistry: "0x482369De283622E7b05731875ec137d4E3D208F9"
15467
+ PositionDelegateRegistry: "0x482369De283622E7b05731875ec137d4E3D208F9",
15468
+ TermManagerModule: "0x94Adc6F9558368B1482197584f1fc7133Ecf835b",
15469
+ UCDController: "0x360Bde4e489ee94E26601B206932De09EE60FF04",
15470
+ LiquidationManagerModule: "0xC4AB00f39e7ceD812F5C67058C9fa44e15d40e76"
15465
15471
  }
15466
15472
  };
15467
15473
  function getPinnedContractAddresses(chainId) {
@@ -15647,10 +15653,10 @@ ${errorReport}`);
15647
15653
  };
15648
15654
  }
15649
15655
  const ratioBigInt = collateralValueUsd * UCD_TOKEN_DECIMALS * 10000n / ucdDebt;
15650
- const collateralRatioBps = Number(ratioBigInt);
15656
+ const collateralRatioBps2 = Number(ratioBigInt);
15651
15657
  return {
15652
15658
  collateralValueUsd,
15653
- collateralRatioBps
15659
+ collateralRatioBps: collateralRatioBps2
15654
15660
  };
15655
15661
  }
15656
15662
  function hasSufficientCollateralForDebt(collateralValueUsd, currentDebt, additionalDebt, requiredRatioBps) {
@@ -16495,6 +16501,17 @@ ${auth.clientId}`;
16495
16501
  );
16496
16502
  }
16497
16503
  }
16504
+ var TIP_READ_FAILURE_PREFIX = "Bitcoin tip-height read failed";
16505
+ var BitcoinTipUnreadableError = class extends Error {
16506
+ constructor(message) {
16507
+ super(message);
16508
+ this.isBitcoinTipUnreadable = true;
16509
+ this.name = "BitcoinTipUnreadableError";
16510
+ }
16511
+ };
16512
+ function isBitcoinTipUnreadableError(error) {
16513
+ return typeof error === "object" && error !== null && error.isBitcoinTipUnreadable === true;
16514
+ }
16498
16515
  var BitcoinDataProvider = class {
16499
16516
  constructor(config) {
16500
16517
  this.config = config;
@@ -16946,27 +16963,12 @@ ${auth.clientId}`;
16946
16963
  if (!data.status.confirmed || !data.status.block_height) {
16947
16964
  return { txid: data.txid ?? txid, confirmations: 0 };
16948
16965
  }
16949
- try {
16950
- const tipResp = await fetch(
16951
- `${this.config.providerUrl}/blocks/tip/height`,
16952
- { signal: controller.signal, headers: await this.withAuth() }
16953
- );
16954
- if (!tipResp.ok) {
16955
- return { txid: data.txid ?? txid, confirmations: 1 };
16956
- }
16957
- const tipBody = (await tipResp.text()).trim();
16958
- const tipHeight = Number.parseInt(tipBody, 10);
16959
- if (!Number.isFinite(tipHeight) || tipHeight <= 0) {
16960
- return { txid: data.txid ?? txid, confirmations: 1 };
16961
- }
16962
- const depth = tipHeight - data.status.block_height + 1;
16963
- return {
16964
- txid: data.txid ?? txid,
16965
- confirmations: depth > 0 ? depth : 0
16966
- };
16967
- } catch {
16968
- return { txid: data.txid ?? txid, confirmations: 1 };
16969
- }
16966
+ const tipHeight = await this.fetchTipHeight(controller.signal);
16967
+ const depth = tipHeight - data.status.block_height + 1;
16968
+ return {
16969
+ txid: data.txid ?? txid,
16970
+ confirmations: depth > 0 ? depth : 0
16971
+ };
16970
16972
  }
16971
16973
  return null;
16972
16974
  } catch (error) {
@@ -16974,12 +16976,55 @@ ${auth.clientId}`;
16974
16976
  if (isAbortError(error)) {
16975
16977
  throw new Error(`Request timeout after ${this.timeout}ms`);
16976
16978
  }
16979
+ if (isBitcoinTipUnreadableError(error)) {
16980
+ throw error;
16981
+ }
16977
16982
  if (getUnknownErrorMessage(error).includes("404")) {
16978
16983
  return null;
16979
16984
  }
16980
16985
  throw error;
16981
16986
  }
16982
16987
  }
16988
+ /**
16989
+ * Current chain tip height from THIS provider — or throw.
16990
+ *
16991
+ * Every exit is a throw naming the provider and the precise failure, because
16992
+ * the only alternative is inventing a confirmation depth (see the call site).
16993
+ * The single `try` exists solely to attach that name to a transport-level
16994
+ * rejection (DNS, TLS, connection reset, abort); it re-throws the cause
16995
+ * verbatim inside the message and never substitutes a value — authorized for
16996
+ * this case by the Batch 2 plan, §C2.
16997
+ *
16998
+ * @param signal - The caller's AbortSignal, so this read shares the same
16999
+ * timeout budget as the transaction fetch it serves.
17000
+ */
17001
+ async fetchTipHeight(signal) {
17002
+ const endpoint = `${this.config.providerUrl}/blocks/tip/height`;
17003
+ let tipResp;
17004
+ try {
17005
+ tipResp = await fetch(endpoint, {
17006
+ signal,
17007
+ headers: await this.withAuth()
17008
+ });
17009
+ } catch (error) {
17010
+ throw new BitcoinTipUnreadableError(
17011
+ `${TIP_READ_FAILURE_PREFIX}: GET ${endpoint} threw \u2014 ${getUnknownErrorMessage(error)}`
17012
+ );
17013
+ }
17014
+ if (!tipResp.ok) {
17015
+ throw new BitcoinTipUnreadableError(
17016
+ `${TIP_READ_FAILURE_PREFIX}: GET ${endpoint} \u2192 ${tipResp.status} ${tipResp.statusText}`
17017
+ );
17018
+ }
17019
+ const tipBody = (await tipResp.text()).trim();
17020
+ const tipHeight = Number.parseInt(tipBody, 10);
17021
+ if (!Number.isFinite(tipHeight) || tipHeight <= 0) {
17022
+ throw new BitcoinTipUnreadableError(
17023
+ `${TIP_READ_FAILURE_PREFIX}: GET ${endpoint} returned an unusable tip height "${tipBody.slice(0, 64)}"`
17024
+ );
17025
+ }
17026
+ return tipHeight;
17027
+ }
16983
17028
  /**
16984
17029
  * Get outputs (vouts) of a Bitcoin transaction
16985
17030
  *
@@ -17614,10 +17659,13 @@ ${auth.clientId}`;
17614
17659
  * only on unanimity. The confirmed-balance consensus the validators run
17615
17660
  * covers `chain_stats` only, so without this the primary provider alone
17616
17661
  * could fabricate an unconfirmed UTXO plus a self-consistent parent proof
17617
- * and inflate the signed balance. Any provider failure or verdict
17618
- * disagreement THROWS (fail-closed) — exclusion on a suppressed proof
17619
- * would deflate the balance and open a wrongful-liquidation window, so
17620
- * neither direction may proceed without agreement.
17662
+ * and inflate the signed balance. Any verdict disagreement THROWS
17663
+ * (fail-closed) — exclusion on a suppressed proof would deflate the balance
17664
+ * and open a wrongful-liquidation window, so neither direction may proceed
17665
+ * without agreement. A provider that cannot state the chain tip — and only
17666
+ * that failure — is dropped from the quorum rather than aborting the read (it
17667
+ * never counts as agreeing), and falling below `minConsensusProviders`
17668
+ * survivors throws — see `verifyParentIsSelfSpendConsensus`.
17621
17669
  *
17622
17670
  * The same per-provider `/tx` fetch also returns the parent's outputs, and
17623
17671
  * every provider must corroborate each claimed UTXO (index, vault address,
@@ -17712,10 +17760,26 @@ ${auth.clientId}`;
17712
17760
  }
17713
17761
  /**
17714
17762
  * Run the self-spend proof against every configured provider and require
17715
- * unanimity. Fail-closed: a provider request failure or a verdict
17716
- * disagreement throws and aborts the balance calculation — see
17763
+ * unanimity AMONG THE PROVIDERS THAT ANSWERED. Fail-closed on disagreement:
17764
+ * a verdict mismatch throws and aborts the balance calculation — see
17717
17765
  * classifySelfChange for why exclusion is not a safe fallback here.
17718
17766
  *
17767
+ * Quorum semantics (2026-09-23, plan C2). ONE failure class is tolerated: a
17768
+ * provider that could not state the chain tip (`BitcoinTipUnreadableError`).
17769
+ * It is ABSENT from the quorum — never counted as agreeing, never allowed to
17770
+ * decide the verdict — and the policy floor, not "at least one", decides when
17771
+ * that absence is fatal: below `minConsensusProviders` surviving readings
17772
+ * there is no cross-check left to trust, and the read fails loudly naming
17773
+ * every provider that dropped out.
17774
+ *
17775
+ * Why only that class. `getTransaction` now throws on an unreadable tip
17776
+ * instead of fabricating `confirmations: 1`; without this carve-out one flaky
17777
+ * `/blocks/tip/height` endpoint would take every balance and spend path down
17778
+ * with it. Every OTHER failure remains fatal, as before: a provider that
17779
+ * answers "I have never seen that transaction" is making a claim about the
17780
+ * chain rather than suffering an outage, and that shape is precisely the
17781
+ * fabricated-UTXO signature the fail-closed rule exists to catch.
17782
+ *
17719
17783
  * When the parent IS a unanimous self-spend, every provider's view of the
17720
17784
  * parent's OUTPUTS must additionally corroborate the primary's claimed
17721
17785
  * UTXOs (index exists, pays the vault, exact value). Without this, a
@@ -17740,32 +17804,52 @@ ${auth.clientId}`;
17740
17804
  )
17741
17805
  )
17742
17806
  );
17743
- const failures = settled.map((r, i) => ({ r, name: providerName(i) })).filter(
17744
- (x) => x.r.status === "rejected"
17745
- ).map(
17746
- ({ r, name }) => `${name} \u2192 ${r.reason?.message ?? String(r.reason)}`
17747
- );
17807
+ const answered = [];
17808
+ const absences = [];
17809
+ const failures = [];
17810
+ settled.forEach((result, i) => {
17811
+ if (result.status === "fulfilled") {
17812
+ answered.push({ index: i, evaluation: result.value });
17813
+ return;
17814
+ }
17815
+ const described = `${providerName(i)} \u2192 ${result.reason?.message ?? String(result.reason)}`;
17816
+ if (isBitcoinTipUnreadableError(result.reason)) {
17817
+ absences.push(described);
17818
+ return;
17819
+ }
17820
+ failures.push(described);
17821
+ });
17748
17822
  if (failures.length > 0) {
17749
17823
  throw new Error(
17750
17824
  `Self-change classification failed for tx ${parentTxid} on ${failures.length}/${providerConfigs.length} provider(s): ${failures.join("; ")}`
17751
17825
  );
17752
17826
  }
17753
- const evaluations = settled.map(
17754
- (r) => r.value
17755
- );
17756
- const votes = evaluations.map((e) => e.selfSpend);
17757
- const disagreements = votes.map((vote, i) => ({ vote, name: providerName(i) })).filter((x) => x.vote !== votes[0]).map(
17758
- (x) => `${providerName(0)}=${votes[0]} vs ${x.name}=${x.vote}`
17827
+ const floor = Math.max(1, this.minConsensusProviders);
17828
+ if (answered.length < floor) {
17829
+ throw new Error(
17830
+ `Self-change classification for tx ${parentTxid}: only ${answered.length}/${providerConfigs.length} provider(s) could state a confirmation depth, below this chain's floor of ${floor}. Unreadable tips: ${absences.join("; ")}`
17831
+ );
17832
+ }
17833
+ if (absences.length > 0) {
17834
+ litDebugLog(
17835
+ `[VaultBalance] self-change: tx ${parentTxid} classified on a reduced quorum \u2014 ${answered.length}/${providerConfigs.length} provider(s) answered (floor ${floor}); dropped for an unreadable chain tip: ${absences.join("; ")}`
17836
+ );
17837
+ }
17838
+ const first = answered[0];
17839
+ const disagreements = answered.slice(1).filter((a) => a.evaluation.selfSpend !== first.evaluation.selfSpend).map(
17840
+ (a) => `${providerName(first.index)}=${first.evaluation.selfSpend} vs ${providerName(a.index)}=${a.evaluation.selfSpend}`
17759
17841
  );
17760
17842
  if (disagreements.length > 0) {
17761
17843
  throw new Error(
17762
17844
  `Self-change consensus mismatch for tx ${parentTxid}: ${disagreements.join("; ")}. A provider may be compromised or out of sync; refusing to sign.`
17763
17845
  );
17764
17846
  }
17765
- if (!votes[0]) {
17847
+ if (!first.evaluation.selfSpend) {
17766
17848
  return false;
17767
17849
  }
17768
- const outputMismatches = evaluations.map((e, i) => e.outputMismatch ? `${providerName(i)} \u2192 ${e.outputMismatch}` : null).filter((m) => m !== null);
17850
+ const outputMismatches = answered.map(
17851
+ (a) => a.evaluation.outputMismatch ? `${providerName(a.index)} \u2192 ${a.evaluation.outputMismatch}` : null
17852
+ ).filter((m) => m !== null);
17769
17853
  if (outputMismatches.length > 0) {
17770
17854
  throw new Error(
17771
17855
  `Self-change output claim mismatch for tx ${parentTxid}: ${outputMismatches.join("; ")}. The reported UTXO set contradicts the parent transaction; refusing to sign.`
@@ -18008,16 +18092,6 @@ ${auth.clientId}`;
18008
18092
  minConfirmations
18009
18093
  );
18010
18094
  const authorizedSpends = await this.getAuthorizedSpendsFromContract(positionId);
18011
- for (const spend of authorizedSpends) {
18012
- const utxoStillExists = utxoSet.utxos.some(
18013
- (utxo) => utxo.txid === spend.txid && utxo.vout === spend.vout
18014
- );
18015
- if (utxoStillExists) {
18016
- throw new Error(
18017
- `Authorized UTXO ${spend.txid}:${spend.vout} not yet spent. Transaction was authorized in smart contract but not signed and broadcasted to Bitcoin network. Complete the transaction by signing and broadcasting it.`
18018
- );
18019
- }
18020
- }
18021
18095
  const authorizedBalance = authorizedSpends.reduce(
18022
18096
  (sum, spend) => sum + spend.satoshis,
18023
18097
  0n
@@ -18313,7 +18387,13 @@ ${auth.clientId}`;
18313
18387
  allowDevSinglePriceProvider: false,
18314
18388
  minBitcoinBalanceConfirmations: 1,
18315
18389
  minBitcoinSpendConfirmations: 1,
18316
- minConsensusProviders: 1
18390
+ // 2 since 2026-09-23. It was 1 because Sepolia ran a single faucet provider
18391
+ // "by design", so the consensus floor was documented as a mainnet-only
18392
+ // guarantee. The registry now holds two, and leaving the floor at 1 meant
18393
+ // Sepolia could never exercise the multi-provider agreement the stale-spend
18394
+ // and balance paths rely on — the one environment where that logic is
18395
+ // supposed to be proved before mainnet.
18396
+ minConsensusProviders: 2
18317
18397
  },
18318
18398
  [
18319
18399
  "ethereum"
@@ -18347,12 +18427,12 @@ ${auth.clientId}`;
18347
18427
  }
18348
18428
  async function executeVaultSnapshot(params) {
18349
18429
  global.ethers = {
18350
- ...import_ethers52.ethers,
18430
+ ...import_ethers53.ethers,
18351
18431
  providers: {
18352
- StaticJsonRpcProvider: import_ethers52.ethers.JsonRpcProvider
18432
+ StaticJsonRpcProvider: import_ethers53.ethers.JsonRpcProvider
18353
18433
  },
18354
- Contract: import_ethers52.ethers.Contract,
18355
- utils: import_ethers52.ethers
18434
+ Contract: import_ethers53.ethers.Contract,
18435
+ utils: import_ethers53.ethers
18356
18436
  // v6 moved utils to top level
18357
18437
  };
18358
18438
  global.Lit = {
@@ -23922,9 +24002,35 @@ var require_fetch_lit_action_from_ipfs = __commonJS({
23922
24002
  return mod && mod.__esModule ? mod : { "default": mod };
23923
24003
  };
23924
24004
  Object.defineProperty(exports2, "__esModule", { value: true });
24005
+ exports2.computeCidV0 = computeCidV0;
23925
24006
  exports2.fetchLitActionCodeFromIpfs = fetchLitActionCodeFromIpfs;
23926
24007
  var axios_1 = __importDefault(require_axios());
24008
+ var ethers_1 = require("ethers");
23927
24009
  var ipfsCodeCache = /* @__PURE__ */ new Map();
24010
+ var CIDV0 = /^Qm[1-9A-HJ-NP-Za-km-z]{44}$/;
24011
+ var SINGLE_BLOCK_MAX_BYTES = 262144;
24012
+ function varint(n) {
24013
+ const out = [];
24014
+ while (n >= 128) {
24015
+ out.push(n & 127 | 128);
24016
+ n >>>= 7;
24017
+ }
24018
+ out.push(n);
24019
+ return out;
24020
+ }
24021
+ function computeCidV0(content) {
24022
+ const n = varint(content.length);
24023
+ const unixfs = new Uint8Array([8, 2, 18, ...n, ...content, 24, ...n]);
24024
+ const node = new Uint8Array([10, ...varint(unixfs.length), ...unixfs]);
24025
+ return (0, ethers_1.encodeBase58)(new Uint8Array([18, 32, ...(0, ethers_1.getBytes)((0, ethers_1.sha256)(node))]));
24026
+ }
24027
+ function responseBytes(data) {
24028
+ if (data instanceof Uint8Array)
24029
+ return data;
24030
+ if (data instanceof ArrayBuffer)
24031
+ return new Uint8Array(data);
24032
+ return null;
24033
+ }
23928
24034
  var GATEWAY_TIMEOUT_MS = 2e4;
23929
24035
  var buildGatewayList = (cid, pinataJwt) => {
23930
24036
  const gateways = [];
@@ -23945,6 +24051,9 @@ var require_fetch_lit_action_from_ipfs = __commonJS({
23945
24051
  }
23946
24052
  return cached;
23947
24053
  }
24054
+ if (!CIDV0.test(cid)) {
24055
+ throw new Error(`Refusing to fetch LIT Action for ${cid}: only CIDv0 (Qm\u2026) content can be verified`);
24056
+ }
23948
24057
  const pinataJwt = options.pinataJwt ?? process.env.PINATA_JWT;
23949
24058
  const extraGateways = options.extraGateways?.map((t) => ({ url: t.replace("{cid}", cid) })) ?? [];
23950
24059
  const gateways = [...extraGateways, ...buildGatewayList(cid, pinataJwt)];
@@ -23956,19 +24065,32 @@ var require_fetch_lit_action_from_ipfs = __commonJS({
23956
24065
  }
23957
24066
  const response = await axios_1.default.get(gateway.url, {
23958
24067
  timeout: GATEWAY_TIMEOUT_MS,
24068
+ responseType: "arraybuffer",
23959
24069
  headers: {
23960
24070
  Accept: "text/plain, application/javascript, text/javascript",
23961
24071
  ...gateway.headers
23962
24072
  }
23963
24073
  });
23964
- if (response.data && typeof response.data === "string") {
23965
- if (options.debug) {
23966
- console.log(`\u2705 [fetchLitActionCodeFromIpfs] Fetched from ${gateway.url}`);
23967
- }
23968
- ipfsCodeCache.set(cid, response.data);
23969
- return response.data;
24074
+ const bytes = responseBytes(response.data);
24075
+ if (!bytes || bytes.length === 0) {
24076
+ failures.push(`${gateway.url}: HTTP ${response.status} returned ${bytes ? "an empty body" : typeof response.data}, expected bytes`);
24077
+ continue;
23970
24078
  }
23971
- failures.push(`${gateway.url}: HTTP ${response.status} returned ${typeof response.data}, expected string`);
24079
+ if (bytes.length > SINGLE_BLOCK_MAX_BYTES) {
24080
+ failures.push(`${gateway.url}: ${bytes.length} bytes exceeds the single-block CIDv0 limit (${SINGLE_BLOCK_MAX_BYTES}); content cannot be verified`);
24081
+ continue;
24082
+ }
24083
+ const actualCid = computeCidV0(bytes);
24084
+ if (actualCid !== cid) {
24085
+ failures.push(`${gateway.url}: content hashes to ${actualCid}, not the requested CID`);
24086
+ continue;
24087
+ }
24088
+ const code = new TextDecoder("utf-8", { fatal: true }).decode(bytes);
24089
+ if (options.debug) {
24090
+ console.log(`\u2705 [fetchLitActionCodeFromIpfs] Fetched and verified from ${gateway.url}`);
24091
+ }
24092
+ ipfsCodeCache.set(cid, code);
24093
+ return code;
23972
24094
  } catch (error) {
23973
24095
  const message = error instanceof Error ? error.message : String(error);
23974
24096
  failures.push(`${gateway.url}: ${message}`);
@@ -25456,6 +25578,53 @@ var require_pkp_signer_module = __commonJS({
25456
25578
  }
25457
25579
  });
25458
25580
 
25581
+ // node_modules/@gvnrdao/dh-lit-ops/dist/modules/mainnet-validator-wallets.js
25582
+ var require_mainnet_validator_wallets = __commonJS({
25583
+ "node_modules/@gvnrdao/dh-lit-ops/dist/modules/mainnet-validator-wallets.js"(exports2) {
25584
+ "use strict";
25585
+ Object.defineProperty(exports2, "__esModule", { value: true });
25586
+ exports2.MAINNET_OP_VALIDATOR_WALLETS = exports2.SEPOLIA_DEFAULT_VALIDATOR_WALLET = exports2.NON_MAINNET_CHAIN_IDS = void 0;
25587
+ exports2.resolveMainnetValidatorWallet = resolveMainnetValidatorWallet;
25588
+ exports2.NON_MAINNET_CHAIN_IDS = /* @__PURE__ */ new Set([
25589
+ 11155111,
25590
+ // Sepolia
25591
+ 1337,
25592
+ // Hardhat (DH local deployment chainId)
25593
+ 31337
25594
+ // Hardhat (default)
25595
+ ]);
25596
+ exports2.SEPOLIA_DEFAULT_VALIDATOR_WALLET = "0xefb258d455a31d061bbeb3de3d2143bdfcb67a6c";
25597
+ exports2.MAINNET_OP_VALIDATOR_WALLETS = {
25598
+ ucdMintValidator: "0x19C8FeE0f8f4b6F9Aa8e521D4CC62F4697CF85af",
25599
+ processPaymentValidator: "0x01480725c1fA026fd4A6bfA3100c691aeC955135",
25600
+ extendPositionValidator: "0xcE08AF213D8d95ad3dD317276F9e93Ab2eD75030",
25601
+ btcWithdrawal: "0x69dCd1204CDB31437CaF7114f74422390b472d3A",
25602
+ loanVaultBtcBalance: "0xc3d549EEb62721750Ff6518f6730Ab0e8D0Fea97",
25603
+ liquidationValidator: "0x66B30C19173005A51f21e2e4180FD7BC8c1d485b",
25604
+ // Non-OAR: verified on-chain by BTCSpendAuthorizer.staleSpendValidatorAddress (set via
25605
+ // AdminModule to this PKP's derived signer). Self-deriving Safe-owned PKP; seed == signer.
25606
+ staleSpendRecoveryValidator: "0x58F9144cF9781c15C061ba86901905a5a19F7661",
25607
+ // Non-OAR: no on-chain consumer verifies these signatures. The Sepolia seed has no key
25608
+ // derivation registered on the mainnet Lit account, so they reuse the Safe-owned
25609
+ // pkp-validator PKP (live derivation, group 2). See
25610
+ // docs/INCIDENT_2026-09-21_MAINNET_PKP_DERIVATION_DECRYPT.md.
25611
+ btcAddressBalance: "0x19524aE4e514a0f08A542596c2DA0B2262c61f48",
25612
+ priceOracle: "0x19524aE4e514a0f08A542596c2DA0B2262c61f48"
25613
+ };
25614
+ function resolveMainnetValidatorWallet(args) {
25615
+ const { registryKey, chainId, wallet } = args;
25616
+ const isNonMainnetChain = Number.isFinite(chainId) && exports2.NON_MAINNET_CHAIN_IDS.has(chainId);
25617
+ if (isNonMainnetChain || !wallet || wallet.toLowerCase() !== exports2.SEPOLIA_DEFAULT_VALIDATOR_WALLET) {
25618
+ return wallet;
25619
+ }
25620
+ if (!registryKey || !Object.prototype.hasOwnProperty.call(exports2.MAINNET_OP_VALIDATOR_WALLETS, registryKey)) {
25621
+ return wallet;
25622
+ }
25623
+ return exports2.MAINNET_OP_VALIDATOR_WALLETS[registryKey];
25624
+ }
25625
+ }
25626
+ });
25627
+
25459
25628
  // node_modules/@gvnrdao/dh-lit-ops/dist/utils/async-request.util.js
25460
25629
  var require_async_request_util = __commonJS({
25461
25630
  "node_modules/@gvnrdao/dh-lit-ops/dist/utils/async-request.util.js"(exports2) {
@@ -25483,7 +25652,9 @@ var require_async_request_util = __commonJS({
25483
25652
  });
25484
25653
  if (!submitResponse.ok) {
25485
25654
  const errorText = await submitResponse.text();
25486
- throw new Error(`Failed to submit request (${submitResponse.status}): ${errorText}`);
25655
+ const retryAfter = submitResponse.status === 429 ? submitResponse.headers.get("retry-after") : null;
25656
+ const retryHint = retryAfter && /^\d+$/.test(retryAfter.trim()) ? ` Retry after ${retryAfter.trim()}s.` : "";
25657
+ throw new Error(`Failed to submit request (${submitResponse.status}): ${errorText}${retryHint}`);
25487
25658
  }
25488
25659
  const submitEnvelope = await submitResponse.json();
25489
25660
  if (!submitEnvelope.success || !submitEnvelope.data?.ticketId) {
@@ -25761,6 +25932,7 @@ var require_lit_ops_module = __commonJS({
25761
25932
  var pkp_manager_module_1 = require_pkp_manager_module();
25762
25933
  var pkp_minter_module_1 = require_pkp_minter_module();
25763
25934
  var pkp_signer_module_1 = require_pkp_signer_module();
25935
+ var mainnet_validator_wallets_1 = require_mainnet_validator_wallets();
25764
25936
  var async_request_util_1 = require_async_request_util();
25765
25937
  var crypto_1 = require("crypto");
25766
25938
  var lit_core_lit_action_client_1 = require_lit_core_lit_action_client();
@@ -25773,26 +25945,6 @@ var require_lit_ops_module = __commonJS({
25773
25945
  { name: "borrower", type: "address" }
25774
25946
  ]
25775
25947
  };
25776
- var NON_MAINNET_CHAIN_IDS = /* @__PURE__ */ new Set([
25777
- 11155111,
25778
- // Sepolia
25779
- 1337,
25780
- // Hardhat (DH local deployment chainId)
25781
- 31337
25782
- // Hardhat (default)
25783
- ]);
25784
- var SEPOLIA_DEFAULT_VALIDATOR_WALLET = "0x82db9f515957aa380b596c6ea2bd30cef181f236";
25785
- var MAINNET_OP_VALIDATOR_WALLETS = {
25786
- ucdMintValidator: "0x19C8FeE0f8f4b6F9Aa8e521D4CC62F4697CF85af",
25787
- processPaymentValidator: "0x01480725c1fA026fd4A6bfA3100c691aeC955135",
25788
- extendPositionValidator: "0xcE08AF213D8d95ad3dD317276F9e93Ab2eD75030",
25789
- btcWithdrawal: "0x69dCd1204CDB31437CaF7114f74422390b472d3A",
25790
- loanVaultBtcBalance: "0xc3d549EEb62721750Ff6518f6730Ab0e8D0Fea97",
25791
- liquidationValidator: "0x66B30C19173005A51f21e2e4180FD7BC8c1d485b",
25792
- // Non-OAR: verified on-chain by BTCSpendAuthorizer.staleSpendValidatorAddress (set via
25793
- // AdminModule to this PKP's derived signer). Self-deriving Safe-owned PKP; seed == signer.
25794
- staleSpendRecoveryValidator: "0x58F9144cF9781c15C061ba86901905a5a19F7661"
25795
- };
25796
25948
  function resolvePkpValidationRegistryAddress(config) {
25797
25949
  const fromConfig = config.pkpValidationRegistryAddress;
25798
25950
  return fromConfig || process.env.PKP_VALIDATION_REGISTRY_ADDRESS || process.env.PKP_VALIDATION_REGISTRY;
@@ -27033,17 +27185,18 @@ var require_lit_ops_module = __commonJS({
27033
27185
  let effectiveValidatorWallet = litActionInfo.validatorWalletAddress;
27034
27186
  const jp = jsParams;
27035
27187
  const resolvedChainId = Number(jp.chainId ?? jp.auth?.chainId ?? jp.authMessage?.chainId ?? this.config.chainId);
27036
- const isNonMainnetChain = Number.isFinite(resolvedChainId) && NON_MAINNET_CHAIN_IDS.has(resolvedChainId);
27037
- if (!isNonMainnetChain && effectiveValidatorWallet && effectiveValidatorWallet.toLowerCase() === SEPOLIA_DEFAULT_VALIDATOR_WALLET) {
27038
- const reg = (0, dh_lit_actions_1.getDeploymentsForNetwork)(this.config.network);
27039
- const registryKey = Object.keys(reg).find((k) => reg[k]?.cid === litActionInfo.cid);
27040
- const mainnetWallet = registryKey ? MAINNET_OP_VALIDATOR_WALLETS[registryKey] : void 0;
27041
- if (mainnetWallet) {
27042
- if (this.config.debug) {
27043
- console.log(`[${label}] mainnet validator remap (${registryKey}, chainId=${Number.isFinite(resolvedChainId) ? resolvedChainId : "unknown\u2192mainnet"}): ${effectiveValidatorWallet} -> ${mainnetWallet}`);
27044
- }
27045
- effectiveValidatorWallet = mainnetWallet;
27188
+ const reg = (0, dh_lit_actions_1.getDeploymentsForNetwork)(this.config.network);
27189
+ const registryKey = Object.keys(reg).find((k) => reg[k]?.cid === litActionInfo.cid);
27190
+ const mainnetWallet = (0, mainnet_validator_wallets_1.resolveMainnetValidatorWallet)({
27191
+ registryKey,
27192
+ chainId: resolvedChainId,
27193
+ wallet: effectiveValidatorWallet
27194
+ });
27195
+ if (mainnetWallet !== effectiveValidatorWallet) {
27196
+ if (this.config.debug) {
27197
+ console.log(`[${label}] mainnet validator remap (${registryKey}, chainId=${Number.isFinite(resolvedChainId) ? resolvedChainId : "unknown\u2192mainnet"}): ${effectiveValidatorWallet} -> ${mainnetWallet}`);
27046
27198
  }
27199
+ effectiveValidatorWallet = mainnetWallet;
27047
27200
  }
27048
27201
  if (process.env.LIT_LANE_VALIDATOR_WALLET_OVERRIDE) {
27049
27202
  if (process.env.LIT_LANE_GUARD !== "1") {
@@ -28210,7 +28363,11 @@ var require_lit_ops_module = __commonJS({
28210
28363
  error: "sign=true requires price oracle PKP in registry (ethAddress/publicKey) or options.pkpId (Lit jsParams pkpId)"
28211
28364
  };
28212
28365
  }
28213
- priceOracleParams.pkpId = resolvedPkpId;
28366
+ priceOracleParams.pkpId = (0, mainnet_validator_wallets_1.resolveMainnetValidatorWallet)({
28367
+ registryKey: "priceOracle",
28368
+ chainId: Number(this.config.chainId),
28369
+ wallet: resolvedPkpId
28370
+ });
28214
28371
  }
28215
28372
  if (this.config.debug) {
28216
28373
  console.log("\u{1F4B0} Calling Price Oracle LIT Action:");
@@ -40435,7 +40592,7 @@ var require_dist3 = __commonJS({
40435
40592
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports3, p)) __createBinding(exports3, m, p);
40436
40593
  };
40437
40594
  Object.defineProperty(exports2, "__esModule", { value: true });
40438
- exports2.default = exports2.broadcastSignedBitcoinTransaction = exports2.convertEthereumSignatureToBitcoinDER = exports2.CORE_API_TRANSPORT_FAILURE_MARKER = exports2.isCoreApiTransportError = exports2.describeErrorWithCause = exports2.normalizeCoreLitActionResult = exports2.executeLitActionViaCoreApi = exports2.fetchLitActionCodeFromIpfs = exports2.redactPositionIdForLog = exports2.asyncRequest = exports2.TaskQueue = exports2.TicketManager = exports2.PKPSigner = exports2.PKPAuthorizerUtils = exports2.PKPAuthorizer = exports2.PKPMinterUtils = exports2.PKPMinter = exports2.PKPManager = exports2.LitActionExecutor = exports2.LitAuthManager = exports2.LitOps = exports2.cidToHex = exports2.getDeploymentsForNetwork = void 0;
40595
+ exports2.default = exports2.broadcastSignedBitcoinTransaction = exports2.convertEthereumSignatureToBitcoinDER = exports2.CORE_API_TRANSPORT_FAILURE_MARKER = exports2.isCoreApiTransportError = exports2.describeErrorWithCause = exports2.normalizeCoreLitActionResult = exports2.executeLitActionViaCoreApi = exports2.fetchLitActionCodeFromIpfs = exports2.redactPositionIdForLog = exports2.asyncRequest = exports2.TaskQueue = exports2.TicketManager = exports2.PKPSigner = exports2.PKPAuthorizerUtils = exports2.PKPAuthorizer = exports2.PKPMinterUtils = exports2.PKPMinter = exports2.PKPManager = exports2.LitActionExecutor = exports2.LitAuthManager = exports2.resolveMainnetValidatorWallet = exports2.LitOps = exports2.cidToHex = exports2.getDeploymentsForNetwork = void 0;
40439
40596
  __exportStar(require_interfaces(), exports2);
40440
40597
  var dh_lit_actions_1 = require_pkg_src();
40441
40598
  Object.defineProperty(exports2, "getDeploymentsForNetwork", { enumerable: true, get: function() {
@@ -40448,6 +40605,10 @@ var require_dist3 = __commonJS({
40448
40605
  Object.defineProperty(exports2, "LitOps", { enumerable: true, get: function() {
40449
40606
  return lit_ops_module_1.LitOps;
40450
40607
  } });
40608
+ var mainnet_validator_wallets_1 = require_mainnet_validator_wallets();
40609
+ Object.defineProperty(exports2, "resolveMainnetValidatorWallet", { enumerable: true, get: function() {
40610
+ return mainnet_validator_wallets_1.resolveMainnetValidatorWallet;
40611
+ } });
40451
40612
  var auth_manager_module_1 = require_auth_manager_module();
40452
40613
  Object.defineProperty(exports2, "LitAuthManager", { enumerable: true, get: function() {
40453
40614
  return auth_manager_module_1.LitAuthManager;
@@ -40883,7 +41044,7 @@ function resolveRealConfig(env) {
40883
41044
 
40884
41045
  // src/boot.ts
40885
41046
  var fs6 = __toESM(require("fs"));
40886
- var import_ethers49 = require("ethers");
41047
+ var import_ethers50 = require("ethers");
40887
41048
 
40888
41049
  // src/boundary/index.ts
40889
41050
  var import_node_crypto8 = require("crypto");
@@ -40973,8 +41134,13 @@ function iso(sec) {
40973
41134
  return new Date(sec * 1e3).toISOString();
40974
41135
  }
40975
41136
  var PSM_FLOOR_TOLERANCE_BPS = 100;
41137
+ var CANONICAL_MAINNET_USDC = "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48";
41138
+ function stablecoinKindFor(network, stablecoinAddress) {
41139
+ if (network !== "mainnet") return "mock";
41140
+ return stablecoinAddress.toLowerCase() === CANONICAL_MAINNET_USDC.toLowerCase() ? "circle" : "onchain";
41141
+ }
40976
41142
  function failureToError(f) {
40977
- const code = f.kind === "signer-missing" ? "SIGNER_UNAVAILABLE" : f.kind === "unavailable" ? "UPSTREAM_UNAVAILABLE" : f.kind === "not-found" ? "NOT_FOUND" : "UPSTREAM_REJECTED";
41143
+ const code = f.kind === "signer-missing" ? "SIGNER_UNAVAILABLE" : f.kind === "unavailable" ? "UPSTREAM_UNAVAILABLE" : f.kind === "unsupported" ? "NOT_IMPLEMENTED" : f.kind === "not-found" ? "NOT_FOUND" : "UPSTREAM_REJECTED";
40978
41144
  const message = f.kind === "malformed" ? `${f.message} (upstream response failed integrity checks)` : f.message;
40979
41145
  return boundaryError(code, message, {
40980
41146
  source: f.source,
@@ -41450,7 +41616,7 @@ var BoundaryCore = class {
41450
41616
  tokenAddress: a.tokenAddress,
41451
41617
  spenderAddress: a.spenderAddress,
41452
41618
  spenderContract: a.spenderContract,
41453
- spenderReason: a.spenderContract === "SimplePSMV2" ? "the PSM contract itself pulls the USDC it converts (transferFrom), so the USDC 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",
41619
+ spenderReason: a.spenderContract === "SimplePSMV2" ? `the PSM contract itself pulls the ${a.tokenSymbol} it converts (transferFrom), so the ${a.tokenSymbol} allowance goes to the PSM` : "the PSM burns your UCD THROUGH the UCDController (controller.burnFromPsm), so the UCD allowance goes to the UCDController \u2014 a different contract than the PSM, by design",
41454
41620
  before: a.before,
41455
41621
  amountUnit: q.amountInUnit,
41456
41622
  basis: "approvals are planned against the allowance read before signing: none when it already covers the amount; an exact approve when it is 0; a partial allowance is reset to 0 first (some tokens refuse a non-zero \u2192 non-zero approve). Every approve is EXACTLY the input amount \u2014 never unlimited."
@@ -41509,9 +41675,10 @@ var BoundaryCore = class {
41509
41675
  chainId: this.deps.chainId,
41510
41676
  psmAddress: s.psmAddress,
41511
41677
  stablecoinAddress: s.stablecoinAddress,
41512
- // Only mainnet runs real Circle USDC; the mock world and sepolia both run a
41513
- // practice stablecoin with a public self-serve mint.
41514
- stablecoinKind: this.deps.network === "mainnet" ? "circle" : "mock",
41678
+ // Labelled by the ACTUAL coin, not the network (C-49): `circle` only for canonical
41679
+ // mainnet USDC, `mock` for the practice token, `onchain` for any other real coin
41680
+ // (e.g. mainnet USDT) — a USDT swap must never render as "real USDC".
41681
+ stablecoinKind: stablecoinKindFor(this.deps.network, s.stablecoinAddress),
41515
41682
  stablecoinSymbol: s.stablecoinSymbol,
41516
41683
  stablecoinDecimals: s.stablecoinDecimals,
41517
41684
  exchangeRate: s.exchangeRate,
@@ -44493,6 +44660,35 @@ var import_ethers9 = require("ethers");
44493
44660
  // src/boundary/upstream/shared/external-bridge/card.ts
44494
44661
  var import_ethers7 = require("ethers");
44495
44662
  init_tx_validator();
44663
+
44664
+ // src/boundary/upstream/shared/external-bridge/card-escape.ts
44665
+ var MAX_VALUE_CHARS = 200;
44666
+ function mustEscape(code) {
44667
+ if (code <= 31 || code === 127) return true;
44668
+ if (code >= 128 && code <= 159) return true;
44669
+ if (code === 8232 || code === 8233) return true;
44670
+ if (code >= 8234 && code <= 8238) return true;
44671
+ if (code >= 8294 && code <= 8297) return true;
44672
+ return false;
44673
+ }
44674
+ function safeValue(raw) {
44675
+ let out = "";
44676
+ for (const ch of String(raw)) {
44677
+ const code = ch.codePointAt(0);
44678
+ out += mustEscape(code) ? `\\u${code.toString(16).padStart(4, "0")}` : ch;
44679
+ if (out.length > MAX_VALUE_CHARS) return `${out.slice(0, MAX_VALUE_CHARS)}\u2026[truncated]`;
44680
+ }
44681
+ return out;
44682
+ }
44683
+
44684
+ // src/boundary/upstream/shared/external-bridge/card.ts
44685
+ function formatBtc(sats) {
44686
+ const negative = sats < 0n;
44687
+ const abs = negative ? -sats : sats;
44688
+ const whole = abs / 10n ** 8n;
44689
+ const frac = (abs % 10n ** 8n).toString().padStart(8, "0").replace(/0+$/, "");
44690
+ return `${negative ? "-" : ""}${whole}${frac ? "." + frac : ""}`;
44691
+ }
44496
44692
  function formatUcd(wei) {
44497
44693
  const negative = wei < 0n;
44498
44694
  const abs = negative ? -wei : wei;
@@ -44538,15 +44734,15 @@ function cardForTx(tx2) {
44538
44734
  "Operation: create a new borrowing position (your wallet is the borrower)",
44539
44735
  `Term: ${Number(args[4])} months`,
44540
44736
  `Position key (PKP id): ${String(args[0])}`,
44541
- `BTC vault (mainnet form): ${String(args[2])}`,
44542
- `BTC vault (regtest form): ${String(args[3])}`,
44737
+ `BTC vault (mainnet form): ${safeValue(args[2])}`,
44738
+ `BTC vault (regtest form): ${safeValue(args[3])}`,
44543
44739
  `Validator generation: ${Number(args[5])}`,
44544
44740
  ...head
44545
44741
  ];
44546
44742
  case "addAddress":
44547
44743
  return [
44548
44744
  "Operation: allowlist a Bitcoin withdrawal destination for YOUR account",
44549
- `BTC address to allowlist: ${String(args[0])}`,
44745
+ `BTC address to allowlist: ${safeValue(args[0])}`,
44550
44746
  "Withdrawals to this address become possible only after the registry's on-chain delay",
44551
44747
  ...head
44552
44748
  ];
@@ -44574,15 +44770,40 @@ function cardForTx(tx2) {
44574
44770
  `Minimum stablecoin out \u2014 the slippage floor (smallest units): ${String(args[2])}`,
44575
44771
  ...head
44576
44772
  ];
44773
+ case "withdrawBTC": {
44774
+ const p = args[0];
44775
+ return [
44776
+ "Operation: withdraw BTC from your vault \u2014 THIS MOVES BITCOIN OUT",
44777
+ `Position: ${safeValue(p.positionId)}`,
44778
+ // The destination is the whole security question of this card. It is a caller-
44779
+ // supplied string, hence safeValue: see the escaping note above.
44780
+ `BTC sent to: ${safeValue(p.withdrawalAddress)}`,
44781
+ `Leaves the vault (fee included): ${formatBtc(BigInt(p.totalDeduction))} BTC (${BigInt(p.totalDeduction)} sats)`,
44782
+ `Collateral remaining after this: ${formatBtc(BigInt(p.newCollateral))} BTC (${BigInt(p.newCollateral)} sats)`,
44783
+ `Spending vault UTXO: ${safeValue(p.utxoTxid)}:${Number(p.utxoVout)}`,
44784
+ ...head
44785
+ ];
44786
+ }
44787
+ case "setPositionDelegate":
44788
+ return [
44789
+ "Operation: set the DELEGATE for this position \u2014 this address may act on the position on your behalf",
44790
+ `Position: ${safeValue(args[0])}`,
44791
+ `Delegate address: ${safeValue(args[1])}`,
44792
+ "Setting the zero address removes the current delegate",
44793
+ ...head
44794
+ ];
44577
44795
  default:
44578
- return [`Operation: ${name}`, ...args.map((a, i) => `arg[${i}]: ${String(a)}`), ...head];
44796
+ throw new Error(
44797
+ `no approval card is defined for the signable function "${name}" \u2014 add a case to cardForTx before this operation can be approved`
44798
+ );
44579
44799
  }
44580
44800
  }
44581
44801
  function cardForTypedData(action, payload) {
44582
44802
  const m = payload.message;
44583
44803
  return [
44584
44804
  `Operation: ${action} \u2014 this signature AUTHORIZES the operation described below; the protocol executes it after your approval`,
44585
- ...Object.entries(m).map(([k, v]) => `${k}: ${String(v)}`),
44805
+ // `detail` here is a server-composed string — same escaping rule as the tx card.
44806
+ ...Object.entries(m).map(([k, v]) => `${safeValue(k)}: ${safeValue(v)}`),
44586
44807
  `Signing domain: ${String(payload.domain["name"])} v${String(payload.domain["version"])} \xB7 chain ${String(payload.domain["chainId"])}`
44587
44808
  ];
44588
44809
  }
@@ -44933,12 +45154,10 @@ init_tx_validator();
44933
45154
 
44934
45155
  // src/boundary/upstream/shared/quantum.ts
44935
45156
  var QUANTUM_WINDOW_SECONDS = 60;
44936
- var AUTH_VALIDITY_WINDOWS = 3;
44937
- function authValiditySec() {
44938
- return QUANTUM_WINDOW_SECONDS * AUTH_VALIDITY_WINDOWS;
44939
- }
44940
45157
  function isAuthFresh(issuedAtSec, nowSec) {
44941
- return issuedAtSec <= nowSec && nowSec - issuedAtSec < authValiditySec();
45158
+ const sq = Math.floor(issuedAtSec / QUANTUM_WINDOW_SECONDS) * QUANTUM_WINDOW_SECONDS;
45159
+ const cq = Math.floor(nowSec / QUANTUM_WINDOW_SECONDS) * QUANTUM_WINDOW_SECONDS;
45160
+ return sq === cq - QUANTUM_WINDOW_SECONDS || sq === cq || sq === cq + QUANTUM_WINDOW_SECONDS;
44942
45161
  }
44943
45162
  function isStrictCurrentQuantum(issuedAtSec, nowSec) {
44944
45163
  return issuedAtSec <= nowSec && Math.floor(issuedAtSec / QUANTUM_WINDOW_SECONDS) === Math.floor(nowSec / QUANTUM_WINDOW_SECONDS);
@@ -44979,7 +45198,7 @@ var SafeCeremony = class {
44979
45198
  if (!auth.ok) return auth.refusal;
44980
45199
  if (!isAuthFresh(issuedAtSec, surface.nowSec())) {
44981
45200
  return this.refuse(
44982
- `${p.action}: the owners' authorization expired \u2014 issued in a past quantum window (validity ${3 * QUANTUM_WINDOW_SECONDS}s); gather the owners and sign again`
45201
+ `${p.action}: the owners' authorization expired \u2014 issued outside the past/current/next quantum window (${QUANTUM_WINDOW_SECONDS}s quanta); gather the owners and sign again`
44983
45202
  );
44984
45203
  }
44985
45204
  const raw = await executor.signTransaction({
@@ -45499,7 +45718,7 @@ var SafeModuleCeremony = class {
45499
45718
  };
45500
45719
 
45501
45720
  // src/boundary/upstream/real/plugin.ts
45502
- var import_ethers48 = require("ethers");
45721
+ var import_ethers49 = require("ethers");
45503
45722
 
45504
45723
  // node_modules/@gvnrdao/dh-sdk/dist/index.mjs
45505
45724
  var import_ethers13 = require("ethers");
@@ -45511,6 +45730,7 @@ var import_ethers18 = require("ethers");
45511
45730
  var import_ethers19 = require("ethers");
45512
45731
  var import_ethers20 = require("ethers");
45513
45732
  var import_ethers21 = require("ethers");
45733
+ var import_ethers22 = require("ethers");
45514
45734
 
45515
45735
  // node_modules/@noble/hashes/esm/utils.js
45516
45736
  function isBytes(a) {
@@ -45958,11 +46178,11 @@ var ripemd1602 = ripemd160;
45958
46178
  // node_modules/@gvnrdao/dh-sdk/dist/index.mjs
45959
46179
  var import_bech32 = __toESM(require_dist(), 1);
45960
46180
  var import_bs58check = __toESM(require_bs58check(), 1);
45961
- var import_ethers22 = require("ethers");
45962
46181
  var import_ethers23 = require("ethers");
45963
46182
  var import_ethers24 = require("ethers");
45964
46183
  var import_ethers25 = require("ethers");
45965
46184
  var import_ethers26 = require("ethers");
46185
+ var import_ethers27 = require("ethers");
45966
46186
 
45967
46187
  // node_modules/axios/lib/helpers/bind.js
45968
46188
  function bind(fn, thisArg) {
@@ -51587,7 +51807,6 @@ var {
51587
51807
  } = axios_default;
51588
51808
 
51589
51809
  // node_modules/@gvnrdao/dh-sdk/dist/index.mjs
51590
- var import_ethers27 = require("ethers");
51591
51810
  var import_ethers28 = require("ethers");
51592
51811
  var import_ethers29 = require("ethers");
51593
51812
  var import_ethers30 = require("ethers");
@@ -51596,6 +51815,7 @@ var import_ethers32 = require("ethers");
51596
51815
  var import_ethers33 = require("ethers");
51597
51816
  var import_dh_lit_ops = __toESM(require_dist3(), 1);
51598
51817
  var import_ethers34 = require("ethers");
51818
+ var import_ethers35 = require("ethers");
51599
51819
  var __create2 = Object.create;
51600
51820
  var __defProp2 = Object.defineProperty;
51601
51821
  var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
@@ -51697,7 +51917,6 @@ var init_deployment_addresses = __esm2({
51697
51917
  PositionDelegateRegistry: "0x482369De283622E7b05731875ec137d4E3D208F9",
51698
51918
  FeeRecipientRegistry: "0x95795F8403DDb629E8527B2934C4e71f5fC0C374",
51699
51919
  BitcoinWithdrawalAddressRegistry: "0x6376D392097F0A81e51BD83960A97EA20eaf1dbe",
51700
- CarryAgentRegistry: "0x5595CB538D44E6Cf179D20364fD631D0477e69f7",
51701
51920
  AgentDelegationRegistry: "0x6AE7fc6bE0925126b9D25b1B7Ce5AD5d127ec025",
51702
51921
  DHAgentDelegate: "0xa5A14489ae883960df6E1463A41a47aBE9Ecc5AF",
51703
51922
  AgentModuleFactory: "0x1Fd3aCa2C030Cf77ce28Af9694D3Bb3034ACa2E5"
@@ -51967,8 +52186,6 @@ var init_deployment_addresses = __esm2({
51967
52186
  OPERATION_AUTHORIZATION_REGISTRY_IMPL: "0xe0D981B60351f0f8fFDA2b50C8180Fb37CeF3883",
51968
52187
  BITCOIN_WITHDRAWAL_ADDRESS_REGISTRY: "0x6376D392097F0A81e51BD83960A97EA20eaf1dbe",
51969
52188
  BITCOIN_WITHDRAWAL_ADDRESS_REGISTRY_IMPL: "0x76E0a2c9d89562fD7c50b5f554d7fa25957e39Db",
51970
- CARRY_AGENT_REGISTRY: "0x5595CB538D44E6Cf179D20364fD631D0477e69f7",
51971
- CARRY_AGENT_REGISTRY_IMPL: "0x1b11a3D5e46F3672E643c997f0d569DFf0b64a01",
51972
52189
  AGENT_DELEGATION_REGISTRY: "0x6AE7fc6bE0925126b9D25b1B7Ce5AD5d127ec025",
51973
52190
  AGENT_DELEGATION_REGISTRY_IMPL: "0xE931E4b9ceF2A48Ac7D57192da4B523756cFC310",
51974
52191
  DH_AGENT_DELEGATE: "0xa5A14489ae883960df6E1463A41a47aBE9Ecc5AF"
@@ -52000,7 +52217,6 @@ var init_deployment_addresses = __esm2({
52000
52217
  PositionDelegateRegistry: "0x482369De283622E7b05731875ec137d4E3D208F9",
52001
52218
  FeeRecipientRegistry: "0x95795F8403DDb629E8527B2934C4e71f5fC0C374",
52002
52219
  BitcoinWithdrawalAddressRegistry: "0x6376D392097F0A81e51BD83960A97EA20eaf1dbe",
52003
- CarryAgentRegistry: "0x5595CB538D44E6Cf179D20364fD631D0477e69f7",
52004
52220
  AgentDelegationRegistry: "0x6AE7fc6bE0925126b9D25b1B7Ce5AD5d127ec025",
52005
52221
  DHAgentDelegate: "0xa5A14489ae883960df6E1463A41a47aBE9Ecc5AF",
52006
52222
  AgentModuleFactory: "0x1Fd3aCa2C030Cf77ce28Af9694D3Bb3034ACa2E5"
@@ -52975,113 +53191,113 @@ var require_pkg_src2 = __commonJS2({
52975
53191
  deployedAt: 1784569687492,
52976
53192
  size: 4140,
52977
53193
  hash: "4c0d65bf1f33cdac22a78fd8c4764319cc3fe00650e0fe7fa8a6090d9a318a7b",
52978
- validatorWalletAddress: "0x82db9f515957aa380b596c6ea2bd30cef181f236",
53194
+ validatorWalletAddress: "0xefb258d455a31d061bbeb3de3d2143bdfcb67a6c",
52979
53195
  pkp: {
52980
53196
  publicKey: "0x04ec0e3acc40884e3f366ca469d08899eb640ad5259fa196b0238075086208a9f8732a3175704f35f0bcc28e07406cfb24c254efd1e7355640577330f0d2dd755f",
52981
- ethAddress: "0xc7e1588Db94Bbe92Ab209B833235144Fc5b97607"
53197
+ ethAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C"
52982
53198
  }
52983
53199
  },
52984
53200
  btcTransactionSigner: {
52985
- cid: "QmVi1BYdxvCX3QUhXwPtP6FjWMzqSPtXzrS54YsXjTgjYf",
53201
+ cid: "QmULkz7hwwqsyLwY23U14dnartdVuSNMrykt69PaNiAq7U",
52986
53202
  authorizedCidHex: cidToHex(
52987
- "QmVi1BYdxvCX3QUhXwPtP6FjWMzqSPtXzrS54YsXjTgjYf"
53203
+ "QmULkz7hwwqsyLwY23U14dnartdVuSNMrykt69PaNiAq7U"
52988
53204
  ),
52989
53205
  name: "Btc Transaction Signer",
52990
53206
  description: "Production Btc Transaction Signer",
52991
53207
  version: "1.1.1",
52992
53208
  deployed: true,
52993
- deployedAt: 1787923905597,
52994
- size: 70646,
52995
- hash: "37c3bb72a660c8275d92e1b73f9482742d86b64789480b9246304c0ca1bab47a"
53209
+ deployedAt: 1790246185256,
53210
+ size: 73313,
53211
+ hash: "d8b6bc646ba33fee7d46c8e9b281de776081ea6f182f56fd15d4c52aaf3dd030"
52996
53212
  },
52997
53213
  ucdMintValidator: {
52998
- cid: "QmUWR5fLiyimLT9TPXpYx3HgwNwkvR6MxjZ7hdeYCFodbc",
53214
+ cid: "QmcxVSn9saEPGBS6mqPhNefgW83V2qeZjjXbhwYLP373xe",
52999
53215
  authorizedCidHex: cidToHex(
53000
- "QmUWR5fLiyimLT9TPXpYx3HgwNwkvR6MxjZ7hdeYCFodbc"
53216
+ "QmcxVSn9saEPGBS6mqPhNefgW83V2qeZjjXbhwYLP373xe"
53001
53217
  ),
53002
53218
  name: "Ucd Mint Validator",
53003
53219
  description: "Production Ucd Mint Validator",
53004
- version: "1.2.1",
53220
+ version: "1.3.0",
53005
53221
  deployed: true,
53006
- deployedAt: 1787923919527,
53007
- size: 86197,
53008
- hash: "c2d80939746cc37f65ef2f63c6a3215b929214a63f10c78144e1f5c98320dabf",
53009
- validatorWalletAddress: "0x82DB9F515957aA380B596C6eA2Bd30CEF181f236",
53222
+ deployedAt: 1790246219868,
53223
+ size: 90022,
53224
+ hash: "65e8cb778c2b767ae6eb37cb5db7b4c5a3f2468d508463c847c83c1b6825fadd",
53225
+ validatorWalletAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C",
53010
53226
  pkp: {
53011
53227
  publicKey: "0x041ab17cd91fc5c0b761eea6092d032807561b621b82c488826776e04a9158d61ba64d809a4729f0501289d980732cb06d8dfd06999dd9c8efd2f495dad78b31bb",
53012
- ethAddress: "0xc7e1588Db94Bbe92Ab209B833235144Fc5b97607"
53228
+ ethAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C"
53013
53229
  }
53014
53230
  },
53015
53231
  processPaymentValidator: {
53016
- cid: "QmXmXuMRAjMLdgKGyTf9KQdGwYrDp8DxkiF44TvSXDf7wF",
53232
+ cid: "QmWFbxJkfxhCtES4wrePWQkYtjhtrP1tohvn9d1r9N5Hd8",
53017
53233
  authorizedCidHex: cidToHex(
53018
- "QmXmXuMRAjMLdgKGyTf9KQdGwYrDp8DxkiF44TvSXDf7wF"
53234
+ "QmWFbxJkfxhCtES4wrePWQkYtjhtrP1tohvn9d1r9N5Hd8"
53019
53235
  ),
53020
53236
  name: "Process Payment Validator",
53021
53237
  description: "Production Process Payment Validator",
53022
53238
  version: "1.2.1",
53023
53239
  deployed: true,
53024
- deployedAt: 1787923987153,
53025
- size: 82217,
53026
- hash: "13defa19614215ab3b1fe88955d69e530d13a09475396af932fe0e213637da2f",
53027
- validatorWalletAddress: "0x82DB9F515957aA380B596C6eA2Bd30CEF181f236",
53240
+ deployedAt: 1790246225795,
53241
+ size: 85107,
53242
+ hash: "25ecf952c4c44c40b0920b92d57906e7010ed9a38e2ba41ccdee6d3377c2b596",
53243
+ validatorWalletAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C",
53028
53244
  pkp: {
53029
53245
  publicKey: "0x04cfccb9b6c7addc79469c0e9fafebef4c70801302c62cdb26b610723a9b8527d23f98a40158c7340d83fd0e62d02b5ec74c12f7a86d98e8c6973b4811110f19ad",
53030
- ethAddress: "0xc7e1588Db94Bbe92Ab209B833235144Fc5b97607"
53246
+ ethAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C"
53031
53247
  }
53032
53248
  },
53033
53249
  extendPositionValidator: {
53034
- cid: "QmU8h99EEVEsQkxroXiYqLsKZw9gNjE6N5CcTpE9aUc12m",
53250
+ cid: "QmZ3g7g5DkgU1gEYpFjprQf3sctUHtGjNQVYezw2bnPGEX",
53035
53251
  authorizedCidHex: cidToHex(
53036
- "QmU8h99EEVEsQkxroXiYqLsKZw9gNjE6N5CcTpE9aUc12m"
53252
+ "QmZ3g7g5DkgU1gEYpFjprQf3sctUHtGjNQVYezw2bnPGEX"
53037
53253
  ),
53038
53254
  name: "Extend Position Validator",
53039
53255
  description: "Production Extend Position Validator",
53040
53256
  version: "1.2.1",
53041
53257
  deployed: true,
53042
- deployedAt: 1787923999294,
53043
- size: 79975,
53044
- hash: "31c1aaf883ef22f37681ddb0a4a949be5c05304b6aef178989475a2da935ef9a",
53045
- validatorWalletAddress: "0x82DB9F515957aA380B596C6eA2Bd30CEF181f236",
53258
+ deployedAt: 1790246231975,
53259
+ size: 82853,
53260
+ hash: "25d4887b7f646649db2bb7f2bfb77d039db83228a6c454377ca26c779b0903cc",
53261
+ validatorWalletAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C",
53046
53262
  pkp: {
53047
53263
  publicKey: "0x04e52338f6a0c3362800f1a94c4c8f08be5030dde0fa217388c53d1c1a4790f4443c9f2886b2d2d8f4b75a9a156e9b028011b1a1cf7648da0e556aa980ec692836",
53048
- ethAddress: "0xc7e1588Db94Bbe92Ab209B833235144Fc5b97607"
53264
+ ethAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C"
53049
53265
  }
53050
53266
  },
53051
53267
  btcWithdrawal: {
53052
- cid: "QmZQWET9pzrVD4gwQuSzYZmqa24JrUNtnnGFDd513sxMCY",
53268
+ cid: "QmbRaaMQr1jCctDGe8mPADsUz1rkb4frT1YqSKroiXjzyP",
53053
53269
  authorizedCidHex: cidToHex(
53054
- "QmZQWET9pzrVD4gwQuSzYZmqa24JrUNtnnGFDd513sxMCY"
53270
+ "QmbRaaMQr1jCctDGe8mPADsUz1rkb4frT1YqSKroiXjzyP"
53055
53271
  ),
53056
53272
  name: "Btc Withdrawal",
53057
53273
  description: "Production Btc Withdrawal",
53058
53274
  version: "1.2.7",
53059
53275
  deployed: true,
53060
- deployedAt: 1787924017769,
53061
- size: 100069,
53062
- hash: "4f8e27414e4da235e63d6ae1325c63f3d2fb956464515a21aa007a99935f0f13",
53063
- validatorWalletAddress: "0x82DB9F515957aA380B596C6eA2Bd30CEF181f236",
53276
+ deployedAt: 1790246239599,
53277
+ size: 101228,
53278
+ hash: "2ed25eca6cc80a43061b7ad119737af48158fdb61d59f10cd06cea51b607f112",
53279
+ validatorWalletAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C",
53064
53280
  pkp: {
53065
53281
  publicKey: "0x043616787c5432415c24378c4ef48de2bcd6bb7b575b837e3cff09171802662da7105d79586c7659677a0ecbaddac4cce06cb2a11f69a16fa0c4d7002ac7d51a4d",
53066
- ethAddress: "0xc7e1588Db94Bbe92Ab209B833235144Fc5b97607"
53282
+ ethAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C"
53067
53283
  }
53068
53284
  },
53069
53285
  liquidationValidator: {
53070
- cid: "Qme6aGADhiszkQbZL977E6nmBacd2PEB7K9Hs8puVrscNx",
53286
+ cid: "QmTs2w8gfAwWZLbzJZg2CZmiLhVXS5kbMgaj42Zuxfodpb",
53071
53287
  authorizedCidHex: cidToHex(
53072
- "Qme6aGADhiszkQbZL977E6nmBacd2PEB7K9Hs8puVrscNx"
53288
+ "QmTs2w8gfAwWZLbzJZg2CZmiLhVXS5kbMgaj42Zuxfodpb"
53073
53289
  ),
53074
53290
  name: "Liquidation Validator",
53075
53291
  description: "Production Liquidation Validator",
53076
53292
  version: "1.2.1",
53077
53293
  deployed: true,
53078
- deployedAt: 1785173262533,
53079
- size: 66846,
53080
- hash: "b35ee7706d733d625faa4dbe37f73c8e20f0c1befa897cd7875e827de52003de",
53081
- validatorWalletAddress: "0x82DB9F515957aA380B596C6eA2Bd30CEF181f236",
53294
+ deployedAt: 1790246247904,
53295
+ size: 70308,
53296
+ hash: "582ccf0ec7f715195e20fdc885996743cb42125b64173424e360ee63db62bbd8",
53297
+ validatorWalletAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C",
53082
53298
  pkp: {
53083
53299
  publicKey: "0x041a241de58976c13e3d7ca5a18e494f7330151e3818706135d50176e78ffb673e58b11f0b67a87c73fade6c6b27d6e7a7377ea9f4c10bf31880f1d725f18cc6f8",
53084
- ethAddress: "0xc7e1588Db94Bbe92Ab209B833235144Fc5b97607"
53300
+ ethAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C"
53085
53301
  }
53086
53302
  },
53087
53303
  priceOracle: {
@@ -53096,28 +53312,28 @@ var require_pkg_src2 = __commonJS2({
53096
53312
  deployedAt: 1781116663270,
53097
53313
  size: 8695,
53098
53314
  hash: "ba20ade60a7fa5acd80dadfafa179c507388cfe6ce48a22a672d70b317ffcc74",
53099
- validatorWalletAddress: "0x82db9f515957aa380b596c6ea2bd30cef181f236",
53315
+ validatorWalletAddress: "0xefb258d455a31d061bbeb3de3d2143bdfcb67a6c",
53100
53316
  pkp: {
53101
53317
  publicKey: "0x043beaa1da47875601a8d6f430b1438ee2d4732eefd06e5c63a474bbdaf9e7df1797b1b951e041b627c2bf839788164825324c9cbd1e2d6f740fdd4bff69b1900b",
53102
- ethAddress: "0xc7e1588Db94Bbe92Ab209B833235144Fc5b97607"
53318
+ ethAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C"
53103
53319
  }
53104
53320
  },
53105
53321
  loanVaultBtcBalance: {
53106
- cid: "QmaeQoHYvcMYobNbu9hQavGDudi8AXoW9tg3YHrvy1g2A4",
53322
+ cid: "QmZ27xCzuoaAhWxRsMPsUQkp45a8WPBb21uhxwchw3LG5W",
53107
53323
  authorizedCidHex: cidToHex(
53108
- "QmaeQoHYvcMYobNbu9hQavGDudi8AXoW9tg3YHrvy1g2A4"
53324
+ "QmZ27xCzuoaAhWxRsMPsUQkp45a8WPBb21uhxwchw3LG5W"
53109
53325
  ),
53110
53326
  name: "Loan Vault Btc Balance",
53111
53327
  description: "Production Loan Vault Btc Balance",
53112
53328
  version: "1.2.1",
53113
53329
  deployed: true,
53114
- deployedAt: 1785173271802,
53115
- size: 56800,
53116
- hash: "a059133214e6ba0a73d655a15600c4b33e361fb340c98f8eecaf8ab7b95aaf83",
53117
- validatorWalletAddress: "0x82DB9F515957aA380B596C6eA2Bd30CEF181f236",
53330
+ deployedAt: 1790179961079,
53331
+ size: 60046,
53332
+ hash: "922e86c0a667fe0c0945771f84aa6b9fe08be9c96dd2f73a9c5cb257d24e22b0",
53333
+ validatorWalletAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C",
53118
53334
  pkp: {
53119
53335
  publicKey: "0x043616787c5432415c24378c4ef48de2bcd6bb7b575b837e3cff09171802662da7105d79586c7659677a0ecbaddac4cce06cb2a11f69a16fa0c4d7002ac7d51a4d",
53120
- ethAddress: "0xc7e1588Db94Bbe92Ab209B833235144Fc5b97607"
53336
+ ethAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C"
53121
53337
  }
53122
53338
  },
53123
53339
  // btc-address-balance (Option B) — address-only signed total balance via
@@ -53127,21 +53343,21 @@ var require_pkg_src2 = __commonJS2({
53127
53343
  // Requires BitcoinProviderRegistry.addAllowedCid(chainId, keccak256(utf8(cid)))
53128
53344
  // on each target chain (the action decrypts registry slots). No OAR entry.
53129
53345
  btcAddressBalance: {
53130
- cid: "QmUXUtU9r1HhQVYgkXPN5s19SKXanhn4pMsCtFEP3GK4Kj",
53346
+ cid: "QmVVjB6zCBiXFKffhQPYUAZhj7TXduuvcrPqKtHa3DMXhN",
53131
53347
  authorizedCidHex: cidToHex(
53132
- "QmUXUtU9r1HhQVYgkXPN5s19SKXanhn4pMsCtFEP3GK4Kj"
53348
+ "QmVVjB6zCBiXFKffhQPYUAZhj7TXduuvcrPqKtHa3DMXhN"
53133
53349
  ),
53134
53350
  name: "Btc Address Balance",
53135
53351
  description: "Address-only signed total BTC balance via registry consensus (no positionId, no price)",
53136
53352
  version: "0.2.1",
53137
53353
  deployed: true,
53138
- deployedAt: 1785173280221,
53139
- size: 27309,
53140
- hash: "f0d08938713d9d89a56a3a386cacbc2b57afd5ad367ea82d827d40e1bfc70989",
53141
- validatorWalletAddress: "0x82DB9F515957aA380B596C6eA2Bd30CEF181f236",
53354
+ deployedAt: 1790179971315,
53355
+ size: 30295,
53356
+ hash: "2c67d9cfa4d50e835fbb28ae50e80217ceb2be3bb862c89290aadf43fdc739c9",
53357
+ validatorWalletAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C",
53142
53358
  pkp: {
53143
53359
  publicKey: "0x0498cbb31facfa26e3ec83ccdabfe4fe341ca0282e0c3cb81da7113723b9726e1e49efa92165cc3faa66ced4454cea56dbab12267852d6525a55d7c4f128b912cd",
53144
- ethAddress: "0xc7e1588Db94Bbe92Ab209B833235144Fc5b97607"
53360
+ ethAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C"
53145
53361
  }
53146
53362
  },
53147
53363
  alwaysSigner: {
@@ -53171,48 +53387,48 @@ var require_pkg_src2 = __commonJS2({
53171
53387
  hash: "03ee5be239c91c735d2c95db89a0d1b77e602cfc18af8eb64b3281fddcd90a72"
53172
53388
  },
53173
53389
  agentModuleExecutor: {
53174
- cid: "QmcD65vuremot5fsHVgp9JBAmei6gAaEtm5mdtLP7Yt9Kf",
53390
+ cid: "QmSwPPvQhT7UhcuVA2m3UxGhVj5WqMpDvYNKU1228QLFsX",
53175
53391
  authorizedCidHex: cidToHex(
53176
- "QmcD65vuremot5fsHVgp9JBAmei6gAaEtm5mdtLP7Yt9Kf"
53392
+ "QmSwPPvQhT7UhcuVA2m3UxGhVj5WqMpDvYNKU1228QLFsX"
53177
53393
  ),
53178
53394
  name: "Agent Module Executor",
53179
53395
  description: "Production Agent Module Executor",
53180
53396
  version: "1.1.1",
53181
53397
  deployed: true,
53182
- deployedAt: 1787924032013,
53183
- size: 13878,
53184
- hash: "a7f0204700912e26e5a354bee13a1242a2baa218643b3bb22d28481f67f9baf4"
53398
+ deployedAt: 1790179978959,
53399
+ size: 14688,
53400
+ hash: "8edb9b12c784c8d7d153cce97235584c24665a788767ae68713dce91109ab35e"
53185
53401
  },
53186
53402
  staleSpendRecoveryValidator: {
53187
- cid: "QmNuwo4PT4AikAmhMdZgPWCb2mJDwWa9TnUqrqvofjbrT8",
53403
+ cid: "Qmarj59zdSSgivkimryrdvnyZqH5YpTimKj1LivXNBHmNz",
53188
53404
  authorizedCidHex: cidToHex(
53189
- "QmNuwo4PT4AikAmhMdZgPWCb2mJDwWa9TnUqrqvofjbrT8"
53405
+ "Qmarj59zdSSgivkimryrdvnyZqH5YpTimKj1LivXNBHmNz"
53190
53406
  ),
53191
53407
  name: "Stale Spend Recovery Validator",
53192
53408
  description: "Production Stale Spend Recovery Validator",
53193
53409
  version: "1.1.2",
53194
53410
  deployed: true,
53195
- deployedAt: 1787924048772,
53196
- size: 41424,
53197
- hash: "3c5f028d2bef4344768462993616d45e30d9d44ef126e04d6eb579821d57d99c",
53198
- validatorWalletAddress: "0x82DB9F515957aA380B596C6eA2Bd30CEF181f236",
53411
+ deployedAt: 1790246256280,
53412
+ size: 48143,
53413
+ hash: "ec9236bcbe0af24d3e1844791fc8fe37371bbecd8ce95d02e13f7c6e1fc7d94c",
53414
+ validatorWalletAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C",
53199
53415
  pkp: {
53200
53416
  publicKey: "0x046da0ad6da7dd4a0063cbeac6f2bdb6a9889c2178b23470833356a8ee5630f7f0eee0db348d9d9aaaadd23eccf0063c8f68ee5e446abe30b882bf1de4c932bc21",
53201
- ethAddress: "0xc7e1588Db94Bbe92Ab209B833235144Fc5b97607"
53417
+ ethAddress: "0xEfb258D455a31d061Bbeb3DE3D2143BdFCB67a6C"
53202
53418
  }
53203
53419
  },
53204
53420
  btcUtxoInvalidator: {
53205
- cid: "QmaNGeWut7EiGwW4zUc2sFSt7RY5NWFgxYboyG333TwrJf",
53421
+ cid: "QmbS44bGcmKYF64Cu35qzsk9sxiU4Umde8Z3q24ZnEbQvX",
53206
53422
  authorizedCidHex: cidToHex(
53207
- "QmaNGeWut7EiGwW4zUc2sFSt7RY5NWFgxYboyG333TwrJf"
53423
+ "QmbS44bGcmKYF64Cu35qzsk9sxiU4Umde8Z3q24ZnEbQvX"
53208
53424
  ),
53209
53425
  name: "Btc Utxo Invalidator",
53210
53426
  description: "Production Btc Utxo Invalidator",
53211
53427
  version: "1.0.0",
53212
53428
  deployed: true,
53213
- deployedAt: 1787924133241,
53214
- size: 66026,
53215
- hash: "603bc50920d7f1dee77086f2c518d9e2922ab3858a419d3fbea8221ea3a6d9e9"
53429
+ deployedAt: 1790246264563,
53430
+ size: 69219,
53431
+ hash: "bda048d8cd6b5a39c2774bcf1320e82d1eea935c2a521006fb8b887e13b6dd8d"
53216
53432
  }
53217
53433
  };
53218
53434
  function getDeploymentsForNetwork(network) {
@@ -53958,7 +54174,7 @@ ${errorReport}`);
53958
54174
  }
53959
54175
  init_debug_logger();
53960
54176
  init_session_signature_cache();
53961
- var import_ethers232 = __require("ethers");
54177
+ var import_ethers242 = __require("ethers");
53962
54178
  var EXPIRED_LOAN_MIN_LIQUIDATION_THRESHOLD_BPS = 11e3;
53963
54179
  var GRACE_PERIOD_DAYS = 30;
53964
54180
  var SATOSHIS_PER_BITCOIN = 100000000n;
@@ -53980,7 +54196,10 @@ ${errorReport}`);
53980
54196
  BTCSpendAuthorizer: "0xfBbF108486fa07F1B06a811C5b66ed68DD9c508a",
53981
54197
  BitcoinProviderRegistry: "0x4ab3Fb96e02893Ed6FAa61bad1918390c8DbbFFC",
53982
54198
  LITActionValidator: "0xD2c5d59c2CC5c409AC65ce0A817236aeC6869512",
53983
- PositionDelegateRegistry: "0xf0aa2678aD4F60f49e8F7725089B5E86B7F8FE4C"
54199
+ PositionDelegateRegistry: "0xf0aa2678aD4F60f49e8F7725089B5E86B7F8FE4C",
54200
+ TermManagerModule: "0xDB99CdF883ffa38acD099bC39F8d1f4508c9239E",
54201
+ UCDController: "0x4b4f8063048bCD59D469219E3f07C6aaDF4f6157",
54202
+ LiquidationManagerModule: "0x74B28695352E7bf736D6c9F76ccb7B4439477De9"
53984
54203
  },
53985
54204
  11155111: {
53986
54205
  PositionManager: "0x68e0507D982AEBF1D1C1Af8FBbd842327e2deeFF",
@@ -53988,7 +54207,10 @@ ${errorReport}`);
53988
54207
  BTCSpendAuthorizer: "0xd7E9Eb5eE53f1d9ee55Dc162bBC7486bE437B6bD",
53989
54208
  BitcoinProviderRegistry: "0xbfA0c48B070D0a9A9CD27469AeacFD2d4261cEE2",
53990
54209
  LITActionValidator: "0x54eECd7C90F8A8fac27749Ba30BbE8AFBAccc856",
53991
- PositionDelegateRegistry: "0x482369De283622E7b05731875ec137d4E3D208F9"
54210
+ PositionDelegateRegistry: "0x482369De283622E7b05731875ec137d4E3D208F9",
54211
+ TermManagerModule: "0x94Adc6F9558368B1482197584f1fc7133Ecf835b",
54212
+ UCDController: "0x360Bde4e489ee94E26601B206932De09EE60FF04",
54213
+ LiquidationManagerModule: "0xC4AB00f39e7ceD812F5C67058C9fa44e15d40e76"
53992
54214
  }
53993
54215
  };
53994
54216
  function getPinnedContractAddresses(chainId) {
@@ -54174,10 +54396,10 @@ ${errorReport}`);
54174
54396
  };
54175
54397
  }
54176
54398
  const ratioBigInt = collateralValueUsd * UCD_TOKEN_DECIMALS * 10000n / ucdDebt;
54177
- const collateralRatioBps = Number(ratioBigInt);
54399
+ const collateralRatioBps2 = Number(ratioBigInt);
54178
54400
  return {
54179
54401
  collateralValueUsd,
54180
- collateralRatioBps
54402
+ collateralRatioBps: collateralRatioBps2
54181
54403
  };
54182
54404
  }
54183
54405
  function hasSufficientCollateralForDebt(collateralValueUsd, currentDebt, additionalDebt, requiredRatioBps) {
@@ -55031,6 +55253,17 @@ ${auth.clientId}`;
55031
55253
  );
55032
55254
  }
55033
55255
  }
55256
+ var TIP_READ_FAILURE_PREFIX = "Bitcoin tip-height read failed";
55257
+ var BitcoinTipUnreadableError = class extends Error {
55258
+ constructor(message) {
55259
+ super(message);
55260
+ this.isBitcoinTipUnreadable = true;
55261
+ this.name = "BitcoinTipUnreadableError";
55262
+ }
55263
+ };
55264
+ function isBitcoinTipUnreadableError(error) {
55265
+ return typeof error === "object" && error !== null && error.isBitcoinTipUnreadable === true;
55266
+ }
55034
55267
  var BitcoinDataProvider = class {
55035
55268
  constructor(config) {
55036
55269
  this.config = config;
@@ -55482,27 +55715,12 @@ ${auth.clientId}`;
55482
55715
  if (!data.status.confirmed || !data.status.block_height) {
55483
55716
  return { txid: data.txid ?? txid, confirmations: 0 };
55484
55717
  }
55485
- try {
55486
- const tipResp = await fetch(
55487
- `${this.config.providerUrl}/blocks/tip/height`,
55488
- { signal: controller.signal, headers: await this.withAuth() }
55489
- );
55490
- if (!tipResp.ok) {
55491
- return { txid: data.txid ?? txid, confirmations: 1 };
55492
- }
55493
- const tipBody = (await tipResp.text()).trim();
55494
- const tipHeight = Number.parseInt(tipBody, 10);
55495
- if (!Number.isFinite(tipHeight) || tipHeight <= 0) {
55496
- return { txid: data.txid ?? txid, confirmations: 1 };
55497
- }
55498
- const depth = tipHeight - data.status.block_height + 1;
55499
- return {
55500
- txid: data.txid ?? txid,
55501
- confirmations: depth > 0 ? depth : 0
55502
- };
55503
- } catch {
55504
- return { txid: data.txid ?? txid, confirmations: 1 };
55505
- }
55718
+ const tipHeight = await this.fetchTipHeight(controller.signal);
55719
+ const depth = tipHeight - data.status.block_height + 1;
55720
+ return {
55721
+ txid: data.txid ?? txid,
55722
+ confirmations: depth > 0 ? depth : 0
55723
+ };
55506
55724
  }
55507
55725
  return null;
55508
55726
  } catch (error) {
@@ -55510,12 +55728,55 @@ ${auth.clientId}`;
55510
55728
  if (isAbortError(error)) {
55511
55729
  throw new Error(`Request timeout after ${this.timeout}ms`);
55512
55730
  }
55731
+ if (isBitcoinTipUnreadableError(error)) {
55732
+ throw error;
55733
+ }
55513
55734
  if (getUnknownErrorMessage(error).includes("404")) {
55514
55735
  return null;
55515
55736
  }
55516
55737
  throw error;
55517
55738
  }
55518
55739
  }
55740
+ /**
55741
+ * Current chain tip height from THIS provider — or throw.
55742
+ *
55743
+ * Every exit is a throw naming the provider and the precise failure, because
55744
+ * the only alternative is inventing a confirmation depth (see the call site).
55745
+ * The single `try` exists solely to attach that name to a transport-level
55746
+ * rejection (DNS, TLS, connection reset, abort); it re-throws the cause
55747
+ * verbatim inside the message and never substitutes a value — authorized for
55748
+ * this case by the Batch 2 plan, §C2.
55749
+ *
55750
+ * @param signal - The caller's AbortSignal, so this read shares the same
55751
+ * timeout budget as the transaction fetch it serves.
55752
+ */
55753
+ async fetchTipHeight(signal) {
55754
+ const endpoint = `${this.config.providerUrl}/blocks/tip/height`;
55755
+ let tipResp;
55756
+ try {
55757
+ tipResp = await fetch(endpoint, {
55758
+ signal,
55759
+ headers: await this.withAuth()
55760
+ });
55761
+ } catch (error) {
55762
+ throw new BitcoinTipUnreadableError(
55763
+ `${TIP_READ_FAILURE_PREFIX}: GET ${endpoint} threw \u2014 ${getUnknownErrorMessage(error)}`
55764
+ );
55765
+ }
55766
+ if (!tipResp.ok) {
55767
+ throw new BitcoinTipUnreadableError(
55768
+ `${TIP_READ_FAILURE_PREFIX}: GET ${endpoint} \u2192 ${tipResp.status} ${tipResp.statusText}`
55769
+ );
55770
+ }
55771
+ const tipBody = (await tipResp.text()).trim();
55772
+ const tipHeight = Number.parseInt(tipBody, 10);
55773
+ if (!Number.isFinite(tipHeight) || tipHeight <= 0) {
55774
+ throw new BitcoinTipUnreadableError(
55775
+ `${TIP_READ_FAILURE_PREFIX}: GET ${endpoint} returned an unusable tip height "${tipBody.slice(0, 64)}"`
55776
+ );
55777
+ }
55778
+ return tipHeight;
55779
+ }
55519
55780
  /**
55520
55781
  * Get outputs (vouts) of a Bitcoin transaction
55521
55782
  *
@@ -56153,10 +56414,13 @@ ${auth.clientId}`;
56153
56414
  * only on unanimity. The confirmed-balance consensus the validators run
56154
56415
  * covers `chain_stats` only, so without this the primary provider alone
56155
56416
  * could fabricate an unconfirmed UTXO plus a self-consistent parent proof
56156
- * and inflate the signed balance. Any provider failure or verdict
56157
- * disagreement THROWS (fail-closed) — exclusion on a suppressed proof
56158
- * would deflate the balance and open a wrongful-liquidation window, so
56159
- * neither direction may proceed without agreement.
56417
+ * and inflate the signed balance. Any verdict disagreement THROWS
56418
+ * (fail-closed) — exclusion on a suppressed proof would deflate the balance
56419
+ * and open a wrongful-liquidation window, so neither direction may proceed
56420
+ * without agreement. A provider that cannot state the chain tip — and only
56421
+ * that failure — is dropped from the quorum rather than aborting the read (it
56422
+ * never counts as agreeing), and falling below `minConsensusProviders`
56423
+ * survivors throws — see `verifyParentIsSelfSpendConsensus`.
56160
56424
  *
56161
56425
  * The same per-provider `/tx` fetch also returns the parent's outputs, and
56162
56426
  * every provider must corroborate each claimed UTXO (index, vault address,
@@ -56251,10 +56515,26 @@ ${auth.clientId}`;
56251
56515
  }
56252
56516
  /**
56253
56517
  * Run the self-spend proof against every configured provider and require
56254
- * unanimity. Fail-closed: a provider request failure or a verdict
56255
- * disagreement throws and aborts the balance calculation — see
56518
+ * unanimity AMONG THE PROVIDERS THAT ANSWERED. Fail-closed on disagreement:
56519
+ * a verdict mismatch throws and aborts the balance calculation — see
56256
56520
  * classifySelfChange for why exclusion is not a safe fallback here.
56257
56521
  *
56522
+ * Quorum semantics (2026-09-23, plan C2). ONE failure class is tolerated: a
56523
+ * provider that could not state the chain tip (`BitcoinTipUnreadableError`).
56524
+ * It is ABSENT from the quorum — never counted as agreeing, never allowed to
56525
+ * decide the verdict — and the policy floor, not "at least one", decides when
56526
+ * that absence is fatal: below `minConsensusProviders` surviving readings
56527
+ * there is no cross-check left to trust, and the read fails loudly naming
56528
+ * every provider that dropped out.
56529
+ *
56530
+ * Why only that class. `getTransaction` now throws on an unreadable tip
56531
+ * instead of fabricating `confirmations: 1`; without this carve-out one flaky
56532
+ * `/blocks/tip/height` endpoint would take every balance and spend path down
56533
+ * with it. Every OTHER failure remains fatal, as before: a provider that
56534
+ * answers "I have never seen that transaction" is making a claim about the
56535
+ * chain rather than suffering an outage, and that shape is precisely the
56536
+ * fabricated-UTXO signature the fail-closed rule exists to catch.
56537
+ *
56258
56538
  * When the parent IS a unanimous self-spend, every provider's view of the
56259
56539
  * parent's OUTPUTS must additionally corroborate the primary's claimed
56260
56540
  * UTXOs (index exists, pays the vault, exact value). Without this, a
@@ -56279,32 +56559,52 @@ ${auth.clientId}`;
56279
56559
  )
56280
56560
  )
56281
56561
  );
56282
- const failures = settled.map((r, i) => ({ r, name: providerName(i) })).filter(
56283
- (x) => x.r.status === "rejected"
56284
- ).map(
56285
- ({ r, name }) => `${name} \u2192 ${r.reason?.message ?? String(r.reason)}`
56286
- );
56562
+ const answered = [];
56563
+ const absences = [];
56564
+ const failures = [];
56565
+ settled.forEach((result, i) => {
56566
+ if (result.status === "fulfilled") {
56567
+ answered.push({ index: i, evaluation: result.value });
56568
+ return;
56569
+ }
56570
+ const described = `${providerName(i)} \u2192 ${result.reason?.message ?? String(result.reason)}`;
56571
+ if (isBitcoinTipUnreadableError(result.reason)) {
56572
+ absences.push(described);
56573
+ return;
56574
+ }
56575
+ failures.push(described);
56576
+ });
56287
56577
  if (failures.length > 0) {
56288
56578
  throw new Error(
56289
56579
  `Self-change classification failed for tx ${parentTxid} on ${failures.length}/${providerConfigs.length} provider(s): ${failures.join("; ")}`
56290
56580
  );
56291
56581
  }
56292
- const evaluations = settled.map(
56293
- (r) => r.value
56294
- );
56295
- const votes = evaluations.map((e) => e.selfSpend);
56296
- const disagreements = votes.map((vote, i) => ({ vote, name: providerName(i) })).filter((x) => x.vote !== votes[0]).map(
56297
- (x) => `${providerName(0)}=${votes[0]} vs ${x.name}=${x.vote}`
56582
+ const floor = Math.max(1, this.minConsensusProviders);
56583
+ if (answered.length < floor) {
56584
+ throw new Error(
56585
+ `Self-change classification for tx ${parentTxid}: only ${answered.length}/${providerConfigs.length} provider(s) could state a confirmation depth, below this chain's floor of ${floor}. Unreadable tips: ${absences.join("; ")}`
56586
+ );
56587
+ }
56588
+ if (absences.length > 0) {
56589
+ litDebugLog(
56590
+ `[VaultBalance] self-change: tx ${parentTxid} classified on a reduced quorum \u2014 ${answered.length}/${providerConfigs.length} provider(s) answered (floor ${floor}); dropped for an unreadable chain tip: ${absences.join("; ")}`
56591
+ );
56592
+ }
56593
+ const first = answered[0];
56594
+ const disagreements = answered.slice(1).filter((a) => a.evaluation.selfSpend !== first.evaluation.selfSpend).map(
56595
+ (a) => `${providerName(first.index)}=${first.evaluation.selfSpend} vs ${providerName(a.index)}=${a.evaluation.selfSpend}`
56298
56596
  );
56299
56597
  if (disagreements.length > 0) {
56300
56598
  throw new Error(
56301
56599
  `Self-change consensus mismatch for tx ${parentTxid}: ${disagreements.join("; ")}. A provider may be compromised or out of sync; refusing to sign.`
56302
56600
  );
56303
56601
  }
56304
- if (!votes[0]) {
56602
+ if (!first.evaluation.selfSpend) {
56305
56603
  return false;
56306
56604
  }
56307
- const outputMismatches = evaluations.map((e, i) => e.outputMismatch ? `${providerName(i)} \u2192 ${e.outputMismatch}` : null).filter((m) => m !== null);
56605
+ const outputMismatches = answered.map(
56606
+ (a) => a.evaluation.outputMismatch ? `${providerName(a.index)} \u2192 ${a.evaluation.outputMismatch}` : null
56607
+ ).filter((m) => m !== null);
56308
56608
  if (outputMismatches.length > 0) {
56309
56609
  throw new Error(
56310
56610
  `Self-change output claim mismatch for tx ${parentTxid}: ${outputMismatches.join("; ")}. The reported UTXO set contradicts the parent transaction; refusing to sign.`
@@ -56547,16 +56847,6 @@ ${auth.clientId}`;
56547
56847
  minConfirmations
56548
56848
  );
56549
56849
  const authorizedSpends = await this.getAuthorizedSpendsFromContract(positionId);
56550
- for (const spend of authorizedSpends) {
56551
- const utxoStillExists = utxoSet.utxos.some(
56552
- (utxo) => utxo.txid === spend.txid && utxo.vout === spend.vout
56553
- );
56554
- if (utxoStillExists) {
56555
- throw new Error(
56556
- `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.`
56557
- );
56558
- }
56559
- }
56560
56850
  const authorizedBalance = authorizedSpends.reduce(
56561
56851
  (sum, spend) => sum + spend.satoshis,
56562
56852
  0n
@@ -56852,7 +57142,13 @@ ${auth.clientId}`;
56852
57142
  allowDevSinglePriceProvider: false,
56853
57143
  minBitcoinBalanceConfirmations: 1,
56854
57144
  minBitcoinSpendConfirmations: 1,
56855
- minConsensusProviders: 1
57145
+ // 2 since 2026-09-23. It was 1 because Sepolia ran a single faucet provider
57146
+ // "by design", so the consensus floor was documented as a mainnet-only
57147
+ // guarantee. The registry now holds two, and leaving the floor at 1 meant
57148
+ // Sepolia could never exercise the multi-provider agreement the stale-spend
57149
+ // and balance paths rely on — the one environment where that logic is
57150
+ // supposed to be proved before mainnet.
57151
+ minConsensusProviders: 2
56856
57152
  },
56857
57153
  [
56858
57154
  "ethereum"
@@ -56886,12 +57182,12 @@ ${auth.clientId}`;
56886
57182
  }
56887
57183
  async function executeVaultSnapshot(params) {
56888
57184
  global.ethers = {
56889
- ...import_ethers232.ethers,
57185
+ ...import_ethers242.ethers,
56890
57186
  providers: {
56891
- StaticJsonRpcProvider: import_ethers232.ethers.JsonRpcProvider
57187
+ StaticJsonRpcProvider: import_ethers242.ethers.JsonRpcProvider
56892
57188
  },
56893
- Contract: import_ethers232.ethers.Contract,
56894
- utils: import_ethers232.ethers
57189
+ Contract: import_ethers242.ethers.Contract,
57190
+ utils: import_ethers242.ethers
56895
57191
  // v6 moved utils to top level
56896
57192
  };
56897
57193
  global.Lit = {
@@ -57161,7 +57457,6 @@ function getSepoliaConfig() {
57161
57457
  feeRecipientRegistry: SEPOLIA_CONTRACTS.FeeRecipientRegistry || "",
57162
57458
  positionDelegateRegistry: SEPOLIA_CONTRACTS.PositionDelegateRegistry || "",
57163
57459
  bitcoinWithdrawalAddressRegistry: SEPOLIA_CONTRACTS.BitcoinWithdrawalAddressRegistry || "",
57164
- carryAgentRegistry: SEPOLIA_CONTRACTS.CarryAgentRegistry || "",
57165
57460
  agentDelegationRegistry: SEPOLIA_CONTRACTS.AgentDelegationRegistry || "",
57166
57461
  dhAgentDelegate: SEPOLIA_CONTRACTS.DHAgentDelegate || "",
57167
57462
  agentModuleFactory: SEPOLIA_CONTRACTS.AgentModuleFactory || ""
@@ -57215,7 +57510,6 @@ function getMainnetConfig() {
57215
57510
  feeRecipientRegistry: MAINNET_CONTRACTS.FeeRecipientRegistry || "",
57216
57511
  positionDelegateRegistry: MAINNET_CONTRACTS.PositionDelegateRegistry || "",
57217
57512
  bitcoinWithdrawalAddressRegistry: MAINNET_CONTRACTS.BitcoinWithdrawalAddressRegistry || "",
57218
- carryAgentRegistry: MAINNET_CONTRACTS.CarryAgentRegistry || "",
57219
57513
  agentDelegationRegistry: MAINNET_CONTRACTS.AgentDelegationRegistry || "",
57220
57514
  dhAgentDelegate: MAINNET_CONTRACTS.DHAgentDelegate || "",
57221
57515
  // Empty on mainnet until the factory is deployed there — the ceremony is Sepolia-only.
@@ -57667,14 +57961,49 @@ var SDKError = class _SDKError extends Error {
57667
57961
  };
57668
57962
  }
57669
57963
  };
57964
+ var MAX_GAS_LIMIT = 5000000n;
57965
+ var MAX_FEE_PER_GAS_WEI = 2000000000000n;
57966
+ var DEFAULT_MAX_TX_FEE_WEI = 250000000000000000n;
57967
+ var PRIORITY_FEE_FLOOR_WEI = 100000000n;
57968
+ var PRIORITY_FEE_CAP_WEI = 3000000000n;
57969
+ var DEFAULT_FEE_CEILING = {
57970
+ maxGasLimit: MAX_GAS_LIMIT,
57971
+ maxFeePerGasWei: MAX_FEE_PER_GAS_WEI,
57972
+ maxTxFeeWei: DEFAULT_MAX_TX_FEE_WEI
57973
+ };
57974
+ function fmtEth(wei) {
57975
+ return `${import_ethers15.ethers.formatEther(wei)} ETH`;
57976
+ }
57977
+ function fmtGwei(wei) {
57978
+ return `${import_ethers15.ethers.formatUnits(wei, "gwei")} gwei`;
57979
+ }
57980
+ function worstCaseFeeWei(gasLimit, maxFeePerGas) {
57981
+ if (gasLimit == null || maxFeePerGas == null)
57982
+ return null;
57983
+ return gasLimit * maxFeePerGas;
57984
+ }
57985
+ function assertFeeCeiling(gasLimit, maxFeePerGas, raise, ceiling = DEFAULT_FEE_CEILING) {
57986
+ if (gasLimit != null && gasLimit > ceiling.maxGasLimit) {
57987
+ raise(`gasLimit ${gasLimit} exceeds the signing ceiling of ${ceiling.maxGasLimit}`);
57988
+ }
57989
+ if (maxFeePerGas != null && maxFeePerGas > ceiling.maxFeePerGasWei) {
57990
+ raise(
57991
+ `maxFeePerGas ${fmtGwei(maxFeePerGas)} exceeds the signing ceiling of ${fmtGwei(ceiling.maxFeePerGasWei)}`
57992
+ );
57993
+ }
57994
+ const worst = worstCaseFeeWei(gasLimit, maxFeePerGas);
57995
+ if (worst != null && worst > ceiling.maxTxFeeWei) {
57996
+ raise(
57997
+ `worst-case transaction fee ${fmtEth(worst)} (gasLimit ${gasLimit} \xD7 ${fmtGwei(maxFeePerGas)}) exceeds the signing ceiling of ${fmtEth(ceiling.maxTxFeeWei)}.${ceiling.raiseHint ? ` ${ceiling.raiseHint}` : ""}`
57998
+ );
57999
+ }
58000
+ }
57670
58001
  var MINT_UCD_GAS_CEILING = BigInt(13e5);
57671
58002
  var WITHDRAW_BTC_GAS_CEILING = BigInt(3e6);
57672
58003
  var MAKE_PAYMENT_GAS_CEILING = BigInt(1e6);
57673
58004
  var EXTEND_POSITION_GAS_CEILING = BigInt(1e6);
57674
58005
  var LIQUIDATION_COMMIT_GAS_CEILING = BigInt(1e6);
57675
58006
  var LIQUIDATION_REVEAL_GAS_CEILING = BigInt(2e6);
57676
- var PRIORITY_FEE_FLOOR_WEI = (0, import_ethers14.parseUnits)("0.1", "gwei");
57677
- var PRIORITY_FEE_CAP_WEI = (0, import_ethers14.parseUnits)("3", "gwei");
57678
58007
  var FEE_HISTORY_BLOCK_COUNT = 20;
57679
58008
  var FEE_HISTORY_REWARD_PERCENTILE = 75;
57680
58009
  function isJsonRpcSendable(provider) {
@@ -58147,7 +58476,7 @@ async function getPKPPublicKeyFromTokenId(pkpTokenId, provider, pkpNftContractAd
58147
58476
  `pkpNftContractAddress is required for getPKPPublicKeyFromTokenId`
58148
58477
  );
58149
58478
  }
58150
- const pkpNft = new import_ethers15.Contract(
58479
+ const pkpNft = new import_ethers16.Contract(
58151
58480
  pkpNftContractAddress,
58152
58481
  PKP_NFT_ABI,
58153
58482
  provider
@@ -58184,7 +58513,7 @@ async function generateBalanceConfirmationAuthorization(positionId, chainId, sig
58184
58513
  const timestamp = calculateNextQuantumTimestamp();
58185
58514
  const caller = await signer.getAddress();
58186
58515
  const action = "confirm-balance";
58187
- const actionHash = (0, import_ethers15.keccak256)((0, import_ethers15.toUtf8Bytes)(action));
58516
+ const actionHash = (0, import_ethers16.keccak256)((0, import_ethers16.toUtf8Bytes)(action));
58188
58517
  const types = [
58189
58518
  "bytes32",
58190
58519
  // positionId
@@ -58198,8 +58527,8 @@ async function generateBalanceConfirmationAuthorization(positionId, chainId, sig
58198
58527
  // actionHash
58199
58528
  ];
58200
58529
  const values = [positionId, timestamp, chainId, caller, actionHash];
58201
- const messageHash = (0, import_ethers15.solidityPackedKeccak256)(types, values);
58202
- const messageHashBytes = (0, import_ethers15.getBytes)(messageHash);
58530
+ const messageHash = (0, import_ethers16.solidityPackedKeccak256)(types, values);
58531
+ const messageHashBytes = (0, import_ethers16.getBytes)(messageHash);
58203
58532
  const signature = await signer.signMessage(messageHashBytes);
58204
58533
  return {
58205
58534
  positionId,
@@ -58253,6 +58582,51 @@ async function resolveAuthorizationInput(provider, signer, ctx) {
58253
58582
  }
58254
58583
  return { timestamp: result.timestamp, signature: result.signature };
58255
58584
  }
58585
+ var BECH32_CHARSET = "qpzry9x8gf2tvdw0s3jn54khce6mua7l";
58586
+ function segwitProgramShape(address) {
58587
+ const lower2 = address.trim().toLowerCase();
58588
+ if (!/^(bc1|tb1|bcrt1)/.test(lower2))
58589
+ return null;
58590
+ const sep = lower2.lastIndexOf("1");
58591
+ const data = lower2.slice(sep + 1);
58592
+ if (data.length < 8)
58593
+ return null;
58594
+ const version2 = BECH32_CHARSET.indexOf(data[0]);
58595
+ if (version2 < 0)
58596
+ return null;
58597
+ const programChars = data.length - 1 - 6;
58598
+ return { version: version2, programBytes: Math.floor(programChars * 5 / 8) };
58599
+ }
58600
+ function dustLimitForAddress(address) {
58601
+ const shape = segwitProgramShape(address);
58602
+ if (shape === null)
58603
+ return 546;
58604
+ if (shape.version === 0 && shape.programBytes === 20)
58605
+ return 294;
58606
+ if (shape.version === 0 && shape.programBytes === 32)
58607
+ return 330;
58608
+ if (shape.version === 1 && shape.programBytes === 32)
58609
+ return 330;
58610
+ return 546;
58611
+ }
58612
+ function destinationDustShortfall(targetAmount, networkFee, destination) {
58613
+ const limit = dustLimitForAddress(destination);
58614
+ return targetAmount - networkFee < limit ? limit : null;
58615
+ }
58616
+ function calculateMintFee(params) {
58617
+ const { mintAmount, mintTimestamp, originationFeeBps, previousExpiryAt, selectedTerm, totalTerm } = params;
58618
+ let mintFee = mintAmount * BigInt(originationFeeBps) / 10000n;
58619
+ if (previousExpiryAt > 0 && mintTimestamp < previousExpiryAt) {
58620
+ const tailSeconds = BigInt(previousExpiryAt) - BigInt(mintTimestamp);
58621
+ const originalTermMonths = totalTerm - selectedTerm;
58622
+ const originalTermSeconds = BigInt(
58623
+ originalTermMonths === 12 ? 365 * 86400 : originalTermMonths * 30 * 86400
58624
+ );
58625
+ const tailFee = tailSeconds * BigInt(originationFeeBps) * mintAmount / (10000n * originalTermSeconds);
58626
+ mintFee = mintFee + tailFee;
58627
+ }
58628
+ return mintFee;
58629
+ }
58256
58630
  function baseMintFeeWei(mintAmountWei, originationFeeBps) {
58257
58631
  if (mintAmountWei < 0n)
58258
58632
  throw new Error("baseMintFeeWei: mintAmountWei cannot be negative");
@@ -58271,20 +58645,34 @@ function debtAfterMintExceedsLoanCap(params) {
58271
58645
  }
58272
58646
  return currentDebtWei + mintAmountWei + mintFeeWei > maxLoanWei;
58273
58647
  }
58274
- function maxPrincipalWithinLoanCap(params) {
58275
- const { maxLoanWei, currentDebtWei, originationFeeBps } = params;
58276
- if (maxLoanWei < 0n || currentDebtWei < 0n) {
58277
- throw new Error("maxPrincipalWithinLoanCap: amounts cannot be negative");
58648
+ function collateralRatioBps(sats, price8, debtWei) {
58649
+ if (sats < 0n || price8 < 0n) {
58650
+ throw new Error("collateralRatioBps: sats and price cannot be negative");
58278
58651
  }
58279
- if (!Number.isInteger(originationFeeBps) || originationFeeBps < 0 || originationFeeBps > 1e4) {
58280
- throw new Error(
58281
- `maxPrincipalWithinLoanCap: originationFeeBps must be an integer in [0, 10000] (got ${String(originationFeeBps)})`
58282
- );
58652
+ if (debtWei <= 0n) {
58653
+ throw new Error("collateralRatioBps: debt must be positive");
58283
58654
  }
58284
- const room = maxLoanWei - currentDebtWei;
58285
- if (room <= 0n)
58286
- return 0n;
58287
- return room * 10000n / (10000n + BigInt(originationFeeBps));
58655
+ return sats * price8 * 100n * 10000n / debtWei;
58656
+ }
58657
+ function collateralRatioPercentString(sats, price8, debtWei) {
58658
+ const bps = collateralRatioBps(sats, price8, debtWei);
58659
+ return `${bps / 100n}.${(bps % 100n).toString().padStart(2, "0")}`;
58660
+ }
58661
+ function maxPrincipalForFee(room, fee) {
58662
+ if (room < 0n)
58663
+ throw new Error("maxPrincipalForFee: room cannot be negative");
58664
+ if (fee(0n) !== 0n)
58665
+ throw new Error("maxPrincipalForFee: fee(0) must be 0");
58666
+ let lo = 0n;
58667
+ let hi = room;
58668
+ while (lo < hi) {
58669
+ const mid = (lo + hi + 1n) / 2n;
58670
+ if (mid + fee(mid) <= room)
58671
+ lo = mid;
58672
+ else
58673
+ hi = mid - 1n;
58674
+ }
58675
+ return lo;
58288
58676
  }
58289
58677
  function buildLoginDomain(chainId) {
58290
58678
  return {
@@ -58331,7 +58719,7 @@ async function buildSignedLoginPayload(signer, chainId, audience, reuse, withSta
58331
58719
  ...statement ? { statement } : {},
58332
58720
  address,
58333
58721
  issuedAt: reuse?.issuedAt ?? Math.floor(Date.now() / 1e3),
58334
- nonce: reuse?.nonce ?? (0, import_ethers17.hexlify)((0, import_ethers17.randomBytes)(32)),
58722
+ nonce: reuse?.nonce ?? (0, import_ethers18.hexlify)((0, import_ethers18.randomBytes)(32)),
58335
58723
  ...audience ? { audience } : {}
58336
58724
  };
58337
58725
  const signature = await signer.signTypedData(
@@ -58932,16 +59320,13 @@ var ERROR_STRING_SELECTOR = "0x08c379a0";
58932
59320
  var PANIC_SELECTOR = "0x4e487b71";
58933
59321
  var QUANTUM_REVERT_NAMES = {
58934
59322
  "0xbe4b82c1": "DeadZoneViolation()",
58935
- "0x137f3b70": "InDeadZone()",
58936
- "0x131d9a21": "QuantumExpired()",
58937
59323
  "0x52ce5d58": "QuantumAlreadyUsed()",
58938
59324
  "0x3e76a3c9": "QuantumOutsideWindow()",
58939
- "0x8baa579f": "InvalidSignature()",
58940
59325
  "0x62278171": "InvalidValidatorSignature()",
58941
- "0x3ee5aeb5": "OperationNotAuthorized()",
58942
- "0x48f5c3ed": "Unauthorized()",
58943
- "0x70f4b32a": "UnauthorizedSigner()",
58944
- "0xd92e233d": "ValidationFailed()",
59326
+ "0x82b42900": "Unauthorized()",
59327
+ "0x3ee5aeb5": "ReentrancyGuardReentrantCall()",
59328
+ "0x0a0b0d79": "ValidationFailed()",
59329
+ "0xd92e233d": "ZeroAddress()",
58945
59330
  "0x36bfdeea": "StateHashMismatch()",
58946
59331
  "0xb9d419a7": "DebtUpdateVerificationFailed()",
58947
59332
  "0xc7e20553": "DebtUpdateVerificationFailedDetailed(bytes32,uint256,uint256,uint256,uint256,uint256)",
@@ -58957,13 +59342,13 @@ function decodeQuantumRevert(e) {
58957
59342
  if (!name && selector && data) {
58958
59343
  try {
58959
59344
  if (selector === ERROR_STRING_SELECTOR) {
58960
- const [message] = import_ethers18.AbiCoder.defaultAbiCoder().decode(
59345
+ const [message] = import_ethers19.AbiCoder.defaultAbiCoder().decode(
58961
59346
  ["string"],
58962
59347
  "0x" + data.slice(10)
58963
59348
  );
58964
59349
  name = `Error("${message}")`;
58965
59350
  } else if (selector === PANIC_SELECTOR) {
58966
- const [code] = import_ethers18.AbiCoder.defaultAbiCoder().decode(
59351
+ const [code] = import_ethers19.AbiCoder.defaultAbiCoder().decode(
58967
59352
  ["uint256"],
58968
59353
  "0x" + data.slice(10)
58969
59354
  );
@@ -59211,12 +59596,12 @@ var RECOVERY_INVALIDATE_ACTION = "btc-utxo-invalidator";
59211
59596
  var QUANTUM_SECONDS = 60;
59212
59597
  var QUANTUM_SAFE_THRESHOLD = 40;
59213
59598
  function buildInvalidateMessageHash(params) {
59214
- const positionIdBytes32 = (0, import_ethers19.zeroPadValue)(
59599
+ const positionIdBytes32 = (0, import_ethers20.zeroPadValue)(
59215
59600
  params.positionId.startsWith("0x") ? params.positionId : `0x${params.positionId}`,
59216
59601
  32
59217
59602
  );
59218
- const actionHash = (0, import_ethers19.keccak256)((0, import_ethers19.toUtf8Bytes)(RECOVERY_INVALIDATE_ACTION));
59219
- return (0, import_ethers19.solidityPackedKeccak256)(
59603
+ const actionHash = (0, import_ethers20.keccak256)((0, import_ethers20.toUtf8Bytes)(RECOVERY_INVALIDATE_ACTION));
59604
+ return (0, import_ethers20.solidityPackedKeccak256)(
59220
59605
  [
59221
59606
  "bytes32",
59222
59607
  // positionId
@@ -59262,7 +59647,7 @@ async function buildInvalidateStaleSpendEnvelope(params) {
59262
59647
  utxoTxid,
59263
59648
  utxoVout
59264
59649
  });
59265
- const signature = await signer.signMessage((0, import_ethers19.getBytes)(messageHash));
59650
+ const signature = await signer.signMessage((0, import_ethers20.getBytes)(messageHash));
59266
59651
  const borrowerAddress = await signer.getAddress();
59267
59652
  return {
59268
59653
  positionId,
@@ -59305,7 +59690,7 @@ function hashBtcInputSet(utxos) {
59305
59690
  seen.add(key);
59306
59691
  }
59307
59692
  const canonical = normalized.sort((a, b) => a.txid < b.txid ? -1 : a.txid > b.txid ? 1 : a.vout - b.vout).map((u) => `${u.txid}:${u.vout}:${u.value}`).join("|");
59308
- return (0, import_ethers20.keccak256)((0, import_ethers20.toUtf8Bytes)(canonical));
59693
+ return (0, import_ethers21.keccak256)((0, import_ethers21.toUtf8Bytes)(canonical));
59309
59694
  }
59310
59695
  async function buildBtcExecuteEnvelope(params) {
59311
59696
  const {
@@ -59350,15 +59735,15 @@ async function buildBtcExecuteEnvelope(params) {
59350
59735
  } else {
59351
59736
  timestamp = currentQuantumStart;
59352
59737
  }
59353
- const actionHash = (0, import_ethers20.keccak256)(
59354
- (0, import_ethers20.toUtf8Bytes)("execute-btc-withdrawal")
59738
+ const actionHash = (0, import_ethers21.keccak256)(
59739
+ (0, import_ethers21.toUtf8Bytes)("execute-btc-withdrawal")
59355
59740
  );
59356
59741
  const utxoIdentifier = `${txid}:${vout}`;
59357
- const positionIdBytes32 = (0, import_ethers20.zeroPadValue)(
59742
+ const positionIdBytes32 = (0, import_ethers21.zeroPadValue)(
59358
59743
  positionId.startsWith("0x") ? positionId : `0x${positionId}`,
59359
59744
  32
59360
59745
  );
59361
- const messageHash = (0, import_ethers20.solidityPackedKeccak256)(
59746
+ const messageHash = (0, import_ethers21.solidityPackedKeccak256)(
59362
59747
  [
59363
59748
  "bytes32",
59364
59749
  // positionId
@@ -59391,7 +59776,7 @@ async function buildBtcExecuteEnvelope(params) {
59391
59776
  actionHash
59392
59777
  ]
59393
59778
  );
59394
- const userSignature = await signer.signMessage((0, import_ethers20.getBytes)(messageHash));
59779
+ const userSignature = await signer.signMessage((0, import_ethers21.getBytes)(messageHash));
59395
59780
  const borrowerAddress = await signer.getAddress();
59396
59781
  return {
59397
59782
  positionId,
@@ -59759,7 +60144,7 @@ function rowToStatus(row) {
59759
60144
  return row;
59760
60145
  }
59761
60146
  async function fetchProtocolPauseStatus(provider, positionManagerAddress) {
59762
- const iface = new import_ethers22.Interface(GET_PROTOCOL_PAUSE_STATUS_ABI);
60147
+ const iface = new import_ethers23.Interface(GET_PROTOCOL_PAUSE_STATUS_ABI);
59763
60148
  const data = iface.encodeFunctionData("getProtocolPauseStatus", []);
59764
60149
  const raw = await provider.call({ to: positionManagerAddress, data });
59765
60150
  const decoded = iface.decodeFunctionResult("getProtocolPauseStatus", raw);
@@ -59949,38 +60334,38 @@ var ContractManager = class {
59949
60334
  }
59950
60335
  const contractRunner = runner;
59951
60336
  const contracts = {
59952
- positionManager: new import_ethers23.Contract(
60337
+ positionManager: new import_ethers24.Contract(
59953
60338
  contractAddresses.positionManager,
59954
60339
  POSITION_MANAGER_ABI,
59955
60340
  contractRunner
59956
60341
  ),
59957
- loanOperationsManager: new import_ethers23.Contract(
59958
- contractAddresses.loanOperationsManager || import_ethers23.ZeroAddress,
60342
+ loanOperationsManager: new import_ethers24.Contract(
60343
+ contractAddresses.loanOperationsManager || import_ethers24.ZeroAddress,
59959
60344
  LOAN_OPS_ABI,
59960
60345
  contractRunner
59961
60346
  ),
59962
- ucdController: new import_ethers23.Contract(
60347
+ ucdController: new import_ethers24.Contract(
59963
60348
  contractAddresses.ucdToken,
59964
60349
  UCD_CONTROLLER_ABI,
59965
60350
  contractRunner
59966
60351
  ),
59967
- termManager: new import_ethers23.Contract(
59968
- contractAddresses.termManager || import_ethers23.ZeroAddress,
60352
+ termManager: new import_ethers24.Contract(
60353
+ contractAddresses.termManager || import_ethers24.ZeroAddress,
59969
60354
  TERM_MANAGER_ABI,
59970
60355
  contractRunner
59971
60356
  ),
59972
- circuitBreaker: new import_ethers23.Contract(
59973
- contractAddresses.circuitBreaker || import_ethers23.ZeroAddress,
60357
+ circuitBreaker: new import_ethers24.Contract(
60358
+ contractAddresses.circuitBreaker || import_ethers24.ZeroAddress,
59974
60359
  CIRCUIT_BREAKER_ABI,
59975
60360
  contractRunner
59976
60361
  ),
59977
- liquidationManager: new import_ethers23.Contract(
59978
- contractAddresses.liquidationManager || import_ethers23.ZeroAddress,
60362
+ liquidationManager: new import_ethers24.Contract(
60363
+ contractAddresses.liquidationManager || import_ethers24.ZeroAddress,
59979
60364
  LIQUIDATION_MANAGER_ABI,
59980
60365
  contractRunner
59981
60366
  ),
59982
- bitcoinWithdrawalAddressRegistry: new import_ethers23.Contract(
59983
- contractAddresses.bitcoinWithdrawalAddressRegistry || import_ethers23.ZeroAddress,
60367
+ bitcoinWithdrawalAddressRegistry: new import_ethers24.Contract(
60368
+ contractAddresses.bitcoinWithdrawalAddressRegistry || import_ethers24.ZeroAddress,
59984
60369
  BITCOIN_WITHDRAWAL_ADDRESS_REGISTRY_ABI,
59985
60370
  contractRunner
59986
60371
  )
@@ -60029,13 +60414,13 @@ var ContractManager = class {
60029
60414
  const address = addresses[key];
60030
60415
  if (!address) {
60031
60416
  missing.push(String(key));
60032
- } else if (!(0, import_ethers23.isAddress)(address)) {
60417
+ } else if (!(0, import_ethers24.isAddress)(address)) {
60033
60418
  invalid.push(String(key));
60034
60419
  }
60035
60420
  }
60036
60421
  for (const key of optionalAddresses) {
60037
60422
  const address = addresses[key];
60038
- if (address && !(0, import_ethers23.isAddress)(address)) {
60423
+ if (address && !(0, import_ethers24.isAddress)(address)) {
60039
60424
  invalid.push(String(key));
60040
60425
  }
60041
60426
  }
@@ -61350,11 +61735,11 @@ var LoanCreator = class {
61350
61735
  try {
61351
61736
  const mainnetVaultAddress = bitcoinAddresses.mainnet;
61352
61737
  const regtestVaultAddress = bitcoinAddresses.regtest;
61353
- const pkpIdBytes32 = (0, import_ethers24.zeroPadValue)(
61354
- (0, import_ethers24.toBeHex)(BigInt(pkpData.tokenId)),
61738
+ const pkpIdBytes32 = (0, import_ethers25.zeroPadValue)(
61739
+ (0, import_ethers25.toBeHex)(BigInt(pkpData.tokenId)),
61355
61740
  32
61356
61741
  );
61357
- const pkpPublicKeyUncompressed = import_ethers24.SigningKey.computePublicKey(
61742
+ const pkpPublicKeyUncompressed = import_ethers25.SigningKey.computePublicKey(
61358
61743
  pkpData.publicKey,
61359
61744
  false
61360
61745
  );
@@ -61367,7 +61752,7 @@ var LoanCreator = class {
61367
61752
  );
61368
61753
  log.debug(`BigInt conversion: ${BigInt(pkpData.tokenId).toString()}`);
61369
61754
  log.debug(
61370
- `Hex from BigInt: ${(0, import_ethers24.toBeHex)(BigInt(pkpData.tokenId))}`
61755
+ `Hex from BigInt: ${(0, import_ethers25.toBeHex)(BigInt(pkpData.tokenId))}`
61371
61756
  );
61372
61757
  log.debug(`Final bytes32 (zero-padded): ${pkpIdBytes32}`);
61373
61758
  log.debug(
@@ -61539,8 +61924,8 @@ var LoanCreator = class {
61539
61924
  }
61540
61925
  }
61541
61926
  if (this.config.debug) {
61542
- const pkpIdBytes32Check = (0, import_ethers24.zeroPadValue)(
61543
- (0, import_ethers24.toBeHex)(BigInt(pkpData.tokenId)),
61927
+ const pkpIdBytes32Check = (0, import_ethers25.zeroPadValue)(
61928
+ (0, import_ethers25.toBeHex)(BigInt(pkpData.tokenId)),
61544
61929
  32
61545
61930
  );
61546
61931
  log.error("\u274C Loan creation transaction failed", {
@@ -61701,7 +62086,7 @@ var LoanCreator = class {
61701
62086
  const coreAddress = this.config.contractManager.getContractAddresses().positionManagerCore;
61702
62087
  if (coreAddress) {
61703
62088
  try {
61704
- const core = new import_ethers24.Contract(
62089
+ const core = new import_ethers25.Contract(
61705
62090
  coreAddress,
61706
62091
  [
61707
62092
  "function getPositionDetails(bytes32) view returns (tuple(bytes32 positionId, bytes32 pkpId, uint256 ucdDebt, string vaultAddress, address borrower, uint40 createdAt, uint40 lastUpdated, uint16 selectedTerm, uint40 expiryAt, uint8 status))"
@@ -61743,8 +62128,8 @@ var LoanCreator = class {
61743
62128
  const newEventAbi = [
61744
62129
  "event PositionCreated(bytes32 indexed positionId, bytes32 indexed pkpId, address indexed borrower, uint256 requestedCollateralRatio, uint256 selectedTerm, uint256 expiryAt)"
61745
62130
  ];
61746
- const oldIface = new import_ethers24.Interface(oldEventAbi);
61747
- const newIface = new import_ethers24.Interface(newEventAbi);
62131
+ const oldIface = new import_ethers25.Interface(oldEventAbi);
62132
+ const newIface = new import_ethers25.Interface(newEventAbi);
61748
62133
  let positionId;
61749
62134
  if (this.config.debug) {
61750
62135
  log.info("\u{1F50D} Parsing transaction receipt logs", {
@@ -62224,7 +62609,7 @@ var LoanQuery = class {
62224
62609
  const isChipotlePkpId2 = typeof rawId === "string" && isNormalizedChipotlePkpId(rawId);
62225
62610
  if (isChipotlePkpId2) {
62226
62611
  if (this.config.positionManagerCoreAddress && this.config.provider) {
62227
- const pmContract = new import_ethers25.Contract(
62612
+ const pmContract = new import_ethers26.Contract(
62228
62613
  this.config.positionManagerCoreAddress,
62229
62614
  POSITION_CORE_ABI,
62230
62615
  this.config.provider
@@ -62327,7 +62712,7 @@ var LoanQuery = class {
62327
62712
  */
62328
62713
  async getBorrowerUcdDebtSummary(borrower) {
62329
62714
  const trimmed = typeof borrower === "string" ? borrower.trim() : "";
62330
- if (!(0, import_ethers25.isAddress)(trimmed)) {
62715
+ if (!(0, import_ethers26.isAddress)(trimmed)) {
62331
62716
  return failure(
62332
62717
  new SDKError({
62333
62718
  message: `Borrower must be an EVM address for a UCD debt summary, got "${trimmed}"`,
@@ -62602,7 +62987,7 @@ var WithdrawalAddressModule = class {
62602
62987
  if (!res.success)
62603
62988
  return res;
62604
62989
  const target = res.value.target;
62605
- if (!target || target === import_ethers26.ZeroAddress) {
62990
+ if (!target || target === import_ethers27.ZeroAddress) {
62606
62991
  return failure(
62607
62992
  new SDKError({
62608
62993
  code: "SDK_WITHDRAWAL_REGISTRY_NOT_CONFIGURED",
@@ -62621,7 +63006,7 @@ var WithdrawalAddressModule = class {
62621
63006
  }
62622
63007
  /** keccak256 of the canonicalized address — matches the on-chain key. */
62623
63008
  static addressHash(btcAddress2) {
62624
- return (0, import_ethers26.keccak256)((0, import_ethers26.toUtf8Bytes)(normalizeBitcoinAddress(btcAddress2)));
63009
+ return (0, import_ethers27.keccak256)((0, import_ethers27.toUtf8Bytes)(normalizeBitcoinAddress(btcAddress2)));
62625
63010
  }
62626
63011
  /**
62627
63012
  * Add a Bitcoin address to the caller's allowlist. It becomes usable only
@@ -68641,7 +69026,7 @@ var _abi = [
68641
69026
  ];
68642
69027
  var _bytecode = "0x60a080604052346100ea57306080527ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a005460ff8160401c166100d9576002600160401b03196001600160401b03821601610073575b60405161485a90816100f0823960805181818161278e01526128870152f35b6001600160401b0319166001600160401b039081177ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a005581527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d290602090a13880610054565b63f92ee8a960e01b60005260046000fd5b600080fdfe6080604052600436101561001257600080fd5b6000803560e01c8062f7fce91461384657806301ffc9a7146137d5578063021d28931461377c5780630871b20614613743578063114249d214610f6157806311d954f81461371a57806313da3166146136e15780631d44a904146136385780631f77bf65146135ff578063248a9ca3146135e05780632b83cccd146131205780632f2ff15d146130ee57806334bac370146130b557806334e181251461307c57806336568abe14613037578063373c86b614612ffe5780633f4ba83a14612f375780634373b57214612f0e5780634451e89b14612b3a5780634ebd25a514612b015780634f1ef2861461280c5780635273b6f6146127e357806352d1902d1461277b578063568fafca146126ed57806359d5d02a146124205780635bc26aea146123eb5780635c975abb146123bb5780635ecc27081461229d5780638456cb59146121a257806385c15d9a1461216957806389d3ad00146120a25780638bff608e146120695780639010d07c1461201657806390ad8b4014611ffa57806391d1485414611fa15780639b759bf714611f5e5780639baf58d214611f415780639f1d0f59146118a8578063a217fddf1461188c578063a3246ad3146117cf578063ad3cb1cc14611788578063b492fc691461168e578063b9f637af14611463578063bf7d911914611424578063c4c5f62414611371578063c55f15ea1461134e578063ca15c87314611317578063ca2ce65d146112de578063cc1f8ffa146112ac578063cf46075e146111a2578063d21a74ff14611165578063d2f8253614611142578063d547741f14611107578063d5d3f78b14610f9a578063d66bd52414610f61578063e1f1c4a714610f44578063e1f3962c14610f18578063ec2f96fe14610ef4578063eda5a26a14610af7578063f1a1eb8414610ab4578063f385116d14610a7b578063f77c479114610a54578063f8c8765e14610661578063faaebd2114610628578063facdfb5e14610488578063fc99bd9a14610377578063fe32e7281461033e5763ffa1ad741461030857600080fd5b3461033b578060031936011261033b57610337610323613a68565b604051918291602083526020830190613a17565b0390f35b80fd5b503461033b57602036600319011261033b576020906040906001600160a01b0361036661392e565b168152601283522054604051908152f35b503461033b57604036600319011261033b5761039161392e565b6010546024359291906001600160a01b03163303610479576001600160a01b03168082526002602052604082205490929060ff16156104665780156104575782825260076020526040822054926103e88285613cb0565b848110610448576001600160ff1b0381116104395760008051602061482e833981519152604085968493846104369852600760205280838a205582519182526020820152a23090339061421c565b80f35b630700fcb360e11b8452600484fd5b63446c8cc960e01b8452600484fd5b63162908e360e11b8252600482fd5b506024916374ed46ad60e01b8252600452fd5b6349db3bd360e01b8252600482fd5b503461033b57602036600319011261033b576104a261392e565b6104aa613f12565b6010546001600160a01b03163303610479576001600160a01b03168082526002602052604082205460ff161561061657808252600760205260408220546040516370a0823160e01b8152306004820152602081602481865afa90811561060b5784916105d4575b50818111156105c5576105248282613b6c565b8215908115610570575b505060008051602061482e833981519152916040918486526007602052808387205582519182526020820152a260016000805160206147ce8339815191525580f35b61271081029080820461271014901517156105b157606484029184830460641417156105b157116105a257388061052e565b63a73af74d60e01b8452600484fd5b634e487b7160e01b86526011600452602486fd5b6105cf8183613b6c565b610524565b90506020813d602011610603575b816105ef602093836139c3565b810103126105fe575138610511565b600080fd5b3d91506105e2565b6040513d86823e3d90fd5b6374ed46ad60e01b8252600452602490fd5b503461033b57602036600319011261033b576020906040906001600160a01b0361065061392e565b168152600483522054604051908152f35b503461033b57608036600319011261033b5761067b61392e565b610683613944565b6044356001600160a01b03811690818103610a50576064356001600160a01b0381169390849003610a4c5760008051602061480e83398151915254604081901c60ff161595906001600160401b031680159081610a44575b6001149081610a3a575b159081610a31575b50610a225760008051602061480e83398151915280546001600160401b0319166001179055856109fd575b6001600160a01b03169081156109ee576001600160a01b03169081156109df5783156109d05761074661448a565b61074e61448a565b61075661448a565b61075e61448a565b60016000805160206147ce8339815191525561077861448a565b61078061448a565b86546001600160a01b0319908116919091178755600180549182168317905560405163313ce56760e01b8152909190602081600481855afa88918161099f575b506107d457633a24e95b60e11b8852600488fd5b6001600160a81b03199092161760a091821b60ff60a01b16176001819055901c60ff16601119810161098d575061080b8186614348565b80610965575b156109205761082e816000805160206147ee833981519152614348565b8061092f575b15610920576108519060008051602061470e833981519152614348565b90816108e9575b50156108da57806108af575b5061086c5780f35b60ff60401b1960008051602061480e833981519152541660008051602061480e833981519152556000805160206146ee833981519152602060405160018152a180f35b601080546001600160a01b031916821790558260008051602061474e8339815191528180a338610864565b63cf5a8e3360e01b8352600483fd5b6109199060008051602061470e83398151915286526000805160206146ae833981519152602052604086206144d0565b5038610858565b63cf5a8e3360e01b8552600485fd5b6000805160206147ee83398151915286526000805160206146ae83398151915260205261095f83604088206144d0565b50610834565b8580526000805160206146ae83398151915260205261098783604088206144d0565b50610811565b63167738cf60e21b8652600452602485fd5b6109c291925060203d6020116109c9575b6109ba81836139c3565b810190613ba9565b90386107c0565b503d6109b0565b630b5eba9f60e41b8752600487fd5b63c1ab6dc160e01b8752600487fd5b6336abb4df60e11b8752600487fd5b60008051602061480e833981519152805460ff60401b1916600160401b179055610718565b63f92ee8a960e01b8752600487fd5b905015386106ed565b303b1591506106e5565b8791506106db565b8580fd5b8480fd5b503461033b578060031936011261033b57546040516001600160a01b039091168152602090f35b503461033b57602036600319011261033b576020906040906001600160a01b03610aa361392e565b168152600a83522054604051908152f35b503461033b57604036600319011261033b576020906040906001600160a01b03610adc61392e565b16815260158352818120602435825283522054604051908152f35b503461033b5761016036600319011261033b57610b1261392e565b90606435604435602435610b24613a58565b9160a4359160c43560e43561010435916101243595610144359760018060a01b03601054163303610ee5576001600160a01b038c16808c52600260205260408c2054909a9060ff16610ed1578a15610ec2578615610eb3576127108811610e99576103e88111610e815760ff82169c60128e118e8115610e76575b50610e6257803b15610e4e578915610e3a578a15610e265782610bc191614260565b84151580610e1d575b610e065785151580610dfd575b610de6578b9c602460208d9e9d604051928380926370a0823160e01b82523060048301525afa9c8d15610dda579c610da6575b506001600160ff1b038c11610d97578a8d8f9760408f97838f918f8f8f8f90859f988f99879f9660008051602061476e8339815191529f978b9f988f8d6000805160206146ce8339815191529f988e8e610d4f9b60008051602061468e8339815191529f8f8f8487526002602052878720600160ff198254161790558487526003602052878720558386526004602052868620558285526006602052878686205582855260056020528585209060ff19825416179055818452600c6020528885852055818452600d6020528985852055818452600e6020528a85852055818452600f6020528b8585205581845260076020528484205582526012602052828220558d8152601360205220558a7f991d1ef1b5c0820d213328cba6682059e00a50e49c469a454eb3557e78eaf6668e80518b81528c6020820152a28c5198899889613cbd565b0390a28151908b82526020820152a28151908782526020820152a280610d73578280f35b604060008051602061482e833981519152918151908582526020820152a281808280f35b63556e7a8160e01b8e5260048efd5b909b506020813d602011610dd2575b81610dc2602093836139c3565b810103126105fe57519a38610c0a565b3d9150610db5565b604051903d90823e3d90fd5b60448c858863dd85772b60e01b8352600452602452fd5b50838610610bd7565b60448c8487637449915760e01b8352600452602452fd5b50828510610bca565b636835314760e11b8d52600160045260248dfd5b636835314760e11b8d5260048d905260248dfd5b63377e3f9960e21b8d5260048c905260248dfd5b63ca95039160e01b8d5260048e905260248dfd5b60069150108e610b9f565b631051834f60e11b8c526004526103e860245260448bfd5b63c1e9a14160e01b8c52600488905261271060245260448cfd5b63a2ec3a5560e01b8c5260048cfd5b63df407ac560e01b8c5260048cfd5b6317f4215b60e21b8c5260048b905260248cfd5b6349db3bd360e01b8b5260048bfd5b503461033b578060031936011261033b57602060ff60015460a01c16604051908152f35b503461033b57602036600319011261033b576020610f3c610f3761392e565b613df5565b604051908152f35b503461033b578060031936011261033b5760206040516127108152f35b503461033b57602036600319011261033b576020906040906001600160a01b03610f8961392e565b168152600783522054604051908152f35b503461033b57602036600319011261033b57610fb461392e565b6010546001600160a01b03163303610479576001600160a01b03168082526002602052604082205460ff16156106165780825260076020526040822054806110f1575080825260026020526040822060ff1981541690558082526003602052816040812055808252600460205281604081205580825260056020526040822060ff198154169055808252600c602052816040812055808252600d602052816040812055808252600e602052816040812055808252600f602052816040812055808252600660205281604081205580825260076020526040822054818352600760205282604081205560405190827f3302a1b37f04242bb55603f5449e7ecd690a35eef08ba1353c48c20e2aae9cda8580a2806110ce578380f35b8160409160008051602061482e8339815191529352846020820152a23880808380f35b604492916376bc059760e11b8352600452602452fd5b503461033b57604036600319011261033b5761113e600435611127613944565b9061113961113482613b79565b614088565b61411a565b5080f35b503461033b578060031936011261033b57602060ff600854166040519015158152f35b503461033b57602036600319011261033b5760209060ff906040906001600160a01b0361119061392e565b16815260058452205416604051908152f35b503461033b57602036600319011261033b576111bc61392e565b6111c4613f12565b6010546001600160a01b03163303610479576001600160a01b03168082526002602052604082205460ff161561061657808252600760205260408220546040516370a0823160e01b8152306004820152602081602481865afa90811561060b57849161126c575b5060008051602061482e833981519152916040918486526007602052808387205582519182526020820152a260016000805160206147ce8339815191525580f35b90506020813d6020116112a4575b81611287602093836139c3565b810103126105fe575160008051602061482e83398151915261122b565b3d915061127a565b503461033b57604036600319011261033b5760206112d46112cb61392e565b60243590613cf6565b6040519015158152f35b503461033b57602036600319011261033b576020906040906001600160a01b0361130661392e565b168152601383522054604051908152f35b503461033b57602036600319011261033b57604060209160043581526000805160206146ae83398151915283522054604051908152f35b503461033b578060031936011261033b576020604051670de0b6b3a76400008152f35b503461033b57604036600319011261033b5761138b61392e565b6010546024359291906001600160a01b03163303610479576001600160a01b031680825260076020526040822054929081841061140d578060008051602061482e8339815191526040866113e3866104369899613b6c565b84895260076020528289205583885260076020528188205482519182526020820152a2339061404c565b5091604492633cb8e07360e01b8352600452602452fd5b503461033b57602036600319011261033b5760209060ff906040906001600160a01b0361144f61392e565b168152600284522054166040519015158152f35b503461033b5761012036600319011261033b5761147e61392e565b6064359190604435602435611491613a58565b601054610104359660e4359260c4359260a43592906001600160a01b0316330361167f576001600160a01b038816808a52600260205260408a205490989060ff161561166b57861561165c576127108811611642576103e882116116285760ff83169060128211801561161e575b61160a578361150d91614260565b85151580611601575b6115ea578a1515806115e1575b6115ca579260008051602061468e83398151915297969592828c956115c4979460408e8e80825260036020528c8383205580825260046020528d838320558152600660205220558b8d52600560205260408d209060ff198254161790558a8c52600c6020528260408d20558a8c52600d6020528360408d20558a8c52600e6020528460408d20558a8c52600f6020528560408d205560405198899889613cbd565b0390a280f35b60448a868d63dd85772b60e01b8352600452602452fd5b50848b10611523565b60448a8588637449915760e01b8352600452602452fd5b50838610611516565b63ca95039160e01b8b52600482905260248bfd5b50600682106114ff565b631051834f60e11b8a5260048290526103e860245260448afd5b63c1e9a14160e01b8a52600488905261271060245260448afd5b63a2ec3a5560e01b8a5260048afd5b6374ed46ad60e01b8a52600489905260248afd5b6349db3bd360e01b8952600489fd5b503461033b57604036600319011261033b576116a861392e565b6001600160a01b0316808252600260205260408220546024359060ff16156117745780156117655761271061172a604085670de0b6b3a76400006117196117329688859a52600560205260ff85852054169080916012811061173f575b505088845260036020528484205490613a8b565b049581526004602052205484613a8b565b048092613b6c565b9082519182526020820152f35b61175e925060ff61175261175892613ad4565b16613ae5565b90613a8b565b3880611705565b63162908e360e11b8352600483fd5b6374ed46ad60e01b83526004829052602483fd5b503461033b578060031936011261033b5761033760408051906117ab81836139c3565b60058252640352e302e360dc1b602083015251918291602083526020830190613a17565b503461033b57602036600319011261033b5760043581526000805160206146ae83398151915260205260408120604051908160208254918281520190819285526020852090855b818110611876575050508261182c9103836139c3565b604051928392602084019060208552518091526040840192915b818110611854575050500390f35b82516001600160a01b0316845285945060209384019390920191600101611846565b8254845260209093019260019283019201611816565b503461033b578060031936011261033b57602090604051908152f35b503461033b576118b736613969565b9190926118c2613f12565b6118ca613f4e565b338152600960205260408120544303611f1f57338152600a602052600360408220541015611f1057338152600a602052604081206119088154613b9a565b90555b6001600160a01b0382168082526002602052604082205490929060ff16611e6f575b828252600260205260ff60408320541615610466578415610457578315611e6057828252600c60205260408220548510611e3b57828252600e60205260408220548015611e2c57808611611e155750846119869161415e565b6040516370a0823160e01b8152306004820152602081602481865afa908115611e0a578291611dd8575b506119bd8530338661421c565b6040516370a0823160e01b8152306004820152602081602481875afa908115611cef57908692918491611d9f575b50906119f691613b6c565b10611d905781815260076020526040812054611a128582613cb0565b818110611d81576001600160ff1b038111611d72576040849260008051602061482e833981519152928486526007602052808387205582519182526020820152a2818152600560205260ff604082205416849060128110611d11575b50611a8f670de0b6b3a7640000918484526003602052604084205490613a8b565b04908281526004602052612710611aaa604083205484613a8b565b0491611ab68382613b6c565b94808610611cfa57506001546040516318160ddd60e01b815290602090829060049082906001600160a01b03165afa908115611cef578391611cbd575b5082546001600160a01b0316803b15611ca45783809160846040518094819363ae494fa160e01b83523360048401528c60248401528b60448401528d60648401525af1801561060b57908491611ca8575b505083611c34575b6001546040516318160ddd60e01b81529190602090839060049082906001600160a01b03165afa801561060b578490611c00575b611b8a9250613b6c565b90808203611bea575050507fb3e2773606abfd36b5bd91394b3a54d1398336c65005baf7bf7a05efeffaf75b611bcd602095604051918291339588429285613bdd565b0390a360016000805160206147ce83398151915255604051908152f35b632d8562a360e11b835260045260245260449150fd5b506020823d602011611c2c575b81611c1a602093836139c3565b810103126105fe57611b8a9151611b80565b3d9150611c0d565b82546001600160a01b0316803b15611ca45783809160846040518094819363ae494fa160e01b83523060048401528a60248401528b60448401528160648401525af1801561060b57908491611c8b575b5050611b4c565b81611c95916139c3565b611ca0578238611c84565b8280fd5b8380fd5b81611cb2916139c3565b611ca0578238611b44565b90506020813d602011611ce7575b81611cd8602093836139c3565b810103126105fe575138611af3565b3d9150611ccb565b6040513d85823e3d90fd5b6371c4efed60e01b83526004869052602452604482fd5b611d21915061175260ff91613ad4565b8015611d5e5780600019048511611d4f57611a8f611d48670de0b6b3a76400009287613a8b565b9150611a6e565b63035fc53d60e41b8252600482fd5b634e487b7160e01b82526012600452602482fd5b630700fcb360e11b8352600483fd5b63446c8cc960e01b8352600483fd5b639bfa3c1760e01b8152600490fd5b919250506020813d602011611dd0575b81611dbc602093836139c3565b810103126105fe57518591906119f66119eb565b3d9150611daf565b90506020813d602011611e02575b81611df3602093836139c3565b810103126105fe5751386119b0565b3d9150611de6565b6040513d84823e3d90fd5b631d7f2ac360e01b83526004869052602452604482fd5b633b5db2f360e11b8352600483fd5b50908152600c6020526040812054630d54e9e160e01b82526004849052602452604490fd5b632cd84af360e01b8252600482fd5b60405163313ce56760e01b815291939291602081600481865afa859181611eef575b50611ea55763105482c760e21b8552600485fd5b93919293838352600560205260ff806040852054169116908103611ec9575061192d565b90506044928252600560205260ff604083205416631e43476360e11b8352600452602452fd5b611f0991925060203d6020116109c9576109ba81836139c3565b9038611e91565b63a74c1c5f60e01b8152600490fd5b3381526009602052436040822055338152600a6020526001604082205561190b565b503461033b578060031936011261033b5760206040516103e88152f35b503461033b57604036600319011261033b576020906040906001600160a01b03611f8661392e565b16815260148352818120602435825283522054604051908152f35b503461033b57604036600319011261033b576040611fbd613944565b91600435815260008051602061478e833981519152602052209060018060a01b0316600052602052602060ff604060002054166040519015158152f35b503461033b578060031936011261033b57602060405160648152f35b503461033b57604036600319011261033b5761205060209160043581526000805160206146ae8339815191528352604060243591206144b8565b905460405160039290921b1c6001600160a01b03168152f35b503461033b57602036600319011261033b576020906040906001600160a01b0361209161392e565b168152600983522054604051908152f35b503461033b57604036600319011261033b576120bc61392e565b60105460243591906001600160a01b0316330361215a576001600160a01b031690811561214b57604060008051602061476e8339815191529183855260136020528185205490848652601360205280838720558486526015602052828620438752602052828620548587526019602052838720558486526017602052438387205582519182526020820152a280f35b63df407ac560e01b8352600483fd5b6349db3bd360e01b8352600483fd5b503461033b57602036600319011261033b576020906040906001600160a01b0361219161392e565b168152600383522054604051908152f35b503461033b578060031936011261033b5760008051602061470e833981519152815260008051602061478e83398151915260209081526040808320336000908152925290205460ff1615612278576121f8613f4e565b600160ff196000805160206147ae8339815191525416176000805160206147ae833981519152557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586020604051338152a16040514281527f80170b5fcdd2bf1e0660ef4b8851f86685f64d41b1a19de1471947ece8725aac60203392a280f35b63e2517d3f60e01b81523360045260008051602061470e833981519152602452604490fd5b503461033b57602036600319011261033b576122b761392e565b60008051602061480e8339815191525460ff8160401c169081156123a3575b506123945760008051602061480e83398151915280546001600160481b0319166003600160401b0117905581805260008051602061478e83398151915260209081526040808420336000908152925290205460ff161561237c5761233990613c5e565b60ff60401b1960008051602061480e833981519152541660008051602061480e833981519152556000805160206146ee833981519152602060405160038152a180f35b63e2517d3f60e01b8252336004526024829052604482fd5b63f92ee8a960e01b8252600482fd5b60036001600160401b039190911610159050386122d6565b503461033b578060031936011261033b57602060ff6000805160206147ae83398151915254166040519015158152f35b503461033b57602036600319011261033b5761240561392e565b6010546001600160a01b031633036104795761043690613c5e565b503461033b57606036600319011261033b5761243a61392e565b612442613944565b60105490926044359290916001600160a01b0316330361047957612464613f4e565b6011546001600160a01b03169182156126de5760405163babcc53960e01b81526001600160a01b0386166004820181905293602090829060249082905afa908115611e0a57829161269f575b5015612690578215612681576001546001600160a01b03928316921682036125d1576040516370a0823160e01b8152306004820152602081602481865afa908115611e0a57829161259f575b50935b841561259057600019810361258a5750835b841561257b5780851161256357505061252d836020958361404c565b7f0bf519e4b3821615dbdd874fa1a5fbb4bb651b4e6beabedd4ac318e770233b2c604080518581524287820152a3604051908152f35b630555ed4f60e31b8252600485905260245260449150fd5b632e11316f60e11b8252600482fd5b93612511565b63f09872eb60e01b8252600482fd5b90506020813d6020116125c9575b816125ba602093836139c3565b810103126105fe5751386124fc565b3d91506125ad565b8181526002602052604081205460ff161561266f576040516370a0823160e01b8152306004820152602081602481865afa908115611e0a57829161263d575b5082825260076020526040822054808211156126355761262f91613b6c565b936124ff565b50508061262f565b90506020813d602011612667575b81612658602093836139c3565b810103126105fe575138612610565b3d915061264b565b60249163eef7849760e01b8252600452fd5b634e46966960e11b8152600490fd5b63133307bb60e21b8152600490fd5b90506020813d6020116126d6575b816126ba602093836139c3565b810103126126d2575180151581036126d257386124b0565b5080fd5b3d91506126ad565b630e048e7160e41b8152600490fd5b503461033b57602036600319011261033b5761270761392e565b6010546001600160a01b03163303610479576001600160a01b0316801561276c57601180546001600160a01b0319811683179091556001600160a01b03167f1e9c406f2707909cfd9f61e744f73bcab77e5997d063276f67883c5257d51cf08380a380f35b634e46966960e11b8252600482fd5b503461033b578060031936011261033b577f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031630036127d457602060405160008051602061472e8339815191528152f35b63703e46dd60e11b8152600490fd5b503461033b578060031936011261033b576010546040516001600160a01b039091168152602090f35b50604036600319011261033b5761282161392e565b602435906001600160401b038211611ca05736602383011215611ca0578160040135908361284e836139fc565b9361285c60405195866139c3565b83855260208501933660248284010111611ca057806024602093018637850101526001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016308114908115612ade575b50612acf576010546001600160a01b03163303612ac0576001600160a01b038116928315612ab157813b15612aa25760008051602061472e83398151915254846128fa613a68565b7f6ea8b34d59b2818d3f37a08dddaa06f5886b9c20c907b36f03ca6528e106e86f61293060405192604084526040840190613a17565b4260208401526001600160a01b038516929081900390a36040516352d1902d60e01b8152602081600481895afa879181612a6a575b5061297e57634c9c8ce360e01b87526004869052602487fd5b908160008051602061472e83398151915288979303612a585750833b15612a44576001600160a01b031916811760008051602061472e833981519152558491907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b8380a2805115612a295761113e9382915190845af43d15612a21573d91612a05836139fc565b92612a1360405194856139c3565b83523d85602085013e61460c565b60609161460c565b5050505034612a355780f35b63b398979f60e01b8152600490fd5b634c9c8ce360e01b86526004829052602486fd5b632a87526960e21b8752600452602486fd5b9091506020813d602011612a9a575b81612a86602093836139c3565b81010312612a9657519038612965565b8780fd5b3d9150612a79565b636f7c43f160e01b8552600485fd5b63e6c4247b60e01b8552600485fd5b6349db3bd360e01b8452600484fd5b63703e46dd60e11b8452600484fd5b60008051602061472e833981519152546001600160a01b031614159050386128b2565b503461033b57602036600319011261033b576020906040906001600160a01b03612b2961392e565b168152600e83522054604051908152f35b503461033b57606036600319011261033b57612b5461395a565b6024356001600160401b038111611ca057612b73903690600401613993565b916044356001600160401b038111610a5057612b93903690600401613993565b60008051602061480e8339815191529291925460ff8160401c16908115612ef6575b50612ee75760008051602061480e83398151915280546001600160481b0319166002600160401b011790556000805160206147ee833981519152865260008051602061478e83398151915260209081526040808820336000908152925290205460ff1615612ec257612c2561448a565b612c2d61448a565b60016000805160206147ce83398151915255600b549160ff8316612eb357818603612ea457612c5b86613bf9565b92612c6960405194856139c3565b868452601f19612c7888613bf9565b01366020860137875b878110612daf575060019060ff191617600b5515159460ff196008541660ff871617600855865b818110612d0c578760008051602061466e833981519152602089604051908152a160ff60401b1960008051602061480e833981519152541660008051602061480e833981519152556000805160206146ee833981519152602060405160028152a180f35b808860008051602061482e8339815191526040612d34612d2f600196888d613c10565b613c36565b612d3f85898c613c10565b357f8f955fa878b4aae8b1ac37b1ab715307470f2822ceff87e23d33ef1e044814a783612d6c888d613c4a565b5193898060a01b0316968793848252600660205280838320558482526007602052858383205582519182526020820152a28151908d82526020820152a201612ca8565b612dbd612d2f828a8a613c10565b612dc8828689613c10565b6001600160a01b03909116808b52600260205260408b20549091359060ff1615612e90576103e88111612e785750906020602492604051938480926370a0823160e01b82523060048301525afa8015612e6d578a90612e37575b60019250612e308288613c4a565b5201612c81565b509060203d8111612e66575b612e4d81836139c3565b6020826000928101031261033b57509060019151612e22565b503d612e43565b6040513d8c823e3d90fd5b631051834f60e11b8b526004526103e860245260448afd5b6351104c5960e01b8b52600482905260248bfd5b63512509d360e11b8752600487fd5b6324d0d1fd60e01b8752600487fd5b63e2517d3f60e01b8652336004526000805160206147ee833981519152602452604486fd5b63f92ee8a960e01b8652600486fd5b60026001600160401b03919091161015905038612bb5565b503461033b578060031936011261033b576011546040516001600160a01b039091168152602090f35b503461033b578060031936011261033b576010546001600160a01b03163303612fef576000805160206147ae8339815191525460ff811615612fe05760ff19166000805160206147ae833981519152557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa6020604051338152a16040514281527f107553d8191d85b405879cf752997865edd48d94e20bda4dd27223c94b31a7cc60203392a280f35b638dfc202b60e01b8252600482fd5b6349db3bd360e01b8152600490fd5b503461033b57602036600319011261033b576020906040906001600160a01b0361302661392e565b168152601683522054604051908152f35b503461033b57604036600319011261033b57613051613944565b336001600160a01b0382160361306d5761113e9060043561411a565b63334bd91960e11b8252600482fd5b503461033b57602036600319011261033b576020906040906001600160a01b036130a461392e565b168152600c83522054604051908152f35b503461033b57602036600319011261033b576020906040906001600160a01b036130dd61392e565b168152601783522054604051908152f35b503461033b57604036600319011261033b5761113e60043561310e613944565b9061311b61113482613b79565b6140d2565b503461033b5761312f36613969565b91909261313a613f12565b613142613f4e565b3381526009602052604081205443036135be57338152600a602052600360408220541015611f1057338152600a602052604081206131808154613b9a565b90555b6001600160a01b0382168082526002602052604082205490929060ff16613543575b828252600260205260ff604083205416156104665760ff6008541615613534578415610457578315611e6057828252600d602052604082205480861061351d5750828252600f6020526040822054801561350e578086116134f857508461320b91613f78565b670de0b6b3a76400008402848104670de0b6b3a7640000036134e4578282526003602052604082205461323d91613ab4565b90828152600560205260ff604082205416601281106134c4575b50828152600660205261327c612710613274604084205485613a8b565b048093613b6c565b938085106134ac575082815260076020528360408220541061348857828152600760205260408120548481106134795760008051602061482e8339815191526040826132c9888895613b6c565b8486526007602052808387205582519182526020820152a26001546040516318160ddd60e01b815290602090829060049082906001600160a01b03165afa908115611e0a578291613447575b5081546001600160a01b0316803b15611ca057826040518092633a52b90760e11b82528183816133498d3360048401613bc2565b03925af18015611cef57613432575b506001546040516318160ddd60e01b81529190602090839060049082906001600160a01b03165afa908115611cef5783916133fc575b6133989250613b6c565b8581036133e45750507f8caf04742286d017f9ac3924388e188c73e6e5094311c5e59a61a7ef86dda8bf611bcd6020956133d386338761404c565b604051918291339588429285613bdd565b635ab6e2db60e01b8252600486905260245260449150fd5b90506020823d60201161342a575b81613417602093836139c3565b810103126105fe5761339891519061338e565b3d915061340a565b9161344081600493946139c3565b9190613358565b90506020813d602011613471575b81613462602093836139c3565b810103126126d2575138613315565b3d9150613455565b6308aed4ef60e31b8252600482fd5b82815260076020526040812054635960d22160e01b82526004526024849052604490fd5b6371c4efed60e01b8252600485905260245260449150fd5b916134d760ff6117526134dd9495613ad4565b90613ab4565b9038613257565b634e487b7160e01b82526011600452602482fd5b625502a360e91b83526004869052602452604482fd5b636c6ff70d60e11b8352600483fd5b6361767b8560e01b83526004869052602452604482fd5b630df65d9f60e01b8252600482fd5b60405163313ce56760e01b815291939291602081600481865afa85918161359d575b506135795763105482c760e21b8552600485fd5b93919293838352600560205260ff806040852054169116908103611ec957506131a5565b6135b791925060203d6020116109c9576109ba81836139c3565b9038613565565b3381526009602052436040822055338152600a60205260016040822055613183565b503461033b57602036600319011261033b576020610f3c600435613b79565b503461033b57602036600319011261033b576020906040906001600160a01b0361362761392e565b168152600f83522054604051908152f35b503461033b57604036600319011261033b5761365261392e565b60105460243591906001600160a01b0316330361215a576001600160a01b031690811561214b5760406000805160206146ce8339815191529183855260126020528185205490848652601260205280838720558486526014602052828620438752602052828620548587526018602052838720558486526016602052438387205582519182526020820152a280f35b503461033b57602036600319011261033b576020906040906001600160a01b0361370961392e565b168152600683522054604051908152f35b503461033b578060031936011261033b576001546040516001600160a01b039091168152602090f35b503461033b57602036600319011261033b576020906040906001600160a01b0361376b61392e565b168152600d83522054604051908152f35b503461033b57602036600319011261033b5761379661395a565b6010546001600160a01b0316330361047957602060008051602061466e83398151915291151560ff196008541660ff821617600855604051908152a180f35b503461033b57602036600319011261033b5760043563ffffffff60e01b81168091036126d257602090635a05180f60e01b811490811561381b575b506040519015158152f35b637965db0b60e01b811491508115613835575b5082613810565b6301ffc9a760e01b1490508261382e565b503461033b57604036600319011261033b5761386061392e565b6001600160a01b0316808252600260205260408220546024359060ff161561177457670de0b6b3a7640000810290808204670de0b6b3a7640000149015171561391a57916138bc60409383835260036020528483205490613ab4565b91808252600560205260ff8483205416601281106138f1575b5061172a84836127109361173295526006602052205484613a8b565b846117329361390f61271094966134d760ff61175261172a97613ad4565b9593509350506138d5565b634e487b7160e01b83526011600452602483fd5b600435906001600160a01b03821682036105fe57565b602435906001600160a01b03821682036105fe57565b6004359081151582036105fe57565b60609060031901126105fe576004356001600160a01b03811681036105fe57906024359060443590565b9181601f840112156105fe578235916001600160401b0383116105fe576020808501948460051b0101116105fe57565b601f909101601f19168101906001600160401b038211908210176139e657604052565b634e487b7160e01b600052604160045260246000fd5b6001600160401b0381116139e657601f01601f191660200190565b919082519283825260005b848110613a43575050826000602080949584010152601f8019910116010190565b80602080928401015182828601015201613a22565b6084359060ff821682036105fe57565b60405190613a776040836139c3565b6005825264322e332e3360d81b6020830152565b81810292918115918404141715613a9e57565b634e487b7160e01b600052601160045260246000fd5b8115613abe570490565b634e487b7160e01b600052601260045260246000fd5b60ff166012039060ff8211613a9e57565b8015613b665760009060208110600116604e821060011617613b5e57600a916001915b60018111613b35575082600019048211613b2157500290565b634e487b7160e01b81526011600452602490fd5b92806000190481116134e45760018416613b55575b80029260011c613b08565b80920291613b4a565b9050600a0a90565b50600190565b91908203918211613a9e57565b60005260008051602061478e83398151915260205260016040600020015490565b6000198114613a9e5760010190565b908160209103126105fe575160ff811681036105fe5790565b6001600160a01b039091168152602081019190915260400190565b9094939260609260808301968352602083015260408201520152565b6001600160401b0381116139e65760051b60200190565b9190811015613c205760051b0190565b634e487b7160e01b600052603260045260246000fd5b356001600160a01b03811681036105fe5790565b8051821015613c205760209160051b010190565b6001600160a01b03168015613c9f57601080546001600160a01b0319811683179091556001600160a01b031660008051602061474e833981519152600080a3565b63e6c4247b60e01b60005260046000fd5b91908201809211613a9e57565b94919360e0969360ff929a99989561010088019b885260208801526040870152166060850152608084015260a083015260c08201520152565b6001600160a01b03811660008181526002602052604090205490919060ff16158015613de8575b8015613de0575b613dce5781600052600f6020526040600020548015908115613dd6575b50613dce57613d66926040918251948592839262f7fce960e01b845260048401613bc2565b0381305afa918215613dc257600092613d8e575b506000526007602052604060002054101590565b9091506040813d604011613dba575b81613daa604093836139c3565b810103126105fe57519038613d7a565b3d9150613d9d565b6040513d6000823e3d90fd5b505050600090565b9050831138613d41565b508215613d24565b5060ff6008541615613d1d565b6001546001600160a01b0391821691168103613e6a576020602491604051928380926370a0823160e01b82523060048301525afa908115613dc257600091613e3b575090565b90506020813d602011613e62575b81613e56602093836139c3565b810103126105fe575190565b3d9150613e49565b80600052600260205260ff60406000205416613e865750600090565b6040516370a0823160e01b815230600482015290602082602481845afa918215613dc257600092613ede575b506000526007602052604060002054808211600014613ed757613ed491613b6c565b90565b5050600090565b90916020823d602011613f0a575b81613ef9602093836139c3565b8101031261033b5750519038613eb2565b3d9150613eec565b60026000805160206147ce8339815191525414613f3d5760026000805160206147ce83398151915255565b633ee5aeb560e01b60005260046000fd5b60ff6000805160206147ae8339815191525416613f6757565b63d93c066560e01b60005260046000fd5b6001600160a01b0316600081815260136020526040902054801561404757816000526015602052604060002043600052602052613fbb6040600020549384613cb0565b92831061403657808260005260176020524360406000205414614018575b8311613ffc57506000526015602052604060002043600052602052604060002055565b925063029359d560e41b60005260045260245260445260646000fd5b5081600052601960205261403160406000205482613cb0565b613fd9565b63446c8cc960e01b60005260046000fd5b505050565b614081614086939261407360405194859263a9059cbb60e01b602085015260248401613bc2565b03601f1981018452836139c3565b6142ed565b565b600081815260008051602061478e8339815191526020908152604080832033845290915290205460ff16156140ba5750565b63e2517d3f60e01b6000523360045260245260446000fd5b6140dc8282614348565b91826140e757505090565b60009182526000805160206146ae8339815191526020526040909120614116916001600160a01b0316906144d0565b5090565b61412482826143ea565b918261412f57505090565b60009182526000805160206146ae8339815191526020526040909120614116916001600160a01b031690614539565b6001600160a01b03166000818152601260205260409020548015614047578160005260146020526040600020436000526020526141a16040600020549384613cb0565b928310614036578082600052601660205243604060002054146141fe575b83116141e257506000526014602052604060002043600052602052604060002055565b92506319a4e2a760e01b60005260045260245260445260646000fd5b5081600052601860205261421760406000205482613cb0565b6141bf565b6040516323b872dd60e01b60208201526001600160a01b039283166024820152929091166044830152606480830193909352918152614086916140816084836139c3565b60405163313ce56760e01b81529190602090839060049082906001600160a01b03165afa600092816142cc575b506142a357631eecbb6560e01b60005260046000fd5b60ff91821691168082036142b5575050565b631e43476360e11b60005260045260245260446000fd5b6142e691935060203d6020116109c9576109ba81836139c3565b913861428d565b906000602091828151910182855af115613dc2576000513d61433f57506001600160a01b0381163b155b61431e5750565b635274afe760e01b60009081526001600160a01b0391909116600452602490fd5b60011415614317565b600081815260008051602061478e833981519152602090815260408083206001600160a01b038616845290915290205460ff16613ed757600081815260008051602061478e833981519152602090815260408083206001600160a01b0395909516808452949091528120805460ff19166001179055339291907f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d9080a4600190565b600081815260008051602061478e833981519152602090815260408083206001600160a01b038616845290915290205460ff1615613ed757600081815260008051602061478e833981519152602090815260408083206001600160a01b0395909516808452949091528120805460ff19169055339291907ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9080a4600190565b60ff60008051602061480e8339815191525460401c16156144a757565b631afcd79f60e31b60005260046000fd5b8054821015613c205760005260206000200190600090565b6001810190826000528160205260406000205415600014613dce578054600160401b8110156139e65761452461450d8260018794018555846144b8565b819391549060031b91821b91600019901b19161790565b90555491600052602052604060002055600190565b9060018201918160005282602052604060002054801515600014614603576000198101818111613a9e578254600019810191908211613a9e578181036145cc575b505050805480156145b657600019019061459482826144b8565b8154906000199060031b1b191690555560005260205260006040812055600190565b634e487b7160e01b600052603160045260246000fd5b6145ec6145dc61450d93866144b8565b90549060031b1c928392866144b8565b90556000528360205260406000205538808061457a565b50505050600090565b90614632575080511561462157602081519101fd5b63d6bda27560e01b60005260046000fd5b81511580614664575b614643575090565b639996b31560e01b60009081526001600160a01b0391909116600452602490fd5b50803b1561463b56fe2c0a5f5ab0ba371221bb3612c2d2f90d36566279309f526000c5b354efd1b0658c67aaac7f77de07240e5a9b36dfdccb2a89c438635abbb27a73142d2aa0f629c1f6fe24621ce81ec5827caf0253cadb74709b061630e6b55e8237170593200048b07fab687f450848f1df8a96db08fef7840f53415f18fdc2ec8e9f810f0930c7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d275027301df982f5215b4963a854cf9c73219df80cb6acd8f098189c9480c7bbc360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc17dc5b1290f7495d7f8cc68476e6941aaf510598fa925d0d2720edc8805a846c4460507c21097c15f6883572ebd157a9ee4b1d989a312314e93afd9d2ecd494002dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b626800cd5ed15c6e187e77e9aee88184c21f4f2182ab5827cb3b7e07fbedcd63f033009b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f00a49807205ce4d355092ef5a8a18f56e8913cf4a201fbe287825b095693c21775f0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a006d129bd71f2401cbe77f49f546d7d5f58992faecfca6e51ba06b50b261e83331a164736f6c6343000822000a";
68643
69028
  var isSuperArgs = (xs) => xs.length > 1;
68644
- var SimplePSMV2__factory = class extends import_ethers27.ContractFactory {
69029
+ var SimplePSMV2__factory = class extends import_ethers28.ContractFactory {
68645
69030
  constructor(...args) {
68646
69031
  if (isSuperArgs(args)) {
68647
69032
  super(...args);
@@ -68661,10 +69046,10 @@ var SimplePSMV2__factory = class extends import_ethers27.ContractFactory {
68661
69046
  static bytecode = _bytecode;
68662
69047
  static abi = _abi;
68663
69048
  static createInterface() {
68664
- return new import_ethers27.Interface(_abi);
69049
+ return new import_ethers28.Interface(_abi);
68665
69050
  }
68666
69051
  static connect(address, runner) {
68667
- return new import_ethers27.Contract(address, _abi, runner);
69052
+ return new import_ethers28.Contract(address, _abi, runner);
68668
69053
  }
68669
69054
  };
68670
69055
  var _abi2 = [
@@ -70359,7 +70744,7 @@ var _abi2 = [
70359
70744
  ];
70360
70745
  var _bytecode2 = "0x60a080604052346100ea57306080527ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a005460ff8160401c166100d9576002600160401b03196001600160401b03821601610073575b60405161304c90816100f0823960805181818161114401526113290152f35b6001600160401b0319166001600160401b039081177ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a005581527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d290602090a13880610054565b63f92ee8a960e01b60005260046000fd5b600080fdfe608080604052600436101561001357600080fd5b60003560e01c90816301ffc9a714611ff7575080630d33f3c214611fd35780630f3f4a9414611f885780631459457a14611be257806318c38b8914611ad15780631d44454114611a005780632106764c146119d9578063248a9ca3146119b35780632ec22d4c146118f25780632f0647ce146118775780632f2ff15d14611846578063324207441461177257806336568abe1461172c578063392f1087146116f65780633f4ba83a146115fe5780633f5aadc91461158f5780634f1ef286146112ad57806352340363146111c45780635273b6f61461119b57806352d1902d14611131578063554c4f4b146110a1578063561b7f8a14610f755780635bc26aea14610ee85780635c975abb14610eb85780636289d18c14610e375780636711cc0b14610e1b5780636e852a7814610d1a5780637e35bf6e14610ce65780638343f67414610cb95780638456cb5914610bc35780638f33527f14610b895780639010d07c14610b3557806391d1485414610adb5780639b9d30c114610ab2578063a19af3f614610a01578063a217fddf146109e5578063a3246ad314610923578063a878086414610907578063ac3c0e30146107fa578063ad3cb1cc146107b3578063b3fad6381461070e578063c34e9c26146106f2578063c86deb31146106d6578063ca15c8731461069d578063d547741f14610665578063dd71d99a14610623578063e0922fa114610576578063efa9b4ae14610507578063f2f4eb26146104de578063f68e9553146104b5578063f94f67ab146103de578063fd437d391461029f5763ffa1ad741461026657600080fd5b3461029a57600036600319011261029a576102966102826121ed565b6040519182916020835260208301906121c8565b0390f35b600080fd5b3461029a57606036600319011261029a576102b861207a565b6102c0612064565b906102c961218f565b906102d2612795565b6001600160a01b0316338190036103ce5780600052600160205260406000209283549360ff8560e01c1660038110156103b8576001036103a75781600160209261033e877fc5d5c5bbf10444998e0ea6d4725e79027b574e1c14ec929279e8a9a95c6c6e919688612c43565b818060a01b038316828060a01b031982541617815561035d878261239f565b0180546001600160401b031916426001600160401b03908116919091179091556001600160a01b0391821660008181526002855260409081902087905551969091168652951693a4005b632437e77160e11b60005260046000fd5b634e487b7160e01b600052602160045260246000fd5b62fca64560e31b60005260046000fd5b3461029a57604036600319011261029a576004356103fa6120c9565b90610403612795565b63ffffffff600554169163ffffffff8116928084109081156104ac575b5061049b5760207f6b7727cc9c3df4a29acf0afe01594c1b7e845d20f40f4a14e4c292164a9ed8e191610452846127e0565b9161046a600863ffffffff845460a01c1617836122e3565b81546001600160e01b031660e09190911b6001600160e01b0319161790556040519485526001600160a01b031693a3005b634346c13160e01b60005260046000fd5b90501584610420565b3461029a57600036600319011261029a576020604051600080516020612fe08339815191528152f35b3461029a57600036600319011261029a576003546040516001600160a01b039091168152602090f35b3461029a57602036600319011261029a57600435610523612795565b61054561052f826127e0565b9190600163ffffffff825460a01c1617906122e3565b6001600160a01b0316907f812690e0a9dff5bf3add998111b8af5c8299608d859025bfe35662060ab4267d600080a3005b3461029a57602036600319011261029a576004356001600160401b0381169081810361029a576000546001600160a01b038116330361061257600160a01b600160e01b0319811660a092831b600160a01b600160e01b031617600055604080519190921c6001600160401b0316815260208101929092527f9c195448332abd01f716db873b329752ea02f19d33f7e311fb0daf082c4edd0391a1005b6349db3bd360e01b60005260046000fd5b3461029a57602036600319011261029a576001600160a01b0361064461207a565b166000526002602052602060018060a01b0360406000205416604051908152f35b3461029a57604036600319011261029a5761069b600435610684612064565b90610696610691826122c2565b6126bf565b612751565b005b3461029a57602036600319011261029a57600435600052600080516020612ee08339815191526020526020604060002054604051908152f35b3461029a57600036600319011261029a57602060405160088152f35b3461029a57600036600319011261029a57602060405160028152f35b3461029a57602036600319011261029a576000606060405161072f81612136565b828152826020820152826040820152015260043560005260046020526080604060002063ffffffff6040519161076483612136565b548160018060a01b038216938481528160208201818560a01c16815260606040840193838760c01c168552019460e01c8552604051968752511660208601525116604084015251166060820152f35b3461029a57600036600319011261029a5761029660408051906107d68183612151565b60058252640352e302e360dc1b6020830152519182916020835260208301906121c8565b3461029a57602036600319011261029a5761081361207a565b6000608060405161082381612105565b828152826020820152826040820152826060820152015260018060a01b03166000526001602052604060002060405161085b81612105565b81546001600160a01b038116825260a081901c6001600160401b03166020830190815292604083019160e01c60ff169060038210156103b857908252600101546001600160401b0380821660608501908152604092831c821660808601908152925194516001600160a01b03168552945116602084015290519260038410156103b857604083019390935291516001600160401b0390811660608301529151909116608082015260a090f35b3461029a57600036600319011261029a57602060405160018152f35b3461029a57602036600319011261029a57600435600052600080516020612ee083398151915260205260406000206040518060208354918281520190819360005260206000209060005b8181106109cf5750505081610983910382612151565b6040519182916020830190602084525180915260408301919060005b8181106109ad575050500390f35b82516001600160a01b031684528594506020938401939092019160010161099f565b825484526020909301926001928301920161096d565b3461029a57600036600319011261029a57602060405160008152f35b3461029a57604036600319011261029a57600435610a1d6120c9565b90610a26612795565b63ffffffff600554169163ffffffff811692808410908115610aa9575b5061049b5760207f1da95b87b4c773f68c1447ffc5644e41a8a8887d55065beb64852014cf7140be91610a96610a78856127e0565b9290610a91600463ffffffff835460a01c1617826122e3565b612210565b6040519485526001600160a01b031693a3005b90501584610a43565b3461029a57600036600319011261029a576020604051600080516020612f208339815191528152f35b3461029a57604036600319011261029a57610af4612064565b600435600052600080516020612fc083398151915260205260406000209060018060a01b0316600052602052602060ff604060002054166040519015158152f35b3461029a57604036600319011261029a57600435600052600080516020612ee08339815191526020526020610b706024356040600020612d0c565b905460405160039290921b1c6001600160a01b03168152f35b3461029a57602036600319011261029a576001600160a01b03610baa61207a565b1660005260026020526020604060002054604051908152f35b3461029a57600036600319011261029a573360009081527f0ac8cc3d209806126662940717264973110c39045b305f6ba49613325a615e09602052604090205460ff1615610c9257610c13612795565b600160ff19600080516020613000833981519152541617600080516020613000833981519152557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586020604051338152a16040514281527f80170b5fcdd2bf1e0660ef4b8851f86685f64d41b1a19de1471947ece8725aac60203392a2005b63e2517d3f60e01b60005233600452600080516020612f2083398151915260245260446000fd5b3461029a57600036600319011261029a5760005460405160a09190911c6001600160401b03168152602090f35b3461029a57604036600319011261029a57610d0a610d02612064565b60043561236c565b906102966040519283928361209a565b3461029a57604036600319011261029a57610d3361207a565b336000908152600080516020612f60833981519152602052604090205460ff161580610e08575b6103ce576001600160a01b03166000818152600160205260409020805460e01c60ff1660038110156103b8576001036103a757805460ff60e01b198116600160e11b1782556001919091018054600160401b600160801b03191642604090811b600160401b600160801b0316919091179091555160243581526001600160a01b0390911691907fc0499cc07ed9d734deec6857802d3f0fa8d5afaf79a7008beb8ba7bef62a271b90602090a3005b50336001600160a01b0382161415610d5a565b3461029a57600036600319011261029a57602060405160048152f35b3461029a57602036600319011261029a57610e506120b6565b6000546001600160a01b031633036106125763ffffffff8116908115610ea757600080516020612fa083398151915291610ea263ffffffff926005549284198416176005556040519384931683612233565b0390a1005b6338f3377360e21b60005260046000fd5b3461029a57600036600319011261029a57602060ff60008051602061300083398151915254166040519015158152f35b3461029a57602036600319011261029a57610f0161207a565b6000546001600160a01b0381169033829003610612576001600160a01b038316928315610f64573b15610f53576001600160a01b03191682176000908155600080516020612f808339815191529080a3005b636f7c43f160e01b60005260046000fd5b63e6c4247b60e01b60005260046000fd5b3461029a57606036600319011261029a57610f8e61207a565b610f96612064565b610f9e61218f565b91610fa7612795565b6001600160a01b031690338290036103ce57816000526001602052604060002060ff815460e01c1660038110156103b857600114611090578160209161100f867ff223dc085722c94c84dcf67427e225799be616382a2a484d378f8921c69a20339587612c43565b80546001600160a01b0319166001600160a01b038316178155611032868261239f565b6001810180546001600160801b031916426001600160401b0390811691909117909155815460ff60e01b1916600160e01b179091556001600160a01b03919091166000818152600284526040908190208690555195909116855293a3005b639d2c8fdf60e01b60005260046000fd5b3461029a57602036600319011261029a576001600160a01b036110c261207a565b166000526001602052604060002060ff60008051602061300083398151915254161580611115575b602091816110fe575b506040519015158152f35b5460a01c6001600160401b031642109050826110f3565b5060ff815460e01c169060038210156103b857906001146110ea565b3461029a57600036600319011261029a577f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316300361118a576020604051600080516020612f408339815191528152f35b63703e46dd60e11b60005260046000fd5b3461029a57600036600319011261029a576000546040516001600160a01b039091168152602090f35b3461029a57602036600319011261029a57600435604060008281526004602052209081549160018060a01b03831692831590811561129e575b5061128d57336000908152600080516020612f60833981519152602052604090205460ff161580611283575b611272578061124563fffffffe61124b935460a01c16826122e3565b8261269b565b7fa5ffbdba01b15df97334e34ad816b9986b6057a5ddc97aba93b7e8ccd21759ed600080a3005b630a606ec360e11b60005260046000fd5b5082331415611229565b6360eb6c2360e01b60005260046000fd5b6001915060a01c1615846111fd565b604036600319011261029a576112c161207a565b602435906001600160401b03821161029a573660238301121561029a578160040135906112ed82612174565b916112fb6040519384612151565b8083526020830193366024838301011161029a57816000926024602093018737840101526001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001630811490811561156c575b5061118a576000546001600160a01b03163303610612576001600160a01b038116928315610f6457813b1561155b5730841461154c57600080516020612f4083398151915254846113a36121ed565b7f6ea8b34d59b2818d3f37a08dddaa06f5886b9c20c907b36f03ca6528e106e86f6113d9604051926040845260408401906121c8565b4260208401526001600160a01b038516929081900390a36040516352d1902d60e01b8152602081600481895afa60009181611518575b506114295785634c9c8ce360e01b60005260045260246000fd5b9081600080516020612f408339815191528793036115045750833b156114ef576001600160a01b0319168117600080516020612f40833981519152557fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b600080a28251156114d4576000809161069b945190845af43d156114cc573d916114af83612174565b926114bd6040519485612151565b83523d6000602085013e612e7e565b606091612e7e565b505050346114de57005b63b398979f60e01b60005260046000fd5b50634c9c8ce360e01b60005260045260246000fd5b632a87526960e21b60005260045260246000fd5b9091506020813d602011611544575b8161153460209383612151565b8101031261029a5751908761140f565b3d9150611527565b614e8d60eb1b60005260046000fd5b632e07c4bd60e11b60005260046000fd5b600080516020612f40833981519152546001600160a01b03161415905084611354565b3461029a57602036600319011261029a576004356115ab612795565b6115cd6115b7826127e0565b9190600263ffffffff825460a01c1617906122e3565b6001600160a01b0316907fc2713e691344add4705edc62a0ee5aede95ba66ad68f97316efef9cb50644edd600080a3005b3461029a57600036600319011261029a57336000908152600080516020612f60833981519152602052604090205460ff1615806116e1575b6116d0576000805160206130008339815191525460ff8116156116bf5760ff1916600080516020613000833981519152557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa6020604051338152a16040514281527f107553d8191d85b405879cf752997865edd48d94e20bda4dd27223c94b31a7cc60203392a2005b638dfc202b60e01b60005260046000fd5b63659a07b360e11b60005260046000fd5b506000546001600160a01b0316331415611636565b3461029a57604036600319011261029a5761029661171d611715612064565b600435612306565b604093919351938493846120dc565b3461029a57604036600319011261029a57611745612064565b336001600160a01b038216036117615761069b90600435612751565b63334bd91960e11b60005260046000fd5b3461029a57602036600319011261029a57600435604060008281526004602052209081549160018060a01b038316928315908115611837575b5061128d57336000908152600080516020612f60833981519152602052604090205460ff16158061182d575b61127257806117f363fffffff7611806935460a01c16826122e3565b80546001600160e01b031681558261269b565b7f054490ec6650e07db9b97a06ea31d44cebd44b390c9975a380055e1b4d3cac21600080a3005b50823314156117d7565b6008915060a01c1615846117ab565b3461029a57604036600319011261029a5761069b600435611865612064565b90611872610691826122c2565b612709565b3461029a57602036600319011261029a576004356118c161189782612629565b91906118ad63fffffffb825460a01c16826122e3565b805463ffffffff60c01b191681558361269b565b6001600160a01b0316907f09cb4ec44cdef8489412844b9682f87f7900758fa2bd7e039113e9125e538e0f600080a3005b3461029a57602036600319011261029a57600435604060008281526004602052209081549160018060a01b0383169283159081156119a4575b5061128d57336000908152600080516020612f60833981519152602052604090205460ff16158061199a575b611272578061124563fffffffd611973935460a01c16826122e3565b7fb390ab029eab314bd18190ebe73d7e5c1c336beaa5c83ac22578378dc9ccc405600080a3005b5082331415611957565b6002915060a01c16158461192b565b3461029a57602036600319011261029a5760206119d16004356122c2565b604051908152f35b3461029a57604036600319011261029a5761029661171d6119f8612064565b60043561224a565b3461029a57604036600319011261029a57600435611a1c6120c9565b63ffffffff600554169063ffffffff811691808310908115611ac8575b5061049b57611a4783612629565b909263ffffffff845460c01c16809260018060a01b03163314159182611abd575b5050611aac57611a98827e8a218591d4362499c38c38eb1c12e7a7cc97a9068818d1fe6046a42ba4a5ba94612210565b611aa760405192839283612233565b0390a2005b634e80a40760e11b60005260046000fd5b111590508186611a68565b90501584611a39565b3461029a57602036600319011261029a57611aea6120b6565b6000805160206130208339815191525460ff8160401c16908115611bca575b50611bb957600080516020613020833981519152805460026001600160401b0319821681179092556000546001600160481b031990911690911791906001600160a01b031633036106125763ffffffff168015610ea757604081600080516020612fa08339815191529263ffffffff196005541617600555815190600082526020820152a160008051602061302083398151915255600080516020612f00833981519152602060405160028152a1005b63f92ee8a960e01b60005260046000fd5b60026001600160401b03919091161015905082611b09565b3461029a5760a036600319011261029a57611bfb61207a565b611c03612064565b906044356001600160a01b03811680820361029a576064356001600160a01b0381169182820361029a576084356001600160a01b038116949085900361029a5760008051602061302083398151915254604081901c60ff161596906001600160401b031680159081611f80575b6001149081611f76575b159081611f6d575b50611bb95760008051602061302083398151915280546001600160401b031916600117905586611f48575b611cb5612acc565b611cbd612acc565b611cc5612acc565b611ccd612acc565b6001600160a01b038116908115610f64578315610f64578515610f64576001600160a01b038916988915610f64573b15610f5357858414611f375762aa36a746148015611f2c575b8015611f21575b1580611f0f575b610f5357611d32906000612afa565b9081611ec8575b5015611e0d57611d5790600080516020612fe0833981519152612afa565b9081611e73575b5015611e0d57611d7c90600080516020612f20833981519152612afa565b9081611e1e575b5015611e0d57600080546001600160a01b031916841781556040519390600080516020612f808339815191528180a38015610f6457803b15610f5357600380546001600160a01b031916919091179055611dd957005b600080516020613020833981519152805460ff60401b1916905560018152600080516020612f0083398151915290602090a1005b63cf5a8e3360e01b60005260046000fd5b600080516020612f20833981519152600052600080516020612ee0833981519152602052611e6c907ffff5b43478fa6840382eb63777e0da6941d320b940e3f70f0ea4780feff95827612d3a565b5084611d83565b600080516020612fe0833981519152600052600080516020612ee0833981519152602052611ec1907f32d31393d541a265984ec379cddd8b1fcbe5f2b0eb8ad81dddfead454f135eaa612d3a565b5086611d5e565b60008052600080516020612ee0833981519152602052611f08907f615f0f9e84155bea8cc509fe18befeb1baf65611e38a6ba60964480fb29dfd44612d3a565b5088611d39565b50823b1580611d235750843b15611d23565b50617a694614611d1c565b506105394614611d15565b638135316560e01b60005260046000fd5b600080516020613020833981519152805460ff60401b1916600160401b179055611cad565b90501589611c82565b303b159150611c7a565b889150611c70565b3461029a57604036600319011261029a57610296611fbc611fa7612064565b600435600052600460205260406000206123c8565b611fc581612090565b60405191818392158361209a565b3461029a57600036600319011261029a57602063ffffffff60055416604051908152f35b3461029a57602036600319011261029a576004359063ffffffff60e01b821680920361029a57602091635a05180f60e01b8114908115612039575b5015158152f35b637965db0b60e01b811491508115612053575b5083612032565b6301ffc9a760e01b1490508361204c565b602435906001600160a01b038216820361029a57565b600435906001600160a01b038216820361029a57565b600811156103b857565b9015158152604081019291906020906120b283612090565b0152565b6004359063ffffffff8216820361029a57565b6024359063ffffffff8216820361029a57565b91604091949363ffffffff916060850196151585526120fa81612090565b602085015216910152565b60a081019081106001600160401b0382111761212057604052565b634e487b7160e01b600052604160045260246000fd5b608081019081106001600160401b0382111761212057604052565b601f909101601f19168101906001600160401b0382119082101761212057604052565b6001600160401b03811161212057601f01601f191660200190565b604435906001600160401b038216820361029a57565b60005b8381106121b85750506000910152565b81810151838201526020016121a8565b906020916121e1815180928185528580860191016121a5565b601f01601f1916010190565b604051906121fc604083612151565b60058252640322e312e360dc1b6020830152565b805463ffffffff60c01b191660c09290921b63ffffffff60c01b16919091179055565b63ffffffff91821681529116602082015260400190565b600052600460205261226160406000209182612485565b61226a81612090565b806122b857505460e01c63ffffffff60055416811580156122b0575b6122a35780821061229c57505b60019160009190565b9050612293565b5050600090600390600090565b508015612286565b6000929091508290565b600052600080516020612fc083398151915260205260016040600020015490565b805463ffffffff60a01b191660a09290921b63ffffffff60a01b16919091179055565b919091600052600460205261232060406000209283612511565b9161232a83612090565b826123625763ffffffff9192505460c01c1663ffffffff60055416811580156122b0576122a35780821061229c575060019160009190565b5060009190600090565b90612383916000526004602052604060002061259d565b61238c81612090565b8061239a5750600190600090565b600091565b8054600160a01b600160e01b03191660a09290921b600160a01b600160e01b0316919091179055565b60ff600080516020613000833981519152541661247e57546001600160a01b0381169081156124765760a01c6002161561246f5760005260016020526040600020549060ff8260e01c1660038110156103b857801561246757600214612460574260a083901c6001600160401b03161115612459576001600160a01b0390811691160361245457600090565b600790565b5050600690565b5050600590565b505050600490565b5050600390565b505050600290565b5050600190565b60ff600080516020613000833981519152541661247e57546001600160a01b0381169081156124765760a01c6008161561246f5760005260016020526040600020549060ff8260e01c1660038110156103b857801561246757600214612460574260a083901c6001600160401b03161115612459576001600160a01b0390811691160361245457600090565b60ff600080516020613000833981519152541661247e57546001600160a01b0381169081156124765760a01c6004161561246f5760005260016020526040600020549060ff8260e01c1660038110156103b857801561246757600214612460574260a083901c6001600160401b03161115612459576001600160a01b0390811691160361245457600090565b60ff600080516020613000833981519152541661247e57546001600160a01b0381169081156124765760a01c6001161561246f5760005260016020526040600020549060ff8260e01c1660038110156103b857801561246757600214612460574260a083901c6001600160401b03161115612459576001600160a01b0390811691160361245457600090565b6000908152600460205260409020805490916001600160a01b03821691821590811561268c575b5061128d57336000908152600080516020612f60833981519152602052604090205460ff161580612682575b61127257565b508133141561267c565b6004915060a01c161538612650565b905460a01c63ffffffff16156126ae5750565b600052600460205260006040812055565b6000818152600080516020612fc08339815191526020908152604080832033845290915290205460ff16156126f15750565b63e2517d3f60e01b6000523360045260245260446000fd5b6127138282612afa565b918261271e57505090565b6000918252600080516020612ee0833981519152602052604090912061274d916001600160a01b031690612d3a565b5090565b61275b8282612ba3565b918261276657505090565b6000918252600080516020612ee0833981519152602052604090912061274d916001600160a01b031690612dab565b60ff60008051602061300083398151915254166127ae57565b63d93c066560e01b60005260046000fd5b519064ffffffffff8216820361029a57565b519061ffff8216820361029a57565b8015612abb57600354604051638d34875560e01b8152600481018390529190600090839060249082906001600160a01b03165afa918215612aaf57600092612904575b5060808201516001600160a01b0316913383900361127257610120015161284981612090565b61285281612090565b600381149081156128ef575b81156128db575b506128ca5781600052600160205260ff60406000205460e01c1660038110156103b8576001036128b957600090815260046020526040902080546001600160a01b0319166001600160a01b03831617815591565b632e68d1d360e21b60005260046000fd5b63e9f6db8560e01b60005260046000fd5b600791506128e881612090565b1438612865565b90506128fa81612090565b600581149061285e565b90913d8082843e6129158184612151565b820191602081840312612a8f578051906001600160401b038211612a975701906101a082840312612a8c57604051926101a084016001600160401b03811185821017612a9b5760409081528351855260208085015190860152838101519085015260608301516001600160401b038111612a9757830181601f82011215612a97578051906129a282612174565b926129b06040519485612151565b82845260208383010111612a9357906129cf91602080850191016121a5565b606084015260808201516001600160a01b0381168103612a8f5760808401526129fa60a083016127bf565b60a0840152612a0b60c083016127bf565b60c0840152612a1c60e083016127d1565b60e0840152612a2e61010083016127bf565b610100840152610120820151906008821015612a8c5750612a7f9161018091610120850152612a6061014082016127bf565b610140850152612a7361016082016127d1565b610160850152016127bf565b6101808201529038612823565b80fd5b5080fd5b8380fd5b8280fd5b634e487b7160e01b83526041600452602483fd5b6040513d6000823e3d90fd5b637bb0b62160e01b60005260046000fd5b60ff6000805160206130208339815191525460401c1615612ae957565b631afcd79f60e31b60005260046000fd5b6000818152600080516020612fc0833981519152602090815260408083206001600160a01b038616845290915290205460ff16612b9c576000818152600080516020612fc0833981519152602090815260408083206001600160a01b0395909516808452949091528120805460ff19166001179055339291907f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d9080a4600190565b5050600090565b6000818152600080516020612fc0833981519152602090815260408083206001600160a01b038616845290915290205460ff1615612b9c576000818152600080516020612fc0833981519152602090815260408083206001600160a01b0395909516808452949091528120805460ff19169055339291907ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9080a4600190565b158015612cfb575b610f64576001600160a01b0316600090815260026020526040902054612cea576001600160401b031642811115612cd95760005460a01c6001600160401b03168015159182612cae575b5050612c9d57565b63e774e7b560e01b60005260046000fd5b909150428103908111612cc357113880612c95565b634e487b7160e01b600052601160045260246000fd5b63efa7aefd60e01b60005260046000fd5b633b53f64f60e21b60005260046000fd5b506001600160a01b03811615612c4b565b8054821015612d245760005260206000200190600090565b634e487b7160e01b600052603260045260246000fd5b6001810190826000528160205260406000205415600014612da3578054600160401b81101561212057612d8e612d77826001879401855584612d0c565b819391549060031b91821b91600019901b19161790565b90555491600052602052604060002055600190565b505050600090565b9060018201918160005282602052604060002054801515600014612e75576000198101818111612cc3578254600019810191908211612cc357818103612e3e575b50505080548015612e28576000190190612e068282612d0c565b8154906000199060031b1b191690555560005260205260006040812055600190565b634e487b7160e01b600052603160045260246000fd5b612e5e612e4e612d779386612d0c565b90549060031b1c92839286612d0c565b905560005283602052604060002055388080612dec565b50505050600090565b90612ea45750805115612e9357602081519101fd5b63d6bda27560e01b60005260046000fd5b81511580612ed6575b612eb5575090565b639996b31560e01b60009081526001600160a01b0391909116600452602490fd5b50803b15612ead56fec1f6fe24621ce81ec5827caf0253cadb74709b061630e6b55e82371705932000c7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d275027301df982f5215b4963a854cf9c73219df80cb6acd8f098189c9480c7bbc360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc07966f2ab141347034724e9b2a472c2f77f5cd745aeba27cacba797b8fcb708617dc5b1290f7495d7f8cc68476e6941aaf510598fa925d0d2720edc8805a846cd37bc77615afefc793aa17d75d4249a9b517ba91b0e54a49c9c4a44b3d7e228302dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b626800edcc084d3dcd65a1f7f23c65c46722faca6953d28e43150a467cf43e5c309238cd5ed15c6e187e77e9aee88184c21f4f2182ab5827cb3b7e07fbedcd63f03300f0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00a164736f6c6343000822000a";
70361
70746
  var isSuperArgs2 = (xs) => xs.length > 1;
70362
- var AgentDelegationRegistry__factory = class extends import_ethers28.ContractFactory {
70747
+ var AgentDelegationRegistry__factory = class extends import_ethers29.ContractFactory {
70363
70748
  constructor(...args) {
70364
70749
  if (isSuperArgs2(args)) {
70365
70750
  super(...args);
@@ -70379,10 +70764,10 @@ var AgentDelegationRegistry__factory = class extends import_ethers28.ContractFac
70379
70764
  static bytecode = _bytecode2;
70380
70765
  static abi = _abi2;
70381
70766
  static createInterface() {
70382
- return new import_ethers28.Interface(_abi2);
70767
+ return new import_ethers29.Interface(_abi2);
70383
70768
  }
70384
70769
  static connect(address, runner) {
70385
- return new import_ethers28.Contract(
70770
+ return new import_ethers29.Contract(
70386
70771
  address,
70387
70772
  _abi2,
70388
70773
  runner
@@ -70396,7 +70781,7 @@ var POSITION_DELEGATE_REGISTRY_ABI = [
70396
70781
  "event PositionDelegateUpdated(bytes32 indexed positionId, address indexed oldDelegate, address indexed newDelegate)"
70397
70782
  ];
70398
70783
  async function setPositionDelegate(positionId, delegate, signer, registryAddress) {
70399
- const registry = new import_ethers29.Contract(
70784
+ const registry = new import_ethers30.Contract(
70400
70785
  registryAddress,
70401
70786
  POSITION_DELEGATE_REGISTRY_ABI,
70402
70787
  signer
@@ -70404,7 +70789,7 @@ async function setPositionDelegate(positionId, delegate, signer, registryAddress
70404
70789
  return registry["setPositionDelegate"](positionId, delegate);
70405
70790
  }
70406
70791
  async function getPositionDelegate(positionId, provider, registryAddress) {
70407
- const registry = new import_ethers29.Contract(
70792
+ const registry = new import_ethers30.Contract(
70408
70793
  registryAddress,
70409
70794
  POSITION_DELEGATE_REGISTRY_ABI,
70410
70795
  provider
@@ -70450,9 +70835,17 @@ async function mintAgentPkp(params) {
70450
70835
  }
70451
70836
  var AGENT_STATUS = { None: 0, Active: 1, Revoked: 2 };
70452
70837
  function planAgentBinding(params) {
70453
- const { isActive, record, nowSeconds } = params;
70838
+ const { isActive, paused, record, nowSeconds } = params;
70839
+ if (typeof paused !== "boolean") {
70840
+ throw new Error("planAgentBinding: `paused` must be read from the registry (boolean required)");
70841
+ }
70454
70842
  if (isActive)
70455
70843
  return { kind: "reuse", agent: record.agent };
70844
+ if (paused) {
70845
+ throw new Error(
70846
+ "AgentDelegationRegistry is paused \u2014 agent delegation cannot be changed until it is unpaused."
70847
+ );
70848
+ }
70456
70849
  const status = Number(record.status);
70457
70850
  if (status === AGENT_STATUS.None || status === AGENT_STATUS.Revoked) {
70458
70851
  return { kind: "register" };
@@ -70462,7 +70855,7 @@ function planAgentBinding(params) {
70462
70855
  }
70463
70856
  if (Number(record.validUntil) > nowSeconds) {
70464
70857
  throw new Error(
70465
- "AgentDelegationRegistry reports an unexpired agent as inactive \u2014 the registry is paused. Agent delegation cannot be changed until it is unpaused."
70858
+ "AgentDelegationRegistry returned an inconsistent read (an unexpired, unpaused Active agent reported inactive); retry."
70466
70859
  );
70467
70860
  }
70468
70861
  return { kind: "rotate" };
@@ -70519,7 +70912,7 @@ var SIGNABLE_FUNCTIONS2 = [
70519
70912
  // this too is client-only and never module-whitelisted.
70520
70913
  "function addAddress(string btcAddress) external"
70521
70914
  ];
70522
- var IFACE2 = new import_ethers31.ethers.Interface(SIGNABLE_FUNCTIONS2);
70915
+ var IFACE2 = new import_ethers32.ethers.Interface(SIGNABLE_FUNCTIONS2);
70523
70916
  function encodeSignable2(fn, args) {
70524
70917
  return IFACE2.encodeFunctionData(fn, args);
70525
70918
  }
@@ -70540,46 +70933,11 @@ function decodeSignable2(data) {
70540
70933
  );
70541
70934
  }
70542
70935
  }
70543
- var MAX_GAS_LIMIT = 5000000n;
70544
- var MAX_FEE_PER_GAS_WEI = 2000000000000n;
70545
- var DEFAULT_MAX_TX_FEE_WEI = 250000000000000000n;
70546
- var DEFAULT_FEE_CEILING = {
70547
- maxGasLimit: MAX_GAS_LIMIT,
70548
- maxFeePerGasWei: MAX_FEE_PER_GAS_WEI,
70549
- maxTxFeeWei: DEFAULT_MAX_TX_FEE_WEI
70550
- };
70551
- function fmtEth(wei) {
70552
- return `${import_ethers33.ethers.formatEther(wei)} ETH`;
70553
- }
70554
- function fmtGwei(wei) {
70555
- return `${import_ethers33.ethers.formatUnits(wei, "gwei")} gwei`;
70556
- }
70557
- function worstCaseFeeWei(gasLimit, maxFeePerGas) {
70558
- if (gasLimit == null || maxFeePerGas == null)
70559
- return null;
70560
- return gasLimit * maxFeePerGas;
70561
- }
70562
- function assertFeeCeiling(gasLimit, maxFeePerGas, raise, ceiling = DEFAULT_FEE_CEILING) {
70563
- if (gasLimit != null && gasLimit > ceiling.maxGasLimit) {
70564
- raise(`gasLimit ${gasLimit} exceeds the signing ceiling of ${ceiling.maxGasLimit}`);
70565
- }
70566
- if (maxFeePerGas != null && maxFeePerGas > ceiling.maxFeePerGasWei) {
70567
- raise(
70568
- `maxFeePerGas ${fmtGwei(maxFeePerGas)} exceeds the signing ceiling of ${fmtGwei(ceiling.maxFeePerGasWei)}`
70569
- );
70570
- }
70571
- const worst = worstCaseFeeWei(gasLimit, maxFeePerGas);
70572
- if (worst != null && worst > ceiling.maxTxFeeWei) {
70573
- raise(
70574
- `worst-case transaction fee ${fmtEth(worst)} (gasLimit ${gasLimit} \xD7 ${fmtGwei(maxFeePerGas)}) exceeds the signing ceiling of ${fmtEth(ceiling.maxTxFeeWei)}.${ceiling.raiseHint ? ` ${ceiling.raiseHint}` : ""}`
70575
- );
70576
- }
70577
- }
70578
70936
  function eqAddr2(a, b) {
70579
70937
  if (!a || !b)
70580
70938
  return false;
70581
70939
  try {
70582
- return import_ethers32.ethers.getAddress(a) === import_ethers32.ethers.getAddress(b);
70940
+ return import_ethers33.ethers.getAddress(a) === import_ethers33.ethers.getAddress(b);
70583
70941
  } catch {
70584
70942
  return false;
70585
70943
  }
@@ -70645,7 +71003,7 @@ function readValue2(tx2) {
70645
71003
  }
70646
71004
  function normalizePositionId2(id) {
70647
71005
  const hex = id.startsWith("0x") ? id : `0x${id}`;
70648
- return import_ethers32.ethers.zeroPadValue(hex, 32).toLowerCase();
71006
+ return import_ethers33.ethers.zeroPadValue(hex, 32).toLowerCase();
70649
71007
  }
70650
71008
  function requirePositionId(actual, expected) {
70651
71009
  const txPositionId = String(actual).toLowerCase();
@@ -70937,18 +71295,18 @@ function buildPsmRedeemTx2(p) {
70937
71295
  var PSM_READS_ABI = ["function supportedStablecoins(address) view returns (bool)"];
70938
71296
  var ERC20_READS_ABI = ["function allowance(address owner, address spender) view returns (uint256)"];
70939
71297
  function psmExchangeReadsFromProvider(provider, psmAddress) {
70940
- const psm = new import_ethers30.ethers.Contract(psmAddress, PSM_READS_ABI, provider);
71298
+ const psm = new import_ethers31.ethers.Contract(psmAddress, PSM_READS_ABI, provider);
70941
71299
  return {
70942
71300
  isStablecoinSupported: async (stablecoin) => await psm.getFunction("supportedStablecoins")(stablecoin),
70943
- allowance: async (token, owner, spender) => await new import_ethers30.ethers.Contract(token, ERC20_READS_ABI, provider).getFunction("allowance")(owner, spender)
71301
+ allowance: async (token, owner, spender) => await new import_ethers31.ethers.Contract(token, ERC20_READS_ABI, provider).getFunction("allowance")(owner, spender)
70944
71302
  };
70945
71303
  }
70946
71304
  var refuse = (direction, msg) => new TxValidationError2(msg, `PSM ${direction}`);
70947
71305
  function requireAddress(direction, label, value) {
70948
- if (!value || !import_ethers30.ethers.isAddress(value)) {
71306
+ if (!value || !import_ethers31.ethers.isAddress(value)) {
70949
71307
  throw refuse(direction, `${label} address is missing or invalid (${String(value)})`);
70950
71308
  }
70951
- return import_ethers30.ethers.getAddress(value);
71309
+ return import_ethers31.ethers.getAddress(value);
70952
71310
  }
70953
71311
  async function planPsmExchange(params) {
70954
71312
  const { direction, amountIn, minOut, vctx, reads } = params;
@@ -71265,6 +71623,384 @@ function formatLiquidationFailureMessage(loanId, errorMessage, btcVault, btcVaul
71265
71623
  const formattedBalance = formatBTCAmount(btcVaultBalance);
71266
71624
  return `\u274C DH SDK: Loan Id ${loanId} liquidation FAILED: ${errorMessage}; BTC vault ${btcVault} balance is ${formattedBalance}, UCD Debt of ${ucdDebt} and BTC Price of ${formattedPrice}`;
71267
71625
  }
71626
+ var CONTRACT_ERROR_FRAGMENTS = [
71627
+ { fragment: "error AboveMaxRedeem(uint256 amount, uint256 maximum)", contracts: ["SimplePSMV2"] },
71628
+ { fragment: "error AboveMaxSwap(uint256 amount, uint256 maximum)", contracts: ["SimplePSMV2"] },
71629
+ { fragment: "error AccessControlBadConfirmation()", contracts: ["PositionManager", "LoanOperationsManagerModule", "CollateralManagerModule", "BTCSpendAuthorizer", "UCDController", "SimplePSMV2"] },
71630
+ { fragment: "error AccessControlUnauthorizedAccount(address account, bytes32 neededRole)", contracts: ["PositionManager", "LoanOperationsManagerModule", "CollateralManagerModule", "BTCSpendAuthorizer", "UCDController", "SimplePSMV2"] },
71631
+ { fragment: "error AddressEmptyCode(address target)", contracts: ["PositionManager", "LoanOperationsManagerModule", "OperationAuthorizationRegistry", "CollateralManagerModule", "BTCSpendAuthorizer", "UCDController", "SimplePSMV2"] },
71632
+ { fragment: "error AlreadyActive()", contracts: ["PositionManagerErrors"] },
71633
+ { fragment: "error AlreadySigned()", contracts: ["PositionManagerErrors", "OperationAuthorizationRegistry"] },
71634
+ { fragment: "error AmountMustBePositive()", contracts: ["LoanOperationsManagerModule", "SimplePSMV2"] },
71635
+ { fragment: "error ArrayLengthMismatch()", contracts: ["BTCSpendAuthorizer", "SimplePSMV2"] },
71636
+ { fragment: "error BTCSpendAuthorizerNotSet()", contracts: ["LoanOperationsManagerModule"] },
71637
+ { fragment: "error BalanceMismatch()", contracts: ["UCDController"] },
71638
+ { fragment: "error BatchSizeTooLarge()", contracts: ["BTCSpendAuthorizer"] },
71639
+ { fragment: "error BelowMinRedeem(uint256 amount, uint256 minimum)", contracts: ["SimplePSMV2"] },
71640
+ { fragment: "error BelowMinSwap(uint256 amount, uint256 minimum)", contracts: ["SimplePSMV2"] },
71641
+ { fragment: "error BorrowerBTCSpendMutationDisabled()", contracts: ["LoanOperationsManagerModule"] },
71642
+ { fragment: "error BtcAmountTooLarge()", contracts: ["PositionManager", "LoanOperationsManagerModule", "CollateralManagerModule"] },
71643
+ { fragment: "error BtcPriceBoundOutOfRange()", contracts: ["LoanOperationsManagerModule"] },
71644
+ { fragment: "error BtcPriceDeviationExceeded(uint256 signedPrice, uint256 chainlinkPrice, uint16 deviationBps)", contracts: ["LoanOperationsManagerModule"] },
71645
+ { fragment: "error BtcPriceFeedStale(uint256 updatedAt, uint256 maxAge)", contracts: ["LoanOperationsManagerModule"] },
71646
+ { fragment: "error BtcPriceTooHigh()", contracts: ["PositionManager", "LoanOperationsManagerModule", "CollateralManagerModule"] },
71647
+ { fragment: "error BurnCallFailed()", contracts: ["UCDController"] },
71648
+ { fragment: "error BurnGuardFailed(uint8 code)", contracts: ["UCDController"] },
71649
+ { fragment: "error BurnVerificationFailed()", contracts: ["PositionManager", "PositionManagerErrors"] },
71650
+ { fragment: "error CannotRemoveLastTerm()", contracts: ["PositionManagerErrors"] },
71651
+ { fragment: "error CannotUpgradeToSelf()", contracts: ["PositionManagerErrors", "LoanOperationsManagerModule", "CollateralManagerModule", "BTCSpendAuthorizer"] },
71652
+ { fragment: "error CircuitBreakerNotActive()", contracts: ["PositionManagerErrors"] },
71653
+ { fragment: "error CircuitBreakerTriggered()", contracts: ["PositionManagerErrors"] },
71654
+ { fragment: "error CollateralOverflow()", contracts: ["PositionManager", "LoanOperationsManagerModule", "CollateralManagerModule"] },
71655
+ { fragment: "error CollateralRatioTooLargeForStorage()", contracts: ["PositionManagerErrors"] },
71656
+ { fragment: "error CollateralRatioTooLow()", contracts: ["PositionManager", "PositionManagerErrors", "LoanOperationsManagerModule"] },
71657
+ { fragment: "error ContractNotDeployed(address addr)", contracts: ["PositionManager"] },
71658
+ { fragment: "error DailyLimitExceeded()", contracts: ["UCDController"] },
71659
+ { fragment: "error DeadZoneViolation()", contracts: ["OperationAuthorizationRegistry"] },
71660
+ { fragment: "error DebtCalculationMismatch()", contracts: ["LoanOperationsManagerModule"] },
71661
+ { fragment: "error DebtNotZero()", contracts: ["PositionManager", "PositionManagerErrors"] },
71662
+ { fragment: "error DebtOverflow()", contracts: ["LoanOperationsManagerModule"] },
71663
+ { fragment: "error DebtUpdateVerificationFailed()", contracts: ["LoanOperationsValidation", "LoanOperationsManagerModule"] },
71664
+ { fragment: "error DebtUpdateVerificationFailedDetailed(bytes32 positionId, uint256 currentDebt, uint256 newDebt, uint256 quantumTimestamp, uint256 supplyAfterMint, uint256 expectedIncrease)", contracts: ["LoanOperationsManagerModule"] },
71665
+ { fragment: "error DecimalsMismatch(uint8 provided, uint8 actual)", contracts: ["SimplePSMV2"] },
71666
+ { fragment: "error DecimalsQueryFailed()", contracts: ["SimplePSMV2"] },
71667
+ { fragment: "error DivisionByZero()", contracts: ["PositionManager", "CollateralManagerModule"] },
71668
+ { fragment: "error ECDSAInvalidSignature()", contracts: ["BTCSpendAuthorizer"] },
71669
+ { fragment: "error ECDSAInvalidSignatureLength(uint256 length)", contracts: ["BTCSpendAuthorizer"] },
71670
+ { fragment: "error ECDSAInvalidSignatureS(bytes32 s)", contracts: ["BTCSpendAuthorizer"] },
71671
+ { fragment: "error ERC1967InvalidImplementation(address implementation)", contracts: ["PositionManager", "LoanOperationsManagerModule", "OperationAuthorizationRegistry", "CollateralManagerModule", "BTCSpendAuthorizer", "UCDController", "SimplePSMV2"] },
71672
+ { fragment: "error ERC1967NonPayable()", contracts: ["PositionManager", "LoanOperationsManagerModule", "OperationAuthorizationRegistry", "CollateralManagerModule", "BTCSpendAuthorizer", "UCDController", "SimplePSMV2"] },
71673
+ { fragment: "error EnforcedPause()", contracts: ["PositionManager", "LoanOperationsManagerModule", "CollateralManagerModule", "BTCSpendAuthorizer", "UCDController", "SimplePSMV2"] },
71674
+ { fragment: "error EntryFeeTooHigh(uint256 fee, uint256 max)", contracts: ["SimplePSMV2"] },
71675
+ { fragment: "error ExceedsFeeBalance(uint256 requested, uint256 max)", contracts: ["SimplePSMV2"] },
71676
+ { fragment: "error ExceedsMaxLoan()", contracts: ["PositionManagerErrors"] },
71677
+ { fragment: "error ExitFeeTooHigh(uint256 fee, uint256 max)", contracts: ["SimplePSMV2"] },
71678
+ { fragment: "error ExpectedPause()", contracts: ["PositionManager", "LoanOperationsManagerModule", "CollateralManagerModule", "BTCSpendAuthorizer", "UCDController", "SimplePSMV2"] },
71679
+ { fragment: "error ExtensionFeeMintingFailed()", contracts: ["PositionManager", "PositionManagerErrors"] },
71680
+ { fragment: "error ExtensionNotAllowed()", contracts: ["PositionManagerErrors"] },
71681
+ { fragment: "error FailedCall()", contracts: ["PositionManager", "LoanOperationsManagerModule", "OperationAuthorizationRegistry", "CollateralManagerModule", "BTCSpendAuthorizer", "UCDController", "SimplePSMV2"] },
71682
+ { fragment: "error FailedToGetStablecoinDecimals()", contracts: ["SimplePSMV2"] },
71683
+ { fragment: "error FailedToGetUCDDecimals()", contracts: ["SimplePSMV2"] },
71684
+ { fragment: "error FeeOnTransferNotSupported()", contracts: ["SimplePSMV2"] },
71685
+ { fragment: "error FeeTooHigh(uint256 fee, uint256 max)", contracts: ["PositionManagerErrors"] },
71686
+ { fragment: "error FeeTooLow(uint256 fee, uint256 min)", contracts: ["PositionManagerErrors"] },
71687
+ { fragment: "error ImplNotDeployed()", contracts: ["LoanOperationsManagerModule", "BTCSpendAuthorizer"] },
71688
+ { fragment: "error ImplementationNotDeployed()", contracts: ["UCDController"] },
71689
+ { fragment: "error InitialBalanceTooLarge()", contracts: ["SimplePSMV2"] },
71690
+ { fragment: "error InsufficientBalance()", contracts: ["PositionManagerErrors"] },
71691
+ { fragment: "error InsufficientCollateralForAmount()", contracts: ["PositionManagerErrors"] },
71692
+ { fragment: "error InsufficientCollateralRatio()", contracts: ["CollateralManagerModule"] },
71693
+ { fragment: "error InsufficientFeeBal()", contracts: ["LoanOperationsManagerModule"] },
71694
+ { fragment: "error InsufficientReserves(uint256 available, uint256 required)", contracts: ["SimplePSMV2"] },
71695
+ { fragment: "error InsufficientSignatures()", contracts: ["OperationAuthorizationRegistry"] },
71696
+ { fragment: "error IntegrityCheckFailed()", contracts: ["PositionManagerErrors"] },
71697
+ { fragment: "error InvalidActionHash()", contracts: ["CollateralManagerModule"] },
71698
+ { fragment: "error InvalidAddress()", contracts: ["PositionManager", "PositionManagerErrors", "OperationAuthorizationRegistry", "CollateralManagerModule", "SimplePSMV2"] },
71699
+ { fragment: "error InvalidAdmin()", contracts: ["LoanOperationsManagerModule", "BTCSpendAuthorizer", "SimplePSMV2"] },
71700
+ { fragment: "error InvalidAmount()", contracts: ["PositionManagerErrors", "SimplePSMV2"] },
71701
+ { fragment: "error InvalidBTCPrice()", contracts: ["PositionManager", "PositionManagerErrors"] },
71702
+ { fragment: "error InvalidBytes32()", contracts: ["PositionManager"] },
71703
+ { fragment: "error InvalidCollateralAmount()", contracts: ["PositionManager", "PositionManagerErrors"] },
71704
+ { fragment: "error InvalidController()", contracts: ["SimplePSMV2"] },
71705
+ { fragment: "error InvalidDecimals(uint8 decimals)", contracts: ["SimplePSMV2"] },
71706
+ { fragment: "error InvalidExchangeRate()", contracts: ["SimplePSMV2"] },
71707
+ { fragment: "error InvalidImpl()", contracts: ["LoanOperationsManagerModule", "BTCSpendAuthorizer"] },
71708
+ { fragment: "error InvalidImplementation()", contracts: ["UCDController"] },
71709
+ { fragment: "error InvalidInitialization()", contracts: ["PositionManager", "LoanOperationsManagerModule", "OperationAuthorizationRegistry", "CollateralManagerModule", "BTCSpendAuthorizer", "UCDController", "SimplePSMV2"] },
71710
+ { fragment: "error InvalidLitSignature()", contracts: ["BTCSpendAuthorizer"] },
71711
+ { fragment: "error InvalidLoanOps()", contracts: ["BTCSpendAuthorizer"] },
71712
+ { fragment: "error InvalidModuleAddress()", contracts: ["UCDController"] },
71713
+ { fragment: "error InvalidNetwork()", contracts: ["PositionManager", "PositionManagerErrors"] },
71714
+ { fragment: "error InvalidNetworkMode()", contracts: ["PositionManagerErrors"] },
71715
+ { fragment: "error InvalidOracleConfig()", contracts: ["LoanOperationsManagerModule"] },
71716
+ { fragment: "error InvalidPKPId()", contracts: ["PositionManagerErrors"] },
71717
+ { fragment: "error InvalidParameter()", contracts: ["UCDController"] },
71718
+ { fragment: "error InvalidPkpPublicKey()", contracts: ["PositionManager", "PositionManagerErrors"] },
71719
+ { fragment: "error InvalidPosMgr()", contracts: ["LoanOperationsManagerModule"] },
71720
+ { fragment: "error InvalidPositionId()", contracts: ["PositionManager", "PositionManagerErrors", "LoanOperationsValidation", "LoanOperationsManagerModule", "CollateralManagerModule"] },
71721
+ { fragment: "error InvalidPositionState()", contracts: ["LoanOperationsManagerModule"] },
71722
+ { fragment: "error InvalidPriceFeed()", contracts: ["LoanOperationsManagerModule"] },
71723
+ { fragment: "error InvalidRecipient()", contracts: ["LoanOperationsManagerModule", "SimplePSMV2"] },
71724
+ { fragment: "error InvalidRegistry()", contracts: ["LoanOperationsManagerModule"] },
71725
+ { fragment: "error InvalidRequestedExpiryDate()", contracts: ["PositionManagerErrors"] },
71726
+ { fragment: "error InvalidSignature(string reason)", contracts: ["PositionManager"] },
71727
+ { fragment: "error InvalidSignatureLength()", contracts: ["PositionManagerErrors"] },
71728
+ { fragment: "error InvalidStablecoinAddress()", contracts: ["SimplePSMV2"] },
71729
+ { fragment: "error InvalidStaleSpendAttestation()", contracts: ["BTCSpendAuthorizer"] },
71730
+ { fragment: "error InvalidString(string value)", contracts: ["PositionManager"] },
71731
+ { fragment: "error InvalidTerm()", contracts: ["PositionManager", "PositionManagerErrors"] },
71732
+ { fragment: "error InvalidTerm(uint256 term, uint256 min, uint256 max)", contracts: ["PositionManager"] },
71733
+ { fragment: "error InvalidTermMgr()", contracts: ["LoanOperationsManagerModule"] },
71734
+ { fragment: "error InvalidTermStartTime()", contracts: ["PositionManagerErrors"] },
71735
+ { fragment: "error InvalidToken()", contracts: ["SimplePSMV2"] },
71736
+ { fragment: "error InvalidUCDCtrl()", contracts: ["LoanOperationsManagerModule"] },
71737
+ { fragment: "error InvalidUCDDecimals(uint8 decimals)", contracts: ["SimplePSMV2"] },
71738
+ { fragment: "error InvalidUCDToken()", contracts: ["LoanOperationsManagerModule"] },
71739
+ { fragment: "error InvalidValidatorAddress()", contracts: ["BTCSpendAuthorizer"] },
71740
+ { fragment: "error InvalidValidatorSignature()", contracts: ["PositionManagerErrors"] },
71741
+ { fragment: "error InvalidVaultAddress()", contracts: ["PositionManagerErrors"] },
71742
+ { fragment: "error InvalidVolumeCap(bool isRedeem)", contracts: ["SimplePSMV2"] },
71743
+ { fragment: "error InvalidWithdrawalAddress()", contracts: ["CollateralManagerModule"] },
71744
+ { fragment: "error InvalidWithdrawalLoanStatusType()", contracts: ["CollateralManagerModule"] },
71745
+ { fragment: "error LiquidationsPaused()", contracts: ["PositionManager", "PositionManagerErrors"] },
71746
+ { fragment: "error LoanAmountTooHigh()", contracts: ["PositionManagerErrors"] },
71747
+ { fragment: "error LoanAmountTooLow()", contracts: ["PositionManagerErrors"] },
71748
+ { fragment: "error MaxAuthorizedSpendsReached()", contracts: ["BTCSpendAuthorizer"] },
71749
+ { fragment: "error MaxLoanOutOfBounds()", contracts: ["LoanOperationsManagerModule"] },
71750
+ { fragment: "error MaxRedeemBelowMin(uint256 maximum, uint256 minimum)", contracts: ["SimplePSMV2"] },
71751
+ { fragment: "error MaxRedeemCapDisabled()", contracts: ["SimplePSMV2"] },
71752
+ { fragment: "error MaxSupplyExceeded()", contracts: ["UCDController"] },
71753
+ { fragment: "error MaxSwapBelowMin(uint256 maximum, uint256 minimum)", contracts: ["SimplePSMV2"] },
71754
+ { fragment: "error MaxSwapCapDisabled()", contracts: ["SimplePSMV2"] },
71755
+ { fragment: "error MinLoanOutOfBounds()", contracts: ["LoanOperationsManagerModule"] },
71756
+ { fragment: "error MintBorrowerMismatch()", contracts: ["LoanOperationsManagerModule"] },
71757
+ { fragment: "error MintCallFailed()", contracts: ["UCDController"] },
71758
+ { fragment: "error MintFailed()", contracts: ["LoanOperationsManagerModule"] },
71759
+ { fragment: "error MintGuardFailed(uint8 code)", contracts: ["UCDController"] },
71760
+ { fragment: "error MintVerificationFailed()", contracts: ["PositionManager", "PositionManagerErrors"] },
71761
+ { fragment: "error MintVerificationMismatch(uint256 expectedSupply, uint256 currentSupply)", contracts: ["PositionManager", "PositionManagerErrors"] },
71762
+ { fragment: "error MissingVERSION()", contracts: ["LoanOperationsManagerModule", "BTCSpendAuthorizer", "UCDController"] },
71763
+ { fragment: "error MissingVersion()", contracts: ["PositionManagerErrors", "CollateralManagerModule"] },
71764
+ { fragment: "error ModuleCallFailed()", contracts: ["PositionManager", "PositionManagerErrors"] },
71765
+ { fragment: "error NoFeesToTransfer()", contracts: ["SimplePSMV2"] },
71766
+ { fragment: "error NoRegistry()", contracts: ["PositionManager", "PositionManagerErrors"] },
71767
+ { fragment: "error NoVersion()", contracts: ["LoanOperationsManagerModule", "BTCSpendAuthorizer", "UCDController"] },
71768
+ { fragment: "error NonZeroReserves(address stablecoin, uint256 reserves)", contracts: ["SimplePSMV2"] },
71769
+ { fragment: "error NormalizationOverflow()", contracts: ["SimplePSMV2"] },
71770
+ { fragment: "error NotAdminModule()", contracts: ["PositionManager", "PositionManagerErrors", "LoanOperationsManagerModule", "OperationAuthorizationRegistry", "CollateralManagerModule", "BTCSpendAuthorizer", "UCDController", "SimplePSMV2"] },
71771
+ { fragment: "error NotAuthorized()", contracts: ["PositionManager", "PositionManagerErrors"] },
71772
+ { fragment: "error NotAuthorizedConsumer()", contracts: ["OperationAuthorizationRegistry"] },
71773
+ { fragment: "error NotAuthorizedSigner()", contracts: ["OperationAuthorizationRegistry"] },
71774
+ { fragment: "error NotBorrower()", contracts: ["PositionManager", "PositionManagerErrors", "LoanOperationsManagerModule"] },
71775
+ { fragment: "error NotContract()", contracts: ["PositionManagerErrors", "LoanOperationsManagerModule", "OperationAuthorizationRegistry", "CollateralManagerModule", "BTCSpendAuthorizer", "SimplePSMV2"] },
71776
+ { fragment: "error NotInitializing()", contracts: ["PositionManager", "LoanOperationsManagerModule", "OperationAuthorizationRegistry", "CollateralManagerModule", "BTCSpendAuthorizer", "UCDController", "SimplePSMV2"] },
71777
+ { fragment: "error NotLiquidationPkpOwner()", contracts: ["PositionManager", "PositionManagerErrors"] },
71778
+ { fragment: "error NotLiquidator()", contracts: ["PositionManager", "PositionManagerErrors"] },
71779
+ { fragment: "error NotOwner()", contracts: ["OperationAuthorizationRegistry"] },
71780
+ { fragment: "error NotPendingOwner()", contracts: ["OperationAuthorizationRegistry"] },
71781
+ { fragment: "error NotProductionAuthorizer()", contracts: ["PositionManagerErrors", "LoanOperationsManagerModule"] },
71782
+ { fragment: "error NotProductionRegistry()", contracts: ["PositionManager", "PositionManagerErrors", "LoanOperationsManagerModule"] },
71783
+ { fragment: "error OnlyCore()", contracts: ["CollateralManagerModule"] },
71784
+ { fragment: "error OnlyLoanOps()", contracts: ["BTCSpendAuthorizer"] },
71785
+ { fragment: "error OnlyPosMgr()", contracts: ["LoanOperationsManagerModule"] },
71786
+ { fragment: "error OnlyPositionManager()", contracts: ["LoanOperationsManagerModule"] },
71787
+ { fragment: "error OperationInProgress()", contracts: ["PositionManager", "PositionManagerErrors"] },
71788
+ { fragment: "error OracleDecimalMismatch()", contracts: ["LoanOperationsManagerModule"] },
71789
+ { fragment: "error PKPAlreadyUsed()", contracts: ["PositionManagerErrors"] },
71790
+ { fragment: "error PaymentAmountTooLarge()", contracts: ["PositionManager", "PositionManagerErrors"] },
71791
+ { fragment: "error PaymentAmountZero()", contracts: ["PositionManager", "PositionManagerErrors"] },
71792
+ { fragment: "error PaymentMustBeLessThanDebt()", contracts: ["LoanOperationsManagerModule"] },
71793
+ { fragment: "error PaymentMustBePositive()", contracts: ["LoanOperationsManagerModule"] },
71794
+ { fragment: "error PositionAlreadyExists()", contracts: ["PositionManager", "PositionManagerErrors"] },
71795
+ { fragment: "error PositionDoesNotExist()", contracts: ["CollateralManagerModule"] },
71796
+ { fragment: "error PositionLiquidatable()", contracts: ["PositionManagerErrors"] },
71797
+ { fragment: "error PositionManagerNotContract()", contracts: ["LoanOperationsValidation"] },
71798
+ { fragment: "error PositionManagerNotSet()", contracts: ["LoanOperationsValidation"] },
71799
+ { fragment: "error PositionNotActive()", contracts: ["PositionManager", "PositionManagerErrors"] },
71800
+ { fragment: "error PositionNotEligible()", contracts: ["LoanOperationsManagerModule"] },
71801
+ { fragment: "error PositionNotEligibleForOperation()", contracts: ["PositionManager", "PositionManagerErrors"] },
71802
+ { fragment: "error PositionNotFound()", contracts: ["PositionManager", "PositionManagerErrors", "LoanOperationsManagerModule"] },
71803
+ { fragment: "error PositionNotInCore()", contracts: ["LoanOperationsValidation"] },
71804
+ { fragment: "error PositionStatusInvalid()", contracts: ["PositionManager", "PositionManagerErrors", "LoanOperationsManagerModule"] },
71805
+ { fragment: "error PositionWouldBecomeLiquidatable()", contracts: ["PositionManagerErrors"] },
71806
+ { fragment: "error ProposalAlreadyExecuted()", contracts: ["OperationAuthorizationRegistry"] },
71807
+ { fragment: "error ProposalAlreadyExists()", contracts: ["OperationAuthorizationRegistry"] },
71808
+ { fragment: "error ProposalCancelled()", contracts: ["OperationAuthorizationRegistry"] },
71809
+ { fragment: "error ProposalNotFound()", contracts: ["OperationAuthorizationRegistry"] },
71810
+ { fragment: "error PsmBurnSupplyMismatch(uint256 expected, uint256 actual)", contracts: ["SimplePSMV2"] },
71811
+ { fragment: "error PsmMintSupplyMismatch(uint256 expected, uint256 actual)", contracts: ["SimplePSMV2"] },
71812
+ { fragment: "error QuantumAlreadyUsed()", contracts: ["OperationAuthorizationRegistry"] },
71813
+ { fragment: "error QuantumOutsideWindow()", contracts: ["OperationAuthorizationRegistry"] },
71814
+ { fragment: "error RateLimitExceeded()", contracts: ["SimplePSMV2"] },
71815
+ { fragment: "error RatioOverflow()", contracts: ["PositionManager", "LoanOperationsManagerModule", "CollateralManagerModule"] },
71816
+ { fragment: "error RecipientNotAllowed()", contracts: ["LoanOperationsManagerModule", "SimplePSMV2"] },
71817
+ { fragment: "error RedeemVolumeExceededThisBlock(address stablecoin, uint256 attempted, uint256 cap)", contracts: ["SimplePSMV2"] },
71818
+ { fragment: "error RedemptionsPaused()", contracts: ["SimplePSMV2"] },
71819
+ { fragment: "error ReentrancyGuardReentrantCall()", contracts: ["PositionManager", "LoanOperationsManagerModule", "CollateralManagerModule", "BTCSpendAuthorizer", "UCDController", "SimplePSMV2"] },
71820
+ { fragment: "error RegistryNotSet()", contracts: ["LoanOperationsManagerModule", "SimplePSMV2"] },
71821
+ { fragment: "error ReserveOverflow()", contracts: ["SimplePSMV2"] },
71822
+ { fragment: "error ReserveTooLarge()", contracts: ["SimplePSMV2"] },
71823
+ { fragment: "error ReserveUnderflow()", contracts: ["SimplePSMV2"] },
71824
+ { fragment: "error SafeERC20FailedOperation(address token)", contracts: ["PositionManager", "LoanOperationsManagerModule", "SimplePSMV2"] },
71825
+ { fragment: "error SameBlockInteraction()", contracts: ["PositionManager", "PositionManagerErrors"] },
71826
+ { fragment: "error SameImpl()", contracts: ["LoanOperationsManagerModule", "BTCSpendAuthorizer"] },
71827
+ { fragment: "error SameImplementation()", contracts: ["PositionManagerErrors", "CollateralManagerModule"] },
71828
+ { fragment: "error SignatureVerificationFailed(bytes4 selector, address recovered, address expected, bytes32 messageHash, uint8 errorCode)", contracts: ["OperationAuthorizationRegistry"] },
71829
+ { fragment: "error SlippageExceeded(uint256 got, uint256 minimum)", contracts: ["SimplePSMV2"] },
71830
+ { fragment: "error SlippageProtectionRequired()", contracts: ["SimplePSMV2"] },
71831
+ { fragment: "error StablecoinAlreadySupported(address stablecoin)", contracts: ["SimplePSMV2"] },
71832
+ { fragment: "error StablecoinNotContract(address stablecoin)", contracts: ["SimplePSMV2"] },
71833
+ { fragment: "error StablecoinNotSupported(address stablecoin)", contracts: ["SimplePSMV2"] },
71834
+ { fragment: "error StablecoinNotSupportedInV1(address stablecoin)", contracts: ["SimplePSMV2"] },
71835
+ { fragment: "error StaleAttestationMismatch()", contracts: ["BTCSpendAuthorizer"] },
71836
+ { fragment: "error StaleAttestationTooOld()", contracts: ["BTCSpendAuthorizer"] },
71837
+ { fragment: "error StaleSpendValidatorNotSet()", contracts: ["BTCSpendAuthorizer"] },
71838
+ { fragment: "error StateHashMismatch()", contracts: ["LoanOperationsValidation", "LoanOperationsManagerModule", "CollateralManagerModule"] },
71839
+ { fragment: "error SwapVolumeExceededThisBlock(address stablecoin, uint256 attempted, uint256 cap)", contracts: ["SimplePSMV2"] },
71840
+ { fragment: "error SyncDriftTooLarge()", contracts: ["SimplePSMV2"] },
71841
+ { fragment: "error TargetAddrRequired()", contracts: ["BTCSpendAuthorizer"] },
71842
+ { fragment: "error TargetExceedsInputValue()", contracts: ["BTCSpendAuthorizer"] },
71843
+ { fragment: "error TargetMustBePositive()", contracts: ["BTCSpendAuthorizer"] },
71844
+ { fragment: "error TermAlreadyExists()", contracts: ["PositionManagerErrors"] },
71845
+ { fragment: "error TermExceedsMaximum()", contracts: ["PositionManager", "PositionManagerErrors"] },
71846
+ { fragment: "error TermNotFound()", contracts: ["PositionManagerErrors"] },
71847
+ { fragment: "error ThresholdTooHigh()", contracts: ["LoanOperationsManagerModule"] },
71848
+ { fragment: "error TimelockNotMet()", contracts: ["OperationAuthorizationRegistry"] },
71849
+ { fragment: "error TimelockRequiredOnThisChain()", contracts: ["OperationAuthorizationRegistry"] },
71850
+ { fragment: "error TimestampOverflow()", contracts: ["LoanOperationsManagerModule"] },
71851
+ { fragment: "error TooManySigners()", contracts: ["OperationAuthorizationRegistry"] },
71852
+ { fragment: "error UTXOAlreadyAuthorized()", contracts: ["BTCSpendAuthorizer"] },
71853
+ { fragment: "error UTXONotAuthorized()", contracts: ["BTCSpendAuthorizer"] },
71854
+ { fragment: "error UUPSUnauthorizedCallContext()", contracts: ["PositionManager", "LoanOperationsManagerModule", "OperationAuthorizationRegistry", "CollateralManagerModule", "BTCSpendAuthorizer", "UCDController", "SimplePSMV2"] },
71855
+ { fragment: "error UUPSUnsupportedProxiableUUID(bytes32 slot)", contracts: ["PositionManager", "LoanOperationsManagerModule", "OperationAuthorizationRegistry", "CollateralManagerModule", "BTCSpendAuthorizer", "UCDController", "SimplePSMV2"] },
71856
+ { fragment: "error UcdAmountTooLarge()", contracts: ["PositionManager", "LoanOperationsManagerModule", "CollateralManagerModule"] },
71857
+ { fragment: "error Unauthorized()", contracts: ["UCDController"] },
71858
+ { fragment: "error UnexpectedRoleGrantFailure()", contracts: ["PositionManager", "PositionManagerErrors", "LoanOperationsManagerModule", "CollateralManagerModule", "BTCSpendAuthorizer", "UCDController", "SimplePSMV2"] },
71859
+ { fragment: "error UnsupportedFeeToken(address token)", contracts: ["SimplePSMV2"] },
71860
+ { fragment: "error UserDailyMintLimitExceeded()", contracts: ["LoanOperationsManagerModule"] },
71861
+ { fragment: "error V2AlreadyInitialized()", contracts: ["SimplePSMV2"] },
71862
+ { fragment: "error ValidationFailed()", contracts: ["PositionManager", "PositionManagerErrors"] },
71863
+ { fragment: "error ValidatorNotActive()", contracts: ["OperationAuthorizationRegistry"] },
71864
+ { fragment: "error WithdrawalAddressNotApproved()", contracts: ["CollateralManagerModule"] },
71865
+ { fragment: "error WithdrawalExceedsReserves(uint256 amount, uint256 reserves)", contracts: ["SimplePSMV2"] },
71866
+ { fragment: "error ZeroAddress()", contracts: ["PositionManager", "UCDController"] },
71867
+ { fragment: "error ZeroAmount()", contracts: ["UCDController"] }
71868
+ ];
71869
+ var TABLE = null;
71870
+ function contractErrorTable() {
71871
+ if (TABLE)
71872
+ return TABLE;
71873
+ const table = /* @__PURE__ */ new Map();
71874
+ const iface = new import_ethers34.Interface(CONTRACT_ERROR_FRAGMENTS.map((e) => e.fragment));
71875
+ const contractsByName = new Map(
71876
+ CONTRACT_ERROR_FRAGMENTS.map((e) => [e.fragment.slice("error ".length, e.fragment.indexOf("(")), e.contracts])
71877
+ );
71878
+ iface.forEachError((fragment) => {
71879
+ const existing = table.get(fragment.selector);
71880
+ const contracts = contractsByName.get(fragment.name) ?? [];
71881
+ if (existing) {
71882
+ for (const c of contracts)
71883
+ if (!existing.contracts.includes(c))
71884
+ existing.contracts.push(c);
71885
+ return;
71886
+ }
71887
+ table.set(fragment.selector, {
71888
+ signature: fragment.format("sighash"),
71889
+ fragment,
71890
+ contracts: [...contracts]
71891
+ });
71892
+ });
71893
+ TABLE = table;
71894
+ return table;
71895
+ }
71896
+ function lookupContractError(selector) {
71897
+ return contractErrorTable().get(selector.toLowerCase()) ?? null;
71898
+ }
71899
+ function extractErrorData(error) {
71900
+ const viaQuantum = decodeQuantumRevert(error).data;
71901
+ if (viaQuantum && viaQuantum.length >= 10)
71902
+ return viaQuantum;
71903
+ const candidates = [
71904
+ error?.error?.error?.error?.data,
71905
+ error?.error?.error?.data,
71906
+ error?.data?.data,
71907
+ error?.transaction?.data
71908
+ ];
71909
+ for (const data of candidates) {
71910
+ if (typeof data === "string" && data.startsWith("0x") && data.length >= 10)
71911
+ return data;
71912
+ }
71913
+ const body = typeof error?.body === "string" ? error.body : null;
71914
+ if (body) {
71915
+ try {
71916
+ const parsed = JSON.parse(body);
71917
+ const data = parsed?.error?.data;
71918
+ if (typeof data === "string" && data.startsWith("0x") && data.length >= 10)
71919
+ return data;
71920
+ } catch {
71921
+ }
71922
+ }
71923
+ return null;
71924
+ }
71925
+ function extractRevertString(error) {
71926
+ if (typeof error?.reason === "string" && error.reason.length > 0)
71927
+ return error.reason;
71928
+ const message = typeof error?.message === "string" ? error.message : null;
71929
+ if (!message)
71930
+ return null;
71931
+ const withReasonString = message.match(/reverted with reason string ['"](.+?)['"]/);
71932
+ if (withReasonString)
71933
+ return withReasonString[1];
71934
+ const withReason = message.match(/reason: ['"](.+?)['"]/);
71935
+ return withReason ? withReason[1] : null;
71936
+ }
71937
+ function renderArgs(args) {
71938
+ return args.map((arg) => typeof arg === "object" && arg !== null ? JSON.stringify(arg) : String(arg)).join(", ");
71939
+ }
71940
+ function decodeContractError(error) {
71941
+ const errorData = extractErrorData(error);
71942
+ if (!errorData) {
71943
+ const revertString2 = extractRevertString(error);
71944
+ if (revertString2 && !revertString2.includes("cannot estimate gas")) {
71945
+ return {
71946
+ name: "RevertString",
71947
+ selector: "0x00000000",
71948
+ args: [revertString2],
71949
+ contract: "Unknown",
71950
+ message: `Revert: ${revertString2}`
71951
+ };
71952
+ }
71953
+ return null;
71954
+ }
71955
+ const selector = errorData.slice(0, 10).toLowerCase();
71956
+ if (selector === ERROR_STRING_SELECTOR || selector === PANIC_SELECTOR) {
71957
+ const { name } = decodeQuantumRevert(error);
71958
+ if (name) {
71959
+ return { name, selector, args: [], contract: "Solidity", message: name };
71960
+ }
71961
+ }
71962
+ const entry = lookupContractError(selector);
71963
+ if (entry) {
71964
+ const contract = entry.contracts.join(" | ");
71965
+ let args = [];
71966
+ try {
71967
+ const decoded = new import_ethers34.Interface([entry.fragment]).decodeErrorResult(entry.fragment, errorData);
71968
+ args = Array.from(decoded);
71969
+ } catch {
71970
+ args = [];
71971
+ }
71972
+ return {
71973
+ name: entry.fragment.name,
71974
+ selector,
71975
+ args,
71976
+ contract,
71977
+ message: `${contract}.${entry.fragment.name}(${renderArgs(args)})`
71978
+ };
71979
+ }
71980
+ const revertString = extractRevertString(error);
71981
+ if (revertString && !revertString.includes("cannot estimate gas")) {
71982
+ return {
71983
+ name: "RevertString",
71984
+ selector,
71985
+ args: [revertString],
71986
+ contract: "Unknown",
71987
+ message: `Revert: ${revertString}`
71988
+ };
71989
+ }
71990
+ return {
71991
+ name: "UnknownError",
71992
+ selector,
71993
+ args: [],
71994
+ contract: "Unknown",
71995
+ message: `Unknown error (selector: ${selector})`
71996
+ };
71997
+ }
71998
+ function formatDecodedError(decoded) {
71999
+ if (decoded.args && decoded.args.length > 0) {
72000
+ return `${decoded.contract}.${decoded.name}(${renderArgs(decoded.args)})`;
72001
+ }
72002
+ return `${decoded.contract}.${decoded.name}()`;
72003
+ }
71268
72004
  function normalizeBigNumberish(value) {
71269
72005
  if (value === null || value === void 0) {
71270
72006
  return "0";
@@ -71288,7 +72024,7 @@ function normalizeBigNumberish(value) {
71288
72024
  }
71289
72025
  return value;
71290
72026
  }
71291
- if (typeof value === "object" && value !== null && "toString" in value && typeof value.toString === "function") {
72027
+ if (typeof value === "object" && value !== null && "toString" in value && typeof value.toString === "function" && value.toString !== Object.prototype.toString) {
71292
72028
  const result = value.toString();
71293
72029
  if (typeof result === "object" && result !== null && "_hex" in result) {
71294
72030
  const resultObj = result;
@@ -72710,12 +73446,21 @@ var DiamondHandsSDK = class _DiamondHandsSDK {
72710
73446
  maxLoanWei: maxLoanValueWei
72711
73447
  })) {
72712
73448
  const debtAfterWei = currentDebtWei + requestAmountWei + baseFeeWei;
73449
+ const suggestionStamp = calculateNextQuantumTimestamp();
73450
+ const room = maxLoanValueWei > currentDebtWei ? maxLoanValueWei - currentDebtWei : 0n;
72713
73451
  const maxPrincipalUcd = Number(
72714
- maxPrincipalWithinLoanCap({
72715
- maxLoanWei: maxLoanValueWei,
72716
- currentDebtWei,
72717
- originationFeeBps: positionTerm.originationFeeBps
72718
- }) / BigInt(10 ** 18)
73452
+ maxPrincipalForFee(
73453
+ room,
73454
+ (principal) => calculateMintFee({
73455
+ mintAmount: principal,
73456
+ mintTimestamp: suggestionStamp,
73457
+ originationFeeBps: positionTerm.originationFeeBps,
73458
+ expiryAt: Number(position2.expiryAt),
73459
+ previousExpiryAt: Number(position2.previousExpiryAt),
73460
+ selectedTerm: Number(position2.selectedTerm),
73461
+ totalTerm: Number(position2.totalTerm)
73462
+ })
73463
+ ) / BigInt(10 ** 18)
72719
73464
  );
72720
73465
  return {
72721
73466
  success: false,
@@ -73453,7 +74198,6 @@ Mint/debt diagnostics (LoanOperationsManager mint path \u2192 increaseDebtFromMi
73453
74198
  let quantumContext = "";
73454
74199
  if (selector === "0x131d9a21" || // QuantumExpired()
73455
74200
  selector === "0x52ce5d58" || // QuantumAlreadyUsed()
73456
- selector === "0x137f3b70" || // InDeadZone()
73457
74201
  selector === "0xbe4b82c1" || // DeadZoneViolation()
73458
74202
  selector === "0x3e76a3c9") {
73459
74203
  const nowSecs = Math.floor(Date.now() / 1e3);
@@ -73576,33 +74320,14 @@ Message: ${causeMessage}${quantumContext}${loanCapDiagnostics}${mintDebtDiagnost
73576
74320
  return result;
73577
74321
  } catch (error) {
73578
74322
  let customErrorDetails = "";
73579
- const errorData = error?.data || error?.error?.data?.data || error?.error?.data;
73580
- if (errorData && typeof errorData === "string" && errorData.startsWith("0x") && errorData.length > 10) {
73581
- const selector = errorData.slice(0, 10);
73582
- const knownErrors = {
73583
- "0x8baa579f": "InvalidSignature()",
73584
- "0xd92e233d": "ValidationFailed()",
73585
- "0x3ee5aeb5": "OperationNotAuthorized()",
73586
- "0x70f4b32a": "UnauthorizedSigner()",
73587
- "0x48f5c3ed": "Unauthorized()",
73588
- "0x36bfdeea": "StateHashMismatch()",
73589
- "0xb9d419a7": "DebtUpdateVerificationFailed()",
73590
- "0xc7e20553": "DebtUpdateVerificationFailedDetailed(bytes32,uint256,uint256,uint256,uint256,uint256)",
73591
- "0x0cfd2a97": "MintVerificationMismatch(uint256,uint256)",
73592
- "0x07637bd8": "MintFailed()",
73593
- "0x131d9a21": "QuantumExpired() - Signature quantum window has closed",
73594
- "0x52ce5d58": "QuantumAlreadyUsed() - This quantum was already used for this position",
73595
- "0x137f3b70": "InDeadZone() - Timestamp in dead zone (near quantum boundary)",
73596
- "0xbe4b82c1": "DeadZoneViolation() - Non-current-quantum signature mined in the last 8s of the current quantum",
73597
- "0x3e76a3c9": "QuantumOutsideWindow() - Timestamp not in past/current/next quantum window"
73598
- };
73599
- const errorName = knownErrors[selector] || `Unknown error ${selector}`;
73600
- customErrorDetails = ` [${errorName}]`;
74323
+ const decoded = decodeContractError(error);
74324
+ if (decoded) {
74325
+ customErrorDetails = ` [${formatDecodedError(decoded)}]`;
73601
74326
  if (this.config.debug) {
73602
74327
  log.error("Custom error decoded from transaction receipt", {
73603
- selector,
73604
- errorName,
73605
- errorData
74328
+ selector: decoded.selector,
74329
+ errorName: decoded.name,
74330
+ contract: decoded.contract
73606
74331
  });
73607
74332
  }
73608
74333
  }
@@ -73813,11 +74538,7 @@ Message: ${causeMessage}${quantumContext}${loanCapDiagnostics}${mintDebtDiagnost
73813
74538
  const debt = positionDetails.debt || positionDetails.ucdDebt || "0";
73814
74539
  const btcPrice2 = litActionResult.btcPrice || "0";
73815
74540
  const btcVaultBalance = litActionResult.btcAmountSats || positionDetails.btcVaultBalance || "0";
73816
- const usdPricePerBTC = Number(btcPrice2) / 1e8;
73817
- const btcAmount = Number(btcVaultBalance) / 1e8;
73818
- const btcValueUSD = btcAmount * usdPricePerBTC;
73819
- const debtUSD = Number(debt) / 1e18;
73820
- const ratio = debtUSD > 0 ? (btcValueUSD / debtUSD * 100).toFixed(2) : "0.00";
74541
+ const ratio = BigInt(debt) > 0n ? collateralRatioPercentString(BigInt(btcVaultBalance), BigInt(btcPrice2), BigInt(debt)) : "0.00";
73821
74542
  const message = formatLiquidationSkippedMessage(
73822
74543
  request.positionId,
73823
74544
  ratio,
@@ -74306,14 +75027,15 @@ Message: ${causeMessage}${quantumContext}${loanCapDiagnostics}${mintDebtDiagnost
74306
75027
  }
74307
75028
  const debt = positionDetails.debt || positionDetails.ucdDebt || "0";
74308
75029
  const btcPrice2 = litActionResult.btcPrice || "0";
74309
- const ratio = debt !== "0" ? (Number(positionDetails.btcVaultBalance || "0") * Number(btcPrice2) / Number(debt) * 100 / 1e8).toFixed(2) : "0.00";
75030
+ const btcVaultBalance = litActionResult.btcAmountSats || positionDetails.btcVaultBalance || "0";
75031
+ const ratio = BigInt(debt) > 0n ? collateralRatioPercentString(BigInt(btcVaultBalance), BigInt(btcPrice2), BigInt(debt)) : "0.00";
74310
75032
  const message = formatLiquidationSuccessMessage(
74311
75033
  request.positionId,
74312
75034
  ratio,
74313
75035
  `${liquidationThreshold / 100}`,
74314
75036
  // Convert to percentage
74315
75037
  positionDetails.btcVault || "unknown",
74316
- positionDetails.btcVaultBalance || "0",
75038
+ btcVaultBalance,
74317
75039
  debt,
74318
75040
  btcPrice2
74319
75041
  );
@@ -76797,6 +77519,17 @@ Message: ${causeMessage}${quantumContext}${loanCapDiagnostics}${mintDebtDiagnost
76797
77519
  error: `networkFee=${request.networkFee} is \u2265 50% of targetAmount=${request.targetAmount}. Refusing to broadcast \u2014 real Bitcoin fees are typically <1% of value.`
76798
77520
  };
76799
77521
  }
77522
+ const destinationDustLimit = destinationDustShortfall(
77523
+ request.targetAmount,
77524
+ request.networkFee,
77525
+ request.destination
77526
+ );
77527
+ if (destinationDustLimit !== null) {
77528
+ return {
77529
+ success: false,
77530
+ error: `Destination would receive ${request.targetAmount - request.networkFee} sats (targetAmount=${request.targetAmount} \u2212 networkFee=${request.networkFee}), below the ${destinationDustLimit}-sat dust limit for ${request.destination}; the transaction would not relay.`
77531
+ };
77532
+ }
76800
77533
  const [txid, voutStr] = request.utxoIdentifier.split(":");
76801
77534
  const vout = parseInt(voutStr || "0", 10);
76802
77535
  if (!txid || isNaN(vout)) {
@@ -78272,8 +79005,9 @@ Message: ${causeMessage}${quantumContext}${loanCapDiagnostics}${mintDebtDiagnost
78272
79005
  const user = await signer.getAddress();
78273
79006
  const registry = AgentDelegationRegistry__factory.connect(addr, signer);
78274
79007
  let agentAddress;
78275
- const [isActive, record, latestBlock] = await Promise.all([
79008
+ const [isActive, paused, record, latestBlock] = await Promise.all([
78276
79009
  registry.isAgentActive(user),
79010
+ registry.paused(),
78277
79011
  registry.agentOf(user),
78278
79012
  this.getProviderOrThrow().getBlock("latest")
78279
79013
  ]);
@@ -78285,7 +79019,7 @@ Message: ${causeMessage}${quantumContext}${loanCapDiagnostics}${mintDebtDiagnost
78285
79019
  /* HIGH */
78286
79020
  });
78287
79021
  }
78288
- const plan = planAgentBinding({ isActive, record, nowSeconds: latestBlock.timestamp });
79022
+ const plan = planAgentBinding({ isActive, paused, record, nowSeconds: latestBlock.timestamp });
78289
79023
  if (plan.kind === "reuse") {
78290
79024
  agentAddress = plan.agent;
78291
79025
  } else {
@@ -79688,15 +80422,15 @@ var SUPPORTED_STABLECOINS = `
79688
80422
  }`;
79689
80423
 
79690
80424
  // src/boundary/upstream/real/psm-calls.ts
79691
- var import_ethers41 = require("ethers");
80425
+ var import_ethers42 = require("ethers");
79692
80426
 
79693
80427
  // node_modules/@gvnrdao/dh-sdk/dist/sign-guard.mjs
79694
- var import_ethers35 = require("ethers");
79695
80428
  var import_ethers36 = require("ethers");
79696
80429
  var import_ethers37 = require("ethers");
79697
80430
  var import_ethers38 = require("ethers");
79698
80431
  var import_ethers39 = require("ethers");
79699
80432
  var import_ethers40 = require("ethers");
80433
+ var import_ethers41 = require("ethers");
79700
80434
  var TxValidationError3 = class extends Error {
79701
80435
  /**
79702
80436
  * @param subject What is being refused. Defaults to the server-returned transaction the
@@ -79743,7 +80477,7 @@ var SIGNABLE_FUNCTIONS3 = [
79743
80477
  // this too is client-only and never module-whitelisted.
79744
80478
  "function addAddress(string btcAddress) external"
79745
80479
  ];
79746
- var IFACE3 = new import_ethers35.ethers.Interface(SIGNABLE_FUNCTIONS3);
80480
+ var IFACE3 = new import_ethers36.ethers.Interface(SIGNABLE_FUNCTIONS3);
79747
80481
  function encodeSignable3(fn, args) {
79748
80482
  return IFACE3.encodeFunctionData(fn, args);
79749
80483
  }
@@ -79773,10 +80507,10 @@ var DEFAULT_FEE_CEILING2 = {
79773
80507
  maxTxFeeWei: DEFAULT_MAX_TX_FEE_WEI2
79774
80508
  };
79775
80509
  function fmtEth2(wei) {
79776
- return `${import_ethers36.ethers.formatEther(wei)} ETH`;
80510
+ return `${import_ethers37.ethers.formatEther(wei)} ETH`;
79777
80511
  }
79778
80512
  function fmtGwei2(wei) {
79779
- return `${import_ethers36.ethers.formatUnits(wei, "gwei")} gwei`;
80513
+ return `${import_ethers37.ethers.formatUnits(wei, "gwei")} gwei`;
79780
80514
  }
79781
80515
  function worstCaseFeeWei2(gasLimit, maxFeePerGas) {
79782
80516
  if (gasLimit == null || maxFeePerGas == null)
@@ -79803,7 +80537,7 @@ function eqAddr3(a, b) {
79803
80537
  if (!a || !b)
79804
80538
  return false;
79805
80539
  try {
79806
- return import_ethers37.ethers.getAddress(a) === import_ethers37.ethers.getAddress(b);
80540
+ return import_ethers38.ethers.getAddress(a) === import_ethers38.ethers.getAddress(b);
79807
80541
  } catch {
79808
80542
  return false;
79809
80543
  }
@@ -79869,7 +80603,7 @@ function readValue3(tx2) {
79869
80603
  }
79870
80604
  function normalizePositionId3(id) {
79871
80605
  const hex = id.startsWith("0x") ? id : `0x${id}`;
79872
- return import_ethers37.ethers.zeroPadValue(hex, 32).toLowerCase();
80606
+ return import_ethers38.ethers.zeroPadValue(hex, 32).toLowerCase();
79873
80607
  }
79874
80608
  function requirePositionId2(actual, expected) {
79875
80609
  const txPositionId = String(actual).toLowerCase();
@@ -80164,18 +80898,18 @@ function buildPsmRedeemTx3(p) {
80164
80898
  var PSM_READS_ABI2 = ["function supportedStablecoins(address) view returns (bool)"];
80165
80899
  var ERC20_READS_ABI2 = ["function allowance(address owner, address spender) view returns (uint256)"];
80166
80900
  function psmExchangeReadsFromProvider2(provider, psmAddress) {
80167
- const psm = new import_ethers40.ethers.Contract(psmAddress, PSM_READS_ABI2, provider);
80901
+ const psm = new import_ethers41.ethers.Contract(psmAddress, PSM_READS_ABI2, provider);
80168
80902
  return {
80169
80903
  isStablecoinSupported: async (stablecoin) => await psm.getFunction("supportedStablecoins")(stablecoin),
80170
- allowance: async (token, owner, spender) => await new import_ethers40.ethers.Contract(token, ERC20_READS_ABI2, provider).getFunction("allowance")(owner, spender)
80904
+ allowance: async (token, owner, spender) => await new import_ethers41.ethers.Contract(token, ERC20_READS_ABI2, provider).getFunction("allowance")(owner, spender)
80171
80905
  };
80172
80906
  }
80173
80907
  var refuse2 = (direction, msg) => new TxValidationError3(msg, `PSM ${direction}`);
80174
80908
  function requireAddress2(direction, label, value) {
80175
- if (!value || !import_ethers40.ethers.isAddress(value)) {
80909
+ if (!value || !import_ethers41.ethers.isAddress(value)) {
80176
80910
  throw refuse2(direction, `${label} address is missing or invalid (${String(value)})`);
80177
80911
  }
80178
- return import_ethers40.ethers.getAddress(value);
80912
+ return import_ethers41.ethers.getAddress(value);
80179
80913
  }
80180
80914
  async function planPsmExchange2(params) {
80181
80915
  const { direction, amountIn, minOut, vctx, reads } = params;
@@ -80302,8 +81036,8 @@ var PsmCalls = class {
80302
81036
  constructor(deps) {
80303
81037
  this.deps = deps;
80304
81038
  const abi = [...PSM_VIEW_FRAGMENTS, ...PSM_ERROR_FRAGMENTS];
80305
- this.iface = new import_ethers41.ethers.Interface(abi);
80306
- this.psm = new import_ethers41.ethers.Contract(deps.psmAddress, abi, deps.provider);
81039
+ this.iface = new import_ethers42.ethers.Interface(abi);
81040
+ this.psm = new import_ethers42.ethers.Contract(deps.psmAddress, abi, deps.provider);
80307
81041
  }
80308
81042
  psm;
80309
81043
  iface;
@@ -80332,8 +81066,8 @@ var PsmCalls = class {
80332
81066
  });
80333
81067
  }
80334
81068
  return this.call(async () => {
80335
- const ucd = new import_ethers41.ethers.Contract(ucdToken, ERC20_FRAGMENTS, this.deps.provider);
80336
- const stable = new import_ethers41.ethers.Contract(this.deps.stablecoinAddress, ERC20_FRAGMENTS, this.deps.provider);
81069
+ const ucd = new import_ethers42.ethers.Contract(ucdToken, ERC20_FRAGMENTS, this.deps.provider);
81070
+ const stable = new import_ethers42.ethers.Contract(this.deps.stablecoinAddress, ERC20_FRAGMENTS, this.deps.provider);
80337
81071
  const [ucdWei, stablecoinUnits] = await Promise.all([ucd["balanceOf"](holder), stable["balanceOf"](holder)]);
80338
81072
  return { ucdWei: ucdWei.toString(), stablecoinUnits: stablecoinUnits.toString() };
80339
81073
  });
@@ -80451,7 +81185,7 @@ var PsmCalls = class {
80451
81185
  };
80452
81186
 
80453
81187
  // src/boundary/upstream/real/session.ts
80454
- var import_ethers42 = require("ethers");
81188
+ var import_ethers43 = require("ethers");
80455
81189
  var REFRESH_LEEWAY_SEC = 30;
80456
81190
  var LOGIN_TYPES_WITH_AUDIENCE3 = {
80457
81191
  DiamondHands: [
@@ -80499,7 +81233,7 @@ var LitOpsSession = class {
80499
81233
  const message = {
80500
81234
  address: this.wallet.address,
80501
81235
  issuedAt: Math.floor(Date.now() / 1e3),
80502
- nonce: "0x" + Buffer.from(import_ethers42.ethers.randomBytes(32)).toString("hex"),
81236
+ nonce: "0x" + Buffer.from(import_ethers43.ethers.randomBytes(32)).toString("hex"),
80503
81237
  audience: this.serviceEndpoint
80504
81238
  };
80505
81239
  const signature = await this.wallet.signTypedData(
@@ -80541,7 +81275,7 @@ function decodeJwtExp(token) {
80541
81275
  }
80542
81276
 
80543
81277
  // src/boundary/upstream/real/write-ops.ts
80544
- var import_ethers44 = require("ethers");
81278
+ var import_ethers45 = require("ethers");
80545
81279
 
80546
81280
  // src/signer/types.ts
80547
81281
  var OperationDeclined = class extends Error {
@@ -80551,7 +81285,7 @@ var OperationDeclined = class extends Error {
80551
81285
  init_tx_validator();
80552
81286
 
80553
81287
  // src/boundary/upstream/shared/external-bridge/page-crypto.ts
80554
- var import_ethers43 = require("ethers");
81288
+ var import_ethers44 = require("ethers");
80555
81289
  var PERSONAL_SIGN_LAYOUTS = {
80556
81290
  "dh-op-envelope-v1": {
80557
81291
  types: ["bytes32", "uint256", "uint256", "uint256", "bytes32"],
@@ -80572,9 +81306,9 @@ function hashForLayout(layout, fields) {
80572
81306
  const values = def.fieldOrder.map((name) => {
80573
81307
  const raw = fields[name];
80574
81308
  if (raw === void 0) throw new Error(`page-crypto: layout "${layout}" missing field "${name}"`);
80575
- return hashUtf8.has(name) ? import_ethers43.ethers.keccak256(import_ethers43.ethers.toUtf8Bytes(raw)) : raw;
81309
+ return hashUtf8.has(name) ? import_ethers44.ethers.keccak256(import_ethers44.ethers.toUtf8Bytes(raw)) : raw;
80576
81310
  });
80577
- return import_ethers43.ethers.solidityPackedKeccak256(def.types, values);
81311
+ return import_ethers44.ethers.solidityPackedKeccak256(def.types, values);
80578
81312
  }
80579
81313
  var PAGE_CRYPTO_JS = `"use strict";
80580
81314
  (function () {
@@ -80817,7 +81551,7 @@ function mcpExpected(leg) {
80817
81551
  }
80818
81552
  var OP_LAYOUT = "dh-op-envelope-v1";
80819
81553
  function randomNonceHex() {
80820
- return "0x" + Buffer.from(import_ethers44.ethers.randomBytes(16)).toString("hex");
81554
+ return "0x" + Buffer.from(import_ethers45.ethers.randomBytes(16)).toString("hex");
80821
81555
  }
80822
81556
  async function postJson(url2, body, headers) {
80823
81557
  const res = await fetch(url2, {
@@ -80878,7 +81612,7 @@ function buildWriteOps(deps) {
80878
81612
  return {
80879
81613
  to: String(tx2["to"] ?? ""),
80880
81614
  data: String(tx2["data"] ?? "0x"),
80881
- value: tx2["value"] != null ? import_ethers44.ethers.toBeHex(BigInt(String(tx2["value"]))) : "0x0",
81615
+ value: tx2["value"] != null ? import_ethers45.ethers.toBeHex(BigInt(String(tx2["value"]))) : "0x0",
80882
81616
  chainId: tx2["chainId"] != null ? Number(tx2["chainId"]) : chainId
80883
81617
  };
80884
81618
  }
@@ -81044,7 +81778,7 @@ function buildWriteOps(deps) {
81044
81778
  mintedUcdWei: minted,
81045
81779
  feeUcdWei: mintFee,
81046
81780
  echoedAmountUcdWei: minted,
81047
- authorization: auth(action, `mint ${import_ethers44.ethers.formatEther(amountWei)} UCD against ${p.positionId}`, r.value.digest)
81781
+ authorization: auth(action, `mint ${import_ethers45.ethers.formatEther(amountWei)} UCD against ${p.positionId}`, r.value.digest)
81048
81782
  },
81049
81783
  { id: SOURCE5, kind: "lit-ops", fetchedAt: (/* @__PURE__ */ new Date()).toISOString() }
81050
81784
  );
@@ -81085,7 +81819,7 @@ function buildWriteOps(deps) {
81085
81819
  txRef: { kind: "eth-tx", id: r.value.txHash },
81086
81820
  paidUcdWei: paid,
81087
81821
  echoedAmountUcdWei: paid,
81088
- authorization: auth(action, `repay ${import_ethers44.ethers.formatEther(amountWei)} UCD on ${p.positionId}`, r.value.digest)
81822
+ authorization: auth(action, `repay ${import_ethers45.ethers.formatEther(amountWei)} UCD on ${p.positionId}`, r.value.digest)
81089
81823
  },
81090
81824
  { id: SOURCE5, kind: "lit-ops", fetchedAt: (/* @__PURE__ */ new Date()).toISOString() }
81091
81825
  );
@@ -81348,7 +82082,7 @@ function buildWriteOps(deps) {
81348
82082
  }
81349
82083
 
81350
82084
  // src/signer/eoa-dh.ts
81351
- var import_ethers45 = require("ethers");
82085
+ var import_ethers46 = require("ethers");
81352
82086
  var EoaDHSigner = class {
81353
82087
  constructor(wallet, broadcast, clock = Date.now) {
81354
82088
  this.wallet = wallet;
@@ -81365,7 +82099,7 @@ var EoaDHSigner = class {
81365
82099
  async signAuthorization(spec) {
81366
82100
  const quantumTs = nextQuantumTimestamp(this.clock());
81367
82101
  const { fields, hashHex } = spec.stamp(quantumTs);
81368
- const signature = await this.wallet.signMessage(import_ethers45.ethers.getBytes(hashHex));
82102
+ const signature = await this.wallet.signMessage(import_ethers46.ethers.getBytes(hashHex));
81369
82103
  return { signature, quantumTs, fields };
81370
82104
  }
81371
82105
  async wrapInnerTx(innerTx) {
@@ -81383,10 +82117,10 @@ var EoaDHSigner = class {
81383
82117
 
81384
82118
  // src/signer/external-eoa.ts
81385
82119
  var import_node_crypto5 = require("crypto");
81386
- var import_ethers47 = require("ethers");
82120
+ var import_ethers48 = require("ethers");
81387
82121
 
81388
82122
  // src/boundary/upstream/shared/external-bridge/verify-landed-tx.ts
81389
- var import_ethers46 = require("ethers");
82123
+ var import_ethers47 = require("ethers");
81390
82124
  function eq2(a, b) {
81391
82125
  return a.toLowerCase() === b.toLowerCase();
81392
82126
  }
@@ -81409,7 +82143,7 @@ function compareLandedTx(landed, approved, borrower) {
81409
82143
  return { status: "verified", from: landed.from, hash: landed.hash };
81410
82144
  }
81411
82145
  function verifyRawSignedTx(rawSignedTx, approved, borrower) {
81412
- const parsed = import_ethers46.ethers.Transaction.from(rawSignedTx);
82146
+ const parsed = import_ethers47.ethers.Transaction.from(rawSignedTx);
81413
82147
  if (!parsed.from || !parsed.to || !parsed.hash) {
81414
82148
  return { status: "mismatch", hash: parsed.hash ?? "0x", reason: "the returned raw transaction is unsigned or malformed" };
81415
82149
  }
@@ -81447,7 +82181,7 @@ async function gasHintAcrossBlocks(provider, from, tx2, action) {
81447
82181
  for (let attempt = 0; attempt < 4; attempt++) {
81448
82182
  try {
81449
82183
  const est = await provider.estimateGas({ from, to: tx2.to, data: tx2.data, value: BigInt(tx2.value) });
81450
- return import_ethers47.ethers.toBeHex(est * 15n / 10n);
82184
+ return import_ethers48.ethers.toBeHex(est * 15n / 10n);
81451
82185
  } catch (e) {
81452
82186
  lastErr = e;
81453
82187
  await new Promise((r) => setTimeout(r, 13e3));
@@ -81497,7 +82231,7 @@ var ExternalEoaDHSigner = class {
81497
82231
  throw new OperationDeclined(`the ${spec.action} authorization was not signed: ${describeOutcome(outcome)}`);
81498
82232
  }
81499
82233
  const finalHash = spec.stamp(used.quantumTs).hashHex;
81500
- const recovered = import_ethers47.ethers.verifyMessage(import_ethers47.ethers.getBytes(finalHash), outcome.signature);
82234
+ const recovered = import_ethers48.ethers.verifyMessage(import_ethers48.ethers.getBytes(finalHash), outcome.signature);
81501
82235
  if (recovered.toLowerCase() !== this.deps.borrower.toLowerCase()) {
81502
82236
  throw new Error(`the ${spec.action} authorization was signed by ${recovered}, not the borrower ${this.deps.borrower}`);
81503
82237
  }
@@ -81508,7 +82242,7 @@ var ExternalEoaDHSigner = class {
81508
82242
  }
81509
82243
  async submitValidatedTx(outerTx, ctx) {
81510
82244
  const approved = toApprovedTx(outerTx, this.deps.chainId);
81511
- const gas = outerTx.gasLimit != null ? import_ethers47.ethers.toBeHex(BigInt(String(outerTx.gasLimit))) : await gasHintAcrossBlocks(this.deps.provider, this.deps.borrower, approved, ctx.action);
82245
+ const gas = outerTx.gasLimit != null ? import_ethers48.ethers.toBeHex(BigInt(String(outerTx.gasLimit))) : await gasHintAcrossBlocks(this.deps.provider, this.deps.borrower, approved, ctx.action);
81512
82246
  const outcome = await this.deps.bridge.requestSignature({
81513
82247
  id: (0, import_node_crypto5.randomUUID)(),
81514
82248
  kind: "transaction",
@@ -81542,7 +82276,7 @@ var ExternalEoaDHSigner = class {
81542
82276
  return new BridgeEthersSigner(this.deps);
81543
82277
  }
81544
82278
  };
81545
- var BridgeEthersSigner = class _BridgeEthersSigner extends import_ethers47.ethers.AbstractSigner {
82279
+ var BridgeEthersSigner = class _BridgeEthersSigner extends import_ethers48.ethers.AbstractSigner {
81546
82280
  constructor(deps) {
81547
82281
  super(deps.provider);
81548
82282
  this.deps = deps;
@@ -81553,13 +82287,13 @@ var BridgeEthersSigner = class _BridgeEthersSigner extends import_ethers47.ether
81553
82287
  return this.deps.borrower;
81554
82288
  }
81555
82289
  async signMessage(message) {
81556
- const bytes = typeof message === "string" ? import_ethers47.ethers.toUtf8Bytes(message) : message;
82290
+ const bytes = typeof message === "string" ? import_ethers48.ethers.toUtf8Bytes(message) : message;
81557
82291
  if (bytes.length !== 32) {
81558
82292
  throw new Error(
81559
82293
  `external-wallet signMessage accepts only the SDK's bare 32-byte auth hashes (got ${bytes.length} bytes) \u2014 no other raw-message signing rides this path.`
81560
82294
  );
81561
82295
  }
81562
- const hashHex = import_ethers47.ethers.hexlify(bytes).toLowerCase();
82296
+ const hashHex = import_ethers48.ethers.hexlify(bytes).toLowerCase();
81563
82297
  const nowMs = (this.deps.clock ?? Date.now)();
81564
82298
  const expiresAtSec = nextQuantumTimestamp(nowMs);
81565
82299
  const secondsLeft = Math.max(0, expiresAtSec - Math.floor(nowMs / 1e3));
@@ -81589,7 +82323,7 @@ var BridgeEthersSigner = class _BridgeEthersSigner extends import_ethers47.ether
81589
82323
  if (outcome.status !== "approved" || !outcome.signature) {
81590
82324
  throw new OperationDeclined(`the btc-withdrawal authorization was not signed: ${describeOutcome(outcome)}`);
81591
82325
  }
81592
- const recovered = import_ethers47.ethers.verifyMessage(bytes, outcome.signature);
82326
+ const recovered = import_ethers48.ethers.verifyMessage(bytes, outcome.signature);
81593
82327
  if (recovered.toLowerCase() !== this.deps.borrower.toLowerCase()) {
81594
82328
  throw new Error(`the btc-withdrawal authorization was signed by ${recovered}, not the borrower ${this.deps.borrower}`);
81595
82329
  }
@@ -81623,11 +82357,11 @@ var BridgeEthersSigner = class _BridgeEthersSigner extends import_ethers47.ether
81623
82357
  const approved = {
81624
82358
  to: tx2.to,
81625
82359
  data: tx2.data,
81626
- value: tx2.value != null ? import_ethers47.ethers.toBeHex(BigInt(String(tx2.value))) : "0x0",
82360
+ value: tx2.value != null ? import_ethers48.ethers.toBeHex(BigInt(String(tx2.value))) : "0x0",
81627
82361
  chainId: tx2.chainId != null ? Number(tx2.chainId) : this.deps.chainId
81628
82362
  };
81629
82363
  const card = cardForTx(approved);
81630
- const gas = tx2.gasLimit != null ? import_ethers47.ethers.toBeHex(BigInt(String(tx2.gasLimit))) : await gasHintAcrossBlocks(this.deps.provider, this.deps.borrower, approved, describeFn(approved.data));
82364
+ const gas = tx2.gasLimit != null ? import_ethers48.ethers.toBeHex(BigInt(String(tx2.gasLimit))) : await gasHintAcrossBlocks(this.deps.provider, this.deps.borrower, approved, describeFn(approved.data));
81631
82365
  const outcome = await this.deps.bridge.requestSignature({
81632
82366
  id: (0, import_node_crypto5.randomUUID)(),
81633
82367
  kind: "transaction",
@@ -81669,7 +82403,7 @@ function toApprovedTx(tx2, fallbackChainId) {
81669
82403
  return {
81670
82404
  to: tx2.to,
81671
82405
  data: tx2.data,
81672
- value: tx2.value != null ? import_ethers47.ethers.toBeHex(BigInt(String(tx2.value))) : "0x0",
82406
+ value: tx2.value != null ? import_ethers48.ethers.toBeHex(BigInt(String(tx2.value))) : "0x0",
81673
82407
  chainId: tx2.chainId != null ? Number(tx2.chainId) : fallbackChainId
81674
82408
  };
81675
82409
  }
@@ -81713,7 +82447,7 @@ var MIN_CONFIRMATIONS = { mainnet: 6, sepolia: 1 };
81713
82447
  var RealUpstreamPlugin = class {
81714
82448
  constructor(config, wallet, runtime) {
81715
82449
  this.config = config;
81716
- this.provider = new import_ethers48.ethers.JsonRpcProvider(config.rpcUrl, config.chainId);
82450
+ this.provider = new import_ethers49.ethers.JsonRpcProvider(config.rpcUrl, config.chainId);
81717
82451
  this.wallet = wallet ?? null;
81718
82452
  this.runtime = runtime ?? null;
81719
82453
  this.session = wallet ? new LitOpsSession(wallet.connect(this.provider), config.serviceEndpoint, config.chainId) : null;
@@ -81750,11 +82484,16 @@ var RealUpstreamPlugin = class {
81750
82484
  this.src("subgraph")
81751
82485
  );
81752
82486
  },
81753
- getPositionEvents: async () => upFail({
81754
- kind: "unavailable",
81755
- source: "subgraph",
81756
- message: "event history is not mapped in this delivery of the real adapter (indexer projection pending)"
81757
- })
82487
+ getPositionEvents: async () => (
82488
+ // PERMANENT capability gap, not a transient outage: the real adapter has no indexer
82489
+ // projection for event history, and this build never will. `unsupported` →
82490
+ // NOT_IMPLEMENTED so the guide does not tell the model to retry it (C-44).
82491
+ upFail({
82492
+ kind: "unsupported",
82493
+ source: "subgraph",
82494
+ message: "event history is not implemented on the real adapter in this build (no indexer projection) \u2014 this is a permanent capability gap, not a transient outage; do not retry"
82495
+ })
82496
+ )
81758
82497
  };
81759
82498
  this.chain = {
81760
82499
  getPositionDetails: (id) => this.chainRead(() => this.readPositionDetails(id)),
@@ -82015,14 +82754,14 @@ var RealUpstreamPlugin = class {
82015
82754
  if (!pkpValidation) {
82016
82755
  throw new Error(`the SDK's ${this.config.network} deployment table has no PKPValidation address \u2014 cannot verify validator version ${version2}.`);
82017
82756
  }
82018
- const registry = new import_ethers48.ethers.Contract(pkpValidation, ["function validatorForVersion(uint256) view returns (address)"], this.provider);
82757
+ const registry = new import_ethers49.ethers.Contract(pkpValidation, ["function validatorForVersion(uint256) view returns (address)"], this.provider);
82019
82758
  let validator;
82020
82759
  try {
82021
82760
  validator = await registry.validatorForVersion(version2);
82022
82761
  } catch (e) {
82023
82762
  throw new Error(`could not verify validator version ${version2} on-chain (PKPValidation ${pkpValidation}): ${e.message}`);
82024
82763
  }
82025
- if (validator === import_ethers48.ethers.ZeroAddress) {
82764
+ if (validator === import_ethers49.ethers.ZeroAddress) {
82026
82765
  throw new Error(
82027
82766
  `validator version ${version2} is NOT registered on ${this.config.network} (PKPValidation ${pkpValidation} returns the zero address) \u2014 the transaction would revert ValidatorNotConfigured. Set DH_VALIDATOR_VERSION to the network's registered generation.`
82028
82767
  );
@@ -82298,7 +83037,7 @@ var RealUpstreamPlugin = class {
82298
83037
  );
82299
83038
  if (!r.ok) return r;
82300
83039
  const raw = r.value.data.supportedStablecoins ?? [];
82301
- const bad = raw.find((x) => !import_ethers48.ethers.isAddress(String(x.address)) || !Number.isFinite(Number(x.decimals)));
83040
+ const bad = raw.find((x) => !import_ethers49.ethers.isAddress(String(x.address)) || !Number.isFinite(Number(x.decimals)));
82302
83041
  if (bad) {
82303
83042
  return {
82304
83043
  ok: false,
@@ -82381,7 +83120,7 @@ var RealUpstreamPlugin = class {
82381
83120
  };
82382
83121
  }
82383
83122
  const symbol = raw.toLowerCase();
82384
- if (import_ethers48.ethers.isAddress(raw)) return this.psmCallsFor(symbol);
83123
+ if (import_ethers49.ethers.isAddress(raw)) return this.psmCallsFor(symbol);
82385
83124
  const verified = await this.verifiedStablecoins();
82386
83125
  if (!verified.ok) return { ok: false, failure: verified.failure };
82387
83126
  const hits = verified.rows.filter((r) => r.symbol.toLowerCase() === symbol);
@@ -82419,7 +83158,7 @@ var RealUpstreamPlugin = class {
82419
83158
  * chain, then sign.
82420
83159
  */
82421
83160
  async psmCallsFor(stablecoinAddress) {
82422
- if (!import_ethers48.ethers.isAddress(stablecoinAddress)) {
83161
+ if (!import_ethers49.ethers.isAddress(stablecoinAddress)) {
82423
83162
  throw new Error(`psmCallsFor requires a resolved 0x address, got '${stablecoinAddress}' \u2014 resolve through psmCallsForChoice`);
82424
83163
  }
82425
83164
  const key = stablecoinAddress.toLowerCase();
@@ -82439,9 +83178,9 @@ var RealUpstreamPlugin = class {
82439
83178
  let supported;
82440
83179
  let symbol;
82441
83180
  try {
82442
- const psm = new import_ethers48.ethers.Contract(psmAddress, ["function supportedStablecoins(address) view returns (bool)"], this.provider);
83181
+ const psm = new import_ethers49.ethers.Contract(psmAddress, ["function supportedStablecoins(address) view returns (bool)"], this.provider);
82443
83182
  supported = await psm["supportedStablecoins"](key);
82444
- const erc20 = new import_ethers48.ethers.Contract(key, ["function symbol() view returns (string)"], this.provider);
83183
+ const erc20 = new import_ethers49.ethers.Contract(key, ["function symbol() view returns (string)"], this.provider);
82445
83184
  symbol = await erc20["symbol"]();
82446
83185
  } catch (e) {
82447
83186
  return { ok: false, failure: { kind: "unavailable", source: "chain-rpc", message: `PSM stablecoin check failed for ${key}: ${e.message}` } };
@@ -82654,7 +83393,7 @@ var RealUpstreamPlugin = class {
82654
83393
  const pm = this.contracts["PositionManager"];
82655
83394
  if (!pm) return false;
82656
83395
  try {
82657
- const c = new import_ethers48.ethers.Contract(pm, PAUSABLE_ABI, this.provider);
83396
+ const c = new import_ethers49.ethers.Contract(pm, PAUSABLE_ABI, this.provider);
82658
83397
  return Boolean(await c["paused"]());
82659
83398
  } catch {
82660
83399
  return false;
@@ -82663,16 +83402,16 @@ var RealUpstreamPlugin = class {
82663
83402
  async readPositionDetails(id) {
82664
83403
  const core = this.contracts["PositionManagerCoreModule"] ?? this.contracts["PositionManager"];
82665
83404
  if (!core) throw new Error(`no PositionManager address for network ${this.config.network}`);
82666
- const c = new import_ethers48.ethers.Contract(core, POSITION_DETAILS_ABI, this.provider);
83405
+ const c = new import_ethers49.ethers.Contract(core, POSITION_DETAILS_ABI, this.provider);
82667
83406
  let d;
82668
83407
  try {
82669
- d = await c["getPositionDetails"](import_ethers48.ethers.zeroPadValue(id, 32));
83408
+ d = await c["getPositionDetails"](import_ethers49.ethers.zeroPadValue(id, 32));
82670
83409
  } catch (e) {
82671
83410
  if (e.code === "CALL_EXCEPTION") return null;
82672
83411
  throw e;
82673
83412
  }
82674
83413
  const borrower = String(d["borrower"]);
82675
- if (borrower === import_ethers48.ethers.ZeroAddress) return null;
83414
+ if (borrower === import_ethers49.ethers.ZeroAddress) return null;
82676
83415
  return {
82677
83416
  positionId: String(d["positionId"]),
82678
83417
  pkpId: String(d["pkpId"]),
@@ -83197,6 +83936,8 @@ var SignatureBridge = class {
83197
83936
  wcTransport = null;
83198
83937
  /** True while a WalletConnect session is THE wallet — ceremonies route over WC. */
83199
83938
  wcActive = false;
83939
+ /** Page session that most recently asked for a pairing QR — see `serveWcPairing`. */
83940
+ pairingSessionId = null;
83200
83941
  keystoreUnlock;
83201
83942
  unlockToken = null;
83202
83943
  unlockSession = null;
@@ -83327,7 +84068,8 @@ var SignatureBridge = class {
83327
84068
  ...handlers?.finalize ? { finalize: handlers.finalize } : {},
83328
84069
  owner: this.wcActive ? "wc" : "page",
83329
84070
  dispatched: false,
83330
- lastAttachedMs: now
84071
+ lastAttachedMs: now,
84072
+ finalizedBy: null
83331
84073
  };
83332
84074
  this.pending.set(request.id, entry);
83333
84075
  if (entry.owner === "wc") {
@@ -83360,7 +84102,8 @@ var SignatureBridge = class {
83360
84102
  // ceremony could not reach quorum through the very pages it is broadcast to.
83361
84103
  owner: "both",
83362
84104
  dispatched: false,
83363
- lastAttachedMs: now
84105
+ lastAttachedMs: now,
84106
+ finalizedBy: null
83364
84107
  };
83365
84108
  this.pending.set(request.id, entry);
83366
84109
  this.pushEntry(entry);
@@ -83458,7 +84201,7 @@ var SignatureBridge = class {
83458
84201
  * receives nothing cannot show anything. Distinct from `attachedNow()`, which counts
83459
84202
  * WalletConnect and must stay global for the connector's eviction predicate. */
83460
84203
  pageAttached() {
83461
- for (const s of this.sessions.values()) if (!s.refused && s.sse) return true;
84204
+ for (const s of this.sessions.values()) if (s.sse && this.authorized(s)) return true;
83462
84205
  return false;
83463
84206
  }
83464
84207
  /** Attachment for ONE entry — the wallet that entry is actually waiting on. The global
@@ -83475,6 +84218,7 @@ var SignatureBridge = class {
83475
84218
  * the deadline is checked first so expiry semantics stay pinned (T-EXT-03). */
83476
84219
  sweep() {
83477
84220
  const now = this.clock();
84221
+ this.evictDeadSessions();
83478
84222
  for (const entry of this.pending.values()) {
83479
84223
  if (entry.settled) continue;
83480
84224
  if (now >= entry.deadlineMs) {
@@ -83587,12 +84331,13 @@ var SignatureBridge = class {
83587
84331
  this.deny(res, 403, "this approval link has expired \u2014 ask for a fresh one (signer_setup status) and reopen");
83588
84332
  return;
83589
84333
  }
84334
+ this.makeRoomForSession();
83590
84335
  if (this.sessions.size >= MAX_SESSIONS) {
83591
84336
  this.deny(res, 429, `too many open approval pages (${MAX_SESSIONS}) \u2014 close one and retry`);
83592
84337
  return;
83593
84338
  }
83594
84339
  const sessionId = (0, import_node_crypto7.randomBytes)(24).toString("hex");
83595
- this.sessions.set(sessionId, { wallet: null, sse: null, refused: null });
84340
+ this.sessions.set(sessionId, { wallet: null, sse: null, refused: null, lastSeenMs: this.clock(), wcPaired: false });
83596
84341
  const page = htmlPageSecurityHeaders();
83597
84342
  res.writeHead(200, { "Content-Type": "text/html; charset=utf-8", "Cache-Control": "no-store", ...page.headers });
83598
84343
  res.end(renderApprovalPage(sessionId, page.nonce));
@@ -83607,6 +84352,7 @@ var SignatureBridge = class {
83607
84352
  * fresh pairing URI. A wallet approving the pairing becomes THE wallet. */
83608
84353
  async serveWcPairing(url2, res) {
83609
84354
  if (!this.checkSession(url2.searchParams.get("s"), res)) return;
84355
+ this.pairingSessionId = url2.searchParams.get("s");
83610
84356
  if (!this.wcConfig) {
83611
84357
  this.deny(res, 404, "WalletConnect is not configured (set DH_WC_PROJECT_ID)");
83612
84358
  return;
@@ -83630,6 +84376,10 @@ var SignatureBridge = class {
83630
84376
  }
83631
84377
  this.wcActive = info !== null;
83632
84378
  this.wallet = info ? { account: info.account, chainId: info.chainId } : null;
84379
+ if (info && this.pairingSessionId) {
84380
+ const paired = this.sessions.get(this.pairingSessionId);
84381
+ if (paired) paired.wcPaired = true;
84382
+ }
83633
84383
  if (info === null) {
83634
84384
  for (const entry of this.pending.values()) {
83635
84385
  if (!entry.settled && !entry.collect) {
@@ -83707,9 +84457,7 @@ var SignatureBridge = class {
83707
84457
  res.write(":connected\n\n");
83708
84458
  session.sse?.end();
83709
84459
  session.sse = res;
83710
- for (const entry of this.pending.values()) {
83711
- if (!entry.settled) res.write(this.wireFor(entry));
83712
- }
84460
+ this.replayPending(session);
83713
84461
  const keepAlive = setInterval(() => res.write(":ka\n\n"), 2e4);
83714
84462
  keepAlive.unref();
83715
84463
  res.on("close", () => {
@@ -83734,6 +84482,7 @@ var SignatureBridge = class {
83734
84482
  }
83735
84483
  session.wallet = { account, chainId };
83736
84484
  this.wallet = { account, chainId };
84485
+ this.replayPending(session);
83737
84486
  this.ok(res);
83738
84487
  }
83739
84488
  /** C-47: the single predicate every wallet account is admitted through. There are THREE
@@ -83817,7 +84566,9 @@ var SignatureBridge = class {
83817
84566
  /** Click-time re-stamp (A0.9): returns the FRESH personal-sign payload for a pending
83818
84567
  * request. Idempotent for requests without a finalize handler (payload as enqueued). */
83819
84568
  async onFinalize(body, res) {
83820
- if (!this.sessionOf(body["sessionId"], res)) return;
84569
+ const sessionId = String(body["sessionId"] ?? "");
84570
+ const session = this.decidingSessionOf(body["sessionId"], res);
84571
+ if (!session) return;
83821
84572
  const entry = this.pending.get(String(body["requestId"] ?? ""));
83822
84573
  if (!entry || entry.settled) {
83823
84574
  this.deny(res, 404, "unknown or already-settled requestId");
@@ -83831,6 +84582,12 @@ var SignatureBridge = class {
83831
84582
  this.deny(res, 409, "a mobile wallet is holding this approval \u2014 it is read-only here; approve or decline it in the wallet");
83832
84583
  return;
83833
84584
  }
84585
+ const holder = entry.finalizedBy ? this.sessions.get(entry.finalizedBy) : void 0;
84586
+ if (entry.finalizedBy && entry.finalizedBy !== sessionId && holder?.sse) {
84587
+ this.deny(res, 409, "another approval page is signing this request \u2014 approve it there, or close that page and retry");
84588
+ return;
84589
+ }
84590
+ entry.finalizedBy = sessionId;
83834
84591
  if (entry.finalize) {
83835
84592
  let fresh;
83836
84593
  try {
@@ -83850,7 +84607,7 @@ var SignatureBridge = class {
83850
84607
  res.end(JSON.stringify({ request: entry.request }));
83851
84608
  }
83852
84609
  onResult(body, res) {
83853
- if (!this.sessionOf(body["sessionId"], res)) return;
84610
+ if (!this.decidingSessionOf(body["sessionId"], res)) return;
83854
84611
  const entry = this.pending.get(String(body["requestId"] ?? ""));
83855
84612
  if (!entry || entry.settled) {
83856
84613
  this.deny(res, 404, "unknown or already-settled requestId");
@@ -83923,7 +84680,7 @@ var SignatureBridge = class {
83923
84680
  /** Broadcast a pending entry to EVERY open page (multi-owner links — plan 06 §1.5). */
83924
84681
  pushEntry(entry) {
83925
84682
  const data = this.wireFor(entry);
83926
- for (const s of this.sessions.values()) if (!s.refused) s.sse?.write(data);
84683
+ for (const s of this.sessions.values()) if (this.authorized(s)) s.sse?.write(data);
83927
84684
  }
83928
84685
  /** Progress goes out as a NAMED event so `es.onmessage` request handling never sees it. */
83929
84686
  pushProgress(payload) {
@@ -83931,7 +84688,51 @@ var SignatureBridge = class {
83931
84688
  data: ${JSON.stringify(payload)}
83932
84689
 
83933
84690
  `;
83934
- for (const s of this.sessions.values()) if (!s.refused) s.sse?.write(data);
84691
+ for (const s of this.sessions.values()) if (this.authorized(s)) s.sse?.write(data);
84692
+ }
84693
+ /** Replay every undecided card to ONE session — used when a session becomes authorized
84694
+ * (hello) after its stream was already open, which is the ordinary page order: the page
84695
+ * attaches its EventSource, then the wallet prompt resolves. Without this the newly
84696
+ * connected page would sit blank until the next push. */
84697
+ replayPending(session) {
84698
+ if (!session.sse || !this.authorized(session)) return;
84699
+ for (const entry of this.pending.values()) {
84700
+ if (!entry.settled) session.sse.write(this.wireFor(entry));
84701
+ }
84702
+ }
84703
+ /** Retire quarantined sessions that hold no stream. Always safe: a refused session is
84704
+ * denied on every route anyway, so keeping it costs a slot and buys nothing. */
84705
+ evictDeadSessions() {
84706
+ for (const [id, s] of this.sessions) if (s.refused && !s.sse) this.sessions.delete(id);
84707
+ }
84708
+ /**
84709
+ * Free a slot for an incoming page load when the ceiling is reached.
84710
+ *
84711
+ * MAX_SESSIONS was a ceiling with NO eviction — nothing but `close()` ever removed a
84712
+ * session — and every page load mints one (a reload is a new session). A long-lived
84713
+ * hosted bridge therefore reached 16 through ordinary use and 429'd the user out of
84714
+ * approving their own ceremonies, permanently, with "close one and retry" as the advice
84715
+ * for pages that were already closed.
84716
+ *
84717
+ * Eviction is ON DEMAND and never touches a session with a live SSE stream: that stream
84718
+ * is a page open in a browser right now, and the C1 contract is that live sessions
84719
+ * survive. Among the streamless it takes the least recently seen — the closed tab.
84720
+ */
84721
+ makeRoomForSession() {
84722
+ this.evictDeadSessions();
84723
+ while (this.sessions.size >= MAX_SESSIONS) {
84724
+ let oldestId = null;
84725
+ let oldestSeen = Infinity;
84726
+ for (const [id, s] of this.sessions) {
84727
+ if (s.sse) continue;
84728
+ if (s.lastSeenMs < oldestSeen) {
84729
+ oldestSeen = s.lastSeenMs;
84730
+ oldestId = id;
84731
+ }
84732
+ }
84733
+ if (oldestId === null) return;
84734
+ this.sessions.delete(oldestId);
84735
+ }
83935
84736
  }
83936
84737
  /**
83937
84738
  * C-47: `this.wallet` is DERIVED, never guessed.
@@ -83974,12 +84775,46 @@ data: ${JSON.stringify(payload)}
83974
84775
  }
83975
84776
  this.rebuildSharedWallet();
83976
84777
  }
84778
+ /**
84779
+ * A session that may SEE cards and DECIDE them — one where a PERSON has proven to be at
84780
+ * the page: `hello` with an admissible account, or a WalletConnect pairing a wallet
84781
+ * actually answered (`wcPaired`).
84782
+ *
84783
+ * `sessionOf` only ever asked "does this session id exist and is it un-quarantined". A
84784
+ * session id is minted by LOADING the page, and on the hosted tier the mount URL travels
84785
+ * through the conversation by design — so anyone holding it could mint a session, never
84786
+ * connect a wallet, and still receive every approval card on /events (the card is the
84787
+ * operation in readable form: position, destination, amounts) and still POST /result to
84788
+ * decline, or /finalize to re-stamp, someone else's ceremony. Quarantine never caught
84789
+ * them: it fires on an OFFERED account, and they offered none.
84790
+ *
84791
+ * Opening the stream without a wallet stays legal — that is how the real page bootstraps
84792
+ * before the user connects. It simply receives nothing and decides nothing until it has
84793
+ * connected. Requesting a pairing is likewise not enough: anyone with the link can ask
84794
+ * for a QR, so only a pairing a WALLET ANSWERED counts.
84795
+ */
84796
+ authorized(session) {
84797
+ if (session.refused) return false;
84798
+ if (session.wallet) return this.accountRefusal(session.wallet.account) === null;
84799
+ return session.wcPaired;
84800
+ }
84801
+ /** `sessionOf`, plus the wallet binding above — for the routes that decide a ceremony. */
84802
+ decidingSessionOf(candidate, res) {
84803
+ const session = this.sessionOf(candidate, res);
84804
+ if (!session) return null;
84805
+ if (!this.authorized(session)) {
84806
+ this.deny(res, 403, "connect your wallet on this page before approving, declining or finalizing a request");
84807
+ return null;
84808
+ }
84809
+ return session;
84810
+ }
83977
84811
  sessionOf(candidate, res) {
83978
84812
  const session = typeof candidate === "string" ? this.sessions.get(candidate) ?? null : null;
83979
84813
  if (!session) {
83980
84814
  this.deny(res, 403, "missing or wrong session");
83981
84815
  return null;
83982
84816
  }
84817
+ session.lastSeenMs = this.clock();
83983
84818
  if (session.refused) {
83984
84819
  this.deny(res, 403, session.refused);
83985
84820
  return null;
@@ -84302,8 +85137,8 @@ async function buildBoundary(configResult, overrides) {
84302
85137
  );
84303
85138
  }
84304
85139
  try {
84305
- const decrypted = await import_ethers49.ethers.Wallet.fromEncryptedJson(keystoreJson, config.keystorePassword);
84306
- if (!(decrypted instanceof import_ethers49.ethers.Wallet)) {
85140
+ const decrypted = await import_ethers50.ethers.Wallet.fromEncryptedJson(keystoreJson, config.keystorePassword);
85141
+ if (!(decrypted instanceof import_ethers50.ethers.Wallet)) {
84307
85142
  return bootError("DH_KEYSTORE_PATH did not decrypt to an EOA wallet keystore.", ["DH_KEYSTORE_PATH"]);
84308
85143
  }
84309
85144
  wallet = decrypted;
@@ -84672,8 +85507,13 @@ function authorizationModeBullets(d) {
84672
85507
  that one \u2014 say it before the popup. Walkthrough: \`guide connect-wallet\`.`);
84673
85508
  }
84674
85509
  if (offers(d, "keystore")) {
84675
- bullets.push(` - \`keystore\` \u2014 a local encrypted keystore signs automatically after each confirmation.
84676
- Real adapter and mock.`);
85510
+ bullets.push(` - \`keystore\` \u2014 a local encrypted keystore signs AUTOMATICALLY, with no per-operation
85511
+ human prompt. Real adapter and mock. Say this plainly when the user picks it: the
85512
+ password is asked ONCE, at unlock; after that the key signs every write this session
85513
+ without a popup, an approval page or any second human step. The \`confirmed: true\` gate
85514
+ is the ASSISTANT's \u2014 it is not the user seeing and approving the operation \u2014 so in this
85515
+ mode you must show the operation and get a real answer before you set it. A user who
85516
+ wants to inspect each operation as it signs wants \`external\`.`);
84677
85517
  }
84678
85518
  if (offers(d, "safe") || offers(d, "safe-module")) {
84679
85519
  bullets.push(` - \`safe\` / \`safe-module\` \u2014 PRACTICE-ONLY today: on the real adapter these modes
@@ -84684,6 +85524,9 @@ function authorizationModeBullets(d) {
84684
85524
  }
84685
85525
  return bullets.join("\n");
84686
85526
  }
85527
+ function readsNeedSignIn(d) {
85528
+ return offers(d, "keystore") ? "On the real adapter a read is NOT a free pass: `position_list {borrower}`, `protocol_status` and `protocol_terms` need a signing identity \u2014 the keystore (the env pair or `unlock-keystore`) or a wallet `connect` \u2014 and refuse on a fresh session until one is connected. Only the practice (mock) world reads without one; there is no signer-less public read on the real adapter." : "On this hosted connector a read is NOT a free pass: even `position_list {borrower}`, `protocol_status` and `protocol_terms` run only AFTER the wallet sign-in that connecting performs (`signer_setup` action `connect`) \u2014 a fresh session refuses them until then. There is no separate keystore step and no signer-less public read here.";
85529
+ }
84687
85530
  function keystoreAbsenceParagraph(d) {
84688
85531
  if (offers(d, "keystore")) return "";
84689
85532
  return `
@@ -84727,9 +85570,11 @@ install matrix. ${connectorInstallNote(d)}
84727
85570
 
84728
85571
  Nothing needs a config file. Three steps:
84729
85572
 
84730
- **1. Know your world.** Read \`boundary://info\` (its \`capabilities\` block) and
84731
- \`protocol_status\`, then tell the user what THIS deployment is: ${worldAxes(d)}; which
84732
- signer modes exist; current terms (\`protocol_terms\`).
85573
+ **1. Know your world.** Read \`boundary://info\` (its \`capabilities\` block) \u2014 that
85574
+ resource always answers, with no sign-in \u2014 and tell the user what THIS deployment is:
85575
+ ${worldAxes(d)}; which signer modes exist. ${readsNeedSignIn(d)} So the live reads
85576
+ (\`protocol_status\`, current terms via \`protocol_terms\`) come right after step 2, not
85577
+ before it.
84733
85578
 
84734
85579
  **2. Choose HOW to authorize operations** (the user's choice, made by talking):
84735
85580
  - **"Use my own wallet"** \u2192 call \`signer_setup\` action \`use\`, mode \`external\` \u2014 works
@@ -84749,8 +85594,9 @@ ${offers(d, "safe") || offers(d, "safe-module") ? `- **Safe / delegation modes (
84749
85594
  surface is the wallet ceremony and nothing else; \`signer_setup\` lists no other mode.
84750
85595
  \`guide safe\` and \`guide delegation\` state what exists elsewhere.`}
84751
85596
  - Not sure? \`signer_setup\` action \`status\` explains what is active and what is missing.
84752
- - **No signer is also a valid start:** every public read works without one \u2014
84753
- \`position_list {borrower}\` with the user's address needs no signer and no login.
85597
+ - **A read is not a signer-less shortcut:** the sign-in in step 2 is what turns reads ON.
85598
+ Until then \`position_list {borrower}\`, \`protocol_status\` and \`protocol_terms\` refuse
85599
+ on the real adapter \u2014 do step 2 first, then reads work.
84754
85600
  ${d.networks.length > 1 ? `- **Wrong network?** On the real adapter the user can switch sepolia \u2194 mainnet by
84755
85601
  talking (\`network_switch\`, human-confirmed) \u2014 see \`guide switch-network\`. State
84756
85602
  the money reality after any switch.` : `- **Wrong network?** This deployment is rolled out to ${d.networks[0]} alone \u2014
@@ -85239,7 +86085,12 @@ ${wrongNetworkTroubleshootingRow(d)}
85239
86085
  owed, wrong position state, or the USER DECLINED in the wallet. The message says which.
85240
86086
  A decline is not an error to fix \u2014 it is the user's decision.
85241
86087
  - **UPSTREAM_UNAVAILABLE** \u2014 a data source or the signature bridge is unreachable/expired.
85242
- Usually transient; re-check with \`protocol_status\` and retry once.
86088
+ Usually transient; re-check with \`protocol_status\` and retry once. (A PERMANENT gap
86089
+ answers \`NOT_IMPLEMENTED\`, below \u2014 that one is not retryable.)
86090
+ - **NOT_IMPLEMENTED** \u2014 a capability this adapter does NOT implement in this build, and never
86091
+ will \u2014 PERMANENT, not a transient outage, so do NOT retry it. \`position_events\` on the
86092
+ real adapter is the case: there is no indexer projection for event history here. Say the
86093
+ history is unavailable on this deployment and move on; the practice (mock) world has it.
85243
86094
  - **NOT_FOUND** \u2014 the position id doesn't exist in this world (check \`position_list\`).
85244
86095
  - **STATE_DIVERGENCE / STALE_DATA warnings** \u2014 sources disagree or lag; the envelope says
85245
86096
  which source and when from. Prefer chain-sourced values; re-read before acting.
@@ -85424,7 +86275,7 @@ var import_mcp2 = require("@modelcontextprotocol/sdk/server/mcp.js");
85424
86275
 
85425
86276
  // src/tools/loan.ts
85426
86277
  var import_zod = require("zod");
85427
- var import_ethers50 = require("ethers");
86278
+ var import_ethers51 = require("ethers");
85428
86279
 
85429
86280
  // src/util/format.ts
85430
86281
  function bigintReplacer(_key, value) {
@@ -85473,7 +86324,7 @@ function requireConfirmation(confirmed, actionLabel) {
85473
86324
  type: "text",
85474
86325
  text: `CONFIRMATION REQUIRED \u2014 refusing to run "${actionLabel}".
85475
86326
  This is an irreversible, fund-moving action. A human must explicitly authorize it.
85476
- Re-invoke with confirmed: true ONLY after a human has approved this exact operation. Do not set confirmed on your own.`
86327
+ Show the user what this operation does \u2014 amounts, destination, and that it cannot be undone \u2014 and re-invoke with confirmed: true ONLY after they answer. Do not set confirmed on your own, and do not treat an earlier approval of a different operation as covering this one. If the signer is a keystore, no wallet prompt will follow: this is the only place a human is asked.`
85477
86328
  }
85478
86329
  ],
85479
86330
  isError: true
@@ -85612,7 +86463,7 @@ function registerLoanTools(server, getB, adapter2 = "real") {
85612
86463
  const b = getB();
85613
86464
  if (!b.ok) return renderError(b.error);
85614
86465
  return renderEnvelope(
85615
- await b.boundary.mintUcd({ positionId, amountUcdWei: (0, import_ethers50.parseEther)(amountUcd.toString()).toString() })
86466
+ await b.boundary.mintUcd({ positionId, amountUcdWei: (0, import_ethers51.parseEther)(amountUcd.toString()).toString() })
85616
86467
  );
85617
86468
  })
85618
86469
  );
@@ -85650,7 +86501,7 @@ function registerLoanTools(server, getB, adapter2 = "real") {
85650
86501
  if (BigInt(detail.data.debtUcdWei) === 0n) return validationFailed("the position has no outstanding debt");
85651
86502
  amountUcdWei = detail.data.debtUcdWei;
85652
86503
  } else {
85653
- amountUcdWei = (0, import_ethers50.parseEther)(amountUcd.toString()).toString();
86504
+ amountUcdWei = (0, import_ethers51.parseEther)(amountUcd.toString()).toString();
85654
86505
  }
85655
86506
  return renderEnvelope(await b.boundary.repayUcd({ positionId, amountUcdWei }));
85656
86507
  })
@@ -85910,7 +86761,7 @@ function registerPositionTools(server, getB) {
85910
86761
  "position_events",
85911
86762
  {
85912
86763
  title: "Get a position's event history",
85913
- description: "Return mint, payment, withdrawal, renewal, and liquidation events for a position (indexer view).",
86764
+ description: "Return mint, payment, withdrawal, renewal, and liquidation events for a position (indexer view). NOT IMPLEMENTED on the real protocol adapter in this build \u2014 it answers NOT_IMPLEMENTED there (a PERMANENT gap, not a transient outage: do not retry). Available on the practice (mock) adapter.",
85914
86765
  inputSchema: {
85915
86766
  id: positionIdSchema2
85916
86767
  }
@@ -86253,7 +87104,7 @@ function registerMockControlTool(server, control, chainId = 1337) {
86253
87104
 
86254
87105
  // src/tools/signer.ts
86255
87106
  var import_zod6 = require("zod");
86256
- var import_ethers51 = require("ethers");
87107
+ var import_ethers52 = require("ethers");
86257
87108
  var MODES = ["external", "keystore", "safe", "safe-module", "mock-simulated"];
86258
87109
  var ACTIONS2 = ["status", "use", "reset-borrower", "unlock-keystore", "connect", "disconnect"];
86259
87110
  var EXTERNAL_ONLY_MODES = ["external"];
@@ -86295,7 +87146,7 @@ function registerSignerTool(server, getRuntime, opts) {
86295
87146
  if (mode !== void 0 && !offeredModes.includes(mode)) {
86296
87147
  return validationFailed(looksSecretShaped(mode) ? SECRET_REFUSAL : `mode '${mode}' is not one of: ${offeredModes.join(" | ")}`);
86297
87148
  }
86298
- if (safeAddress !== void 0 && !import_ethers51.ethers.isAddress(safeAddress)) {
87149
+ if (safeAddress !== void 0 && !import_ethers52.ethers.isAddress(safeAddress)) {
86299
87150
  return validationFailed(looksSecretShaped(safeAddress) ? SECRET_REFUSAL : `'${safeAddress}' is not a valid Safe address`);
86300
87151
  }
86301
87152
  if (action === "status") {
@@ -86456,7 +87307,7 @@ function registerGuidePrompts(server, deployment = LOCAL_GUIDE_DEPLOYMENT) {
86456
87307
  role: "user",
86457
87308
  content: {
86458
87309
  type: "text",
86459
- 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, keep me on the read-only path (position_list with my address needs no signer) and say the true reason; " + onboardAuthorizationLine(deployment) + "Ask before every operation; never assume confirmation."
87310
+ text: "I'm new to Diamond Hands. FIRST read boundary://info and its capabilities block \u2014 it is the truth about this session: the network, practice vs real money, whether writes are enabled (and the true reason when not), and which signer modes exist here. Never promise anything it does not list. Then read the guide topics 'getting-started' and 'first-setup' (guide tool), check protocol_status, and walk me through setup step by step IN MY LANGUAGE: tell me plainly whether this is practice or real money. BRANCH on capabilities: if no signer mode is available or writes are disabled, say the true reason \u2014 and note that on the real adapter even a read (position_list, protocol_status, protocol_terms) needs the wallet sign-in that connecting performs first; there is no signer-less read path, so guide me to sign in before expecting any read to return; " + onboardAuthorizationLine(deployment) + "Ask before every operation; never assume confirmation."
86460
87311
  }
86461
87312
  }
86462
87313
  ]
@@ -86644,7 +87495,7 @@ function registerProtocolResources(server, getB) {
86644
87495
  "protocol://psm",
86645
87496
  {
86646
87497
  title: "PSM status (UCD \u2194 USDC exchange)",
86647
- description: "Live SimplePSMV2 state as {data, warnings, source}. `data` carries network + chainId + psmAddress (the money surface names its chain) and `stablecoins`: EVERY coin this PSM supports, each with its own stablecoinKind (mock = practice token with a public self-serve mint; circle = real USDC), pause + redeemEnabled switches, live reserves, and per-direction fees (WITH their token), min/max (WITH their units \u2014 to-ucd caps in the stablecoin's smallest units, from-ucd caps in UCD wei) and per-block volume caps ('uncapped' when the on-chain cap is 0). This is where a caller learns the coin names that `psm_quote` and `psm_swap` require.",
87498
+ description: "Live SimplePSMV2 state as {data, warnings, source}. `data` carries network + chainId + psmAddress (the money surface names its chain) and `stablecoins`: EVERY coin this PSM supports, each with its own stablecoinKind (mock = practice token with a public self-serve mint; circle = canonical mainnet USDC, i.e. real Circle USDC; onchain = any OTHER real coin such as mainnet USDT \u2014 real and on-chain, but NOT Circle USDC), pause + redeemEnabled switches, live reserves, and per-direction fees (WITH their token), min/max (WITH their units \u2014 to-ucd caps in the stablecoin's smallest units, from-ucd caps in UCD wei) and per-block volume caps ('uncapped' when the on-chain cap is 0). This is where a caller learns the coin names that `psm_quote` and `psm_swap` require.",
86648
87499
  mimeType: "application/json"
86649
87500
  },
86650
87501
  async (uri) => {
@@ -86706,7 +87557,7 @@ function registerBoundaryInfoResource(server, getB) {
86706
87557
  }
86707
87558
 
86708
87559
  // src/version.ts
86709
- var SERVER_VERSION = "0.5.18";
87560
+ var SERVER_VERSION = "0.5.20";
86710
87561
 
86711
87562
  // src/server.ts
86712
87563
  var SERVER_INSTRUCTIONS = "Diamond Hands MCP \u2014 Bitcoin-collateralized borrowing. Before promising ANY flow, read the boundary://info resource and honor its `capabilities` block: it states which network this server is on, whether money is real (practiceWorld), whether writes are enabled (and the true reason when they are not), and which signer modes this build actually offers \u2014 never describe a flow outside it. State the network and whether funds are real when the user first acts. Authorization is chosen by conversation via the signer_setup tool (when listed); writes always require confirmed:true after showing the human-readable card. For walkthroughs consult the guide tool / guide:// resources instead of inventing steps; when a tool refuses, relay its stated reason and remedy \u2014 do not improvise alternatives. When a network_switch tool is listed, the network can change mid-session \u2014 after ANY switch, re-read boundary://info and state the new network and money reality to the user before doing anything else. When the user asks to disconnect / log out / sign out / forget or remove their wallet, call signer_setup action 'disconnect' (the full flush) \u2014 never treat 'reset-borrower' as a disconnect; it only swaps identity. READING DATA: a payload's fields and notes are authoritative \u2014 state what they say, never speculate past them, and when the data does not carry something, say 'the data does not carry X'. Field meanings live in guide topic 'reading-data'; `reading` notes inside a result are interpretation instructions for that exact payload \u2014 follow them over any prior assumption.";